Add a wrong station state to the field monitor

This commit is contained in:
Jeff S
2021-10-15 11:15:34 -07:00
committed by Patrick Fairbank
parent 8ccc1d772c
commit d369fddab3
3 changed files with 17 additions and 2 deletions

View File

@@ -48,6 +48,11 @@ type DriverStationConnection struct {
tcpConn net.Conn
udpConn net.Conn
log *TeamMatchLog
// WrongStation indicates if the team in the station is the incorrect team
// by being non-empty. If the team is in the correct station, or no team is
// connected, this is empty.
WrongStation string
}
var allianceStationPositionMap = map[string]byte{"R1": 0, "R2": 1, "R3": 2, "B1": 3, "B2": 4, "B3": 5}
@@ -319,8 +324,9 @@ func (arena *Arena) listenForDriverStations() {
teamDigit1, _ := strconv.Atoi(teamDigits[1])
teamDigit2, _ := strconv.Atoi(teamDigits[2])
stationTeamId := teamDigit1*100 + teamDigit2
wrongAssignedStation := ""
if stationTeamId != teamId {
wrongAssignedStation := arena.getAssignedAllianceStation(stationTeamId)
wrongAssignedStation = arena.getAssignedAllianceStation(stationTeamId)
if wrongAssignedStation != "" {
// The team is supposed to be in this match, but is plugged into the wrong station.
log.Printf("Team %d is in incorrect station %s.", teamId, wrongAssignedStation)
@@ -350,6 +356,10 @@ func (arena *Arena) listenForDriverStations() {
}
arena.AllianceStations[assignedStation].DsConn = dsConn
if wrongAssignedStation != "" {
dsConn.WrongStation = wrongAssignedStation
}
// Spin up a goroutine to handle further TCP communication with this driver station.
go dsConn.handleTcpConnection(arena)
}

View File

@@ -69,6 +69,9 @@ body {
.team-id[data-status=radio-linked], .team-notes[data-status=radio-linked] {
background-color: #ff00ff;
}
.team-id[data-status=wrong-station], .team-notes[data-status=wrong-station] {
background-color: #246f92;
}
.team-box-row {
display: flex;
height: 20%;

View File

@@ -37,7 +37,9 @@ var handleArenaStatus = function(data) {
if (stationStatus.Bypass) {
status = "";
} else if (stationStatus.DsConn) {
if (stationStatus.DsConn.RobotLinked) {
if (stationStatus.DsConn.WrongStation) {
status = "wrong-station";
} else if (stationStatus.DsConn.RobotLinked) {
status = "robot-linked";
} else if (stationStatus.DsConn.RadioLinked) {
status = "radio-linked";