Gets / Sets the PLC register value
Object value
Reading Values:
When reading from the PLC, you need to specify the DataType for the value being read.
Default data types for registers as follows:
%R, %AQ, %AI, %W, %BM - Int16
%M, %I, %Q, %S, %SA, %SB, %SC, %G, %T - Boolean
The Length property determines the number of contiguous number of PLC registers read. The .Value propery will be returned as a Array of the specified .DataType
Writing Values:
When setting the .Value for writing, the Type of the Object will be assigned to the PLC. See Tag.ATOMIC for supported data types.
Error Condition:
When an error occurs the .Value property will be returned as a null reference (Nothing in Visual Basic)
| Exception Type | Condition |
|---|---|
| ArgumentNullException | Thrown if Value property is a null reference (Nothing in Visual Basic) when setting. |
| ArgumentException | Thrown if Value property is an unsupported NetType |
VB
' * reading
Dim MyPLC As New GELink.Controller("192.168.1.45")
Dim MyTag As New GELink.Tag("%R1")
' * read %R1 as System.Int16 (default)
MyPLC.ReadTag(MyTag)
Console.WriteLine(MyTag.Value.ToString())
' * read %R1 as System.Int32
MyTag.DataType = ATOMIC.INT
MyPLC.ReadTag(MyTag)
Console.WriteLine(MyTag.Value.ToString())
' * read %R1 as System.Single
MyTag.DataType = ATOMIC.REAL
MyPLC.ReadTag(MyTag)
Console.WriteLine(MyTag.Value.ToString())
' * reading %R1 as an array
MyTag.DataType = ATOMIC.INT
MyTag.Length = 100
MyPLC.ReadTag(MyTag)
' * writing System.Int16
Dim _plcValue As System.Int
_plcValue = 123
MyTag.Value = _plcValue
MyPLC.WriteTag(MyTag)
C#
// reading
GELink.Controller MyPLC = new GELink.Controller("192.168.1.45");
GELink.Tag MyTag = new GELink.Tag("%R1");
// read %R1 as System.Int16 (default)
MyPLC.ReadTag(MyTag);
Console.WriteLine(MyTag.Value.ToString());
// read %R1 as System.Int32
MyTag.DataType = ATOMIC.INT;
MyPLC.ReadTag(MyTag);
Console.WriteLine(MyTag.Value.ToString());
// read %R1 as System.Single
MyTag.DataType = ATOMIC.REAL;
MyPLC.ReadTag(MyTag);
Console.WriteLine(MyTag.Value.ToString());
// reading %R1 as an array
MyTag.DataType = ATOMIC.INT;
MyTag.Length = 100;
MyPLC.ReadTag(MyTag);
// writing System.Int16
System.Int16 _plcValue
_plcValue = 123;
MyTag.Value = _plcValue;
MyPLC.WriteTag(MyTag);
Tag Class | GELink Namespace | ErrorCode | ErrorString | QualityCode | QualityString