OPC-UA Driver Allow Reading without Predefined Nodes

Hello, I am attempting to create a new OPC UA Driver extending ManagedDevice. I have a working implementation using predefined nodes for all data being accessed. Now, I am trying to make it more dynamic and since there may be a rather large amount of possible nodes, I would rather be able to access them in a method similar to the Modbus Driver with the “ns=1;s=[device]HRF1234” methodology.

I am able to perform direct OPC reads via the Script console at this point but I cannot figure out the subscription bit for usage with tags. The tags are giving an “Error_Configuration” message, though they work with my old driver. I am addressing the various attributes using values I found by logging a predefined diagnostic node. Here is what I am trying for a node that is not in the NodeManager:

String nodeName = getNodeName(id.getNodeId());
DataValue value = httpJsonHandler.getValue(nodeName);
AttributeId attributeId = AttributeId.from(id.getAttributeId()).get();
Object v;
switch (attributeId)
    case AccessLevel:
        v = AccessLevel.READ_ONLY;
    case UserAccessLevel:
        v = AccessLevel.READ_ONLY;
    case EventNotifier:
        v = null;
    case MinimumSamplingInterval:
        v = -1.0;
    case DataType:
        v = BuiltinDataType.Float.getNodeId();
        v = null;

if (attributeId == AttributeId.Value)
    results.add(new DataValue(new Variant(v)));   

I tried logging the onDataItemsCreated and only the predefined node appeared. I couldn’t find any docs on the ManagedDevice but I have been basing everything so far on Milo’s ManagedAddressSpaceServices. Any help you can offer would be appreciated.

Thank you,

1 Like

ManagedDevice (and all the Managed* Milo classes) might be the wrong approach for having dynamically addressable Nodes, but you can probably still get it to work by overriding the read and write methods at the very least. Implementing just onDataItemsCreated isn’t enough - you’ll never get far enough to have that called for a dynamically addressed Node if read isn’t implemented to return attributes for those Nodes.

If your device implementation will be entirely dynamic and not a hybrid then the “Managed” abstractions are probably wrong for you all together. They basically just take care of implementing browse, read, and write based on the assumption all Nodes will be registered with the NodeManager. If that’s not going to be true at all you may as well just implement Device directly.



Avoiding a full implementation of Device is not really an option if you want dynamic node creation. Well, unless you implement the older Driver interface instead (ahem, cough).

1 Like

I appreciate the advice. That at least gives me some direction for the future. I think I will dig into the full Device implementation at some point. For now, I am just adding Nodes to the node manager as needed in the read method and then removing them if they haven’t been accessed in a while.

1 Like

That is exactly what I want to do but don’t know how to implement the read method
some pointers please , i am also using the ManagedDevice

1 Like