I have a FactoryTalk server with some nodes and I need to monitor several attribute values.
I made a client which reads and writes data succesfully, but I can't get the subscription to work.
Here's the subscription configuration:
subscription = new Subscription(session.DefaultSubscription)
{
DisplayName = "Test subscription",
PublishingEnabled = true,
PublishingInterval = 500,
LifetimeCount = 0,
};
My monitored items:
monitoredItems = nodeAttrs
.Select(nodeId => new MonitoredItem(subscription.DefaultItem)
{
StartNodeId = nodeId,
AttributeId = Attributes.Value,
QueueSize = 1,
SamplingInterval = 500,
MonitoringMode = MonitoringMode.Reporting,
})
.ToList();
And I assign them the notification handler (I need the protocol object instance here, so I tweaked it):
MonitoredItemNotificationEventHandler monitoredItemEventHandler = (monitoredItem, e) => AttributeNotification(monitoredItem, e, protocol);
Then I add the event handlers:
foreach (var monitoredItem in monitoredItems)
{
monitoredItem.Notification += monitoredItemEventHandler;
}
And I add the items to the subscription and create it:
subscription.AddItems(monitoredItems);
session.AddSubscription(subscription);
subscription.Create();
I've checked through the console and the subscription gets created and assigned an ID by the server. I check all the monitored items as well, CreateMonitoredItems
service call succeeds, and they also get client handles assigned, NodeId
's are correctly resolved, with no error StatusCode
s.
I make changes to the attributes via a 3rd party client application called UaExpert.
Yet I can't get the notification event handler to fire off.
Did I do something wrong? Does anyone have advice on how to resolve/debug this?