Skip to content

Commit

Permalink
Merge pull request openWB#1068 from LKuemmel/boot_done
Browse files Browse the repository at this point in the history
fix boot done
  • Loading branch information
LKuemmel authored Aug 2, 2023
2 parents 4b3ec21 + 6a3421c commit 587e4d8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/helpermodules/command_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

@pytest.fixture
def subdata_fixture() -> None:
SubData(*([Mock()]*15))
SubData(*([Mock()]*16))
SubData.cp_data = {"cp0": Mock(spec=ChargepointStateUpdate, chargepoint=Mock(
spec=Chargepoint, chargepoint_module=Mock(spec=ChargepointModulePro)))}

Expand Down
3 changes: 2 additions & 1 deletion packages/helpermodules/setdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,8 @@ def process_system_topic(self, msg: mqtt.MQTTMessage):
"openWB/set/system/wizard_done" in msg.topic or
"openWB/set/system/update_in_progress" in msg.topic or
"openWB/set/system/dataprotection_acknowledged" in msg.topic or
"openWB/set/system/usage_terms_acknowledged" in msg.topic):
"openWB/set/system/usage_terms_acknowledged" in msg.topic or
"openWB/set/system/update_config_completed" in msg.topic):
self._validate_value(msg, bool)
elif "openWB/set/system/version" in msg.topic:
self._validate_value(msg, str)
Expand Down
6 changes: 6 additions & 0 deletions packages/helpermodules/subdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __init__(self,
event_time_charging_plan: threading.Event,
event_start_internal_chargepoint: threading.Event,
event_stop_internal_chargepoint: threading.Event,
event_update_config_completed: threading.Event,
event_soc: threading.Event,
event_jobs_running: threading.Event):
self.event_ev_template = event_ev_template
Expand All @@ -94,6 +95,7 @@ def __init__(self,
self.event_time_charging_plan = event_time_charging_plan
self.event_start_internal_chargepoint = event_start_internal_chargepoint
self.event_stop_internal_chargepoint = event_stop_internal_chargepoint
self.event_update_config_completed = event_update_config_completed
self.event_soc = event_soc
self.event_jobs_running = event_jobs_running
self.heartbeat = False
Expand Down Expand Up @@ -739,6 +741,10 @@ def process_system_topic(self, client: mqtt.Client, var: dict, msg: mqtt.MQTTMes
if decode_payload(msg.payload) != "":
Pub().pub("openWB/system/subdata_initialized", "")
self.event_subdata_initialized.set()
elif "openWB/system/update_config_completed" == msg.topic:
if decode_payload(msg.payload) != "":
Pub().pub("openWB/system/update_config_completed", "")
self.event_update_config_completed.set()
elif "openWB/system/debug_level" == msg.topic:
logging.getLogger().setLevel(decode_payload(msg.payload))
self.set_json_payload(var["system"].data, msg)
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 @@ -445,6 +445,7 @@ def update(self):
self.__pub_missing_defaults()
self.__update_version()
self.__solve_breaking_changes()
Pub().pub("openWB/set/system/update_config_completed", True)
except Exception:
log.exception("Fehler beim Prüfen des Brokers.")

Expand Down
4 changes: 3 additions & 1 deletion packages/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def schedule_jobs():
event_command_completed = threading.Event()
event_command_completed.set()
event_subdata_initialized = threading.Event()
event_update_config_completed = threading.Event()
event_jobs_running = threading.Event()
event_jobs_running.set()
prep = prepare.Prepare()
Expand All @@ -199,6 +200,7 @@ def schedule_jobs():
event_scheduled_charging_plan, event_time_charging_plan,
general_internal_chargepoint_handler.event_start,
general_internal_chargepoint_handler.event_stop,
event_update_config_completed,
event_soc,
event_jobs_running)
comm = command.Command(event_command_completed)
Expand All @@ -219,7 +221,7 @@ def schedule_jobs():
t_comm.start()
t_internal_chargepoint.start()
# Warten, damit subdata Zeit hat, alle Topics auf dem Broker zu empfangen.
time.sleep(5)
event_update_config_completed.wait(300)
Pub().pub("openWB/set/system/boot_done", True)
Path(Path(__file__).resolve().parents[1]/"ramdisk"/"bootdone").touch()
schedule_jobs()
Expand Down

0 comments on commit 587e4d8

Please sign in to comment.