INGEAR.NET.GELink

 

Controller.WriteTag Method 

Performs cached Tag write operation.

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

Parameters

Tag
Instance of a Tag or array of Tags

Return Value

The result of the operation.  (see ResultCode)

Remarks

If the instance of the Controller class is not already Connected, calling this method will automatically establish the connection.

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
   ' **************************
   ' * use Initialize
   ' *
   Dim MyPLC As New GELink.Controller("192.168.1.45")
   Dim MyTag As New GELink.Tag("%R1")
 
   MyTag.Value = 123
   ' **************************
   ' * Write Tag
   MyPLC.Write(MyTag)
   ' *************************
   ' * check results
   If MyTag.QualityCode = ResultCode.QUAL_GOOD Then
     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#
using GELink;
try
{
   ///////////////////////////
   // Initialize
   GELink.Controller MyPLC = new GELink.Controller("192.168.1.45");


   GELink.Tag MyTag = new GELInk.Tag("%R1");   ///////////////////////////   // set the value   MyTag.Value = 123;   ///////////////////////////   // write the tag   MyPLC.WriteTag(MyTag);   ///////////////////////////   // check results   if (ResultCode.QUAL_GOOD == MyTag.QualityCode)    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); }

See Also

Controller Class | GELink Namespace | GroupWrite | Now | ReadTag