0
Beantwortet

Subscription fields are mostly null

JGIngaa vor 3 Monaten in OPCUA4Unity aktualisiert von Thomas vor 3 Monaten 3

Dear game4automation team,

so far the OPCUA4Unity asset works very smooth. Great work!

In my project I tried to update my data like you show in the DemoTextWithDelegate example. But the subscription object returned in OPCUA_Interface :

sub = connection.SubscribeNodeDataChange(nodeid,del);

is pretty much empty:

I used UAExpert to test the subscription with the same node id, which worked. As far as I can tell I do not get any warnings or errors. Here is my code how I subscribe:

private OPCUANodeSubscription _safetyLevelSubscription; //subscription is a class member
[...]
_safetyLevelSubscription = _interface.Subscribe(node.NodeId, SafetyLevelNodeChanged); //this is the call
[...]
 public void SafetyLevelNodeChanged(OPCUANodeSubscription sub, object obj) //this is the delegate signature

Now, I noticed that the OPCUAInterface gameobject holds pretty much all the nodes of the top node as childs and keeps them up to date. At least in the editor. Wouldn't it be best practice then to always access those child OPCUA_Nodes instead of adding an additional subscription?

Thanks for your thoughts!

JG

EDIT:

Maybe I should add, that the delegate is not called when the value on the OPC UA server changes. I assume it is due to the null ptr in the subscription. Also, I use a codesys opc ua stack.

Antwort

Antwort
Wird überprüft

Thanks for the positive feedback. Please give us a review in the Asset Store if you like it.

You have both options. Subscribe in code or use the imported child nodes for accessing the values.

Usually the subscription gets null if the server is not reachable. Some servers are also limiting the number of subscriptions - maybe this is the case on your server. Do you see anything in the console log?

Antwort
Wird überprüft

Thanks for the positive feedback. Please give us a review in the Asset Store if you like it.

You have both options. Subscribe in code or use the imported child nodes for accessing the values.

Usually the subscription gets null if the server is not reachable. Some servers are also limiting the number of subscriptions - maybe this is the case on your server. Do you see anything in the console log?

Ok after some more testing I found the cause of the problem: It seems like a the subscription gets an exception whenever I use a "force" mode to write a value on my plc. When this happend I need to restart the plc and opcua4unity can subscribe as it should be. I guess the problem is within the plc system then, so I reported it to the guys @CodeSys. 

Thank you!