diff --git a/field/display.go b/field/display.go index ca390ec..b197410 100644 --- a/field/display.go +++ b/field/display.go @@ -51,7 +51,7 @@ var displayTypePaths = map[DisplayType]string{ AllianceStationDisplay: "/displays/alliance_station", AnnouncerDisplay: "/displays/announcer", AudienceDisplay: "/displays/audience", - FieldMonitorDisplay: "/displays/fta", + FieldMonitorDisplay: "/displays/field_monitor", PitDisplay: "/displays/pit", QueueingDisplay: "/displays/queueing", TwitchStreamDisplay: "/displays/twitch", diff --git a/field/display_test.go b/field/display_test.go index 6eaa8df..bf25879 100644 --- a/field/display_test.go +++ b/field/display_test.go @@ -31,7 +31,7 @@ func TestDisplayFromUrl(t *testing.T) { assert.Equal(t, AnnouncerDisplay, display.Type) display, _ = DisplayFromUrl("/displays/audience/websocket", query) assert.Equal(t, AudienceDisplay, display.Type) - display, _ = DisplayFromUrl("/displays/fta/websocket", query) + display, _ = DisplayFromUrl("/displays/field_monitor/websocket", query) assert.Equal(t, FieldMonitorDisplay, display.Type) display, _ = DisplayFromUrl("/displays/pit/websocket", query) assert.Equal(t, PitDisplay, display.Type) diff --git a/static/css/cheesy-arena.css b/static/css/cheesy-arena.css index e5f6dbf..2c5f237 100644 --- a/static/css/cheesy-arena.css +++ b/static/css/cheesy-arena.css @@ -46,7 +46,7 @@ .modal-large { width: 60%; } -.ds-status, .radio-status, .robot-status, .battery-status, .bypass-status, .bypass-status-fta, .trip-time, .packet-loss { +.ds-status, .radio-status, .robot-status, .battery-status, .bypass-status, .trip-time, .packet-loss { background-color: #aaa; color: #000; border: 1px solid #999; diff --git a/static/css/field_monitor_display.css b/static/css/field_monitor_display.css new file mode 100644 index 0000000..65994e9 --- /dev/null +++ b/static/css/field_monitor_display.css @@ -0,0 +1,52 @@ +/* + Copyright 2018 Team 254. All Rights Reserved. + Author: pat@patfairbank.com (Patrick Fairbank) +*/ + +html { + height: 100%; + cursor: none; + -webkit-user-select: none; + -moz-user-select: none; + overflow: hidden; +} +body { + height: 100%; + font-family: FuturaLTBold; + color: #fff; +} +.center { + display: flex; + align-items: center; + justify-content: center; +} +.position-row { + height: 33.3%; +} +.left-position, .right-position { + width: 8%; + height: 100%; + font-size: 6vw; +} +.left-position[data-reversed=false], .right-position[data-reversed=true] { + background-color: #ff4444; +} +.left-position[data-reversed=true], .right-position[data-reversed=false] { + background-color: #2080ff; +} +.team { + width: 42%; + height: 100%; + background-color: #333; + font-size: 13vw; +} +.team[data-status=no-link] { + background-color: #963; +} +.team[data-status=ds-linked] { + background-color: #ff0; + color: #333; +} +.team[data-status=robot-linked] { + background-color: #0a3; +} diff --git a/static/js/field_monitor_display.js b/static/js/field_monitor_display.js new file mode 100644 index 0000000..85040c2 --- /dev/null +++ b/static/js/field_monitor_display.js @@ -0,0 +1,61 @@ +// Copyright 2018 Team 254. All Rights Reserved. +// Author: pat@patfairbank.com (Patrick Fairbank) +// +// Client-side logic for the field monitor display. + +var websocket; +var redSide; +var blueSide; + +// Handles a websocket message to update the team connection status. +var handleArenaStatus = function(data) { + $.each(data.AllianceStations, function(station, stationStatus) { + // Select the DOM element corresponding to the team station. + var teamElement; + if (station[0] === "R") { + teamElement = $("#" + redSide + "Team" + station[1]); + } else { + teamElement = $("#" + blueSide + "Team" + station[1]); + } + + if (stationStatus.Team) { + // Set the team number and status. + teamElement.text(stationStatus.Team.Id); + var status = "no-link"; + if (stationStatus.Bypass) { + status = ""; + } else if (stationStatus.DsConn) { + if (stationStatus.DsConn.RobotLinked) { + status = "robot-linked"; + } else if (stationStatus.DsConn.DsLinked) { + status = "ds-linked"; + } + } + teamElement.attr("data-status", status); + } else { + // No team is present in this position for this match; blank out the status. + teamElement.text(""); + teamElement.attr("data-status", ""); + } + }); +}; + +$(function() { + // Read the configuration for this display from the URL query string. + var urlParams = new URLSearchParams(window.location.search); + var reversed = urlParams.get("reversed"); + if (reversed === "true") { + redSide = "right"; + blueSide = "left"; + } else { + redSide = "left"; + blueSide = "right"; + } + $(".reversible-left").attr("data-reversed", reversed); + $(".reversible-right").attr("data-reversed", reversed); + + // Set up the websocket back to the server. + websocket = new CheesyWebsocket("/displays/field_monitor/websocket", { + arenaStatus: function(event) { handleArenaStatus(event.data); } + }); +}); diff --git a/static/js/fta_display.js b/static/js/fta_display.js deleted file mode 100644 index 96441d8..0000000 --- a/static/js/fta_display.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2014 Team 254. All Rights Reserved. -// Author: austin.linux@gmail.com (Austin Schuh) -// Author: pat@patfairbank.com (Patrick Fairbank) -// -// Client-side logic for the FTA diagnostic display. - -var websocket; - -// Handles a websocket message to update the team connection status. -var handleArenaStatus = function(data) { - // Update the team status view. - $.each(data.AllianceStations, function(station, stationStatus) { - if (stationStatus.Team) { - $("#status" + station + " .team").text(stationStatus.Team.Id); - } else { - $("#status" + station + " .team").text(""); - } - - if (stationStatus.DsConn) { - var dsConn = stationStatus.DsConn; - $("#status" + station + " .ds-status").attr("data-status-ok", dsConn.DsLinked); - $("#status" + station + " .radio-status").attr("data-status-ok", dsConn.RadioLinked); - $("#status" + station + " .robot-status").attr("data-status-ok", dsConn.RobotLinked); - if (stationStatus.DsConn.SecondsSinceLastRobotLink > 1 && stationStatus.DsConn.SecondsSinceLastRobotLink < 1000) { - $("#status" + station + " .robot-status").text(stationStatus.DsConn.SecondsSinceLastRobotLink.toFixed()); - } else { - $("#status" + station + " .robot-status").text(""); - } - var lowBatteryThreshold = 6; - if (matchStates[data.MatchState] === "PRE_MATCH" || matchStates[data.MatchState] === "TIMEOUT_ACTIVE" || - matchStates[data.MatchState] === "POST_TIMEOUT") { - lowBatteryThreshold = 12; - } - $("#status" + station + " .battery-status").attr("data-status-ok", - dsConn.BatteryVoltage > lowBatteryThreshold && dsConn.RobotLinked); - $("#status" + station + " .battery-status").text(dsConn.BatteryVoltage.toFixed(1) + "V"); - $("#status" + station + " .trip-time").attr("data-status-ok", true); - $("#status" + station + " .trip-time").text(dsConn.DsRobotTripTimeMs.toFixed(1) + "ms"); - $("#status" + station + " .packet-loss").attr("data-status-ok", true); - $("#status" + station + " .packet-loss").text(dsConn.MissedPacketCount); - } else { - $("#status" + station + " .ds-status").attr("data-status-ok", ""); - $("#status" + station + " .ds-status").text(""); - $("#status" + station + " .radio-status").attr("data-status-ok", ""); - $("#status" + station + " .radio-status").text(""); - $("#status" + station + " .robot-status").attr("data-status-ok", ""); - $("#status" + station + " .robot-status").text(""); - $("#status" + station + " .battery-status").attr("data-status-ok", ""); - $("#status" + station + " .battery-status").text(""); - $("#status" + station + " .trip-time").attr("data-status-ok", ""); - $("#status" + station + " .trip-time").text(""); - $("#status" + station + " .packet-loss").attr("data-status-ok", ""); - $("#status" + station + " .packet-loss").text(""); - } - - if (stationStatus.Estop) { - $("#status" + station + " .bypass-status-fta").attr("data-status-ok", false); - $("#status" + station + " .bypass-status-fta").text("ES"); - } else if (stationStatus.Bypass) { - $("#status" + station + " .bypass-status-fta").attr("data-status-ok", false); - $("#status" + station + " .bypass-status-fta").text("B"); - } else { - $("#status" + station + " .bypass-status-fta").attr("data-status-ok", true); - $("#status" + station + " .bypass-status-fta").text(""); - } - }); -}; - -$(function() { - // Activate tooltips above the status headers. - $("[data-toggle=tooltip]").tooltip({"placement": "top"}); - - // Set up the websocket back to the server. - websocket = new CheesyWebsocket("/displays/fta/websocket", { - arenaStatus: function(event) { handleArenaStatus(event.data); } - }); -}); diff --git a/templates/base.html b/templates/base.html index ce3237d..4ef3ff6 100644 --- a/templates/base.html +++ b/templates/base.html @@ -84,7 +84,7 @@