mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
Add cycle time and event status to field monitor (closes #91).
This commit is contained in:
@@ -21,7 +21,16 @@ body {
|
||||
justify-content: center;
|
||||
}
|
||||
.position-row {
|
||||
height: 33.3%;
|
||||
height: 31%;
|
||||
}
|
||||
#eventStatusRow {
|
||||
height: 7%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-evenly;
|
||||
background-color: #333;
|
||||
font-size: 1.5vw;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.left-position, .right-position {
|
||||
width: 8%;
|
||||
|
||||
@@ -98,6 +98,16 @@ var handleArenaStatus = function(data) {
|
||||
});
|
||||
};
|
||||
|
||||
// Handles a websocket message to update the event status message.
|
||||
var handleEventStatus = function(data) {
|
||||
if (data.CycleTime === "") {
|
||||
$("#cycleTimeMessage").text("Last cycle time: Unknown");
|
||||
} else {
|
||||
$("#cycleTimeMessage").text("Last cycle time: " + data.CycleTime);
|
||||
}
|
||||
$("#earlyLateMessage").text(data.EarlyLateMessage);
|
||||
};
|
||||
|
||||
$(function() {
|
||||
// Read the configuration for this display from the URL query string.
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
@@ -114,6 +124,7 @@ $(function() {
|
||||
|
||||
// Set up the websocket back to the server.
|
||||
websocket = new CheesyWebsocket("/displays/field_monitor/websocket", {
|
||||
arenaStatus: function(event) { handleArenaStatus(event.data); }
|
||||
arenaStatus: function(event) { handleArenaStatus(event.data); },
|
||||
eventStatus: function(event) { handleEventStatus(event.data); },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
{{template "row" dict "leftPosition" "1" "rightPosition" "3"}}
|
||||
{{template "row" dict "leftPosition" "2" "rightPosition" "2"}}
|
||||
{{template "row" dict "leftPosition" "3" "rightPosition" "1"}}
|
||||
<div id="eventStatusRow">
|
||||
<div id="cycleTimeMessage"></div>
|
||||
<div id="earlyLateMessage"></div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="/static/js/lib/jquery.min.js"></script>
|
||||
<script src="/static/js/lib/jquery.json-2.4.min.js"></script>
|
||||
|
||||
@@ -49,5 +49,6 @@ func (web *Web) fieldMonitorDisplayWebsocketHandler(w http.ResponseWriter, r *ht
|
||||
defer ws.Close()
|
||||
|
||||
// Subscribe the websocket to the notifiers whose messages will be passed on to the client.
|
||||
ws.HandleNotifiers(display.Notifier, web.arena.ArenaStatusNotifier, web.arena.ReloadDisplaysNotifier)
|
||||
ws.HandleNotifiers(display.Notifier, web.arena.ArenaStatusNotifier, web.arena.EventStatusNotifier,
|
||||
web.arena.ReloadDisplaysNotifier)
|
||||
}
|
||||
|
||||
@@ -31,4 +31,5 @@ func TestFieldMonitorDisplayWebsocket(t *testing.T) {
|
||||
// Should get a few status updates right after connection.
|
||||
readWebsocketType(t, ws, "displayConfiguration")
|
||||
readWebsocketType(t, ws, "arenaStatus")
|
||||
readWebsocketType(t, ws, "eventStatus")
|
||||
}
|
||||
|
||||
@@ -31,8 +31,4 @@ func TestPitDisplayWebsocket(t *testing.T) {
|
||||
// Should get a few status updates right after connection.
|
||||
readWebsocketType(t, ws, "displayConfiguration")
|
||||
readWebsocketType(t, ws, "eventStatus")
|
||||
|
||||
// Check forced reloading as that is the only purpose the pit websocket serves.
|
||||
web.arena.ReloadDisplaysNotifier.Notify()
|
||||
readWebsocketType(t, ws, "reload")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user