OPCFoundation / UA-.NETStandard

OPC Unified Architecture .NET Standard
Other
1.95k stars 945 forks source link

AddPredifnedNode at runtime #504

Closed benjamin1988 closed 6 years ago

benjamin1988 commented 6 years ago

Hello, I'm fighting with an issue. I have Classes and predefined nodes with the model compiler. After "normal" starting of the opc UA server with the standard namespaces. We add during runtime our predefined nodes. First of all we add the Opc.Ua.DI DI Nodeset.zip predefined nodes and afterwards our custom predefined nodes CustomNodes and Classes.zip. This is done with the Server.NodeManager.CoreNodeManager.ImportNodes function. Afterwards we want to add an instance of our custom DeviceState Type. _Device = new DeviceState(null);

    _Device.Create(SystemContext, null, new QualifiedName(_DeviceAdapter.MachineName, _NamespaceIndex), null, true);

This custom Object is created in the DeviceSet of the OPC.Ua.DI via references: // link root to objects folder. IList references = null;

    NodeId deviceSet = ExpandedNodeId.ToNodeId(Opc.Ua.Di.ObjectIds.DeviceSet, Server.NamespaceUris);

    if (!externalReferences.TryGetValue(deviceSet, out references))
    {
      externalReferences[deviceSet] = references = new List<IReference>();
    }
    references.Add(new Opc.Ua.NodeStateReference(Opc.Ua.ReferenceTypeIds.Organizes, false, _Device.NodeId));
    AddPredefinedNode(SystemContext, _Device);

Now we try to check the whole Address space via the OPC UA Expert. And saw that the instance of the object is correct. but the Attributes oft the nodes aren't shown correctly. uaexpert

We also tried to register the NamespaceManager which is added during runtime, but without any success. _ServerInternal.NodeManager.RegisterNamespaceManager(Opc.Ua.Di.Namespaces.OpcUaDi, manager); _ServerInternal.NodeManager.RegisterNamespaceManager(Opc.Ua.DeviceModel.Namespaces.DeviceModel, manager);

At least its very strange thate the UA:Expert shows the right NodeId at the bottom of the window. Our NodeStateFactory creates Numeric nodeIds increasing 16000: grafik

Do you know what we do wrong? I don't know what to do and just tried a lot of different ways.

Thanks

benjamin1988 commented 6 years ago

I could solve the problem by adding our custom nodemanager at startup and creating the instance afterwards. Sorry was my fault.