conson-xp 1.33.0__py3-none-any.whl → 1.35.0__py3-none-any.whl
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.
- {conson_xp-1.33.0.dist-info → conson_xp-1.35.0.dist-info}/METADATA +1 -1
- {conson_xp-1.33.0.dist-info → conson_xp-1.35.0.dist-info}/RECORD +32 -32
- xp/__init__.py +1 -1
- xp/cli/commands/conbus/conbus_actiontable_commands.py +34 -35
- xp/cli/commands/conbus/conbus_autoreport_commands.py +11 -10
- xp/cli/commands/conbus/conbus_blink_commands.py +20 -6
- xp/cli/commands/conbus/conbus_custom_commands.py +6 -4
- xp/cli/commands/conbus/conbus_datapoint_commands.py +8 -6
- xp/cli/commands/conbus/conbus_lightlevel_commands.py +19 -16
- xp/cli/commands/conbus/conbus_linknumber_commands.py +7 -6
- xp/cli/commands/conbus/conbus_modulenumber_commands.py +7 -6
- xp/cli/commands/conbus/conbus_msactiontable_commands.py +7 -9
- xp/cli/commands/conbus/conbus_output_commands.py +9 -7
- xp/cli/commands/conbus/conbus_raw_commands.py +7 -2
- xp/cli/commands/conbus/conbus_scan_commands.py +4 -2
- xp/services/conbus/actiontable/actiontable_download_service.py +79 -37
- xp/services/conbus/actiontable/actiontable_list_service.py +17 -17
- xp/services/conbus/actiontable/actiontable_upload_service.py +78 -36
- xp/services/conbus/actiontable/msactiontable_service.py +88 -48
- xp/services/conbus/conbus_blink_all_service.py +89 -35
- xp/services/conbus/conbus_blink_service.py +82 -24
- xp/services/conbus/conbus_custom_service.py +81 -26
- xp/services/conbus/conbus_datapoint_queryall_service.py +90 -43
- xp/services/conbus/conbus_datapoint_service.py +76 -28
- xp/services/conbus/conbus_output_service.py +82 -22
- xp/services/conbus/conbus_raw_service.py +78 -37
- xp/services/conbus/conbus_scan_service.py +86 -42
- xp/services/conbus/write_config_service.py +76 -26
- xp/utils/dependencies.py +12 -24
- {conson_xp-1.33.0.dist-info → conson_xp-1.35.0.dist-info}/WHEEL +0 -0
- {conson_xp-1.33.0.dist-info → conson_xp-1.35.0.dist-info}/entry_points.txt +0 -0
- {conson_xp-1.33.0.dist-info → conson_xp-1.35.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -5,49 +5,49 @@ This service handles setting link numbers for modules through Conbus telegrams.
|
|
|
5
5
|
|
|
6
6
|
import logging
|
|
7
7
|
from datetime import datetime
|
|
8
|
-
from typing import
|
|
8
|
+
from typing import Any, Optional
|
|
9
9
|
|
|
10
|
-
from
|
|
10
|
+
from psygnal import Signal
|
|
11
11
|
|
|
12
|
-
from xp.models import ConbusClientConfig
|
|
13
12
|
from xp.models.conbus.conbus_writeconfig import ConbusWriteConfigResponse
|
|
14
13
|
from xp.models.protocol.conbus_protocol import TelegramReceivedEvent
|
|
15
14
|
from xp.models.telegram.datapoint_type import DataPointType
|
|
16
15
|
from xp.models.telegram.system_function import SystemFunction
|
|
17
16
|
from xp.models.telegram.telegram_type import TelegramType
|
|
18
|
-
from xp.services.protocol import
|
|
17
|
+
from xp.services.protocol.conbus_event_protocol import ConbusEventProtocol
|
|
19
18
|
from xp.services.telegram.telegram_service import TelegramService
|
|
20
19
|
|
|
21
20
|
|
|
22
|
-
class WriteConfigService
|
|
23
|
-
"""
|
|
24
|
-
Service for writing module settings via Conbus telegrams.
|
|
21
|
+
class WriteConfigService:
|
|
22
|
+
"""Service for writing module settings via Conbus telegrams.
|
|
25
23
|
|
|
26
24
|
Handles setting assignment by sending F04DXX telegrams and processing
|
|
27
25
|
ACK/NAK responses from modules.
|
|
26
|
+
|
|
27
|
+
Attributes:
|
|
28
|
+
conbus_protocol: Protocol for Conbus communication.
|
|
29
|
+
telegram_service: Service for parsing telegrams.
|
|
30
|
+
on_finish: Signal emitted when write operation completes (with response).
|
|
28
31
|
"""
|
|
29
32
|
|
|
33
|
+
on_finish: Signal = Signal(ConbusWriteConfigResponse)
|
|
34
|
+
|
|
30
35
|
def __init__(
|
|
31
36
|
self,
|
|
37
|
+
conbus_protocol: ConbusEventProtocol,
|
|
32
38
|
telegram_service: TelegramService,
|
|
33
|
-
cli_config: ConbusClientConfig,
|
|
34
|
-
reactor: PosixReactorBase,
|
|
35
39
|
) -> None:
|
|
36
40
|
"""Initialize the Conbus link number set service.
|
|
37
41
|
|
|
38
42
|
Args:
|
|
43
|
+
conbus_protocol: Protocol for Conbus communication.
|
|
39
44
|
telegram_service: Service for parsing telegrams.
|
|
40
|
-
cli_config: Configuration for Conbus client connection.
|
|
41
|
-
reactor: Twisted reactor for event loop.
|
|
42
45
|
"""
|
|
43
|
-
|
|
46
|
+
self.conbus_protocol = conbus_protocol
|
|
44
47
|
self.telegram_service = telegram_service
|
|
45
48
|
self.datapoint_type: Optional[DataPointType] = None
|
|
46
49
|
self.serial_number: str = ""
|
|
47
50
|
self.data_value: str = ""
|
|
48
|
-
self.write_config_finished_callback: Optional[
|
|
49
|
-
Callable[[ConbusWriteConfigResponse], None]
|
|
50
|
-
] = None
|
|
51
51
|
self.write_config_response: ConbusWriteConfigResponse = (
|
|
52
52
|
ConbusWriteConfigResponse(
|
|
53
53
|
success=False,
|
|
@@ -58,8 +58,15 @@ class WriteConfigService(ConbusProtocol):
|
|
|
58
58
|
# Set up logging
|
|
59
59
|
self.logger = logging.getLogger(__name__)
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
# Connect protocol signals
|
|
62
|
+
self.conbus_protocol.on_connection_made.connect(self.connection_made)
|
|
63
|
+
self.conbus_protocol.on_telegram_sent.connect(self.telegram_sent)
|
|
64
|
+
self.conbus_protocol.on_telegram_received.connect(self.telegram_received)
|
|
65
|
+
self.conbus_protocol.on_timeout.connect(self.timeout)
|
|
66
|
+
self.conbus_protocol.on_failed.connect(self.failed)
|
|
67
|
+
|
|
68
|
+
def connection_made(self) -> None:
|
|
69
|
+
"""Handle connection made event."""
|
|
63
70
|
self.logger.debug(f"Connection established, writing config {self.data_value}.")
|
|
64
71
|
|
|
65
72
|
# Validate parameters before sending
|
|
@@ -79,7 +86,7 @@ class WriteConfigService(ConbusProtocol):
|
|
|
79
86
|
# Function F04 = WRITE_CONFIG,
|
|
80
87
|
# Datapoint = D datapoint_type
|
|
81
88
|
# Data = XX
|
|
82
|
-
self.send_telegram(
|
|
89
|
+
self.conbus_protocol.send_telegram(
|
|
83
90
|
telegram_type=TelegramType.SYSTEM,
|
|
84
91
|
serial_number=self.serial_number,
|
|
85
92
|
system_function=SystemFunction.WRITE_CONFIG,
|
|
@@ -133,6 +140,11 @@ class WriteConfigService(ConbusProtocol):
|
|
|
133
140
|
succeed_or_failed=succeed, system_function=reply_telegram.system_function
|
|
134
141
|
)
|
|
135
142
|
|
|
143
|
+
def timeout(self) -> None:
|
|
144
|
+
"""Handle timeout event."""
|
|
145
|
+
self.logger.debug("Timeout occurred")
|
|
146
|
+
self.finished(succeed_or_failed=False, message="Timeout")
|
|
147
|
+
|
|
136
148
|
def failed(self, message: str) -> None:
|
|
137
149
|
"""Handle telegram failed event.
|
|
138
150
|
|
|
@@ -163,16 +175,15 @@ class WriteConfigService(ConbusProtocol):
|
|
|
163
175
|
self.write_config_response.system_function = system_function
|
|
164
176
|
self.write_config_response.datapoint_type = self.datapoint_type
|
|
165
177
|
self.write_config_response.data_value = self.data_value
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
self.
|
|
178
|
+
|
|
179
|
+
# Emit finish signal
|
|
180
|
+
self.on_finish.emit(self.write_config_response)
|
|
169
181
|
|
|
170
182
|
def write_config(
|
|
171
183
|
self,
|
|
172
184
|
serial_number: str,
|
|
173
185
|
datapoint_type: DataPointType,
|
|
174
186
|
data_value: str,
|
|
175
|
-
finish_callback: Callable[[ConbusWriteConfigResponse], None],
|
|
176
187
|
timeout_seconds: Optional[float] = None,
|
|
177
188
|
) -> None:
|
|
178
189
|
"""Write config to a specific module.
|
|
@@ -181,14 +192,53 @@ class WriteConfigService(ConbusProtocol):
|
|
|
181
192
|
serial_number: 10-digit module serial number.
|
|
182
193
|
datapoint_type: the datapoint type to write to.
|
|
183
194
|
data_value: the data to write.
|
|
184
|
-
finish_callback: Callback function to call when operation completes.
|
|
185
195
|
timeout_seconds: Optional timeout in seconds.
|
|
186
196
|
"""
|
|
187
197
|
self.logger.info("Starting write_config")
|
|
188
198
|
if timeout_seconds:
|
|
189
|
-
self.timeout_seconds = timeout_seconds
|
|
199
|
+
self.conbus_protocol.timeout_seconds = timeout_seconds
|
|
190
200
|
self.serial_number = serial_number
|
|
191
201
|
self.datapoint_type = datapoint_type
|
|
192
202
|
self.data_value = data_value
|
|
193
|
-
|
|
194
|
-
|
|
203
|
+
|
|
204
|
+
def set_timeout(self, timeout_seconds: float) -> None:
|
|
205
|
+
"""Set operation timeout.
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
timeout_seconds: Timeout in seconds.
|
|
209
|
+
"""
|
|
210
|
+
self.conbus_protocol.timeout_seconds = timeout_seconds
|
|
211
|
+
|
|
212
|
+
def start_reactor(self) -> None:
|
|
213
|
+
"""Start the reactor."""
|
|
214
|
+
self.conbus_protocol.start_reactor()
|
|
215
|
+
|
|
216
|
+
def stop_reactor(self) -> None:
|
|
217
|
+
"""Stop the reactor."""
|
|
218
|
+
self.conbus_protocol.stop_reactor()
|
|
219
|
+
|
|
220
|
+
def __enter__(self) -> "WriteConfigService":
|
|
221
|
+
"""Enter context manager - reset state for singleton reuse.
|
|
222
|
+
|
|
223
|
+
Returns:
|
|
224
|
+
Self for context manager protocol.
|
|
225
|
+
"""
|
|
226
|
+
self.write_config_response = ConbusWriteConfigResponse(
|
|
227
|
+
success=False, serial_number=""
|
|
228
|
+
)
|
|
229
|
+
self.datapoint_type = None
|
|
230
|
+
self.serial_number = ""
|
|
231
|
+
self.data_value = ""
|
|
232
|
+
return self
|
|
233
|
+
|
|
234
|
+
def __exit__(
|
|
235
|
+
self, _exc_type: Optional[type], _exc_val: Optional[Exception], _exc_tb: Any
|
|
236
|
+
) -> None:
|
|
237
|
+
"""Exit context manager and disconnect signals."""
|
|
238
|
+
self.conbus_protocol.on_connection_made.disconnect(self.connection_made)
|
|
239
|
+
self.conbus_protocol.on_telegram_sent.disconnect(self.telegram_sent)
|
|
240
|
+
self.conbus_protocol.on_telegram_received.disconnect(self.telegram_received)
|
|
241
|
+
self.conbus_protocol.on_timeout.disconnect(self.timeout)
|
|
242
|
+
self.conbus_protocol.on_failed.disconnect(self.failed)
|
|
243
|
+
self.on_finish.disconnect()
|
|
244
|
+
self.stop_reactor()
|
xp/utils/dependencies.py
CHANGED
|
@@ -159,9 +159,8 @@ class ServiceContainer:
|
|
|
159
159
|
self.container.register(
|
|
160
160
|
ConbusDatapointService,
|
|
161
161
|
factory=lambda: ConbusDatapointService(
|
|
162
|
+
conbus_protocol=self.container.resolve(ConbusEventProtocol),
|
|
162
163
|
telegram_service=self.container.resolve(TelegramService),
|
|
163
|
-
cli_config=self.container.resolve(ConbusClientConfig),
|
|
164
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
165
164
|
),
|
|
166
165
|
scope=punq.Scope.singleton,
|
|
167
166
|
)
|
|
@@ -169,9 +168,8 @@ class ServiceContainer:
|
|
|
169
168
|
self.container.register(
|
|
170
169
|
ConbusDatapointQueryAllService,
|
|
171
170
|
factory=lambda: ConbusDatapointQueryAllService(
|
|
171
|
+
conbus_protocol=self.container.resolve(ConbusEventProtocol),
|
|
172
172
|
telegram_service=self.container.resolve(TelegramService),
|
|
173
|
-
cli_config=self.container.resolve(ConbusClientConfig),
|
|
174
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
175
173
|
),
|
|
176
174
|
scope=punq.Scope.singleton,
|
|
177
175
|
)
|
|
@@ -179,8 +177,7 @@ class ServiceContainer:
|
|
|
179
177
|
self.container.register(
|
|
180
178
|
ConbusScanService,
|
|
181
179
|
factory=lambda: ConbusScanService(
|
|
182
|
-
|
|
183
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
180
|
+
conbus_protocol=self.container.resolve(ConbusEventProtocol),
|
|
184
181
|
),
|
|
185
182
|
scope=punq.Scope.singleton,
|
|
186
183
|
)
|
|
@@ -265,8 +262,7 @@ class ServiceContainer:
|
|
|
265
262
|
self.container.register(
|
|
266
263
|
ConbusBlinkService,
|
|
267
264
|
factory=lambda: ConbusBlinkService(
|
|
268
|
-
|
|
269
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
265
|
+
conbus_protocol=self.container.resolve(ConbusEventProtocol),
|
|
270
266
|
telegram_service=self.container.resolve(TelegramService),
|
|
271
267
|
),
|
|
272
268
|
scope=punq.Scope.singleton,
|
|
@@ -275,8 +271,7 @@ class ServiceContainer:
|
|
|
275
271
|
self.container.register(
|
|
276
272
|
ConbusBlinkAllService,
|
|
277
273
|
factory=lambda: ConbusBlinkAllService(
|
|
278
|
-
|
|
279
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
274
|
+
conbus_protocol=self.container.resolve(ConbusEventProtocol),
|
|
280
275
|
telegram_service=self.container.resolve(TelegramService),
|
|
281
276
|
),
|
|
282
277
|
scope=punq.Scope.singleton,
|
|
@@ -285,9 +280,8 @@ class ServiceContainer:
|
|
|
285
280
|
self.container.register(
|
|
286
281
|
ConbusOutputService,
|
|
287
282
|
factory=lambda: ConbusOutputService(
|
|
283
|
+
conbus_protocol=self.container.resolve(ConbusEventProtocol),
|
|
288
284
|
telegram_output_service=self.container.resolve(TelegramOutputService),
|
|
289
|
-
cli_config=self.container.resolve(ConbusClientConfig),
|
|
290
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
291
285
|
),
|
|
292
286
|
scope=punq.Scope.singleton,
|
|
293
287
|
)
|
|
@@ -295,9 +289,8 @@ class ServiceContainer:
|
|
|
295
289
|
self.container.register(
|
|
296
290
|
WriteConfigService,
|
|
297
291
|
factory=lambda: WriteConfigService(
|
|
292
|
+
conbus_protocol=self.container.resolve(ConbusEventProtocol),
|
|
298
293
|
telegram_service=self.container.resolve(TelegramService),
|
|
299
|
-
cli_config=self.container.resolve(ConbusClientConfig),
|
|
300
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
301
294
|
),
|
|
302
295
|
scope=punq.Scope.singleton,
|
|
303
296
|
)
|
|
@@ -311,8 +304,7 @@ class ServiceContainer:
|
|
|
311
304
|
self.container.register(
|
|
312
305
|
ActionTableService,
|
|
313
306
|
factory=lambda: ActionTableService(
|
|
314
|
-
|
|
315
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
307
|
+
conbus_protocol=self.container.resolve(ConbusEventProtocol),
|
|
316
308
|
actiontable_serializer=self.container.resolve(ActionTableSerializer),
|
|
317
309
|
telegram_service=self.container.resolve(TelegramService),
|
|
318
310
|
),
|
|
@@ -322,8 +314,7 @@ class ServiceContainer:
|
|
|
322
314
|
self.container.register(
|
|
323
315
|
ActionTableUploadService,
|
|
324
316
|
factory=lambda: ActionTableUploadService(
|
|
325
|
-
|
|
326
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
317
|
+
conbus_protocol=self.container.resolve(ConbusEventProtocol),
|
|
327
318
|
actiontable_serializer=self.container.resolve(ActionTableSerializer),
|
|
328
319
|
telegram_service=self.container.resolve(TelegramService),
|
|
329
320
|
conson_config=self.container.resolve(ConsonModuleListConfig),
|
|
@@ -364,8 +355,7 @@ class ServiceContainer:
|
|
|
364
355
|
self.container.register(
|
|
365
356
|
MsActionTableService,
|
|
366
357
|
factory=lambda: MsActionTableService(
|
|
367
|
-
|
|
368
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
358
|
+
conbus_protocol=self.container.resolve(ConbusEventProtocol),
|
|
369
359
|
xp20ms_serializer=self.container.resolve(Xp20MsActionTableSerializer),
|
|
370
360
|
xp24ms_serializer=self.container.resolve(Xp24MsActionTableSerializer),
|
|
371
361
|
xp33ms_serializer=self.container.resolve(Xp33MsActionTableSerializer),
|
|
@@ -377,9 +367,8 @@ class ServiceContainer:
|
|
|
377
367
|
self.container.register(
|
|
378
368
|
ConbusCustomService,
|
|
379
369
|
factory=lambda: ConbusCustomService(
|
|
370
|
+
conbus_protocol=self.container.resolve(ConbusEventProtocol),
|
|
380
371
|
telegram_service=self.container.resolve(TelegramService),
|
|
381
|
-
cli_config=self.container.resolve(ConbusClientConfig),
|
|
382
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
383
372
|
),
|
|
384
373
|
scope=punq.Scope.singleton,
|
|
385
374
|
)
|
|
@@ -387,8 +376,7 @@ class ServiceContainer:
|
|
|
387
376
|
self.container.register(
|
|
388
377
|
ConbusRawService,
|
|
389
378
|
factory=lambda: ConbusRawService(
|
|
390
|
-
|
|
391
|
-
reactor=self.container.resolve(PosixReactorBase),
|
|
379
|
+
conbus_protocol=self.container.resolve(ConbusEventProtocol),
|
|
392
380
|
),
|
|
393
381
|
scope=punq.Scope.singleton,
|
|
394
382
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|