Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
77cc726d
Commit
77cc726d
authored
Aug 21, 2016
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix importing unknown reference type
parent
33fbe220
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
opcua/common/node.py
opcua/common/node.py
+7
-2
opcua/common/xmlexporter.py
opcua/common/xmlexporter.py
+15
-9
No files found.
opcua/common/node.py
View file @
77cc726d
...
...
@@ -356,10 +356,15 @@ class Node(object):
def
get_parent
(
self
):
"""
returns parent of the node.
A Node may have several parents, the first found is returned.
This method uses reverse references, a node might be missing such a link,
thus we will not find its parent.
"""
refs
=
self
.
get_references
(
refs
=
ua
.
ObjectIds
.
HierarchicalReferences
,
direction
=
ua
.
BrowseDirection
.
Inverse
)
return
Node
(
self
.
server
,
refs
[
0
].
NodeId
)
if
len
(
refs
)
>
0
:
return
Node
(
self
.
server
,
refs
[
0
].
NodeId
)
else
:
return
None
def
get_child
(
self
,
path
):
"""
...
...
opcua/common/xmlexporter.py
View file @
77cc726d
...
...
@@ -61,6 +61,7 @@ class XmlExporter(object):
#from IPython import embed
#embed()
if
pretty
:
self
.
etree
.
write
(
xmlpath
+
"-not-pretty.xml"
,
short_empty_elements
=
False
)
rough_string
=
Et
.
tostring
(
self
.
etree
.
getroot
(),
'utf-8'
)
reparsed
=
minidom
.
parseString
(
rough_string
)
pretty_string
=
reparsed
.
toprettyxml
(
indent
=
" "
)
...
...
@@ -108,7 +109,7 @@ class XmlExporter(object):
def
_add_node_common
(
self
,
nodetype
,
node
):
browsename
=
node
.
get_browse_name
().
to_string
()
nodeid
=
node
.
nodeid
.
to_string
()
parent
=
node
.
get_parent
()
.
nodeid
.
to_string
()
parent
=
node
.
get_parent
()
displayname
=
node
.
get_display_name
().
Text
.
decode
(
encoding
=
'UTF8'
)
desc
=
node
.
get_description
().
Text
if
desc
is
None
:
...
...
@@ -117,8 +118,9 @@ class XmlExporter(object):
node_el
=
Et
.
SubElement
(
self
.
etree
.
getroot
(),
nodetype
,
BrowseName
=
browsename
,
NodeId
=
nodeid
,
ParentNodeId
=
parent
)
NodeId
=
nodeid
)
if
parent
is
not
None
:
node_el
.
attrib
[
"ParentNodeId"
]
=
parent
.
nodeid
.
to_string
()
if
desc
not
in
(
None
,
""
):
node_el
.
attrib
[
"Description"
]
=
desc
disp_el
=
Et
.
SubElement
(
node_el
,
'DisplayName'
,
)
...
...
@@ -142,8 +144,12 @@ class XmlExporter(object):
self
.
_add_ref_els
(
obj_el
,
node
)
def
add_variable_common
(
self
,
node
,
el
):
datatype
=
o_ids
.
ObjectIdNames
[
node
.
get_data_type
().
Identifier
]
datatype_nodeid
=
node
.
get_data_type
().
to_string
()
dtype
=
node
.
get_data_type
()
if
dtype
.
Identifier
in
o_ids
.
ObjectIdNames
:
datatype
=
o_ids
.
ObjectIdNames
[
dtype
.
Identifier
]
self
.
aliases
[
datatype
]
=
dtype
.
to_string
()
else
:
datatype
=
dtype
.
to_string
()
rank
=
node
.
get_value_rank
()
value
=
str
(
node
.
get_value
())
print
(
"VAR COMMON"
,
node
,
rank
,
value
,
datatype
)
...
...
@@ -153,7 +159,6 @@ class XmlExporter(object):
val_el
=
Et
.
SubElement
(
el
,
'Value'
)
valx_el
=
Et
.
SubElement
(
val_el
,
'uax:'
+
datatype
)
valx_el
.
text
=
value
self
.
aliases
[
datatype
]
=
datatype_nodeid
def
add_etree_variable
(
self
,
node
):
"""
...
...
@@ -190,12 +195,10 @@ class XmlExporter(object):
def
add_etree_method
(
self
,
obj
):
obj_el
=
self
.
_add_node_common
(
"UAMethod"
,
obj
)
self
.
_add_ref_els
(
obj_el
,
obj
)
raise
NotImplementedError
def
add_etree_reference
(
self
,
obj
):
obj_el
=
self
.
_add_node_common
(
"UAReference"
,
obj
)
self
.
_add_ref_els
(
obj_el
,
obj
)
raise
NotImplementedError
def
add_etree_datatype
(
self
,
obj
):
"""
...
...
@@ -227,7 +230,10 @@ class XmlExporter(object):
refs_el
=
Et
.
SubElement
(
parent_el
,
'References'
)
for
ref
in
refs
:
ref_name
=
o_ids
.
ObjectIdNames
[
ref
.
ReferenceTypeId
.
Identifier
]
if
ref
.
ReferenceTypeId
.
Identifier
in
o_ids
.
ObjectIdNames
:
ref_name
=
o_ids
.
ObjectIdNames
[
ref
.
ReferenceTypeId
.
Identifier
]
else
:
ref_name
=
ref
.
ReferenceTypeId
.
to_string
()
ref_forward
=
str
(
ref
.
IsForward
).
lower
()
ref_nodeid
=
ref
.
NodeId
.
to_string
()
ref_el
=
Et
.
SubElement
(
refs_el
,
'Reference'
,
IsForward
=
ref_forward
,
ReferenceType
=
ref_name
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment