Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
osie
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
0
Merge Requests
0
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
Martin Manchev
osie
Commits
cde97b35
Commit
cde97b35
authored
Dec 03, 2021
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend test.
parent
1b812226
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
11 deletions
+20
-11
tests/test.py
tests/test.py
+20
-11
No files found.
tests/test.py
View file @
cde97b35
"""
OPC-UA test agent used for testing of PLC program here: https://lab.nexedi.com/nexedi/osie/tree/master/Beremiz/beremiz_test_opc_ua
XXX:
- add asserts
"""
from
opcua
import
Client
import
time
client
=
Client
(
"opc.tcp://k2-osie:4840/"
)
TIMEOUT
=
5
# seconds to wait between checks
NUMBER_OF_CHECKS
=
10
# number of times we check the server
OPC_UA_ADDRESS
=
"opc.tcp://k2-osie:4840/"
OPC_UA_IDENTIFIER
=
"ns=1;s=i2c0.relay0"
# connect to a session at OPC-UA server
client
=
Client
(
OPC_UA_ADDRESS
)
try
:
client
.
connect
()
...
...
@@ -14,13 +19,17 @@ try:
# Client has a few methods to get proxy to UA nodes that should always be in address space such as Root or Objects
root
=
client
.
get_root_node
()
children_list
=
root
.
get_children
()
for
i
in
range
(
0
,
10
):
var
=
client
.
get_node
(
"ns=1;s=i2c0.relay0"
)
i2c0_relay0
=
var
.
get_value
()
# XXX: do asserts here
print
i2c0_relay0
print
"sleep"
time
.
sleep
(
5
)
var
=
client
.
get_node
(
OPC_UA_IDENTIFIER
)
for
i
in
range
(
0
,
NUMBER_OF_CHECKS
):
i2c0_relay0_before
=
var
.
get_value
()
print
"
\
n
i2c0_relay0 (before) = "
,
i2c0_relay0_before
print
"sleep ..."
time
.
sleep
(
TIMEOUT
)
i2c0_relay0_after
=
var
.
get_value
()
print
"i2c0_relay0 (after) = "
,
i2c0_relay0_after
# for the wait timeout runtime should have increased the value
assert
i2c0_relay0_after
>
i2c0_relay0_before
finally
:
client
.
disconnect
()
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