Skip to content

Commit

Permalink
Merge pull request #1094 from openWB/feature_timeout_soc
Browse files Browse the repository at this point in the history
Feature timeout soc
  • Loading branch information
benderl authored Aug 31, 2023
2 parents db37e35 + 30ee58b commit bc34377
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion packages/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,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 @@ -210,6 +209,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 @@ -222,6 +222,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

0 comments on commit bc34377

Please sign in to comment.