рефакторинг кода обновления параметров, изменения в логике работы получения статуса насосной
This commit is contained in:
@@ -21,7 +21,7 @@ class MbClearHistoryService(Thread):
|
||||
|
||||
class MbService(Thread):
|
||||
def __init__(self, ip_addr, port, scan_rate, poll_time_ms=60000, save_days=60):
|
||||
super().__init__()
|
||||
super().__init__(daemon=True)
|
||||
self._poll_time_ms = poll_time_ms
|
||||
self._scan_rate = scan_rate
|
||||
|
||||
@@ -107,6 +107,8 @@ class MbTankService(MbService):
|
||||
# D1: radar_high_reg
|
||||
# D2: radar_low_reg
|
||||
values = self.mb.read_holding_registers(0, 6)
|
||||
if values is None:
|
||||
return
|
||||
self._curr_state = {
|
||||
"level": values[0],
|
||||
"status": values[5],
|
||||
@@ -148,10 +150,12 @@ class MbPumpService(MbService):
|
||||
# D26: vfd_current
|
||||
# D27: vfd_error
|
||||
off = 16
|
||||
values = self.mb.read_holding_registers(16, 35 - off)
|
||||
values = self.mb.read_holding_registers(16, 36 - off)
|
||||
if values is None:
|
||||
return
|
||||
with self._lock:
|
||||
# определение запущенного насоса
|
||||
pr = None
|
||||
pr = -1
|
||||
if values[33 - off] & (1 << 14):
|
||||
pr = 1
|
||||
elif values[33 - off] & (1 << 15):
|
||||
@@ -159,15 +163,15 @@ class MbPumpService(MbService):
|
||||
|
||||
self._curr_state = {
|
||||
'alarms': values[35 - off],
|
||||
'flow_meter': values[16 - off],
|
||||
'flow_meter': values[16 - off] / 100,
|
||||
'last_update': int(datetime.now().timestamp()),
|
||||
'pump_stage': values[28 - off],
|
||||
'vfd_curr': values[26 - off],
|
||||
'vfd_curr': values[26 - off] / 100,
|
||||
'vfd_err': values[27 - off],
|
||||
'vfd_freq': values[25 - off],
|
||||
'vfd_freq': values[25 - off] / 100,
|
||||
'pump_running': pr,
|
||||
'pump_moto_watch_1': values[31 - off],
|
||||
'pump_moto_watch_2': values[32 - off],
|
||||
'moto_watch_1': values[31 - off],
|
||||
'moto_watch_2': values[32 - off],
|
||||
'half_auto_control': values[30 - off]
|
||||
}
|
||||
|
||||
@@ -186,8 +190,8 @@ class MbPumpService(MbService):
|
||||
'vfd_err': None,
|
||||
'vfd_freq': None,
|
||||
'pump_running': None,
|
||||
'pump_moto_watch_1': None,
|
||||
'pump_moto_watch_2': None,
|
||||
'moto_watch_1': None,
|
||||
'moto_watch_2': None,
|
||||
'half_auto_control': None
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user