SumHandleRead Class
Read (primitive, Any) values by Handle SumCommand.
Inheritance Hierarchy
System.Object
SumCommand
SumRead
TwinCAT.Ads.SumCommand.SumHandleRead
Namespace: TwinCAT.Ads.SumCommand
Assembly: TwinCAT.Ads (in TwinCAT.Ads.dll)
Version: 4.3.0.0
Syntax
C#
public class SumHandleRead : SumRead
VB
Public Class SumHandleRead
Inherits SumRead
The SumHandleRead type exposes the following members.
Methods
|
Name |
Description |
---|---|---|
|
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. | |
|
Returns a string that represents the current object. (Inherited from Object.) | |
|
Tries to read the values of the . |
Remarks
This is an ADS Sum Command to access values by handle information. It is always used in combination with and . By design (and in contrast to the symbolic access in SumSymbolRead, SumSymbolWrite) this access method can act only with ADS ANY Type (Primitive) values (disadvantage). The Advantage is, that no symbolic information must be loaded before accessing the values, see samples:
Examples
Usage of Sum commands with handles (CreateHandles, Read, Write, ReleaseHandles)
/// <summary>
/// Defines the entry point of the application.
/// </summary>
/// <param name="args">The arguments.</param>
static void Main(string[] args)
{
Console.WriteLine("");
Console.WriteLine("Press [Enter] for start:");
Console.ReadLine();
// Parse the command-line arguments
AmsAddress address = ArgParser.Parse(args);
using (TcAdsClient client = new TcAdsClient())
{
// Connect the AdsClient to the device target.
client.Connect(address);
string[] instancePathList = {"GVL.bVar", "GVL.iCount", "TwinCAT_SystemInfoVarList._AppInfo.ProjectName"};
SumCreateHandles createHandlesCommand = new SumCreateHandles(client,instancePathList);
uint[] handles = createHandlesCommand.CreateHandles();
Type[] valueTypes = new Type[] { typeof(bool), typeof(short), typeof(string)};
SumHandleRead readCommand = new SumHandleRead(client,handles,valueTypes);
object[] readValues = readCommand.Read();
for (int i = 0; i < instancePathList.Length; i++)
{
Console.WriteLine("Symbol: {0} (Value: {1}, Type: {2})",instancePathList[i],readValues[i].ToString(),valueTypes[i].Name);
}
// Sum Command Write
SumHandleWrite writeCommand = new SumHandleWrite(client,handles,valueTypes);
object[] writeValues = new object[] {true, (short) 42, "MyNewProjectName"};
writeCommand.Write(writeValues);
SumReleaseHandles releaseCommand = new SumReleaseHandles(client,handles);
releaseCommand.ReleaseHandles();
}
Console.WriteLine("");
Console.WriteLine("Press [Enter] for leave:");
Console.ReadLine();
}
Reference
TwinCAT.Ads.SumCommand Namespace
TwinCAT.Ads.SumCommand.SumCreateHandles
TwinCAT.Ads.SumCommand.SumReleaseHandles
TwinCAT.Ads.SumCommand.ISumCommand
TwinCAT.Ads.SumCommand.SumReleaseHandles