Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters

Please confirm you want to mark all posts read

Mark all topics read

sp_MobileMenu Actions
Avatar

New/Updated Topics

Select Forum

sp_TopicIcon
Best way to animate or replace existing Predefined Nodes in server address space
Avatar
Julien BENNET
Posts: 6
03/05/2020 - 03:00

1

I was attempting to customize values of some of the existing well-known nodes in the predefined address space.

Others UA implementations offer "re-binding" solution where you just re-map a node-id with your callbacks and/or data.

Is there an easy way, with existing sample code, to easily re-bind a predefined node ? (Could only find documentation about creating own custom address space, not modifying existing nodes)

 

I was a bit puzzled by the classes CoreNodeManager and ConfigurationNodeManager, with their different public interfaces, and came up with a solution. But it looks way too complicated !

To add a node,  linked to existing system structure :

// Create a new NodeState :
var myNewNodeState = new BaseDataVariableState<string>(existingparent) //or new PropertyState()
// Link it with parent : 
existingparent.AddChild(myNewNodeState)
// Import the node into the CoreNodeManager and AddReference within the CoreNodeManager 
server.CoreNodeManager.ImportNodes(server.DefaultSystemContext, new NodeState[] { myNewNodeState });
server.CoreNodeManager.AddReference(existingparent.NodeId, ReferenceTypeIds.HasProperty, false, myNewNodeState.NodeId, false);

To replace a node in predefined system structure :

// Create a new NodeState :
var myNewNodeState = new BaseDataVariableState<string>(existingparent) //or new PropertyState()
// REPLACE it with parent : 
existingparent.ReplaceChild(myNewNodeState)

// HACK : Get ConfigurationNodeManager (my node is handled by this manager)
INodeManager myNodeMgr;
Opc.Ua.Server.NodeHandle objectX = (Opc.Ua.Server.NodeHandle)server.NodeManager.GetManagerHandle(myNewNodeState.NodeId, out myNodeMgr);
var cfgManager = myNodeMgr as ConfigurationNodeManager;
// DELETE THE NODE REFERENCE FROM ConfigManager AND CoreManager
cfgManager.DeleteNode(server.DefaultSystemContext, myNewNodeState.NodeId);
server.CoreNodeManager.DeleteNode(myNewNodeState.NodeId, deleteChildren: true, silent: true);

// Import the node into the CoreNodeManager and AddReference within the CoreNodeManager  (can't re-import in ConfigManager without screwing the NodeId!)
server.CoreNodeManager.ImportNodes(server.DefaultSystemContext, new NodeState[] { myNewNodeState });
server.CoreNodeManager.AddReference(existingparent.NodeId, ReferenceTypeIds.HasProperty, false, myNewNodeState.NodeId, false);

 

Maybe there is a less convoluted way to do this ?

Avatar
Randy Armstrong
Posts: 1664
03/05/2020 - 10:41

2

You are doing it the way it needs to be done.

Some of the APIs in the code base are more complex than they need to be but fixing them would be a lot of effort and there is a shortage of volunteers.

Avatar
Julien BENNET
Posts: 6
03/06/2020 - 00:55

3

Ok thanks Randy.

Forum Timezone:
America/Phoenix
Most Users Ever Online: 975
Currently Online: Clifford Almeida
Guest(s) 36
Currently Browsing this Page:
1 Guest(s)

Devices in use: Desktop (34), Phone (3)

Forum Stats:
Groups: 2
Forums: 10
Topics: 1515
Posts: 5123