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
454bf64e
Commit
454bf64e
authored
Jan 01, 2016
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cast int to enum for nodeclass and valuerank in BinaryClient.
parent
eed7aa5c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
5 deletions
+34
-5
opcua/binary_client.py
opcua/binary_client.py
+10
-0
opcua/node.py
opcua/node.py
+3
-3
opcua/uaprotocol_hand.py
opcua/uaprotocol_hand.py
+20
-1
opcua/uatypes.py
opcua/uatypes.py
+1
-1
No files found.
opcua/binary_client.py
View file @
454bf64e
...
...
@@ -289,6 +289,16 @@ class BinaryClient(object):
data
=
self
.
_uasocket
.
send_request
(
request
)
response
=
ua
.
ReadResponse
.
from_binary
(
data
)
response
.
ResponseHeader
.
ServiceResult
.
check
()
# cast to Enum attributes that need to
for
idx
,
rv
in
enumerate
(
parameters
.
NodesToRead
):
if
rv
.
AttributeId
==
ua
.
AttributeIds
.
NodeClass
:
dv
=
response
.
Results
[
idx
]
if
dv
.
StatusCode
.
is_good
():
dv
.
Value
.
Value
=
ua
.
NodeClass
(
dv
.
Value
.
Value
)
elif
rv
.
AttributeId
==
ua
.
AttributeIds
.
ValueRank
:
dv
=
response
.
Results
[
idx
]
if
dv
.
StatusCode
.
is_good
()
and
dv
.
Value
.
Value
in
(
-
3
,
-
2
,
-
1
,
0
,
1
,
2
,
3
,
4
):
dv
.
Value
.
Value
=
ua
.
ValueRank
(
dv
.
Value
.
Value
)
return
response
.
Results
def
write
(
self
,
params
):
...
...
opcua/node.py
View file @
454bf64e
...
...
@@ -449,10 +449,10 @@ def _create_variable(server, parentnodeid, nodeid, qname, val, isproperty=False)
attrs
.
DataType
=
_guess_uatype
(
val
)
attrs
.
Value
=
val
if
isinstance
(
val
,
list
)
or
isinstance
(
val
,
tuple
):
attrs
.
ValueRank
=
0
attrs
.
ValueRank
=
ua
.
ValueRank
.
OneDimension
else
:
attrs
.
ValueRank
=
-
1
#
attrs.ArrayDimensions = 0
attrs
.
ValueRank
=
ua
.
ValueRank
.
Scalar
#
attrs.ArrayDimensions = None
attrs
.
WriteMask
=
ua
.
OpenFileMode
.
Read
attrs
.
UserWriteMask
=
ua
.
OpenFileMode
.
Read
attrs
.
Historizing
=
0
...
...
opcua/uaprotocol_hand.py
View file @
454bf64e
import
struct
import
logging
import
hashlib
from
enum
import
IntEnum
import
opcua.uaprotocol_auto
as
auto
import
opcua.uatypes
as
uatypes
...
...
@@ -13,9 +14,27 @@ logger = logging.getLogger('opcua.uaprotocol')
OPC_TCP_SCHEME
=
'opc.tcp'
class
ValueRank
(
IntEnum
):
"""
Defines dimensions of a variable.
This enum does not support all cases since ValueRank support any n>0
but since it is an IntEnum it can be replace by a normal int
"""
ScalarOrOneDimension
=
-
3
Any
=
-
2
Scalar
=
-
1
OneOrMoreDimensions
=
0
OneDimension
=
1
# the next names are not in spec but so common we express them here
TwoDimensions
=
2
ThreeDimensions
=
3
FourDimensions
=
3
class
AccessLevelMask
(
object
):
"""
u
sed by AccessLevel and UserAccessLevel
U
sed by AccessLevel and UserAccessLevel
"""
CurrentRead
=
0
CurrentWrite
=
1
...
...
opcua/uatypes.py
View file @
454bf64e
...
...
@@ -765,7 +765,7 @@ class Variant(FrozenClass):
raise
Exception
(
"Could not guess UA type of {} with type {}, specify UA type"
.
format
(
val
,
type
(
val
)))
def
__str__
(
self
):
return
"Variant(val:{},type:{})"
.
format
(
self
.
Value
,
self
.
VariantType
)
return
"Variant(val:{
!s
},type:{})"
.
format
(
self
.
Value
,
self
.
VariantType
)
__repr__
=
__str__
def
to_binary
(
self
):
...
...
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