conson-xp 1.46.0__py3-none-any.whl → 1.48.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.46.0.dist-info → conson_xp-1.48.0.dist-info}/METADATA +1 -1
- conson_xp-1.48.0.dist-info/RECORD +210 -0
- xp/__init__.py +3 -2
- xp/cli/commands/conbus/conbus.py +1 -1
- xp/cli/commands/conbus/conbus_actiontable_commands.py +33 -19
- xp/cli/commands/conbus/conbus_autoreport_commands.py +8 -4
- xp/cli/commands/conbus/conbus_blink_commands.py +20 -10
- xp/cli/commands/conbus/conbus_config_commands.py +2 -1
- xp/cli/commands/conbus/conbus_custom_commands.py +4 -2
- xp/cli/commands/conbus/conbus_datapoint_commands.py +10 -5
- xp/cli/commands/conbus/conbus_discover_commands.py +8 -4
- xp/cli/commands/conbus/conbus_event_commands.py +8 -4
- xp/cli/commands/conbus/conbus_export_commands.py +8 -4
- xp/cli/commands/conbus/conbus_lightlevel_commands.py +16 -8
- xp/cli/commands/conbus/conbus_linknumber_commands.py +8 -4
- xp/cli/commands/conbus/conbus_modulenumber_commands.py +8 -4
- xp/cli/commands/conbus/conbus_msactiontable_commands.py +78 -40
- xp/cli/commands/conbus/conbus_output_commands.py +16 -8
- xp/cli/commands/conbus/conbus_raw_commands.py +6 -3
- xp/cli/commands/conbus/conbus_receive_commands.py +6 -3
- xp/cli/commands/conbus/conbus_scan_commands.py +6 -3
- xp/cli/commands/file_commands.py +6 -3
- xp/cli/commands/homekit/homekit.py +4 -2
- xp/cli/commands/homekit/homekit_start_commands.py +2 -1
- xp/cli/commands/module_commands.py +8 -4
- xp/cli/commands/reverse_proxy_commands.py +8 -4
- xp/cli/commands/server/server_commands.py +6 -3
- xp/cli/commands/telegram/telegram_blink_commands.py +4 -2
- xp/cli/commands/telegram/telegram_checksum_commands.py +4 -2
- xp/cli/commands/telegram/telegram_discover_commands.py +2 -1
- xp/cli/commands/telegram/telegram_linknumber_commands.py +4 -2
- xp/cli/commands/telegram/telegram_parse_commands.py +4 -2
- xp/cli/commands/telegram/telegram_version_commands.py +2 -1
- xp/cli/commands/term/term_commands.py +4 -2
- xp/cli/main.py +2 -1
- xp/cli/utils/click_tree.py +6 -3
- xp/cli/utils/datapoint_type_choice.py +4 -2
- xp/cli/utils/decorators.py +42 -21
- xp/cli/utils/error_handlers.py +16 -8
- xp/cli/utils/formatters.py +22 -11
- xp/cli/utils/module_type_choice.py +4 -2
- xp/cli/utils/serial_number_type.py +4 -2
- xp/cli/utils/system_function_choice.py +4 -2
- xp/cli/utils/xp_module_type.py +4 -2
- xp/models/actiontable/actiontable.py +8 -8
- xp/models/actiontable/actiontable_type.py +20 -0
- xp/models/actiontable/msactiontable_xp20.py +8 -4
- xp/models/actiontable/msactiontable_xp24.py +12 -6
- xp/models/actiontable/msactiontable_xp33.py +20 -10
- xp/models/conbus/conbus.py +8 -4
- xp/models/conbus/conbus_autoreport.py +4 -2
- xp/models/conbus/conbus_blink.py +4 -2
- xp/models/conbus/conbus_client_config.py +6 -3
- xp/models/conbus/conbus_connection_status.py +4 -2
- xp/models/conbus/conbus_custom.py +4 -2
- xp/models/conbus/conbus_datapoint.py +4 -2
- xp/models/conbus/conbus_discover.py +6 -3
- xp/models/conbus/conbus_event_list.py +4 -2
- xp/models/conbus/conbus_event_raw.py +4 -2
- xp/models/conbus/conbus_export.py +2 -1
- xp/models/conbus/conbus_lightlevel.py +4 -2
- xp/models/conbus/conbus_linknumber.py +4 -2
- xp/models/conbus/conbus_logger_config.py +8 -4
- xp/models/conbus/conbus_output.py +4 -2
- xp/models/conbus/conbus_raw.py +4 -2
- xp/models/conbus/conbus_receive.py +4 -2
- xp/models/conbus/conbus_writeconfig.py +4 -2
- xp/models/config/conson_module_config.py +8 -4
- xp/models/homekit/homekit_accessory.py +4 -2
- xp/models/homekit/homekit_config.py +12 -6
- xp/models/log_entry.py +16 -8
- xp/models/protocol/conbus_protocol.py +36 -18
- xp/models/response.py +12 -8
- xp/models/telegram/action_type.py +4 -2
- xp/models/telegram/datapoint_type.py +4 -2
- xp/models/telegram/event_telegram.py +14 -7
- xp/models/telegram/event_type.py +2 -1
- xp/models/telegram/input_action_type.py +2 -1
- xp/models/telegram/input_type.py +2 -1
- xp/models/telegram/module_type.py +24 -12
- xp/models/telegram/module_type_code.py +2 -1
- xp/models/telegram/output_telegram.py +16 -10
- xp/models/telegram/reply_telegram.py +24 -13
- xp/models/telegram/system_function.py +6 -3
- xp/models/telegram/system_telegram.py +10 -6
- xp/models/telegram/telegram.py +2 -1
- xp/models/telegram/telegram_type.py +2 -1
- xp/models/telegram/timeparam_type.py +2 -1
- xp/models/term/connection_state.py +4 -2
- xp/models/term/module_state.py +2 -1
- xp/models/term/protocol_keys_config.py +6 -3
- xp/models/term/status_message.py +2 -1
- xp/models/term/telegram_display.py +2 -1
- xp/models/write_config_type.py +4 -2
- xp/services/actiontable/actiontable_serializer.py +34 -41
- xp/services/{conbus/actiontable/actiontable_download_state_machine.py → actiontable/download_state_machine.py} +13 -8
- xp/services/actiontable/msactiontable_xp20_serializer.py +73 -50
- xp/services/actiontable/msactiontable_xp24_serializer.py +73 -54
- xp/services/actiontable/msactiontable_xp33_serializer.py +44 -20
- xp/services/actiontable/serializer_protocol.py +76 -0
- xp/services/conbus/actiontable/actiontable_download_service.py +68 -31
- xp/services/conbus/actiontable/actiontable_list_service.py +17 -4
- xp/services/conbus/actiontable/actiontable_show_service.py +10 -6
- xp/services/conbus/actiontable/actiontable_upload_service.py +17 -9
- xp/services/conbus/conbus_blink_all_service.py +16 -8
- xp/services/conbus/conbus_blink_service.py +14 -7
- xp/services/conbus/conbus_custom_service.py +16 -8
- xp/services/conbus/conbus_datapoint_queryall_service.py +18 -9
- xp/services/conbus/conbus_datapoint_service.py +18 -9
- xp/services/conbus/conbus_discover_service.py +24 -13
- xp/services/conbus/conbus_event_list_service.py +11 -7
- xp/services/conbus/conbus_event_raw_service.py +18 -10
- xp/services/conbus/conbus_export_service.py +28 -14
- xp/services/conbus/conbus_output_service.py +18 -10
- xp/services/conbus/conbus_raw_service.py +16 -8
- xp/services/conbus/conbus_receive_service.py +18 -10
- xp/services/conbus/conbus_scan_service.py +18 -10
- xp/services/conbus/msactiontable/msactiontable_upload_service.py +18 -10
- xp/services/conbus/write_config_service.py +18 -9
- xp/services/homekit/homekit_cache_service.py +12 -6
- xp/services/homekit/homekit_conbus_service.py +12 -6
- xp/services/homekit/homekit_config_validator.py +34 -17
- xp/services/homekit/homekit_conson_validator.py +18 -9
- xp/services/homekit/homekit_dimminglight.py +14 -7
- xp/services/homekit/homekit_dimminglight_service.py +14 -7
- xp/services/homekit/homekit_hap_service.py +18 -9
- xp/services/homekit/homekit_lightbulb.py +10 -5
- xp/services/homekit/homekit_lightbulb_service.py +10 -5
- xp/services/homekit/homekit_module_service.py +8 -4
- xp/services/homekit/homekit_outlet.py +14 -7
- xp/services/homekit/homekit_outlet_service.py +12 -6
- xp/services/homekit/homekit_service.py +24 -12
- xp/services/log_file_service.py +16 -8
- xp/services/module_type_service.py +10 -5
- xp/services/protocol/conbus_event_protocol.py +51 -26
- xp/services/protocol/conbus_protocol.py +36 -19
- xp/services/protocol/protocol_factory.py +12 -6
- xp/services/protocol/telegram_protocol.py +12 -6
- xp/services/reverse_proxy_service.py +26 -14
- xp/services/server/base_server_service.py +42 -23
- xp/services/server/client_buffer_manager.py +12 -7
- xp/services/server/cp20_server_service.py +10 -7
- xp/services/server/device_service_factory.py +12 -8
- xp/services/server/server_service.py +18 -11
- xp/services/server/xp130_server_service.py +11 -8
- xp/services/server/xp20_server_service.py +16 -10
- xp/services/server/xp230_server_service.py +10 -7
- xp/services/server/xp24_server_service.py +22 -13
- xp/services/server/xp33_server_service.py +44 -25
- xp/services/telegram/telegram_blink_service.py +14 -8
- xp/services/telegram/telegram_checksum_service.py +12 -7
- xp/services/telegram/telegram_datapoint_service.py +14 -9
- xp/services/telegram/telegram_discover_service.py +28 -15
- xp/services/telegram/telegram_link_number_service.py +18 -10
- xp/services/telegram/telegram_output_service.py +24 -12
- xp/services/telegram/telegram_service.py +22 -11
- xp/services/telegram/telegram_version_service.py +14 -8
- xp/services/term/protocol_monitor_service.py +30 -16
- xp/services/term/state_monitor_service.py +39 -21
- xp/term/protocol.py +12 -6
- xp/term/state.py +12 -7
- xp/term/widgets/help_menu.py +6 -3
- xp/term/widgets/modules_list.py +20 -10
- xp/term/widgets/protocol_log.py +12 -6
- xp/term/widgets/status_footer.py +10 -5
- xp/utils/checksum.py +6 -3
- xp/utils/dependencies.py +25 -30
- xp/utils/event_helper.py +6 -4
- xp/utils/logging.py +6 -3
- xp/utils/serialization.py +30 -16
- xp/utils/state_machine.py +16 -9
- xp/utils/time_utils.py +6 -3
- conson_xp-1.46.0.dist-info/RECORD +0 -211
- xp/services/conbus/msactiontable/msactiontable_download_service.py +0 -275
- xp/services/conbus/msactiontable/msactiontable_list_service.py +0 -100
- xp/services/conbus/msactiontable/msactiontable_show_service.py +0 -89
- {conson_xp-1.46.0.dist-info → conson_xp-1.48.0.dist-info}/WHEEL +0 -0
- {conson_xp-1.46.0.dist-info → conson_xp-1.48.0.dist-info}/entry_points.txt +0 -0
- {conson_xp-1.46.0.dist-info → conson_xp-1.48.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""
|
|
2
|
+
Service for device discover telegram operations.
|
|
2
3
|
|
|
3
|
-
This service handles generation and parsing of device discover system telegrams
|
|
4
|
-
|
|
4
|
+
This service handles generation and parsing of device discover system telegrams used for
|
|
5
|
+
enumerating all connected devices on the console bus.
|
|
5
6
|
"""
|
|
6
7
|
|
|
7
8
|
from typing import List, Set
|
|
@@ -24,7 +25,8 @@ class DeviceInfo:
|
|
|
24
25
|
def __init__(
|
|
25
26
|
self, serial_number: str, checksum_valid: bool = True, raw_telegram: str = ""
|
|
26
27
|
):
|
|
27
|
-
"""
|
|
28
|
+
"""
|
|
29
|
+
Initialize device info.
|
|
28
30
|
|
|
29
31
|
Args:
|
|
30
32
|
serial_number: 10-digit module serial number.
|
|
@@ -36,7 +38,8 @@ class DeviceInfo:
|
|
|
36
38
|
self.raw_telegram = raw_telegram
|
|
37
39
|
|
|
38
40
|
def __str__(self) -> str:
|
|
39
|
-
"""
|
|
41
|
+
"""
|
|
42
|
+
Return string representation of device.
|
|
40
43
|
|
|
41
44
|
Returns:
|
|
42
45
|
String with serial number and checksum status.
|
|
@@ -45,7 +48,8 @@ class DeviceInfo:
|
|
|
45
48
|
return f"Device {self.serial_number} ({status})"
|
|
46
49
|
|
|
47
50
|
def __repr__(self) -> str:
|
|
48
|
-
"""
|
|
51
|
+
"""
|
|
52
|
+
Return repr representation of device.
|
|
49
53
|
|
|
50
54
|
Returns:
|
|
51
55
|
DeviceInfo constructor representation.
|
|
@@ -53,7 +57,8 @@ class DeviceInfo:
|
|
|
53
57
|
return f"DeviceInfo(serial='{self.serial_number}', checksum_valid={self.checksum_valid})"
|
|
54
58
|
|
|
55
59
|
def to_dict(self) -> dict:
|
|
56
|
-
"""
|
|
60
|
+
"""
|
|
61
|
+
Convert to dictionary for JSON serialization.
|
|
57
62
|
|
|
58
63
|
Returns:
|
|
59
64
|
Dictionary with device information.
|
|
@@ -99,7 +104,8 @@ class TelegramDiscoverService:
|
|
|
99
104
|
return telegram
|
|
100
105
|
|
|
101
106
|
def create_discover_telegram_object(self) -> SystemTelegram:
|
|
102
|
-
"""
|
|
107
|
+
"""
|
|
108
|
+
Create a SystemTelegram object for discover broadcast.
|
|
103
109
|
|
|
104
110
|
Returns:
|
|
105
111
|
SystemTelegram object representing the discover command.
|
|
@@ -121,7 +127,8 @@ class TelegramDiscoverService:
|
|
|
121
127
|
|
|
122
128
|
@staticmethod
|
|
123
129
|
def is_discover_response(reply_telegram: ReplyTelegram) -> bool:
|
|
124
|
-
"""
|
|
130
|
+
"""
|
|
131
|
+
Check if a reply telegram is a discover response.
|
|
125
132
|
|
|
126
133
|
Args:
|
|
127
134
|
reply_telegram: Reply telegram to check.
|
|
@@ -133,7 +140,8 @@ class TelegramDiscoverService:
|
|
|
133
140
|
|
|
134
141
|
@staticmethod
|
|
135
142
|
def _generate_discover_response(serial_number: str) -> str:
|
|
136
|
-
"""
|
|
143
|
+
"""
|
|
144
|
+
Generate discover response telegram for a device.
|
|
137
145
|
|
|
138
146
|
Args:
|
|
139
147
|
serial_number: 10-digit module serial number.
|
|
@@ -149,7 +157,8 @@ class TelegramDiscoverService:
|
|
|
149
157
|
|
|
150
158
|
@staticmethod
|
|
151
159
|
def get_unique_devices(devices: List[DeviceInfo]) -> List[DeviceInfo]:
|
|
152
|
-
"""
|
|
160
|
+
"""
|
|
161
|
+
Filter out duplicate devices based on serial number.
|
|
153
162
|
|
|
154
163
|
Args:
|
|
155
164
|
devices: List of discovered devices.
|
|
@@ -169,7 +178,8 @@ class TelegramDiscoverService:
|
|
|
169
178
|
|
|
170
179
|
@staticmethod
|
|
171
180
|
def validate_discover_response_format(raw_telegram: str) -> bool:
|
|
172
|
-
"""
|
|
181
|
+
"""
|
|
182
|
+
Validate if a raw telegram matches discover response format.
|
|
173
183
|
|
|
174
184
|
Args:
|
|
175
185
|
raw_telegram: Raw telegram string to validate.
|
|
@@ -187,7 +197,8 @@ class TelegramDiscoverService:
|
|
|
187
197
|
return match is not None
|
|
188
198
|
|
|
189
199
|
def generate_discover_summary(self, devices: List[DeviceInfo]) -> dict:
|
|
190
|
-
"""
|
|
200
|
+
"""
|
|
201
|
+
Generate a summary of a discover results.
|
|
191
202
|
|
|
192
203
|
Args:
|
|
193
204
|
devices: List of discovered devices.
|
|
@@ -223,7 +234,8 @@ class TelegramDiscoverService:
|
|
|
223
234
|
}
|
|
224
235
|
|
|
225
236
|
def format_discover_results(self, devices: List[DeviceInfo]) -> str:
|
|
226
|
-
"""
|
|
237
|
+
"""
|
|
238
|
+
Format discover results for human-readable output.
|
|
227
239
|
|
|
228
240
|
Args:
|
|
229
241
|
devices: List of discovered devices.
|
|
@@ -263,7 +275,8 @@ class TelegramDiscoverService:
|
|
|
263
275
|
|
|
264
276
|
@staticmethod
|
|
265
277
|
def is_discover_request(telegram: SystemTelegram) -> bool:
|
|
266
|
-
"""
|
|
278
|
+
"""
|
|
279
|
+
Check if telegram is a discover request.
|
|
267
280
|
|
|
268
281
|
Args:
|
|
269
282
|
telegram: System telegram to check.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""
|
|
2
|
+
Service for link number telegram operations.
|
|
2
3
|
|
|
3
|
-
This service handles generation and parsing of link number system telegrams
|
|
4
|
-
|
|
4
|
+
This service handles generation and parsing of link number system telegrams used for
|
|
5
|
+
setting and reading module link numbers.
|
|
5
6
|
"""
|
|
6
7
|
|
|
7
8
|
from contextlib import suppress
|
|
@@ -34,7 +35,8 @@ class LinkNumberService:
|
|
|
34
35
|
|
|
35
36
|
@staticmethod
|
|
36
37
|
def generate_set_link_number_telegram(serial_number: str, link_number: int) -> str:
|
|
37
|
-
"""
|
|
38
|
+
"""
|
|
39
|
+
Generate a telegram to set a module's link number.
|
|
38
40
|
|
|
39
41
|
Args:
|
|
40
42
|
serial_number: The 10-digit module serial number.
|
|
@@ -79,7 +81,8 @@ class LinkNumberService:
|
|
|
79
81
|
|
|
80
82
|
@staticmethod
|
|
81
83
|
def generate_read_link_number_telegram(serial_number: str) -> str:
|
|
82
|
-
"""
|
|
84
|
+
"""
|
|
85
|
+
Generate a telegram to read a module's current link number.
|
|
83
86
|
|
|
84
87
|
Args:
|
|
85
88
|
serial_number: The 10-digit module serial number.
|
|
@@ -115,7 +118,8 @@ class LinkNumberService:
|
|
|
115
118
|
def create_set_link_number_telegram_object(
|
|
116
119
|
self, serial_number: str, link_number: int
|
|
117
120
|
) -> SystemTelegram:
|
|
118
|
-
"""
|
|
121
|
+
"""
|
|
122
|
+
Create a SystemTelegram object for setting link number.
|
|
119
123
|
|
|
120
124
|
Args:
|
|
121
125
|
serial_number: The 10-digit module serial number.
|
|
@@ -144,7 +148,8 @@ class LinkNumberService:
|
|
|
144
148
|
def create_read_link_number_telegram_object(
|
|
145
149
|
self, serial_number: str
|
|
146
150
|
) -> SystemTelegram:
|
|
147
|
-
"""
|
|
151
|
+
"""
|
|
152
|
+
Create a SystemTelegram object for reading link number.
|
|
148
153
|
|
|
149
154
|
Args:
|
|
150
155
|
serial_number: The 10-digit module serial number.
|
|
@@ -169,7 +174,8 @@ class LinkNumberService:
|
|
|
169
174
|
|
|
170
175
|
@staticmethod
|
|
171
176
|
def parse_link_number_from_reply(reply_telegram: ReplyTelegram) -> Optional[int]:
|
|
172
|
-
"""
|
|
177
|
+
"""
|
|
178
|
+
Parse the link number value from a reply telegram.
|
|
173
179
|
|
|
174
180
|
Args:
|
|
175
181
|
reply_telegram: Reply telegram containing link number data.
|
|
@@ -193,7 +199,8 @@ class LinkNumberService:
|
|
|
193
199
|
|
|
194
200
|
@staticmethod
|
|
195
201
|
def is_ack_response(reply_telegram: ReplyTelegram) -> bool:
|
|
196
|
-
"""
|
|
202
|
+
"""
|
|
203
|
+
Check if a reply telegram is an ACK response.
|
|
197
204
|
|
|
198
205
|
Args:
|
|
199
206
|
reply_telegram: Reply telegram to check.
|
|
@@ -205,7 +212,8 @@ class LinkNumberService:
|
|
|
205
212
|
|
|
206
213
|
@staticmethod
|
|
207
214
|
def is_nak_response(reply_telegram: ReplyTelegram) -> bool:
|
|
208
|
-
"""
|
|
215
|
+
"""
|
|
216
|
+
Check if a reply telegram is a NAK response.
|
|
209
217
|
|
|
210
218
|
Args:
|
|
211
219
|
reply_telegram: Reply telegram to check.
|
|
@@ -18,7 +18,8 @@ class XPOutputError(Exception):
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class TelegramOutputService:
|
|
21
|
-
"""
|
|
21
|
+
"""
|
|
22
|
+
Service for XP action operations.
|
|
22
23
|
|
|
23
24
|
Handles parsing and validation of XP24 action telegrams,
|
|
24
25
|
status queries, and action command generation.
|
|
@@ -37,7 +38,8 @@ class TelegramOutputService:
|
|
|
37
38
|
XP_ACK_NAK_PATTERN = re.compile(r"^<R(\d{10})F(1[89])D([A-Z0-9]{2})>$")
|
|
38
39
|
|
|
39
40
|
def __init__(self, telegram_service: TelegramService) -> None:
|
|
40
|
-
"""
|
|
41
|
+
"""
|
|
42
|
+
Initialize the XP output service.
|
|
41
43
|
|
|
42
44
|
Args:
|
|
43
45
|
telegram_service: TelegramService instance for parsing operations.
|
|
@@ -45,7 +47,8 @@ class TelegramOutputService:
|
|
|
45
47
|
self.telegram_service = telegram_service
|
|
46
48
|
|
|
47
49
|
def validate_output_number(self, output_number: int) -> None:
|
|
48
|
-
"""
|
|
50
|
+
"""
|
|
51
|
+
Validate XP24 output number according to architecture constraints.
|
|
49
52
|
|
|
50
53
|
Args:
|
|
51
54
|
output_number: Output number to validate (0-3).
|
|
@@ -66,7 +69,8 @@ class TelegramOutputService:
|
|
|
66
69
|
|
|
67
70
|
@staticmethod
|
|
68
71
|
def validate_serial_number(serial_number: str) -> None:
|
|
69
|
-
"""
|
|
72
|
+
"""
|
|
73
|
+
Validate serial number format.
|
|
70
74
|
|
|
71
75
|
Args:
|
|
72
76
|
serial_number: Serial number to validate.
|
|
@@ -88,7 +92,8 @@ class TelegramOutputService:
|
|
|
88
92
|
def generate_system_action_telegram(
|
|
89
93
|
self, serial_number: str, output_number: int, action: ActionType
|
|
90
94
|
) -> str:
|
|
91
|
-
"""
|
|
95
|
+
"""
|
|
96
|
+
Generate XP24 action telegram string.
|
|
92
97
|
|
|
93
98
|
Args:
|
|
94
99
|
serial_number: Target module serial number.
|
|
@@ -121,7 +126,8 @@ class TelegramOutputService:
|
|
|
121
126
|
return f"<{data_part}{checksum}>"
|
|
122
127
|
|
|
123
128
|
def generate_system_status_telegram(self, serial_number: str) -> str:
|
|
124
|
-
"""
|
|
129
|
+
"""
|
|
130
|
+
Generate XP output status query telegram.
|
|
125
131
|
|
|
126
132
|
Args:
|
|
127
133
|
serial_number: Target module serial number.
|
|
@@ -144,7 +150,8 @@ class TelegramOutputService:
|
|
|
144
150
|
return f"<{data_part}{checksum}>"
|
|
145
151
|
|
|
146
152
|
def parse_reply_telegram(self, raw_telegram: str) -> OutputTelegram:
|
|
147
|
-
"""
|
|
153
|
+
"""
|
|
154
|
+
Parse a raw XP output response telegram string.
|
|
148
155
|
|
|
149
156
|
Args:
|
|
150
157
|
raw_telegram: The raw telegram string (e.g., "<R0012345003F18DFF>").
|
|
@@ -194,7 +201,8 @@ class TelegramOutputService:
|
|
|
194
201
|
raise XPOutputError(f"Invalid values in XP24 action telegram: {e}")
|
|
195
202
|
|
|
196
203
|
def parse_system_telegram(self, raw_telegram: str) -> OutputTelegram:
|
|
197
|
-
"""
|
|
204
|
+
"""
|
|
205
|
+
Parse a raw XP output telegram string.
|
|
198
206
|
|
|
199
207
|
Args:
|
|
200
208
|
raw_telegram: The raw telegram string (e.g., "<S0012345008F27D00AAFN>").
|
|
@@ -247,7 +255,8 @@ class TelegramOutputService:
|
|
|
247
255
|
raise XPOutputError(f"Invalid values in XP24 action telegram: {e}")
|
|
248
256
|
|
|
249
257
|
def parse_status_response(self, raw_telegram: str) -> list[bool]:
|
|
250
|
-
"""
|
|
258
|
+
"""
|
|
259
|
+
Parse XP24 status response telegram to extract output states.
|
|
251
260
|
|
|
252
261
|
Args:
|
|
253
262
|
raw_telegram: Raw reply telegram (e.g., "<R0012345008F02D12xxxx1110FJ>").
|
|
@@ -284,7 +293,8 @@ class TelegramOutputService:
|
|
|
284
293
|
|
|
285
294
|
@staticmethod
|
|
286
295
|
def format_status_summary(status: Dict[int, bool]) -> str:
|
|
287
|
-
"""
|
|
296
|
+
"""
|
|
297
|
+
Format status dictionary into human-readable summary.
|
|
288
298
|
|
|
289
299
|
Args:
|
|
290
300
|
status: Dictionary mapping output numbers to states.
|
|
@@ -301,7 +311,8 @@ class TelegramOutputService:
|
|
|
301
311
|
|
|
302
312
|
@staticmethod
|
|
303
313
|
def format_action_summary(telegram: OutputTelegram) -> str:
|
|
304
|
-
"""
|
|
314
|
+
"""
|
|
315
|
+
Format XP24 action telegram for human-readable output.
|
|
305
316
|
|
|
306
317
|
Args:
|
|
307
318
|
telegram: The parsed action telegram.
|
|
@@ -323,7 +334,8 @@ class TelegramOutputService:
|
|
|
323
334
|
|
|
324
335
|
@staticmethod
|
|
325
336
|
def format_output_state(data_value: str) -> str:
|
|
326
|
-
"""
|
|
337
|
+
"""
|
|
338
|
+
Format module output state data value for display.
|
|
327
339
|
|
|
328
340
|
Algorithm:
|
|
329
341
|
1. Remove 'x' characters
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""
|
|
2
|
+
Telegram Service for parsing XP telegrams.
|
|
2
3
|
|
|
3
|
-
This module provides telegram parsing functionality for event, system, and reply
|
|
4
|
+
This module provides telegram parsing functionality for event, system, and reply
|
|
5
|
+
telegrams.
|
|
4
6
|
"""
|
|
5
7
|
|
|
6
8
|
import logging
|
|
@@ -25,7 +27,8 @@ class TelegramParsingError(Exception):
|
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
class TelegramService:
|
|
28
|
-
"""
|
|
30
|
+
"""
|
|
31
|
+
Service for parsing event telegrams from the console bus.
|
|
29
32
|
|
|
30
33
|
Handles parsing of telegrams in the format:
|
|
31
34
|
<[EO]{module_type}L{link_number}I{output_number}{event_type}{checksum}>
|
|
@@ -53,7 +56,8 @@ class TelegramService:
|
|
|
53
56
|
self.logger = logging.getLogger(__name__)
|
|
54
57
|
|
|
55
58
|
def parse_event_telegram(self, raw_telegram: str) -> EventTelegram:
|
|
56
|
-
"""
|
|
59
|
+
"""
|
|
60
|
+
Parse a raw telegram string into an EventTelegram object.
|
|
57
61
|
|
|
58
62
|
Args:
|
|
59
63
|
raw_telegram: The raw telegram string (e.g., "<E14L00I02MAK>").
|
|
@@ -124,7 +128,8 @@ class TelegramService:
|
|
|
124
128
|
def validate_checksum(
|
|
125
129
|
telegram: Union[EventTelegram, ReplyTelegram, SystemTelegram, OutputTelegram],
|
|
126
130
|
) -> bool:
|
|
127
|
-
"""
|
|
131
|
+
"""
|
|
132
|
+
Validate the checksum of a parsed telegram.
|
|
128
133
|
|
|
129
134
|
Args:
|
|
130
135
|
telegram: The parsed telegram.
|
|
@@ -150,7 +155,8 @@ class TelegramService:
|
|
|
150
155
|
|
|
151
156
|
@staticmethod
|
|
152
157
|
def format_event_telegram_summary(telegram: EventTelegram) -> str:
|
|
153
|
-
"""
|
|
158
|
+
"""
|
|
159
|
+
Format a telegram for human-readable output.
|
|
154
160
|
|
|
155
161
|
Args:
|
|
156
162
|
telegram: The parsed telegram.
|
|
@@ -171,7 +177,8 @@ class TelegramService:
|
|
|
171
177
|
)
|
|
172
178
|
|
|
173
179
|
def parse_system_telegram(self, raw_telegram: str) -> SystemTelegram:
|
|
174
|
-
"""
|
|
180
|
+
"""
|
|
181
|
+
Parse a raw system telegram string into a SystemTelegram object.
|
|
175
182
|
|
|
176
183
|
Args:
|
|
177
184
|
raw_telegram: The raw telegram string (e.g., "<S0020012521F02D18FN>").
|
|
@@ -229,7 +236,8 @@ class TelegramService:
|
|
|
229
236
|
raise TelegramParsingError(f"Invalid values in system telegram: {e}")
|
|
230
237
|
|
|
231
238
|
def parse_reply_telegram(self, raw_telegram: str) -> ReplyTelegram:
|
|
232
|
-
"""
|
|
239
|
+
"""
|
|
240
|
+
Parse a raw reply telegram string into a ReplyTelegram object.
|
|
233
241
|
|
|
234
242
|
Args:
|
|
235
243
|
raw_telegram: The raw telegram string (e.g., "<R0020012521F02D18+26,0§CIL>").
|
|
@@ -297,7 +305,8 @@ class TelegramService:
|
|
|
297
305
|
def parse_telegram(
|
|
298
306
|
self, raw_telegram: str
|
|
299
307
|
) -> Union[EventTelegram, SystemTelegram, ReplyTelegram]:
|
|
300
|
-
"""
|
|
308
|
+
"""
|
|
309
|
+
Auto-detect and parse any type of telegram.
|
|
301
310
|
|
|
302
311
|
Args:
|
|
303
312
|
raw_telegram: The raw telegram string.
|
|
@@ -329,7 +338,8 @@ class TelegramService:
|
|
|
329
338
|
|
|
330
339
|
@staticmethod
|
|
331
340
|
def format_system_telegram_summary(telegram: SystemTelegram) -> str:
|
|
332
|
-
"""
|
|
341
|
+
"""
|
|
342
|
+
Format a system telegram for human-readable output.
|
|
333
343
|
|
|
334
344
|
Args:
|
|
335
345
|
telegram: The parsed system telegram.
|
|
@@ -351,7 +361,8 @@ class TelegramService:
|
|
|
351
361
|
|
|
352
362
|
@staticmethod
|
|
353
363
|
def format_reply_telegram_summary(telegram: ReplyTelegram) -> str:
|
|
354
|
-
"""
|
|
364
|
+
"""
|
|
365
|
+
Format a reply telegram for human-readable output.
|
|
355
366
|
|
|
356
367
|
Args:
|
|
357
368
|
telegram: The parsed reply telegram.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""
|
|
2
|
+
Version service for handling version information parsing and validation.
|
|
2
3
|
|
|
3
|
-
This service provides business logic for version operations,
|
|
4
|
-
|
|
4
|
+
This service provides business logic for version operations, following the layered
|
|
5
|
+
architecture pattern.
|
|
5
6
|
"""
|
|
6
7
|
|
|
7
8
|
import re
|
|
@@ -29,7 +30,8 @@ class VersionService:
|
|
|
29
30
|
|
|
30
31
|
@staticmethod
|
|
31
32
|
def parse_version_string(version_string: str) -> Response:
|
|
32
|
-
"""
|
|
33
|
+
"""
|
|
34
|
+
Parse a version string into its components.
|
|
33
35
|
|
|
34
36
|
Args:
|
|
35
37
|
version_string: Version string in format 'XP230_V1.00.04'
|
|
@@ -90,7 +92,8 @@ class VersionService:
|
|
|
90
92
|
|
|
91
93
|
@staticmethod
|
|
92
94
|
def generate_version_request_telegram(serial_number: str) -> Response:
|
|
93
|
-
"""
|
|
95
|
+
"""
|
|
96
|
+
Generate a system telegram to request version information.
|
|
94
97
|
|
|
95
98
|
Args:
|
|
96
99
|
serial_number: 10-digit serial number of the device
|
|
@@ -138,7 +141,8 @@ class VersionService:
|
|
|
138
141
|
|
|
139
142
|
@staticmethod
|
|
140
143
|
def validate_version_telegram(telegram: SystemTelegram) -> Response:
|
|
141
|
-
"""
|
|
144
|
+
"""
|
|
145
|
+
Validate if a system telegram is a valid version request.
|
|
142
146
|
|
|
143
147
|
Args:
|
|
144
148
|
telegram: Parsed system telegram
|
|
@@ -190,7 +194,8 @@ class VersionService:
|
|
|
190
194
|
|
|
191
195
|
@staticmethod
|
|
192
196
|
def parse_version_reply(telegram: ReplyTelegram) -> Response:
|
|
193
|
-
"""
|
|
197
|
+
"""
|
|
198
|
+
Parse version information from a reply telegram.
|
|
194
199
|
|
|
195
200
|
Args:
|
|
196
201
|
telegram: Parsed reply telegram containing version data
|
|
@@ -246,7 +251,8 @@ class VersionService:
|
|
|
246
251
|
|
|
247
252
|
@staticmethod
|
|
248
253
|
def format_version_summary(version_data: dict) -> str:
|
|
249
|
-
"""
|
|
254
|
+
"""
|
|
255
|
+
Format version information for human-readable output.
|
|
250
256
|
|
|
251
257
|
Args:
|
|
252
258
|
version_data: Version information dictionary
|
|
@@ -14,7 +14,8 @@ from xp.services.protocol.conbus_event_protocol import ConbusEventProtocol
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class ProtocolMonitorService:
|
|
17
|
-
"""
|
|
17
|
+
"""
|
|
18
|
+
Service for protocol monitoring in terminal interface.
|
|
18
19
|
|
|
19
20
|
Wraps ConbusEventProtocol and provides high-level operations
|
|
20
21
|
for the TUI without exposing protocol implementation details.
|
|
@@ -38,7 +39,8 @@ class ProtocolMonitorService:
|
|
|
38
39
|
conbus_protocol: ConbusEventProtocol,
|
|
39
40
|
protocol_keys: ProtocolKeysConfig,
|
|
40
41
|
) -> None:
|
|
41
|
-
"""
|
|
42
|
+
"""
|
|
43
|
+
Initialize the Protocol Monitor service.
|
|
42
44
|
|
|
43
45
|
Args:
|
|
44
46
|
conbus_protocol: ConbusEventProtocol instance.
|
|
@@ -77,7 +79,8 @@ class ProtocolMonitorService:
|
|
|
77
79
|
|
|
78
80
|
@property
|
|
79
81
|
def connection_state(self) -> ConnectionState:
|
|
80
|
-
"""
|
|
82
|
+
"""
|
|
83
|
+
Get current connection state.
|
|
81
84
|
|
|
82
85
|
Returns:
|
|
83
86
|
Current connection state.
|
|
@@ -86,7 +89,8 @@ class ProtocolMonitorService:
|
|
|
86
89
|
|
|
87
90
|
@property
|
|
88
91
|
def server_info(self) -> str:
|
|
89
|
-
"""
|
|
92
|
+
"""
|
|
93
|
+
Get server connection info (IP:port).
|
|
90
94
|
|
|
91
95
|
Returns:
|
|
92
96
|
Server address in format "IP:port".
|
|
@@ -131,10 +135,11 @@ class ProtocolMonitorService:
|
|
|
131
135
|
self.on_status_message.emit("Disconnected")
|
|
132
136
|
|
|
133
137
|
def toggle_connection(self) -> None:
|
|
134
|
-
"""
|
|
138
|
+
"""
|
|
139
|
+
Toggle connection state between connected and disconnected.
|
|
135
140
|
|
|
136
|
-
Disconnects if currently connected or connecting.
|
|
137
|
-
|
|
141
|
+
Disconnects if currently connected or connecting. Connects if currently
|
|
142
|
+
disconnected or failed.
|
|
138
143
|
"""
|
|
139
144
|
if self._connection_state in (
|
|
140
145
|
ConnectionState.CONNECTED,
|
|
@@ -145,7 +150,8 @@ class ProtocolMonitorService:
|
|
|
145
150
|
self.connect()
|
|
146
151
|
|
|
147
152
|
def _send_telegram(self, name: str, telegram: str) -> None:
|
|
148
|
-
"""
|
|
153
|
+
"""
|
|
154
|
+
Send a raw telegram.
|
|
149
155
|
|
|
150
156
|
Args:
|
|
151
157
|
name: Display name for the telegram.
|
|
@@ -159,7 +165,8 @@ class ProtocolMonitorService:
|
|
|
159
165
|
self.on_status_message.emit(f"Failed: {e}")
|
|
160
166
|
|
|
161
167
|
def handle_key_press(self, key: str) -> bool:
|
|
162
|
-
"""
|
|
168
|
+
"""
|
|
169
|
+
Handle protocol key press.
|
|
163
170
|
|
|
164
171
|
Args:
|
|
165
172
|
key: Key that was pressed.
|
|
@@ -184,7 +191,8 @@ class ProtocolMonitorService:
|
|
|
184
191
|
self.on_status_message.emit(f"Connected to {self.server_info}")
|
|
185
192
|
|
|
186
193
|
def _on_connection_failed(self, failure: Failure) -> None:
|
|
187
|
-
"""
|
|
194
|
+
"""
|
|
195
|
+
Handle connection failed.
|
|
188
196
|
|
|
189
197
|
Args:
|
|
190
198
|
failure: Twisted failure object with error details.
|
|
@@ -195,7 +203,8 @@ class ProtocolMonitorService:
|
|
|
195
203
|
self.on_status_message.emit(failure.getErrorMessage())
|
|
196
204
|
|
|
197
205
|
def _on_telegram_received(self, event: TelegramReceivedEvent) -> None:
|
|
198
|
-
"""
|
|
206
|
+
"""
|
|
207
|
+
Handle telegram received.
|
|
199
208
|
|
|
200
209
|
Args:
|
|
201
210
|
event: Telegram received event with frame data.
|
|
@@ -204,7 +213,8 @@ class ProtocolMonitorService:
|
|
|
204
213
|
self.on_telegram_display.emit(display_event)
|
|
205
214
|
|
|
206
215
|
def _on_telegram_sent(self, telegram: str) -> None:
|
|
207
|
-
"""
|
|
216
|
+
"""
|
|
217
|
+
Handle telegram sent.
|
|
208
218
|
|
|
209
219
|
Args:
|
|
210
220
|
telegram: Sent telegram string.
|
|
@@ -217,7 +227,8 @@ class ProtocolMonitorService:
|
|
|
217
227
|
self.logger.debug("Timeout occurred (continuous monitoring)")
|
|
218
228
|
|
|
219
229
|
def _on_failed(self, error: str) -> None:
|
|
220
|
-
"""
|
|
230
|
+
"""
|
|
231
|
+
Handle connection failed.
|
|
221
232
|
|
|
222
233
|
Args:
|
|
223
234
|
error: Error message describing the failure.
|
|
@@ -234,7 +245,8 @@ class ProtocolMonitorService:
|
|
|
234
245
|
self.disconnect()
|
|
235
246
|
|
|
236
247
|
def get_keys(self) -> ItemsView[str, ProtocolKeyConfig]:
|
|
237
|
-
"""
|
|
248
|
+
"""
|
|
249
|
+
Get protocol key mappings.
|
|
238
250
|
|
|
239
251
|
Returns:
|
|
240
252
|
Dictionary items view of key to ProtocolKeyConfig mappings.
|
|
@@ -242,7 +254,8 @@ class ProtocolMonitorService:
|
|
|
242
254
|
return self._protocol_keys.protocol.items()
|
|
243
255
|
|
|
244
256
|
def __enter__(self) -> "ProtocolMonitorService":
|
|
245
|
-
"""
|
|
257
|
+
"""
|
|
258
|
+
Enter context manager.
|
|
246
259
|
|
|
247
260
|
Returns:
|
|
248
261
|
Self for context management.
|
|
@@ -255,7 +268,8 @@ class ProtocolMonitorService:
|
|
|
255
268
|
_exc_val: Optional[BaseException],
|
|
256
269
|
_exc_tb: Optional[Any],
|
|
257
270
|
) -> None:
|
|
258
|
-
"""
|
|
271
|
+
"""
|
|
272
|
+
Exit context manager and clean up resources.
|
|
259
273
|
|
|
260
274
|
Args:
|
|
261
275
|
_exc_type: Exception type if any.
|