2
votes

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...

1
Are the update times very different between CurrentAtTag and IOLPort for example? Like first is slow-changer and the second one is quick changing? If not I would simply go with subscription to all of them and see if the performance is OK. - astrowalker
Hi @astrowalker, no they are almost at the same time. I already considered to subscripe to all nodes. The problem is that i need to call another method within my application which needs all the values. I am not sure how i could do that if i get the values in different callbacks... You know what i mean? Perhaps this problem is easy to solve but i dont have an idea for the moment. - Niko
It seems like you may not be considering your architecture correctly. If a number of data fields change together, then they really belong to a single, combo unit instead of different fields. - Stephen Chung

1 Answers

1
votes

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.