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
bec6bd4c
Commit
bec6bd4c
authored
Apr 22, 2022
by
Alexander Schrode
Committed by
oroulet
Apr 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow setting StatusCode
parent
da4badcb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
asyncua/server/address_space.py
asyncua/server/address_space.py
+13
-2
tests/test_common.py
tests/test_common.py
+13
-1
No files found.
asyncua/server/address_space.py
View file @
bec6bd4c
...
...
@@ -780,8 +780,19 @@ class AddressSpace:
attval
=
node
.
attributes
.
get
(
attr
,
None
)
if
attval
is
None
:
return
ua
.
StatusCode
(
ua
.
StatusCodes
.
BadAttributeIdInvalid
)
if
not
self
.
_is_expected_variant_type
(
value
,
attval
,
node
):
if
value
.
StatusCode
is
not
None
and
not
value
.
StatusCode
.
is_good
():
# https://reference.opcfoundation.org/v104/Core/docs/Part4/7.7.1/
# If the StatusCode indicates an error then the value is to be ignored and the Server shall set it to null.
value
=
ua
.
DataValue
(
ua
.
Variant
(
ua
.
Null
,
ua
.
VariantType
.
Null
),
value
.
StatusCode
,
value
.
ServerTimestamp
,
value
.
SourceTimestamp
,
value
.
ServerPicoseconds
,
value
.
SourcePicoseconds
)
elif
not
self
.
_is_expected_variant_type
(
value
,
attval
,
node
):
# Only check datatype if no bad StatusCode is set
return
ua
.
StatusCode
(
ua
.
StatusCodes
.
BadTypeMismatch
)
old
=
attval
.
value
...
...
tests/test_common.py
View file @
bec6bd4c
...
...
@@ -642,6 +642,18 @@ async def test_write_value(opc):
await
opc
.
opc
.
delete_nodes
([
v
])
async
def
test_write_value_statuscode_bad
(
opc
):
o
=
opc
.
opc
.
nodes
.
objects
var
=
ua
.
Variant
(
'Some value that should not be set!'
)
dvar
=
ua
.
DataValue
(
var
,
StatusCode_
=
ua
.
StatusCode
(
ua
.
StatusCodes
.
BadDeviceFailure
))
v
=
await
o
.
add_variable
(
3
,
'VariableValueBad'
,
var
)
await
v
.
write_value
(
dvar
)
with
pytest
.
raises
(
ua
.
UaStatusCodeError
)
as
error_read
:
await
v
.
read_data_value
()
assert
error_read
.
type
.
code
==
dvar
.
StatusCode
.
value
await
opc
.
opc
.
delete_nodes
([
v
])
async
def
test_array_value
(
opc
):
o
=
opc
.
opc
.
nodes
.
objects
v
=
await
o
.
add_variable
(
3
,
'VariableArrayValue'
,
[
1
,
2
,
3
])
...
...
@@ -1014,7 +1026,7 @@ async def test_instantiate_abstract(opc):
finit_statemachine_type
=
opc
.
opc
.
get_node
(
"ns=0;i=2771"
)
# IsAbstract=True
with
pytest
.
raises
(
ua
.
UaError
):
node
=
await
instantiate
(
opc
.
opc
.
nodes
.
objects
,
finit_statemachine_type
,
bname
=
"2:TestFiniteStateMachine"
)
async
def
test_variable_with_datatype
(
opc
):
v1
=
await
opc
.
opc
.
nodes
.
objects
.
add_variable
(
...
...
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