INGEAR.NET.GELink

 

Controller.ReadTag Method 

Performs cached Tag read operation.

[Visual Basic]
Public Function ReadTag( _
   ParamArray Tag As Tag() _
) As Integer
[C#]
public int ReadTag(
   params Tag[] Tag
);

Parameters

Tag
Instance of a Tag or array of Tags

Return Value

The status of the operation (see ResultCode)

Remarks

If the instance of the Controller class is not already connected to the programmable logic controller, calling this method will automatically establish a connection.

The data value from the programmable logic controller will be returned in the Value property of the Tag class.   

Exceptions

Exception Type Condition
ArgumentNullException Thrown if Tag parameter is a null reference (Nothing in Visual Basic)
InvalidOperationException Thrown if Tag parameter is not Tag Type, or if Name> is null or empty, or Value is null

Example

VB
Try
   ' **************************
   ' * Initialize
   ' *
   Dim MyPLC As New GELink.Controller("192.168.1.45")
   Dim MyTag As New GELink.Tag("%R1")
  ' **************************
   ' * read Tag
   MyPLC.ReadTag(MyTag)
   ' *************************
   ' * check results
   If MyTag.QualityCode = ResultCode.QUAL_GOOD Then
     Console.WriteLine(Convert.ToString(MyTag.Value))
     Console.WriteLine(MyTag.TimeStamp.ToString())
  End If
   ' *************************
   ' * show quality status and error
   Console.WriteLine(MyTag.QualityString)
   Console.WriteLine(MyTag.ErrorString)
Catch ex As Exception
   Console.WriteLine(ex.Message, Me.Text)
End Try
 
C#
try
{
   ///////////////////////////
   // initialize


   GELink.Controller MyPLC = new GELink.Controller("192.168.1.45");
   GELink.Tag MyTag = MyPLC.CreateNewTag();   ///////////////////////////   // read the tag   MyPLC.ReadTag(MyTag);   ///////////////////////////   // check results   if (ResultCode.QUAL_GOOD == MyTag.QualityCode)   {     Console.WriteLine(Convert.ToString(MyTag.Value));     Console.WriteLine(MyTag.TimeStamp.ToString());   }   ///////////////////////////   // show quality and error   Console.WriteLine(MyTag.QualityString);   Console.WriteLine(MyTag.ErrorString); } catch (System.Exception ex) {   Console.WriteLine(ex.Message, this.Text); }

Controller Class | GELink Namespace | GroupRead | WriteTag | Now