conson-xp 1.45.0__py3-none-any.whl → 1.47.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.
Files changed (179) hide show
  1. {conson_xp-1.45.0.dist-info → conson_xp-1.47.0.dist-info}/METADATA +1 -1
  2. conson_xp-1.47.0.dist-info/RECORD +210 -0
  3. xp/__init__.py +3 -2
  4. xp/cli/commands/conbus/conbus.py +1 -1
  5. xp/cli/commands/conbus/conbus_actiontable_commands.py +33 -15
  6. xp/cli/commands/conbus/conbus_autoreport_commands.py +8 -4
  7. xp/cli/commands/conbus/conbus_blink_commands.py +20 -10
  8. xp/cli/commands/conbus/conbus_config_commands.py +2 -1
  9. xp/cli/commands/conbus/conbus_custom_commands.py +4 -2
  10. xp/cli/commands/conbus/conbus_datapoint_commands.py +10 -5
  11. xp/cli/commands/conbus/conbus_discover_commands.py +8 -4
  12. xp/cli/commands/conbus/conbus_event_commands.py +8 -4
  13. xp/cli/commands/conbus/conbus_export_commands.py +8 -4
  14. xp/cli/commands/conbus/conbus_lightlevel_commands.py +16 -8
  15. xp/cli/commands/conbus/conbus_linknumber_commands.py +8 -4
  16. xp/cli/commands/conbus/conbus_modulenumber_commands.py +8 -4
  17. xp/cli/commands/conbus/conbus_msactiontable_commands.py +78 -40
  18. xp/cli/commands/conbus/conbus_output_commands.py +16 -8
  19. xp/cli/commands/conbus/conbus_raw_commands.py +6 -3
  20. xp/cli/commands/conbus/conbus_receive_commands.py +6 -3
  21. xp/cli/commands/conbus/conbus_scan_commands.py +6 -3
  22. xp/cli/commands/file_commands.py +6 -3
  23. xp/cli/commands/homekit/homekit.py +4 -2
  24. xp/cli/commands/homekit/homekit_start_commands.py +2 -1
  25. xp/cli/commands/module_commands.py +8 -4
  26. xp/cli/commands/reverse_proxy_commands.py +8 -4
  27. xp/cli/commands/server/server_commands.py +6 -3
  28. xp/cli/commands/telegram/telegram_blink_commands.py +4 -2
  29. xp/cli/commands/telegram/telegram_checksum_commands.py +4 -2
  30. xp/cli/commands/telegram/telegram_discover_commands.py +2 -1
  31. xp/cli/commands/telegram/telegram_linknumber_commands.py +4 -2
  32. xp/cli/commands/telegram/telegram_parse_commands.py +4 -2
  33. xp/cli/commands/telegram/telegram_version_commands.py +2 -1
  34. xp/cli/commands/term/term_commands.py +4 -2
  35. xp/cli/main.py +2 -1
  36. xp/cli/utils/click_tree.py +6 -3
  37. xp/cli/utils/datapoint_type_choice.py +4 -2
  38. xp/cli/utils/decorators.py +42 -21
  39. xp/cli/utils/error_handlers.py +16 -8
  40. xp/cli/utils/formatters.py +22 -11
  41. xp/cli/utils/module_type_choice.py +4 -2
  42. xp/cli/utils/serial_number_type.py +4 -2
  43. xp/cli/utils/system_function_choice.py +4 -2
  44. xp/cli/utils/xp_module_type.py +4 -2
  45. xp/models/actiontable/actiontable.py +8 -8
  46. xp/models/actiontable/actiontable_type.py +20 -0
  47. xp/models/actiontable/msactiontable_xp20.py +8 -4
  48. xp/models/actiontable/msactiontable_xp24.py +12 -6
  49. xp/models/actiontable/msactiontable_xp33.py +20 -10
  50. xp/models/conbus/conbus.py +8 -4
  51. xp/models/conbus/conbus_autoreport.py +4 -2
  52. xp/models/conbus/conbus_blink.py +4 -2
  53. xp/models/conbus/conbus_client_config.py +6 -3
  54. xp/models/conbus/conbus_connection_status.py +4 -2
  55. xp/models/conbus/conbus_custom.py +4 -2
  56. xp/models/conbus/conbus_datapoint.py +4 -2
  57. xp/models/conbus/conbus_discover.py +6 -3
  58. xp/models/conbus/conbus_event_list.py +4 -2
  59. xp/models/conbus/conbus_event_raw.py +4 -2
  60. xp/models/conbus/conbus_export.py +2 -1
  61. xp/models/conbus/conbus_lightlevel.py +4 -2
  62. xp/models/conbus/conbus_linknumber.py +4 -2
  63. xp/models/conbus/conbus_logger_config.py +8 -4
  64. xp/models/conbus/conbus_output.py +4 -2
  65. xp/models/conbus/conbus_raw.py +4 -2
  66. xp/models/conbus/conbus_receive.py +4 -2
  67. xp/models/conbus/conbus_writeconfig.py +4 -2
  68. xp/models/config/conson_module_config.py +8 -4
  69. xp/models/homekit/homekit_accessory.py +4 -2
  70. xp/models/homekit/homekit_config.py +12 -6
  71. xp/models/log_entry.py +16 -8
  72. xp/models/protocol/conbus_protocol.py +36 -18
  73. xp/models/response.py +12 -8
  74. xp/models/telegram/action_type.py +4 -2
  75. xp/models/telegram/datapoint_type.py +4 -2
  76. xp/models/telegram/event_telegram.py +14 -7
  77. xp/models/telegram/event_type.py +2 -1
  78. xp/models/telegram/input_action_type.py +2 -1
  79. xp/models/telegram/input_type.py +2 -1
  80. xp/models/telegram/module_type.py +24 -12
  81. xp/models/telegram/module_type_code.py +2 -1
  82. xp/models/telegram/output_telegram.py +16 -10
  83. xp/models/telegram/reply_telegram.py +24 -13
  84. xp/models/telegram/system_function.py +6 -3
  85. xp/models/telegram/system_telegram.py +10 -6
  86. xp/models/telegram/telegram.py +2 -1
  87. xp/models/telegram/telegram_type.py +2 -1
  88. xp/models/telegram/timeparam_type.py +2 -1
  89. xp/models/term/connection_state.py +4 -2
  90. xp/models/term/module_state.py +2 -1
  91. xp/models/term/protocol_keys_config.py +6 -3
  92. xp/models/term/status_message.py +2 -1
  93. xp/models/term/telegram_display.py +2 -1
  94. xp/models/write_config_type.py +4 -2
  95. xp/services/actiontable/actiontable_serializer.py +34 -41
  96. xp/services/actiontable/download_state_machine.py +281 -0
  97. xp/services/actiontable/msactiontable_xp20_serializer.py +77 -49
  98. xp/services/actiontable/msactiontable_xp24_serializer.py +78 -53
  99. xp/services/actiontable/msactiontable_xp33_serializer.py +39 -9
  100. xp/services/actiontable/serializer_protocol.py +76 -0
  101. xp/services/conbus/actiontable/actiontable_download_service.py +134 -280
  102. xp/services/conbus/actiontable/actiontable_list_service.py +17 -4
  103. xp/services/conbus/actiontable/actiontable_show_service.py +10 -6
  104. xp/services/conbus/actiontable/actiontable_upload_service.py +17 -9
  105. xp/services/conbus/conbus_blink_all_service.py +16 -8
  106. xp/services/conbus/conbus_blink_service.py +14 -7
  107. xp/services/conbus/conbus_custom_service.py +16 -8
  108. xp/services/conbus/conbus_datapoint_queryall_service.py +18 -9
  109. xp/services/conbus/conbus_datapoint_service.py +18 -9
  110. xp/services/conbus/conbus_discover_service.py +24 -13
  111. xp/services/conbus/conbus_event_list_service.py +11 -7
  112. xp/services/conbus/conbus_event_raw_service.py +18 -10
  113. xp/services/conbus/conbus_export_service.py +28 -14
  114. xp/services/conbus/conbus_output_service.py +18 -10
  115. xp/services/conbus/conbus_raw_service.py +16 -8
  116. xp/services/conbus/conbus_receive_service.py +18 -10
  117. xp/services/conbus/conbus_scan_service.py +18 -10
  118. xp/services/conbus/msactiontable/msactiontable_upload_service.py +17 -9
  119. xp/services/conbus/write_config_service.py +18 -9
  120. xp/services/homekit/homekit_cache_service.py +12 -6
  121. xp/services/homekit/homekit_conbus_service.py +12 -6
  122. xp/services/homekit/homekit_config_validator.py +34 -17
  123. xp/services/homekit/homekit_conson_validator.py +18 -9
  124. xp/services/homekit/homekit_dimminglight.py +14 -7
  125. xp/services/homekit/homekit_dimminglight_service.py +14 -7
  126. xp/services/homekit/homekit_hap_service.py +18 -9
  127. xp/services/homekit/homekit_lightbulb.py +10 -5
  128. xp/services/homekit/homekit_lightbulb_service.py +10 -5
  129. xp/services/homekit/homekit_module_service.py +8 -4
  130. xp/services/homekit/homekit_outlet.py +14 -7
  131. xp/services/homekit/homekit_outlet_service.py +12 -6
  132. xp/services/homekit/homekit_service.py +24 -12
  133. xp/services/log_file_service.py +16 -8
  134. xp/services/module_type_service.py +10 -5
  135. xp/services/protocol/conbus_event_protocol.py +140 -21
  136. xp/services/protocol/conbus_protocol.py +36 -19
  137. xp/services/protocol/protocol_factory.py +12 -6
  138. xp/services/protocol/telegram_protocol.py +12 -6
  139. xp/services/reverse_proxy_service.py +26 -14
  140. xp/services/server/base_server_service.py +42 -23
  141. xp/services/server/client_buffer_manager.py +12 -7
  142. xp/services/server/cp20_server_service.py +10 -7
  143. xp/services/server/device_service_factory.py +12 -8
  144. xp/services/server/server_service.py +18 -11
  145. xp/services/server/xp130_server_service.py +11 -8
  146. xp/services/server/xp20_server_service.py +16 -10
  147. xp/services/server/xp230_server_service.py +10 -7
  148. xp/services/server/xp24_server_service.py +22 -13
  149. xp/services/server/xp33_server_service.py +44 -25
  150. xp/services/telegram/telegram_blink_service.py +14 -8
  151. xp/services/telegram/telegram_checksum_service.py +12 -7
  152. xp/services/telegram/telegram_datapoint_service.py +14 -9
  153. xp/services/telegram/telegram_discover_service.py +28 -15
  154. xp/services/telegram/telegram_link_number_service.py +18 -10
  155. xp/services/telegram/telegram_output_service.py +24 -12
  156. xp/services/telegram/telegram_service.py +22 -11
  157. xp/services/telegram/telegram_version_service.py +14 -8
  158. xp/services/term/protocol_monitor_service.py +30 -16
  159. xp/services/term/state_monitor_service.py +39 -21
  160. xp/term/protocol.py +12 -6
  161. xp/term/state.py +12 -7
  162. xp/term/widgets/help_menu.py +6 -3
  163. xp/term/widgets/modules_list.py +20 -10
  164. xp/term/widgets/protocol_log.py +12 -6
  165. xp/term/widgets/status_footer.py +10 -5
  166. xp/utils/checksum.py +6 -3
  167. xp/utils/dependencies.py +26 -31
  168. xp/utils/event_helper.py +6 -4
  169. xp/utils/logging.py +6 -3
  170. xp/utils/serialization.py +30 -16
  171. xp/utils/state_machine.py +16 -9
  172. xp/utils/time_utils.py +6 -3
  173. conson_xp-1.45.0.dist-info/RECORD +0 -210
  174. xp/services/conbus/msactiontable/msactiontable_download_service.py +0 -275
  175. xp/services/conbus/msactiontable/msactiontable_list_service.py +0 -100
  176. xp/services/conbus/msactiontable/msactiontable_show_service.py +0 -89
  177. {conson_xp-1.45.0.dist-info → conson_xp-1.47.0.dist-info}/WHEEL +0 -0
  178. {conson_xp-1.45.0.dist-info → conson_xp-1.47.0.dist-info}/entry_points.txt +0 -0
  179. {conson_xp-1.45.0.dist-info → conson_xp-1.47.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,7 +1,8 @@
1
- """Service for link number telegram operations.
1
+ """
2
+ Service for link number telegram operations.
2
3
 
3
- This service handles generation and parsing of link number system telegrams
4
- used for setting and reading module link numbers.
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
- """Generate a telegram to set a module's link number.
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
- """Generate a telegram to read a module's current link number.
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
- """Create a SystemTelegram object for setting link number.
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
- """Create a SystemTelegram object for reading link number.
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
- """Parse the link number value from a reply telegram.
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
- """Check if a reply telegram is an ACK response.
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
- """Check if a reply telegram is a NAK response.
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
- """Service for XP action operations.
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
- """Initialize the XP output service.
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
- """Validate XP24 output number according to architecture constraints.
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
- """Validate serial number format.
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
- """Generate XP24 action telegram string.
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
- """Generate XP output status query telegram.
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
- """Parse a raw XP output response telegram string.
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
- """Parse a raw XP output telegram string.
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
- """Parse XP24 status response telegram to extract output states.
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
- """Format status dictionary into human-readable summary.
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
- """Format XP24 action telegram for human-readable output.
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
- """Format module output state data value for display.
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
- """Telegram Service for parsing XP telegrams.
1
+ """
2
+ Telegram Service for parsing XP telegrams.
2
3
 
3
- This module provides telegram parsing functionality for event, system, and reply telegrams.
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
- """Service for parsing event telegrams from the console bus.
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
- """Parse a raw telegram string into an EventTelegram object.
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
- """Validate the checksum of a parsed telegram.
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
- """Format a telegram for human-readable output.
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
- """Parse a raw system telegram string into a SystemTelegram object.
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
- """Parse a raw reply telegram string into a ReplyTelegram object.
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
- """Auto-detect and parse any type of telegram.
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
- """Format a system telegram for human-readable output.
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
- """Format a reply telegram for human-readable output.
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
- """Version service for handling version information parsing and validation.
1
+ """
2
+ Version service for handling version information parsing and validation.
2
3
 
3
- This service provides business logic for version operations,
4
- following the layered architecture pattern.
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
- """Parse a version string into its components.
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
- """Generate a system telegram to request version information.
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
- """Validate if a system telegram is a valid version request.
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
- """Parse version information from a reply telegram.
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
- """Format version information for human-readable output.
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
- """Service for protocol monitoring in terminal interface.
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
- """Initialize the Protocol Monitor service.
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
- """Get current connection state.
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
- """Get server connection info (IP:port).
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
- """Toggle connection state between connected and disconnected.
138
+ """
139
+ Toggle connection state between connected and disconnected.
135
140
 
136
- Disconnects if currently connected or connecting.
137
- Connects if currently disconnected or failed.
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
- """Send a raw telegram.
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
- """Handle protocol key press.
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
- """Handle connection failed.
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
- """Handle telegram received.
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
- """Handle telegram sent.
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
- """Handle connection failed.
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
- """Get protocol key mappings.
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
- """Enter context manager.
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
- """Exit context manager and clean up resources.
271
+ """
272
+ Exit context manager and clean up resources.
259
273
 
260
274
  Args:
261
275
  _exc_type: Exception type if any.
@@ -20,7 +20,8 @@ from xp.services.telegram.telegram_service import TelegramService
20
20
 
21
21
 
22
22
  class StateMonitorService:
23
- """Service for module state monitoring in terminal interface.
23
+ """
24
+ Service for module state monitoring in terminal interface.
24
25
 
25
26
  Wraps ConbusEventProtocol and ConsonModuleListConfig to provide
26
27
  high-level module state tracking for the TUI.
@@ -48,7 +49,8 @@ class StateMonitorService:
48
49
  conson_config: ConsonModuleListConfig,
49
50
  telegram_service: TelegramService,
50
51
  ) -> None:
51
- """Initialize the State Monitor service.
52
+ """
53
+ Initialize the State Monitor service.
52
54
 
53
55
  Args:
54
56
  conbus_protocol: ConbusEventProtocol instance.
@@ -109,7 +111,8 @@ class StateMonitorService:
109
111
 
110
112
  @property
111
113
  def connection_state(self) -> ConnectionState:
112
- """Get current connection state.
114
+ """
115
+ Get current connection state.
113
116
 
114
117
  Returns:
115
118
  Current connection state.
@@ -118,7 +121,8 @@ class StateMonitorService:
118
121
 
119
122
  @property
120
123
  def server_info(self) -> str:
121
- """Get server connection info (IP:port).
124
+ """
125
+ Get server connection info (IP:port).
122
126
 
123
127
  Returns:
124
128
  Server address in format "IP:port".
@@ -127,7 +131,8 @@ class StateMonitorService:
127
131
 
128
132
  @property
129
133
  def module_states(self) -> List[ModuleState]:
130
- """Get all module states.
134
+ """
135
+ Get all module states.
131
136
 
132
137
  Returns:
133
138
  List of all module states.
@@ -172,10 +177,11 @@ class StateMonitorService:
172
177
  self.on_status_message.emit("Disconnected")
173
178
 
174
179
  def toggle_connection(self) -> None:
175
- """Toggle connection state between connected and disconnected.
180
+ """
181
+ Toggle connection state between connected and disconnected.
176
182
 
177
- Disconnects if currently connected or connecting.
178
- Connects if currently disconnected or failed.
183
+ Disconnects if currently connected or connecting. Connects if currently
184
+ disconnected or failed.
179
185
  """
180
186
  if self._connection_state in (
181
187
  ConnectionState.CONNECTED,
@@ -186,10 +192,12 @@ class StateMonitorService:
186
192
  self.connect()
187
193
 
188
194
  def refresh_all(self) -> None:
189
- """Refresh all module states.
195
+ """
196
+ Refresh all module states.
190
197
 
191
- Queries module_output_state datapoint for eligible modules (XP24, XP33LR, XP33LED).
192
- Updates outputs column and last_update timestamp for each queried module.
198
+ Queries module_output_state datapoint for eligible modules (XP24, XP33LR,
199
+ XP33LED). Updates outputs column and last_update timestamp for each queried
200
+ module.
193
201
  """
194
202
  self.on_status_message.emit("Refreshing module states...")
195
203
 
@@ -205,7 +213,8 @@ class StateMonitorService:
205
213
  )
206
214
 
207
215
  def _query_module_output_state(self, serial_number: str) -> None:
208
- """Query module output state datapoint.
216
+ """
217
+ Query module output state datapoint.
209
218
 
210
219
  Args:
211
220
  serial_number: Module serial number to query.
@@ -228,7 +237,8 @@ class StateMonitorService:
228
237
  self.on_module_list_updated.emit(self.module_states)
229
238
 
230
239
  def _on_connection_failed(self, failure: Exception) -> None:
231
- """Handle connection failed event.
240
+ """
241
+ Handle connection failed event.
232
242
 
233
243
  Args:
234
244
  failure: Exception that caused the failure.
@@ -239,7 +249,8 @@ class StateMonitorService:
239
249
  self.on_status_message.emit(f"Connection failed: {failure}")
240
250
 
241
251
  def _on_telegram_received(self, event: TelegramReceivedEvent) -> None:
242
- """Handle telegram received event.
252
+ """
253
+ Handle telegram received event.
243
254
 
244
255
  Routes telegrams to appropriate handlers based on type.
245
256
  Processes reply telegrams for datapoint queries and event telegrams for state changes.
@@ -254,7 +265,8 @@ class StateMonitorService:
254
265
  self._handle_event_telegram(event)
255
266
 
256
267
  def _handle_reply_telegram(self, event: TelegramReceivedEvent) -> None:
257
- """Handle reply telegram for datapoint queries.
268
+ """
269
+ Handle reply telegram for datapoint queries.
258
270
 
259
271
  Args:
260
272
  event: Telegram received event.
@@ -290,7 +302,8 @@ class StateMonitorService:
290
302
  self.on_status_message.emit("Connection timeout")
291
303
 
292
304
  def _on_failed(self, failure: Exception) -> None:
293
- """Handle protocol failure event.
305
+ """
306
+ Handle protocol failure event.
294
307
 
295
308
  Args:
296
309
  failure: Exception that caused the failure.
@@ -301,7 +314,8 @@ class StateMonitorService:
301
314
  self.on_status_message.emit(f"Protocol error: {failure}")
302
315
 
303
316
  def _find_module_by_link(self, link_number: int) -> Optional[ModuleState]:
304
- """Find module state by link number.
317
+ """
318
+ Find module state by link number.
305
319
 
306
320
  Args:
307
321
  link_number: Link number to search for.
@@ -317,7 +331,8 @@ class StateMonitorService:
317
331
  def _update_output_bit(
318
332
  self, module_state: ModuleState, output_number: int, output_state: bool
319
333
  ) -> None:
320
- """Update a single output bit in module state.
334
+ """
335
+ Update a single output bit in module state.
321
336
 
322
337
  Args:
323
338
  module_state: Module state to update.
@@ -338,7 +353,8 @@ class StateMonitorService:
338
353
  module_state.outputs = " ".join(outputs)
339
354
 
340
355
  def _handle_event_telegram(self, event: TelegramReceivedEvent) -> None:
341
- """Handle event telegram for output state changes.
356
+ """
357
+ Handle event telegram for output state changes.
342
358
 
343
359
  Processes XP24 and XP33 output event telegrams to update module state in real-time.
344
360
  - XP24 output events use input_number 80-83 to represent outputs 0-3.
@@ -415,7 +431,8 @@ class StateMonitorService:
415
431
  self.logger.debug("StateMonitorService cleaned up")
416
432
 
417
433
  def __enter__(self) -> "StateMonitorService":
418
- """Context manager entry.
434
+ """
435
+ Context manager entry.
419
436
 
420
437
  Returns:
421
438
  Self for context manager.
@@ -423,7 +440,8 @@ class StateMonitorService:
423
440
  return self
424
441
 
425
442
  def __exit__(self, _exc_type: object, _exc_val: object, _exc_tb: object) -> None:
426
- """Context manager exit.
443
+ """
444
+ Context manager exit.
427
445
 
428
446
  Args:
429
447
  _exc_type: Exception type.