Add ethernet connected, trip time, missed packets, and tooltips to the field monitor (closes #63).

This commit is contained in:
Patrick Fairbank
2020-03-31 20:04:42 -07:00
parent a5a7821b3f
commit 30b0679b6e
5 changed files with 47 additions and 13 deletions

View File

@@ -83,6 +83,7 @@ type Arena struct {
type AllianceStation struct {
DsConn *DriverStationConnection
Ethernet bool
Astop bool
Estop bool
Bypass bool
@@ -747,6 +748,13 @@ func (arena *Arena) handlePlcInput() {
arena.handleEstop("B1", blueEstops[0])
arena.handleEstop("B2", blueEstops[1])
arena.handleEstop("B3", blueEstops[2])
redEthernets, blueEthernets := arena.Plc.GetEthernetConnected()
arena.AllianceStations["R1"].Ethernet = redEthernets[0]
arena.AllianceStations["R2"].Ethernet = redEthernets[1]
arena.AllianceStations["R3"].Ethernet = redEthernets[2]
arena.AllianceStations["B1"].Ethernet = blueEthernets[0]
arena.AllianceStations["B2"].Ethernet = blueEthernets[1]
arena.AllianceStations["B3"].Ethernet = blueEthernets[2]
if arena.MatchState == PreMatch || arena.MatchState == PostMatch || arena.MatchState == TimeoutActive ||
arena.MatchState == PostTimeout {

View File

@@ -159,6 +159,20 @@ func (plc *Plc) GetTeamEstops() ([3]bool, [3]bool) {
return redEstops, blueEstops
}
// Returns whether anything is connected to each station's designated Ethernet port on the SCC.
func (plc *Plc) GetEthernetConnected() ([3]bool, [3]bool) {
return [3]bool{
plc.inputs[redConnected1],
plc.inputs[redConnected2],
plc.inputs[redConnected3],
},
[3]bool{
plc.inputs[blueConnected1],
plc.inputs[blueConnected2],
plc.inputs[blueConnected3],
}
}
// Set the on/off state of the stack lights on the scoring table.
func (plc *Plc) SetStackLights(red, blue, orange, green bool) {
plc.coils[stackLightRed] = red

View File

@@ -5,9 +5,6 @@
html {
height: 100%;
cursor: none;
-webkit-user-select: none;
-moz-user-select: none;
overflow: hidden;
}
body {
@@ -74,7 +71,7 @@ body {
width: 100%;
}
.team-box {
width: 25%;
width: 20%;
height: 100%;
font-size: 2.5vw;
background-color: #333;

View File

@@ -19,6 +19,7 @@ var handleArenaStatus = function(data) {
teamElementPrefix = "#" + blueSide + "Team" + station[1];
}
var teamIdElement = $(teamElementPrefix + "Id");
var teamEthernetElement = $(teamElementPrefix + "Ethernet");
var teamDsElement = $(teamElementPrefix + "Ds");
var teamRadioElement = $(teamElementPrefix + "Radio");
var teamRadioTextElement = $(teamElementPrefix + "Radio span");
@@ -47,6 +48,14 @@ var handleArenaStatus = function(data) {
teamIdElement.attr("data-status", "");
}
// Format the Ethernet status box.
teamEthernetElement.attr("data-status-ok", stationStatus.Ethernet ? "true" : "");
if (stationStatus.DsConn && stationStatus.DsConn.DsRobotTripTimeMs > 0) {
teamEthernetElement.text(stationStatus.DsConn.DsRobotTripTimeMs);
} else {
teamEthernetElement.text("ETH");
}
var wifiStatus = data.TeamWifiStatuses[station];
teamRadioTextElement.text(wifiStatus.TeamId);
@@ -54,6 +63,7 @@ var handleArenaStatus = function(data) {
// Format the driver station status box.
var dsConn = stationStatus.DsConn;
teamDsElement.attr("data-status-ok", dsConn.DsLinked);
teamDsElement.text(dsConn.MissedPacketCount);
// Format the radio status box according to the connection status of the robot radio.
var radioOkay = stationStatus.Team && stationStatus.Team.Id === wifiStatus.TeamId && wifiStatus.RadioLinked;
@@ -69,6 +79,7 @@ var handleArenaStatus = function(data) {
}
} else {
teamDsElement.attr("data-status-ok", "");
teamDsElement.text("DS");
teamRobotElement.attr("data-status-ok", "");
teamRobotElement.text("RBT");

View File

@@ -44,13 +44,17 @@
<div id="{{.side}}Team{{.position}}" class="team">
<div id="{{.side}}Team{{.position}}Id" class="team-id center"></div>
<div class="team-box-row">
<div id="{{.side}}Team{{.position}}Ds" class="team-box center">DS</div>
<div id="{{.side}}Team{{.position}}Radio" class="team-box center">
<div id="{{.side}}Team{{.position}}Ethernet" class="team-box center"
title="Driver Station Ethernet Connected&#10;Trip Time (ms)">ETH</div>
<div id="{{.side}}Team{{.position}}Ds" class="team-box center"
title="Driver Station Software Running&#10;Missed Packets">DS</div>
<div id="{{.side}}Team{{.position}}Radio" class="team-box center" title="Field Access Point Configured Team">
<i class="glyphicon glyphicon-signal"></i>
<span></span>
</div>
<div id="{{.side}}Team{{.position}}Robot" class="team-box center"></div>
<div id="{{.side}}Team{{.position}}Bypass" class="team-box center"></div>
<div id="{{.side}}Team{{.position}}Robot" class="team-box center"
title="Battery Voltage&#10;Seconds Since Last Connected"></div>
<div id="{{.side}}Team{{.position}}Bypass" class="team-box center" title="Emergency-Stopped or Bypassed"></div>
</div>
</div>
{{end}}