Clarifications about ExternalPush ValueTypes

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

Moderator: uasdknet

Post Reply
efzed
Full Member
Full Member
Posts: 7
Joined: 12 Jun 2015, 01:42

Clarifications about ExternalPush ValueTypes

Post by efzed »

Hello,
I can't find any example about NodeHandleType.ExternalPush data.

So far my understanding is as follows:

Internal
---------
If a variable has an Internal ValueType its value attribute is completely handled by the NodeManager -- no hook functions for customizing reading nor writing.
When creating a variable an initial value can be provided (e.g. CreateVariableSettings.Value).
If you try to modify a Node value from within the NodeManager the change isn't published to clients.
(Seems like you can't modify the points and let the clients know that using this approach)

ExternalPolled
-----------------
If a variable has an ExternalPolled ValueType its value attribute is completely handled by the overridden Read and Write methods of NodeManager.
No value is held internally in each Node (is this true?), so without providing a Read method no value can be retrieved.
When creating a variable no initial value can be provided (it would be useless anyway) but instead a custom object must be provided in CreateVariableSettings.ValueData as a container for the value (or for other parameters needed to retrieve the value from somewhere else through Read method)

ExternalPush
------------------
Looking at Fig. 3.4 of http://documentation.unified-automation ... ess03.html, I thought that if a variable has an ExternalPush ValueType its value is held by the NodeManager (internally in each Node without the need of a custom ValueData object) and that an external action can modify the Node value attribute.
From the figure isn't clear though if the value attribute is held inside the node or if a ValueData user object must be provided to hold any value.
Secondly, it is not clear to me how the value attribute can be changed and published to the OPC clients.
I have tried:

StatusCode status = node.Write(Attributes.Value, value);

NodeAttributeHandle handle;
GetNodeHandle(Server.DefaultRequestContext, nodeId, Attributes.Value, out handle);
ReportDataChanges(Server.DefaultRequestContext, handle);

without success.

Is any example of using ExternalPush mode available?

Thanks

F.

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

Re: Clarifications about ExternalPush ValueTypes

Post by Support Team »

Hello,

Here is a short summary for changing the values of Variables using the different NodeHandleTypes

Internal
-----------
You are right, the value attribute is complete handled by the NodeManager. If you are setting a value of an "Internal" Variable, you have to call ReportDataChanges as you described for ExternalPush.

Code: Select all

NodeAttributeHandle handle;
GetNodeHandle(Server.DefaultRequestContext, nodeId, Attributes.Value, out handle);
ReportDataChanges(Server.DefaultRequestContext, handle);
ExternalPolled
-----------------
The in-memory-node does not hold the value of a Variable. The value is received by the Read method of the NodeManager. It is application logic to return the correct value in the Read method. In our Server Getting Started example we are using the UserData of the NodeHandle to get the address of the node.

ExternalPush
-----------------
You have to implement Read/Write/StartMonitoring/StopMontoring in your NodeManager (see http://documentation.unified-automation ... aAccessEtc). We are using the NodeHandleType ExternalPush in our DemoServer example.

Best regards
Support Team

efzed
Full Member
Full Member
Posts: 7
Joined: 12 Jun 2015, 01:42

Re: Clarifications about ExternalPush ValueTypes

Post by efzed »

Hi,
I'd like to have some more clarifications about ExternalPush NodeHandleType; when I create a Variable Node I assign a value to it:

[...]
varSettings.ValueData = new <myclass>(intialValue); // myclass is similar to ValueDataSource of the UaDemoServer
VariableNode variable = CreateVariable(Server.DefaultRequestContext, varSettings);

Every method in the UaServerDemo that handles such variable receives a handle that allows to retrieve such ValueData (tipically through a cast) -- this makes me suspect that the value that I initially setup is possibly still stored somewhere in the server (NodeManager?).

If I want to programmatically change the value of my variable, say from an event handler (not from an OPC client), when I try to get the variable with FindInMemoryNode I can't find any property that resembles ValueData or anything else that lets me get to it (say a UserData property that could be cast to myclass, i.e. a Datasource class).

The question is: is a link to the ValueData available anywhere in the server/node manager, or is it completely responsibility of the application using the SDK to maintain a (further) copy of such values?

efzed
Full Member
Full Member
Posts: 7
Joined: 12 Jun 2015, 01:42

Re: Clarifications about ExternalPush ValueTypes

Post by efzed »

Hi there,
I think I found the correct way, but I hope to get a confirm.
The way to get a variable node with all its stuff (I am focusing on its associated value, that for ExternalPush variables is user managed) is not by retrieving a node from the in-memory representation, like this:

Code: Select all

    // Wrong
    NodeId varNodeId = new NodeId("myNodeId", InstanceNamespaceIndex);
    VariableNode varNode = FindInMemoryNode(varNodeId) as VariableNode;
but by retrieving a handle to the right attribute:

Code: Select all


    NodeAttributeHandle handle;
    GetNodeHandle(Server.DefaultRequestContext, varNodeId, Attributes.Value, out handle);
Now handle has all the correct properties, specifically the user defined stored value in the UserData property.
If I want to programmatically change the value of a variable attribute and report it to monitoring clients I can thus do it this way:

Code: Select all

    // Say I want to change a value to 12345.67
    DataValue dv = new DataValue(new Variant(12345.67)) { ServerTimestamp = DateTime.MinValue };

    NodeAttributeHandle handle;
    GetNodeHandle(Server.DefaultRequestContext, varNodeId, Attributes.Value, out handle);

    Write(Server.DefaultRequestContext, handle, null, dv);

    // publish the change to monitoring clients
    ReportDataChanges(Server.DefaultRequestContext, handle);

Post Reply