Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LKuemmel committed Jun 18, 2024
1 parent 9e2b9e3 commit 4a95473
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 18 deletions.
2 changes: 2 additions & 0 deletions packages/control/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 0 additions & 8 deletions packages/helpermodules/changed_values_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions packages/helpermodules/update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
13 changes: 5 additions & 8 deletions packages/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 0 additions & 2 deletions packages/modules/loadvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 4a95473

Please sign in to comment.