Introduction

The TwinCAT ADS WCF Service is based on the TwinCAT.Ads DLL and provides access to ads devices via Windows Communication Foundation (WCF) technology.

API
Simplex Methods
Duplex Methods
Callbacks
Endpoints


Notes on the documentation

This description is only intended for the use of trained specialists in control and automation engineering who are familiar with the applicable national standards.
It is essential that the following notes and explanations are followed when installing and commissioning these components.

The responsible staff must ensure that the application or use of the products described satisfy all the requirements for safety, including all the relevant laws, regulations, guidelines and standards.

Disclaimer

The documentation has been prepared with care. The products described are, however, constantly under development.
For that reason the documentation is not in every case checked for consistency with performance data, standards or other characteristics.
In the event that it contains technical or editorial errors, we retain the right to make alterations at any time and without warning.
No claims for the modification of products that have already been supplied may be made on the basis of the data, diagrams and descriptions in this documentation.

Trademarks

Beckhoff®, TwinCAT®, EtherCAT®, Safety over EtherCAT®, TwinSAFE® and XFC® are registered trademarks of and licensed by Beckhoff Automation GmbH.
Other designations used in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owners.

Patent Pending

The TwinCAT Technology is covered, including but not limited to the following patent applications and patents:
EP0851348, US6167425 with corresponding applications or registrations in various other countries.

Copyright

© Beckhoff Automation GmbH & Co. KG, Germany.
The reproduction, distribution and utilization of this document as well as the communication of its contents to others without express authorization are prohibited.
Offenders will be held liable for the payment of damages. All rights reserved in the event of the grant of a patent, utility model or design.


Safety reference

TwinCAT ADS WCFDS WCF

Safety references

The TwinCAT ADS WCF service provides access through different endpoints. Some of them are implemented without security features to provide better performance and should only be used in secured intranet environments. These endpoints are marked with the Unsec prefix.

If you want the TwinCAT ADS WCF service to be reachable via the Internet, you should ensure that these endpoints are not reachable.

Secured endpoints

If you want to use the secured endpoints of the TwinCAT ADS WCF service you have to use a SSL encoded port for communication and the authentication is based on Windows credentials.

You can use your own certificates for SSL encoding or you can use a self signed certificate generated by the TcAdsWcfCertGen.exe tool.

Configure a port with an SSL certificate

Microsoft provides port configuration tools for the different versions of Microsoft Windows. A manual for configuring a port with an SSL certificate can be found here.


TcAdsWcfCertGen.exe

TcAdsWcfCertGen is a console application which will create a self signed certificate for SSL encoding.
TcAdsWcfCertGen is stored in the TcAdsWcf installation directory.

Usage: TcAdsWcfCertGen.exe DOMAINNAME

Parameters

DOMAINNAME

The name of the Domain which will be used to reach the TwinCAT ADS WCF service.

Example

If the TwinCAT ADS WCF service should be reachable over the url http://www.beckhoff.com/TwinCAT/Ads/Wcf/TcAdsService you have to use the following command to create a certificate with TcAdsWcfCertGen:

TcAdsWWcfCertGen.exe www.beckhoff.com

This will generate a certificate with the common name www.beckhoff.com which can be used for SSL encoding.


ITcAdsServiceSimplex

The ITcAdsServiceSimplex interface provides access to the features which are available with the simplex endpoints of the TwinCAT Ads WCF Service.

Methods and Properties

ITcAdsServiceSimplex Methods | Description
Read1 | Reads data from an ADS device and writes it to the given byte array reference.
Read2 | Reads data from an ADS device and writes it to the given byte array reference.
Read3 | Reads data from an ADS device and writes it to the given byte array reference.
ReadDeviceInfo | Reads the identification and version number of an ADS server.
ReadState | Reads the ADS status and the device status from an ADS server.
ReadWrite1 | Writes data to an ADS device and then reads data from this device.
ReadWrite2 | Writes data to an ADS device and then reads data from this device.
ReadWrite3 | Writes data to an ADS device and then reads data from this device.
ReadWrite4 | Writes data to an ADS device and then reads data from this device.
TryReadState | Reads the ADS status and the device status from an ADS server. Unlike the ReadState method this method does not call an exception on failure. Instead an AdsErrorCode is returned. If the return value is equal to AdsErrorCode.NoError the call was successfull.
Write1 | Writes data to an ADS device.
Write2 | Writes data to an ADS device.
Write3 | Writes data to an ADS device.
Write4 | Writes data to an ADS device.
Write5 | Writes data to an ADS device.
Write6 | Writes data to an ADS device.
Write7 | Writes data to an ADS device.
Write8 | Writes data to an ADS device.
WriteControl1 | Changes the ADS status and the device status of an ADS server.
WriteControl2 | Writes the passed object value to the specified ADS symbol.The parameter type must have the same layout as the ADS symbol.


ITcAdsServiceSimplex.Read1

Reads data from an ADS device and writes it to the given byte array reference.
byte[ ] Read1 (
    string netId,
    int port,
    string variableName,
    int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
variableName
Name of the ADS symbol.
length
The length of the returned byte array.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.Read2

Reads data from an ADS device and writes it to the given byte array reference.
byte[ ] Read2 (
    string netId,
    int port,
    int indexGroup,
    int indexOffset,
    int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
length
The length of the returned byte array.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.Read3

Reads data from an ADS device and writes it to the given byte array reference.
byte[ ] Read3 (
    string netId,
    int port,
    long indexGroup,
    long indexOffset,
    int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
length
The length of the returned byte array.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.ReadDeviceInfo

Reads the identification and version number of an ADS server.
DeviceInfo ReadDeviceInfo (
    string netId,
    int port
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.

Return Value

DeviceInfo struct containing the name of the device and the version information.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.ReadState

Reads the ADS status and the device status from an ADS server.
StateInfo ReadState (
    string netId,
    int port
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.

Return Value

The ADS statue and device status.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.ReadWrite1

Writes data to an ADS device and then reads data from this device.

byte[ ] ReadWrite1 (
    string netId,
    int port,
    int indexGroup,
    int indexOffset,
    int rdLength,
    byte [ ] wrbuffer
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
rdLength
The length of the returned byte array.
wrbuffer
Byte array that contains the data that should be written.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.ReadWrite2

Writes data to an ADS device and then reads data from this device.

byte[ ] ReadWrite2 (
    string netId,
    int port,
    long indexGroup,
    long indexOffset,
    int rdLength
    byte [ ] wrbuffer
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
rdLength
The length of the returned byte array.
wrbuffer
Byte array that contains the data that should be written.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.ReadWrite3

Writes data to an ADS device and then reads data from this device.

byte[ ] ReadWrite3 (
    string netId,
    int port,
    int indexGroup,
    int indexOffset,
    int rdLength,
    byte [ ] wrbuffer,
    int wrOffset,
    int wrLength
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
rdLength
The length of the returned byte array.
wrbuffer
Byte array that contains the data that should be written.
wrOffset
Offset of the data in wrbuffer.
wrLength
Length of the data in wrbuffer.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.ReadWrite4

Writes data to an ADS device and then reads data from this device.

byte[ ] ReadWrite4 (
    string netId,
    int port,
    long indexGroup,
    long indexOffset,
    int rdLength,
    byte [ ] wrbuffer,
    int wrOffset,
    int wrLength
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
rdLength
The length of the returned byte array.
wrbuffer
Byte array that contains the data that should be written.
wrOffset
Offset of the data in wrbuffer.
wrLength
Length of the data in wrbuffer.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.TryReadState

Reads the ADS status and the device status from an ADS server. Unlike the ReadState method this method does not call an exception on failure. Instead an AdsErrorCode is returned. If the return value is equal to AdsErrorCode.NoError the call was successfull.
int TryReadState (
    string netId,
    int port,
    out StateInfo stateInfo
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
stateInfo
Output reference of type StateInfo which will receive the data.

Return Value

AdsErrorCode

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.Write1

Writes data to an ADS device.
void Write1 (
    string netId,
    int port ,
    string variableName,
    byte [ ] buffer
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
variableName
Name of the ADS symbol.
buffer
Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.Write2

Writes data to an ADS device.
void Write2 (
    string netId,
    int port,
    int indexGroup,
    int indexOffset,
    byte [ ] buffer
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
buffer
Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.Write3

Writes data to an ADS device.
void Write3 (
    string netId,
    int port,
    long indexGroup,
    long indexOffset,
    byte [ ] buffer
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
buffer
Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.Write4

Writes data to an ADS device.
void Write4 (
    string netId,
    int port,
    string variableName,
    byte [ ] buffer,
    int offset,
    int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
variableName
Name of the ADS symbol.
buffer
Byte array that contains the data.
offset
Offset of the data in buffer.
length
Length of the data in buffer.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.Write5

Writes data to an ADS device.
void Write5 (
     string netId,
     int port,
     int indexGroup,
     int indexOffset,
     byte [ ] buffer,
     int offset,
     int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
buffer
Byte array that contains the data.
offset
Offset of the data in buffer.
length
Length of the data in buffer.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.Write6

Writes data to an ADS device.
void Write6 (
     string netId,
     int port,
     long indexGroup,
     long indexOffset,
     byte [ ] buffer,
     int offset,
     int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
buffer
Byte array that contains the data.
offset
Offset of the data in buffer.
length
Length of the data in buffer.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceDuplex.Write6

TwinCAT ADS WCF

ITcAdsServiceSimplex.Write7

Writes data to an ADS device.
void Write7(
    string netId,
    int port,
    int indexGroup,
    int indexOffset);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceDuplex.Write6

TwinCAT ADS WCF

ITcAdsServiceSimplex.Write8

Writes data to an ADS device.
void Write8(
    string netId,
    int port,
    long indexGroup,
    long indexOffset);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.WriteControl1

Changes the ADS status and the device status of an ADS server.
 void WriteControl1 (
    string netId,
    int port,
    StateInfo stateInfo
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
stateInfo
New ADS status and device status.

SOAP Error Faults

Type | Description
 | AdsErrorFaulthe AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceSimplex.WriteControl2

Changes the ADS status and the device status of an ADS server.
 void WriteControl2 (
    string netId,
    int port,
    StateInfo stateInfo,
    byte [ ] buffer,
    int offset,
    int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
stateInfo
New ADS status and device status.
buffer
Byte array that contains the data that should be sent to the ADS device.
offset
Offset of the data in buffer.
length
Length of the data in buffer.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceSimplex Interface


ITcAdsServiceDuplex

The ITcAdsServiceDuplex interface provides access to the features which are available with the duplex endpoints of the TwinCAT Ads WCF Service.

Methods and Properties

ITcAdsServiceDuplex Methods | Description
SubscribeAdsNotificationEvent | Subscribes to the AdsNotificationEventHandler of the associated TcAdsClient. Callbacks will be passed through the ITcAdsServiceCallbaks.AdsNotification method.
SubscribeAdsNotificationErrorEvent | Subscribes to the AdsNotificationErrorEventHandler of the associated TcAdsClient. Callbacks will be passed through the ITcAdsServiceCallbaks.AdsNotificationError method.
SubscribeAdsStateChangedEvent | Subscribes to the AdsStateChangedEventHandler of the associated TcAdsClient. Callbacks will be passed through the ITcAdsServiceCallbaks.AdsStateChanged method.
SubscribeAdsSymbolVersionChangedEvent | Subscribes to the AdsSymbolVersionChangedEventHandler of the associated TcAdsClient. Callbacks will be passed through the ITcAdsServiceCallbaks.AdsSymbolVersionChanged method.
SubscribeAmsRouterNotificationEvent | Subscribes to the AmsRouterNotificationEventHandler of the associated TcAdsClient. Callbacks will be passed through the ITcAdsServiceCallbaks.AmsRouterNotification method.
AddDeviceNotification1 | Connects a variable to the associated TcAdsClient. The notification will be passed through the ITcAdsServiceCallbaks.AdsNotification method if the ITcAdsServiceDuplex .SubscibeAdsNotificationEvent method was called successfully.
AddDeviceNotification2 | Connects a variable to the associated TcAdsClient. The notification will be passed through the ITcAdsServiceCallbaks.AdsNotification method if the ITcAdsServiceDuplex .SubscibeAdsNotificationEvent method was called successfully.
AddDeviceNotification3 | Connects a variable to the associated TcAdsClient. The notification will be passed through the ITcAdsServiceCallbaks.AdsNotification method if the ITcAdsServiceDuplex .SubscibeAdsNotificationEvent method was called successfully.
AddBufferedDeviceNotification1 | Connects a variable to the associated TcAdsClient. The notification will be passed through the ITcAdsServiceCallbaks.AdsNotification method if the ITcAdsServiceDuplex .SubscibeAdsNotificationEvent method was called successfully.
AddBufferedDeviceNotification2 | Connects a variable to the associated TcAdsClient. The notification will be passed through the ITcAdsServiceCallbaks.AdsNotification method if the ITcAdsServiceDuplex .SubscibeAdsNotificationEvent method was called successfully.
AddBufferedDeviceNotification3 | Connects a variable to the associated TcAdsClient. The notification will be passed through the ITcAdsServiceCallbaks.AdsNotification method if the ITcAdsServiceDuplex .SubscibeAdsNotificationEvent method was called successfully.
DeleteDeviceNotification | Deletes an existing notification.
GetTimeout | Gets the timeout for the associated TcAdsClient.
SetTimeout | Sets the timeout for the associated TcAdsClient.
Read1 | Reads data from an ADS device and writes it to the given byte array reference.
Read2 | Reads data from an ADS device and writes it to the given byte array reference.
Read3 | Reads data from an ADS device and writes it to the given byte array reference.
ReadDeviceInfo | Reads the identification and version number of an ADS server.
ReadState | Reads the ADS status and the device status from an ADS server.
ReadWrite1 | Writes data to an ADS device and then reads data from this device.
ReadWrite2 | Writes data to an ADS device and then reads data from this device.
ReadWrite3 | Writes data to an ADS device and then reads data from this device.
ReadWrite4 | Writes data to an ADS device and then reads data from this device.
TryReadState | Reads the ADS status and the device status from an ADS server. Unlike the ReadState method this method does not call an exception on failure. Instead an AdsErrorCode is returned. If the return value is equal to AdsErrorCode.NoError the call was successfull.
Write1 | Writes data to an ADS device.
Write2 | Writes data to an ADS device.
Write3 | Writes data to an ADS device.
Write4 | Writes data to an ADS device.
Write5 | Writes data to an ADS device.
Write6 | Writes data to an ADS device.
Write7 | Writes data to an ADS device.
Write8 | Writes data to an ADS device.
WriteControl1 | Changes the ADS status and the device status of an ADS server.
WriteControl2 | Writes the passed object value to the specified ADS symbol.The parameter type must have the same layout as the ADS symbol.


ITcAdsServiceDuplex.SubscribeAdsNotificationEvent

Subscribes to the AdsNotificationEventHandler of the associated TcAdsClient. Callbacks will be passed through the ITcAdsServiceCallbaks.AdsNotification method.

void SubscribeAdsNotificationEvent (
    string netId,
    int port
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.

SOAP Error Faults

Type | Description
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.SubscribeAdsNotificationErrorEvent

Subscribes to the AdsNotificationErrorEventHandler of the associated TcAdsClient. Callbacks will be passed through the ITcAdsServiceCallbaks.AdsNotificationError method.

void SubscribeAdsNotificationErrorEvent (
    string netId,
    int port
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.

SOAP Error Faults

Type | Description
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.SubscribeAdsStateChangedEvent

Subscribes to the AdsStateChangedEventHandler of the associated TcAdsClient. Callbacks will be passed through the ITcAdsServiceCallbaks.AdsStateChanged method.

void SubscribeAdsStateChangedEvent (
    string netId,
    int port
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.

SOAP Error Faults

Type | Description
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.SubscribeAdsSymbolVersionChangedEvent

Subscribes to the AdsSymbolVersionChangedEventHandler of the associated TcAdsClient. Callbacks will be passed through the ITcAdsServiceCallbaks.AdsSymbolVersionChanged method.
void SubscribeAdsSymbolVersionChangedEvent (
    string netId,
    int port
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.

SOAP Error Faults

Type | Description
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.SubscribeAmsRouterNotificationEvent

Subscribes to the AmsRouterNotificationEventHandler of the associated TcAdsClient. Callbacks will be passed through the ITcAdsServiceCallbaks.AmsRouterNotification method.

void SubscribeAmsRouterNotificationEvent (
    string netId,
    int port
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.

SOAP Error Faults

Type | Description
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.AddDeviceNotification1

Connects a variable to the associated TcAdsClient. The notification will be passed through the ITcAdsServiceCallbaks.AdsNotification method if the ITcAdsServiceDuplex .SubscibeAdsNotificationEvent method was called successfully.

int AddDeviceNotification1 (
    string netId,
    int port,
    string variableName,
    int length,
    AdsTransMode transMode,
    int cycleTime,
    int maxDelay,
    object userData );
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
variableName
The name of the ADS symbol.
length
The length of the byte array buffer which will be returned by the AdsNotification callback.
transMode
Specifies if the event should be fired cyclically or only if the variable has changed.
cycleTime
The ADS server checks whether the variable has changed after this time interval. Unit is ms.
maxDelay
The AdsNotification event is fired at the latest when this time has elapsed. The unit is ms.
userData
This object can be used to store user specific data.
Only data types which can be serialized are allowed.

Return Value

The handle of the notification.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.AddDeviceNotification2

Connects a variable to the associated TcAdsClient. The notification will be passed through the ITcAdsServiceCallbaks.AdsNotification method if the ITcAdsServiceDuplex .SubscibeAdsNotificationEvent method was called successfully.

int AddDeviceNotification2 (
    string netId,
    int port,
    int indexGroup,
    int indexOffset,
    int length,
    AdsTransMode transMode,
    int cycleTime,
    int maxDelay,
    object userData );

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
length
The length of the byte array buffer which will be returned by the AdsNotification callback.
transMode
Specifies if the event should be fired cyclically or only if the variable has changed.
cycleTime
The ADS server checks whether the variable has changed after this time interval. Unit is ms.
maxDelay
The AdsNotification event is fired at the latest when this time has elapsed. The unit is ms.
userData
This object can be used to store user specific data.
Only data types which can be serialized are allowed.

Return Value

The handle of the notification.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.AddDeviceNotification3

Connects a variable to the associated TcAdsClient. The notification will be passed through the ITcAdsServiceCallbaks.AdsNotification method if the ITcAdsServiceDuplex .SubscibeAdsNotificationEvent method was called successfully.

int AddDeviceNotification3 (
    string netId,
    int port,
    long indexGroup,
    long indexOffset,
    int length,
    AdsTransMode transMode,
    int cycleTime,
    int maxDelay,
    object userData
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
length
The length of the byte array buffer which will be returned by the AdsNotification callback.
transMode
Specifies if the event should be fired cyclically or only if the variable has changed.
cycleTime
The ADS server checks whether the variable has changed after this time interval. Unit is ms.
maxDelay
The AdsNotification event is fired at the latest when this time has elapsed. The unit is ms.
userData
This object can be used to store user specific data.
Only data types which can be serialized are allowed.

Return Value

The handle of the notification.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.AddDeviceNotification3

TwinCAT ADS WCF

ITcAdsServiceDuplex.AddBufferedDeviceNotification1

Connects a variable to the associated TcAdsClient. The notification will be passed through the ITcAdsServiceCallbaks.AdsNotification method if the ITcAdsServiceDuplex .SubscibeAdsNotificationEvent method was called successfully.

int AddBufferedDeviceNotification1(
    string netId,
    int port,
    string variableName,
    int length,
    AdsTransMode transMode,
    int cycleTime,
    int maxDelay,
    int maxValues,
    object userData
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
variableName
The name of the ADS symbol.
length
The length of the byte array buffer which will be returned by the AdsNotification callback.
transMode
Specifies if the event should be fired cyclically or only if the variable has changed.
cycleTime
The ADS server checks whether the variable has changed after this time interval. Unit is ms.
maxDelay
The AdsNotification event is fired at the latest when this time has elapsed. The unit is ms.
maxValues
This values defines when a buffered notification is fired.
userData
This object can be used to store user specific data.
Only data types which can be serialized are allowed.

Return Value

The handle of the notification.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.AddDeviceNotification2

TwinCAT ADS WCF

ITcAdsServiceDuplex.AddBufferedDeviceNotification2

Connects a variable to the associated TcAdsClient. The notification will be passed through the ITcAdsServiceCallbaks.AdsNotification method if the ITcAdsServiceDuplex .SubscibeAdsNotificationEvent method was called successfully.

int AddBufferedDeviceNotification2 (
    string netId,
    int port,
    int indexGroup,
    int indexOffset,
    int length,
    AdsTransMode transMode,
    int cycleTime,
    int maxDelay,
    int maxValues,
    object userData
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
length
The length of the byte array buffer which will be returned by the AdsNotification callback.
transMode
Specifies if the event should be fired cyclically or only if the variable has changed.
cycleTime
The ADS server checks whether the variable has changed after this time interval. Unit is ms.
maxDelay
The AdsNotification event is fired at the latest when this time has elapsed. The unit is ms.
maxValues
This values defines when a buffered notification is fired.
userData
This object can be used to store user specific data.
Only data types which can be serialized are allowed.

Return Value

The handle of the notification.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.AddDeviceNotification3

TwinCAT ADS WCF

ITcAdsServiceDuplex.AddBufferedDeviceNotification3

Connects a variable to the associated TcAdsClient. The notification will be passed through the ITcAdsServiceCallbaks.AdsNotification method if the ITcAdsServiceDuplex .SubscibeAdsNotificationEvent method was called successfully.

int AddDeviceNotification3 (
    string netId,
    int port,
    long indexGroup,
    long indexOffset,
    int length,
    AdsTransMode transMode,
    int cycleTime,
    int maxDelay,
    int maxValues,
    object userData
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
length
The length of the byte array buffer which will be returned by the AdsNotification callback.
transMode
Specifies if the event should be fired cyclically or only if the variable has changed.
cycleTime
The ADS server checks whether the variable has changed after this time interval. Unit is ms.
maxDelay
The AdsNotification event is fired at the latest when this time has elapsed. The unit is ms.
maxValues
This values defines when a buffered notification is fired.
userData
This object can be used to store user specific data.
Only data types which can be serialized are allowed.

Return Value

The handle of the notification.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.DeleteDeviceNotification

Deletes an existing notification.

void DeleteDeviceNotification (
    string netId,
    int port,
    int notificationHandle );

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
notificationHandle
Handle of the notification.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.GetTimeout

Gets the timeout for the associated TcAdsClient.

int GetTimeout (
    string netId,
    int port
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.

Return Value

The actual timeout value in milliseconds.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsNotificationClientNotFoundErrorFault | The AdsNotificationClientNotFoundErrorFault is returned if a TcAdsClient object for AdsNotification through passing is not found in the NotificationClient cache of a wcf duplex context.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.SetTimeout

Sets the timeout for the associated TcAdsClient.

void SetTimeout (
    string netId,
    int port,
    int value
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
value
The timeout value in milliseconds.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsNotificationClientNotFoundErrorFault | The AdsNotificationClientNotFoundErrorFault is returned if a TcAdsClient object for AdsNotification through passing is not found in the NotificationClient cache of a wcf duplex context.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface | ITcAdsServiceDuplex Interface | ITcAdsServiceCallbacks Interface


ITcAdsServiceDuplex.Read1

Reads data from an ADS device and writes it to the given byte array reference.
byte[ ] Read1 (
    string netId,
    int port,
    string variableName,
    int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
variableName
Name of the ADS symbol.
length
The length of the returned byte array.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.Read2

Reads data from an ADS device and writes it to the given byte array reference.
byte[ ] Read2 (
    string netId,
    int port,
    int indexGroup,
    int indexOffset,
    int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
length
The length of the returned byte array.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.Read3

Reads data from an ADS device and writes it to the given byte array reference.
byte[ ] Read3 (
    string netId,
    int port,
    long indexGroup,
    long indexOffset,
    int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
length
The length of the returned byte array.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.ReadDeviceInfo

Reads the identification and version number of an ADS server.
DeviceInfo ReadDeviceInfo (
    string netId,
    int port
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.

Return Value

DeviceInfo struct containing the name of the device and the version information.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.ReadState

Reads the ADS status and the device status from an ADS server.
StateInfo ReadState (
    string netId,
    int port
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.

Return Value

The ADS statue and device status.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.ReadWrite1

Writes data to an ADS device and then reads data from this device.

byte[ ] ReadWrite1 (
    string netId,
    int port,
    int indexGroup,
    int indexOffset,
    int rdLength,
    byte [ ] wrbuffer
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
rdLength
The length of the returned byte array.
wrbuffer
Byte array that contains the data that should be written.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.ReadWrite2

Writes data to an ADS device and then reads data from this device.

byte[ ] ReadWrite2 (
    string netId,
    int port,
    long indexGroup,
    long indexOffset,
    int rdLength,
    byte [ ] wrbuffer
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
rdLength
The length of the returned byte array.
wrbuffer
Byte array that contains the data that should be written.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.ReadWrite3

Writes data to an ADS device and then reads data from this device.

byte[ ] ReadWrite3 (
    string netId,
    int port,
    int indexGroup,
    int indexOffset,
    int rdLength,
    byte [ ] wrbuffer,
    int wrOffset,
    int wrLength
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
rdLength
The length of the returned byte array.
wrbuffer
Byte array that contains the data that should be written.
wrOffset
Offset of the data in wrbuffer.
wrLength
Length of the data in wrbuffer.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.ReadWrite4

Writes data to an ADS device and then reads data from this device.

byte [ ] ReadWrite4 (
    string netId,
    int port,
    long indexGroup,
    long indexOffset,
    int rdLength,
    byte [ ] wrbuffer,
    int wrOffset,
    int wrLength
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
rdLength
The length of the returned byte array.
wrbuffer
Byte array that contains the data that should be written.
wrOffset
Offset of the data in wrbuffer.
wrLength
Length of the data in wrbuffer.

Return Value

Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.TryReadState

Reads the ADS status and the device status from an ADS server. Unlike the ReadState method this method does not call an exception on failure. Instead an AdsErrorCode is returned. If the return value is equal to AdsErrorCode.NoError the call was successfull.
int TryReadState (
    string netId,
    int port,
    out StateInfo stateInfo
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
stateInfo
Output reference of type StateInfo which will receive the data.

Return Value

AdsErrorCode

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.Write1

Writes data to an ADS device.
void Write1 (
    string netId,
    int port ,
    string variableName,
    byte [ ] buffer
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
variableName
Name of the ADS symbol.
buffer
Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.Write2

Writes data to an ADS device.
void Write2 (
    string netId,
    int port,
    int indexGroup,
    int indexOffset,
    byte [ ] buffer
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
buffer
Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.Write3

Writes data to an ADS device.
void Write3 (
    string netId,
    int port,
    long indexGroup,
    long indexOffset,
    byte [ ] buffer
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
buffer
Byte array that contains the data.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.Write4

Writes data to an ADS device.
void Write4 (
    string netId,
    int port,
    string variableName,
    byte [ ] buffer,
    int offset,
    int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
variableName
Name of the ADS symbol.
buffer
Byte array that contains the data.
offset
Offset of the data in buffer.
length
Length of the data in buffer.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.Write5

Writes data to an ADS device.
void Write5 (
     string netId,
     int port,
     int indexGroup,
     int indexOffset,
     byte [ ] buffer,
     int offset,
     int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
buffer
Byte array that contains the data.
offset
Offset of the data in buffer.
length
Length of the data in buffer.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.Write6

Writes data to an ADS device.
void Write6 (
     string netId,
     int port,
     long indexGroup,
     long indexOffset,
     byte [ ] buffer,
     int offset,
     int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.
buffer
Byte array that contains the data.
offset
Offset of the data in buffer.
length
Length of the data in buffer.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
ArgumentErrorFault | The ArgumentErrorFault is returned if there is a failure in an argument of a method.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.Write6

TwinCAT ADS WCF

ITcAdsServiceDuplex.Write7

Writes data to an ADS device.
void Write7(
    string netId,
    int port,
    int indexGroup,
    int indexOffset);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.Write6

TwinCAT ADS WCF

ITcAdsServiceDuplex.Write8

Writes data to an ADS device.
void Write8(
    string netId,
    int port,
    long indexGroup,
    long indexOffset);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
indexGroup
Contains the index group number of the requested ADS service.
indexOffset
Contains the index offset number of the requested ADS service.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.WriteControl1

Changes the ADS status and the device status of an ADS server.
 void WriteControl1 (
    string netId,
    int port,
    StateInfo stateInfo
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
stateInfo
New ADS status and device status.

SOAP Error Faults

Type | Description
 | AdsErrorFaulthe AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceDuplex.WriteControl2

Changes the ADS status and the device status of an ADS server.
 void WriteControl2 (
    string netId,
    int port,
    StateInfo stateInfo,
    byte [ ] buffer,
    int offset,
    int length
);

Parameters

netId
NetID of the target AMS Router.
port
Port of the target AMS Router.
stateInfo
New ADS status and device status.
buffer
Byte array that contains the data that should be sent to the ADS device.
offset
Offset of the data in buffer.
length
Length of the data in buffer.

SOAP Error Faults

Type | Description
AdsErrorFault | The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
AdsErrorErrorFault | The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.
UnexpectedErrorFault | The UnexpectedErrorFault is returned if an unexpected Error occurs.

See Also

ITcAdsServiceDuplex Interface


ITcAdsServiceCallbacks

The ITcAdsServiceCallbacks interface provides access to the callback methods of the duplex endpoints.

Methods and Properties

ITcAdsServiceCallbacks Methods | Description
AdsNotification | Passes through AdsNotificationEventHandler callback of the associated TcAdsClient. To subscribe to the AdsNotificationEventHandler the ITcAdsServiceDuplex.SubscribeAdsNotificationEvent method has to be called.
AdsNotificationError | Passes through AdsNotificationErrorEventHandler callback of the associated TcAdsClient. To subscribe to the AdsNotificationErrorEventHandler the ITcAdsServiceDuplex.SubscribeAdsNotificationErrorEvent method has to be called.
AdsStateChanged | Passes through AdsStateChangedEventHandler callback of the associated TcAdsClient. To subscribe to the AdsStateChangedEventHandler the ITcAdsServiceDuplex.SubscribeAdsStateChangedEvent method has to be called.
AdsSymbolVersionChanged | Passes through AdsSymbolVersionChangedEventHandler callback of the associated TcAdsClient. To subscribe to the AdsSymbolVersionChangedEventHandler the ITcAdsServiceDuplex.SubscribeAdsSymbolVersionChangedEvent method has to be called.
AmsRouterNotification | Passes through AmsRouterNotificationEventHandler callback of the associated TcAdsClient. To subscribe to the AmsRouterNotificationEventHandler the ITcAdsServiceDuplex.SubscribeAmsRouterNotificationEvent method has to be called.
HeartBeat | Used by the TwinCAT ADS WCF Service to test if the client application is still reachable. If the HeartBeat callback fails, the client will be set to a Faulted State.


ITcAdsServiceCallbacks.AdsNotification

Passes through AdsNotificationEventHandler callback of the associated TcAdsClient.
To subscribe to the AdsNotificationEventHandler the ITcAdsServiceDuplex.SubscribeAdsNotificationEvent method has to be called.

void AdsNotification (
        string netId,
        int port,
        byte [ ] buffer,
        int length,
        int notificationHandle,
        int offset,
        long timeStamp,
        object userData
);

Parameters

netId
NetID of the AMS Router.
port
Port of the AMS Router.
buffer
Byte array that holds the notification data.
Note: If you use buffered Notifications you will receive only one callback which contains all data.
length
The length of the data in buffer.
notificationHandle
The handle of the connection.
offset
The offset of the data in buffer.
timeStamp
The timestamp when the notification was raised.
userData
This object is passed by to AddDeviceNotification methods and can be used to store data.

See Also

ITcAdsServiceCallbacks Interface | ITcAdsServiceDuplex Interface


ITcAdsServiceCallbacks.AdsNotificationError

Passes through AdsNotificationErrorEventHandler callback of the associated TcAdsClient.
To subscribe to the AdsNotificationErrorEventHandler the ITcAdsServiceDuplex.SubscribeAdsNotificationErrorEvent method has to be called.

 void AdsNotificationError (
    string netId,
    int port,
    Exception error
);

Parameters

netId
NetID of the AMS Router.
port
Port of the AMS Router.
error
Exception that was caught while handling notifications.

See Also

ITcAdsServiceCallbacks Interface | ITcAdsServiceDuplex Interface


ITcAdsServiceCallbacks.AdsStateChanged

Passes through AdsStateChangedEventHandler callback of the associated TcAdsClient.
To subscribe to the AdsStateChangedEventHandler the ITcAdsServiceDuplex.SubscribeAdsStateChangedEvent method has to be called.

void AdsStateChanged (
    string netId,
    int port,
    StateInfo state
);

Parameters

netId
NetID of the AMS Router.
port
Port of the AMS Router.
state
Current state of the ADS device.

See Also

ITcAdsServiceCallbacks Interface | ITcAdsServiceDuplex Interface


ITcAdsServiceCallbacks.AdsSymbolVersionChanged

Passes through AdsSymbolVersionChangedEventHandler callback of the associated TcAdsClient.
To subscribe to the AdsSymbolVersionChangedEventHandler the ITcAdsServiceDuplex.SubscribeAdsSymbolVersionChangedEventHandler method has to be called.

void AdsSymbolVersionChanged (
    string netId,
    int port
);

Parameters

netId
NetID of the AMS Router.
port
Port of the AMS Router.

See Also

ITcAdsServiceCallbacks Interface | TcAdsServiceDuplex Interface


ITcAdsServiceCallbacks.AmsRouterNotification

Passes through AmsRouterNotificationEventHandler callback of the associated TcAdsClient.
To subscribe to the AmsRouterNotificationEventHandler the ITcAdsServiceDuplex.SubscribeAmsRouterNotificationEventHandler method has to be called.

void AmsRouterNotification (
    string netId,
    int port,
    AmsRouterState state
);

Parameters

netId
NetID of the AMS Router.
port
Port of the AMS Router.
state
Current state of the Ams Router.

See Also

ITcAdsServiceCallbacks Interface | ITcAdsServiceDuplex Interface


ITcAdsServiceCallbacks.AdsStateChanged

TwinCAT ADS WCF

ITcAdsServiceCallbacks.HeartBeat

Used by the TwinCAT ADS WCF Service to test if the client application is still reachable.
The HeartBeat will be send every 5 seconds.
If the HeartBeat callback fails, the client will be set to a Faulted State.
It can also be used to detect if the server is still alive.

void HeartBeat( );

See Also

ITcAdsServiceCallbacks Interface | ITcAdsServiceDuplex Interface


AdsErrorCode

public enum AdsErrorCode
{
    NoError = 0,
    InternalError = 1,
    NoRTime = 2,
    LockedMemoryError = 3,
    MailBoxError = 4,
    WrongHMsg = 5,
    TargetPortNotFound = 6,
    TargetMachineNotFound = 7,
    UnknownCommandID = 8,
    BadTaskID = 9,
    NoIO = 10,
    UnknwonAmsCommand = 11,
    Win32Error = 12,
    PortNotConnected = 13,
    InvalidAmsLength = 14,
    InvalidAmsNetID = 15,
    LowInstallLevel = 16,
    NoDebug = 17,
    PortDisabled = 18,
    PortConnected = 19,
    AmsSyncWin32Error = 20,
    SyncTimeOut = 21,
    AmsSyncAmsError = 22,
    AmsSyncNoIndexMap = 23,
    InvalidAmsPort = 24,
    NoMemory = 25,
    TCPSendError = 26,
    HostUnreachable = 27,
    NoLockedMemory = 1280,
    MailboxFull = 1282,
    DeviceError = 1792,
    DeviceServiceNotSupported = 1793,
    DeviceInvalidGroup = 1794,
    DeviceInvalidOffset = 1795,
    DeviceInvalidAccess = 1796,
    DeviceInvalidSize = 1797,
    DeviceInvalidData = 1798,
    DeviceNotReady = 1799,
    DeviceBusy = 1800,
    DeviceInvalidContext = 1801,
    DeviceNoMemory = 1802,
    DeviceInavlidParam = 1803,
    DeviceNotFound = 1804,
    DeviceSyntaxError = 1805,
    DeviceIncompatible = 1806,
    DeviceSymbolNotFound = 1808,
    DeviceSymbolVersionInvalid = 1809,
    DeviceInvalidState = 1810,
    DeviceTransModeNotSupported = 1811,
    DeviceNotifyHandleInvalid = 1812,
    DeviceClientUnknown = 1813,
    DeviceNoMoreHandles = 1814,
    DeviceInvalidWatchsize = 1815,
    DeviceNotInitialized = 1816,
    DeviceTimeOut = 1817,
    DeviceNoInterface = 1818,
    DeviceInvalidInterface = 1819,
    DeviceInvalidCLSID = 1820,
    DeviceInvalidObjectID = 1821,
    ClientError = 1856,
    ClientInvalidParameter = 1857,
    ClientListEmpty = 1858,
    ClientVaraiableInUse = 1859,
    ClientDuplicateInvokeID = 1860,
    ClientSyncTimeOut = 1861,
    ClientW32OR = 1862,
    ClientTimeoutInvalid = 1863,
    ClientPortNotOpen = 1864,
    ClientNoAmsAddr = 1865,
    ClientSyncInternal = 1872,
    ClientAddHash = 1873,
    ClientRemoveHash = 1874,
    ClientNoMoreSymbols = 1875,
    ClientSyncResInvalid = 1876,
    ClientSyncPortLocked = 1877,
    ClientQueueFull = 32768,
}

Members

Member Name | Description
NoError | No Error. Error code: 0(0x000).
InternalError | Internal Error. Error code: 1(0x001).
NoRTime | No Rtime. Error code: 2(0x002).
LockedMemoryError | Allocation locked memory error. Error code: 3(0x003).
MailBoxError | Insert mailbox error. Error code: 4(0x004).
WrongHMsg | Wrong receive HMSG. Error code: 5(0x005).
TargetPortNotFound | Target port not found. Error code: 6(0x006).
TargetMachineNotFound | Target machine not found. Error code: 7(0x007).
UnknownCommandID | Unknown command ID. Error code: 8(0x008).
BadTaskID | Bad task ID. Error code: 9(0x009).
NoIO | No IO. Error code: 10(0x00A).
UnknownAmsCommand | Unknown AMS command. Error code: 11(0x00B).
Win32Error | Win 32 error. Error code: 12(0x00C).
PortNotConnected | Port is not connected. Error code: 13(0x00D).
InvalidAmsLength | Invalid AMS length. Error code: 14(0x00E).
InvalidAmsNetID | Invalid AMS Net ID. Error code: 15(0x00F).
LowInstallLevel | Low Installation level. Error code: 16(0x010).
NoDebug | No debug available. Error code: 17(0x011).
PortDisabled | Port disabled. Error code: 18(0x012).
PortConnected | Port is already connected. Error code: 19(0x013).
AmsSyncWin32Error | AMS Sync Win32 error. Error code: 20(0x014).
SyncTimeOut | AMS Sync timeout. Error code: 21(0x015).
AmsSyncAmsError | AMS Sync AMS error Error code: 22(0x016).
AmsSyncNoIndexMap | AMS Sync no index map. Error code: 23(0x017).
InvalidAmsPort | Invalid AMS port. Error code: 24(0x018).
NoMemory | No memory. Error code: 25(0x019).
TCPSendError | TCP send error. Error code: 26(0x01A).
HostUnreachable | Host unreachable. Error code: 27(0x1B).
NoLockedMemory | Router: no locked memory. Error code: 1280(0x500).
MailboxFull | Router: mailbox full. Error code: 1282(0x501).
DeviceError | error class <device error"> Error code: 1792(0x700).
DeviceServiceNotSupported | Service is not supported by server. Error code: 1793(0x701).
DeviceInvalidGroup | Invalid index group. Error code: 1794(0x702).
DeviceInvalidOffset | Invalid index offset. Error code: 1795(0x703).
DeviceInvalidAccess | Reading/writing not permitted. Error code: 1796(0x704).
DeviceInvalidSize | Parameter size not correct. Error code: 1797(0x705).
DeviceInvalidData | Invalid parameter value(s). Error code: 1798(0x706).
DeviceNotReady | Device is not in a ready state. Error code: 1799(0x707).
DeviceBusy | Device is busy. Error code: 1800(0x708).
DeviceInvalidContext | Invalid context (must be in Windows). Error code: 1801(0x709).
DeviceNoMemory | Out of memory. Error code: 1802(0x70a).
DeviceInavlidParam | Invalid parameter value(s). Error code: 1803(0x70b).
DeviceNotFound | Not found (files, ...). Error code: 1804(0x70c).
DeviceSyntaxError | Syntax error in command or file. Error code: 1805(0x70d).
DeviceIncompatible | Objects do not match. Error code: 1806(0x70e).
DeviceExists | Object already exists. Error code: 1807(0x70f).
DeviceSymbolNotFound | Symbol not found. Error code: 1808(0x7010).
DeviceSymbolVersionInvalid | Symbol version is invalid. Error code: 1809(0x711).
DeviceInvalidState | Server is not i a valid state. Error code: 1810(0x712).
DeviceTransModeNotSupported | ADS transmode is not supported. Error code: 1811(0x713).
DeviceNotifyHandleInvalid | Notification handle is invalid. Error code: 1812(0x714).
DeviceClientUnknown | Notification client not registered. Error code: 1813(0x715).
DeviceNoMoreHandles | No more notification handles. Error code: 1814(0x716).
DeviceInvalidWatchsize | Size for watch to big. Error code: 1815(0x717).
DeviceNotInitialized | Device is not initialized. Errocr code: 1818(0x718).
DeviceTimeOut | Device has a timeout. Error code: 1817(0x719).
DeviceNoInterface | Query interface has failed. Error code: 1818(0x71A).
DeviceInvalidInterface | Wrong interface required. Error code: 1819(0x71B).
DeviceInvalidCLSID | Class ID is invalid. Error code: 1820(0x71C).
DeviceInvalidObjectID | Object ID is invalid. Error code: 1821(0x71D).
ClientError | Error class <client error> Error code: 1856(0x740).
ClientInvalidParameter | Parameter at service is invalid. Error code: 1857(0x741).
ClientListEmpty | Polling list is empty. Error code: 1858(0x742).
ClientVaraiableInUse | Variable connection is already in use. Error code: 1859(0x743).
ClientDuplicateInvokeID | Invoke ID already in use. Error code: 1860(0x744).
ClientSyncTimeOut | Timeout has elapsed. Error code: 1861(x745).
ClientW32OR | Error in win32 subsystem. Error code: 1862(0x746).
ClientTimeoutInvalid | Timeout value is invalid. Error code: 1863(0x747).
ClientPortNotOpen | Ads port is not opened. Error code: 1864(0x748).
ClientNoAmsAddr | No AMS addr. Error code: 1865(0x749).
ClientSyncInternal | An internal in ADS sync has occured. Error code: 1872(0x750).
ClientAddHash | Hash table overflow. Error code: 1873(0x751).
ClientRemoveHash | There are no more symbols in the hash table. Error code: 1874(0x752).
ClientNoMoreSymbols | There are no more symbols in cache. Error code: 1875(0x753).
ClientSyncResInvalid | An invalid response has been received. Error code: 1876(0x754).
ClientSyncPortLocked | Sync port is locked. Error code: 1877(0x755).
ClientQueueFull | Client queue is full


AdsReservedIndexGroups

public enum AdsReservedIndexGroups
{
    PlcRWMX = 16416,
    PlcRWMB = 16416,
    PlcRWRB = 16432,
    PlcRWDB = 16448,
    SymbolTable = 61440,
    SymbolName = 61441,
    SymbolValue = 61442,
    SymbolHandleByName = 61443,
    SymbolValueByName = 61444,
    SymbolValueByHandle = 61445,
    SymbolReleaseHandle = 61446,
    SymbolInfoByName = 61447,
    SymbolVersion = 61448,
    SymbolInfoByNameEx = 61449,
    SymbolDownload = 61450,
    SymbolUpload = 61451,
    SymbolUploadInfo = 61452,
    SymbolNote = 61456,
    IOImageRWIB = 61472,
    IOImageRWIX = 61473,
    IOImageRWOB = 61488,
    IOImageRWOX = 61489,
    IOImageClearI = 61504,
    IOImageClearO = 61520,
    DeviceData = 61696,
}

Members

Member Name | Description
PlcRWMB |
PlcRWMX |
PlcRWRB |
PlcRWDB |
SymbolTable |
SymbolName |
SymbolValue |
SymbolHandleByName |
SymbolValueByName |
SymbolValueByHandle |
SymbolReleaseHandle |
SymbolInfoByName |
SymbolVersion |
SymbolInfoByNameEx |
SymbolDownload |
SymbolUpload |
SymbolUploadInfo |
SymbolNote |
IOImageRWIB |
IOImageRWIX |
IOImageRWOB |
IOImageRWOX |
IOImageClearI |
IOImageClearO |
DeviceData |


AdsReservedIndexOffset

public enum AdsReservedIndexOffset
{
    DeviceDataAdsState = 0,
    DeviceDataDeviceState = 2,
    DeviceDataConfigID = 4,
}

Members

Member Name | Description
DeviceDataAdsState |
DeviceDataDeviceState |
DeviceDataConfigID |


AdsState

public enum AdsState
{
    Invalid = 0,
    Idle = 1,
    Reset = 2,
    Init = 3,
    Start = 4,
    Run = 5,
    Stop = 6,
    SaveConfig = 7,
    LoadConfig = 8,
    PowerFailure = 9,
    PowerGood = 10,
    Error = 11,
    Shutdown = 12,
    Suspend = 13,
    Resume = 14,
    Config = 15,
    Reconfig = 16,
    Maxstates = 17,
}

Members

Member Name | Description
Invalid | invalided state
Idle | idle state
Reset | reset state
Init | initialized
Start | started
Run | running
Stop | stopped
SaveConfig | saved configuration
LoadConfig | load configuration
PowerFailure | power failure
PowerGood | power good
Error | error state
Shutdown | shutting down
Suspend | suspended
Resume | resumed
Config | system is in config mode
Reconfig | system should restart in config mode
Maxstates |


AdsTransMode

public enum AdsTransMode
{
    Cyclic = 3,
    OnChange = 4,
}

Members

Member Name | Description
Cyclic | The AdsSyncNotification-Event is fired cyclically.
OnChange | The AdsSyncNotification-Event is fired when the data changes.


AmsPort

public enum AmsPort
{
    Router = 1,
    Debugger = 2,
    Logger = 100,
    EventLog = 110,
    R0_Realtime = 200,
    R0_Trace = 290,
    R0_IO = 300,
    R0_NC = 500,
    R0_NCSAF = 501,
    R0_NCSVB = 511,
    R0_ISG = 550,
    R0_CNC = 600,
    R0_LINE = 700,
    R0_PLC = 800,
    PlcRuntime1 = 801,
    PlcRuntime2 = 811,
    PlcRuntime3 = 821,
    PlcRuntime4 = 831,
    CamshaftController = 900,
    R0_CAMTOOL = 950,
    R0_USER = 2000,
    R3_CTRLPROG = 10000,
    SystemService = 10000,
    R3_SYSCTRL = 10001,
    R3_SYSSAMPLER = 10100,
    R3_TCPRAWCONN = 10200,
    R3_TCPIPSERVER = 10201,
    R3_SYSMANAGER = 10300,
    R3_SMSSERVER = 10400,
    R3_MODBUSSERVER = 10500,
    R3_S7SERVER = 10600,
    R3_PLCCONTROL = 10800,
    R3_NCCTRL = 11000,
    R3_NCINTERPRETER = 11500,
    R3_STRECKECTRL = 12000,
    R3_CAMCTRL = 13000,
    R3_SCOPE = 14000,
    R3_SINECH1 = 15000,
    R3_CONTROLNET = 16000,
    R3_OPCSERVER = 17000,
    R3_OPCCLIENT = 17500,
    USEDEFAULT = 65535,
}

Members

Member Name | Description
Router | AmsRouter
Debugger | AmsDebugger
Logger | Logger
EventLog | Event Logger
R0_Realtime | R0 Realtime
R0_Trace | R0 Trace
R0_IO | R0 IO
R0_NC | NC (R0)
R0_NCSAF | R0 Satzausführung
R0_NCSVB | R0 Satzvorbereitung
R0_ISG | R0 ISG
R0_CNC | R0 CNC
R0_LINE | R0 Line
R0_PLC | R0 PLC
PlcRuntime1 | PLC RuntimeSystem 1
PlcRuntime2 | PLC RuntimeSystem 2
PlcRuntime3 | PLC RuntimeSystem 3
PlcRuntime4 | PLC RuntimeSystem 4
CamshaftController | Camshaft Controller (R0)
R0_CAMTOOL | R0 CAM Tool
R0_USER | R0 User
SystemService | System Service (AMSPORT_R3_SYSSERV, 10000)
R3_CTRLPROG |
R3_SYSCTRL |
R3_SYSSAMPLER |
R3_TCPRAWCONN |
R3_TCPIPSERVER |
R3_SYSMANAGER |
R3_SMSSERVER |
R3_MODBUSSERVER |
R3_S7SERVER |
R3_PLCCONTROL |
R3_NCCTRL |
R3_NCINTERPRETER |
R3_STRECKECTRL |
R3_CAMCTRL |
R3_SCOPE |
R3_SINECH1 |
R3_CONTROLNET |
R3_OPCSERVER |
R3_OPCCLIENT |
USEDEFAULT |


AmsRouterState

public enum AmsRouterState
{
    Stop = 0,
    Start = 1,
    Removed = 2,
}

Members

Member Name | Description
Stop | Ams Router is stopped.
Start | Ams Router is started.
Removed | Ams Router has been removed.


DeviceInfo

The DeviceInfo structure contains the name and the version information of the device.

public struct DeviceInfo
{
    public string Name { get; set; }
    public AdsVersion Version { get; set; }
}

StateInfo Properties | Description
Name | Gets or sets the name of the device.
Version | Gets or sets the version information.


StateInfo

The StateInfo structure contains the Ads state and device state.

public struct StateInfo
{
    public AdsState AdsState { get; set; }
    public short DeviceState { get; set; }
}

StateInfo Properties | Description
AdsState | Gets or sets the Ads state.
DeviceState | Gets or sets the device state.


AdsVersion

The DeviceInfo structure contains the name and the version information of the device.

public struct AdsVersion
{
    public int Build { get; set; }
    public byte Revision { get; set; }
    public byte Version { get; set; }
}

StateInfo Properties | Description
Build | Gets or sets the build number.
Revision | Gets or sets the revision number.
Version | Gets or sets the version number.


AdsErrorFault

The AdsErrorFault is returned if an AdsException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.

Properties

Property | Description
string Message | Description of the Error which causes the ErrorFault.


AdsErrorErrorFault

The AdsErrorErrorFault is returned if an AdsErrorException is thrown by a TcAdsClient object in a method of the TwinCAT ADS WCF service.

Properties

Property | Description
string Message | Description of the Error which causes the ErrorFault.
AdsErrorCode ErrorCode | The AdsErrorCode of the AdsErrorException.


ArgumentErrorFault

The ArgumentErrorFault is returned if there is a failure in an argument of a method.

Properties

Property | Description
string Message | Description of the Error which causes the ErrorFault.


AdsNotificationClientNotFoundErrorFault

The AdsNotificationClientNotFoundErrorFault is returned if a TcAdsClient object for AdsNotification through passing is not found in the NotificationClient cache of a wcf duplex context.

Properties

Property | Description
string Message | Description of the Error which causes the ErrorFault.


UnexpectedErrorFault

The UnexpectedErrorFault is returned if an unexpected Error occurs.

Properties

Property | Description
string Message | Description of the Error which causes the ErrorFault.


Endpoints

Name | Description
UnsecNetTcp | duplex / unsecured
SecNetTcp | duplex / secured
UnsecWsDualHttp | duplex / unsecured
SecWsDualHttp | duplex / secured
UnsecPollingDuplex3 | duplex / unsecured
SecPollingDuplex3 | duplex / secured
UnsecPollingDuplex4 | duplex / unsecured
SecPollingDuplex4 | duplex / secured
UnsecBasicHttp | simplex / unsecured
SecBasicHttp | simplex / secured
UnsecWebHttp | simplex / unsecured
SecWebHttp | simplex / secured

See Also

Safety references


SecBasicHttp

TwinCAT ADS WCF

SecWebHttp

Address: https://[target_name]:8002/TwinCAT/Ads/Wcf/TcAdsService/SecWebHttp

The SecWebHttp endpoint provides secured access to the TcAdsService WCF service in a simplex context via http.

See Also

Safety references


SecBasicHttp

TwinCAT ADS WCF

UnsecWebHttp

Address: https://[target_name]:8002/TwinCAT/Ads/Wcf/TcAdsService/UnsecWebHttp

The UnsecWebHttp endpoint provides unsecured access to the TcAdsService WCF service in a simplex context via http.

See Also

Safety references


SecBasicHttp

Address: https://[target_name]:8002/TwinCAT/Ads/Wcf/TcAdsService/SecBasicHttp

The SecBasicHttp endpoint provides secured access to the TcAdsService WCF service in a simplex context via http.

See Also

Safety references


UnsecBasicHttp

Address: http://[target_name]:8003/TwinCAT/Ads/Wcf/TcAdsService/UnsecBasicHttp

The UnsecBasicHttp endpoint provides unsecured access to the TcAdsService WCF service in a simplex context via http.

See Also

Safety references


SecWsDualHttp

Address: https://[target_name]:8002/TwinCAT/Ads/Wcf/TcAdsService/SecWsDualHttp

The SecWsDualHttp endpoint provides secured access to the TcAdsService WCF service in a duplex context via http.

See Also

Safety references


UnsecWsDualHttp

Address: http://[target_name]:8003/TwinCAT/Ads/Wcf/TcAdsService/UnsecWsDualHttp

The UnsecWsDualHttp endpoint provides unsecured access to the TcAdsService WCF service in a duplex context via http.

See Also

Safety references


SecNetTcp

Address: net.tcp://[target_name]:4508/TwinCAT/Ads/Wcf/TcAdsService/SecNetTcp

The SecNetTcp endpoint provides secured access to the TcAdsService WCF service in a duplex context via tcp.

See Also

Safety references


UnsecNetTcp

Address: net.tcp://[target_name]:4508/TwinCAT/Ads/Wcf/TcAdsService/UnsecNetTcp

The UnsecNetTcp endpoint provides unsecured access to the TcAdsService WCF service in a duplex context via tcp.

See Also

Safety references


SecPollingDuplex3

Address: https://[target_name]:8002/TwinCAT/Ads/Wcf/TcAdsService/SecPollingDuplex3

The SecPollingDuplex3 endpoint provides secured access to the TcAdsService WCF service in a duplex context via http for Silverlight 3 applications.

See Also

Safety references


UnsecPollingDuplex3

Address: http://[target_name]:8003/TwinCAT/Ads/Wcf/TcAdsService/UnsecPollingDuplex3

The UnsecPollingDuplex3 endpoint provides unsecured access to the TcAdsService WCF service in a duplex context via http for Silverlight 3 applications.

See Also

Safety references


SecPollingDuplex4

Address: https://[target_name]:8002/TwinCAT/Ads/Wcf/TcAdsService/SecPollingDuplex4

The SecPollingDuplex4 endpoint provides secured access to the TcAdsService WCF service in a duplex context via http for Silverlight 4 applications.

See Also

Safety references


UnsecPollingDuplex4

Address: http://[target_name]:8003/TwinCAT/Ads/Wcf/TcAdsService/UnsecPollingDuplex4

The UnsecPollingDuplex endpoint provides unsecured access to the TcAdsService WCF service in a duplex context via http for Silverlight 4 applications.

See Also

Safety references


ClientAccessPolicyProvider

The ClientAccessPolicyProvider is a WCF (Windows Communication Foundation) service which provides access to the ClientAccessPolicy.xml via HTTP Get on the defined base addresses.

If a web client makes a call to a WCF service like the TcAdsService, it will ask for the ClientAccessPolicy.xml file to determine whether cross domain access to this resource is allowed or not.

Web clients connected over Net.Tcp are requesting the ClientAccessPolicy.xml on port 80.

If the Internet Information Services (IIS) are running, they will listening for ClientAccessPolicy.xml request on port 80.
In this case the ClientAccessPolicy.xml has to be placed in the wwwroot directory. The default path is: "C:\Intepub\wwwroot\".

If the Internet Information Services (IIS) are not installed the ClientAccessPolicyProvider has to be listening on port 80. Therefore the base address "http://localhost:80/" has to be added to the App.config of the TcAdsWcfHost.exe application. The base address of the ClientAccessPolicyProvider service must also be adjusted if the default base addresses of the TcAdsService have changed.


ClientAccessPolicy.xml

The ClientAccessPolicy.xml is used by web clients to determine if cross domain access is allowed or not.

MSDN about ClientAccessPolicy.xml and Silverlight

The default ClientAccessPolicy.xml configuration of the TwinCAT ADS WCF.
The default configuration should not be used in production environments.
<?xml version="1.0" encoding="utf-8"?>
    <access-policy>
        <cross-domain-access>
            <policy>
                <allow-from http-request-headers="*">
                    <domain uri="http://*"/>
                    <domain uri="https://*"/>
                </allow-from>
                <grant-to>
                    <resource path="/" include-subpaths="true"/>
                    <socket-resource port="4502-4534" protocol="tcp"/>
                </grant-to>
            </policy>
        </cross-domain-access>
    </access-policy>


Create a WCF service reference in Visual Studio

In order to create a WCF service reference in Visual Studio you must choose the command Add Service Reference... under the Project menu.
This opens the Add Service Reference dialog:

In the dialog enter the htttp or the https based base address of the TcAdsService and press the GO button.
This will load the service meta data and create the needed client code.
After that the service reference will be listed in the Solution Explorer with the chosen namespace.