motorcortex-python 0.23.2__tar.gz → 0.23.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {motorcortex_python-0.23.2/motorcortex_python.egg-info → motorcortex_python-0.23.3}/PKG-INFO +1 -1
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex/message_types.py +39 -39
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex/request.py +6 -27
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex/subscribe.py +12 -6
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex/subscription.py +1 -1
- motorcortex_python-0.23.3/motorcortex/version.py +1 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3/motorcortex_python.egg-info}/PKG-INFO +1 -1
- motorcortex_python-0.23.2/motorcortex/version.py +0 -1
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/LICENSE +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/MANIFEST.in +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/README.md +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex/__init__.py +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex/motorcortex_hash.json +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex/motorcortex_pb2.py +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex/parameter_tree.py +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex/reply.py +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex/setup_logger.py +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex/state_callback_handler.py +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex_python.egg-info/SOURCES.txt +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex_python.egg-info/dependency_links.txt +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex_python.egg-info/requires.txt +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex_python.egg-info/top_level.txt +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/setup.cfg +0 -0
- {motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/setup.py +0 -0
|
@@ -59,56 +59,56 @@ class PrimitiveTypes(object):
|
|
|
59
59
|
self.__decoder = None
|
|
60
60
|
self.__encoder = None
|
|
61
61
|
self.__prepare = None
|
|
62
|
-
if
|
|
63
|
-
self.__decoder = lambda
|
|
64
|
-
self.__encoder = lambda
|
|
62
|
+
if type_name == "BOOL":
|
|
63
|
+
self.__decoder = lambda length, val: struct.unpack('%db' % length, val)
|
|
64
|
+
self.__encoder = lambda length, val: struct.pack('%db' % length, *val)
|
|
65
65
|
self.__prepare = lambda val: [bool(x) for x in val.split(",")]
|
|
66
|
-
elif
|
|
67
|
-
self.__decoder = lambda
|
|
68
|
-
self.__encoder = lambda
|
|
66
|
+
elif type_name == "DOUBLE":
|
|
67
|
+
self.__decoder = lambda length, val: struct.unpack('%dd' % length, val)
|
|
68
|
+
self.__encoder = lambda length, val: struct.pack('%dd' % length, *val)
|
|
69
69
|
self.__prepare = lambda val: [float(x) for x in val.split(",")]
|
|
70
|
-
elif
|
|
71
|
-
self.__decoder = lambda
|
|
72
|
-
self.__encoder = lambda
|
|
70
|
+
elif type_name == "FLOAT":
|
|
71
|
+
self.__decoder = lambda length, val: struct.unpack('%df' % length, val)
|
|
72
|
+
self.__encoder = lambda length, val: struct.pack('%df' % length, *val)
|
|
73
73
|
self.__prepare = lambda val: [float(x) for x in val.split(",")]
|
|
74
|
-
elif
|
|
75
|
-
self.__decoder = lambda
|
|
76
|
-
self.__encoder = lambda
|
|
74
|
+
elif type_name == "INT8":
|
|
75
|
+
self.__decoder = lambda length, val: struct.unpack('%db' % length, val)
|
|
76
|
+
self.__encoder = lambda length, val: struct.pack('%db' % length, *val)
|
|
77
77
|
self.__prepare = lambda val: [int(float(x)) & 0x7f for x in val.split(",")]
|
|
78
|
-
elif
|
|
79
|
-
self.__decoder = lambda
|
|
80
|
-
self.__encoder = lambda
|
|
78
|
+
elif type_name == "UINT8":
|
|
79
|
+
self.__decoder = lambda length, val: struct.unpack('%dB' % length, val)
|
|
80
|
+
self.__encoder = lambda length, val: struct.pack('%dB' % length, *val)
|
|
81
81
|
self.__prepare = lambda val: [int(float(x)) & 0xff for x in val.split(",")]
|
|
82
|
-
elif
|
|
83
|
-
self.__decoder = lambda
|
|
84
|
-
self.__encoder = lambda
|
|
82
|
+
elif type_name == "INT16":
|
|
83
|
+
self.__decoder = lambda length, val: struct.unpack('%dh' % length, val)
|
|
84
|
+
self.__encoder = lambda length, val: struct.pack('%dh' % length, *val)
|
|
85
85
|
self.__prepare = lambda val: [int(float(x)) & 0x7fff for x in val.split(",")]
|
|
86
|
-
elif
|
|
87
|
-
self.__decoder = lambda
|
|
88
|
-
self.__encoder = lambda
|
|
86
|
+
elif type_name == "UINT16":
|
|
87
|
+
self.__decoder = lambda length, val: struct.unpack('%dH' % length, val)
|
|
88
|
+
self.__encoder = lambda length, val: struct.pack('%dH' % length, *val)
|
|
89
89
|
self.__prepare = lambda val: [int(float(x)) & 0xffff for x in val.split(",")]
|
|
90
|
-
elif
|
|
91
|
-
self.__decoder = lambda
|
|
92
|
-
self.__encoder = lambda
|
|
90
|
+
elif type_name == "INT32":
|
|
91
|
+
self.__decoder = lambda length, val: struct.unpack('%di' % length, val)
|
|
92
|
+
self.__encoder = lambda length, val: struct.pack('%di' % length, *val)
|
|
93
93
|
self.__prepare = lambda val: [int(float(x)) & 0x7fffffff for x in val.split(",")]
|
|
94
|
-
elif
|
|
95
|
-
self.__decoder = lambda
|
|
96
|
-
self.__encoder = lambda
|
|
94
|
+
elif type_name == "UINT32":
|
|
95
|
+
self.__decoder = lambda length, val: struct.unpack('%dI' % length, val)
|
|
96
|
+
self.__encoder = lambda length, val: struct.pack('%dI' % length, *val)
|
|
97
97
|
self.__prepare = lambda val: [int(float(x)) & 0xffffffff for x in val.split(",")]
|
|
98
|
-
elif
|
|
99
|
-
self.__decoder = lambda
|
|
100
|
-
self.__encoder = lambda
|
|
98
|
+
elif type_name == "INT64":
|
|
99
|
+
self.__decoder = lambda length, val: struct.unpack('%dq' % length, val)
|
|
100
|
+
self.__encoder = lambda length, val: struct.pack('%dq' % length, *val)
|
|
101
101
|
self.__prepare = lambda val: [int(float(x)) for x in val.split(",")]
|
|
102
|
-
elif
|
|
103
|
-
self.__decoder = lambda
|
|
104
|
-
self.__encoder = lambda
|
|
102
|
+
elif type_name == "UINT64":
|
|
103
|
+
self.__decoder = lambda length, val: struct.unpack('%dQ' % length, val)
|
|
104
|
+
self.__encoder = lambda length, val: struct.pack('%dQ' % length, *val)
|
|
105
105
|
self.__prepare = lambda val: [int(float(x)) for x in val.split(",")]
|
|
106
|
-
elif
|
|
107
|
-
self.__decoder = lambda
|
|
108
|
-
self.__encoder = lambda
|
|
109
|
-
elif
|
|
110
|
-
self.__decoder = lambda
|
|
111
|
-
self.__encoder = lambda
|
|
106
|
+
elif type_name == "STRING":
|
|
107
|
+
self.__decoder = lambda length, val: val.split(b'\0')[0].decode()
|
|
108
|
+
self.__encoder = lambda length, val: (val + '\0').encode()
|
|
109
|
+
elif type_name == "USER_TYPE":
|
|
110
|
+
self.__decoder = lambda length, val: val
|
|
111
|
+
self.__encoder = lambda length, val: val
|
|
112
112
|
|
|
113
113
|
def decode(self, value, number_of_elements):
|
|
114
114
|
val = self.__decoder(number_of_elements, value)
|
|
@@ -28,27 +28,6 @@ class ConnectionState(Enum):
|
|
|
28
28
|
DISCONNECTING = 4
|
|
29
29
|
DISCONNECTED = 5
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
class Base64Encoder(json.JSONEncoder):
|
|
33
|
-
# pylint: disable=method-hidden
|
|
34
|
-
encoding = 'utf-8'
|
|
35
|
-
|
|
36
|
-
def default(self, o):
|
|
37
|
-
if isinstance(o, bytes):
|
|
38
|
-
return base64.b64encode(o).decode(Base64Encoder.encoding)
|
|
39
|
-
return json.JSONEncoder.default(self, o)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
class Base64Decoder(json.JSONDecoder):
|
|
43
|
-
# pylint: disable=method-hidden
|
|
44
|
-
encoding = 'utf-8'
|
|
45
|
-
|
|
46
|
-
def default(self, o):
|
|
47
|
-
if isinstance(o, bytes):
|
|
48
|
-
return base64.b64decode(o).encode(Base64Decoder.decode())
|
|
49
|
-
return json.Base64Decoder.default(self, o)
|
|
50
|
-
|
|
51
|
-
|
|
52
31
|
class Request(object):
|
|
53
32
|
|
|
54
33
|
def __init__(self, protobuf_types, parameter_tree):
|
|
@@ -81,14 +60,14 @@ class Request(object):
|
|
|
81
60
|
self.__connected_lock = Condition() # Create Condition instead of Queue
|
|
82
61
|
self.__connected = False # Initialize state
|
|
83
62
|
|
|
84
|
-
def pre_connect_cb(
|
|
63
|
+
def pre_connect_cb(_pipe):
|
|
85
64
|
with self.__connected_lock:
|
|
86
65
|
self.__connected = True
|
|
87
66
|
self.__connection_state = ConnectionState.CONNECTION_OK
|
|
88
67
|
self.__callback_handler.notify(self, self.connectionState())
|
|
89
68
|
self.__connected_lock.notify_all() # Wake up all waiting threads
|
|
90
69
|
|
|
91
|
-
def post_remove_cb(
|
|
70
|
+
def post_remove_cb(_pipe):
|
|
92
71
|
with self.__connected_lock:
|
|
93
72
|
if self.__connection_state == ConnectionState.DISCONNECTING:
|
|
94
73
|
self.__connection_state = ConnectionState.DISCONNECTED
|
|
@@ -155,7 +134,7 @@ class Request(object):
|
|
|
155
134
|
"""Request a parameter tree hash from the server.
|
|
156
135
|
|
|
157
136
|
Returns:
|
|
158
|
-
Reply(ParameterTreeMsg): A Promise, which resolves when parameter tree hash is received or fails
|
|
137
|
+
Reply(ParameterTreeMsg): A Promise, which resolves when a parameter tree hash is received or fails
|
|
159
138
|
otherwise. ParameterTreeHashMsg message has a status field to check the status of the operation.
|
|
160
139
|
|
|
161
140
|
Examples:
|
|
@@ -188,14 +167,14 @@ class Request(object):
|
|
|
188
167
|
self.getParameterTreeHash(), self.__protobuf_types, self.__socket))
|
|
189
168
|
|
|
190
169
|
def save(self, path, file_name):
|
|
191
|
-
"""Request a server to save a parameter tree to file.
|
|
170
|
+
"""Request a server to save a parameter tree to a file.
|
|
192
171
|
|
|
193
172
|
Args:
|
|
194
173
|
path(str): path where to save
|
|
195
174
|
file_name(str): file name
|
|
196
175
|
|
|
197
176
|
Returns:
|
|
198
|
-
Reply(StatusMsg): A promise, which resolves when save operation is completed,
|
|
177
|
+
Reply(StatusMsg): A promise, which resolves when the save operation is completed,
|
|
199
178
|
fails otherwise.
|
|
200
179
|
|
|
201
180
|
"""
|
|
@@ -218,7 +197,7 @@ class Request(object):
|
|
|
218
197
|
value argument)
|
|
219
198
|
|
|
220
199
|
Returns:
|
|
221
|
-
Reply(StatusMsg): A Promise, which resolves when parameter value is updated or fails otherwise.
|
|
200
|
+
Reply(StatusMsg): A Promise, which resolves when a parameter value is updated or fails otherwise.
|
|
222
201
|
|
|
223
202
|
Examples:
|
|
224
203
|
>>> reply = req.setParameter("root/Control/activateSemiAuto", False)
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/python3
|
|
2
|
-
import time
|
|
3
|
-
|
|
4
|
-
import pynng
|
|
5
2
|
|
|
6
3
|
#
|
|
7
4
|
# Developer: Alexey Zakharov (alexey.zakharov@vectioneer.com)
|
|
8
5
|
# All rights reserved. Copyright (c) 2016-2025 VECTIONEER.
|
|
9
6
|
#
|
|
10
7
|
|
|
8
|
+
import pynng
|
|
11
9
|
from motorcortex.request import Request, Reply, ConnectionState
|
|
12
10
|
from motorcortex.subscription import Subscription
|
|
13
11
|
from motorcortex.state_callback_handler import StateCallbackHandler
|
|
@@ -69,14 +67,14 @@ class Subscribe:
|
|
|
69
67
|
self.__connected_lock = Condition()
|
|
70
68
|
self.__is_connected = False
|
|
71
69
|
|
|
72
|
-
def pre_connect_cb(
|
|
70
|
+
def pre_connect_cb(_pipe):
|
|
73
71
|
with self.__connected_lock:
|
|
74
72
|
self.__is_connected = True
|
|
75
73
|
self.__connection_state = ConnectionState.CONNECTION_OK
|
|
76
74
|
self.__callback_handler.notify(self.__req, self, self.connectionState())
|
|
77
75
|
self.__connected_lock.notify_all() # Wake up all waiting threads
|
|
78
76
|
|
|
79
|
-
def post_remove_cb(
|
|
77
|
+
def post_remove_cb(_pipe):
|
|
80
78
|
with self.__connected_lock:
|
|
81
79
|
if self.__connection_state == ConnectionState.DISCONNECTING:
|
|
82
80
|
self.__connection_state = ConnectionState.DISCONNECTED
|
|
@@ -118,7 +116,15 @@ class Subscribe:
|
|
|
118
116
|
try:
|
|
119
117
|
buffer = socket.recv()
|
|
120
118
|
except pynng.Timeout:
|
|
121
|
-
|
|
119
|
+
logger.debug('Socket timeout, retrying subscription loop...')
|
|
120
|
+
# Submit a no-op task to check if the pool is shutting down
|
|
121
|
+
try:
|
|
122
|
+
self.__pool.submit(lambda: None).cancel()
|
|
123
|
+
continue
|
|
124
|
+
except RuntimeError:
|
|
125
|
+
logger.debug('Pool is shutting down, exiting subscription loop')
|
|
126
|
+
break
|
|
127
|
+
|
|
122
128
|
except pynng.Closed:
|
|
123
129
|
logger.debug('Socket closed, exiting subscription loop')
|
|
124
130
|
break
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.23.3'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.23.2'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex/state_callback_handler.py
RENAMED
|
File without changes
|
{motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex_python.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex_python.egg-info/requires.txt
RENAMED
|
File without changes
|
{motorcortex_python-0.23.2 → motorcortex_python-0.23.3}/motorcortex_python.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|