We're developing an OPC UA server based on the C++ SDK. The server loads an arbitrary nodeset.xml, defined by the user of our product. And during the startup and we need to automatically instantiate some of the object types defined in the nodeset. We managed to get this working, but the solution feels rather hacky and cumbersome. This might be due to our lack of experience with the SDK...
Could someone explain the proper way of doing something like that?
Here are some further details of what we do: We have our custom node manager. The node manager implements the objectTypeCreated method, where we get notified about the created types. Later on, in the allNodesAndReferencesCreated method we iterate through these types, traverse through their hierarchical references and more-or-less clone the object type node with all its child nodes under the Objects folder.
And here are some examples of the things that bother us:
- The hierarchical references of the type node (e.g. 'HasComponent') are stored in the m_lstFullReferences of the UaBase::ObjectType. But this member seems to have no getter. We had to implement our own sub-class where this member is exposed.
- To instantiate the type and its children, we need to "clone" the given nodes, so that the instance has the same properties as the type. It would be nice to use a copy constructor of UaBase::BaseNode, instead of getting-setting each attribute one by one. There is however only the generated copy-constructor and we're not sure if we can trust it.
- When using the SDK functions we often need to "convert" between UaBase::BaseNode and UaNode. They both seem to represent OPC UA nodes but somehow in a different way. Not sure how they meant to be used, or if it's okay to keep switching between the two.
- Some functions we'd like to use (e.g. Browse) require a session. However during startup we don't have any. Is there a way to call such methods without a real OPC UA session?
Etmund