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
b80cd4d7
Commit
b80cd4d7
authored
Aug 23, 2023
by
Yuta Okamoto
Committed by
oroulet
Aug 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add type hints to struct_from_binary()
parent
4cfe6969
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
11 deletions
+15
-11
asyncua/client/client.py
asyncua/client/client.py
+1
-1
asyncua/common/node.py
asyncua/common/node.py
+1
-1
asyncua/sync.py
asyncua/sync.py
+5
-4
asyncua/ua/ua_binary.py
asyncua/ua/ua_binary.py
+7
-4
asyncua/ua/uatypes.py
asyncua/ua/uatypes.py
+1
-1
No files found.
asyncua/client/client.py
View file @
b80cd4d7
...
@@ -681,7 +681,7 @@ class Client:
...
@@ -681,7 +681,7 @@ class Client:
def
get_server_node
(
self
):
def
get_server_node
(
self
):
return
self
.
get_node
(
ua
.
FourByteNodeId
(
ua
.
ObjectIds
.
Server
))
return
self
.
get_node
(
ua
.
FourByteNodeId
(
ua
.
ObjectIds
.
Server
))
def
get_node
(
self
,
nodeid
:
Union
[
ua
.
NodeId
,
str
])
->
Node
:
def
get_node
(
self
,
nodeid
:
Union
[
Node
,
ua
.
NodeId
,
str
,
bytes
,
int
])
->
Node
:
"""
"""
Get node using NodeId object or a string representing a NodeId.
Get node using NodeId object or a string representing a NodeId.
"""
"""
...
...
asyncua/common/node.py
View file @
b80cd4d7
...
@@ -46,7 +46,7 @@ class Node:
...
@@ -46,7 +46,7 @@ class Node:
OPC-UA protocol. Feel free to look at the code of this class and call
OPC-UA protocol. Feel free to look at the code of this class and call
directly UA services methods to optimize your code
directly UA services methods to optimize your code
"""
"""
def
__init__
(
self
,
session
:
AbstractSession
,
nodeid
:
Union
[
ua
.
NodeId
,
str
,
int
]):
def
__init__
(
self
,
session
:
AbstractSession
,
nodeid
:
Union
[
"Node"
,
ua
.
NodeId
,
str
,
bytes
,
int
]):
self
.
session
=
session
self
.
session
=
session
self
.
nodeid
:
ua
.
NodeId
self
.
nodeid
:
ua
.
NodeId
if
isinstance
(
nodeid
,
Node
):
if
isinstance
(
nodeid
,
Node
):
...
...
asyncua/sync.py
View file @
b80cd4d7
...
@@ -205,6 +205,7 @@ class _SubHandler:
...
@@ -205,6 +205,7 @@ class _SubHandler:
def
status_change_notification
(
self
,
status
:
ua
.
StatusChangeNotification
):
def
status_change_notification
(
self
,
status
:
ua
.
StatusChangeNotification
):
self
.
sync_handler
.
status_change_notification
(
status
)
self
.
sync_handler
.
status_change_notification
(
status
)
class
Client
:
class
Client
:
def
__init__
(
self
,
url
:
str
,
timeout
:
int
=
4
,
tloop
=
None
):
def
__init__
(
self
,
url
:
str
,
timeout
:
int
=
4
,
tloop
=
None
):
self
.
tloop
=
tloop
self
.
tloop
=
tloop
...
@@ -291,8 +292,9 @@ class Client:
...
@@ -291,8 +292,9 @@ class Client:
def
get_namespace_index
(
self
,
url
):
def
get_namespace_index
(
self
,
url
):
pass
pass
def
get_node
(
self
,
nodeid
):
def
get_node
(
self
,
nodeid
:
Union
[
"SyncNode"
,
ua
.
NodeId
,
str
,
bytes
,
int
]):
return
SyncNode
(
self
.
tloop
,
self
.
aio_obj
.
get_node
(
nodeid
))
aio_nodeid
=
nodeid
.
aio_obj
if
isinstance
(
nodeid
,
SyncNode
)
else
nodeid
return
SyncNode
(
self
.
tloop
,
self
.
aio_obj
.
get_node
(
aio_nodeid
))
def
get_root_node
(
self
):
def
get_root_node
(
self
):
return
SyncNode
(
self
.
tloop
,
self
.
aio_obj
.
get_root_node
())
return
SyncNode
(
self
.
tloop
,
self
.
aio_obj
.
get_root_node
())
...
@@ -437,7 +439,6 @@ class Server:
...
@@ -437,7 +439,6 @@ class Server:
return
Subscription
(
self
.
tloop
,
aio_sub
)
return
Subscription
(
self
.
tloop
,
aio_sub
)
class
EventGenerator
:
class
EventGenerator
:
def
__init__
(
self
,
tloop
,
aio_evgen
):
def
__init__
(
self
,
tloop
,
aio_evgen
):
self
.
aio_obj
=
aio_evgen
self
.
aio_obj
=
aio_evgen
...
@@ -459,7 +460,7 @@ def new_node(sync_node, nodeid):
...
@@ -459,7 +460,7 @@ def new_node(sync_node, nodeid):
class
SyncNode
:
class
SyncNode
:
def
__init__
(
self
,
tloop
,
aio_n
ode
):
def
__init__
(
self
,
tloop
:
ThreadLoop
,
aio_node
:
node
.
N
ode
):
self
.
aio_obj
=
aio_node
self
.
aio_obj
=
aio_node
self
.
tloop
=
tloop
self
.
tloop
=
tloop
...
...
asyncua/ua/ua_binary.py
View file @
b80cd4d7
...
@@ -5,7 +5,7 @@ Binary protocol specific functions and constants
...
@@ -5,7 +5,7 @@ Binary protocol specific functions and constants
import
functools
import
functools
import
struct
import
struct
import
logging
import
logging
from
typing
import
Any
,
Callable
from
typing
import
IO
,
Any
,
Callable
,
Optional
,
Sequence
,
Type
,
TypeVar
,
Union
import
typing
import
typing
import
uuid
import
uuid
from
enum
import
Enum
,
IntFlag
from
enum
import
Enum
,
IntFlag
...
@@ -17,6 +17,8 @@ from .uatypes import type_from_optional, type_is_list, type_is_union, type_from_
...
@@ -17,6 +17,8 @@ from .uatypes import type_from_optional, type_is_list, type_is_union, type_from_
logger
=
logging
.
getLogger
(
'__name__'
)
logger
=
logging
.
getLogger
(
'__name__'
)
T
=
TypeVar
(
'T'
)
def
test_bit
(
data
,
offset
):
def
test_bit
(
data
,
offset
):
mask
=
1
<<
offset
mask
=
1
<<
offset
...
@@ -373,7 +375,7 @@ def to_binary(uatype, val):
...
@@ -373,7 +375,7 @@ def to_binary(uatype, val):
@
functools
.
lru_cache
(
maxsize
=
None
)
@
functools
.
lru_cache
(
maxsize
=
None
)
def
create_list_serializer
(
uatype
,
recursive
:
bool
=
False
)
->
Callable
[[
Any
],
bytes
]:
def
create_list_serializer
(
uatype
,
recursive
:
bool
=
False
)
->
Callable
[[
Optional
[
Sequence
[
Any
]]
],
bytes
]:
"""
"""
Given a type, return a function that takes a list of instances
Given a type, return a function that takes a list of instances
of that type and serializes it.
of that type and serializes it.
...
@@ -391,6 +393,7 @@ def create_list_serializer(uatype, recursive: bool = False) -> Callable[[Any], b
...
@@ -391,6 +393,7 @@ def create_list_serializer(uatype, recursive: bool = False) -> Callable[[Any], b
return
recursive_serialize
return
recursive_serialize
type_serializer
=
create_type_serializer
(
uatype
)
type_serializer
=
create_type_serializer
(
uatype
)
def
serialize
(
val
):
def
serialize
(
val
):
if
val
is
None
:
if
val
is
None
:
return
none_val
return
none_val
...
@@ -686,7 +689,7 @@ def _create_dataclass_deserializer(objtype):
...
@@ -686,7 +689,7 @@ def _create_dataclass_deserializer(objtype):
return
decode
return
decode
def
struct_from_binary
(
objtype
,
data
)
:
def
struct_from_binary
(
objtype
:
Union
[
Type
[
T
],
str
],
data
:
IO
)
->
T
:
"""
"""
unpack an ua struct. Arguments are an objtype as Python dataclass or string
unpack an ua struct. Arguments are an objtype as Python dataclass or string
"""
"""
...
...
asyncua/ua/uatypes.py
View file @
b80cd4d7
...
@@ -915,7 +915,7 @@ class Variant:
...
@@ -915,7 +915,7 @@ class Variant:
# FIXME: typing is wrong here
# FIXME: typing is wrong here
Value: Any = None
Value: Any = None
VariantType:
VariantType
= None
VariantType:
"
VariantType
"
= None
Dimensions: Optional[List[Int32]] = None
Dimensions: Optional[List[Int32]] = None
is_array: Optional[bool] = None
is_array: Optional[bool] = None
...
...
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