added wildcard state

This commit is contained in:
Dorian Zedler 2020-10-04 15:22:43 +02:00
parent ec6723af75
commit b8e8f45222
Signed by: dorian
GPG key ID: D3B255CB8BC7CD37
3 changed files with 24 additions and 4 deletions

View file

@ -86,6 +86,7 @@ public:
WON, /*!< Timer has won */
LOST, /*!< Timer has lost */
FAILED, /*!< A false start occured */
WILDCARD, /*!< The opponent has done a false start */
CANCELLED, /*!< Timer was cancelled */
INCIDENT, /*!< There was a technical incident (most likely a disconnected extension) */
DISABLED /*!< Timer is disabled */
@ -332,6 +333,15 @@ protected slots:
*/
void technicalIncident();
/*!
* \brief Function to set the timer into WILDCARD state
*
* Only works when the timer is in STARTING state.
*
* \return false if not in STARTING state
*/
bool wildcard();
signals:
/*!

View file

@ -248,10 +248,11 @@ int ScStwRace::handleFalseStart() {
int returnCode = ScStw::Success;
// cancel all running timers
// set all running timers to wildcard
foreach(ScStwTimer *timer, this->timers) {
if(timer->getState() != ScStwTimer::FAILED && !timer->cancel() && timer->getState() != ScStwTimer::DISABLED)
returnCode = ScStw::InternalErrorTimerOperationFailed;
if(timer->getState() != ScStwTimer::FAILED && timer->getState() != ScStwTimer::DISABLED)
if(!timer->wildcard())
returnCode = ScStw::InternalErrorTimerOperationFailed;
}
this->setState(STOPPED);

View file

@ -71,6 +71,15 @@ void ScStwTimer::technicalIncident() {
this->setState(INCIDENT);
}
bool ScStwTimer::wildcard() {
if(this->state != STARTING)
return false;
this->setState(WILDCARD);
return true;
}
void ScStwTimer::handleClimberStart(double timeOfStart) {
this->reactionTime = timeOfStart - this->startTime;
qDebug() << "+ [INFO][TIMER] reaction time: " << this->reactionTime;
@ -109,7 +118,7 @@ bool ScStwTimer::stop(StopReason reason) {
}
bool ScStwTimer::stop(StopReason reason, double timeOfStop) {
if(this->state != STARTING && this->state != RUNNING && this->state != WAITING){
if(this->state != STARTING && this->state != WILDCARD && this->state != RUNNING && this->state != WAITING){
return false;
}