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
43436b74
Commit
43436b74
authored
Nov 24, 2017
by
Mathias Lüdtke
Committed by
oroulet
Nov 25, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
introduced call_method_full
outputs the full CallMethodResult object instead of the OutputArguments only
parent
1e06fcef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
+21
-15
opcua/common/methods.py
opcua/common/methods.py
+21
-15
No files found.
opcua/common/methods.py
View file @
43436b74
...
...
@@ -12,28 +12,34 @@ def call_method(parent, methodid, *args):
nodeid of method as a NodeId object
arguments are variants or python object convertible to variants.
which may be of different types
returns a list of va
riants which ar
e output of the method
returns a list of va
lues or a single value depending on th
e output of the method
"""
if
isinstance
(
methodid
,
(
str
,
ua
.
uatypes
.
QualifiedName
)):
methodid
=
parent
.
get_child
(
methodid
).
nodeid
elif
isinstance
(
methodid
,
node
.
Node
):
methodid
=
methodid
.
nodeid
arguments
=
[]
for
arg
in
args
:
if
not
isinstance
(
arg
,
ua
.
Variant
):
arg
=
ua
.
Variant
(
arg
)
arguments
.
append
(
arg
)
result
=
_call_method
(
parent
.
server
,
parent
.
nodeid
,
methodid
,
arguments
)
result
=
call_method_full
(
parent
,
methodid
,
*
args
)
if
len
(
result
.
OutputArguments
)
==
0
:
return
None
elif
len
(
result
.
OutputArguments
)
==
1
:
return
result
.
OutputArguments
[
0
]
.
Value
return
result
.
OutputArguments
[
0
]
else
:
return
[
var
.
Value
for
var
in
result
.
OutputArguments
]
return
result
.
OutputArguments
def
call_method_full
(
parent
,
methodid
,
*
args
):
"""
Call an OPC-UA method. methodid is browse name of child method or the
nodeid of method as a NodeId object
arguments are variants or python object convertible to variants.
which may be of different types
returns a CallMethodResult object with converted OutputArguments
"""
if
isinstance
(
methodid
,
(
str
,
ua
.
uatypes
.
QualifiedName
)):
methodid
=
parent
.
get_child
(
methodid
).
nodeid
elif
isinstance
(
methodid
,
node
.
Node
):
methodid
=
methodid
.
nodeid
result
=
_call_method
(
parent
.
server
,
parent
.
nodeid
,
methodid
,
to_variant
(
*
args
))
result
.
OutputArguments
=
[
var
.
Value
for
var
in
result
.
OutputArguments
]
return
result
def
_call_method
(
server
,
parentnodeid
,
methodid
,
arguments
):
request
=
ua
.
CallMethodRequest
()
...
...
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