- began to redo layout
- fixed some issues in ScStwRace
This commit is contained in:
parent
6460714b62
commit
78b0b883d5
4 changed files with 35 additions and 26 deletions
|
@ -150,6 +150,8 @@ private slots:
|
|||
*/
|
||||
void handleTimerStop();
|
||||
|
||||
bool isStarting();
|
||||
|
||||
signals:
|
||||
void startTimers();
|
||||
void stopTimers(int type);
|
||||
|
|
|
@ -71,11 +71,6 @@ int ScStwRemoteMonitorRace::stop() {
|
|||
return 904;
|
||||
}
|
||||
|
||||
// type can be:
|
||||
// 0: stopp
|
||||
// 1: cancel
|
||||
// 2: fail (fase start)
|
||||
|
||||
qDebug() << "+ --- stopping race";
|
||||
|
||||
int returnCode = 900;
|
||||
|
@ -95,7 +90,7 @@ int ScStwRemoteMonitorRace::stop() {
|
|||
|
||||
int ScStwRemoteMonitorRace::reset() {
|
||||
|
||||
if(this->getState() != ScStwRace::STOPPED) {
|
||||
if(this->getState() != ScStwRace::STOPPED && this->getState() != ScStwRace::INCIDENT) {
|
||||
return 904;
|
||||
}
|
||||
|
||||
|
|
|
@ -175,9 +175,8 @@ int ScStwRace::reset() {
|
|||
}
|
||||
}
|
||||
|
||||
if(returnCode == ScStw::Success){
|
||||
if(returnCode == ScStw::Success)
|
||||
this->setState(IDLE);
|
||||
}
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
@ -188,12 +187,6 @@ int ScStwRace::cancel() {
|
|||
|
||||
qDebug() << "[INFO][RACE] cancelling race";
|
||||
|
||||
this->soundPlayer->cancel(this->soundVolume);
|
||||
this->nextActionTimer->stop();
|
||||
this->nextActionLoop->quit();
|
||||
this->climberReadyWaitLoop->quit();
|
||||
this->nextStartAction = None;
|
||||
|
||||
int returnCode = ScStw::Success;
|
||||
|
||||
foreach(ScStwTimer *timer, this->timers){
|
||||
|
@ -201,6 +194,17 @@ int ScStwRace::cancel() {
|
|||
returnCode = ScStw::InternalErrorTimerOperationFailed;
|
||||
}
|
||||
|
||||
if(returnCode != ScStw::Success)
|
||||
return returnCode;
|
||||
|
||||
this->setState(STOPPED);
|
||||
|
||||
this->soundPlayer->cancel(this->soundVolume);
|
||||
this->nextActionTimer->stop();
|
||||
this->nextActionLoop->quit();
|
||||
this->climberReadyWaitLoop->quit();
|
||||
this->nextStartAction = None;
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
|
@ -227,15 +231,13 @@ bool ScStwRace::playSoundsAndStartTimers() {
|
|||
|
||||
// The check if all timers are ready has already happened at this point
|
||||
if(!this->doDelayAndSoundOfStartAction(AtYourMarks)) {
|
||||
qDebug() << "At marks sound returned false!";
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if the start was cancelled
|
||||
if(this->state != PREPAIRING)
|
||||
if(!this->isStarting())
|
||||
return false;
|
||||
|
||||
qDebug() << "NOW IN WAITING";
|
||||
this->setState(WAITING);
|
||||
|
||||
// do climber readiness tests
|
||||
|
@ -265,7 +267,7 @@ bool ScStwRace::playSoundsAndStartTimers() {
|
|||
this->climberReadyWaitLoop->exec();
|
||||
|
||||
// check if the start was cancelled
|
||||
if(this->state != WAITING)
|
||||
if(!this->isStarting())
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -280,7 +282,7 @@ bool ScStwRace::playSoundsAndStartTimers() {
|
|||
this->climberReadyWaitLoop->exec();
|
||||
|
||||
// check if the start was cancelled
|
||||
if(this->state != WAITING)
|
||||
if(!this->isStarting())
|
||||
return false;
|
||||
|
||||
} while(this->nextActionTimer->remainingTime() > 0);
|
||||
|
@ -319,7 +321,7 @@ bool ScStwRace::playSoundsAndStartTimers() {
|
|||
}
|
||||
|
||||
// check if a false start occured
|
||||
if(this->state != STARTING)
|
||||
if(!this->isStarting())
|
||||
return true;
|
||||
|
||||
nextStartAction = None;
|
||||
|
@ -333,6 +335,9 @@ bool ScStwRace::playSoundsAndStartTimers() {
|
|||
}
|
||||
|
||||
bool ScStwRace::doDelayAndSoundOfStartAction(ScStwRace::StartAction action, double *timeOfSoundPlaybackStart) {
|
||||
if(!this->isStarting())
|
||||
return false;
|
||||
|
||||
if(this->startActionSettings.contains(action) && this->startActionSettings[action]["Enabled"].toBool()) {
|
||||
|
||||
this->nextStartAction = action;
|
||||
|
@ -351,6 +356,9 @@ bool ScStwRace::doDelayAndSoundOfStartAction(ScStwRace::StartAction action, doub
|
|||
}
|
||||
}
|
||||
|
||||
if(!this->isStarting())
|
||||
return false;
|
||||
|
||||
if(!this->soundPlayer->play(action, this->soundVolume, timeOfSoundPlaybackStart))
|
||||
return false;
|
||||
}
|
||||
|
@ -547,3 +555,7 @@ QVariantList ScStwRace::getTimerDetailList() {
|
|||
|
||||
return tmpTimers;
|
||||
}
|
||||
|
||||
bool ScStwRace::isStarting() {
|
||||
return this->state == PREPAIRING || this->state == WAITING || this->state == STARTING;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,9 @@ bool ScStwTimer::cancel() {
|
|||
if(!(this->state == IDLE || this->state == STARTING || this->state == RUNNING))
|
||||
return false;
|
||||
|
||||
this->stop(CancelStop, -1);
|
||||
qDebug() << "[INFO][TIMER] Timer was cancelled";
|
||||
|
||||
this->setState(CANCELLED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -125,11 +127,6 @@ bool ScStwTimer::stop(StopReason reason, double timeOfStop) {
|
|||
this->setState(FAILED);
|
||||
break;
|
||||
}
|
||||
case CancelStop: {
|
||||
qDebug() << "[INFO][TIMER] Timer was cancelled";
|
||||
this->setState(CANCELLED);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
|
@ -284,6 +281,9 @@ QString ScStwTimer::getText() {
|
|||
case ScStwTimer::CANCELLED:
|
||||
newText = "cancelled";
|
||||
break;
|
||||
case ScStwTimer::INCIDENT:
|
||||
newText = "Technical incident!";
|
||||
break;
|
||||
case ScStwTimer::DISABLED:
|
||||
newText = "---";
|
||||
break;
|
||||
|
|
Reference in a new issue