In advanced programming, we usually use tag events to do some duties, we have two Tag events:
1. The event occurs when the tag value changed
2. The event occurs when the tag connection status changed
This is an example about tag events using c# language.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication17
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Event occur when the Tag value changed
iDriver1.Task(“AT-TMSDevice”).Tag(“HighLevel”).TagValueChanged += Form1_TagValueChanged;
// Event occur when the connection status (good or bad) of Tag changed
iDriver1.Task(“AT-TMSDevice”).Tag(“HighLevel”).TagStatusChanged += Form1_TagStatusChanged;
}
void Form1_TagValueChanged(object o, ATSCADA.TagValueEventArgs e)
{
// Show the Tag value when the Tag value changed
MessageBox.Show(iDriver1.Task(“AT-TMSDevice”).Tag(“HighLevel”).Value);
}
void Form1_TagStatusChanged(object o, ATSCADA.TagStatusEventArgs e)
{
// Show the connection status (good or bad) of Tag
MessageBox.Show( iDriver1.Task(“AT-TMSDevice”).Tag(“HighLevel”).Status);
}
}
}