Simplify Updating Node Attributes Across All Namespace Fragments? #16
Unanswered
Mame-Ibra859
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
To modify the attributes (e.g., display name and description) of an OPC UA node, I added a method addMethodUpdateNodeAttributes() in DynamicNodeFragment.java, and I call it inside the addDynamicNodes() method of the same class.
However, this method only works for nodes registered in the Dynamic, because this line:
UaNode node = getNodeManager().get(new NodeId(namespace.getNamespaceIndex(), identifier));
only finds nodes that are known to the current fragment's NodeManager.
From this, I concluded that I would need to write similar methods in each fragment class (VariantNodesFragment.java, DataTypeTestNodesFragment.java, DemoNamespace.java, DynamicNodesFragment.java, etc.) to be able to update the nodes they each manage.
Is there a simpler or more global way to implement this functionality perhaps a shared or central access to all nodes so that I don't have to duplicate this update method in every fragment class?
Here's my current method for reference:
public void addMethodUpdateNodeAttributes() {
try {
UaMethodNode updateNodeAttributesMethod = UaMethodNode.builder(getNodeContext())
.setNodeId(deriveChildNodeId(namespace.getDemoFolder().getNodeId(), "updateNodeAttributes"))
.setBrowseName(new QualifiedName(namespace.getNamespaceIndex(), "updateNodeAttributes"))
.setDisplayName(LocalizedText.english("updateNodeAttributes"))
.setDescription(LocalizedText.english("Method for update a node"))
.setExecutable(true)
.setUserExecutable(true)
.build();
}
Any suggestions for a more centralized or reusable approach?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions