New subscription returns initial data change value

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
mantela
Hero Member
Hero Member
Posts: 21
Joined: 28 Mar 2017, 07:20

New subscription returns initial data change value

Post by mantela »

Hello Support Team,

I noticed that I always get an initial data change value after creating a new UaSubscription (see below).

[2017-10-10 10:01:23.279 DBG default] ..\..\..\modules\DMPAcE_ImatecPLCLib\OPCUADataSubscription.cpp:230 - CreateMonitoredItems succeeded for item: ns=4;s=UA_ST040.OUT_WtInPosition.UAO_SyncTokenOut
[2017-10-10 10:01:23.289 DBG default] ..\..\..\modules\DMPAcE_ImatecPLCLib\OPCUAClient.cpp:109 - Connection status changed to Connected
...
[2017-10-10 10:01:23.481 DBG default] ..\..\..\modules\DMPAcE_ImatecPLCLib\OPCUADataSubscription.cpp:74 - Data of variable UA_ST040.OUT_WtInPosition.UAO_SyncTokenOut was changed to value 0

Unfortunately this is not the desired behaviour because I am listening to the OPCUADataSubscription (UAO_SyncTokenOut) with a NotificationService which automatically starts running a test sequence.
My current work around was to add a short timeout of 1 second after creating a new subscription. But this is not a good solution because the performance is getting worse. So is there a way to eliminate this initial data change?

Thank you in advance!

Andre

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: New subscription returns initial data change value

Post by Support Team »

Hello Andre,

that's the expected and specified behaviour. OPC defines to send an initial value for each DataMonitoredItem in a subscription.
Best regards
Unified Automation Support Team

mantela
Hero Member
Hero Member
Posts: 21
Joined: 28 Mar 2017, 07:20

Re: New subscription returns initial data change value

Post by mantela »

Thank you for your response.

Is there another solution to ignore the initial data change?

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: New subscription returns initial data change value

Post by Support Team »

Hello Andre,

there is no solution to ignore the initial DataChange and it doesn't really make sense.

- Assume at time X the client creates a Subscription and a MonitoredItem.
- At time x+1 the value of a Variable changes.
- At time x+2 the server actually samples the Variable
- At time x+3 the server send sthe initial DatachangeNotification
So the client will discard the value and wait forever.

If you have to ignore any DataChangeNotification you have a logical problem in your application.
If you want to set a trigger in the server to let the client start an action you should use a well defined trigger for that.
e.g. a Variable with values
0 - no action / finished
1 - start action
2 - action in progress
Best regards
Unified Automation Support Team

mantela
Hero Member
Hero Member
Posts: 21
Joined: 28 Mar 2017, 07:20

Re: New subscription returns initial data change value

Post by mantela »

Well, I do not want to ignore any data change but I do not want to get a data change notification even if there is none (directly after creating a new subscription - this information is nice to know but I do not need it and I do not want to receive it!).
The actual problem I have is that I subscribe to a OPC UA server variable at the beginning of each OPC UA client command. This variable indicates that the PLC executed an arbitrary command and answered correctly. After subscribing I set (read and write) several OPC UA variables and afterwards I wait for the data change to synchronise my program/the OPC UA server <-> client communication (I do this with QWaitCondition). So if i get a data change notification directly after creating a subscription, my program is going on, even if the PLC is still working and has not answered yet.
So actually the question is how can I synchronise my PLC executing commands with the OPC UA client commands?

mantela
Hero Member
Hero Member
Posts: 21
Joined: 28 Mar 2017, 07:20

Re: New subscription returns initial data change value

Post by mantela »

Another option that came to my mind would be to use the filter element in http://documentation.unified-automation ... ption.html but I'm not sure how I can use it or where it has to be set. Is there a way to filter out predefined data notifications? Could you please give me an example?

Post Reply