minor fixes and cleanup
This commit is contained in:
parent
0020723364
commit
1f8fdab69f
4 changed files with 14 additions and 54 deletions
|
@ -20,7 +20,7 @@ import QtMultimedia 5.8
|
|||
import QtQuick.Window 2.2
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import com.itsblue.speedclimbingstopwatch 1.0
|
||||
import com.itsblue.speedclimbingstopwatch 2.0
|
||||
|
||||
|
||||
Popup {
|
||||
|
|
|
@ -507,6 +507,7 @@ Window {
|
|||
},
|
||||
|
||||
Transition {
|
||||
from: "STARTING"
|
||||
to: "RUNNING"
|
||||
//disable transitions for the RUNNING state
|
||||
}
|
||||
|
|
|
@ -256,67 +256,24 @@ void ClimbingRace::syncWithBaseStation() {
|
|||
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
default:
|
||||
{
|
||||
// case RUNNING
|
||||
if(speedTimers[0]->state != 2){
|
||||
speedTimers[0]->setState(SpeedTimer::RUNNING);
|
||||
}
|
||||
|
||||
// get current time
|
||||
tmpReply = this->baseConn->sendCommand(2001, 0);
|
||||
tmpReply = this->baseConn->sendCommand(2007);
|
||||
if(tmpReply["status"] != 200){
|
||||
//handle error!!
|
||||
qDebug() << "+ --- getting current time (timer 0) from basestation failed";
|
||||
qDebug() << "+ --- getting timers from basestation failed";
|
||||
this->baseStationSyncTimer->start();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
speedTimers[0]->stoppedTime = tmpReply["data"].toInt();
|
||||
}
|
||||
QVariantList timers = tmpReply["data"].toList();
|
||||
|
||||
// get current time
|
||||
tmpReply = this->baseConn->sendCommand(2003, 0);
|
||||
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();
|
||||
}
|
||||
speedTimers[0]->stoppedTime = timers[0].toMap()["currTime"].toDouble();
|
||||
speedTimers[0]->reactionTime = timers[0].toMap()["reactTime"].toDouble();
|
||||
|
||||
break;
|
||||
}
|
||||
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();
|
||||
speedTimers[0]->setState(SpeedTimer::timerState(timers[0].toMap()["state"].toInt()));
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -89,10 +89,12 @@ bool SpeedTimer::reset(bool force){
|
|||
}
|
||||
|
||||
void SpeedTimer::setState(timerState newState){
|
||||
if(this->state != newState){
|
||||
this->state = newState;
|
||||
qDebug() << "+--- timer state changed: " << newState;
|
||||
emit this->stateChanged(newState);
|
||||
}
|
||||
}
|
||||
|
||||
QString SpeedTimer::getState(){
|
||||
switch(state){
|
||||
|
|
Reference in a new issue