-
Notifications
You must be signed in to change notification settings - Fork 8
/
Program.cs
30 lines (27 loc) · 901 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using Opc.Da;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OPC_server_subscription
{
class Program
{
static void Main(string[] args)
{
OPCServer server = new OPCServer("OPCServer.1");
server.AddSubscription("Group1", new string[] { "Signal1" }.ToList(), OPCSubscription_DataChanged);
Console.ReadLine();
}
public static void OPCSubscription_DataChanged(object subscriptionHandle, object requestHandle, ItemValueResult[] tags)
{
// Display result whenever a tag value is updated
for (int i = 0; i < tags.Length; i++)
{
Console.WriteLine(" ItemName: " + tags[i].ItemName);
Console.WriteLine(" Value: " + tags[i].Value);
}
}
}
}