INGEAR.NET.GELink

 

Tag.Value Property

Gets / Sets the PLC register value

[Visual Basic]
NotOverridable Public Property Value As Object _
    Implements ITag.Value
[C#]
public object Value {get; set;}

Property Value

Object value

Implements

ITag.Value

Remarks

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)  

Exceptions

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

Example

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);

See Also

Tag Class | GELink Namespace | ErrorCode | ErrorString | QualityCode | QualityString