INGEAR.NET.Logix

 

Controller.GroupWrite Method 

Executes a block write of all the Tag classes in the TagGroup, or array of TagGroups

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

Parameters

TagGroup
An instance or array of instances of the TagGroup class

Return Value

ResultCode.E_SUCCESS if successful, else ResultCode / CIP Error Codes for a list of possible errors.

Remarks

The TagGroup.Active property must = true for this method to executed.  The Tag.Active property enables or disables individual tags for group updates. Calling this method will invoke the TagGroup.pdate event handler for the group as well as Tag.Changed event for individual tags.

Exceptions

Exception Type Condition
ArgumentNullException Thrown if TagGroup paramater is a null reference (Nothing in Visual Basic)
InvalidOperationException Thrown if TagGroup parameter is not type TagGroup

Example

VB
Try
  ' ***********************************
  ' * initialize the Controller class
  Dim MyPLC as New Logix.Controller()
  ' ***********************************
  ' * initialize TagGroup class
  Dim tagGroup as New Logix.TagGroup
  ' ***********************************
  ' * initialize tag classes
  Dim Tag1 as New Logix.Tag("MyInt")
  Dim Tag2 as New Logix.Tag("MyDint")
  Dim Tag3 as New Logix.Tag("MyFloat")
  '************************************
  '* set controller properties
  MyPLC.IPAdress = "192.168.1.32"
  '************************************
  '* add tags to the group
  tagGroup.AddTag(Tag1)
  tagGroup.AddTag(Tag2)
  tagGroup.AddTag(Tag3)
  ' ***********************************
  ' * set tag values and data types
  Tag1.Value = 123
  Tag1.DataType = Logix.ATOMIC.INT
  Tag2.Value = 123456
  Tag2.DataType = Logix.ATOMIC.DINT
  Tag3.Value = 123.456
  Tag3.DataType = Logix.ATOMIC.REAL
  ' ***********************************
  ' * update the group
  MyPLC.GroupWrite(tagGroup)
  ' ***********************************
  ' * Tag1 Results
  If Tag1.QualityCode = ResultCode.QUAL_GOOD Then
    Console.WriteLine(Tag1.Timestamp.ToString())
  Else
    Console.WriteLine(Tag1.ErrorString)
  End If
  Console.WriteLine(Tag1.QualityString)
  ' ************************************
  ' * Tag2 Results
  If Tag2.QualityCode = ResultCode.QUAL_GOOD Then
    Console.WriteLine(Tag2.Timestamp.ToString())
  Else
    Console.WriteLine(Tag2.ErrorString)
  End If
  Console.WriteLine(Tag2.QualityString)
  ' **************************************
  ' * Tag3 Results
  If Tag3.QualityCode = ResultCode.QUAL_GOOD Then
    Console.WriteLine(Tag3.Timestamp.ToString())
  Else
    Console.WriteLine(Tag3.ErrorString)
  End If
  Console.WriteLine(Tag3.QualityString)
Catch ex As System.Exception
  Console.WriteLine(ex.Message)
End Try
  
C#
try
{
  ///////////////////////////////////////
  // initialize the Controller class
  Logix.Controller MyPLC = new Logix.Controller();
  ///////////////////////////////////////
  // initialize TagGroup class
  Logix.TagGroup tagGroup = new Logix.TagGroup();
  ///////////////////////////////////////
  // initialize tag classes
  Logix.Tag Tag1 = new Logix.Tag("MyInt");
  Logix.Tag Tag2 = new Logix.Tag("MyDInt");
  Logix.Tag Tag3 = new Logix.Tag("MyFloat");
  ///////////////////////////////////////
  // set controller properties
  MyPLC.IPAdress = "192.168.1.32";
  ///////////////////////////////////////
  // add tags to the group
  tagGroup.AddTag(Tag1);
  tagGroup.AddTag(Tag2);
  tagGroup.AddTag(Tag3);
  ///////////////////////////////////////
  // set tag values and data types
  Tag1.Value = 123;
  Tag1.DataType = Logix.ATOMIC.INT;
  Tag2.Value = 123456;
  Tag2.DataType = Logix.ATOMIC.DINT;
  Tag3.Value = 123.456;
  Tag3.DataType = Logix.ATOMIC.REAL;
  ///////////////////////////////////////
  // update the group
  MyPLC.GroupWrite(tagGroup);
  //////////////////////////////////////
  // Tag1 Results
  if (ResultCode.QUAL_GOOD == Tag1.QualityCode)
    Console.WriteLine(Tag1.Timestamp.ToString());
  else
    Console.WriteLine(Tag1.ErrorString);
  Console.WriteLine(Tag1.QualityString)
  //////////////////////////////////////
  // Tag2 Results
  if (ResultCode.QUAL_GOOD == Tag2.QualityCode)
    Console.WriteLine(Tag2.Timestamp.ToString());
  else
    Console.WriteLine(Tag2.ErrorString);
  Console.WriteLine(Tag2.QualityString)
  //////////////////////////////////////
  // Tag3 Results
  if (ResultCode.QUAL_GOOD == Tag3.QualityCode)
    Console.WriteLine(Tag3.Timestamp.ToString());
  else
    Console.WriteLine(Tag3.ErrorString);
  Console.WriteLine(Tag3.QualityString)
}
catch(System.Exception ex)
{
  Console.WriteLine(ex.Message);
}    

See Also

Controller Class | Logix Namespace | GroupRead | WriteTag