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
98eb074d
Commit
98eb074d
authored
Jul 22, 2020
by
oroulet
Committed by
oroulet
Jul 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save enum data in EnumDefinition attribute and fix a crappy bug
parent
5436c28c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
3 deletions
+43
-3
asyncua/common/xmlimporter.py
asyncua/common/xmlimporter.py
+34
-2
asyncua/common/xmlparser.py
asyncua/common/xmlparser.py
+4
-1
asyncua/ua/uaprotocol_hand.py
asyncua/ua/uaprotocol_hand.py
+5
-0
No files found.
asyncua/common/xmlimporter.py
View file @
98eb074d
...
@@ -380,7 +380,14 @@ class XmlImporter:
...
@@ -380,7 +380,14 @@ class XmlImporter:
attrs
.
DisplayName
=
ua
.
LocalizedText
(
obj
.
displayname
)
attrs
.
DisplayName
=
ua
.
LocalizedText
(
obj
.
displayname
)
if
obj
.
abstract
:
if
obj
.
abstract
:
attrs
.
IsAbstract
=
obj
.
abstract
attrs
.
IsAbstract
=
obj
.
abstract
attrs
.
DataTypeDefinition
=
self
.
_get_sdef
(
node
,
obj
)
if
obj
.
definitions
and
obj
.
parent
==
ua
.
NodeId
(
29
):
attrs
.
DataTypeDefinition
=
self
.
_get_edef
(
node
,
obj
)
pass
elif
obj
.
definitions
and
obj
.
parent
==
ua
.
NodeId
(
22
):
#FIXME need better check for subclasses!!
attrs
.
DataTypeDefinition
=
self
.
_get_sdef
(
node
,
obj
)
else
:
print
(
"NOT DEFINITON"
,
obj
.
parent
,
obj
)
node
.
NodeAttributes
=
attrs
node
.
NodeAttributes
=
attrs
res
=
await
self
.
_get_server
().
add_nodes
([
node
])
res
=
await
self
.
_get_server
().
add_nodes
([
node
])
res
[
0
].
StatusCode
.
check
()
res
[
0
].
StatusCode
.
check
()
...
@@ -400,26 +407,51 @@ class XmlImporter:
...
@@ -400,26 +407,51 @@ class XmlImporter:
refs
.
append
(
ref
)
refs
.
append
(
ref
)
await
self
.
_add_references
(
refs
)
await
self
.
_add_references
(
refs
)
def
_get_edef
(
self
,
node
,
obj
):
if
not
obj
.
definitions
:
return
None
edef
=
ua
.
EnumDefinition
()
if
obj
.
parent
:
edef
.
BaseDataType
=
obj
.
parent
for
field
in
obj
.
definitions
:
f
=
ua
.
EnumField
()
f
.
Name
=
field
.
name
if
field
.
dname
:
f
.
DisplayName
=
ua
.
LocalizedText
(
text
=
field
.
dname
)
else
:
f
.
DisplayName
=
ua
.
LocalizedText
(
text
=
field
.
name
)
f
.
Value
=
field
.
value
f
.
Description
=
ua
.
LocalizedText
(
text
=
field
.
desc
)
edef
.
Fields
.
append
(
f
)
return
edef
def
_get_sdef
(
self
,
node
,
obj
):
def
_get_sdef
(
self
,
node
,
obj
):
if
not
obj
.
definitions
:
if
not
obj
.
definitions
:
return
None
return
None
sdef
=
ua
.
StructureDefinition
()
sdef
=
ua
.
StructureDefinition
()
if
obj
.
parent
:
if
obj
.
parent
:
sdef
.
BaseDataType
=
self
.
to_nodeid
(
obj
.
parent
)
sdef
.
BaseDataType
=
self
.
to_nodeid
(
obj
.
parent
)
sdef
.
StructureType
=
ua
.
StructureType
.
Structure
for
data
in
obj
.
refs
:
for
data
in
obj
.
refs
:
if
data
.
reftype
==
"HasEncoding"
:
if
data
.
reftype
==
"HasEncoding"
:
# looks likebinary encodingisthe firt one...can someone confirm?
# looks likebinary encodingisthe firt one...can someone confirm?
sdef
.
DefaultEncodingId
=
self
.
to_nodeid
(
data
.
target
)
sdef
.
DefaultEncodingId
=
self
.
to_nodeid
(
data
.
target
)
break
break
optional
=
False
for
field
in
obj
.
definitions
:
for
field
in
obj
.
definitions
:
f
=
ua
.
StructureField
()
f
=
ua
.
StructureField
()
f
.
Name
=
field
.
name
f
.
Name
=
field
.
name
f
.
DataType
=
self
.
to_nodeid
(
field
.
datatype
)
f
.
DataType
=
self
.
to_nodeid
(
field
.
datatype
)
f
.
ValueRank
=
field
.
valuerank
f
.
ValueRank
=
field
.
valuerank
f
.
IsOptional
=
field
.
optional
f
.
IsOptional
=
field
.
optional
if
f
.
IsOptional
:
optional
=
True
f
.
ArrayDimensions
=
field
.
arraydim
f
.
ArrayDimensions
=
field
.
arraydim
f
.
Description
=
ua
.
LocalizedText
(
text
=
field
.
desc
)
sdef
.
Fields
.
append
(
f
)
sdef
.
Fields
.
append
(
f
)
if
optional
:
sdef
.
StructureType
=
ua
.
StructureType
.
StructureWithOptionalFields
else
:
sdef
.
StructureType
=
ua
.
StructureType
.
Structure
return
sdef
return
sdef
def
_sort_nodes_by_parentid
(
self
,
ndatas
):
def
_sort_nodes_by_parentid
(
self
,
ndatas
):
...
...
asyncua/common/xmlparser.py
View file @
98eb074d
...
@@ -69,11 +69,14 @@ class NodeData:
...
@@ -69,11 +69,14 @@ class NodeData:
class
Field
:
class
Field
:
def
__init__
(
self
,
data
):
def
__init__
(
self
,
data
):
self
.
datatype
=
data
.
get
(
"DataType"
)
self
.
datatype
=
data
.
get
(
"DataType"
,
""
)
self
.
name
=
data
.
get
(
"Name"
)
self
.
name
=
data
.
get
(
"Name"
)
self
.
dname
=
data
.
get
(
"DisplayName"
,
""
)
self
.
optional
=
bool
(
data
.
get
(
"IsOptional"
,
False
))
self
.
optional
=
bool
(
data
.
get
(
"IsOptional"
,
False
))
self
.
valuerank
=
int
(
data
.
get
(
"ValueRank"
,
-
1
))
self
.
valuerank
=
int
(
data
.
get
(
"ValueRank"
,
-
1
))
self
.
arraydim
=
data
.
get
(
"ArrayDimensions"
,
None
)
#FIXME: check type
self
.
arraydim
=
data
.
get
(
"ArrayDimensions"
,
None
)
#FIXME: check type
self
.
value
=
int
(
data
.
get
(
"Value"
,
0
))
self
.
desc
=
data
.
get
(
"Description"
,
""
)
class
RefStruct
:
class
RefStruct
:
...
...
asyncua/ua/uaprotocol_hand.py
View file @
98eb074d
...
@@ -342,6 +342,11 @@ class DataTypeAttributes(auto.DataTypeAttributes):
...
@@ -342,6 +342,11 @@ class DataTypeAttributes(auto.DataTypeAttributes):
self
.
DataTypeDefinition
=
auto
.
ExtensionObject
()
self
.
DataTypeDefinition
=
auto
.
ExtensionObject
()
self
.
_freeze
=
True
self
.
_freeze
=
True
# we now need to register DataTypeAttributes since we added a new attritbute
nid
=
uatypes
.
FourByteNodeId
(
auto
.
ObjectIds
.
DataTypeAttributes_Encoding_DefaultBinary
)
uatypes
.
extension_objects_by_typeid
[
nid
]
=
DataTypeAttributes
uatypes
.
extension_object_typeids
[
'DataTypeAttributes'
]
=
nid
class
ViewAttributes
(
auto
.
ViewAttributes
):
class
ViewAttributes
(
auto
.
ViewAttributes
):
def
__init__
(
self
):
def
__init__
(
self
):
...
...
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