From 8be3541bb5dcc1ee79f64589b0134cc1d0abdf64 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Fri, 2 Oct 2020 19:56:08 +0200 Subject: [PATCH] some fixes in race and settings --- ScStwLibraries/ScStwLibraries.pri | 10 ++- .../headers/client/scstwremoterace.h | 7 +- .../headers/client/scstwremotetimer.h | 80 +++++++++++++++++++ ScStwLibraries/headers/scstwlibraries.h | 2 +- ScStwLibraries/headers/scstwrace.h | 2 + ScStwLibraries/headers/scstwsetting.h | 10 ++- ScStwLibraries/headers/scstwsettings.h | 23 +----- ScStwLibraries/headers/scstwtimer.h | 60 +------------- .../sources/client/scstwremoterace.cpp | 49 +++++++----- .../sources/client/scstwremotesettings.cpp | 2 + .../sources/client/scstwremotetimer.cpp | 41 ++++++++++ ScStwLibraries/sources/scstwrace.cpp | 2 + ScStwLibraries/sources/scstwsetting.cpp | 16 +++- ScStwLibraries/sources/scstwsettings.cpp | 2 +- ScStwLibraries/sources/scstwtimer.cpp | 45 +---------- 15 files changed, 192 insertions(+), 159 deletions(-) create mode 100644 ScStwLibraries/headers/client/scstwremotetimer.h create mode 100644 ScStwLibraries/sources/client/scstwremotetimer.cpp diff --git a/ScStwLibraries/ScStwLibraries.pri b/ScStwLibraries/ScStwLibraries.pri index 903b9bc..28d1ab7 100644 --- a/ScStwLibraries/ScStwLibraries.pri +++ b/ScStwLibraries/ScStwLibraries.pri @@ -39,13 +39,15 @@ HEADERS += \ ScStwLibraries_ClientLibs { SOURCES += \ $$PWD/sources/client/scstwclient.cpp \ - $$PWD/sources/client/scstwremotesettings.cpp \ - $$PWD/sources/client/scstwremotemonitorrace.cpp + $$PWD/sources/client/scstwremoterace.cpp \ + $$PWD/sources/client/scstwremotetimer.cpp \ + $$PWD/sources/client/scstwremotesettings.cpp HEADERS += \ $$PWD/headers/client/scstwclient.h \ - $$PWD/headers/client/scstwremotesettings.h \ - $$PWD/headers/client/scstwremotemonitorrace.h + $$PWD/headers/client/scstwremoterace.h \ + $$PWD/headers/client/scstwremotetimer.h \ + $$PWD/headers/client/scstwremotesettings.h INCLUDEPATH += $$PWD/headers/client } diff --git a/ScStwLibraries/headers/client/scstwremoterace.h b/ScStwLibraries/headers/client/scstwremoterace.h index ef134e7..42c68dc 100644 --- a/ScStwLibraries/headers/client/scstwremoterace.h +++ b/ScStwLibraries/headers/client/scstwremoterace.h @@ -22,12 +22,13 @@ #include #include "scstwrace.h" #include "scstwclient.h" +#include "scstwremotetimer.h" -class ScStwRemoteMonitorRace : public ScStwRace +class ScStwRemoteRace : public ScStwRace { Q_OBJECT public: - ScStwRemoteMonitorRace(ScStwClient *monitorClient, QObject *parent = nullptr); + ScStwRemoteRace(ScStwClient *monitorClient, QObject *parent = nullptr); protected: double currentStartTotalDelay; @@ -36,8 +37,10 @@ protected: private: ScStwClient *scStwClient; + QList remoteTimers; public slots: + ScStw::StatusCode start(bool); ScStw::StatusCode start(); ScStw::StatusCode cancel(); ScStw::StatusCode stop(); diff --git a/ScStwLibraries/headers/client/scstwremotetimer.h b/ScStwLibraries/headers/client/scstwremotetimer.h new file mode 100644 index 0000000..71d5992 --- /dev/null +++ b/ScStwLibraries/headers/client/scstwremotetimer.h @@ -0,0 +1,80 @@ +#ifndef SCSTWREMOTETIMER_H +#define SCSTWREMOTETIMER_H + +#include +#include + +class ScStwRemoteTimer : public ScStwTimer +{ + Q_OBJECT +public: + ScStwRemoteTimer(QObject *parent = nullptr); + + friend class ScStwRemoteRace; + +private: + ScStwTimer::ReadyState readyState; + +public slots: + /*! + * \brief Function to get the current ready status of a timer + * \return The current ready status + */ + virtual ScStwTimer::ReadyState getReadyState(); + +protected slots: + /*! + * \brief Function to dircetly change the start time + * + * Only works when directControlEnabled is set to true! + * + * \param startTime the time to change to + * \return false when directControlEnabled is set to false and the startTime was therefore not modified, true otherwise + */ + void setStartTime(double startTime); + + /*! + * \brief Function to dircetly change the stop time + * + * Only works when directControlEnabled is set to true! + * + * \param stopTime the time to change to + * \return false when directControlEnabled is set to false and the stopTime was therefore not modified, true otherwise + */ + void setStopTime(double stopTime); + + /*! + * \brief Function to dircetly change the rection time + * + * Only works when directControlEnabled is set to true! + * + * \param reactionTime the time to change to + * \return false when directControlEnabled is set to false and the reactionTime was therefore not modified, true otherwise + */ + void setReactionTime(double rectionTime); + + /*! + * \brief Function to dircetly change the letter + * + * Only works when directControlEnabled is set to true! + * + * \param newLetter the letter to change to + * \return false when directControlEnabled is set to false and the letter was therefore not modified, true otherwise + */ + void setLetter(QString newLetter); + + void setReadyState(ScStwTimer::ReadyState); + + /*! + * \brief Function to change the state of the timer + * + * Doing this will emit the ScStwTimer::stateChanged() signal (only if the new state differs from the current one) + * + * \param newState The new state + */ + void setState(TimerState newState); + + +}; + +#endif // SCSTWREMOTETIMER_H diff --git a/ScStwLibraries/headers/scstwlibraries.h b/ScStwLibraries/headers/scstwlibraries.h index e7c495e..1965a70 100644 --- a/ScStwLibraries/headers/scstwlibraries.h +++ b/ScStwLibraries/headers/scstwlibraries.h @@ -34,7 +34,7 @@ #include "scstwsettings.h" #ifdef ScStwLibraries_ClientLibs #include "scstwsetting.h" -#include "scstwremotemonitorrace.h" +#include "scstwremoterace.h" #include "scstwclient.h" #endif diff --git a/ScStwLibraries/headers/scstwrace.h b/ScStwLibraries/headers/scstwrace.h index 80906da..e3edea4 100644 --- a/ScStwLibraries/headers/scstwrace.h +++ b/ScStwLibraries/headers/scstwrace.h @@ -52,6 +52,7 @@ class ScStwRace : public QObject Q_PROPERTY(RaceState state READ getState NOTIFY stateChanged) Q_PROPERTY(QVariantList timers READ getTimerDetailList NOTIFY timersChanged) Q_PROPERTY(QVariantList currentStartDelay READ getCurrentStartDelay NOTIFY currentStartDelayChanged) + Q_PROPERTY(bool isReadyForNextState READ isReadyForNextState NOTIFY isReadyForNextStateChanged) public: explicit ScStwRace(QObject *parent = nullptr); @@ -160,6 +161,7 @@ signals: void stateChanged(RaceState state); void currentStartDelayChanged(); void timersChanged(); + void isReadyForNextStateChanged(); }; diff --git a/ScStwLibraries/headers/scstwsetting.h b/ScStwLibraries/headers/scstwsetting.h index 72818b7..bd57cd7 100644 --- a/ScStwLibraries/headers/scstwsetting.h +++ b/ScStwLibraries/headers/scstwsetting.h @@ -22,23 +22,25 @@ #include #include +class ScStwSettings; + class ScStwSetting : public QObject { Q_OBJECT Q_PROPERTY(QVariant value READ getValue WRITE setValue NOTIFY valueChanged) protected: - explicit ScStwSetting(QObject *parent = nullptr); + explicit ScStwSetting(int key, int keyLevel, ScStwSettings*scStwSettings, QObject *parent); + + friend class ScStwSettings; int key; int keyLevel; bool hasToReload; - virtual bool writeSetting(int, int, QVariant) = 0; - virtual QVariant readSetting(int, int) = 0; - private: QVariant valueCache; + ScStwSettings *scStwSettings; public slots: QVariant getValue(); diff --git a/ScStwLibraries/headers/scstwsettings.h b/ScStwLibraries/headers/scstwsettings.h index 19026b8..282a603 100644 --- a/ScStwLibraries/headers/scstwsettings.h +++ b/ScStwLibraries/headers/scstwsettings.h @@ -109,30 +109,9 @@ private: bool loadSettingsFromFile(); - class ScStwSettingInternal: public ScStwSetting { - public: - ScStwSettingInternal(int key, int keyLevel, ScStwSettings*scStwSettings, QObject *parent):ScStwSetting(parent) { - this->scStwSettings = scStwSettings; - connect(this->scStwSettings, &ScStwSettings::settingChanged, this, &ScStwSettingInternal::handleSettingChange); - this->key = key; - this->keyLevel = keyLevel; - this->handleSettingChange(-1, 0, QVariant()); - } - protected: - ScStwSettings *scStwSettings; - - bool writeSetting(int key, int keyLevel, QVariant value) { - return this->scStwSettings->writeSetting(key, keyLevel, value); - } - - QVariant readSetting(int key, int keyLevel) { - return this->scStwSettings->readSetting(key, keyLevel); - } - }; - QMap keyToStringConverters; QMap keyToTypeConverters; - QMap> internalSettingHandlers; + QMap> internalSettingHandlers; private slots: bool writeSettingsToFile(); diff --git a/ScStwLibraries/headers/scstwtimer.h b/ScStwLibraries/headers/scstwtimer.h index 25e9fda..a8a94a0 100644 --- a/ScStwLibraries/headers/scstwtimer.h +++ b/ScStwLibraries/headers/scstwtimer.h @@ -71,10 +71,9 @@ public: * \param directControlEnabled Defines if protected properties (startTimer, stopTime, reactionTime and state) can be directly set from outside. * \param letter the letter of the timer (only first char will be used!) */ - explicit ScStwTimer(QObject *parent = nullptr, bool directControlEnabled = false, QString letter = "" ); + explicit ScStwTimer(QObject *parent = nullptr, QString letter = "" ); friend class ScStwRace; - friend class ScStwRemoteRace; /*! * \brief The TimerState enum contains all state the timer can be in @@ -137,11 +136,6 @@ protected: */ double reactionTime; - /*! - * \brief Defines if protected properties (startTimer, stopTime, reactionTime and state) can be directly set from outside. - */ - bool directControlEnabled; - /*! * \brief The letter (eg. "A" or "B") of the Timer (only one char) */ @@ -267,58 +261,6 @@ public slots: */ void setDisabled(bool disabled); - /*! - * \brief Function to change the state of the timer - * - * Only works when directControlEnabled is set to true! - * Doing this will emit the ScStwTimer::stateChanged() signal (only if the new state differs from the current one) - * - * \param newState The new state - * \param force whether to force the state change (just to distinguish between protected and public function) - * \return false when directControlEnabled or force is set to false and the startTime was therefore not modified, true otherwise - */ - bool setState(TimerState newState, bool force); - - /*! - * \brief Function to dircetly change the start time - * - * Only works when directControlEnabled is set to true! - * - * \param startTime the time to change to - * \return false when directControlEnabled is set to false and the startTime was therefore not modified, true otherwise - */ - bool setStartTime(double startTime); - - /*! - * \brief Function to dircetly change the stop time - * - * Only works when directControlEnabled is set to true! - * - * \param stopTime the time to change to - * \return false when directControlEnabled is set to false and the stopTime was therefore not modified, true otherwise - */ - bool setStopTime(double stopTime); - - /*! - * \brief Function to dircetly change the rection time - * - * Only works when directControlEnabled is set to true! - * - * \param reactionTime the time to change to - * \return false when directControlEnabled is set to false and the reactionTime was therefore not modified, true otherwise - */ - bool setReactionTime(double rectionTime); - - /*! - * \brief Function to dircetly change the letter - * - * Only works when directControlEnabled is set to true! - * - * \param newLetter the letter to change to - * \return false when directControlEnabled is set to false and the letter was therefore not modified, true otherwise - */ - bool setLetter(QString newLetter); - /*! * \brief Function to check if the timer currently wants to be disabled * \return true or false diff --git a/ScStwLibraries/sources/client/scstwremoterace.cpp b/ScStwLibraries/sources/client/scstwremoterace.cpp index 210ce9d..13f94ba 100644 --- a/ScStwLibraries/sources/client/scstwremoterace.cpp +++ b/ScStwLibraries/sources/client/scstwremoterace.cpp @@ -16,9 +16,9 @@ ** along with this program. If not, see . ****************************************************************************/ -#include "scstwremotemonitorrace.h" +#include "scstwremoterace.h" -ScStwRemoteMonitorRace::ScStwRemoteMonitorRace(ScStwClient *monitorClient, QObject *parent) : ScStwRace(parent) +ScStwRemoteRace::ScStwRemoteRace(ScStwClient *monitorClient, QObject *parent) : ScStwRace(parent) { this->currentlyWaitingForClimbers = false; @@ -28,15 +28,19 @@ ScStwRemoteMonitorRace::ScStwRemoteMonitorRace(ScStwClient *monitorClient, QObje this->scStwClient->addSignalSubscription(ScStw::TimersChanged); this->scStwClient->addSignalSubscription(ScStw::CurrentStartDelayChanged); - connect(this->scStwClient, &ScStwClient::stateChanged, this, &ScStwRemoteMonitorRace::handleClientStateChanged); - connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteMonitorRace::handleBaseStationSignal); + connect(this->scStwClient, &ScStwClient::stateChanged, this, &ScStwRemoteRace::handleClientStateChanged); + connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteRace::handleBaseStationSignal); } // -------------------------- // --- Main Functionality --- // -------------------------- -ScStw::StatusCode ScStwRemoteMonitorRace::start() { +ScStw::StatusCode ScStwRemoteRace::start(bool) { + return this->start(); +} + +ScStw::StatusCode ScStwRemoteRace::start() { if(this->getState() != ScStwRace::IDLE && this->getState() != ScStwRace::WAITING) return ScStw::CurrentStateNotVaildForOperationError; @@ -47,7 +51,7 @@ ScStw::StatusCode ScStwRemoteMonitorRace::start() { return ScStw::StatusCode(reply["status"].toInt()); } -ScStw::StatusCode ScStwRemoteMonitorRace::cancel() { +ScStw::StatusCode ScStwRemoteRace::cancel() { if(this->getState() != PREPAIRING && this->getState() != WAITING && this->getState() != STARTING && this->getState() != RUNNING) return ScStw::CurrentStateNotVaildForOperationError; @@ -58,7 +62,7 @@ ScStw::StatusCode ScStwRemoteMonitorRace::cancel() { return ScStw::StatusCode(reply["status"].toInt()); } -ScStw::StatusCode ScStwRemoteMonitorRace::stop() { +ScStw::StatusCode ScStwRemoteRace::stop() { if(this->getState() != ScStwRace::RUNNING && this->getState() != ScStwRace::STARTING) return ScStw::CurrentStateNotVaildForOperationError; @@ -69,7 +73,7 @@ ScStw::StatusCode ScStwRemoteMonitorRace::stop() { return ScStw::StatusCode(reply["status"].toInt()); } -ScStw::StatusCode ScStwRemoteMonitorRace::reset() { +ScStw::StatusCode ScStwRemoteRace::reset() { if(this->getState() != ScStwRace::STOPPED && this->getState() != ScStwRace::INCIDENT) return ScStw::CurrentStateNotVaildForOperationError; @@ -85,7 +89,7 @@ ScStw::StatusCode ScStwRemoteMonitorRace::reset() { // --- Base Station sync --- // ------------------------- -void ScStwRemoteMonitorRace::handleClientStateChanged() { +void ScStwRemoteRace::handleClientStateChanged() { // TODO switch (this->scStwClient->getState()) { case ScStwClient::CONNECTED: @@ -105,7 +109,7 @@ void ScStwRemoteMonitorRace::handleClientStateChanged() { * * @param data */ -void ScStwRemoteMonitorRace::handleBaseStationSignal(ScStw::SignalKey key, QVariant data) { +void ScStwRemoteRace::handleBaseStationSignal(ScStw::SignalKey key, QVariant data) { //qDebug() << "got signal: " << data; switch (key) { case ScStw::RaceStateChanged: @@ -141,7 +145,7 @@ void ScStwRemoteMonitorRace::handleBaseStationSignal(ScStw::SignalKey key, QVari } } -bool ScStwRemoteMonitorRace::refreshRemoteTimers(QVariantList remoteTimers) { +bool ScStwRemoteRace::refreshRemoteTimers(QVariantList remoteTimers) { if(remoteTimers.length() != this->timers.length()){ // local timers are out of sync @@ -155,8 +159,9 @@ bool ScStwRemoteMonitorRace::refreshRemoteTimers(QVariantList remoteTimers) { foreach(QVariant remoteTimer, remoteTimers){ // create a local timer for each remote timer - ScStwTimer * timer = new ScStwTimer(this, true); + ScStwRemoteTimer * timer = new ScStwRemoteTimer(this); this->timers.append(timer); + this->remoteTimers.append(timer); connect(timer, &ScStwTimer::stateChanged, this, &ScStwRace::timersChanged); connect(timer, &ScStwTimer::reactionTimeChanged, this, &ScStwRace::timersChanged); } @@ -164,30 +169,34 @@ bool ScStwRemoteMonitorRace::refreshRemoteTimers(QVariantList remoteTimers) { foreach(QVariant remoteTimer, remoteTimers){ int currId = remoteTimer.toMap()["id"].toInt(); + ScStwTimer::TimerState newState = ScStwTimer::TimerState(remoteTimer.toMap()["state"].toInt()); + + qDebug() << "refreshing timers: id: " << currId << " state: " << newState << " readyState: " << remoteTimer.toMap()["readyState"].toInt(); + double currentMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch(); - this->timers[currId]->setStartTime(currentMSecsSinceEpoch - remoteTimer.toMap()["currentTime"].toDouble()); + this->remoteTimers[currId]->setStartTime(currentMSecsSinceEpoch - remoteTimer.toMap()["currentTime"].toDouble()); if(newState >= ScStwTimer::WAITING) - this->timers[currId]->setStopTime(currentMSecsSinceEpoch); + this->remoteTimers[currId]->setStopTime(currentMSecsSinceEpoch); - this->timers[currId]->setReactionTime(remoteTimer.toMap()["reactionTime"].toDouble()); + this->remoteTimers[currId]->setReactionTime(remoteTimer.toMap()["reactionTime"].toDouble()); + this->remoteTimers[currId]->setLetter(remoteTimer.toMap()["letter"].toString()); + this->remoteTimers[currId]->setReadyState(ScStwTimer::ReadyState(remoteTimer.toMap()["readyState"].toInt())); - this->timers[currId]->setState(newState, true); - - this->timers[currId]->setLetter(remoteTimer.toMap()["letter"].toString()); + this->remoteTimers[currId]->setState(newState); } return true; } -bool ScStwRemoteMonitorRace::addTimer(ScStwTimer* timer) { +bool ScStwRemoteRace::addTimer(ScStwTimer* timer) { Q_UNUSED(timer) return false; } -QVariantList ScStwRemoteMonitorRace::getCurrentStartDelay() { +QVariantList ScStwRemoteRace::getCurrentStartDelay() { int nextActionDelay = -1; double nextActionDelayProg = -1; diff --git a/ScStwLibraries/sources/client/scstwremotesettings.cpp b/ScStwLibraries/sources/client/scstwremotesettings.cpp index 5fb46f7..4128256 100644 --- a/ScStwLibraries/sources/client/scstwremotesettings.cpp +++ b/ScStwLibraries/sources/client/scstwremotesettings.cpp @@ -59,6 +59,8 @@ bool ScStwRemoteSettings::setDefaultSetting(QString key, QVariant defaultVariant void ScStwRemoteSettings::handleClientStateChange() { if(this->scStwClient->getState() == ScStwClient::DISCONNECTED) emit this->settingChanged(-1, 0, QVariant()); + else if(this->scStwClient->getState() == ScStwClient::CONNECTED) + emit this->settingChanged(-1, 0, QVariant()); } void ScStwRemoteSettings::handleBaseStationSignal(ScStw::SignalKey key, QVariant data) { diff --git a/ScStwLibraries/sources/client/scstwremotetimer.cpp b/ScStwLibraries/sources/client/scstwremotetimer.cpp new file mode 100644 index 0000000..a1c55b2 --- /dev/null +++ b/ScStwLibraries/sources/client/scstwremotetimer.cpp @@ -0,0 +1,41 @@ +#include "../../headers/client/scstwremotetimer.h" + +ScStwRemoteTimer::ScStwRemoteTimer(QObject *parent) : ScStwTimer(parent) +{ + this->readyState = ScStwTimer::getReadyState(); +} + +ScStwTimer::ReadyState ScStwRemoteTimer::getReadyState() { + return this->readyState; +} + +void ScStwRemoteTimer::setStartTime(double startTime) { + this->startTime = startTime; +} + +void ScStwRemoteTimer::setStopTime(double stopTime) { + this->stopTime = stopTime; +} + +void ScStwRemoteTimer::setReactionTime(double reactionTime) { + this->reactionTime = reactionTime; +} + +void ScStwRemoteTimer::setLetter(QString newLetter) { + this->letter = newLetter; +} + +void ScStwRemoteTimer::setReadyState(ScStwTimer::ReadyState readyState) { + if(this->readyState != readyState) { + this->readyState = readyState; + emit this->readyStateChanged(readyState); + } +} + +void ScStwRemoteTimer::setState(TimerState newState){ + if(this->state != newState) { + this->state = newState; + qDebug() << "+ [INFO][REMOTETIMER] timer state changed: " << newState; + emit this->stateChanged(); + } +} diff --git a/ScStwLibraries/sources/scstwrace.cpp b/ScStwLibraries/sources/scstwrace.cpp index 803e23a..56d753f 100644 --- a/ScStwLibraries/sources/scstwrace.cpp +++ b/ScStwLibraries/sources/scstwrace.cpp @@ -589,6 +589,8 @@ bool ScStwRace::addTimer(ScStwTimer *timer) { connect(timer, &ScStwTimer::reactionTimeChanged, this, &ScStwRace::timersChanged); connect(timer, &ScStwTimer::readyStateChanged, this->startWaitLoop, &QEventLoop::quit); + connect(timer, &ScStwTimer::readyStateChanged, this, &ScStwRace::isReadyForNextStateChanged); + if(this->competitionMode && timer->getState() == ScStwTimer::DISABLED) timer->setDisabled(false); diff --git a/ScStwLibraries/sources/scstwsetting.cpp b/ScStwLibraries/sources/scstwsetting.cpp index 1c10f53..2dcc0ee 100644 --- a/ScStwLibraries/sources/scstwsetting.cpp +++ b/ScStwLibraries/sources/scstwsetting.cpp @@ -17,22 +17,32 @@ ****************************************************************************/ #include "scstwsetting.h" +#include "scstwsettings.h" #include -ScStwSetting::ScStwSetting(QObject *parent) : QObject(parent) +ScStwSetting::ScStwSetting(int key, int keyLevel, ScStwSettings*scStwSettings, QObject *parent) : QObject(parent) { + this->scStwSettings = scStwSettings; + connect(this->scStwSettings, &ScStwSettings::settingChanged, this, &ScStwSetting::handleSettingChange); + this->key = key; + this->keyLevel = keyLevel; + this->handleSettingChange(-1, this->keyLevel, QVariant()); } QVariant ScStwSetting::getValue() { if(this->hasToReload) { - this->valueCache = this->readSetting(this->key, this->keyLevel); + this->valueCache = this->scStwSettings->readSetting(this->key, this->keyLevel); this->hasToReload = false; } + + qDebug() << "Setting read: keyLevel: " << this->keyLevel << " key: " << this->key << " value: " << this->valueCache; + return this->valueCache; } + void ScStwSetting::setValue(QVariant value) { if(value != this->valueCache) { - this->writeSetting(this->key, this->keyLevel, value); + this->scStwSettings->writeSetting(this->key, this->keyLevel, value); } } diff --git a/ScStwLibraries/sources/scstwsettings.cpp b/ScStwLibraries/sources/scstwsettings.cpp index fa372ea..260881f 100644 --- a/ScStwLibraries/sources/scstwsettings.cpp +++ b/ScStwLibraries/sources/scstwsettings.cpp @@ -112,7 +112,7 @@ ScStwSetting * ScStwSettings::getSetting(int key, int keyLevel) { this->internalSettingHandlers.insert(keyLevel, {}); if(!this->internalSettingHandlers[keyLevel].contains(key)) - this->internalSettingHandlers[keyLevel].insert(key, new ScStwSettingInternal(key, keyLevel, this, this)); + this->internalSettingHandlers[keyLevel].insert(key, new ScStwSetting(key, keyLevel, this, this)); return this->internalSettingHandlers[keyLevel][key]; } diff --git a/ScStwLibraries/sources/scstwtimer.cpp b/ScStwLibraries/sources/scstwtimer.cpp index 0756f50..249bfa8 100644 --- a/ScStwLibraries/sources/scstwtimer.cpp +++ b/ScStwLibraries/sources/scstwtimer.cpp @@ -18,10 +18,8 @@ #include "../headers/scstwtimer.h" -ScStwTimer::ScStwTimer(QObject *parent, bool directControlEnabled, QString letter) : QObject(parent) +ScStwTimer::ScStwTimer(QObject *parent, QString letter) : QObject(parent) { - this->directControlEnabled = directControlEnabled; - if(letter.length() > 1) this->letter = letter[0]; else @@ -30,6 +28,7 @@ ScStwTimer::ScStwTimer(QObject *parent, bool directControlEnabled, QString lette this->startTime = 0; this->stopTime = 0; this->reactionTime = 0; + this->wantsToBeDisabled = false; this->state = IDLE; } @@ -173,38 +172,6 @@ ScStwTimer::ReadyState ScStwTimer::getReadyState() { // --- helper functions --- // ------------------------ -bool ScStwTimer::setStartTime(double startTime) { - if(!this->directControlEnabled) - return false; - - this->startTime = startTime; - return true; -} - -bool ScStwTimer::setStopTime(double stopTime) { - if(!this->directControlEnabled) - return false; - - this->stopTime = stopTime; - return true; -} - -bool ScStwTimer::setReactionTime(double reactionTime) { - if(!this->directControlEnabled) - return false; - - this->reactionTime = reactionTime; - return true; -} - -bool ScStwTimer::setState(TimerState newState, bool force) { - if(!this->directControlEnabled || !force) - return false; - - this->setState(newState); - return true; -} - void ScStwTimer::setState(TimerState newState){ if(this->state == DISABLED && newState != IDLE) return; @@ -219,14 +186,6 @@ void ScStwTimer::setState(TimerState newState){ } } -bool ScStwTimer::setLetter(QString newLetter) { - if(!this->directControlEnabled) - return false; - - this->letter = newLetter; - return true; -} - ScStwTimer::TimerState ScStwTimer::getState() { return this->state; }