INGEAR.NET.ABLink

 

TagGroup.Update Event

Update Event Handler

[Visual Basic]
Public Event Update As EventHandler
[C#]
public event EventHandler Update;

 

Example

VB
' ******************************
' * Initialize Controller and Group
Dim MyPLC As New ABLink.Controller("192.168.1.32")
Dim WithEvents MyGroup As New ABLink.TagGroup()
' *******************************
' * initialize Tag classes
Dim Tag1 As New ABLink.Tag("N7:0")
Dim Tag2 As New ABLink.Tag("F8:0")
Dim Tag3 As New ABLink.Tag("B3:0/0")
Try
 
 ' *****************************
 ' * add event handler
  AddHandler MyGroup.Update, AddressOf MyGroup_Update 
  
  ' *****************************
  ' * add Tags to Group
  MyGroup.AddTag(Tag1)
  MyGroup.AddTag(Tag2)
  MyGroup.AddTag(Tag3)
  
  ' ****************************
  ' * read the group
  MyPLC.GroupRead(MyGroup)
  
Catch ex As System.Exception
  Console.WriteLine(ex.Message)
End Try
{...elsewhere in code...}
' *********************************
' * event handler
Private Sub MyGroup_Update(ByVal sender As Object, ByVal e As System.EventArgs)
  Try
   Dim nTag as Integer
   Dim theGroup as ABLink.TagGroup
   Dim args as ABLink.TagGroupEventArgs
   
   ' ***************************
   ' * TagGroup that caused the event 
   theGroup = sender
   
   ' ***************************
   ' * event argument parameters
   args = e
   
   ' ***************************
   ' * display operation and time that cause the event
   Console.WriteLine(args.EventString)
   Console.WriteLine(args.TimeStamp.ToString())
   
   ' ***************************
   ' * process the tags in the group
   For nTag = 0 to args.Tags.Length-1
     If ResultCode.QUAL_GOOD = args.Tags(nTag).QualityCode Then
       Console.WriteLine(Convert.ToString(args.Tags(nTag).Value))
     Else
       Console.WriteLine(args.Tags(nTag).ErrorString)
     End If
     Console.WriteLine(args.Tags(nTag).QualityString)
   Next
     
 Catch ex As System.Exception
   Console.WriteLine(ex.Message)
 End Try
End Sub


C# /////////////////////////// // initialize controller and group ABLink.Controller MyPLC = new ABLink.Controller("192.168.1.32"); ABLink.TagGroup MyGroup = new ABLink.TagGroup(); /////////////////////////////// // initialize tags ABLink.Tag Tag1 = new ABLink.Tag("N7:0"); ABLink.Tag Tag2 = new ABLink.Tag("F8:0"); ABLink.Tag Tag3 = new ABLink.Tag("B3:0/0"); try {  //////////////////////////////  // add tags to group  MyGroup.AddTag(Tag1);  MyGroup.AddTag(Tag2);  MyGroup.AddTag(Tag3);    ///////////////////////////  // add event handler  MyGroup.Update +=new EventHandler(MyGroup_Update);    ///////////////////////////  // read the tag  MyPLC.GroupRead(MyGroup); } catch(System.Excpetion ex) {  Console.WriteLine(ex.Message); } {...elsewhere in code...} ///////////////////////////////////// // EVENT HANDLER private void MyGroup_Update(object sender, EventArgs e) {  try  {    //////////////////////////////////////    // TagGroup that caused the event    ABLink.TagGroup theGroup = (ABLink.TagGroup)sender;        //////////////////////////////////////    // event argument parameters    ABLink.TagGroupEventArgs args = (ABLink.TagGroupEventArgs)e;        /////////////////////////////////////    // display operation name and time of the event    Console.WriteLine(args.EventName);    Console.WriteLine(args.TimeStamp.ToString());        /////////////////////////////////////    // process the event data    for (int nTag = 0; nTag ; nTag++)    {       if(ResultCode.QUAL_GOOD == args.Tags[nTag].QualityCode)          Console.WriteLine(Convert.ToString(args.Tags[nTag].Value));       else             Console.WriteLine(args.Tags[nTag].ErrorString);       Console.WriteLine(args.Tags[nTag].QualityString);    }     }  catch (System.Exception ex)  {    Console.WriteLine(ex.Message);  } }           

See Also

TagGroup Class | ABLink Namespace | GroupRead | GroupWrite | Active