Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: FreeOpcUa/python-opcua
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9f5dcfc5cd601aa3f03483cb68e529f48d14e307
Choose a base ref
..
head repository: FreeOpcUa/python-opcua
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f37acdcf56a3f107e4ef49fc2f8a1cbc4788999c
Choose a head ref
Showing with 15 additions and 18 deletions.
  1. +2 −3 opcua/common/xmlimporter.py
  2. +11 −12 opcua/common/xmlparser.py
  3. +2 −3 schemas/generate_address_space.py
5 changes: 2 additions & 3 deletions opcua/common/xmlimporter.py
Original file line number Diff line number Diff line change
@@ -144,9 +144,8 @@ def _get_node(self, obj):
node.BrowseName = self._migrate_ns(obj.browsename)
self.logger.info("Importing xml node (%s, %s) as (%s %s)", obj.browsename, obj.nodeid, node.BrowseName, node.RequestedNewNodeId)
node.NodeClass = getattr(ua.NodeClass, obj.nodetype[2:])
if obj.parent:
if obj.parent and obj.parentlink:
node.ParentNodeId = self._migrate_ns(obj.parent)
if obj.parentlink:
node.ReferenceTypeId = self._migrate_ns(obj.parentlink)
if obj.typedef:
node.TypeDefinition = self._migrate_ns(obj.typedef)
@@ -395,7 +394,7 @@ def _add_refs(self, obj):
refs = []
for data in obj.refs:
ref = ua.AddReferencesItem()
ref.IsForward = True
ref.IsForward = data.forward
ref.ReferenceTypeId = self.to_nodeid(data.reftype)
ref.SourceNodeId = self._migrate_ns(obj.nodeid)
ref.TargetNodeClass = ua.NodeClass.DataType
23 changes: 11 additions & 12 deletions opcua/common/xmlparser.py
Original file line number Diff line number Diff line change
@@ -329,17 +329,16 @@ def _parse_body(self, el):

def _parse_refs(self, el, obj):
for ref in el:
struct = RefStruct()
struct.forward = "IsForward" not in ref.attrib or ref.attrib["IsForward"] not in ("false", "False")
struct.target = ref.text
struct.reftype = ref.attrib["ReferenceType"]
obj.refs.append(struct)

if ref.attrib["ReferenceType"] == "HasTypeDefinition":
obj.typedef = ref.text
elif "IsForward" in ref.attrib and ref.attrib["IsForward"] in ("false", "False"):
# if obj.parent:
# sys.stderr.write("Parent is already set with: "+ obj.parent + " " + ref.text + "\n")
obj.parent = ref.text
obj.parentlink = ref.attrib["ReferenceType"]
else:
struct = RefStruct()
if "IsForward" in ref.attrib:
struct.forward = ref.attrib["IsForward"]
struct.target = ref.text
struct.reftype = ref.attrib["ReferenceType"]
obj.refs.append(struct)
elif not struct.forward:
if not obj.parent:
obj.parent = ref.text
if obj.parent == ref.text:
obj.parentlink = ref.attrib["ReferenceType"]
5 changes: 2 additions & 3 deletions schemas/generate_address_space.py
Original file line number Diff line number Diff line change
@@ -90,9 +90,8 @@ def make_node_code(self, obj, indent):
self.writecode(indent, 'node.RequestedNewNodeId = ua.NodeId.from_string("{0}")'.format(obj.nodeid))
self.writecode(indent, 'node.BrowseName = ua.QualifiedName.from_string("{0}")'.format(obj.browsename))
self.writecode(indent, 'node.NodeClass = ua.NodeClass.{0}'.format(obj.nodetype[2:]))
if obj.parent:
if obj.parent and obj.parentlink:
self.writecode(indent, 'node.ParentNodeId = ua.NodeId.from_string("{0}")'.format(obj.parent))
if obj.parent:
self.writecode(indent, 'node.ReferenceTypeId = {0}'.format(self.to_ref_type(obj.parentlink)))
if obj.typedef:
self.writecode(indent, 'node.TypeDefinition = ua.NodeId.from_string("{0}")'.format(obj.typedef))
@@ -267,7 +266,7 @@ def make_refs_code(self, obj, indent):
self.writecode(indent, "refs = []")
for ref in obj.refs:
self.writecode(indent, 'ref = ua.AddReferencesItem()')
self.writecode(indent, 'ref.IsForward = True')
self.writecode(indent, 'ref.IsForward = {0}'.format(ref.forward))
self.writecode(indent, 'ref.ReferenceTypeId = {0}'.format(self.to_ref_type(ref.reftype)))
self.writecode(indent, 'ref.SourceNodeId = ua.NodeId.from_string("{0}")'.format(obj.nodeid))
self.writecode(indent, 'ref.TargetNodeClass = ua.NodeClass.DataType')