diff --git a/field/arena_notifiers.go b/field/arena_notifiers.go index 46fdffff..0c32979c 100644 --- a/field/arena_notifiers.go +++ b/field/arena_notifiers.go @@ -86,6 +86,8 @@ func (arena *Arena) generateArenaStatusMessage() any { AllianceStations map[string]*AllianceStation MatchState CanStartMatch bool + AccessPointStatus string + SwitchStatus string PlcIsHealthy bool FieldEStop bool PlcArmorBlockStatuses map[string]bool @@ -94,6 +96,8 @@ func (arena *Arena) generateArenaStatusMessage() any { arena.AllianceStations, arena.MatchState, arena.checkCanStartMatch() == nil, + arena.accessPoint.Status, + arena.networkSwitch.Status, arena.Plc.IsHealthy(), arena.Plc.GetFieldEStop(), arena.Plc.GetArmorBlockStatuses(), diff --git a/network/access_point.go b/network/access_point.go index f0cb778b..2407ebb1 100644 --- a/network/access_point.go +++ b/network/access_point.go @@ -22,7 +22,6 @@ import ( ) const ( - accessPointApiPort = 8081 accessPointPollPeriodSec = 1 ) @@ -77,7 +76,7 @@ func (ap *AccessPoint) SetSettings( networkSecurityEnabled bool, wifiStatuses [6]*TeamWifiStatus, ) { - ap.apiUrl = fmt.Sprintf("http://%s:%d", address, accessPointApiPort) + ap.apiUrl = fmt.Sprintf("http://%s", address) ap.password = password ap.channel = channel ap.networkSecurityEnabled = networkSecurityEnabled diff --git a/network/switch.go b/network/switch.go index e4cbfd64..c67dd51f 100644 --- a/network/switch.go +++ b/network/switch.go @@ -38,6 +38,7 @@ type Switch struct { mutex sync.Mutex configBackoffDuration time.Duration configPauseDuration time.Duration + Status string } var ServerIpAddress = "10.0.100.5" // The DS will try to connect to this address only. @@ -49,6 +50,7 @@ func NewSwitch(address, password string) *Switch { password: password, configBackoffDuration: switchConfigBackoffDurationSec * time.Second, configPauseDuration: switchConfigPauseDurationSec * time.Second, + Status: "UNKNOWN", } } @@ -57,6 +59,7 @@ func (sw *Switch) ConfigureTeamEthernet(teams [6]*model.Team) error { // Make sure multiple configurations aren't being set at the same time. sw.mutex.Lock() defer sw.mutex.Unlock() + sw.Status = "CONFIGURING" // Remove old team VLANs to reset the switch state. removeTeamVlansCommand := "" @@ -67,6 +70,7 @@ func (sw *Switch) ConfigureTeamEthernet(teams [6]*model.Team) error { } _, err := sw.runConfigCommand(removeTeamVlansCommand) if err != nil { + sw.Status = "ERROR" return err } time.Sleep(sw.configPauseDuration) @@ -114,6 +118,7 @@ func (sw *Switch) ConfigureTeamEthernet(teams [6]*model.Team) error { if len(addTeamVlansCommand) > 0 { _, err = sw.runConfigCommand(addTeamVlansCommand) if err != nil { + sw.Status = "ERROR" return err } } @@ -121,6 +126,7 @@ func (sw *Switch) ConfigureTeamEthernet(teams [6]*model.Team) error { // Give some time for the configuration to take before another one can be attempted. time.Sleep(sw.configBackoffDuration) + sw.Status = "ACTIVE" return nil } diff --git a/network/switch_test.go b/network/switch_test.go index ab7a9165..284fead3 100644 --- a/network/switch_test.go +++ b/network/switch_test.go @@ -15,6 +15,7 @@ import ( func TestConfigureSwitch(t *testing.T) { sw := NewSwitch("127.0.0.1", "password") + assert.Equal(t, "UNKNOWN", sw.Status) sw.port = 9050 sw.configBackoffDuration = time.Millisecond sw.configPauseDuration = time.Millisecond @@ -33,6 +34,7 @@ func TestConfigureSwitch(t *testing.T) { assert.Nil(t, sw.ConfigureTeamEthernet([6]*model.Team{nil, nil, nil, nil, nil, nil})) assert.Equal(t, expectedResetCommand, command1) assert.Equal(t, "", command2) + assert.Equal(t, "ACTIVE", sw.Status) // Should configure one team if only one is present. sw.port += 1 diff --git a/static/css/cheesy-arena.css b/static/css/cheesy-arena.css index a68c9323..bfd0efb1 100644 --- a/static/css/cheesy-arena.css +++ b/static/css/cheesy-arena.css @@ -94,6 +94,18 @@ .badge-scoring[data-ready=true] { background-color: #0c6; } +.badge-status { + background-color: #e66; +} +.badge-status[data-status=BOOTING] { + background-color: #f92; +} +.badge-status[data-status=CONFIGURING] { + background-color: #08f; +} +.badge-status[data-status=ACTIVE] { + background-color: #0c6; +} .badge-saved-match { background-color: #666; } diff --git a/static/js/match_play.js b/static/js/match_play.js index 4c995e78..d1493790 100644 --- a/static/js/match_play.js +++ b/static/js/match_play.js @@ -252,6 +252,9 @@ const handleArenaStatus = function(data) { break; } + $("#accessPointStatus").attr("data-status", data.AccessPointStatus); + $("#switchStatus").attr("data-status", data.SwitchStatus); + if (data.PlcIsHealthy) { $("#plcStatus").text("Connected"); $("#plcStatus").attr("data-ready", true); diff --git a/templates/match_play.html b/templates/match_play.html index 7e76ad9c..8fc0200e 100644 --- a/templates/match_play.html +++ b/templates/match_play.html @@ -92,13 +92,20 @@
Scoring

Referee

+ {{if .EventSettings.NetworkSecurityEnabled}} +
Network Status
+

+ Access Point
+ Switch +

+ {{end}} {{if .PlcIsEnabled}} -

PLC Status

+
PLC Status

-
- E-Stop + + E-Stop
{{range $name, $status := .PlcArmorBlockStatuses}} -
{{$name}} + {{$name}} {{end}}

{{end}} diff --git a/templates/setup_settings.html b/templates/setup_settings.html index 998c9c41..cf6df401 100644 --- a/templates/setup_settings.html +++ b/templates/setup_settings.html @@ -172,7 +172,7 @@
- +