TcAdsClient.ReadAny Method (UInt32, UInt32, Type)

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

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

Syntax

C#

public Object ReadAny(
    uint indexGroup,
    uint indexOffset,
    Type type
)

VB

Public Function ReadAny ( 
    indexGroup As UInteger,
    indexOffset As UInteger,
    type As Type
) As Object

Parameters

indexGroup

Type: System.UInt32
Index group of the ADS variable.

indexOffset

Type: System.UInt32
Index offset of the ADS variable.

type

Type: System.Type
Type of the object to be read.

Return Value

Type: Object
The object the read data is written to.

Implements

IAdsAnyAccess.ReadAny(UInt32, UInt32, Type)

Examples

Usage of ReadAny/WriteAny

using (TcAdsClient client = new TcAdsClient())
{
    UInt32 valueToRead = 0;
    UInt32 valueToWrite = 42;

    client.Connect(AmsNetId.Local, 851);
    adsClient.WriteAny(0x4020, 0x0, valueToWrite);
    valueToRead = (uint)adsClient.ReadAny(0x4020, 0x0, typeof(UInt32));
}

Reference

TcAdsClient Class

ReadAny Overload

TwinCAT.Ads Namespace