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
ae958a98
Commit
ae958a98
authored
Jan 09, 2016
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NodeIdType as Enum
parent
2cbd3339
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
opcua/ua/uatypes.py
opcua/ua/uatypes.py
+10
-8
No files found.
opcua/ua/uatypes.py
View file @
ae958a98
...
...
@@ -326,7 +326,7 @@ class StatusCode(FrozenClass):
__repr__
=
__str__
class
NodeIdType
(
object
):
class
NodeIdType
(
Enum
):
TwoByte
=
0
FourByte
=
1
Numeric
=
2
...
...
@@ -458,26 +458,26 @@ class NodeId(FrozenClass):
def
to_binary
(
self
):
if
self
.
NodeIdType
==
NodeIdType
.
TwoByte
:
return
struct
.
pack
(
"<BB"
,
self
.
NodeIdType
,
self
.
Identifier
)
return
struct
.
pack
(
"<BB"
,
self
.
NodeIdType
.
value
,
self
.
Identifier
)
elif
self
.
NodeIdType
==
NodeIdType
.
FourByte
:
return
struct
.
pack
(
"<BBH"
,
self
.
NodeIdType
,
self
.
NamespaceIndex
,
self
.
Identifier
)
return
struct
.
pack
(
"<BBH"
,
self
.
NodeIdType
.
value
,
self
.
NamespaceIndex
,
self
.
Identifier
)
elif
self
.
NodeIdType
==
NodeIdType
.
Numeric
:
return
struct
.
pack
(
"<BHI"
,
self
.
NodeIdType
,
self
.
NamespaceIndex
,
self
.
Identifier
)
return
struct
.
pack
(
"<BHI"
,
self
.
NodeIdType
.
value
,
self
.
NamespaceIndex
,
self
.
Identifier
)
elif
self
.
NodeIdType
==
NodeIdType
.
String
:
return
struct
.
pack
(
"<BH"
,
self
.
NodeIdType
,
self
.
NamespaceIndex
)
+
\
return
struct
.
pack
(
"<BH"
,
self
.
NodeIdType
.
value
,
self
.
NamespaceIndex
)
+
\
pack_string
(
self
.
Identifier
)
elif
self
.
NodeIdType
==
NodeIdType
.
ByteString
:
return
struct
.
pack
(
"<BH"
,
self
.
NodeIdType
,
self
.
NamespaceIndex
)
+
\
return
struct
.
pack
(
"<BH"
,
self
.
NodeIdType
.
value
,
self
.
NamespaceIndex
)
+
\
pack_bytes
(
self
.
Identifier
)
else
:
return
struct
.
pack
(
"<BH"
,
self
.
NodeIdType
,
self
.
NamespaceIndex
)
+
\
return
struct
.
pack
(
"<BH"
,
self
.
NodeIdType
.
value
,
self
.
NamespaceIndex
)
+
\
self
.
Identifier
.
to_binary
()
@
staticmethod
def
from_binary
(
data
):
nid
=
NodeId
()
encoding
=
ord
(
data
.
read
(
1
))
nid
.
NodeIdType
=
encoding
&
0b00111111
nid
.
NodeIdType
=
NodeIdType
(
encoding
&
0b00111111
)
if
nid
.
NodeIdType
==
NodeIdType
.
TwoByte
:
nid
.
Identifier
=
ord
(
data
.
read
(
1
))
...
...
@@ -551,6 +551,8 @@ class QualifiedName(FrozenClass):
'''
def
__init__
(
self
,
name
=
""
,
namespaceidx
=
0
):
if
not
isinstance
(
namespaceidx
,
int
):
raise
UAError
(
"namespaceidx must be an int"
)
self
.
NamespaceIndex
=
namespaceidx
self
.
Name
=
name
self
.
_freeze
=
True
...
...
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