Executes an immediate read of the Allen-Bradley device referenced by the Controller and Name parameters.
Use this constructor when immediately reading BOOL Array or STRING data types.
| Exception Type | Condition |
|---|---|
| ArgumentNullException | Thrown if Logix.Controller or Name parameter= a null reference (Nothing in Visual Basic) |
| InvalidOperationException | Thrown Name.Length is less that 1 character. |
VB
Try
' **************************
' * initialize controller
Dim MyPLC as New Logix.Controller("192.168.1.31")
' *************************
' * immediately read tag on initialization
Dim MyTag as New Logix.Tag(MyPLC, "MyString", ATOMIC.STRING)
' *************************
' * check results
If ResultCode.QUAL_GOOD == MyTag.QualityCode Then
Console.WriteLine(Convert.ToString(MyTag.Value))
Console.WriteLine(MyTag.Timestamp.ToString())
Else
Console.WriteLine(MyTag.ErrorString)
End If
Console.WriteLine(MyTag.QualityString)
Catch ex As System.Exception
MessageBox.Show(ex.Message, Me.Text)
End Try
C#
try
{
/////////////////////////////
// initialize controller
Logix.Controller MyPLC = new Logix.Controller("192.168.1.31");
/////////////////////////////
// immediately read tag on initialization
Logix.Tag MyTag = new Logix.Tag(MyPLC, "MyString", ATOMIC.STRING);
/////////////////////////////
// check results
if(ResultCode.QUAL_GOOD == MyTag.QualityCode)
{
Console.WriteLine(Convert.ToString(MyTag.Value));
Console.WriteLine(MyTag.Timestamp.ToString());
}
else
Console.WriteLine(MyTag.ErrorString);
Console.WriteLine(MyTag.QualityString);
}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message, this.Text);
}
Tag Class | Logix Namespace | Tag Constructor Overload List | Now | ReadTag