AdsConnection Class

ADS Connection class

Inheritance Hierarchy

System.Object
  TwinCAT.Ads.AdsConnection
Namespace:  TwinCAT.Ads
Assembly:  TwinCAT.Ads (in TwinCAT.Ads.dll) Version: 4.3.0.0

Syntax

C#

public sealed class AdsConnection : IAdsConnection, 
    IConnection, IConnectionStateProvider, IAdsNotifications, IAdsAnyAccess, IAdsHandleAccess, 
    ITcAdsRpcInvoke, IDisposable

VB

Public NotInheritable Class AdsConnection
    Implements IAdsConnection, IConnection, IConnectionStateProvider, IAdsNotifications, 
    IAdsAnyAccess, IAdsHandleAccess, ITcAdsRpcInvoke, IDisposable

The AdsConnection type exposes the following members.

Properties

 

Name

Description

AccessWaitTime

Gets the access wait time.

ActiveSince

Gets the UTC time when tha last active/resurrected Connection was established

Address

Gets the AmsAddress of the ADS server.

ClientAddress

Get the AmsAddress of the ADS client.

ConnectionEstablishedAt

Gets the UTC time when the Connection was originally established.

ConnectionLostCount

Gets the connection lost count.

ConnectionLostTime

Gets the connection lost time.

ConnectionState

Gets the current Connection state of the AdsConnection

Disposed

Gets a value indicating whether this AdsConnection is disposed.

Id

Gets the AdsConnection identifier.

IsActive

Gets a value indicating whether communication is in active state

IsConnected

Gets a value indicating whether the local ADS port was opened successfully. It does not indicate if the target port is available. Use the method ReadState to determine if the target port is available.

IsLocal

Gets a value indicating whether the ADS client is connected to a ADS Server on the local computer.

IsLost

Gets a value indicating whether the communication is in lost / open state

IsReconnecting

Gets a value indicating whether communication is ready for reconnecting

Name

Gets the name.

ResurrectingTries

Gets the number of tries to resurrect the AdsConnection.

Resurrections

Gets the number of succeeded connection resurrections.

Session

Gets the Session object of the AdsConnection object.

State

Gets the current ConnectionState

Timeout

Gets the timeout (in milliseconds)

Methods

 

Name

Description

AddDeviceNotification(String, AdsStream, AdsTransMode, Int32, Int32, Object)

Connects a variable to the ADS client. The ADS client will be notified by the AdsNotification event.

AddDeviceNotification(UInt32, UInt32, AdsStream, AdsTransMode, Int32, Int32, Object)

Connects a variable to the ADS client. The ADS client will be notified by the AdsNotification event.

AddDeviceNotification(String, AdsStream, Int32, Int32, AdsTransMode, Int32, Int32, Object)

Adds the device notification.

AddDeviceNotification(UInt32, UInt32, AdsStream, Int32, Int32, AdsTransMode, Int32, Int32, Object)

Connects a variable to the ADS client. The ADS client will be notified by the AdsNotification event.

AddDeviceNotificationEx(String, AdsTransMode, Int32, Int32, Object, Type)

Connects a variable to the ADS client. The ADS client will be notified by the AdsNotification event.

AddDeviceNotificationEx(String, AdsTransMode, Int32, Int32, Object, Type, .Int32.)

Connects a variable to the ADS client. The ADS client will be notified by the AdsNotification event.

AddDeviceNotificationEx(UInt32, UInt32, AdsTransMode, Int32, Int32, Object, Type)

Connects a variable to the ADS client. The ADS client will be notified by the AdsNotification event.

AddDeviceNotificationEx(UInt32, UInt32, AdsTransMode, Int32, Int32, Object, Type, .Int32.)

Connects a variable to the ADS client. The ADS client will be notified by the AdsNotification event. If type is a string type, the first element of the parameter args specifies the number of characters of the string. If type is an array type, the number of elements for each dimension has to be specified in the parameter args. At the moment only 1 dimensional Arrays are supported.

Close

Closes the AdsConnection

Connect

(Re)Connects the IConnection when disconnected.

CreateSymbolLoader

Creates a new instance of the Symbol loader with the specified mode.

CreateVariableHandle

Generates a unique handle for an ADS variable.

DeleteDeviceNotification

Deletes an existing notification.

DeleteVariableHandle

Releases the handle of a ADS variable again.

Disconnect

Disconnects this IConnection.

Dispose

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Equals

Determines whether the specified object is equal to the current object. (Inherited from Object.)

GetHashCode

Serves as the default hash function. (Inherited from Object.)

GetType

Gets the Type of the current instance. (Inherited from Object.)

InvokeRpcMethod(String, Int32, .Object.)

Invokes the specified RPC Method

InvokeRpcMethod(String, String, .Object.)

Invokes the specified RPC Method

InvokeRpcMethod(ITcAdsSymbol, Int32, .Object.)

Invokes the specified RPC Method

InvokeRpcMethod(ITcAdsSymbol, String, .Object.)

Invokes the specified RPC Method.

Read(Int32, AdsStream)

Reads data synchronously from an ADS device and writes it to the given stream.

Read(UInt32, UInt32, AdsStream)

Reads data synchronously from an ADS device and writes it to the given stream.

Read(Int32, AdsStream, Int32, Int32)

Reads data synchronously from an ADS device and writes it to the given stream.

Read(UInt32, UInt32, .Byte., Int32, Int32)

Reads data synchronously from an ADS device and writes it to the given stream.

Read(UInt32, UInt32, AdsStream, Int32, Int32)

Reads data synchronously from an ADS device and writes it to the given stream.

Read(UInt32, UInt32, .Byte., Int32, Int32, Int32)

Reads data synchronously from an ADS device and writes it to the given stream.

Read(UInt32, UInt32, AdsStream, Int32, Int32, Int32)

Reads data synchronously from an ADS device and writes it to the given stream.

ReadAny(Int32, Type)

Reads data synchronously from an ADS device and writes it to an object.

ReadAny(Int32, Type, .Int32.)

Reads any.

ReadAny(UInt32, UInt32, Type)

Reads data synchronously from an ADS device and writes it to an object.

ReadAny(UInt32, UInt32, Type, .Int32.)

Reads data synchronously from an ADS device and writes it to an object. If the Type of the object to be read is a string type, the first element of the parameter args specifies the number of characters of the string. If the Type of the object to be read is an array type, the number of elements for each dimension has to be specified in the parameter args. At the moment only 1 dimensional Arrays are supported.

ReadAny(UInt32, UInt32, Type, .Int32., Int32)

Reads data synchronously from an ADS device and writes it to an object. If the Type of the object to be read is a string type, the first element of the parameter args specifies the number of characters of the string. If the Type of the object to be read is an array type, the number of elements for each dimension has to be specified in the parameter args. At the moment only 1 dimensional Arrays are supported.

ReadAnyString(Int32, Int32, Encoding)

Reads the string.

ReadAnyString(UInt32, UInt32, Int32, Encoding)

Reads the string

ReadDeviceInfo

Reads the identification and version number of an ADS server.

ReadState.

Reads the ADS status and the device status from an ADS server.

ReadState(Int32)

Reads the ADS status and the device status from an ADS server.

ReadSymbol(ITcAdsSymbol)

Reads the value of a symbol and returns it as an object. Strings and all primitive datatypes(UInt32, Int32, Bool etc.) are supported. Arrays and structures cannot be read.

ReadSymbol(String, Type, Boolean)

Reads the value of a symbol and returns the value as object. The parameter type must have the same layout as the ADS symbol.

ReadSymbolInfo

Call this method to obtain information about the individual symbols (variables) in ADS devices.

ReadWrite(UInt32, UInt32, AdsStream, AdsStream)

Writes data synchronously to an ADS device and then Reads data from this device.

ReadWrite(UInt32, UInt32, AdsStream, AdsStream, Int32)

Writes data synchronously to an ADS device and then Reads data from this device.

ReadWrite(Int32, AdsStream, Int32, Int32, AdsStream, Int32, Int32)

Writes data synchronously to an ADS device and then Reads data from this device.

ReadWrite(UInt32, UInt32, .Byte., Int32, Int32, .Byte., Int32, Int32)

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

ReadWrite(UInt32, UInt32, AdsStream, Int32, Int32, AdsStream, Int32, Int32)

Writes data synchronously to an ADS device and then Reads data from this device.

ReadWrite(UInt32, UInt32, .Byte., Int32, Int32, .Byte., Int32, Int32, Int32)

Writes data synchronously to an ADS device and then Reads data from this device.

ReadWrite(UInt32, UInt32, AdsStream, Int32, Int32, AdsStream, Int32, Int32, Int32)

Writes data synchronously to an ADS device and then Reads data from this device.

ToString

Returns a string that represents the current object. (Inherited from Object.)

TryAddDeviceNotification

Connects a variable to the ADS client. The ADS client will be notified by the AdsNotification event.

TryAddDeviceNotificationEx

Connects a variable to the ADS client. The ADS client will be notified by the AdsNotification event.

TryDeleteDeviceNotification

Deletes an existing notification.

TryInvokeRpcMethod(String, Int32, .Object., Object.)

Invokes the specified RPC Method

TryInvokeRpcMethod(String, String, .Object., Object.)

Invokes the specified RPC Method

TryInvokeRpcMethod(ITcAdsSymbol, Int32, .Object., Object.)

Invokes the specified RPC Method

TryInvokeRpcMethod(ITcAdsSymbol, String, .Object., Object.)

Invokes the specified RPC Method.

TryRead(Int32, AdsStream, Int32, Int32, Int32.)

Reads data synchronously from an ADS device and writes it to the given stream.

TryRead(UInt32, UInt32, .Byte., Int32, Int32, Int32.)

Reads data synchronously from an ADS device and writes it to the given stream.

TryRead(UInt32, UInt32, AdsStream, Int32, Int32, Int32.)

Reads data synchronously from an ADS device and writes it to the given stream.

TryRead(UInt32, UInt32, .Byte., Int32, Int32, Int32, Int32.)

Reads data synchronously from an ADS device and writes it to the given stream.

TryRead(UInt32, UInt32, AdsStream, Int32, Int32, Int32, Int32.)

Reads data synchronously from an ADS device and writes it to the given stream.

TryReadState(StateInfo.)

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 successful.

TryReadState(Int32, StateInfo.)

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.

TryReadWrite(Int32, AdsStream, Int32, Int32, AdsStream, Int32, Int32, Int32.)

Writes data synchronously to an ADS device and then Reads data from this device.

TryReadWrite(UInt32, UInt32, .Byte., Int32, Int32, .Byte., Int32, Int32, Int32.)

Writes data synchronously to an ADS device and then Reads data from this device.

TryReadWrite(UInt32, UInt32, AdsStream, Int32, Int32, AdsStream, Int32, Int32, Int32.)

Writes data synchronously to an ADS device and then Reads data from this device.

TryReadWrite(UInt32, UInt32, .Byte., Int32, Int32, .Byte., Int32, Int32, Int32, Int32.)

Writes data synchronously to an ADS device and then Reads data from this device.

TryReadWrite(UInt32, UInt32, AdsStream, Int32, Int32, AdsStream, Int32, Int32, Int32, Int32.)

Writes data synchronously to an ADS device and then Reads data from this device.

TryWrite(Int32, AdsStream, Int32, Int32)

Writes data synchronously to an ADS device.

TryWrite(UInt32, UInt32, .Byte., Int32, Int32)

Writes data synchronously to an ADS device.

TryWrite(UInt32, UInt32, AdsStream, Int32, Int32)

Writes data synchronously to an ADS device.

TryWrite(UInt32, UInt32, .Byte., Int32, Int32, Int32)

Writes data synchronously to an ADS device.

TryWrite(UInt32, UInt32, AdsStream, Int32, Int32, Int32)

Writes data synchronously to an ADS device.

TryWriteControl(StateInfo)

Changes the ADS status and the device status of an ADS server.

TryWriteControl(StateInfo, Int32)

Changes the ADS status and the device status of an ADS server.

TryWriteControl(StateInfo, AdsStream, Int32, Int32)

Changes the ADS status and the device status of an ADS server.

TryWriteControl(StateInfo, AdsStream, Int32, Int32, Int32)

Changes the ADS status and the device status of an ADS server.

Write(Int32, AdsStream)

Writes data synchronously to an ADS device.

Write(UInt32, UInt32)

Trigger Client Method/Command.

Write(UInt32, UInt32, Int32)

Trigger Client Method/Command.

Write(UInt32, UInt32, AdsStream)

Writes data synchronously to an ADS device.

Write(Int32, AdsStream, Int32, Int32)

Writes data synchronously to an ADS device.

Write(UInt32, UInt32, AdsStream, Int32)

Writes data synchronously to an ADS device.

Write(UInt32, UInt32, .Byte., Int32, Int32)

Writes data synchronously to an ADS device.

Write(UInt32, UInt32, AdsStream, Int32, Int32)

Writes data synchronously to an ADS device.

Write(UInt32, UInt32, .Byte., Int32, Int32, Int32)

Writes data synchronously to an ADS device.

Write(UInt32, UInt32, AdsStream, Int32, Int32, Int32)

Writes data synchronously to an ADS device.

WriteAny(Int32, Object)

Writes an object synchronously to an ADS device.

WriteAny(Int32, Object, .Int32.)

Writes an object synchronously to an ADS device. If the Type of the object to be written is a string type, the first element of parameter args specifies the number of characters of the string.

WriteAny(UInt32, UInt32, Object)

Writes an object synchronously to an ADS device.

WriteAny(UInt32, UInt32, Object, .Int32.)

Writes an object synchronously to an ADS device. If the Type of the object to be written is a string type, the first element of parameter args specifies the number of characters of the string.

WriteAny(UInt32, UInt32, Object, .Int32., Int32)

Writes an object synchronously to an ADS device. If the Type of the object to be written is a string type, the first element of parameter args specifies the number of characters of the string.

WriteControl(StateInfo)

Changes the ADS status and the device status of an ADS server.

WriteControl(StateInfo, Int32)

Changes the ADS status and the device status of an ADS server.

WriteControl(StateInfo, AdsStream, Int32, Int32)

Changes the ADS status and the device status of an ADS server.

WriteControl(StateInfo, AdsStream, Int32, Int32, Int32)

Changes the ADS status and the device status of an ADS server.

WriteSymbol(ITcAdsSymbol, Object)

Writes a value to the symbol. Strings and all primitive data types(UInt32, Int32, Bool etc.) are supported. Array and structures are not supported. If a string is passed as parameter, the method attempts to parse the string according to the ADS data type of the symbol.

WriteSymbol(String, Object, Boolean)

Writes the passed object value to the specified ADS symbol.The parameter type must have the same layout as the ADS symbol.

Events

 

Name

Description

AdsNotification

Occurs when the ADS device sends a notification to the client.

AdsNotificationError

Occurs when a exception has occurred during notification management.

AdsNotificationEx

Occurs when the ADS devices sends a notification to the client.

AdsStateChanged

Occurs when ADS State has been changed.

AdsSymbolVersionChanged

Occurs when the symbol version has been changed.

AmsRouterNotification

Occurs when the Route sends an Notification.

ConnectionStateChanged

Occurs when connection status of the AdsConnection has been changed.

Extension Methods

 

Name

Description

PollAdsState(IObservable.Unit.)

Overloaded.

Gets an observable sequence of AdsStates via Polling. (Defined by AdsClientExtensions.)

PollAdsState(TimeSpan)

Overloaded.

Gets an observable sequence of AdsStates via Polling. (Defined by AdsClientExtensions.)

PollValues(String, Type, IObservable.Unit.)

Overloaded.

Polls the symbol values on timepoints where the polling observable streams data / triggers (Defined by AnyTypeExtensions.)

PollValues(String, Type, TimeSpan)

Overloaded.

Polls the symbol as value sequence of object values with a specified period time. (Defined by AnyTypeExtensions.)

PollValues(String, Type, .Int32., TimeSpan)

Overloaded.

Polls the symbol as value sequence of object values with a specified period time. (Defined by AnyTypeExtensions.)

PollValues(String, Type, IObservable.Unit., Func.Exception, Object.)

Overloaded.

Polls the symbol values on timepoints where the polling observable streams data / triggers (Defined by AnyTypeExtensions.)

PollValues(String, Type, TimeSpan, Func.Exception, Object.)

Overloaded.

Polls the symbol as value sequence of object values with a specified period time. (Defined by AnyTypeExtensions.)

PollValues(String, Type, .Int32., IObservable.Unit., Func.Exception, Object.)

Overloaded.

Polls the symbol values on time points where the polling observable streams data / triggers (Defined by AnyTypeExtensions.)

PollValues(String, Type, .Int32., TimeSpan, Func.Exception, Object.)

Overloaded.

Polls the symbol as value sequence of object values with a specified period time. (Defined by AnyTypeExtensions.)

PollValues.T.(String, IObservable.Unit.)

Overloaded.

Polls the symbol values on timepoints where the polling observable streams data / triggers (Defined by AnyTypeExtensions.)

PollValues.T.(String, TimeSpan)

Overloaded.

Polls the symbol as value sequence of object values with a specified period time. (Defined by AnyTypeExtensions.)

PollValues.T.(String, IObservable.Unit., Func.Exception, T.)

Overloaded.

Polls the symbol values on timepoints where the polling observable streams data / triggers (Defined by AnyTypeExtensions.)

PollValues.T.(String, TimeSpan, Func.Exception, T.)

Overloaded.

Polls the symbol as value sequence of object values with a specified period time. (Defined by AnyTypeExtensions.)

PollValues.T.(String, .Int32., IObservable.Unit.)

Overloaded.

Polls the symbol values on time points where the polling observable streams data / triggers (Defined by AnyTypeExtensions.)

PollValues.T.(String, .Int32., TimeSpan)

Overloaded.

Polls the symbol as value sequence of object values with a specified period time. (Defined by AnyTypeExtensions.)

PollValues.T.(String, .Int32., IObservable.Unit., Func.Exception, T.)

Overloaded.

Polls the symbol values on timepoints where the polling observable streams data / triggers (Defined by AnyTypeExtensions.)

PollValues.T.(String, .Int32., TimeSpan, Func.Exception, T.)

Overloaded.

Polls the symbol as value sequence of object values with a specified period time. (Defined by AnyTypeExtensions.)

WhenNotification(ISymbol)

Overloaded.

Gets an observable sequence of Notifications. (Defined by AdsClientExtensions.)

WhenNotification(ISymbolCollection)

Overloaded.

Gets an observable sequence of Notification objects. (Defined by AdsClientExtensions.)

WhenNotification(ISymbol, NotificationSettings)

Overloaded.

Gets an observable sequence of Notifications. (Defined by AdsClientExtensions.)

WhenNotification(ISymbolCollection, NotificationSettings)

Overloaded.

Gets an observable sequence of Notification objects. (Defined by AdsClientExtensions.)

WhenValueChanged

Observable sequence of Values driven by ADS Notifications on the specified symbol. (Defined by ValueSymbolExtensions.)

WriteValues.T.(String, IObservable.T.)

Overloaded.

Writes the sequence of values to the symbol specified by the instance path. (Defined by AnyTypeExtensions.)

WriteValues.T.(String, IObservable.T., Action.Exception.)

Overloaded.

Writes the sequence of values to the symbol specified by the instance path. (Defined by AnyTypeExtensions.)

Remarks

The ADS Connection class represents an ADS Point-to-Point Connection between client and server. It is established by using the Connect method of the AdsSession object. An ADS Connection can have different ConnectionStates, which represent the state of the logical ADS connection.

Reference

TwinCAT.Ads Namespace

TwinCAT.Ads.AdsSession

TwinCAT.Ads.IAdsConnection

System.IDisposable