Fixed stopped and reaction time (Fix #9)
This commit is contained in:
parent
6037d29c4c
commit
7529095d6f
2 changed files with 44 additions and 42 deletions
|
@ -72,7 +72,9 @@ ScStw::StatusCode ScStwRace::start(bool asyncronous) {
|
|||
this->setState(PREPAIRING);
|
||||
|
||||
if(asyncronous) {
|
||||
QTimer::singleShot(1, [=](){this->playSoundsAndStartTimers();});
|
||||
QTimer::singleShot(1, [=]() {
|
||||
this->playSoundsAndStartTimers();
|
||||
});
|
||||
}
|
||||
else
|
||||
this->playSoundsAndStartTimers();
|
||||
|
@ -94,8 +96,8 @@ ScStw::StatusCode ScStwRace::stop() {
|
|||
|
||||
ScStw::StatusCode returnCode = ScStw::Success;
|
||||
|
||||
foreach(ScStwTimer *speedTimer, this->timers){
|
||||
if(!speedTimer->stop(timeOfStop) && speedTimer->getState() != ScStwTimer::DISABLED){
|
||||
foreach(ScStwTimer *speedTimer, this->timers) {
|
||||
if(!speedTimer->stop(timeOfStop) && speedTimer->getState() != ScStwTimer::DISABLED) {
|
||||
returnCode = ScStw::InternalErrorTimerOperationFailed;
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +123,7 @@ ScStw::StatusCode ScStwRace::reset() {
|
|||
|
||||
ScStw::StatusCode returnCode = ScStw::Success;
|
||||
|
||||
foreach(ScStwTimer *timer, this->timers){
|
||||
foreach(ScStwTimer *timer, this->timers) {
|
||||
if(!timer->reset() && timer->getState() != ScStwTimer::DISABLED && timer->getState() != ScStwTimer::IDLE) {
|
||||
returnCode = ScStw::InternalErrorTimerOperationFailed;
|
||||
}
|
||||
|
@ -143,7 +145,7 @@ ScStw::StatusCode ScStwRace::cancel() {
|
|||
|
||||
ScStw::StatusCode returnCode = ScStw::Success;
|
||||
|
||||
foreach(ScStwTimer *timer, this->timers){
|
||||
foreach(ScStwTimer *timer, this->timers) {
|
||||
if(!timer->cancel() && timer->getState() != ScStwTimer::DISABLED)
|
||||
returnCode = ScStw::InternalErrorTimerOperationFailed;
|
||||
}
|
||||
|
@ -351,8 +353,8 @@ bool ScStwRace::playSoundsAndStartTimers() {
|
|||
|
||||
// start all timers
|
||||
bool startOk = true;
|
||||
foreach(ScStwTimer *timer, this->timers){
|
||||
if(!timer->start(timeOfSoundPlaybackStart + 3100) && timer->getState() != ScStwTimer::DISABLED){
|
||||
foreach(ScStwTimer *timer, this->timers) {
|
||||
if(!timer->start(timeOfSoundPlaybackStart + 3000) && timer->getState() != ScStwTimer::DISABLED) {
|
||||
startOk = false;
|
||||
}
|
||||
}
|
||||
|
@ -439,8 +441,8 @@ void ScStwRace::handleTimerStateChange(ScStwTimer::TimerState newState) {
|
|||
bool raceIsOver = true;
|
||||
int incidentCount = 0;
|
||||
|
||||
foreach(ScStwTimer * timer, this->timers){
|
||||
if(timer->getState() < ScStwTimer::WAITING){
|
||||
foreach(ScStwTimer * timer, this->timers) {
|
||||
if(timer->getState() < ScStwTimer::WAITING) {
|
||||
// if the timer is not in stoped state
|
||||
raceIsOver = false;
|
||||
}
|
||||
|
@ -562,7 +564,7 @@ void ScStwRace::technicalIncident() {
|
|||
this->setState(INCIDENT);
|
||||
}
|
||||
|
||||
foreach(ScStwTimer *timer, this->timers){
|
||||
foreach(ScStwTimer *timer, this->timers) {
|
||||
if(raceIsRunning && timer->getReadyState() == ScStwTimer::ExtensionBatteryIsCritical)
|
||||
continue;
|
||||
else if(timer->getReadyState() == ScStwTimer::ExtensionIsNotConnected || timer->getReadyState() == ScStwTimer::ExtensionBatteryIsCritical)
|
||||
|
@ -818,7 +820,7 @@ int ScStwRace::getSoundDelaySetting(ScStwSoundPlayer::StartSound sound) {
|
|||
QVariantList ScStwRace::getTimerDetailList() {
|
||||
QVariantList tmpTimers;
|
||||
|
||||
foreach(ScStwTimer * timer, this->timers){
|
||||
foreach(ScStwTimer * timer, this->timers) {
|
||||
QVariantMap tmpTimer;
|
||||
tmpTimer.insert("id", this->timers.indexOf(timer));
|
||||
tmpTimer.insert("state", timer->getState());
|
||||
|
@ -890,7 +892,7 @@ void ScStwRace::setAutoRefreshTimerText(bool autoRefresh) {
|
|||
this->timerTextRefreshTimer->connect(
|
||||
this->timerTextRefreshTimer,
|
||||
&QTimer::timeout,
|
||||
[=]{
|
||||
[=] {
|
||||
// refresh timer text
|
||||
if(this->getState() == ScStwRace::RUNNING) {
|
||||
emit this->timersChanged();
|
||||
|
|
|
@ -53,7 +53,7 @@ bool ScStwTimer::start(double timeOfStart) {
|
|||
|
||||
if(timeOfStart - QDateTime::currentMSecsSinceEpoch() > 0) {
|
||||
this->setState(STARTING);
|
||||
QTimer::singleShot(timeOfStart - QDateTime::currentMSecsSinceEpoch(), [=](){
|
||||
QTimer::singleShot(timeOfStart - QDateTime::currentMSecsSinceEpoch(), [=]() {
|
||||
if(this->state == STARTING)
|
||||
this->setState(RUNNING);
|
||||
});
|
||||
|
@ -87,7 +87,7 @@ void ScStwTimer::handleClimberStart(double timeOfStart) {
|
|||
this->reactionTime = timeOfStart - this->startTime;
|
||||
qDebug() << "+ [INFO][TIMER] reaction time: " << this->reactionTime;
|
||||
|
||||
if(this->reactionTime <= 0 && this->reactionTime){
|
||||
if(this->reactionTime <= 100 && this->reactionTime) {
|
||||
qDebug() << "[INFO][TIMER] False Start detected: " << "start Time: " << startTime << " reactionTime: " << reactionTime;
|
||||
this->setState(FAILING);
|
||||
}
|
||||
|
@ -171,8 +171,8 @@ bool ScStwTimer::setResult(TimerState result) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ScStwTimer::reset(){
|
||||
if( this->state < WON || this->state == DISABLED ){
|
||||
bool ScStwTimer::reset() {
|
||||
if( this->state < WON || this->state == DISABLED ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ ScStwTimer::ReadyState ScStwTimer::getReadyState() {
|
|||
// --- helper functions ---
|
||||
// ------------------------
|
||||
|
||||
void ScStwTimer::setState(TimerState newState){
|
||||
void ScStwTimer::setState(TimerState newState) {
|
||||
if(this->state == DISABLED && newState != IDLE)
|
||||
return;
|
||||
|
||||
|
|
Reference in a new issue