Reputation: 31
I started a OPC UA project using the Milo project to create a OPC UA Client. I am still very new to OPC UA. Right now I am stuck looking for the best practice to read values from several Nodes after a data change of one specific node.
The information model looks like this: RfidSensorType
On my server i will have several objects of this RfidSensorType. The client creates a subscription on the CurrentAtTag Node to listen for data changes.
My Question: When the value of CurrentAtTag is changed a callback function will be called in my client which contains the UaMonitoredItem and the DataValue of the CurrentAtTag. In my application i need to process (at the same time) also the values of Station, IOLPort and CurrentValue which are changed at that moment too. How can i access those values within the callback from CurrentAtTag?
My only solution is: Using a synchronous read request within that callback -> Is that an legit approach?
My Research: 1) TriggeringService I've seen that a TriggerigService exists, which monitors items will send reports only if one specific node changes it values. Problem: This will call several callsbacks and noz just one..i need all the informations at the same time to further process them..
2) Event Monitoring In event monitoring one can select "Event fields" which will be returned for each Event notificaiton. I am not sure if i could select the CurrentAtTag, Station, IOLPort and CurrentValue...
Upvotes: 2
Views: 2742
Reputation: 868
Just like you can subscribe to the server's ServerStatus (nodeid "i=2256"), you should be able to subscribe to the nodeid corresponding to 'RfidSensor_Station1'. The server will send PublishResponse with data of type 'RfidSensorType' encoded as an ExtensionObject. The trick is decoding the ExtensionObject.
As Kevin corrected, because 'RfidSensor_Station1' is not node class 'Variable' then it doesn't have a value attribute and you can not monitor the node for data changes. If you are using a PLC, I might combine all properties of the sensor into a string, or byte array. Then I monitor the new variable, and parse the string in the client.
Or you could make ReadRequest as you describe. That will work just fine.
Upvotes: 1