fixed problems from rebase
This commit is contained in:
parent
2cfc40444e
commit
aff108ee90
3 changed files with 43 additions and 32 deletions
|
@ -46,21 +46,11 @@ class ScStw : public QObject {
|
|||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief The RaceState enum contains all states a race can have
|
||||
*/
|
||||
<<<<<<< HEAD:ScStwLibraries/ScStw.hpp
|
||||
enum RaceState { IDLE, STARTING, WAITING, RUNNING, STOPPED };
|
||||
Q_ENUM(RaceState)
|
||||
|
||||
/**
|
||||
* @brief The SignalKey enum contains all signal keys a client can subscribe to
|
||||
*
|
||||
* @see ScStw::signalKeyFromInt()
|
||||
*/
|
||||
=======
|
||||
|
||||
>>>>>>> - some changes to file structure:ScStwLibraries/headers/ScStw.hpp
|
||||
enum SignalKey {
|
||||
InvalidSignal = -1,
|
||||
RaceStateChanged = 9000,
|
||||
|
@ -70,13 +60,6 @@ public:
|
|||
};
|
||||
Q_ENUM(SignalKey)
|
||||
|
||||
<<<<<<< HEAD:ScStwLibraries/ScStw.hpp
|
||||
/**
|
||||
* @brief The NextStartAction enum contains all action that occur before a race is started
|
||||
*/
|
||||
enum NextStartAction { AtYourMarks, Ready, Start, None };
|
||||
Q_ENUM(NextStartAction)
|
||||
|
||||
/**
|
||||
* @brief The BaseStationSetting enum contains all settings of the base station that can be changed by a client
|
||||
*
|
||||
|
@ -85,8 +68,6 @@ public:
|
|||
* @see ScStw::baseStationSettingFromString()
|
||||
* @see ScStw::baseStationSettings
|
||||
*/
|
||||
=======
|
||||
>>>>>>> - some changes to file structure:ScStwLibraries/headers/ScStw.hpp
|
||||
enum BaseStationSetting {
|
||||
InvalidSetting = -1,
|
||||
ReadySoundEnableSetting,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QObject>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include "ScStw.hpp"
|
||||
|
||||
class ScStwTimer : public QObject
|
||||
|
@ -33,6 +34,7 @@ public slots:
|
|||
|
||||
// --- main functionality ---
|
||||
bool start();
|
||||
bool start(double timeOfStart);
|
||||
bool cancel();
|
||||
bool stop();
|
||||
bool stop(TimerState);
|
||||
|
@ -42,11 +44,11 @@ public slots:
|
|||
TimerState getState();
|
||||
double getCurrentTime();
|
||||
double getReactionTime();
|
||||
void refreshDisableStatus();
|
||||
void setDisabled(bool disabled);
|
||||
|
||||
protected slots:
|
||||
|
||||
void handleClimberStart(double timeOfStart);
|
||||
bool stop(StopReason reason);
|
||||
|
||||
// --- helper functions ---
|
||||
|
@ -57,6 +59,7 @@ signals:
|
|||
void startCanceled(bool falseStart);
|
||||
void reactionTimeChanged();
|
||||
void stopRequested();
|
||||
void requestEnableChange(ScStwTimer* timer);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -7,18 +7,36 @@ ScStwTimer::ScStwTimer(QObject *parent) : QObject(parent)
|
|||
this->stopTime = 0;
|
||||
this->stoppedTime = 0;
|
||||
this->reactionTime = 0;
|
||||
|
||||
this->state = IDLE;
|
||||
}
|
||||
|
||||
bool ScStwTimer::start() {
|
||||
switch (this->state) {
|
||||
case STARTING: {
|
||||
// in case of STARTING, start the race!
|
||||
return this->start(QDateTime::currentMSecsSinceEpoch());
|
||||
}
|
||||
|
||||
this->startTime = QDateTime::currentMSecsSinceEpoch();
|
||||
bool ScStwTimer::start(double timeOfStart) {
|
||||
switch (this->state) {
|
||||
case IDLE: {
|
||||
// in case of IDLE, start the race!
|
||||
|
||||
this->startTime = timeOfStart;
|
||||
this->stopTime = 0;
|
||||
this->stoppedTime = 0;
|
||||
|
||||
this->setState(RUNNING);
|
||||
if(timeOfStart - QDateTime::currentMSecsSinceEpoch() > 0) {
|
||||
this->setState(STARTING);
|
||||
QTimer::singleShot(timeOfStart - QDateTime::currentMSecsSinceEpoch(), [=](){
|
||||
if(this->state == STARTING)
|
||||
this->setState(RUNNING);
|
||||
});
|
||||
QTimer::singleShot(timeOfStart - QDateTime::currentMSecsSinceEpoch() - 1000, [=](){
|
||||
//this->handleClimberStart(QDateTime::currentMSecsSinceEpoch());
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
this->setState(RUNNING);
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
|
@ -28,8 +46,20 @@ bool ScStwTimer::start() {
|
|||
}
|
||||
}
|
||||
|
||||
void ScStwTimer::handleClimberStart(double timeOfStart) {
|
||||
this->reactionTime = timeOfStart - this->startTime;
|
||||
qDebug() << "+ [INFO][TIMER] reaction time: " << this->reactionTime;
|
||||
|
||||
if(this->reactionTime <= 0){
|
||||
this->stop(FailStop);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: check if necessary: emit this->reactionTimeChanged();
|
||||
}
|
||||
|
||||
bool ScStwTimer::cancel() {
|
||||
if(!(this->state == STARTING || this->state == RUNNING))
|
||||
if(!(this->state == IDLE || this->state == STARTING || this->state == RUNNING))
|
||||
return false;
|
||||
|
||||
this->setState(CANCELLED);
|
||||
|
@ -37,7 +67,7 @@ bool ScStwTimer::cancel() {
|
|||
}
|
||||
|
||||
bool ScStwTimer::stop() {
|
||||
this->stop(ManualStop);
|
||||
return this->stop(ManualStop);
|
||||
}
|
||||
|
||||
bool ScStwTimer::stop(TimerState result) {
|
||||
|
@ -76,12 +106,9 @@ bool ScStwTimer::stop(StopReason reason) {
|
|||
}
|
||||
case FailStop: {
|
||||
this->stoppedTime = 0;
|
||||
//qDebug() << "+ [INFO][TIMER] Stopped: " << "start Time: " << startTime << " stopTime: " << stopTime << " stoppedTime: " << stoppedTime << " reactionTime: " << reactionTime;
|
||||
|
||||
if(this->state == RUNNING){
|
||||
qDebug() << "+ [INFO][TIMER] False Start detected, step 2: " << "start Time: " << startTime << " startpadTriggerTime: " << startPadTriggerTime << " reactionTime: " << reactionTime;
|
||||
this->setState(FAILED);
|
||||
}
|
||||
qDebug() << "+ [INFO][TIMER] False Start detected: " << "start Time: " << startTime << " reactionTime: " << reactionTime;
|
||||
this->setState(FAILED);
|
||||
|
||||
emit startCanceled(true);
|
||||
|
||||
|
|
Reference in a new issue