Skip to content

Commit f80283f

Browse files
authored
Add rio ping (#168)
* Stack light Status Update stack light status to show disconnected robots during a match. * Rio Linked Add Rio ping to field monitor and logs to show no code status * fix Fixed Log viewer go.
1 parent ef2ac58 commit f80283f

7 files changed

+25
-10
lines changed

field/driver_station_connection.go

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type DriverStationConnection struct {
3737
Estop bool
3838
DsLinked bool
3939
RadioLinked bool
40+
RioLinked bool
4041
RobotLinked bool
4142
BatteryVoltage float64
4243
DsRobotTripTimeMs int
@@ -100,6 +101,7 @@ func (arena *Arena) listenForDsUdpPackets() {
100101
dsConn.DsLinked = true
101102
dsConn.lastPacketTime = time.Now()
102103

104+
dsConn.RioLinked = data[3]&0x08 != 0
103105
dsConn.RadioLinked = data[3]&0x10 != 0
104106
dsConn.RobotLinked = data[3]&0x20 != 0
105107
if dsConn.RobotLinked {
@@ -122,6 +124,7 @@ func (dsConn *DriverStationConnection) update(arena *Arena) error {
122124
if time.Since(dsConn.lastPacketTime).Seconds() > driverStationUdpLinkTimeoutSec {
123125
dsConn.DsLinked = false
124126
dsConn.RadioLinked = false
127+
dsConn.RioLinked = false
125128
dsConn.RobotLinked = false
126129
dsConn.BatteryVoltage = 0
127130
}

field/team_match_log.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ package field
77

88
import (
99
"fmt"
10-
"github.com/Team254/cheesy-arena/model"
11-
"github.com/Team254/cheesy-arena/network"
1210
"log"
1311
"os"
1412
"path/filepath"
1513
"time"
14+
15+
"github.com/Team254/cheesy-arena/model"
16+
"github.com/Team254/cheesy-arena/network"
1617
)
1718

1819
const logsDir = "static/logs"
@@ -38,7 +39,7 @@ func NewTeamMatchLog(teamId int, match *model.Match, wifiStatus *network.TeamWif
3839
}
3940

4041
log := TeamMatchLog{log.New(logFile, "", 0), logFile, wifiStatus}
41-
log.logger.Println("matchTimeSec,packetType,teamId,allianceStation,dsLinked,radioLinked,robotLinked,auto,enabled," +
42+
log.logger.Println("matchTimeSec,packetType,teamId,allianceStation,dsLinked,radioLinked,rioLinked,robotLinked,auto,enabled," +
4243
"emergencyStop,batteryVoltage,missedPacketCount,dsRobotTripTimeMs,rxRate,txRate,signalNoiseRatio")
4344

4445
return &log, nil
@@ -47,13 +48,14 @@ func NewTeamMatchLog(teamId int, match *model.Match, wifiStatus *network.TeamWif
4748
// Adds a line to the log when a packet is received.
4849
func (log *TeamMatchLog) LogDsPacket(matchTimeSec float64, packetType int, dsConn *DriverStationConnection) {
4950
log.logger.Printf(
50-
"%f,%d,%d,%s,%v,%v,%v,%v,%v,%v,%f,%d,%d,%f,%f,%d",
51+
"%f,%d,%d,%s,%v,%v,%v,%v,%v,%v,%v,%f,%d,%d,%f,%f,%d",
5152
matchTimeSec,
5253
packetType,
5354
dsConn.TeamId,
5455
dsConn.AllianceStation,
5556
dsConn.DsLinked,
5657
dsConn.RadioLinked,
58+
dsConn.RioLinked,
5759
dsConn.RobotLinked,
5860
dsConn.Auto,
5961
dsConn.Enabled,

static/css/field_monitor_display.css

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ body {
9494
background-color: #00ff00;
9595
color: #333;
9696
}
97+
.team-id[data-status=rio-linked], .team-notes[data-status=rio-linked] {
98+
background-color: #00cc00;
99+
}
97100
.team-id[data-status=radio-linked], .team-notes[data-status=radio-linked] {
98101
background-color: #AA3377;
99102
}

static/js/field_monitor_display.js

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ var handleArenaStatus = function(data) {
5151
status = "wrong-station";
5252
} else if (stationStatus.DsConn.RobotLinked) {
5353
status = "robot-linked";
54+
} else if (stationStatus.DsConn.RioLinked) {
55+
status = "rio-linked";
5456
} else if (stationStatus.DsConn.RadioLinked) {
5557
status = "radio-linked";
5658
} else if (stationStatus.DsConn.DsLinked) {

templates/field_monitor_display.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
{{template "row" dict "leftPosition" "3" "rightPosition" "1"}}
2828
<div id="eventStatusRow" class="ds-dependent">
2929
<div id="leftScore" class="fta-dependent ds-dependent left-score text-center reversible-left" style="width:8%; vertical-align:middle;"></div>
30-
<div id="cycleTimeMessage" class="text-center ds-dependent" style="width: 42%;"></div>
31-
<div id="earlyLateMessage" class="text-center ds-dependent" style="width: 42%;"></div>
30+
<div id="cycleTimeMessage" class="text-center ds-dependent" style="width: 46%;"></div>
31+
<div id="earlyLateMessage" class="text-center ds-dependent" style="width: 38%;"></div>
3232
<div id="rightScore" class="right-score ds-dependent text-center fta-dependent reversible-right " style="width: 8%;"></div>
3333
</div>
3434
</body>

templates/view_match_log.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ <h1>{{.Match.ShortName}} - {{ .MatchLogs.TeamId}}({{.MatchLogs.AllianceStation}}
3636
<th>Match Time</th>
3737
<th>DS Linked</th>
3838
<th>Radio Linked</th>
39+
<th>Rio Linked</th>
3940
<th>Robot Linked</th>
4041
<th>Mode</th>
4142
<th>Enabled</th>
@@ -54,7 +55,8 @@ <h1>{{.Match.ShortName}} - {{ .MatchLogs.TeamId}}({{.MatchLogs.AllianceStation}}
5455
<td data-status-ok="{{and $row.DsLinked $row.RadioLinked $row.RobotLinked}}">{{printf "%.2f" $row.MatchTimeSec}}</td>
5556
<td>{{$row.DsLinked}}</td>
5657
<td>{{if $row.DsLinked}}{{$row.RadioLinked}}{{else}}*****{{end}}</td>
57-
<td>{{if and $row.DsLinked $row.RadioLinked}}{{$row.RobotLinked}}{{else}}*****{{end}}</td>
58+
<td>{{if and $row.DsLinked $row.RadioLinked}}{{$row.RioLinked}}{{else}}*****{{end}}</td>
59+
<td>{{if and $row.DsLinked $row.RadioLinked $row.RioLinked}}{{$row.RobotLinked}}{{else}}*****{{end}}</td>
5860
<td>{{if $row.Auto}}Auto{{else}}Telop{{end}}</td>
5961
<td>{{$row.Enabled}}</td>
6062
<td>{{$row.EmergencyStop}}</td>

web/match_logs.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ package web
88
import (
99
"encoding/csv"
1010
"fmt"
11-
"github.com/Team254/cheesy-arena/game"
12-
"github.com/Team254/cheesy-arena/model"
13-
"github.com/gorilla/mux"
1411
"net/http"
1512
"os"
1613
"path/filepath"
1714
"strconv"
15+
16+
"github.com/Team254/cheesy-arena/game"
17+
"github.com/Team254/cheesy-arena/model"
18+
"github.com/gorilla/mux"
1819
)
1920

2021
type MatchLogsListItem struct {
@@ -34,6 +35,7 @@ type MatchLogRow struct {
3435
AllianceStation string
3536
DsLinked bool
3637
RadioLinked bool
38+
RioLinked bool
3739
RobotLinked bool
3840
Auto bool
3941
Enabled bool
@@ -201,6 +203,7 @@ func (web *Web) getMatchLogFromRequest(r *http.Request) (*model.Match, *MatchLog
201203
curRow.AllianceStation = record[headerMap["allianceStation"]]
202204
curRow.DsLinked, _ = strconv.ParseBool(record[headerMap["dsLinked"]])
203205
curRow.RadioLinked, _ = strconv.ParseBool(record[headerMap["radioLinked"]])
206+
curRow.RioLinked, _ = strconv.ParseBool(record[headerMap["rioLinked"]])
204207
curRow.RobotLinked, _ = strconv.ParseBool(record[headerMap["robotLinked"]])
205208
curRow.Auto, _ = strconv.ParseBool(record[headerMap["auto"]])
206209
curRow.Enabled, _ = strconv.ParseBool(record[headerMap["enabled"]])

0 commit comments

Comments
 (0)