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
6c18d694
Commit
6c18d694
authored
Sep 21, 2016
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add some missing attributes
parent
28dc5b20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
17 deletions
+31
-17
opcua/common/xmlexporter.py
opcua/common/xmlexporter.py
+31
-17
No files found.
opcua/common/xmlexporter.py
View file @
6c18d694
...
@@ -65,7 +65,7 @@ class XmlExporter(object):
...
@@ -65,7 +65,7 @@ class XmlExporter(object):
short_empty_elements
=
False
,
short_empty_elements
=
False
,
encoding
=
'utf-8'
,
encoding
=
'utf-8'
,
xml_declaration
=
True
xml_declaration
=
True
)
)
else
:
else
:
self
.
etree
.
write
(
xmlpath
,
self
.
etree
.
write
(
xmlpath
,
short_empty_elements
=
False
,
short_empty_elements
=
False
,
...
@@ -120,23 +120,25 @@ class XmlExporter(object):
...
@@ -120,23 +120,25 @@ class XmlExporter(object):
displayname
=
node
.
get_display_name
().
Text
.
decode
(
'utf-8'
)
displayname
=
node
.
get_display_name
().
Text
.
decode
(
'utf-8'
)
desc
=
node
.
get_description
().
Text
desc
=
node
.
get_description
().
Text
print
(
"NODE COMMON"
,
node
)
print
(
"NODE COMMON"
,
node
)
node_el
=
Et
.
SubElement
(
self
.
etree
.
getroot
(),
node_el
=
Et
.
SubElement
(
self
.
etree
.
getroot
(),
nodetype
)
nodetype
,
node_el
.
attrib
[
"NodeId"
]
=
nodeid
BrowseName
=
browsename
,
node_el
.
attrib
[
"BrowseName"
]
=
browsename
NodeId
=
nodeid
)
if
parent
is
not
None
:
if
parent
is
not
None
:
node_el
.
attrib
[
"ParentNodeId"
]
=
parent
.
nodeid
.
to_string
()
node_el
.
attrib
[
"ParentNodeId"
]
=
parent
.
nodeid
.
to_string
()
self
.
_add_sub_el
(
node_el
,
'DisplayName'
,
displayname
)
if
desc
not
in
(
None
,
""
):
if
desc
not
in
(
None
,
""
):
self
.
_add_sub_el
(
node_el
,
'Description'
,
desc
.
decode
(
'utf-8'
))
self
.
_add_sub_el
(
node_el
,
'Description'
,
desc
.
decode
(
'utf-8'
))
self
.
_add_sub_el
(
node_el
,
'DisplayName'
,
displayname
)
#FIXME: add WriteMask and UserWriteMask
return
node_el
return
node_el
def
add_etree_object
(
self
,
obj
):
def
add_etree_object
(
self
,
node
):
"""
"""
Add a UA object element to the XML etree
Add a UA object element to the XML etree
"""
"""
obj_el
=
self
.
_add_node_common
(
"UAObject"
,
obj
)
obj_el
=
self
.
_add_node_common
(
"UAObject"
,
node
)
self
.
_add_ref_els
(
obj_el
,
obj
)
var
=
node
.
get_attribute
(
ua
.
AttributeIds
.
EventNotifier
)
obj_el
.
attrib
[
"EventNotifier"
]
=
str
(
var
.
Value
.
Value
)
self
.
_add_ref_els
(
obj_el
,
node
)
def
add_etree_object_type
(
self
,
node
):
def
add_etree_object_type
(
self
,
node
):
"""
"""
...
@@ -158,6 +160,8 @@ class XmlExporter(object):
...
@@ -158,6 +160,8 @@ class XmlExporter(object):
rank
=
node
.
get_value_rank
()
rank
=
node
.
get_value_rank
()
el
.
attrib
[
"DataType"
]
=
dtype_name
el
.
attrib
[
"DataType"
]
=
dtype_name
el
.
attrib
[
"ValueRank"
]
=
str
(
int
(
rank
))
el
.
attrib
[
"ValueRank"
]
=
str
(
int
(
rank
))
#var = node.get_attribute(ua.AttributeIds.ArrayDimensions())
#self._addobj_el.attrib["ArrayDimensions"] = str(var.Value.Value)
value_to_etree
(
el
,
dtype_name
,
dtype
,
node
)
value_to_etree
(
el
,
dtype_name
,
dtype
,
node
)
def
add_etree_variable
(
self
,
node
):
def
add_etree_variable
(
self
,
node
):
...
@@ -171,12 +175,18 @@ class XmlExporter(object):
...
@@ -171,12 +175,18 @@ class XmlExporter(object):
useraccesslevel
=
node
.
get_attribute
(
ua
.
AttributeIds
.
UserAccessLevel
).
Value
.
Value
useraccesslevel
=
node
.
get_attribute
(
ua
.
AttributeIds
.
UserAccessLevel
).
Value
.
Value
# We only write these values if they are different from defaults
# We only write these values if they are different from defaults
# default must of course mange the one in manage_nodes.py
# Not sure where default is defined....
# and other OPC UA servers
if
accesslevel
!=
ua
.
AccessLevel
.
CurrentRead
.
mask
:
if
accesslevel
!=
ua
.
AccessLevel
.
CurrentRead
.
mask
:
var_el
.
attrib
[
"AccessLevel"
]
=
str
(
accesslevel
)
var_el
.
attrib
[
"AccessLevel"
]
=
str
(
accesslevel
)
if
useraccesslevel
!=
ua
.
AccessLevel
.
CurrentRead
.
mask
:
if
useraccesslevel
!=
ua
.
AccessLevel
.
CurrentRead
.
mask
:
var_el
.
attrib
[
"UserAccessLevel"
]
=
str
(
useraccesslevel
)
var_el
.
attrib
[
"UserAccessLevel"
]
=
str
(
useraccesslevel
)
var
=
node
.
get_attribute
(
ua
.
AttributeIds
.
MinimumSamplingInterval
)
if
var
.
Value
.
Value
:
var_el
.
attrib
[
"MinimumSamplingInterval"
]
=
str
(
var
.
Value
.
Value
)
var
=
node
.
get_attribute
(
ua
.
AttributeIds
.
Historizing
)
if
var
.
Value
.
Value
:
var_el
.
attrib
[
"Historizing"
]
=
'true'
self
.
_add_ref_els
(
var_el
,
node
)
self
.
_add_ref_els
(
var_el
,
node
)
def
add_etree_variable_type
(
self
,
node
):
def
add_etree_variable_type
(
self
,
node
):
...
@@ -184,7 +194,7 @@ class XmlExporter(object):
...
@@ -184,7 +194,7 @@ class XmlExporter(object):
Add a UA variable type element to the XML etree
Add a UA variable type element to the XML etree
"""
"""
var_el
=
self
.
_add_node_common
(
"UAVariable"
,
node
)
var_el
=
self
.
_add_node_common
(
"UAVariable
Type
"
,
node
)
self
.
add_variable_common
(
node
,
var_el
)
self
.
add_variable_common
(
node
,
var_el
)
abstract
=
node
.
get_attribute
(
ua
.
AttributeIds
.
IsAbstract
)
abstract
=
node
.
get_attribute
(
ua
.
AttributeIds
.
IsAbstract
)
...
@@ -193,9 +203,14 @@ class XmlExporter(object):
...
@@ -193,9 +203,14 @@ class XmlExporter(object):
self
.
_add_ref_els
(
var_el
,
node
)
self
.
_add_ref_els
(
var_el
,
node
)
def
add_etree_method
(
self
,
obj
):
def
add_etree_method
(
self
,
node
):
obj_el
=
self
.
_add_node_common
(
"UAMethod"
,
obj
)
obj_el
=
self
.
_add_node_common
(
"UAMethod"
,
node
)
self
.
_add_ref_els
(
obj_el
,
obj
)
var
=
node
.
get_attribute
(
ua
.
AttributeIds
.
Executable
)
obj_el
.
attrib
[
"Executable"
]
=
str
(
var
.
Value
.
Value
)
var
=
node
.
get_attribute
(
ua
.
AttributeIds
.
UserExecutable
)
obj_el
.
attrib
[
"UserExecutable"
]
=
str
(
var
.
Value
.
Value
)
self
.
_add_ref_els
(
obj_el
,
node
)
def
add_etree_reference
(
self
,
obj
):
def
add_etree_reference
(
self
,
obj
):
obj_el
=
self
.
_add_node_common
(
"UAReference"
,
obj
)
obj_el
=
self
.
_add_node_common
(
"UAReference"
,
obj
)
...
@@ -239,7 +254,6 @@ class XmlExporter(object):
...
@@ -239,7 +254,6 @@ class XmlExporter(object):
ref_el
.
attrib
[
'IsForward'
]
=
'false'
ref_el
.
attrib
[
'IsForward'
]
=
'false'
ref_el
.
text
=
ref
.
NodeId
.
to_string
()
ref_el
.
text
=
ref
.
NodeId
.
to_string
()
# add any references that gets used to aliases dict; this gets handled later
self
.
aliases
[
ref_name
]
=
ref
.
ReferenceTypeId
.
to_string
()
self
.
aliases
[
ref_name
]
=
ref
.
ReferenceTypeId
.
to_string
()
...
@@ -256,7 +270,7 @@ def _value_to_etree(el, dtype_name, dtype, val):
...
@@ -256,7 +270,7 @@ def _value_to_etree(el, dtype_name, dtype, val):
_value_to_etree
(
list_el
,
dtype_name
,
dtype
,
nval
)
_value_to_etree
(
list_el
,
dtype_name
,
dtype
,
nval
)
else
:
else
:
if
dtype
.
Identifier
is
int
and
dtype
.
Identifier
>
21
:
# this is an extentionObject:
if
dtype
.
Identifier
is
int
and
dtype
.
Identifier
>
21
:
# this is an extentionObject:
_extobj_to_etree
(
el
,
dtype_name
,
dtype
)
_extobj_to_etree
(
el
,
dtype_name
,
dtype
,
val
)
else
:
else
:
val_el
=
Et
.
SubElement
(
el
,
"uax:"
+
dtype_name
)
val_el
=
Et
.
SubElement
(
el
,
"uax:"
+
dtype_name
)
val_el
.
text
=
str
(
val
)
val_el
.
text
=
str
(
val
)
...
...
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