I'm trying to monitor alarm events on a OPC UA client utilizing event based monitored items. I subscribe to the node: ns=2;s=Sinumerik
and add the corresponding attributes and filters. Later on I handle the notification on a OnNotification() method as shown in the code below.
var list = new List<MonitoredItem> { new MonitoredItem(_subscription.DefaultItem) {StartNodeId = "ns=2;s=Sinumerik" } };
foreach (MonitoredItem item in list)
{
item.AttributeId = Attributes.EventNotifier;
item.MonitoringMode = MonitoringMode.Reporting;
item.SamplingInterval = -1;
item.QueueSize = 100;
item.DiscardOldest = false;
EventFilter filter = new EventFilter();
filter.AddSelectClause(ObjectTypes.BaseEventType, Opc.Ua.BrowseNames.Message);
filter.AddSelectClause(ObjectTypes.BaseEventType, Opc.Ua.BrowseNames.Severity);
item.Filter = filter;
item.Notification += OnNotification;
}
_subscriptions[subscriptionNum].Create();
_subscriptions[subscriptionNum].ApplyChanges();
The OnNotification() method looks like this:
private void OnNotification(MonitoredItem item, MonitoredItemNotificationEventArgs e)
{
foreach (var value in item.DequeueValues())
{
Console.WriteLine("Display Name: " + item.DisplayName + "Value: " + value.Value);
}
}
I receive the event notification but there are no Values in the MonitoredItem.
Is this the correct way to monitor event based monitored items for Sinumerik Alarms using OPC UA?