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
0b866d06
Commit
0b866d06
authored
Jul 09, 2022
by
oroulet
Committed by
oroulet
Jul 09, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use single code for struct generation
parent
1c94c659
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
asyncua/common/structures104.py
asyncua/common/structures104.py
+3
-3
tests/test_common.py
tests/test_common.py
+15
-0
No files found.
asyncua/common/structures104.py
View file @
0b866d06
...
...
@@ -62,11 +62,11 @@ async def new_struct(
simple way to create a new structure
return the created data type node and the list of encoding nodes
"""
type_name
=
server
.
nodes
.
base_structure_type
if
is_union
:
type_name
=
server
.
nodes
.
base_union_type
dtype
=
await
create_data_type
(
type_name
,
idx
,
name
)
if
isinstance
(
idx
,
ua
.
NodeId
):
...
...
@@ -176,7 +176,7 @@ class {struct_name}{base_class}:
{struct_name} structure autogenerated from StructureDefinition object
'''
data_type = ua.NodeId.from_string(
"{data_type.to_string()}"
)
data_type = ua.NodeId.from_string(
'
{
data_type
.
to_string
()}
'
)
"""
...
...
tests/test_common.py
View file @
0b866d06
...
...
@@ -1575,3 +1575,18 @@ async def test_alias(opc):
v
.
MyStringType
=
'1234'
await
var
.
write_value
(
v
)
val
=
await
var
.
read_value
()
async
def
test_custom_struct_with_strange_chars
(
opc
):
idx
=
4
await
new_struct
(
opc
.
opc
,
ua
.
StringNodeId
(
'Toto"æ'
,
99
),
ua
.
QualifiedName
(
"Siemens"
,
99
),
[
new_struct_field
(
"MyBool"
,
ua
.
VariantType
.
Boolean
),
new_struct_field
(
"MyUInt32"
,
ua
.
VariantType
.
UInt32
,
array
=
True
),
])
await
opc
.
opc
.
load_data_type_definitions
()
mystruct
=
ua
.
Siemens
()
mystruct
.
MyUInt32
=
[
78
,
79
]
var
=
await
opc
.
opc
.
nodes
.
objects
.
add_variable
(
idx
,
"my_siemens_struct"
,
ua
.
Variant
(
mystruct
,
ua
.
VariantType
.
ExtensionObject
))
val
=
await
var
.
read_value
()
assert
val
.
MyUInt32
==
[
78
,
79
]
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