SumInstancePathAnyTypeRead Class

SumRead Command that uses the instancePath as symbol ID / Address and returns objects as Values (ANY Type marshaling)

Inheritance Hierarchy

SystemObject
  SumCommandWrapperSumReadWrite
    SumInstancePathCommandSumReadWrite, String
      TwinCAT.Ads.SumCommandSumInstancePathAnyTypeRead

Namespace: TwinCAT.Ads.SumCommand
Assembly: TwinCAT.Ads (in TwinCAT.Ads.dll) Version: 7.0.0+e56d35ccc4675faac24789a4aab60071fc61d470

Syntax

C#

public class SumInstancePathAnyTypeRead : SumInstancePathCommand<SumReadWrite, string>

The SumInstancePathAnyTypeRead type exposes the following members.

Constructors

 

Name

Description

SumInstancePathAnyTypeRead(IAdsConnection, IListValueTupleString, AnyTypeSpecifier)

Initializes a new instance of the SumRead class.

SumInstancePathAnyTypeRead(IAdsConnection, IListValueTupleString, AnyTypeSpecifier, SumFallbackMode)

Initializes a new instance of the SumRead class.

Methods

 

Name

Description

Equals

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

Finalize

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)

GetHashCode

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

GetType

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

MemberwiseClone

Creates a shallow copy of the current Object.
(Inherited from Object)

Read

Reads all the values in one ADS roundtrip and returns an result object containing all the SumCommand SubResults.

ReadAsync

Reads all the values as an asynchronous operation in one ADS roundtrip and returns an result object containing all the SumCommand SubResults.

ToString

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

Remarks

The return value results will be produced by the AnyTypeMarshaler and must be predefined following the ANY_TYPE concept. Therefore a list of specifiers must be specified for the SumInstancePathAnyTypeRead constructor. The internal single value reads are done by ValueByName / ValueByName.

Example

Usage of the SumInstancePathAnyTypeRead SumCommand

AmsAddress address = new AmsAddress(AmsNetId.Local, AmsPort.PlcRuntime_851);

CancellationTokenSource cancelSource = new CancellationTokenSource();
CancellationToken cancel = cancelSource.Token;

using (AdsClient client = new AdsClient())
{
    // Connect the AdsClient to the device target.
    client.Connect(address);

    // Load symbolic information
    ISymbolLoader loader = SymbolLoaderFactory.Create(client, SymbolLoaderSettings.Default);
    var resultReadSymbols = await loader.GetSymbolsAsync(cancel);
    resultReadSymbols.ThrowOnError();

    ISymbolCollection<ISymbol> allSymbols = resultReadSymbols.Symbols;

    ISymbol var1Sym = allSymbols["GVL.bVar1"];
    ISymbol var2Sym = allSymbols["GVL.iCount"];
    ISymbol projectNameSym = allSymbols["TwinCAT_SystemInfoVarList._AppInfo.ProjectName"];

    // Define the ANY_TYPE specifiers
    List<(ISymbol,AnyTypeSpecifier spec)> instancePathList = new List<(ISymbol, AnyTypeSpecifier spec)>(){
    (var1Sym, new AnyTypeSpecifier(typeof(bool), (int[]) null)),
    (var2Sym, new AnyTypeSpecifier(typeof(short), (int[]) null)),
    (projectNameSym,new AnyTypeSpecifier(typeof(string),new int[] {63})) // See ANY_TYPE specifications
    };
    SumAnyTypeRead sumRead = new SumAnyTypeRead(client, instancePathList, SumFallbackMode.All);

    var resultRead = await sumRead.Read2Async(cancel);

    if (resultRead.Succeeded)
    {
    foreach (var subResult in resultRead.ValueResults)
    {
        Console.WriteLine($"Symbol: {subResult.Source}, Value: {subResult.Value}, ErrorCode: {(AdsErrorCode) subResult.ErrorCode}");
    }

    var var1Value = (bool)resultRead.ValueResults[0].Value;
    var var2Value = (short)resultRead.ValueResults[1].Value;
    var projectName = (string)resultRead.ValueResults[2].Value;
    }

Reference

TwinCAT.Ads.SumCommand Namespace

Beckhoff Automation GmbH & Co. KG 2001-2026