Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Best methods on the server side to keep the OPC-UA client up to date on sensor values
March 26, 2018
20:12, EEST
Avatar
Luke.d
Member
Members
Forum Posts: 8
Member Since:
February 21, 2018
sp_UserOfflineSmall Offline

Hi,

Suppose we have implemented a generic OPC-UA server;
It can read from a sensor (e.g. temperature) in a manner generally indipendent from OPC-UA.

To simplify, suppose that the sensor is represented in the address space of Server as a simple UaVariable of type Double.

If I wanted to implement a server-side application, in which the OPC-UA clients want to read this UaVariable, I could do:

1) To use IOManagerListener (described in your server PROSYS tutorial):
– More precisaly, the OnReadValue(..) must implement the reading from the sensor and update the UaVariable.
– In this way, every time the client calls the Read service on that UaVariable, he will see the value updated of the sensor.

For example:

@Override
public boolean onReadValue (…, NodeId nodeId, UaValueNode node, DataValue dataValue, …) {

if (nodeId.getValue (). equals (MySimpleServer.IDENTIFIER_TEMPERATURE)) {

/ * Read from sensor * /
Double valueRead = mySensor.readTemperature ();

Variant variantValueRead = new Variant (new Double (valueRead));

/ * Modify dataValue (The data value to return to client) * /
dataValue.setValue (variantValueRead);

/ * Modify node (The node object to read.) * /
node.setValue (variantValueRead);

} else if (…) {

}

return true; // other listeners will not get called with the read request.
}

2) To use subscription mechanism:
– The client subscribes to the UAvariable temperature and will receive notifications about changes it.
(Suppose you have set the data change filter and the other parameters of the subscription according to your needs).
– If I wanted to do this, I would have to do a server-side “polling” to update the variable, right?

– That is, in the server I could create (and run) a thread that executes the following pseudocode:
(Obviously the thread can be executed periodically or only once with a while loop that can contain “waits” in order to avoid active waits)

while (server.isRunning ()) {

Double valueSensor = mySensor.readTemperature ();
myTemperatureUaNode.setCurrentValue (valueSensor);

}

Are these strategies correct?
Which is more used? (for example in industrial applications).

I think that the 2° strategy can be preferred in case the client wants to see updated value automatically and “periodically” over time where as the 1° strategy might be useful when client explicitly requests updating of data (asynchronously).
Is that right?

Are there more convenient ways?

I hope I explained myself well.

Thanks in advance,
regards,
Luke

March 27, 2018
12:35, EEST
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hello Luke,

Thank you for a detailed explanation and a good question.

The strategy 2 is the one you should use. In practice, it’s also the only convenient strategy. In other words, this strategy means that you use UaNode-based node objects to cache all values in memory. You don’t need to do anything else than provide new values to the objects to make your server work as expected.

You can use

CacheVariable.updateValue();

or

PlainVariable.setCurrentValue();

to provide new samples to the Variables.

Alternatively, if you cannot use the UaNode based approach, you can implement a fully customized node manager, as described in chapter “Custom Node Manager” of the server tutorial document. This approach will be beneficial in case you have your data already in a background system and do not wish to replicate the data in the node objects. You will need to implement all node handling yourself, but you don’t need to instantiate a UaNode object in the memory for every node. The SDK does provide an example implementation of this approach, called MyBigNodeManager.

April 23, 2018
12:45, EEST
Avatar
Luke.d
Member
Members
Forum Posts: 8
Member Since:
February 21, 2018
sp_UserOfflineSmall Offline

Hi,

Thanks for your answer and your time,

Considering also a third strategy (a kind of hybrid of 1) and 2) strategies):

3)
– The client calls the Read service on that UaVariable.
– The server do “polling” to update the variable(similar to server-side of strategy 2) ).

In comparison to strategy 1) , which is more used? (for example in industrial applications), 1) or 3) ?

Best Regards,
Thanks,
Luke

April 23, 2018
13:59, EEST
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hi,

In your original post, I think the strategy 1 only covers implementing read calls and not subscriptions. If we consider a generic OPC UA server implementation, it’s kind of assumed that the server needs to implement a subscription mechanism and the client application then decides if it issues read calls or creates subscriptions.

I’m actually going to answer more generically and maybe not exactly to the direct question here. The point being that a generic OPC UA server basically has three possible types of variables:

a) Internal data. This kind of variable values are not read from an external data source but it’s completely internal to the server application. For example, the standardized ServerStatus node (browse path Objects->Server->ServerStatus) typically contains only data that is internal to the server application.

b) Variables that are updated by external events. In the context of Prosys OPC UA Java SDK, this strategy means that you use UaNode-based node objects to cache all values in memory. This strategy also requires that the external system can actively update the values to the OPC UA server or that the OPC UA server application has internal logic (such as a timer) which updates the values to UaNode objects. In the context of Prosys OPC UA Java SDK, this is the most typical case because the SDK is designed so that this is the most easiest approach to implement.

c) Variables which poll external devices. In this case, the OPC UA server fetches the value directly from an underlying system and not from it’s own cache. In the context of the original forum post, this external device would be the temperature sensor. This approach will be beneficial in case you have your data already in a background system and do not wish to replicate the data in the node objects. You can implement this approach with Prosys OPC UA Java SDK if you implement a fully customized node manager. However, with the current Java SDK this requires a lot of work and for this reason in the context of Prosys OPC UA Java SDK this approach is used much less than the UaNode based memory cache.

It’s hard to say what strategy would be “more used” generally. Different approaches have their own benefits.

April 23, 2018
16:14, EEST
Avatar
Mike.Stair
Member
Members
Forum Posts: 12
Member Since:
January 12, 2018
sp_UserOfflineSmall Offline

Hi everyone!

I have a similar question regarding writing service management.

When a client performs a write operation on a node which strategy is preferable to use to go to update the sensor / actuator?

For example I could intercept writing with an IOlistener or I could create a thread that checks if the node’s value has been updated and write to the actuator sensor.
Are there any other ways?

Thanks,
Regards,
Mike

April 23, 2018
17:04, EEST
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hi Mike,

Typically the value should be written directly to the device (sensor/actuator) without delay. The normal place to intercept the write calls in your implementation of IoManagerListener and write the value to the underlying device.

In OPC UA, there’s also a return value for a successful operation that completes asynchronously. So it’s also a valid scenario that you have a separate logic for making the writes to underlying device. But as said, the most typical scenario is to write directly to the data source.

April 23, 2018
17:23, EEST
Avatar
Mike.Stair
Member
Members
Forum Posts: 12
Member Since:
January 12, 2018
sp_UserOfflineSmall Offline

Perfect!

Thanks for your answer!

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
10 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

ibrahim: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 685

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6259

Newest Members:

Jan-Pfizer, DavidROunc, fen.pang@woodside.com, aytule, rashadbrownrigg, christi10l, ahamad1, Flores Frederick, ellenmoss, harriettscherer

Moderators: Jouni Aro: 1009, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1