INGEAR.NET.ABLink

 

TagGroup.AddTag Method 

Add instances of Tag classes to the TagGroup collection.

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

Parameters

Tag
Tag, or array of Tags to add to TagGroup

Return Value

E_SUCCESS successful else ResultCode for list of possible errors.

Remarks

The Active property must = true for this method to executed. Setting the Active property enables or disables individual tags for group updates. Call this method will invoke the Update event handler for the group as well as Changed event for individual tags.  

If the Tag.Name already exists in the TagGroup collection, an exception is thrown.

 

Exceptions

Exception Type Condition
ArgumentNullException Thrown if Tag parameter = a null reference (Nothing in Visual Basic)
ArgumentOutOfRangeException

 

Thrown if Tag parameter not type ABLink.Tag

 

 

Example

VB
' ***********************************
' * initialize the Controller class
Dim MyPLC as New ABLink.Controller()
' ***********************************
' * initialize TagGroup class
Dim tagGroup as New ABLink.TagGroup
' ***********************************
' * initialize tag classes
Dim Tag1 as New ABLink.Tag("N7:0")
Dim Tag2 as New ABLink.Tag("N7:13")
Dim Tag3 as New ABLink.Tag("F8:100")
'************************************
'* set controller properties
MyPLC.IPAdress = "192.168.1.32"
MyPLC.CPUType = CPU.SLC
MyPLC.DriverType = Driver.ENET
'************************************
'* add tags to the group
tagGroup.AddTag(Tag1)
tagGroup.AddTag(Tag2)
tagGroup.AddTag(Tag3)
' ***********************************
' * update the group
MyPLC.GroupRead(tagGroup)
' ***********************************
' * Tag1 Results
If Tag1.QualityCode = ResultCode.QUAL_GOOD Then
  Console.WriteLine(Convert.ToString(Tag1.Value))
  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(Convert.ToString(Tag2.Value))
  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(Convert.ToString(Tag3.Value))
  Console.WriteLine(Tag3.Timestamp.ToString())
Else
  Console.WriteLine(Tag3.ErrorString)
End If
Console.WriteLine(Tag3.QualityString)


C# /////////////////////////////////////// // initialize the Controller class ABLink.Controller MyPLC = new ABLink.Controller(); /////////////////////////////////////// // initialize TagGroup class ABLink.TagGroup tagGroup = new ABLink.TagGroup(); /////////////////////////////////////// // initialize tag classes ABLink.Tag Tag1 = new ABLink.Tag("N7:0"); ABLink.Tag Tag2 = new ABLink.Tag("N7:13"); ABLink.Tag Tag3 = wew ABLink.Tag("F8:100"); /////////////////////////////////////// // set controller properties MyPLC.IPAdress = "192.168.1.32"; MyPLC.CPUType = CPU.SLC; MyPLC.DriverType = Driver.ENET; /////////////////////////////////////// // add tags to the group tagGroup.AddTag(Tag1); tagGroup.AddTag(Tag2); tagGroup.AddTag(Tag3); /////////////////////////////////////// // update the group MyPLC.GroupRead(tagGroup); ////////////////////////////////////// // Tag1 Results if (ResultCode.QUAL_GOOD == Tag1.QualityCode) {  Console.WriteLine(Convert.ToString(Tag1.Value));  Console.WriteLine(Tag1.Timestamp.ToString()); }   else  Console.WriteLine(Tag1.ErrorString); Console.WriteLine(Tag1.QualityString) ////////////////////////////////////// // Tag2 Results if (ResultCode.QUAL_GOOD == Tag2.QualityCode) {  Console.WriteLine(Convert.ToString(Tag2.Value));  Console.WriteLine(Tag2.Timestamp.ToString()); }   else  Console.WriteLine(Tag2.ErrorString); Console.WriteLine(Tag2.QualityString) ////////////////////////////////////// // Tag3 Results if (ResultCode.QUAL_GOOD == Tag3.QualityCode) {  Console.WriteLine(Convert.ToString(Tag3.Value));  Console.WriteLine(Tag3.Timestamp.ToString()); }   else  Console.WriteLine(Tag3.ErrorString); Console.WriteLine(Tag3.QualityString)

See Also

TagGroup Class | ABLink Namespace | RemoveTag | Clear | Count | Tags | GroupWrite | ReadTag