From 86e66783244007a833457f3e76fa26867f9be277 Mon Sep 17 00:00:00 2001 From: Michael Swan Date: Mon, 14 May 2018 19:25:32 -0700 Subject: [PATCH] Fixed game state issues with prestart. --- RoboticsGUI/GUI/Helpers/Constants.cs | 4 ++-- RoboticsGUI/GUI/Model/TeamGameModel.cs | 8 +++++--- RoboticsGUI/GUI/View/MainWindowView.xaml | 2 +- RoboticsGUI/GUI/ViewModel/MainWindowViewModel.cs | 5 +++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/RoboticsGUI/GUI/Helpers/Constants.cs b/RoboticsGUI/GUI/Helpers/Constants.cs index db9f53b..39c156e 100644 --- a/RoboticsGUI/GUI/Helpers/Constants.cs +++ b/RoboticsGUI/GUI/Helpers/Constants.cs @@ -11,7 +11,7 @@ public static class Constants //Default time motors spend moving in each direction. public const int defaultMotorFwdTime = 1000; //milliseconds. public const int defaultMotorBackTime = 1000; //milliseconds. - public const int defaultGameTime = 150; //seconds + public const int gameTime = 150; //total game time in seconds - may change this to be configurable later //Scoring increments for the scoring areas. public const uint platInc = 100; //Not sure which platform is the larger one, so use 100 increment for now. @@ -39,7 +39,7 @@ public static class Constants public const short bmotor1 = 4; //Motor1 public const short bmotor2 = 5; //Motor2 - public const int preStartBlinkInterval = 250; + public const int preStartBlinkInterval = 50; public const short keepAliveLed = 13; //Pin 13 is the built in Arduino pin we are using to physically show communication is OK public const int keepAliveInterval = 500; //how often to blink LED in msec } diff --git a/RoboticsGUI/GUI/Model/TeamGameModel.cs b/RoboticsGUI/GUI/Model/TeamGameModel.cs index d813ef6..e742971 100644 --- a/RoboticsGUI/GUI/Model/TeamGameModel.cs +++ b/RoboticsGUI/GUI/Model/TeamGameModel.cs @@ -60,6 +60,7 @@ private set private const int hoverTime = 30000; //hover time in total elapsed msecs before absolute end private const int obstacleTime = 105000; //obstacle time in total elapsed msecs before absolute end private const int platformTime = 150000; //platform time + private const double gameTimeTotalMS = Constants.gameTime * 1000; //game time in milliseconds //Time left after above times have elapsed private double startLeft; private double hoverLeft; @@ -71,8 +72,9 @@ private void OnTimeChange(object sender, PropertyChangedEventArgs e) double timeLeft = _countdown.TimeRemaining.TotalMilliseconds; switch (_state) { + case gameState.PreStart: case gameState.Idle: - if (timeLeft > 0 && timeLeft < _countdown.Timeout.TotalMilliseconds) + if (timeLeft > 0 && timeLeft < gameTimeTotalMS) { _state = gameState.Start; _teamControl.StartLed.Value = true; @@ -173,11 +175,11 @@ public void PreStart() _state = gameState.PreStart; _blinkTimer.Start(); } - else if (_state == gameState.PreStart) + else if (_state == gameState.PreStart) //toggle off { _blinkTimer.Stop(); _teamControl.StartLed.Value = false; - _state = gameState.Start; + _state = gameState.Idle; } } diff --git a/RoboticsGUI/GUI/View/MainWindowView.xaml b/RoboticsGUI/GUI/View/MainWindowView.xaml index 73ab50e..b7e4608 100644 --- a/RoboticsGUI/GUI/View/MainWindowView.xaml +++ b/RoboticsGUI/GUI/View/MainWindowView.xaml @@ -192,6 +192,7 @@