From 4db1f1dfc9806a019710c0ebcd67e610fa32c67a Mon Sep 17 00:00:00 2001 From: LKuemmel Date: Tue, 8 Aug 2023 16:53:25 +0200 Subject: [PATCH 1/3] fix timeout soc --- packages/modules/update_soc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/modules/update_soc.py b/packages/modules/update_soc.py index 0f3e4480d3..1798011e9d 100644 --- a/packages/modules/update_soc.py +++ b/packages/modules/update_soc.py @@ -28,7 +28,7 @@ def update(self) -> None: threads_update, threads_store = self._get_threads() with ModuleUpdateCompletedContext(self.event_vehicle_update_completed, topic): threads_update, threads_store = self._get_threads() - thread_handler(threads_update, data.data.general_data.data.control_interval/3) + thread_handler(threads_update, 300) with ModuleUpdateCompletedContext(self.event_vehicle_update_completed, topic): # threads_store = self._filter_failed_store_threads(threads_store) thread_handler(threads_store, data.data.general_data.data.control_interval/3) From 5dd2704cc281c9d896cf79535800a269e70d9515 Mon Sep 17 00:00:00 2001 From: LKuemmel Date: Wed, 9 Aug 2023 08:23:38 +0200 Subject: [PATCH 2/3] scheduler interval --- packages/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/main.py b/packages/main.py index 9c3d6f6904..5845d041c9 100755 --- a/packages/main.py +++ b/packages/main.py @@ -140,7 +140,7 @@ def handler_random_nightly(self): def schedule_jobs(): [schedule.every().minute.at(f":{i:02d}").do(handler.handler10Sec).tag("algorithm") for i in range(0, 60, 10)] - [schedule.every().minute.at(f":{i:02d}").do(soc.update).tag("algorithm") for i in range(0, 60, 10)] + [schedule.every().minute.at(f":{i:02d}").do(soc.update).tag("algorithm") for i in range(0, 60, 5)] [schedule.every().minute.at(f":{i:02d}").do(smarthome_handler).tag("algorithm") for i in range(0, 60, 5)] [schedule.every().hour.at(f":{i:02d}").do(handler.handler5Min) for i in range(0, 60, 5)] [schedule.every().hour.at(f":{i:02d}").do(handler.handler5MinAlgorithm).tag("algorithm") for i in range(0, 60, 5)] From 30ee58b1d8fa940df2cb83a833aff62ea0bf5a09 Mon Sep 17 00:00:00 2001 From: LKuemmel Date: Wed, 30 Aug 2023 11:26:26 +0200 Subject: [PATCH 3/3] run update soc as thread --- packages/main.py | 3 ++- packages/modules/update_soc.py | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/main.py b/packages/main.py index 5845d041c9..43905f7b5e 100755 --- a/packages/main.py +++ b/packages/main.py @@ -140,7 +140,6 @@ def handler_random_nightly(self): def schedule_jobs(): [schedule.every().minute.at(f":{i:02d}").do(handler.handler10Sec).tag("algorithm") for i in range(0, 60, 10)] - [schedule.every().minute.at(f":{i:02d}").do(soc.update).tag("algorithm") for i in range(0, 60, 5)] [schedule.every().minute.at(f":{i:02d}").do(smarthome_handler).tag("algorithm") for i in range(0, 60, 5)] [schedule.every().hour.at(f":{i:02d}").do(handler.handler5Min) for i in range(0, 60, 5)] [schedule.every().hour.at(f":{i:02d}").do(handler.handler5MinAlgorithm).tag("algorithm") for i in range(0, 60, 5)] @@ -208,6 +207,7 @@ def schedule_jobs(): t_sub = Thread(target=sub.sub_topics, args=(), name="Subdata") t_set = Thread(target=set.set_data, args=(), name="Setdata") t_comm = Thread(target=comm.sub_commands, args=(), name="Commands") + t_soc = Thread(target=soc.update, args=(), name="SoC") t_internal_chargepoint = Thread(target=general_internal_chargepoint_handler.handler, args=(), name="Internal Chargepoint") if hasattr(rfid0, "input_device"): @@ -220,6 +220,7 @@ def schedule_jobs(): t_sub.start() t_set.start() t_comm.start() + t_soc.start() t_internal_chargepoint.start() # Warten, damit subdata Zeit hat, alle Topics auf dem Broker zu empfangen. event_update_config_completed.wait(300) diff --git a/packages/modules/update_soc.py b/packages/modules/update_soc.py index 1798011e9d..b4b61ab53b 100644 --- a/packages/modules/update_soc.py +++ b/packages/modules/update_soc.py @@ -1,4 +1,5 @@ import logging +import time from typing import List, Tuple import copy from threading import Event, Thread @@ -23,17 +24,19 @@ def __init__(self) -> None: self.event_vehicle_update_completed.set() def update(self) -> None: - topic = "openWB/set/vehicle/set/vehicle_update_completed" - try: - threads_update, threads_store = self._get_threads() - with ModuleUpdateCompletedContext(self.event_vehicle_update_completed, topic): + while True: + topic = "openWB/set/vehicle/set/vehicle_update_completed" + try: threads_update, threads_store = self._get_threads() - thread_handler(threads_update, 300) - with ModuleUpdateCompletedContext(self.event_vehicle_update_completed, topic): - # threads_store = self._filter_failed_store_threads(threads_store) - thread_handler(threads_store, data.data.general_data.data.control_interval/3) - except Exception: - log.exception("Fehler im update_soc-Modul") + with ModuleUpdateCompletedContext(self.event_vehicle_update_completed, topic): + threads_update, threads_store = self._get_threads() + thread_handler(threads_update, 300) + with ModuleUpdateCompletedContext(self.event_vehicle_update_completed, topic): + # threads_store = self._filter_failed_store_threads(threads_store) + thread_handler(threads_store, data.data.general_data.data.control_interval/3) + except Exception: + log.exception("Fehler im update_soc-Modul") + time.sleep(5) def _get_threads(self) -> Tuple[List[Thread], List[Thread]]: threads_update, threads_store = [], []