SumAnyTypeRead Class
Symbolic ADS Sum read access (ANY_TYPE marshalling) on already loaded symbols.
Inheritance Hierarchy
System.Object
SumCommandWrapper<SumReadWrite>
SumSymbolCommand<SumReadWrite>
SumSymbolReadBase
TwinCAT.Ads.SumCommand.SumAnyTypeRead
Namespace: TwinCAT.Ads.SumCommand
Assembly: TwinCAT.Ads (in TwinCAT.Ads.dll) Version: 7.0.0+e56d35ccc4675faac24789a4aab60071fc61d470
Syntax
C#
public class SumAnyTypeRead : SumSymbolReadBase,
ISumRead2<ISymbol>, ISumCommandThe SumAnyTypeRead type exposes the following members.
Constructors
|
|
Name |
Description |
|---|---|---|
|
|
SumAnyTypeRead(IAdsConnection, IList<ValueTuple<ISymbol, AnyTypeSpecifier>>) |
Initializes a new instance of the SumAnyTypeRead class. |
|
|
SumAnyTypeRead(IAdsConnection, IList<ValueTuple<ISymbol, AnyTypeSpecifier>>, SumFallbackMode) |
Initializes a new instance of the SumAnyTypeRead class. |
Methods
|
|
Name |
Description |
|---|---|---|
|
|
Creates the SumCommand results (abstract)
| |
|
|
Determines whether the specified object is equal to the current object. | |
|
|
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. | |
|
|
Serves as the default hash function. | |
|
|
Gets the Type of the current instance. | |
|
|
Creates a shallow copy of the current Object. | |
|
|
Reads the Values. | |
|
|
Read as an asynchronous operation. | |
|
|
Returns a string that represents the current object. |
Extension Methods
|
|
Name |
Description |
|---|---|---|
|
|
Gets a value indicating, that all SubCommands failed.
| |
|
|
Gets a value indicating, that all SubCommands succeeded.
| |
|
|
Gets the first SubError that is not NoError | |
|
|
Gets a value indicating, whether the overall Sumcommand failed (checking all subcommand results).
| |
|
|
Gets a value indicating, whether the overall SumCommand succeeded (including all subcommands)
| |
|
|
Gets the Overall (combined error) from SumCommand AND SubCommands.
| |
|
|
Polls a series of symbols via a ISumRead2<S> command. The SumCommand will read all contained values with every trigger in one roundtrip.
| |
|
|
Polls a series of symbols via a ISumRead2<S> command. The SumCommand will read all contained values with every trigger.
|
Remarks
The SumAnyTypeRead implements symbolic read with predefined value marshalling. The requested value types are specified before calling the read operation an must fit to its symbol definition. The advantage of the symbolic access is (in contrast to the handle access classes SumHandleReadAnyType,SumHandleWriteAnyType) or the acess by instance path (SumInstancePathAnyTypeRead) that all type information is available when using this ADS Sum Command. The disadvantage is, that the Symbolic information must be loaded before using this SumCommand, see examples. The SumAnyTypeRead defaults to an InstancePath/SymbolName read (ValueByNameValueByName).
Example
Usage of the SumAnyTypeRead 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;
}See Also
Reference
TwinCAT.Ads.SumCommand Namespace ISumCommand ISumRead2<S>SumReadSumSymbolWriteSumInstancePathAnyTypeRead
Beckhoff Automation GmbH & Co. KG 2001-2026