OPC client not receiving updates for variable changes in Server

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

Moderator: uasdknet

Post Reply
Kapil
Jr. Member
Jr. Member
Posts: 3
Joined: 13 Oct 2020, 08:44

OPC client not receiving updates for variable changes in Server

Post by Kapil »

Following instructions from the server getting started
" The only thing that needs to be implemented is the update the value of the Variable node if a data change arrives for this variable. All the read and data monitoring is already handled by the SDK."

I do update a variable by in a Timer method()
foreach (ReferenceNode reference in TestObj_1.FindReferences(UnifiedAutomation.UaBase.ReferenceTypeIds.HierarchicalReferences, false, true, Server.TypeManager))
{
VariableNode variable = FindInMemoryNode((NodeId)reference.TargetId) as VariableNode;
And then Setting the variable.value.
}

If I monitor the node (using FullClient.exe) I get the value at the time of add...The value never refreshes in the client.....unless
I remove and re-add the node to the monitoring section I see the new value.

Please advise on what needs to be done for auto refresh for the clients.

User avatar
h2k_toy
Sr. Member
Sr. Member
Posts: 14
Joined: 24 Sep 2020, 09:13

Re: OPC client not receiving updates for variable changes in Server

Post by h2k_toy »

I suggest you to use (free) UaExpert tool for testing.
It offers much advanced functionality:

Open a event viewer document in the UaExpert.
Then drag the node which contains the variable to that eventviewer window.
You can test it with the server-node.
If your node with your custom variable is not able to be added to the Event window, then i think the
NotifierParent Property of the CreateObjectSettings has to be set to the SErver-Node:

Code: Select all

	    var aWeldDevicesSettings = new CreateObjectSettings()
            {
                ParentNodeId = UnifiedAutomation.UaBase.ObjectIds.ObjectsFolder,
                ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes,
                RequestedNodeId = new NodeId(Name, aNodeManager.DynamicNamespaceIndex.Value),
                BrowseName = new QualifiedName(Name, aNodeManager.DynamicNamespaceIndex.Value),
                TypeDefinitionId = UnifiedAutomation.UaBase.ObjectTypeIds.FolderType,
                [b]NotifierParent = UnifiedAutomation.UaBase.ObjectIds.Server[/b]
            };
It first didnt work for me but when i remember correctly it worked after i added this.
Then you should at least see the event in the event viewer.

But i did not find out how i can test reaction on the ModelChanged-Event, because the uaexpert always polls the value.

Kapil
Jr. Member
Jr. Member
Posts: 3
Joined: 13 Oct 2020, 08:44

Re: OPC client not receiving updates for variable changes in Server

Post by Kapil »

Thanks for your reply.'

I did try adding the NotifierParent for the objects and it can be added to the event viewer.

The client still do not get the Variable updates. Unless I remove and add again...Is there any other call I need to make for clients to be updated on value changes ?

Thanks
Kapil

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

Re: OPC client not receiving updates for variable changes in Server

Post by Support Team »

Hello,

We have to compare the different ways for updating Variable Values. You can configure Variables by calling SetVariableConfiguration. Depending on the passed NodeHandleType, the values are updated in a diffenent way.

The ServerGettingStarted example is using NodeHandleType.ExternalPolled to configure the variables. Here the NodeManager must implement the method Read and Write. This NodeHandleType shall be used if the data source only has read access.
The DemoServer example is using the NodeHandleType.ExternalPushed to configure the variables. Here the NodeManager must implement the method Read and Write, StartDataMonitoring, ModifyDataMonitoring, StopDataMonitoring and SetDataMonitoringMode. The NodeHandleType shall be used if the data source has read access and can report the data changes itself to the application, i.e. it is event driven. It shall also be used if accessing the data source can block.
The NodeHandleType.InternalPolled is set implicitly when LinkModelToNode is called. Please see the HowTo in the UaModeler documentation.
The NodeHandleType.Internal is the default NodeHandleType. If the values of these kind of Variable should change you need to set the Value at the Variable and call

Code: Select all

BaseNodeManager.GetNodeHandle
(http://documentation.unified-automation.com/uasdkdotnet/3.0.6/html/classUnifiedAutomation_1_1UaServer_1_1BaseNodeManager.html#a5cdd54b163ab5827d0a6fe9f03928059) to get a NodeAttributeHandle for the Value attribute. This NodeAttributeHandle has to be used to call

Code: Select all

BaseNodeManager.ReportDataChanges
(http://documentation.unified-automation.com/uasdkdotnet/3.0.6/html/classUnifiedAutomation_1_1UaServer_1_1BaseNodeManager.html#add0a37e23cdf0bcf0b7bc90b2eb42afd).

The event mechanism of OPC UA is different from sending DataChanges.
Best regards
Unified Automation Support Team

Kapil
Jr. Member
Jr. Member
Posts: 3
Joined: 13 Oct 2020, 08:44

Re: OPC client not receiving updates for variable changes in Server

Post by Kapil »

Appreciate the response and solution.
The BaseNodeManager.ReportDataChanges made it happen.

Thanks!
PS - I hope a small note on this can be added to getting started doc will help future users of the SDK.

Post Reply