From 0c44fed2bd213882ac658e53ebaaeb3370b440b0 Mon Sep 17 00:00:00 2001 From: Benjamin Braatz Date: Mon, 31 Jan 2022 21:29:16 +0100 Subject: [PATCH] Correct the parameters on every stop. --- gmodbus/hitachi.py | 40 +++++++++++++++++----------------------- schaltschrank/config.py | 1 + 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/gmodbus/hitachi.py b/gmodbus/hitachi.py index 5b02f89..4c5a1e8 100644 --- a/gmodbus/hitachi.py +++ b/gmodbus/hitachi.py @@ -11,39 +11,33 @@ class SJP1Fu(): def __init__(self, client: ClientInterface) -> None: self.__protocol = DatatypesProtocol(client, SJP1FU_COILS, SJP1FU_REGISTERS) - async def set_parameters(self) -> None: - # AA115 = 01, 14-43 - await self.__protocol.write_register(12015, 1) - # AC120 = 0.5 s, 14-44 - await self.__protocol.write_register(12220, 1) - # bA122 = 02, 14-53 - await self.__protocol.write_register(13022, 2) - # bA123 = 50 A, 14-53 - await self.__protocol.write_register(13023, 50) - # bA124 = 5 s, 14-53 - await self.__protocol.write_register(13024, 5) - # Cb40 = 01, 14-58 - await self.__protocol.write_register(14140, 1) - # Hb102 = 11 kW, 14-64 - await self.__protocol.write_register(15102, 11) - # Hb103 = 4, 14-64 - await self.__protocol.write_register(15103, 4) - # bC110 = 22.5A Motorschutz ??? + parameters = [(12015, 1), (12220, 90), (13022, 2), (13023, 50), (13024, 5), + (13110, 2), (14140, 1), (15102, 11), (15103, 4)] + + async def check_parameters(self) -> None: + for (register, value) in self.parameters: + current = int(await self.__protocol.read_register(register)) + if current != value: + print(f"Register {register} is {current} instead of {value}.") + + async def correct_parameters(self) -> None: + for (register, value) in self.parameters: + current = int(await self.__protocol.read_register(register)) + if current != value: + print(f"Register {register} is {current} instead of {value}.") + await self.__protocol.write_register(9002, 1) + await self.__protocol.write_register(register, value) async def set_frequency(self, frequency: int) -> None: - # Page 532 / 14-41 await self.__protocol.write_register(10502, frequency) async def get_frequency(self) -> int: - # Page 532 / 14-41 return int(await self.__protocol.read_register(10502)) async def start_inverter(self) -> None: - # Page 518 / 14-27 await self.__protocol.write_coil(1, True) async def stop_inverter(self) -> None: - # Page 518 / 14-27 await self.__protocol.write_coil(1, False) @property @@ -161,7 +155,7 @@ SJP1FU_REGISTERS = { }, 15103: { 'code': 'Hb103', - 'name': 'Selection of number of firs IM motor poles', + 'name': 'Selection of number of first IM motor poles', 'rw': 'rw', 'type': 'uint16', 'conf': { diff --git a/schaltschrank/config.py b/schaltschrank/config.py index a4cd59b..59e281d 100644 --- a/schaltschrank/config.py +++ b/schaltschrank/config.py @@ -70,6 +70,7 @@ async def fu_handler(queues, fu): event = await in_queue.get() if event['name'] == 'motorstop': await fu.stop_inverter() + await fu.correct_parameters() for out_queue in queues: await out_queue.put({'name': 'motoraus'}) elif event['name'] == 'dauervor': -- 2.34.1