Commit 6b2b0544 authored by olivier R-D's avatar olivier R-D Committed by ORD

copy type definition when copying node

parent 8f3ed5fc
......@@ -55,11 +55,12 @@ def _rdesc_from_node(parent, node):
rdesc.ReferenceTypeId = ua.NodeId(ua.ObjectIds.Organizes)
else:
rdesc.ReferenceTypeId = ua.NodeId(ua.ObjectIds.HasComponent)
rdesc.TypeDefinition = node.nodeid
typedef = node.get_type_definition()
if typedef:
rdesc.TypeDefinition = typedef
return rdesc
def _read_and_copy_attrs(node_type, struct, addnode):
names = [name for name in struct.__dict__.keys() if not name.startswith("_") and name not in ("BodyLength", "TypeId", "SpecifiedAttributes", "Encoding", "IsAbstract", "EventNotifier")]
attrs = [getattr(ua.AttributeIds, name) for name in names]
......
......@@ -17,6 +17,7 @@ def instantiate(parent, node_type, nodeid=None, bname=None, idx=0):
properties are also instantiated
"""
rdesc = _rdesc_from_node(parent, node_type)
rdesc.TypeDefinition = node_type.nodeid
if nodeid is None:
nodeid = ua.NodeId(namespaceidx=idx) # will trigger automatic node generation in namespace idx
......
......@@ -185,7 +185,7 @@ def _create_object(server, parentnodeid, nodeid, qname, objecttype):
addnode.NodeClass = ua.NodeClass.Object
if isinstance(objecttype, int):
addnode.TypeDefinition = ua.NodeId(objecttype)
elif isinstance(objecttype, ua.NodeId):
else:
addnode.TypeDefinition = objecttype
attrs = ua.ObjectAttributes()
attrs.EventNotifier = 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment