conson-xp 0.11.19__py3-none-any.whl → 1.0.1__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-0.11.19.dist-info → conson_xp-1.0.1.dist-info}/METADATA +1 -1
- {conson_xp-0.11.19.dist-info → conson_xp-1.0.1.dist-info}/RECORD +23 -23
- xp/__init__.py +1 -1
- xp/cli/commands/__init__.py +0 -1
- xp/cli/commands/conbus/conbus_config_commands.py +3 -12
- xp/cli/commands/conbus/conbus_lightlevel_commands.py +35 -16
- xp/cli/commands/conbus/conbus_linknumber_commands.py +24 -11
- xp/cli/commands/conbus/conbus_output_commands.py +44 -18
- xp/models/conbus/conbus.py +12 -11
- xp/models/conbus/conbus_linknumber.py +1 -1
- xp/services/conbus/conbus_autoreport_get_service.py +29 -73
- xp/services/conbus/conbus_datapoint_service.py +6 -1
- xp/services/conbus/conbus_lightlevel_get_service.py +101 -0
- xp/services/conbus/conbus_lightlevel_set_service.py +205 -0
- xp/services/conbus/conbus_linknumber_get_service.py +86 -0
- xp/services/conbus/conbus_linknumber_set_service.py +155 -0
- xp/services/conbus/conbus_output_service.py +129 -92
- xp/services/conbus/conbus_scan_service.py +94 -98
- xp/services/protocol/conbus_protocol.py +1 -0
- xp/utils/dependencies.py +26 -50
- xp/services/conbus/conbus_connection_pool.py +0 -148
- xp/services/conbus/conbus_lightlevel_service.py +0 -205
- xp/services/conbus/conbus_linknumber_service.py +0 -197
- xp/services/conbus/conbus_service.py +0 -306
- {conson_xp-0.11.19.dist-info → conson_xp-1.0.1.dist-info}/WHEEL +0 -0
- {conson_xp-0.11.19.dist-info → conson_xp-1.0.1.dist-info}/entry_points.txt +0 -0
- {conson_xp-0.11.19.dist-info → conson_xp-1.0.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,137 +1,174 @@
|
|
|
1
|
-
"""Conbus
|
|
1
|
+
"""Conbus Output Service for sending action telegrams to Conbus modules.
|
|
2
2
|
|
|
3
|
-
This service
|
|
4
|
-
|
|
3
|
+
This service handles sending action telegrams (ON/OFF) to module outputs
|
|
4
|
+
and processing ACK/NAK responses.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import logging
|
|
8
8
|
from datetime import datetime
|
|
9
|
-
from typing import
|
|
9
|
+
from typing import Callable, Optional
|
|
10
10
|
|
|
11
|
-
from
|
|
11
|
+
from twisted.internet.posixbase import PosixReactorBase
|
|
12
|
+
|
|
13
|
+
from xp.models import ConbusClientConfig
|
|
12
14
|
from xp.models.conbus.conbus_output import ConbusOutputResponse
|
|
15
|
+
from xp.models.protocol.conbus_protocol import TelegramReceivedEvent
|
|
13
16
|
from xp.models.telegram.action_type import ActionType
|
|
14
|
-
from xp.models.telegram.
|
|
17
|
+
from xp.models.telegram.output_telegram import OutputTelegram
|
|
15
18
|
from xp.models.telegram.system_function import SystemFunction
|
|
16
|
-
from xp.
|
|
17
|
-
from xp.services.
|
|
18
|
-
from xp.services.telegram.telegram_output_service import
|
|
19
|
-
|
|
19
|
+
from xp.models.telegram.telegram_type import TelegramType
|
|
20
|
+
from xp.services.protocol import ConbusProtocol
|
|
21
|
+
from xp.services.telegram.telegram_output_service import (
|
|
22
|
+
TelegramOutputService,
|
|
23
|
+
XPOutputError,
|
|
24
|
+
)
|
|
20
25
|
|
|
21
26
|
|
|
22
27
|
class ConbusOutputError(Exception):
|
|
23
|
-
"""Raised when Conbus
|
|
28
|
+
"""Raised when Conbus output operations fail"""
|
|
24
29
|
|
|
25
30
|
pass
|
|
26
31
|
|
|
27
32
|
|
|
28
|
-
class ConbusOutputService:
|
|
33
|
+
class ConbusOutputService(ConbusProtocol):
|
|
29
34
|
"""
|
|
30
|
-
|
|
35
|
+
Service for sending action telegrams to Conbus module outputs.
|
|
31
36
|
|
|
32
|
-
Manages
|
|
33
|
-
|
|
37
|
+
Manages action telegram transmission (ON/OFF) and processes
|
|
38
|
+
ACK/NAK responses from modules.
|
|
34
39
|
"""
|
|
35
40
|
|
|
36
41
|
def __init__(
|
|
37
42
|
self,
|
|
38
|
-
telegram_service: TelegramService,
|
|
39
43
|
telegram_output_service: TelegramOutputService,
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
cli_config: ConbusClientConfig,
|
|
45
|
+
reactor: PosixReactorBase,
|
|
42
46
|
):
|
|
43
|
-
"""Initialize the Conbus
|
|
47
|
+
"""Initialize the Conbus output service
|
|
44
48
|
|
|
45
49
|
Args:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
conbus_service: ConbusService for dependency injection
|
|
50
|
+
telegram_output_service: TelegramOutputService for telegram generation/parsing
|
|
51
|
+
cli_config: Conbus client configuration
|
|
52
|
+
reactor: Twisted reactor for async operations
|
|
50
53
|
"""
|
|
51
|
-
|
|
52
|
-
# Service dependencies
|
|
53
|
-
self.telegram_service = telegram_service
|
|
54
|
+
super().__init__(cli_config, reactor)
|
|
54
55
|
self.telegram_output_service = telegram_output_service
|
|
55
|
-
self.
|
|
56
|
-
self.
|
|
56
|
+
self.serial_number: str = ""
|
|
57
|
+
self.output_number: int = 0
|
|
58
|
+
self.action_type: ActionType = ActionType.ON_RELEASE
|
|
59
|
+
self.finish_callback: Optional[Callable[[ConbusOutputResponse], None]] = None
|
|
60
|
+
self.service_response: ConbusOutputResponse = ConbusOutputResponse(
|
|
61
|
+
success=False,
|
|
62
|
+
serial_number=self.serial_number,
|
|
63
|
+
output_number=self.output_number,
|
|
64
|
+
action_type=self.action_type,
|
|
65
|
+
timestamp=datetime.now(),
|
|
66
|
+
)
|
|
57
67
|
|
|
58
68
|
# Set up logging
|
|
59
69
|
self.logger = logging.getLogger(__name__)
|
|
60
70
|
|
|
61
|
-
def
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def __exit__(
|
|
65
|
-
self,
|
|
66
|
-
_exc_type: Optional[type],
|
|
67
|
-
_exc_val: Optional[Exception],
|
|
68
|
-
_exc_tb: Optional[Any],
|
|
69
|
-
) -> None:
|
|
70
|
-
# Cleanup logic if needed
|
|
71
|
-
pass
|
|
72
|
-
|
|
73
|
-
def get_output_state(self, serial_number: str) -> ConbusDatapointResponse:
|
|
74
|
-
# TODO: Migrate to new ConbusDatapointService callback-based API
|
|
75
|
-
# Send status query using custom telegram method
|
|
76
|
-
response = self.datapoint_service.query_datapoint( # type: ignore[call-arg,func-returns-value]
|
|
77
|
-
serial_number=serial_number,
|
|
78
|
-
datapoint_type=DataPointType.MODULE_OUTPUT_STATE, # "12"
|
|
71
|
+
def connection_established(self) -> None:
|
|
72
|
+
self.logger.debug(
|
|
73
|
+
f"Connection established, sending action {self.action_type} to output {self.output_number}..."
|
|
79
74
|
)
|
|
80
75
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
# Validate parameters before sending
|
|
77
|
+
try:
|
|
78
|
+
self.telegram_output_service.validate_output_number(self.output_number)
|
|
79
|
+
self.telegram_output_service.validate_serial_number(self.serial_number)
|
|
80
|
+
except XPOutputError as e:
|
|
81
|
+
self.failed(str(e))
|
|
82
|
+
return
|
|
83
|
+
|
|
84
|
+
# Send F27D{output:02d}{action} telegram
|
|
85
|
+
# F27 = ACTION, D = data with output number and action type
|
|
86
|
+
self.send_telegram(
|
|
87
|
+
telegram_type=TelegramType.SYSTEM,
|
|
88
|
+
serial_number=self.serial_number,
|
|
89
|
+
system_function=SystemFunction.ACTION,
|
|
90
|
+
data_value=f"{self.output_number:02d}{self.action_type.value}",
|
|
88
91
|
)
|
|
89
92
|
|
|
90
|
-
|
|
93
|
+
def telegram_sent(self, telegram_sent: str) -> None:
|
|
94
|
+
self.service_response.sent_telegram = telegram_sent
|
|
91
95
|
|
|
92
|
-
def
|
|
93
|
-
self
|
|
94
|
-
) -> ConbusOutputResponse:
|
|
96
|
+
def telegram_received(self, telegram_received: TelegramReceivedEvent) -> None:
|
|
97
|
+
self.logger.debug(f"Telegram received: {telegram_received}")
|
|
95
98
|
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
if not self.service_response.received_telegrams:
|
|
100
|
+
self.service_response.received_telegrams = []
|
|
101
|
+
self.service_response.received_telegrams.append(telegram_received.frame)
|
|
98
102
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
if (
|
|
104
|
+
not telegram_received.checksum_valid
|
|
105
|
+
or telegram_received.telegram_type != TelegramType.REPLY
|
|
106
|
+
or telegram_received.serial_number != self.serial_number
|
|
107
|
+
):
|
|
108
|
+
self.logger.debug("Not a reply for our serial number")
|
|
109
|
+
return
|
|
102
110
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
SystemFunction.ACTION, # "27"
|
|
107
|
-
input_action, # "00AA", "01AA", etc.
|
|
111
|
+
# Parse the reply telegram to get ACK/NAK
|
|
112
|
+
output_telegram = self.telegram_output_service.parse_reply_telegram(
|
|
113
|
+
telegram_received.frame
|
|
108
114
|
)
|
|
109
115
|
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
or len(response.received_telegrams) <= 0
|
|
116
|
+
if output_telegram and output_telegram.system_function in (
|
|
117
|
+
SystemFunction.ACK,
|
|
118
|
+
SystemFunction.NAK,
|
|
114
119
|
):
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
action_type=action_type,
|
|
121
|
-
error=response.error,
|
|
122
|
-
timestamp=response.timestamp or datetime.now(),
|
|
123
|
-
received_telegrams=response.received_telegrams,
|
|
120
|
+
self.logger.debug(f"Received {output_telegram.system_function} response")
|
|
121
|
+
self.succeed(output_telegram)
|
|
122
|
+
else:
|
|
123
|
+
self.logger.debug(
|
|
124
|
+
f"Unexpected system function: {output_telegram.system_function}"
|
|
124
125
|
)
|
|
125
126
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
127
|
+
def succeed(self, output_telegram: OutputTelegram) -> None:
|
|
128
|
+
self.logger.debug("Successfully sent action to output")
|
|
129
|
+
self.service_response.success = True
|
|
130
|
+
self.service_response.timestamp = datetime.now()
|
|
131
|
+
self.service_response.serial_number = self.serial_number
|
|
132
|
+
self.service_response.output_number = self.output_number
|
|
133
|
+
self.service_response.action_type = self.action_type
|
|
134
|
+
self.service_response.output_telegram = output_telegram
|
|
135
|
+
if self.finish_callback:
|
|
136
|
+
self.finish_callback(self.service_response)
|
|
137
|
+
|
|
138
|
+
def failed(self, message: str) -> None:
|
|
139
|
+
self.logger.debug(f"Failed with message: {message}")
|
|
140
|
+
self.service_response.success = False
|
|
141
|
+
self.service_response.timestamp = datetime.now()
|
|
142
|
+
self.service_response.serial_number = self.serial_number
|
|
143
|
+
self.service_response.output_number = self.output_number
|
|
144
|
+
self.service_response.action_type = self.action_type
|
|
145
|
+
self.service_response.error = message
|
|
146
|
+
if self.finish_callback:
|
|
147
|
+
self.finish_callback(self.service_response)
|
|
148
|
+
|
|
149
|
+
def send_action(
|
|
150
|
+
self,
|
|
151
|
+
serial_number: str,
|
|
152
|
+
output_number: int,
|
|
153
|
+
action_type: ActionType,
|
|
154
|
+
finish_callback: Callable[[ConbusOutputResponse], None],
|
|
155
|
+
timeout_seconds: Optional[float] = None,
|
|
156
|
+
) -> None:
|
|
157
|
+
"""
|
|
158
|
+
Send an action telegram to a module output.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
serial_number: 10-digit module serial number
|
|
162
|
+
output_number: Output number (0-99)
|
|
163
|
+
action_type: Action to perform (ON_RELEASE, OFF_PRESS, etc.)
|
|
164
|
+
finish_callback: Callback function to call when operation completes
|
|
165
|
+
timeout_seconds: Optional timeout in seconds
|
|
166
|
+
"""
|
|
167
|
+
self.logger.info("Starting send_action")
|
|
168
|
+
if timeout_seconds:
|
|
169
|
+
self.timeout_seconds = timeout_seconds
|
|
170
|
+
self.serial_number = serial_number
|
|
171
|
+
self.output_number = output_number
|
|
172
|
+
self.action_type = action_type
|
|
173
|
+
self.finish_callback = finish_callback
|
|
174
|
+
self.start_reactor()
|
|
@@ -5,124 +5,120 @@ various types of telegrams including discover, version, and sensor data requests
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import logging
|
|
8
|
-
import
|
|
9
|
-
from typing import
|
|
8
|
+
from datetime import datetime
|
|
9
|
+
from typing import Callable, Optional
|
|
10
|
+
|
|
11
|
+
from twisted.internet.posixbase import PosixReactorBase
|
|
10
12
|
|
|
11
13
|
from xp.models import (
|
|
12
|
-
|
|
14
|
+
ConbusClientConfig,
|
|
13
15
|
ConbusResponse,
|
|
14
16
|
)
|
|
15
|
-
from xp.
|
|
16
|
-
from xp.services.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class ConbusScanError(Exception):
|
|
20
|
-
"""Raised when Conbus client send operations fail"""
|
|
17
|
+
from xp.models.protocol.conbus_protocol import TelegramReceivedEvent
|
|
18
|
+
from xp.services.protocol import ConbusProtocol
|
|
21
19
|
|
|
22
|
-
pass
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
class ConbusScanService:
|
|
21
|
+
class ConbusScanService(ConbusProtocol):
|
|
26
22
|
"""
|
|
27
|
-
|
|
23
|
+
Service for querying datapoints from Conbus modules.
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
and
|
|
25
|
+
Uses ConbusProtocol to provide datapoint query functionality
|
|
26
|
+
for reading sensor data and module information.
|
|
31
27
|
"""
|
|
32
28
|
|
|
33
29
|
def __init__(
|
|
34
30
|
self,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
):
|
|
38
|
-
"""Initialize the Conbus
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
cli_config: ConbusClientConfig,
|
|
32
|
+
reactor: PosixReactorBase,
|
|
33
|
+
) -> None:
|
|
34
|
+
"""Initialize the Conbus datapoint service"""
|
|
35
|
+
super().__init__(cli_config, reactor)
|
|
36
|
+
self.serial_number: str = ""
|
|
37
|
+
self.function_code: str = ""
|
|
38
|
+
self.datapoint_value: int = -1
|
|
39
|
+
self.progress_callback: Optional[Callable[[str], None]] = None
|
|
40
|
+
self.finish_callback: Optional[Callable[[ConbusResponse], None]] = None
|
|
41
|
+
self.service_response: ConbusResponse = ConbusResponse(
|
|
42
|
+
success=False,
|
|
43
|
+
serial_number=self.serial_number,
|
|
44
|
+
sent_telegrams=[],
|
|
45
|
+
received_telegrams=[],
|
|
46
|
+
timestamp=datetime.now(),
|
|
47
|
+
)
|
|
49
48
|
# Set up logging
|
|
50
49
|
self.logger = logging.getLogger(__name__)
|
|
51
50
|
|
|
52
|
-
def
|
|
53
|
-
self,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
# Call progress callback with error response
|
|
95
|
-
if progress_callback:
|
|
96
|
-
progress_callback(error_response, count, total_combinations)
|
|
97
|
-
|
|
98
|
-
return results
|
|
51
|
+
def connection_established(self) -> None:
|
|
52
|
+
self.logger.debug("Connection established, starting scan")
|
|
53
|
+
self.scan_next_datacode()
|
|
54
|
+
|
|
55
|
+
def scan_next_datacode(self) -> bool:
|
|
56
|
+
self.datapoint_value += 1
|
|
57
|
+
if self.datapoint_value >= 100:
|
|
58
|
+
if self.finish_callback:
|
|
59
|
+
self.finish_callback(self.service_response)
|
|
60
|
+
return False
|
|
61
|
+
|
|
62
|
+
self.logger.debug(f"Scanning next datacode: {self.datapoint_value:02d}")
|
|
63
|
+
data = f"{self.datapoint_value:02d}"
|
|
64
|
+
telegram_body = f"S{self.serial_number}F{self.function_code}D{data}"
|
|
65
|
+
self.sendFrame(telegram_body.encode())
|
|
66
|
+
return True
|
|
67
|
+
|
|
68
|
+
def telegram_sent(self, telegram_sent: str) -> None:
|
|
69
|
+
self.service_response.success = True
|
|
70
|
+
self.service_response.sent_telegrams.append(telegram_sent)
|
|
71
|
+
|
|
72
|
+
def telegram_received(self, telegram_received: TelegramReceivedEvent) -> None:
|
|
73
|
+
self.logger.debug(f"Telegram received: {telegram_received}")
|
|
74
|
+
if not self.service_response.received_telegrams:
|
|
75
|
+
self.service_response.received_telegrams = []
|
|
76
|
+
self.service_response.received_telegrams.append(telegram_received.frame)
|
|
77
|
+
|
|
78
|
+
if self.progress_callback:
|
|
79
|
+
self.progress_callback(telegram_received.frame)
|
|
80
|
+
|
|
81
|
+
def timeout(self) -> bool:
|
|
82
|
+
self.logger.debug(f"Timeout: {self.timeout_seconds}s")
|
|
83
|
+
continue_scan = self.scan_next_datacode()
|
|
84
|
+
return continue_scan
|
|
85
|
+
|
|
86
|
+
def failed(self, message: str) -> None:
|
|
87
|
+
self.logger.debug(f"Failed with message: {message}")
|
|
88
|
+
self.service_response.success = False
|
|
89
|
+
self.service_response.timestamp = datetime.now()
|
|
90
|
+
self.service_response.error = message
|
|
91
|
+
if self.finish_callback:
|
|
92
|
+
self.finish_callback(self.service_response)
|
|
99
93
|
|
|
100
94
|
def scan_module_background(
|
|
101
95
|
self,
|
|
102
96
|
serial_number: str,
|
|
103
97
|
function_code: str,
|
|
104
|
-
progress_callback:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return self.scan_module(serial_number, function_code, progress_callback)
|
|
111
|
-
|
|
112
|
-
# Start background thread
|
|
113
|
-
scan_thread = threading.Thread(target=background_scan, daemon=True)
|
|
114
|
-
scan_thread.start()
|
|
98
|
+
progress_callback: Callable[[str], None],
|
|
99
|
+
finish_callback: Callable[[ConbusResponse], None],
|
|
100
|
+
timeout_seconds: Optional[float] = None,
|
|
101
|
+
) -> None:
|
|
102
|
+
"""
|
|
103
|
+
Query a specific datapoint from a module.
|
|
115
104
|
|
|
116
|
-
|
|
105
|
+
Args:
|
|
106
|
+
serial_number: 10-digit module serial number
|
|
107
|
+
function_code: the function code to scan
|
|
108
|
+
progress_callback: callback to handle progress
|
|
109
|
+
finish_callback: callback function to call when the datapoint is received
|
|
110
|
+
timeout_seconds: timeout in seconds
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
ConbusDatapointResponse with operation result and datapoint value
|
|
114
|
+
"""
|
|
117
115
|
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
self.logger.info("Starting query_datapoint")
|
|
117
|
+
if timeout_seconds:
|
|
118
|
+
self.timeout_seconds = timeout_seconds
|
|
120
119
|
|
|
121
|
-
|
|
122
|
-
self
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
) -> None:
|
|
127
|
-
# Cleanup logic if needed
|
|
128
|
-
pass
|
|
120
|
+
self.serial_number = serial_number
|
|
121
|
+
self.function_code = function_code
|
|
122
|
+
self.progress_callback = progress_callback
|
|
123
|
+
self.finish_callback = finish_callback
|
|
124
|
+
self.start_reactor()
|
|
@@ -145,6 +145,7 @@ class ConbusProtocol(protocol.Protocol, protocol.ClientFactory):
|
|
|
145
145
|
self._stop_reactor()
|
|
146
146
|
|
|
147
147
|
def timeout(self) -> bool:
|
|
148
|
+
"""Timeout callback, return True to continue waiting for next timeout, False to stop"""
|
|
148
149
|
self.logger.info("Timeout after: %ss", self.timeout_seconds)
|
|
149
150
|
self.failed(f"Timeout after: {self.timeout_seconds}s")
|
|
150
151
|
return False
|
xp/utils/dependencies.py
CHANGED
|
@@ -25,10 +25,6 @@ from xp.services.conbus.conbus_autoreport_get_service import ConbusAutoreportGet
|
|
|
25
25
|
from xp.services.conbus.conbus_autoreport_set_service import ConbusAutoreportSetService
|
|
26
26
|
from xp.services.conbus.conbus_blink_all_service import ConbusBlinkAllService
|
|
27
27
|
from xp.services.conbus.conbus_blink_service import ConbusBlinkService
|
|
28
|
-
from xp.services.conbus.conbus_connection_pool import (
|
|
29
|
-
ConbusConnectionPool,
|
|
30
|
-
ConbusSocketConnectionManager,
|
|
31
|
-
)
|
|
32
28
|
from xp.services.conbus.conbus_custom_service import ConbusCustomService
|
|
33
29
|
from xp.services.conbus.conbus_datapoint_queryall_service import (
|
|
34
30
|
ConbusDatapointQueryAllService,
|
|
@@ -37,13 +33,13 @@ from xp.services.conbus.conbus_datapoint_service import (
|
|
|
37
33
|
ConbusDatapointService,
|
|
38
34
|
)
|
|
39
35
|
from xp.services.conbus.conbus_discover_service import ConbusDiscoverService
|
|
40
|
-
from xp.services.conbus.
|
|
41
|
-
from xp.services.conbus.
|
|
36
|
+
from xp.services.conbus.conbus_lightlevel_set_service import ConbusLightlevelSetService
|
|
37
|
+
from xp.services.conbus.conbus_linknumber_get_service import ConbusLinknumberGetService
|
|
38
|
+
from xp.services.conbus.conbus_linknumber_set_service import ConbusLinknumberSetService
|
|
42
39
|
from xp.services.conbus.conbus_output_service import ConbusOutputService
|
|
43
40
|
from xp.services.conbus.conbus_raw_service import ConbusRawService
|
|
44
41
|
from xp.services.conbus.conbus_receive_service import ConbusReceiveService
|
|
45
42
|
from xp.services.conbus.conbus_scan_service import ConbusScanService
|
|
46
|
-
from xp.services.conbus.conbus_service import ConbusService
|
|
47
43
|
from xp.services.homekit.homekit_cache_service import HomeKitCacheService
|
|
48
44
|
from xp.services.homekit.homekit_conbus_service import HomeKitConbusService
|
|
49
45
|
from xp.services.homekit.homekit_dimminglight_service import HomeKitDimmingLightService
|
|
@@ -106,30 +102,13 @@ class ServiceContainer:
|
|
|
106
102
|
def _register_services(self) -> None:
|
|
107
103
|
"""Register all services in the container based on dependency graph."""
|
|
108
104
|
|
|
109
|
-
# ConbusClientConfig
|
|
105
|
+
# ConbusClientConfig
|
|
110
106
|
self.container.register(
|
|
111
107
|
ConbusClientConfig,
|
|
112
108
|
factory=lambda: ConbusClientConfig.from_yaml(self._config_path),
|
|
113
109
|
scope=punq.Scope.singleton,
|
|
114
110
|
)
|
|
115
111
|
|
|
116
|
-
# Core infrastructure layer - ConbusConnectionPool (singleton)
|
|
117
|
-
self.container.register(
|
|
118
|
-
ConbusSocketConnectionManager,
|
|
119
|
-
factory=lambda: ConbusSocketConnectionManager(
|
|
120
|
-
cli_config=self.container.resolve(ConbusClientConfig)
|
|
121
|
-
),
|
|
122
|
-
scope=punq.Scope.singleton,
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
self.container.register(
|
|
126
|
-
ConbusConnectionPool,
|
|
127
|
-
factory=lambda: ConbusConnectionPool(
|
|
128
|
-
connection_manager=self.container.resolve(ConbusSocketConnectionManager)
|
|
129
|
-
),
|
|
130
|
-
scope=punq.Scope.singleton,
|
|
131
|
-
)
|
|
132
|
-
|
|
133
112
|
# Telegram services layer
|
|
134
113
|
self.container.register(TelegramService, scope=punq.Scope.singleton)
|
|
135
114
|
self.container.register(
|
|
@@ -143,16 +122,6 @@ class ServiceContainer:
|
|
|
143
122
|
self.container.register(TelegramBlinkService, scope=punq.Scope.singleton)
|
|
144
123
|
self.container.register(LinkNumberService, scope=punq.Scope.singleton)
|
|
145
124
|
|
|
146
|
-
# ConbusService - depends on ConbusConnectionPool
|
|
147
|
-
self.container.register(
|
|
148
|
-
ConbusService,
|
|
149
|
-
factory=lambda: ConbusService(
|
|
150
|
-
client_config=self.container.resolve(ConbusClientConfig),
|
|
151
|
-
connection_pool=self.container.resolve(ConbusConnectionPool),
|
|
152
|
-
),
|
|
153
|
-
scope=punq.Scope.singleton,
|
|
154
|
-
)
|
|
155
|
-
|
|
156
125
|
# Conbus services layer
|
|
157
126
|
self.container.register(
|
|
158
127
|
ConbusDatapointService,
|
|
@@ -177,8 +146,8 @@ class ServiceContainer:
|
|
|
177
146
|
self.container.register(
|
|
178
147
|
ConbusScanService,
|
|
179
148
|
factory=lambda: ConbusScanService(
|
|
180
|
-
|
|
181
|
-
|
|
149
|
+
cli_config=self.container.resolve(ConbusClientConfig),
|
|
150
|
+
reactor=self.container.resolve(PosixReactorBase),
|
|
182
151
|
),
|
|
183
152
|
scope=punq.Scope.singleton,
|
|
184
153
|
)
|
|
@@ -215,20 +184,18 @@ class ServiceContainer:
|
|
|
215
184
|
self.container.register(
|
|
216
185
|
ConbusOutputService,
|
|
217
186
|
factory=lambda: ConbusOutputService(
|
|
218
|
-
telegram_service=self.container.resolve(TelegramService),
|
|
219
187
|
telegram_output_service=self.container.resolve(TelegramOutputService),
|
|
220
|
-
|
|
221
|
-
|
|
188
|
+
cli_config=self.container.resolve(ConbusClientConfig),
|
|
189
|
+
reactor=self.container.resolve(PosixReactorBase),
|
|
222
190
|
),
|
|
223
191
|
scope=punq.Scope.singleton,
|
|
224
192
|
)
|
|
225
193
|
|
|
226
194
|
self.container.register(
|
|
227
|
-
|
|
228
|
-
factory=lambda:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
datapoint_service=self.container.resolve(ConbusDatapointService),
|
|
195
|
+
ConbusLightlevelSetService,
|
|
196
|
+
factory=lambda: ConbusLightlevelSetService(
|
|
197
|
+
cli_config=self.container.resolve(ConbusClientConfig),
|
|
198
|
+
reactor=self.container.resolve(PosixReactorBase),
|
|
232
199
|
),
|
|
233
200
|
scope=punq.Scope.singleton,
|
|
234
201
|
)
|
|
@@ -301,12 +268,21 @@ class ServiceContainer:
|
|
|
301
268
|
)
|
|
302
269
|
|
|
303
270
|
self.container.register(
|
|
304
|
-
|
|
305
|
-
factory=lambda:
|
|
306
|
-
conbus_service=self.container.resolve(ConbusService),
|
|
307
|
-
datapoint_service=self.container.resolve(ConbusDatapointService),
|
|
308
|
-
link_number_service=self.container.resolve(LinkNumberService),
|
|
271
|
+
ConbusLinknumberGetService,
|
|
272
|
+
factory=lambda: ConbusLinknumberGetService(
|
|
309
273
|
telegram_service=self.container.resolve(TelegramService),
|
|
274
|
+
cli_config=self.container.resolve(ConbusClientConfig),
|
|
275
|
+
reactor=self.container.resolve(PosixReactorBase),
|
|
276
|
+
),
|
|
277
|
+
scope=punq.Scope.singleton,
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
self.container.register(
|
|
281
|
+
ConbusLinknumberSetService,
|
|
282
|
+
factory=lambda: ConbusLinknumberSetService(
|
|
283
|
+
telegram_service=self.container.resolve(TelegramService),
|
|
284
|
+
cli_config=self.container.resolve(ConbusClientConfig),
|
|
285
|
+
reactor=self.container.resolve(PosixReactorBase),
|
|
310
286
|
),
|
|
311
287
|
scope=punq.Scope.singleton,
|
|
312
288
|
)
|