From 4a95473f3a8079bd2c80d0e1df0f237b559a96e6 Mon Sep 17 00:00:00 2001 From: LKuemmel Date: Tue, 18 Jun 2024 10:15:25 +0200 Subject: [PATCH] fixes --- packages/control/prepare.py | 2 ++ packages/helpermodules/changed_values_handler.py | 8 -------- packages/helpermodules/update_config.py | 1 + packages/main.py | 13 +++++-------- packages/modules/loadvars.py | 2 -- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/packages/control/prepare.py b/packages/control/prepare.py index 2bbc9ca383..ee32f486ee 100644 --- a/packages/control/prepare.py +++ b/packages/control/prepare.py @@ -18,6 +18,8 @@ def setup_algorithm(self) -> None: """ bereitet die Daten für den Algorithmus vor und startet diesen. """ try: + data.data.pv_all_data.calc_power_for_all_components() + data.data.bat_all_data.calc_power_for_all_components() for cp in data.data.cp_data.values(): cp.setup_values_at_start() data.data.bat_all_data.setup_bat() diff --git a/packages/helpermodules/changed_values_handler.py b/packages/helpermodules/changed_values_handler.py index 484f90e2a1..fe62b60b50 100644 --- a/packages/helpermodules/changed_values_handler.py +++ b/packages/helpermodules/changed_values_handler.py @@ -125,14 +125,6 @@ def _update_value(self, topic_prefix, data_inst_previous, data_inst): class ChangedValuesContext: - """ Wenn die Werte der Komponenten nicht miteinander verrechnet werden, sollen, auch wenn bei einer Komponente ein - Fehler auftritt, alle anderen dennoch ausgelesen werden. WR-Werte dienen nur statistischen Zwecken, ohne - EVU-Werte ist aber keine Regelung möglich. Ein nicht antwortender WR soll dann nicht die Regelung verhindern. - for component in self.components: - with SingleComponentUpdateContext(component): - component.update() - """ - def __init__(self, event_module_update_completed: threading.Event): self.changed_values_handler = ChangedValuesHandler(event_module_update_completed) diff --git a/packages/helpermodules/update_config.py b/packages/helpermodules/update_config.py index abcb4072f9..3c13a3d105 100644 --- a/packages/helpermodules/update_config.py +++ b/packages/helpermodules/update_config.py @@ -403,6 +403,7 @@ class UpdateConfig: "^openWB/system/version$", ] default_topic = ( + ("openWB/bat/config/configured", False), ("openWB/bat/get/fault_state", 0), ("openWB/bat/get/fault_str", NO_ERROR), ("openWB/chargepoint/get/power", 0), diff --git a/packages/main.py b/packages/main.py index 042c7c38c9..91c21a2505 100755 --- a/packages/main.py +++ b/packages/main.py @@ -11,7 +11,7 @@ from threading import Thread from control.chargelog.chargelog import calculate_charge_cost -from helpermodules.changed_values_handler import ChangedValuesHandler +from helpermodules.changed_values_handler import ChangedValuesContext from helpermodules.measurement_logging.update_yields import update_daily_yields, update_pv_monthly_yearly_yields from helpermodules.measurement_logging.write_log import LogType, save_log from modules import loadvars @@ -55,7 +55,7 @@ def handler_with_control_interval(): wait_for_module_update_completed(loadvars_.event_module_update_completed, "openWB/set/system/device/module_update_completed") data.data.copy_data() - with ChangedValuesHandler(loadvars_.event_module_update_completed): + with ChangedValuesContext(loadvars_.event_module_update_completed): self.heartbeat = True if data.data.system_data["system"].data["perform_update"]: data.data.system_data["system"].perform_update() @@ -84,14 +84,13 @@ def handler5MinAlgorithm(self): ausführt, die nur alle 5 Minuten ausgeführt werden müssen. """ try: - with ChangedValuesHandler(loadvars_.event_module_update_completed): + with ChangedValuesContext(loadvars_.event_module_update_completed): totals = save_log(LogType.DAILY) update_daily_yields(totals) update_pv_monthly_yearly_yields() data.data.general_data.grid_protection() data.data.optional_data.et_get_prices() data.data.counter_all_data.validate_hierarchy() - changed_values_handler.pub_changed_values() except KeyboardInterrupt: log.critical("Ausführung durch exit_after gestoppt: "+traceback.format_exc()) except Exception: @@ -124,7 +123,7 @@ def handler5Min(self): general_internal_chargepoint_handler.event_start.set() else: general_internal_chargepoint_handler.internal_chargepoint_handler.heartbeat = False - with ChangedValuesHandler(loadvars_.event_module_update_completed): + with ChangedValuesContext(loadvars_.event_module_update_completed): sub.system_data["system"].update_ip_address() except KeyboardInterrupt: log.critical("Ausführung durch exit_after gestoppt: "+traceback.format_exc()) @@ -152,7 +151,7 @@ def handler_random_nightly(self): @exit_after(10) def handler_hour(self): try: - with ChangedValuesHandler(loadvars_.event_module_update_completed): + with ChangedValuesContext(loadvars_.event_module_update_completed): for cp in data.data.cp_data.values(): calculate_charge_cost(cp) except KeyboardInterrupt: @@ -192,7 +191,6 @@ def schedule_jobs(): prep = prepare.Prepare() general_internal_chargepoint_handler = GeneralInternalChargepointHandler() rfid = RfidReader() - changed_values_handler = ChangedValuesHandler(loadvars_.event_module_update_completed) event_ev_template = threading.Event() event_ev_template.set() event_charge_template = threading.Event() @@ -253,7 +251,6 @@ def schedule_jobs(): event_update_config_completed.wait(300) Pub().pub("openWB/set/system/boot_done", True) Path(Path(__file__).resolve().parents[1]/"ramdisk"/"bootdone").touch() - changed_values_handler.store_initial_values() schedule_jobs() except Exception: log.exception("Fehler im Main-Modul") diff --git a/packages/modules/loadvars.py b/packages/modules/loadvars.py index ba23a85db1..f59a391210 100644 --- a/packages/modules/loadvars.py +++ b/packages/modules/loadvars.py @@ -31,8 +31,6 @@ def get_values(self) -> None: thread_handler(self._get_general(), data.data.general_data.data.control_interval/3) thread_handler(self._set_general(), data.data.general_data.data.control_interval/3) wait_for_module_update_completed(self.event_module_update_completed, topic) - data.data.pv_all_data.calc_power_for_all_components() - data.data.bat_all_data.calc_power_for_all_components() except Exception: log.exception("Fehler im loadvars-Modul")