You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You could put multiple addresses in one subscription.
I did it like this:
Note: I need the namespace 3. In your code, the value is fixed to value 2.
public ushort namespaceIndex = 3;
List<MonitoredItem> itemsMulti;
public void MonitoringMultiInit()
{
itemsMulti = new List<MonitoredItem>();
}
public void MonitoringMulti(string address, MonitoredItemNotificationEventHandler monitor)
{
MonitoredItem monitored = new MonitoredItem();
monitored.StartNodeId = new NodeId(address, namespaceIndex);
monitored.AttributeId = Attributes.Value;
monitored.Notification += monitor;
itemsMulti.Add(monitored);
}
public void MonitoringMultiExec(int miliseconds)
{
var subscription = this.Subscription(miliseconds);
subscription.AddItems(itemsMulti);
this.Session.AddSubscription(subscription);
subscription.Create();
subscription.ApplyChanges();
}
How to use
client.MonitoringMultiInit();
client.MonitoringMulti("Device.Counter.Value1", (_, e) => {
// Anything you need to be executed when the value changes
// Get the value of the tag being monitored
var monitored = (MonitoredItemNotification)e.NotificationValue;
Console.WriteLine(monitored.Value);
});
client.MonitoringMulti("Device.Counter.Value2", (_, e) => {
// Anything you need to be executed when the value changes
// Get the value of the tag being monitored
var monitored = (MonitoredItemNotification)e.NotificationValue;
Console.WriteLine(monitored.Value);
});
//....... add up to 1000 for Siemens S7 PLC
client.MonitoringMultiExec(1000);
regards
RaLa
The text was updated successfully, but these errors were encountered:
Hi Luis
You could put multiple addresses in one subscription.
I did it like this:
Note: I need the namespace 3. In your code, the value is fixed to value 2.
How to use
regards
RaLa
The text was updated successfully, but these errors were encountered: