From 48055dc5ca7a92709dc3624eff9b305b15a6335d Mon Sep 17 00:00:00 2001 From: Patrick Fairbank Date: Sat, 27 Jul 2019 12:09:35 -0700 Subject: [PATCH] Remove game-specific data functionality. --- .../20140524180123_CreateMatches.sql | 3 +-- field/arena.go | 13 ----------- field/arena_notifiers.go | 10 ++++----- field/driver_station_connection.go | 22 ------------------- model/match.go | 1 - model/match_test.go | 10 ++++----- static/js/match_play.js | 6 +---- templates/match_play.html | 4 ---- web/match_play.go | 4 +--- 9 files changed, 12 insertions(+), 61 deletions(-) diff --git a/db/migrations/20140524180123_CreateMatches.sql b/db/migrations/20140524180123_CreateMatches.sql index 03eb24e..747e0f9 100644 --- a/db/migrations/20140524180123_CreateMatches.sql +++ b/db/migrations/20140524180123_CreateMatches.sql @@ -22,8 +22,7 @@ CREATE TABLE matches ( status VARCHAR(16), startedat DATETIME, scorecommittedat DATETIME, - winner VARCHAR(16), - gamespecificdata VARCHAR(3) + winner VARCHAR(16) ); CREATE UNIQUE INDEX type_displayname ON matches(type, displayname); diff --git a/field/arena.go b/field/arena.go index ed49f0e..f03d5bc 100644 --- a/field/arena.go +++ b/field/arena.go @@ -622,19 +622,6 @@ func (arena *Arena) sendDsPacket(auto bool, enabled bool) { arena.lastDsPacketTime = time.Now() } -func (arena *Arena) sendGameSpecificDataPacket() { - for _, allianceStation := range arena.AllianceStations { - dsConn := allianceStation.DsConn - if dsConn != nil { - err := dsConn.sendGameSpecificDataPacket(arena.CurrentMatch.GameSpecificData) - if err != nil { - log.Printf("Error sending game-specific data packet to Team %d: %v", dsConn.TeamId, err) - } - } - } - arena.lastDsPacketTime = time.Now() -} - // Returns the alliance station identifier for the given team, or the empty string if the team is not present // in the current match. func (arena *Arena) getAssignedAllianceStation(teamId int) string { diff --git a/field/arena_notifiers.go b/field/arena_notifiers.go index b0089be..d9fec98 100644 --- a/field/arena_notifiers.go +++ b/field/arena_notifiers.go @@ -92,13 +92,11 @@ func (arena *Arena) generateArenaStatusMessage() interface{} { AllianceStations map[string]*AllianceStation TeamWifiStatuses map[string]network.TeamWifiStatus MatchState - CanStartMatch bool - PlcIsHealthy bool - FieldEstop bool - GameSpecificData string + CanStartMatch bool + PlcIsHealthy bool + FieldEstop bool }{arena.CurrentMatch.Id, arena.AllianceStations, teamWifiStatuses, arena.MatchState, - arena.checkCanStartMatch() == nil, arena.Plc.IsHealthy, arena.Plc.GetFieldEstop(), - arena.CurrentMatch.GameSpecificData} + arena.checkCanStartMatch() == nil, arena.Plc.IsHealthy, arena.Plc.GetFieldEstop()} } func (arena *Arena) generateAudienceDisplayModeMessage() interface{} { diff --git a/field/driver_station_connection.go b/field/driver_station_connection.go index d822fa2..39fbfd9 100644 --- a/field/driver_station_connection.go +++ b/field/driver_station_connection.go @@ -385,25 +385,3 @@ func (dsConn *DriverStationConnection) handleTcpConnection(arena *Arena) { } } } - -func (dsConn *DriverStationConnection) sendGameSpecificDataPacket(gameSpecificData string) error { - byteData := []byte(gameSpecificData) - size := len(byteData) - packet := make([]byte, size+4) - - packet[0] = 0 // Packet size - packet[1] = byte(size + 2) // Packet size - packet[2] = 28 // Packet type - packet[3] = byte(size) // Data size - - // Fill the rest of the packet with the data. - for i, character := range byteData { - packet[i+4] = character - } - - if dsConn.tcpConn != nil { - _, err := dsConn.tcpConn.Write(packet) - return err - } - return nil -} diff --git a/model/match.go b/model/match.go index a557ec1..e562c86 100644 --- a/model/match.go +++ b/model/match.go @@ -35,7 +35,6 @@ type Match struct { StartedAt time.Time ScoreCommittedAt time.Time Winner string - GameSpecificData string } var ElimRoundNames = map[int]string{1: "F", 2: "SF", 4: "QF", 8: "EF"} diff --git a/model/match_test.go b/model/match_test.go index 7ccaf46..fc58b8b 100644 --- a/model/match_test.go +++ b/model/match_test.go @@ -21,7 +21,7 @@ func TestMatchCrud(t *testing.T) { db := setupTestDb(t) match := Match{0, "qualification", "254", time.Now().UTC(), 0, 0, 0, 1, false, 2, false, 3, false, 4, false, - 5, false, 6, false, "", time.Now().UTC(), time.Now().UTC(), "", ""} + 5, false, 6, false, "", time.Now().UTC(), time.Now().UTC(), ""} db.CreateMatch(&match) match2, err := db.GetMatchById(1) assert.Nil(t, err) @@ -46,7 +46,7 @@ func TestTruncateMatches(t *testing.T) { db := setupTestDb(t) match := Match{0, "qualification", "254", time.Now().UTC(), 0, 0, 0, 1, false, 2, false, 3, false, 4, false, - 5, false, 6, false, "", time.Now().UTC(), time.Now().UTC(), "", ""} + 5, false, 6, false, "", time.Now().UTC(), time.Now().UTC(), ""} db.CreateMatch(&match) db.TruncateMatches() match2, err := db.GetMatchById(1) @@ -83,13 +83,13 @@ func TestGetMatchesByType(t *testing.T) { db := setupTestDb(t) match := Match{0, "qualification", "1", time.Now().UTC(), 0, 0, 0, 1, false, 2, false, 3, false, 4, false, - 5, false, 6, false, "", time.Now().UTC(), time.Now().UTC(), "", ""} + 5, false, 6, false, "", time.Now().UTC(), time.Now().UTC(), ""} db.CreateMatch(&match) match2 := Match{0, "practice", "1", time.Now().UTC(), 0, 0, 0, 1, false, 2, false, 3, false, 4, false, 5, - false, 6, false, "", time.Now().UTC(), time.Now().UTC(), "", ""} + false, 6, false, "", time.Now().UTC(), time.Now().UTC(), ""} db.CreateMatch(&match2) match3 := Match{0, "practice", "2", time.Now().UTC(), 0, 0, 0, 1, false, 2, false, 3, false, 4, false, 5, - false, 6, false, "", time.Now().UTC(), time.Now().UTC(), "", ""} + false, 6, false, "", time.Now().UTC(), time.Now().UTC(), ""} db.CreateMatch(&match3) matches, err := db.GetMatchesByType("test") diff --git a/static/js/match_play.js b/static/js/match_play.js index 9cc24f1..93f0255 100644 --- a/static/js/match_play.js +++ b/static/js/match_play.js @@ -21,7 +21,7 @@ var toggleBypass = function(station) { // Sends a websocket message to start the match. var startMatch = function() { websocket.send("startMatch", - { muteMatchSounds: $("#muteMatchSounds").prop("checked"), gameSpecificData: $("#gameSpecificData").val() }); + { muteMatchSounds: $("#muteMatchSounds").prop("checked") }); }; // Sends a websocket message to abort the match. @@ -187,10 +187,6 @@ var handleArenaStatus = function(data) { $("#plcStatus").attr("data-ready", false); } $("#fieldEstop").attr("data-ready", !data.FieldEstop); - - if (matchStates[data.MatchState] !== "PRE_MATCH") { - $("#gameSpecificData").val(data.GameSpecificData); - } }; // Handles a websocket message to update the match time countdown. diff --git a/templates/match_play.html b/templates/match_play.html index 63f7521..2c97233 100644 --- a/templates/match_play.html +++ b/templates/match_play.html @@ -195,10 +195,6 @@
-

Game-Specific Data

- -

Match Sounds