added command to disable and enable a timer

This commit is contained in:
Dorian Zedler 2020-10-05 22:21:33 +02:00
parent ce22916e92
commit 9bd3e53fae
Signed by: dorian
GPG Key ID: D3B255CB8BC7CD37
3 changed files with 16 additions and 0 deletions

View File

@ -81,6 +81,7 @@ public:
StopRaceCommand = 1001,
ResetRaceCommand = 1002,
CancelRaceCommand = 1003,
SetTimerDisabled = 1004,
GetRaceStateCommand = 2000,
GetRaceDetailsCommand = 2001,
@ -120,6 +121,7 @@ public:
CurrentStateNotVaildForOperationError = 403,
AccessDeniedError = 401,
NoSessionActiveError = 408,
ItemNotFoundError = 409,
UpdateFailedError = 500,

View File

@ -117,6 +117,8 @@ public slots:
virtual ScStw::StatusCode reset();
virtual ScStw::StatusCode cancel();
virtual ScStw::StatusCode setTimerDisabled(int id, bool disabled);
virtual bool addTimer(ScStwTimer *timer);
// getters

View File

@ -153,6 +153,18 @@ ScStw::StatusCode ScStwRace::cancel() {
return returnCode;
}
ScStw::StatusCode ScStwRace::setTimerDisabled(int timerId, bool disabled) {
if(this->state != IDLE && this->state != WAITING)
return ScStw::CurrentStateNotVaildForOperationError;
if(timerId < 0 || timerId - 1 > this->timers.length())
return ScStw::ItemNotFoundError;
this->timers[timerId]->setDisabled(disabled);
return ScStw::Success;
}
void ScStwRace::handleTimerReadyStateChange(ScStwTimer::ReadyState readyState) {
if(!this->competitionMode || this->state == IDLE || this->state == STOPPED || this->state == INCIDENT )