Page 1 of 1

Userdata inside MonitoredItem or UaClient_Subscription

Posted: 07 Nov 2017, 16:58
by caspervanzoest
I am currently working with the ANSI C Client SDK. (version 1.7.0)
My software writes its value into a pointer, which is unique for each (subscribed) node.
So, for example, if a subscribed OPCUA node changes its data, It will write the latest value of the node into its corresponding pointer.

The UaClient_Subscription allows storage of this in 'user data'.
This goes fine when I create a subscription foreach node.
However, the OPCUA protocol allows me to add multiple node's into one subscription. (aka monitored items)

If I would create a MonitoredItem foreach node, (within the same subscription)
there is no 'user data' available to store my pointer into. (except one in the subscription)

This leaves us with my following questions:
- Is there any way to store 'user data' in a MonitoredItem, instead of UaClient_Subscription?
- What are the pro's and cons of using a UaClient_Subscription foreach MonitoredItem, instead of creating many UaClient_Subscriptions with one MonitoredItem in each?

All feedback is welcome.
Thanks in advance!

Re: Userdata inside MonitoredItem or UaClient_Subscription

Posted: 23 Nov 2017, 15:32
by Support Team
Hello caspervanzoest,

connecting monitored items to your custom information can be done by using the ClientHandle which you pass inside the RequestedParameters of an OpcUa_MonitoredItemCreateRequest. This handle can be chosen freely by you and is passed back to you in the OpcUa_MonitoredItemNotification of a DataChange callback. Using any kind of mapping (e.g. a list with the ClientHandle as index or a map) you can then determine your custom information belonging to the monitored item using the ClientHandle.