

12:29, EET

December 11, 2017

Hello,
in my UaServer application I create a UaTypeNode as follows:
int ns = nodeManager.getNamespaceIndex();
NodeId ordersTypeId = new NodeId(ns, 1000);
UaObjectTypeNode ordersType = new UaObjectTypeNode(nodeManager, ordersTypeId, “OrderType”, Locale.ENGLISH);
and add variables like this
NodeId priorityId = new NodeId(ns, 108);
CacheVariable priority = new CacheVariable(nodeManager, priorityId, “Priority”, Locale.ENGLISH);
priority.setDataType(int32Type);
priority.setTypeDefinition(dataItemType);
priority.updateValue(new Variant(0));
ordersType.addComponent(priority);
there are more but they are all created and added in the same way. Then I add the created type as a subtype to baseObjectType
nodeManager.addNodeAndReference(baseObjectType, ordersType, Identifiers.HasSubtype);
My problem is, when I create a UaInstance with createInstance() like this
UaInstance order = nodeManager.createInstance(ordersType.getNodeId(), “Name”, nodeId);
it creates a UaNode with “HasTypeDefinition” set to “OrderType” but it does not create the variables as components which are defined in ordersType. So I get an “empty” UaNode object. Can someone please explain what I’m doing wrong?
Kind regards,
Max
14:02, EET

April 3, 2012

Hi,
Since your code does not show them, I would expect the components are missing a HasModellingRule reference. Nodes that do not have a HasModellingRule are not considered part of the type that would be instantiated (they are just extra nodes that are part only of the type node itself, e.g. a “static” Method).
I recommend that you add a Mandatory modellingrule to your components. There is also Optional, but those has to be configured for instantiation and are by default not part of the instances.
– Bjarne
1 Guest(s)
