Notify to the client that a variable has changed

268 views
Skip to first unread message

stefano...@zoppas.com

unread,
May 10, 2017, 3:00:59 AM5/10/17
to open62541
Hello everybody,
I'm trying to develop a simple tutorial projects, made of both client and server. I successfully implemented the server with only one integer variable. Then I developed the client. Now I would like the client be notified every time the variable change the value. The client example included in the package only make a single publish request to the server and then terminates. What I need is the client stay in a loop (until the it receives the termination command i.e. CTRL-C) and print a message every time the variable change.
Is it possible to do this?
Thank you in advance.

Stefano

michael...@googlemail.com

unread,
May 10, 2017, 11:04:06 AM5/10/17
to open62541
Just loop infinitely and call for the manual publish request over and over. Maybe add some Sleep-Time between publish requests, I've seen some Clients losing connection on some servers for too fast requesting.

stefano...@zoppas.com

unread,
May 10, 2017, 11:07:03 AM5/10/17
to open62541, michael...@googlemail.com
But...this is a polling; then I can use directly a reading of the variable in a loop with a delay instead of the publish-subscription mechanism.

michael...@googlemail.com

unread,
May 10, 2017, 11:24:18 AM5/10/17
to open62541
That's how OPC UA works, afaik. The reason might be that OPC UA has to work with http protocol, too: The server can always only answer to client requests.

You can use some asynchronous threaded part to petform that "polling".

aome advantages over reading the values directly should be:

1. a single request for a whole subscription, which can have multiple monitored items

2. multiple data changes of the same variable within the same publish: If queues are big enough you should receive each changed value, even if the sample interval is slower than the changing of values

See this, too: https://groups.google.com/forum/m/#!topic/open62541/2LPNraNG3Xw

Julius Pfrommer

unread,
May 10, 2017, 11:48:01 AM5/10/17
to open62541, michael...@googlemail.com, stefano...@zoppas.com
OPC UA Notifications are not polling but push-notification by the server.
You can test this with any generic client, such as UA Expert and a traffic analyzer, such as Wireshark.
There is (nearly no) traffic when the value does not update.
Then open62541 server fully supports this async push-notifications.

The open62541 client SDK however, does not implement async response processing (yet).
Therefore, you need to cyclically send a publish-request to get the notifications. This is done only once in the example.
If your value updates at a higher rate than you are sending publish-requests, you get back an array of notifications with every response.
The callback for processing the notifications is called on every of these notification.

Best regards,
Julius

stefano...@zoppas.com

unread,
May 11, 2017, 2:39:11 AM5/11/17
to open62541, michael...@googlemail.com, stefano...@zoppas.com
Thank you very much for the clarification. I think I must understand better the "async response processing" concept
Reply all
Reply to author
Forward
0 new messages