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
c8c87d16
Commit
c8c87d16
authored
Apr 30, 2019
by
oroulet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up uacall
parent
0275174c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
46 deletions
+24
-46
asyncua/tools.py
asyncua/tools.py
+22
-44
tools/uacall
tools/uacall
+1
-1
tools/uadiscover
tools/uadiscover
+1
-1
No files found.
asyncua/tools.py
View file @
c8c87d16
...
...
@@ -711,15 +711,15 @@ async def _uacall():
parser
.
add_argument
(
"-m"
,
"--method"
,
dest
=
"method"
,
type
=
int
,
default
=
None
,
help
=
"Set method to call. If not given then (single) method of the selected node is used."
)
parser
.
add_argument
(
"-M"
,
"--method-name"
,
dest
=
"method_name"
,
type
=
str
,
default
=
None
,
help
=
"Set name of method to call. Overrides --method"
)
help
=
"browse name of method to call"
)
parser
.
add_argument
(
"-t"
,
"--datatype"
,
dest
=
"datatype"
,
default
=
"guess"
,
choices
=
[
"guess"
,
'byte'
,
'sbyte'
,
'nodeid'
,
'expandednodeid'
,
'qualifiedname'
,
'browsename'
,
'string'
,
'float'
,
'double'
,
'int16'
,
'int32'
,
"int64"
,
'uint16'
,
'uint32'
,
'uint64'
,
"bool"
,
"string"
,
'datetime'
,
'bytestring'
,
'xmlelement'
,
'statuscode'
,
'localizedtext'
],
help
=
"Data type to return"
)
parser
.
add_argument
(
"-l"
,
"--list"
,
"--array"
,
...
...
@@ -727,14 +727,8 @@ async def _uacall():
default
=
"guess"
,
choices
=
[
"guess"
,
"true"
,
"false"
],
help
=
"Value is an array"
)
parser
.
add_argument
(
"-t"
,
"--datatype"
,
dest
=
"datatype"
,
default
=
"guess"
,
choices
=
[
"guess"
,
'byte'
,
'sbyte'
,
'nodeid'
,
'expandednodeid'
,
'qualifiedname'
,
'browsename'
,
'string'
,
'float'
,
'double'
,
'int16'
,
'int32'
,
"int64"
,
'uint16'
,
'uint32'
,
'uint64'
,
"bool"
,
"string"
,
'datetime'
,
'bytestring'
,
'xmlelement'
,
'statuscode'
,
'localizedtext'
],
help
=
"Data type to return"
)
parser
.
add_argument
(
"value"
,
help
=
"
Value
to use for call to method, if any"
,
help
=
"
Comma separated value(s)
to use for call to method, if any"
,
nargs
=
"?"
,
metavar
=
"VALUE"
)
...
...
@@ -745,40 +739,24 @@ async def _uacall():
await
client
.
connect
()
try
:
node
=
await
get_node
(
client
,
args
)
# val must be a tuple in order to enable method calls without arguments
if
(
args
.
value
is
None
):
val
=
()
#empty tuple
if
args
.
value
is
None
:
val
=
()
# empty tuple
else
:
val
=
(
_val_to_variant
(
args
.
value
,
args
),)
# tuple with one element
val
=
args
.
value
.
split
(
","
)
val
=
[
_val_to_variant
(
v
,
args
)
for
v
in
val
]
# determine method to call: Either explicitly given or automatically select the method of the selected node.
methods
=
await
node
.
get_methods
()
method_id
=
None
#print( "methods=%s" % (methods) )
if
(
args
.
method_name
is
not
None
):
method_id
=
args
.
method_name
elif
(
args
.
method
is
None
):
if
(
len
(
methods
)
==
0
):
raise
ValueError
(
"No methods in selected node and no method given"
)
elif
(
len
(
methods
)
==
1
):
method_id
=
methods
[
0
]
else
:
raise
ValueError
(
"Selected node has {0:d} methods but no method given. Provide one of {1!s}"
.
format
(
*
(
methods
))
)
else
:
for
m
in
methods
:
if
(
m
.
nodeid
.
Identifier
==
args
.
method
):
method_id
=
m
.
nodeid
break
if
(
method_id
is
None
):
# last resort:
method_id
=
ua
.
NodeId
(
identifier
=
args
.
method
)
#, namespaceidx=? )#, nodeidtype=?): )
#print( "method_id=%s\nval=%s" % (method_id,val) )
result_variants
=
await
node
.
call_method
(
method_id
,
*
val
)
print
(
"resulting result_variants={0!s}"
.
format
(
result_variants
)
)
if
args
.
method
is
not
None
:
method_id
=
args
.
method
else
:
methods
=
await
node
.
get_methods
()
if
len
(
methods
)
==
0
:
raise
ValueError
(
"No methods in selected node and no method given"
)
else
:
method_id
=
methods
[
0
]
result
=
await
node
.
call_method
(
method_id
,
*
val
)
print
(
f"resulting result_variants=
{
result
}
"
)
finally
:
await
client
.
disconnect
()
...
...
tools/uacall
100644 → 100755
View file @
c8c87d16
#!/usr/bin/env python
#!/usr/bin/env python
3
import
sys
import
os
...
...
tools/uadiscover
View file @
c8c87d16
#!/usr/bin/env python
#!/usr/bin/env python
3
import
sys
import
os
...
...
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