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
75d9928e
Commit
75d9928e
authored
Dec 28, 2016
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix decoding of variant containing a Null array of of a type that cannot be null
parent
91ab3c47
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
opcua/ua/uatypes.py
opcua/ua/uatypes.py
+17
-6
No files found.
opcua/ua/uatypes.py
View file @
75d9928e
...
...
@@ -742,24 +742,34 @@ class Variant(FrozenClass):
:vartype Value: Any supported type
:ivar VariantType:
:vartype VariantType: VariantType
:ivar Dimension:
:vartype Dimensions: The length of each dimensions. Usually guessed from value.
:ivar is_array:
:vartype is_array: If the variant is an array. Usually guessed from value.
"""
def
__init__
(
self
,
value
=
None
,
varianttype
=
None
,
dimensions
=
None
):
def
__init__
(
self
,
value
=
None
,
varianttype
=
None
,
dimensions
=
None
,
is_array
=
None
):
self
.
Value
=
value
self
.
VariantType
=
varianttype
self
.
Dimensions
=
dimensions
self
.
is_array
=
is_array
if
self
.
is_array
is
None
:
if
isinstance
(
value
,
(
list
,
tuple
)):
self
.
is_array
=
True
else
:
self
.
is_array
=
False
self
.
_freeze
=
True
if
isinstance
(
value
,
Variant
):
self
.
Value
=
value
.
Value
self
.
VariantType
=
value
.
VariantType
if
self
.
VariantType
is
None
:
self
.
VariantType
=
self
.
_guess_type
(
self
.
Value
)
if
self
.
Value
is
None
and
self
.
VariantType
not
in
(
if
self
.
Value
is
None
and
not
self
.
is_array
and
self
.
VariantType
not
in
(
VariantType
.
Null
,
VariantType
.
String
,
VariantType
.
DateTime
):
raise
UaError
(
"Variant of type {0} cannot have value None"
.
format
(
self
.
VariantType
))
if
self
.
Dimensions
is
None
and
type
(
self
.
Value
)
in
(
list
,
tuple
):
raise
UaError
(
"
Non array
Variant of type {0} cannot have value None"
.
format
(
self
.
VariantType
))
if
self
.
Dimensions
is
None
and
isinstance
(
self
.
Value
,
(
list
,
tuple
)
):
dims
=
get_shape
(
self
.
Value
)
if
len
(
dims
)
>
1
:
self
.
Dimensions
=
dims
...
...
@@ -828,6 +838,7 @@ class Variant(FrozenClass):
@
staticmethod
def
from_binary
(
data
):
dimensions
=
None
array
=
False
encoding
=
ord
(
data
.
read
(
1
))
int_type
=
encoding
&
0b00111111
vtype
=
datatype_to_varianttype
(
int_type
)
...
...
@@ -835,13 +846,13 @@ class Variant(FrozenClass):
return
Variant
(
None
,
vtype
,
encoding
)
if
uabin
.
test_bit
(
encoding
,
7
):
value
=
uabin
.
unpack_uatype_array
(
vtype
,
data
)
array
=
True
else
:
value
=
uabin
.
unpack_uatype
(
vtype
,
data
)
if
uabin
.
test_bit
(
encoding
,
6
):
dimensions
=
uabin
.
unpack_uatype_array
(
VariantType
.
Int32
,
data
)
value
=
reshape
(
value
,
dimensions
)
return
Variant
(
value
,
vtype
,
dimensions
)
return
Variant
(
value
,
vtype
,
dimensions
,
is_array
=
array
)
def
reshape
(
flat
,
dims
):
...
...
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