Added fallback of using alliance station displays for hot goals.

This commit is contained in:
Patrick Fairbank
2014-08-22 21:42:26 -07:00
parent 8e6e436589
commit 59072c6c25
10 changed files with 51 additions and 2 deletions

View File

@@ -80,6 +80,7 @@ type Arena struct {
allianceStationDisplayNotifier *Notifier
allianceSelectionNotifier *Notifier
lowerThirdNotifier *Notifier
hotGoalLightNotifier *Notifier
audienceDisplayScreen string
allianceStationDisplays map[string]string
allianceStationDisplayScreen string
@@ -125,6 +126,7 @@ func (arena *Arena) Setup() {
arena.allianceStationDisplayNotifier = NewNotifier()
arena.allianceSelectionNotifier = NewNotifier()
arena.lowerThirdNotifier = NewNotifier()
arena.hotGoalLightNotifier = NewNotifier()
// Load empty match as current.
arena.MatchState = PRE_MATCH

View File

@@ -8,6 +8,7 @@ CREATE TABLE event_settings (
selectionround2order VARCHAR(1),
selectionround3order VARCHAR(1),
teaminfodownloadenabled bool,
alliancedisplayhotgoals bool,
tbapublishingenabled bool,
tbaeventcode VARCHAR(16),
tbasecretid VARCHAR(255),

View File

@@ -882,6 +882,8 @@ func AllianceStationDisplayWebsocketHandler(w http.ResponseWriter, r *http.Reque
defer close(matchTimeListener)
realtimeScoreListener := mainArena.realtimeScoreNotifier.Listen()
defer close(realtimeScoreListener)
hotGoalLightListener := mainArena.hotGoalLightNotifier.Listen()
defer close(hotGoalLightListener)
// Send the various notifications immediately upon connection.
var data interface{}
@@ -978,6 +980,15 @@ func AllianceStationDisplayWebsocketHandler(w http.ResponseWriter, r *http.Reque
mainArena.redRealtimeScore.CurrentCycle,
mainArena.blueRealtimeScore.Score(mainArena.redRealtimeScore.Fouls),
mainArena.blueRealtimeScore.CurrentCycle}
case side, ok := <-hotGoalLightListener:
if !ok {
return
}
if !eventSettings.AllianceDisplayHotGoals {
continue
}
messageType = "hotGoalLight"
message = side
}
err = websocket.Write(messageType, message)
if err != nil {

View File

@@ -14,6 +14,7 @@ type EventSettings struct {
SelectionRound2Order string
SelectionRound3Order string
TeamInfoDownloadEnabled bool
AllianceDisplayHotGoals bool
TbaPublishingEnabled bool
TbaEventCode string
TbaSecretId string

View File

@@ -12,26 +12,34 @@ import (
var hotGoalLights map[string]bool
var assistLights map[string]int
var pedestalLights map[string]bool
var newMatch bool
func SetupLights() {
hotGoalLights = make(map[string]bool)
assistLights = make(map[string]int)
pedestalLights = make(map[string]bool)
newMatch = true
}
func SetHotGoalLights(alliance string, leftSide bool) {
if hotGoalLights[alliance] == leftSide {
if !newMatch && hotGoalLights[alliance] == leftSide {
return
}
newMatch = false
hotGoalLights[alliance] = leftSide
if leftSide {
fmt.Printf("Setting left %s goal hot\n", alliance)
mainArena.hotGoalLightNotifier.Notify("left")
} else {
fmt.Printf("Setting right %s goal hot\n", alliance)
mainArena.hotGoalLightNotifier.Notify("right")
}
}
func SetAssistGoalLights(alliance string, numAssists int) {
newMatch = true
mainArena.hotGoalLightNotifier.Notify("")
if assistLights[alliance] == numAssists {
return
}

View File

@@ -42,6 +42,7 @@ func SettingsPostHandler(w http.ResponseWriter, r *http.Request) {
eventSettings.SelectionRound2Order = r.PostFormValue("selectionRound2Order")
eventSettings.SelectionRound3Order = r.PostFormValue("selectionRound3Order")
eventSettings.TeamInfoDownloadEnabled = r.PostFormValue("teamInfoDownloadEnabled") == "on"
eventSettings.AllianceDisplayHotGoals = r.PostFormValue("allianceDisplayHotGoals") == "on"
eventSettings.TbaPublishingEnabled = r.PostFormValue("tbaPublishingEnabled") == "on"
eventSettings.TbaEventCode = r.PostFormValue("tbaEventCode")
eventSettings.TbaSecretId = r.PostFormValue("tbaSecretId")

View File

@@ -86,3 +86,11 @@ body {
[data-status=bypass] {
background-color: #666;
}
#hotGoalLight {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: #ff0;
}

View File

@@ -116,6 +116,15 @@ var handleRealtimeScore = function(data) {
$("#blueScore").text(data.BlueScore);
};
var handleHotGoalLight = function(side) {
if (allianceStation != "" &&
(side == "left" && allianceStation[1] == "3" || side == "right" && allianceStation[1] == "1")) {
$("#hotGoalLight").show();
} else {
$("#hotGoalLight").hide();
}
};
$(function() {
if (displayId == "") {
displayId = Math.floor(Math.random() * 10000);
@@ -130,6 +139,7 @@ $(function() {
status: function(event) { handleStatus(event.data); },
matchTiming: function(event) { handleMatchTiming(event.data); },
matchTime: function(event) { handleMatchTime(event.data); },
realtimeScore: function(event) { handleRealtimeScore(event.data); }
realtimeScore: function(event) { handleRealtimeScore(event.data); },
hotGoalLight: function(event) { handleHotGoalLight(event.data); }
});
});

View File

@@ -19,6 +19,7 @@
</div>
</div>
<img id="logo" src="/static/img/logo-black.svg" style="display: none;"/>
<div id="hotGoalLight" style="display: none;"></div>
<script>
// A unique id to differentiate this station's display from its peers.
var displayId = "{{.DisplayId}}";

View File

@@ -91,6 +91,12 @@
<input type="checkbox" name="teamInfoDownloadEnabled"{{if .TeamInfoDownloadEnabled}} checked{{end}}>
</div>
</div>
<div class="form-group">
<label class="col-lg-7 control-label">Use alliance station displays for hot goals</label>
<div class="col-lg-1 checkbox">
<input type="checkbox" name="allianceDisplayHotGoals"{{if .AllianceDisplayHotGoals}} checked{{end}}>
</div>
</div>
</fieldset>
<fieldset>
<legend>Publishing</legend>