OPCFoundation / UA-.NETStandard

OPC Unified Architecture .NET Standard
Other
1.97k stars 950 forks source link

Instanciate Pre-defined nodes automaticaly #2852

Open william-hazem opened 2 days ago

william-hazem commented 2 days ago

Type of issue

Current Behavior

Are there any mechanisms in the framework that allow handling pre-defined nodes, such as instances of custom object types in the model file (.xml)?

I have pre-defined instances in the .xml of a custom object type. In my custom node manager, I have hard-coded definitions and instances such that:

internal class MyNodeManager : CustomNodeManager2
    {
        private MyServerConfiguration mConfiguration;
        private static CustomTypeState1 mCustomObj1;
        private static CustomTypeState2 mCustomObj2;
        ...
public override void CreateAddressSpace(IDictionary<NodeId, IList<IReference>> externalReferences)
{
            lock (Lock)
            {
                LoadPredefinedNodes(SystemContext, externalReferences);

                BaseObjectState passiveNode = (BaseObjectState)FindPredefinedNode(new NodeId(yourorganisation.org.Planta.Objects.Object1, base.NamespaceIndexes[0]), typeof(BaseObjectState));
                BaseObjectState passiveNode2 = (BaseObjectState)FindPredefinedNode(new NodeId(yourorganisation.org.Planta.Objects.Object2, base.NamespaceIndexes[0]), typeof(BaseObjectState));
               ...
                mCustomObj1= new CustomTypeState1(null);
                mCustomObj1.Create(SystemContext, passiveNode);
                ...
                mCustomObj2 = new CustomTypeState2(null);
                mCustomObj2.Create(SystemContext, passiveNode2);
                ...
                AddPredefinedNode(SystemContext, mCustomObj1);
                AddPredefinedNode(SystemContext, mCustomObj2);
                ....
            }
}

For each node, I need to address it manually and manage every object ID, object type, and namespace and explicit instance. Is there any way to generalize this instantiation for any application? (Suppose there are hundreds of nodes and types in my application).

Expected Behavior

No response

Steps To Reproduce

No response

Environment

No response

Anything else?

No response