minor fixes and cleanup

This commit is contained in:
Dorian Zedler 2019-03-09 15:06:48 +01:00
parent 0020723364
commit 1f8fdab69f
4 changed files with 14 additions and 54 deletions

View file

@ -20,7 +20,7 @@ import QtMultimedia 5.8
import QtQuick.Window 2.2 import QtQuick.Window 2.2
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import com.itsblue.speedclimbingstopwatch 1.0 import com.itsblue.speedclimbingstopwatch 2.0
Popup { Popup {

View file

@ -507,6 +507,7 @@ Window {
}, },
Transition { Transition {
from: "STARTING"
to: "RUNNING" to: "RUNNING"
//disable transitions for the RUNNING state //disable transitions for the RUNNING state
} }

View file

@ -256,67 +256,24 @@ void ClimbingRace::syncWithBaseStation() {
break; break;
} }
case 2: default:
{ {
// case RUNNING
if(speedTimers[0]->state != 2){
speedTimers[0]->setState(SpeedTimer::RUNNING);
}
// get current time // get current time
tmpReply = this->baseConn->sendCommand(2001, 0); tmpReply = this->baseConn->sendCommand(2007);
if(tmpReply["status"] != 200){ if(tmpReply["status"] != 200){
//handle error!! //handle error!!
qDebug() << "+ --- getting current time (timer 0) from basestation failed"; qDebug() << "+ --- getting timers from basestation failed";
this->baseStationSyncTimer->start(); this->baseStationSyncTimer->start();
return; return;
} }
else { else {
speedTimers[0]->stoppedTime = tmpReply["data"].toInt(); QVariantList timers = tmpReply["data"].toList();
}
// get current time speedTimers[0]->stoppedTime = timers[0].toMap()["currTime"].toDouble();
tmpReply = this->baseConn->sendCommand(2003, 0); speedTimers[0]->reactionTime = timers[0].toMap()["reactTime"].toDouble();
if(tmpReply["status"] != 200){
//handle error!!
qDebug() << "+ --- getting reaction time (timer 0) from basestation failed";
this->baseStationSyncTimer->start();
return;
}
else {
speedTimers[0]->reactionTime = tmpReply["data"].toInt();
}
break; speedTimers[0]->setState(SpeedTimer::timerState(timers[0].toMap()["state"].toInt()));
}
case 3:
{
// case STOPPED
if(speedTimers[0]->state != 3){
speedTimers[0]->setState(SpeedTimer::STOPPED);
}
// get current time
tmpReply = this->baseConn->sendCommand(2001, 0);
if(tmpReply["status"] != 200){
//handle error!!
qDebug() << "+ --- getting current time (timer 0) from basestation failed";
return;
}
else {
speedTimers[0]->stoppedTime = tmpReply["data"].toInt();
}
// get current time
tmpReply = this->baseConn->sendCommand(2003, 0);
if(tmpReply["status"] != 200){
//handle error!!
qDebug() << "+ --- getting current time (timer 0) from basestation failed";
this->baseStationSyncTimer->start();
return;
}
else {
speedTimers[0]->reactionTime = tmpReply["data"].toInt();
} }
break; break;

View file

@ -89,9 +89,11 @@ bool SpeedTimer::reset(bool force){
} }
void SpeedTimer::setState(timerState newState){ void SpeedTimer::setState(timerState newState){
this->state = newState; if(this->state != newState){
qDebug() << "+--- timer state changed: " << newState; this->state = newState;
emit this->stateChanged(newState); qDebug() << "+--- timer state changed: " << newState;
emit this->stateChanged(newState);
}
} }
QString SpeedTimer::getState(){ QString SpeedTimer::getState(){