INGEAR.NET.Logix

 

Tag Constructor (Controller, String, ATOMIC)

Executes an immediate read of the Allen-Bradley device referenced by the Controller and Name parameters.

[Visual Basic]
Overloads Public Sub New( _
   ByVal Controller As Controller, _
   ByVal Name As String, _
   ByVal DataType As ATOMIC _
)
[C#]
public Tag(
   Controller Controller,
   string Name,
   ATOMIC DataType
);

Parameters

Controller
Sets the parent Controller class.
Name
Sets the Name property.
DataType
Sets the DataType property

Remarks

Use this constructor when immediately reading BOOL Array or STRING data types.

Exceptions

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.

Example

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

See Also

Tag Class | Logix Namespace | Tag Constructor Overload List | Now | ReadTag