Fixed file load naming and added period sorting constraint.

This commit is contained in:
Chris Davoren 2023-10-19 17:01:52 +10:00
parent 7bbd0cfd63
commit d19c8491f7
2 changed files with 4 additions and 2 deletions

View File

@ -37,6 +37,9 @@ class SimulationThread(threading.Thread):
for period in self.periods: for period in self.periods:
period["timestart"] = datetime.time.fromisoformat(period["timestart"]) 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): def signal_stop(self):
self.mutex.acquire() self.mutex.acquire()
self.running = False self.running = False

View File

@ -26,9 +26,8 @@ class TrafficlightfrontendConfig(AppConfig):
print("Traffic Light Frontend: initialization.") print("Traffic Light Frontend: initialization.")
print("Current working directory: {}".format(os.getcwd())) 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() SimulationThread.get_instance(periods, start_time=datetime.time.fromisoformat("07:59"), time_factor=4.0).start()