Sets / Returns a cached value.
Unlike the Now property which immediately reads/writes the value to the Allen-Bradley device, the Value property holds the value property in cache until a ReadTag, WriteTag, GroupRead or GroupWrite operation. When setting this property to a System.Array, the Tag.Length is set automatically.
| Exception Type | Condition |
|---|---|
| ArgumentNullException | Thrown if Value property is set to a null reference (Nothing in Visual Basic) |
VB
Try
' ********************************
' * initialize controller and tag
Dim MyPLC as New Logix.Tag.Controller("192.168.1.31")
Dim MyTag as New Logix.Tag("MyIntTag")
' *******************************
' * read value from PLC
MyPLC.ReadTag(MyTag)
' *******************************
' * check the status
If ResultCode.QUAL_GOOD = MyTag.QualityCode Then
Console.WriteLine(MyTag.Value.ToString())
Console.WriteLine(MyTag.Timestamp.ToString())
Else
Console.WriteLine(MyTag.ErrorString)
End If
Console.WriteLine(MyTag.QualityString)
Catch ex As System.Exception
Console.WriteLine(ex.Message)
End Try
C#
try
{
//////////////////////////////////
// initialize controller and tag
Logix.Controller MyPLC = new Logix.Controller("192.168.1.31");
Logix.Tag MyTag = new Logix.Tag("MyIntTag");
/////////////////////////////////
// read value from PLC
MyPLC.ReadTag(MyTag);
//////////////////////////////////
// check results
if(ResultCode.QUAL_GOOD == MyTag.QualityCode)
Console.WriteLine(Convert.ToString(MyTag.Value));
Console.WriteLine(MyTag.Timestamp.ToString());
else
Console.WriteLine(MyTag.ErrorCode);
Console.WriteLine(MyTag.QualityString);
}
catch(System.Exception ex)
{
Console.WriteLine(ex.Message);
}