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: 6.0.328+39e3229
Syntax
C#
public class SumAnyTypeRead : SumSymbolReadBase,
ISumRead2<ISymbol>, ISumCommand
The SumAnyTypeRead type exposes the following members.
Constructors
|
Name |
Description |
---|---|---|
|
Initializes a new instance of the SumAnyTypeRead class. |
Methods
|
Name |
Description |
---|---|---|
|
Creates the SumCommand results (abstract) (Overrides SumSymbolReadBase.createResults(IList.SumDataEntity., IList.ReadOnlyMemory.Byte.., .AdsErrorCode.).) | |
|
Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
|
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
|
Serves as the default hash function. (Inherited from Object.) | |
|
Gets the Type of the current instance. (Inherited from Object.) | |
|
Creates a shallow copy of the current Object. (Inherited from Object.) | |
|
Reads the Values. | |
|
Read as an asynchronous operation. | |
|
Returns a string that represents the current object. (Inherited from Object.) |
Extension Methods
|
Name |
Description |
---|---|---|
|
Gets a value indicating, that all SubCommands failed. (Defined by ISumCommandExtension.) | |
|
Gets a value indicating, that all SubCommands succeeded. (Defined by ISumCommandExtension.) | |
|
Gets the first SubError that is not NoError (Defined by ISumCommandExtension.) | |
|
Gets a value indicating, whether the overall Sumcommand failed (checking all subcommand results). (Defined by ISumCommandExtension.) | |
|
Gets a value indicating, whether the overall SumCommand succeeded (including all subcommands) (Defined by ISumCommandExtension.) | |
|
Gets the Overall (combined error) from SumCommand AND SubCommands. (Defined by ISumCommandExtension.) | |
|
Overloaded. Polls a series of symbols via a ISumRead2.S. command. The SumCommand will read all contained values with every trigger in one roundtrip. (Defined by ValueSymbolExtensions.) | |
|
Overloaded. Polls a series of symbols via a ISumRead2.S. command. The SumCommand will read all contained values with every trigger. (Defined by ValueSymbolExtensions.) |
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 SumHandleRead,SumHandleWrite) 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).
Examples
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,Type,int[] args)> instancePathList = new List<(ISymbol, Type, int[] args)>(){
(var1Sym, typeof(bool), null),
(var2Sym, typeof(short), null),
(projectNameSym,typeof(string),new int[] {63}) // See ANY_TYPE specifications
};
SumAnyTypeRead sumRead = new SumAnyTypeRead(client, instancePathList);
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
TwinCAT.Ads.SumCommand.ISumCommand
TwinCAT.Ads.SumCommand.ISumRead2.S.
SumRead