Remove STEMtv client since the service has been discontinued.

This commit is contained in:
Patrick Fairbank
2018-09-23 12:21:32 -07:00
parent 36c7c56212
commit f8466f743a
9 changed files with 28 additions and 126 deletions

View File

@@ -23,8 +23,6 @@ CREATE TABLE event_settings (
tbadownloadenabled bool,
adminpassword VARCHAR(255),
readerpassword VARCHAR(255),
stemtvpublishingenabled bool,
stemtveventcode VARCHAR(16),
scaleledaddress VARCHAR(255),
redswitchledaddress VARCHAR(255),
blueswitchledaddress VARCHAR(255),

View File

@@ -48,7 +48,6 @@ type Arena struct {
networkSwitch *NetworkSwitch
Plc plc.Plc
TbaClient *partner.TbaClient
StemTvClient *partner.StemTvClient
AllianceStations map[string]*AllianceStation
Displays map[string]*Display
ArenaNotifiers
@@ -148,7 +147,6 @@ func (arena *Arena) LoadSettings() error {
arena.networkSwitch = NewNetworkSwitch(settings.SwitchAddress, settings.SwitchPassword)
arena.Plc.SetAddress(settings.PlcAddress)
arena.TbaClient = partner.NewTbaClient(settings.TbaEventCode, settings.TbaSecretId, settings.TbaSecret)
arena.StemTvClient = partner.NewStemTvClient(settings.StemTvEventCode)
if arena.EventSettings.NetworkSecurityEnabled {
if err = arena.accessPoint.ConfigureAdminWifi(); err != nil {

View File

@@ -6,35 +6,33 @@
package model
type EventSettings struct {
Id int
Name string
NumElimAlliances int
SelectionRound2Order string
SelectionRound3Order string
TBADownloadEnabled bool
TbaPublishingEnabled bool
TbaEventCode string
TbaSecretId string
TbaSecret string
NetworkSecurityEnabled bool
ApAddress string
ApUsername string
ApPassword string
ApTeamChannel int
ApAdminChannel int
ApAdminWpaKey string
SwitchAddress string
SwitchPassword string
PlcAddress string
AdminPassword string
ReaderPassword string
StemTvPublishingEnabled bool
StemTvEventCode string
ScaleLedAddress string
RedSwitchLedAddress string
BlueSwitchLedAddress string
RedVaultLedAddress string
BlueVaultLedAddress string
Id int
Name string
NumElimAlliances int
SelectionRound2Order string
SelectionRound3Order string
TBADownloadEnabled bool
TbaPublishingEnabled bool
TbaEventCode string
TbaSecretId string
TbaSecret string
NetworkSecurityEnabled bool
ApAddress string
ApUsername string
ApPassword string
ApTeamChannel int
ApAdminChannel int
ApAdminWpaKey string
SwitchAddress string
SwitchPassword string
PlcAddress string
AdminPassword string
ReaderPassword string
ScaleLedAddress string
RedSwitchLedAddress string
BlueSwitchLedAddress string
RedVaultLedAddress string
BlueVaultLedAddress string
}
const eventSettingsId = 0

View File

@@ -1,35 +0,0 @@
// Copyright 2016 Team 254. All Rights Reserved.
// Author: pat@patfairbank.com (Patrick Fairbank)
//
// Methods for publishing match video split information to STEMtv.
package partner
import (
"fmt"
"github.com/Team254/cheesy-arena/model"
"net/http"
"time"
)
type StemTvClient struct {
BaseUrl string
eventCode string
}
const (
stemTvBaseUrl = "http://52.21.72.74:5000"
preMatchPaddingSec = 5
postScoreDisplayPaddingSec = 10
)
func NewStemTvClient(eventCode string) *StemTvClient {
return &StemTvClient{stemTvBaseUrl, eventCode}
}
func (client *StemTvClient) PublishMatchVideoSplit(match *model.Match, scoreDisplayTime time.Time) error {
url := fmt.Sprintf("%s/event/api/v1.0/%s/%s/split/%d,%d", client.BaseUrl, client.eventCode, match.TbaCode(),
match.StartedAt.Unix()-preMatchPaddingSec, scoreDisplayTime.Unix()+postScoreDisplayPaddingSec)
_, err := http.Get(url)
return err
}

View File

@@ -1,29 +0,0 @@
// Copyright 2016 Team 254. All Rights Reserved.
// Author: pat@patfairbank.com (Patrick Fairbank)
package partner
import (
"github.com/Team254/cheesy-arena/model"
"github.com/stretchr/testify/assert"
"net/http"
"net/http/httptest"
"testing"
"time"
)
func TestPublishMatchVideoSplit(t *testing.T) {
// Mock the STEMtv server.
stemTvServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "/event/api/v1.0/my_event_code/qm254/split/981187501,981187690", r.URL.String())
}))
defer stemTvServer.Close()
client := NewStemTvClient("my_event_code")
client.BaseUrl = stemTvServer.URL
matchStartedTime, _ := time.Parse("2006-01-02 15:04:05 -0700", "2001-02-03 04:05:06 -0400")
match := &model.Match{Type: "qualification", DisplayName: "254", StartedAt: matchStartedTime}
scoreDisplayTime, _ := time.Parse("2006-01-02 15:04:05 -0700", "2001-02-03 04:08:00 -0400")
assert.Nil(t, client.PublishMatchVideoSplit(match, scoreDisplayTime))
}

View File

@@ -112,19 +112,6 @@
<input type="text" class="form-control" name="tbaSecret" value="{{.TbaSecret}}">
</div>
</div>
<p>Contact STEMtv to obtain an event code.</p>
<div class="form-group">
<label class="col-lg-7 control-label">Enable STEMtv publishing</label>
<div class="col-lg-1 checkbox">
<input type="checkbox" name="stemTvPublishingEnabled"{{if .StemTvPublishingEnabled}} checked{{end}}>
</div>
</div>
<div class="form-group">
<label class="col-lg-5 control-label">STEMtv Event Code</label>
<div class="col-lg-7">
<input type="text" class="form-control" name="stemTvEventCode" value="{{.StemTvEventCode}}">
</div>
</div>
</fieldset>
<fieldset>
<legend>Authentication</legend>

View File

@@ -410,16 +410,6 @@ func (web *Web) commitMatchScore(match *model.Match, matchResult *model.MatchRes
}()
}
if web.arena.EventSettings.StemTvPublishingEnabled && match.Type != "practice" {
// Publish asynchronously to STEMtv.
go func() {
err = web.arena.StemTvClient.PublishMatchVideoSplit(match, time.Now())
if err != nil {
log.Printf("Failed to publish match video split to STEMtv: %s", err.Error())
}
}()
}
// Back up the database, but don't error out if it fails.
err = web.arena.Database.Backup(web.arena.EventSettings.Name, fmt.Sprintf("post_%s_match_%s", match.Type, match.DisplayName))
if err != nil {

View File

@@ -157,11 +157,9 @@ func TestCommitMatch(t *testing.T) {
match, _ = web.arena.Database.GetMatchById(1)
assert.Equal(t, "T", match.Winner)
// Verify TBA and STEMtv publishing by checking the log for the expected failure messages.
// Verify TBA publishing by checking the log for the expected failure messages.
web.arena.TbaClient.BaseUrl = "fakeUrl"
web.arena.StemTvClient.BaseUrl = "fakeUrl"
web.arena.EventSettings.TbaPublishingEnabled = true
web.arena.EventSettings.StemTvPublishingEnabled = true
var writer bytes.Buffer
log.SetOutput(&writer)
err = web.commitMatchScore(match, matchResult, false)
@@ -169,7 +167,6 @@ func TestCommitMatch(t *testing.T) {
time.Sleep(time.Millisecond * 10) // Allow some time for the asynchronous publishing to happen.
assert.Contains(t, writer.String(), "Failed to publish matches")
assert.Contains(t, writer.String(), "Failed to publish rankings")
assert.Contains(t, writer.String(), "Failed to publish match video split to STEMtv")
}
func TestCommitEliminationTie(t *testing.T) {

View File

@@ -48,8 +48,6 @@ func (web *Web) settingsPostHandler(w http.ResponseWriter, r *http.Request) {
eventSettings.TbaEventCode = r.PostFormValue("tbaEventCode")
eventSettings.TbaSecretId = r.PostFormValue("tbaSecretId")
eventSettings.TbaSecret = r.PostFormValue("tbaSecret")
eventSettings.StemTvPublishingEnabled = r.PostFormValue("stemTvPublishingEnabled") == "on"
eventSettings.StemTvEventCode = r.PostFormValue("stemTvEventCode")
eventSettings.NetworkSecurityEnabled = r.PostFormValue("networkSecurityEnabled") == "on"
eventSettings.ApAddress = r.PostFormValue("apAddress")
eventSettings.ApUsername = r.PostFormValue("apUsername")