diff --git a/qml/ErrorDialog.qml b/qml/ErrorDialog.qml index 916ed7c..ef7f328 100644 --- a/qml/ErrorDialog.qml +++ b/qml/ErrorDialog.qml @@ -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 { diff --git a/qml/main.qml b/qml/main.qml index d0afb9e..dd319d8 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -507,6 +507,7 @@ Window { }, Transition { + from: "STARTING" to: "RUNNING" //disable transitions for the RUNNING state } diff --git a/sources/climbingrace.cpp b/sources/climbingrace.cpp index 429910f..71eaee8 100644 --- a/sources/climbingrace.cpp +++ b/sources/climbingrace.cpp @@ -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; diff --git a/sources/speedtimer.cpp b/sources/speedtimer.cpp index 6dd043a..8493505 100644 --- a/sources/speedtimer.cpp +++ b/sources/speedtimer.cpp @@ -89,9 +89,11 @@ bool SpeedTimer::reset(bool force){ } void SpeedTimer::setState(timerState newState){ - this->state = newState; - qDebug() << "+--- timer state changed: " << newState; - emit this->stateChanged(newState); + if(this->state != newState){ + this->state = newState; + qDebug() << "+--- timer state changed: " << newState; + emit this->stateChanged(newState); + } } QString SpeedTimer::getState(){