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
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
nexedi
osie
Commits
80876498
Commit
80876498
authored
Dec 08, 2021
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass paramaters from CLI.
parent
d0898521
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
28 deletions
+56
-28
tests/test_runtime_coupler_increment.py
tests/test_runtime_coupler_increment.py
+56
-28
No files found.
tests/test_runtime_coupler_increment.py
View file @
80876498
...
@@ -4,16 +4,41 @@
...
@@ -4,16 +4,41 @@
"""
"""
from
opcua
import
Client
from
opcua
import
Client
import
time
import
time
import
argparse
import
configparser
TIMEOUT
=
5
# seconds to wait between checks
def
main
():
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
# handle CLI arguments
client
=
Client
(
OPC_UA_ADDRESS
)
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--iterations'
,
\
type
=
int
,
\
default
=
10
,
\
help
=
'number of iterations to check'
)
parser
.
add_argument
(
'--timeout'
,
\
type
=
int
,
\
default
=
5
,
\
help
=
'seconds to wait between checks'
)
parser
.
add_argument
(
'--opc-ua-server'
,
\
type
=
str
,
\
default
=
'opc.tcp://k2-osie:4840/'
,
\
help
=
'Address of OPC-UA server'
)
parser
.
add_argument
(
'--opc-ua-node-identifier'
,
\
type
=
str
,
\
default
=
'ns=1;s=i2c0.relay0'
,
\
help
=
'Address of OPC-UA server'
)
try
:
args
=
parser
.
parse_args
()
NUMBER_OF_CHECKS
=
args
.
iterations
TIMEOUT
=
args
.
timeout
OPC_UA_ADDRESS
=
args
.
opc_ua_server
OPC_UA_IDENTIFIER
=
args
.
opc_ua_node_identifier
# connect to a session at OPC-UA server
client
=
Client
(
OPC_UA_ADDRESS
)
try
:
client
.
connect
()
client
.
connect
()
# Client has a few methods to get proxy to UA nodes that should always be in address space such as Root or Objects
# Client has a few methods to get proxy to UA nodes that should always be in address space such as Root or Objects
...
@@ -24,12 +49,15 @@ try:
...
@@ -24,12 +49,15 @@ try:
for
i
in
range
(
0
,
NUMBER_OF_CHECKS
):
for
i
in
range
(
0
,
NUMBER_OF_CHECKS
):
i2c0_relay0_before
=
var
.
get_value
()
i2c0_relay0_before
=
var
.
get_value
()
print
(
"
\
n
i2c0_relay0 (before) = "
,
i2c0_relay0_before
)
print
(
"
\
n
i2c0_relay0 (before) = "
,
i2c0_relay0_before
)
print
(
"sleep ..."
)
print
(
"Sleep for %s seconds ..."
%
TIMEOUT
)
time
.
sleep
(
TIMEOUT
)
time
.
sleep
(
TIMEOUT
)
i2c0_relay0_after
=
var
.
get_value
()
i2c0_relay0_after
=
var
.
get_value
()
print
(
"i2c0_relay0 (after) = "
,
i2c0_relay0_after
)
print
(
"i2c0_relay0 (after) = "
,
i2c0_relay0_after
)
# for the wait timeout runtime should have increased the value
# for the wait timeout runtime should have increased the value
assert
i2c0_relay0_after
>
i2c0_relay0_before
assert
i2c0_relay0_after
>
i2c0_relay0_before
finally
:
finally
:
client
.
disconnect
()
client
.
disconnect
()
if
__name__
==
"__main__"
:
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