Write a TagGroup to the programmable logic controller
| Exception Type | Condition |
|---|---|
| ArgumentNullException | Thrown if TagGroup parameter is a null reference (Nothing in Visual Basic). |
| ArgumentException | Thrown if TagGroup parameter is not TagGroup Type. |
VB Try ' ***************************** ' * Initialize Dim MyPLC As New GELink.Controller("192.168.1.45") Dim Tag1 As New GELink.Tag("%R1") Dim Tag2 As New GELink.Tag("%M1") Dim Tag3 As New GELink.Tag("%R2")
Dim MyGroup As New GELink.TagGroup ' ***************************** ' * set Tag values Tag1.Value = 123 Tag2.Value = True Tag3.Value = 456
' ****************************** ' * add tags to Group MyGroup.AddTag(Tag1) MyGroup.AddTag(Tag2) MyGroup.AddTag(Tag3)
' ***************************** ' * write Tags MyPLC.GroupWrite(MyGroup) ' ***************************** ' * display Tag1 result If ResultCode.QUAL_GOOD <> Tag1.QualityCode Then Console.WriteLine(Tag1.ErrorString) End If
' ***************************** ' * display Tag2 result If ResultCode.QUAL_GOOD <> Tag2.QualityCode Then Console.WriteLine(Tag2.ErrorString) End If
' ***************************** ' * display Tag3 result If ResultCode.QUAL_GOOD = Tag3.QualityCode Then Console.WriteLine(Tag3.ErrorString) End If
Catch ex As Exception Console.WriteLine(ex.Message) End Try
C# try { ////////////////////////////// // Initialize GELink.Controller MyPLC = new GELink.Controller("192.168.1.45"); GELink.Tag Tag1 = new GELink.Tag("%R1"); GELink.Tag Tag2 = new GELink.Tag("%M1"); GELink.Tag Tag3 = new GELink.Tag("%R2"); GELink.TagGroup MyGroup = new GELink.TagGroup(); ////////////////////////////// // set Tag values Tag1.Value = 123; Tag2.Value = true; Tag3.Value = 456;
////////////////////////////// // add tags to group MyGroup.AddTag(Tag1); MyGroup.AddTag(Tag2); MyGroup.AddTag(Tag3);
////////////////////////////// // write Tags MyPLC.GroupWrite(MyGroup);
///////////////////////////// // display Tag1 result if (ResultCode.QUAL_GOOD != Tag1.QualityCode) Console.WriteLine(Tag1.ErrorString);
///////////////////////////// // display Tag2 result if (ResultCode.QUAL_GOOD == Tag2.QualityCode) Console.WriteLine(Tag2.ErrorString);
///////////////////////////// // display Tag3 result if (ResultCode.QUAL_GOOD == Tag3.QualityCode) Console.WriteLine(Tag3.ErrorString); } catch (System.Exception ex) { Console.WriteLine(ex.Message); }
Controller Class | GELink Namespace | GroupRead | IController.GroupWrite