Hide the commit match button on the scoring display until the match is finished.

This commit is contained in:
Patrick Fairbank
2015-05-31 12:40:24 -07:00
parent 369fadfbbe
commit 818fe7c6c6
3 changed files with 29 additions and 3 deletions

View File

@@ -64,6 +64,8 @@ func ScoringDisplayWebsocketHandler(w http.ResponseWriter, r *http.Request) {
matchLoadTeamsListener := mainArena.matchLoadTeamsNotifier.Listen()
defer close(matchLoadTeamsListener)
matchTimeListener := mainArena.matchTimeNotifier.Listen()
defer close(matchTimeListener)
reloadDisplaysListener := mainArena.reloadDisplaysNotifier.Listen()
defer close(reloadDisplaysListener)
@@ -73,6 +75,11 @@ func ScoringDisplayWebsocketHandler(w http.ResponseWriter, r *http.Request) {
log.Printf("Websocket error: %s", err)
return
}
err = websocket.Write("matchTime", MatchTimeMessage{mainArena.MatchState, int(mainArena.lastMatchTimeSec)})
if err != nil {
log.Printf("Websocket error: %s", err)
return
}
// Spin off a goroutine to listen for notifications and pass them on through the websocket.
go func() {
@@ -86,6 +93,12 @@ func ScoringDisplayWebsocketHandler(w http.ResponseWriter, r *http.Request) {
}
messageType = "score"
message = *score
case matchTimeSec, ok := <-matchTimeListener:
if !ok {
return
}
messageType = "matchTime"
message = MatchTimeMessage{mainArena.MatchState, matchTimeSec.(int)}
case _, ok := <-reloadDisplaysListener:
if !ok {
return

View File

@@ -8,6 +8,7 @@ var selectedStack = 0;
var numStacks = 10;
var stacks;
var stackScoreChanged = false;
var scoreCommitted = false;
function Stack() {
this.Totes = 0;
@@ -59,15 +60,15 @@ var handleScore = function(data) {
$("#autoScore").show();
$("#teleopCommands").hide();
$("#teleopScore").hide();
$("#commitMatchScore").hide();
$("#waitingMessage").hide();
scoreCommitted = false;
} else if (!data.TeleopCommitted) {
$("#autoCommands").hide();
$("#autoScore").hide();
$("#teleopCommands").show();
$("#teleopScore").show();
$("#commitMatchScore").show();
$("#waitingMessage").hide();
scoreCommitted = false;
} else {
$("#autoCommands").hide();
$("#autoScore").hide();
@@ -75,6 +76,7 @@ var handleScore = function(data) {
$("#teleopScore").hide();
$("#commitMatchScore").hide();
$("#waitingMessage").show();
scoreCommitted = true;
}
};
@@ -146,6 +148,15 @@ var handleKeyPress = function(event) {
}
};
// Handles a websocket message to update the match status.
var handleMatchTime = function(data) {
if (matchStates[data.MatchState] == "POST_MATCH" && !scoreCommitted) {
$("#commitMatchScore").show();
} else {
$("#commitMatchScore").hide();
}
};
// Updates the stack grid to highlight only the active stack.
var updateSelectedStack = function() {
for (i = 0; i < numStacks; i++) {
@@ -176,7 +187,8 @@ var commitMatchScore = function() {
$(function() {
// Set up the websocket back to the server.
websocket = new CheesyWebsocket("/displays/scoring/" + alliance + "/websocket", {
score: function(event) { handleScore(event.data); }
score: function(event) { handleScore(event.data); },
matchTime: function(event) { handleMatchTime(event.data); }
});
updateSelectedStack();

View File

@@ -138,6 +138,7 @@
<script>
var alliance = "{{.Alliance}}";
</script>
<script src="/static/js/match_timing.js"></script>
<script src="/static/js/scoring_display.js"></script>
{{end}}
{{define "stack"}}