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
56562f6e
Commit
56562f6e
authored
Jul 20, 2021
by
oroulet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update example ua custom enums/struct example
parent
522a54bc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
examples/client-custom-structures-and-enums.py
examples/client-custom-structures-and-enums.py
+4
-3
No files found.
examples/client-
data-type-definition
.py
→
examples/client-
custom-structures-and-enums
.py
View file @
56562f6e
...
...
@@ -4,8 +4,6 @@ import logging
from
asyncua
import
Client
,
Node
,
ua
from
asyncua.common.structures104
import
load_custom_struct
logging
.
basicConfig
(
level
=
logging
.
INFO
)
_logger
=
logging
.
getLogger
(
'asyncua'
)
async
def
main
():
...
...
@@ -16,7 +14,8 @@ async def main():
idx
=
await
client
.
register_namespace
(
uri
)
await
client
.
load_data_type_definitions
()
my_enum
=
await
client
.
nodes
.
objects
.
get_child
(
f"
{
idx
}
:my_enum"
)
print
(
"ENUM"
,
await
my_enum
.
get_value
())
val
=
await
my_enum
.
get_value
()
print
(
"ENUM"
,
val
,
type
(
val
),
val
==
ua
.
MyEnum
.
toto
)
# enums are int32 in UA, we do not convert them back to IntEnum yet
my_struct
=
await
client
.
nodes
.
objects
.
get_child
(
f"
{
idx
}
:my_struct"
)
print
(
"STRUCT"
,
await
my_struct
.
read_value
())
my_struct_opt
=
await
client
.
nodes
.
objects
.
get_child
(
f"
{
idx
}
:my_struct_optional"
)
...
...
@@ -27,4 +26,6 @@ async def main():
my_type
=
await
load_custom_struct
(
mystructnode
)
if
__name__
==
'__main__'
:
logging
.
basicConfig
(
level
=
logging
.
WARNING
)
_logger
=
logging
.
getLogger
(
'asyncua'
)
asyncio
.
run
(
main
())
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