From d19c8491f7139e424fbd766e5e54d7ee02bc1883 Mon Sep 17 00:00:00 2001 From: Chris Davoren Date: Thu, 19 Oct 2023 17:01:52 +1000 Subject: [PATCH] Fixed file load naming and added period sorting constraint. --- simulation/simulation_thread.py | 3 +++ trafficlightfrontend/apps.py | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/simulation/simulation_thread.py b/simulation/simulation_thread.py index 95e34f5..5c04e6c 100644 --- a/simulation/simulation_thread.py +++ b/simulation/simulation_thread.py @@ -37,6 +37,9 @@ class SimulationThread(threading.Thread): for period in self.periods: period["timestart"] = datetime.time.fromisoformat(period["timestart"]) + # Essential - periods are assumed to be in chronological order + self.periods.sort(key=lambda x: x["timestart"]) + def signal_stop(self): self.mutex.acquire() self.running = False diff --git a/trafficlightfrontend/apps.py b/trafficlightfrontend/apps.py index 97a10fb..b46410e 100644 --- a/trafficlightfrontend/apps.py +++ b/trafficlightfrontend/apps.py @@ -26,9 +26,8 @@ class TrafficlightfrontendConfig(AppConfig): print("Traffic Light Frontend: initialization.") print("Current working directory: {}".format(os.getcwd())) - print(settings.BASE_DIR) - periods = json.load(open("states.json")) + periods = json.load(open("periods.json")) SimulationThread.get_instance(periods, start_time=datetime.time.fromisoformat("07:59"), time_factor=4.0).start()