Performs an immediate read / write of the ControlLogix/CompactLogix
Default value is a null reference (Nothing in Visual Basic)
| Exception Type | Condition |
|---|---|
| InvalidOperationException | Thrown if Controller is a null reference (Nothing in Visual Basic) or if assigning a null value to the .Now property. |
VB
Try
' ****************************
' * initialize controller
Dim MyPLC as New Logix.Controller("192.168.1.31")
' ****************************
' * initialize tag
Dim MyTag as New Logix.Tag("theTag")
' ****************************
' * set the Controller property
MyTag.Controller = MyPLC
' ****************************
' * perform immediate read
Console.WriteLine(Convert.ToString(MyTag.Now))
Catch ex As System.Exception
Console.WriteLine(ex.Message)
End Try
C#
try
{
////////////////////////////////
// initialize controller
Logix.Controller MyPLC = new Logix.Controller("192.168.1.31");
////////////////////////////////
// initialize tag
Logix.Tag MyTag = new Logix.Tag("N7:0");
///////////////////////////////
// set controller property
MyTag.Controller = MyPLC;
///////////////////////////////
// execute immediate read
Console.WriteLine(Convert.ToString(MyTag.Now));
}
catch (System.Exception ex)
{
Console.WriteLine(ex.Message);
}