Added period verbose name for presentation purposes.

This commit is contained in:
Chris Davoren 2023-10-20 19:41:31 +10:00
parent 325c976c59
commit bb2093ca2c
3 changed files with 13 additions and 4 deletions

View File

@ -1,6 +1,7 @@
[ [
{ {
"name" : "offpeak-morning", "name" : "offpeak-morning",
"verbose-name" : "Morning off-peak",
"timestart" : "00:00", "timestart" : "00:00",
"states" : [ "states" : [
{ "duration" : 20, "north" : "green", "south" : "green", "east" : "red", "west" : "red", "north-right" : "red" }, { "duration" : 20, "north" : "green", "south" : "green", "east" : "red", "west" : "red", "north-right" : "red" },
@ -16,6 +17,7 @@
}, },
{ {
"name" : "peak-morning", "name" : "peak-morning",
"verbose-name" : "Morning peak",
"timestart" : "08:00", "timestart" : "08:00",
"states" : [ "states" : [
{ "duration" : 40, "north" : "green", "south" : "green", "east" : "red", "west" : "red", "north-right" : "red" }, { "duration" : 40, "north" : "green", "south" : "green", "east" : "red", "west" : "red", "north-right" : "red" },
@ -31,6 +33,7 @@
}, },
{ {
"name" : "offpeak-middle", "name" : "offpeak-middle",
"verbose-name" : "Middle off-peak",
"timestart" : "10:00", "timestart" : "10:00",
"states" : [ "states" : [
{ "duration" : 20, "north" : "green", "south" : "green", "east" : "red", "west" : "red", "north-right" : "red" }, { "duration" : 20, "north" : "green", "south" : "green", "east" : "red", "west" : "red", "north-right" : "red" },
@ -46,6 +49,7 @@
}, },
{ {
"name" : "peak-afternoon", "name" : "peak-afternoon",
"verbose-name" : "Afternoon peak",
"timestart" : "17:00", "timestart" : "17:00",
"states" : [ "states" : [
{ "duration" : 40, "north" : "green", "south" : "green", "east" : "red", "west" : "red", "north-right" : "red" }, { "duration" : 40, "north" : "green", "south" : "green", "east" : "red", "west" : "red", "north-right" : "red" },
@ -61,6 +65,7 @@
}, },
{ {
"name" : "offpeak-evening", "name" : "offpeak-evening",
"verbose-name" : "Evening off-peak",
"timestart" : "19:00", "timestart" : "19:00",
"states" : [ "states" : [
{ "duration" : 20, "north" : "green", "south" : "green", "east" : "red", "west" : "red", "north-right" : "red" }, { "duration" : 20, "north" : "green", "south" : "green", "east" : "red", "west" : "red", "north-right" : "red" },

View File

@ -54,7 +54,13 @@ class SimulationThread(threading.Thread):
def get_snapshot(self): def get_snapshot(self):
self.mutex.acquire() self.mutex.acquire()
return_data = {"current_period": self.periods[self.current_period_index]["name"], "current_state": self.periods[self.current_period_index]["states"][self.current_state_index], "next_changeover_time": self.next_changeover_time, "simulation_time": self.current_simulation_datetime.time()} return_data = {
"current_period_name": self.periods[self.current_period_index]["name"],
"current_period_verbose_name": self.periods[self.current_period_index]["verbose-name"],
"current_state": self.periods[self.current_period_index]["states"][self.current_state_index],
"next_changeover_time": self.next_changeover_time,
"simulation_time": self.current_simulation_datetime.time(),
}
self.mutex.release() self.mutex.release()
return return_data return return_data

View File

@ -73,12 +73,10 @@
return; return;
} }
light_status = JSON.parse(this.responseText); light_status = JSON.parse(this.responseText);
// console.log(light_status);
// console.log(light_status.current_period);
let static_path_prefix = "/static/trafficlightfrontend/"; let static_path_prefix = "/static/trafficlightfrontend/";
document.getElementById("status").innerHTML = JSON.stringify(light_status.current_state); document.getElementById("status").innerHTML = JSON.stringify(light_status.current_state);
document.getElementById("period").innerHTML = light_status.current_period; document.getElementById("period").innerHTML = light_status.current_period_verbose_name;
document.getElementById("time").innerHTML = light_status.simulation_time; document.getElementById("time").innerHTML = light_status.simulation_time;
document.getElementById("north").style.backgroundImage = "url(" + static_path_prefix + light_status.current_state.north + ".png)"; document.getElementById("north").style.backgroundImage = "url(" + static_path_prefix + light_status.current_state.north + ".png)";