Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature timeout soc #1094

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, 10)]
[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)]
Expand Down Expand Up @@ -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"):
Expand All @@ -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)
Expand Down
23 changes: 13 additions & 10 deletions packages/modules/update_soc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import time
from typing import List, Tuple
import copy
from threading import Event, Thread
Expand All @@ -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, data.data.general_data.data.control_interval/3)
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 = [], []
Expand Down