From e5080e711811153a30d5b073354e32189543e0a7 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Mon, 6 Apr 2020 22:54:28 +0200 Subject: [PATCH] some fixes and improvements --- ScStwSrc/headers/climbingrace.h | 8 -------- ScStwSrc/sources/climbingrace.cpp | 23 ++++++++++++----------- shared-libraries | 2 +- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/ScStwSrc/headers/climbingrace.h b/ScStwSrc/headers/climbingrace.h index d246d50..3566eec 100644 --- a/ScStwSrc/headers/climbingrace.h +++ b/ScStwSrc/headers/climbingrace.h @@ -55,14 +55,6 @@ private: // helper vars QVariantList qmlTimers; - const QMap remoteSettings = { - {"ready_en", ScStw::ReadySoundEnableSetting}, - {"ready_delay", ScStw::ReadySoundDelaySetting}, - {"at_marks_en", ScStw::AtYourMarksSoundEnableSetting}, - {"at_marks_delay", ScStw::AtYourMarksSoundDelaySetting}, - {"soundVolume", ScStw::SoundVolumeSetting} - }; - private slots: // helper functions void playSoundsAndStartRace(); diff --git a/ScStwSrc/sources/climbingrace.cpp b/ScStwSrc/sources/climbingrace.cpp index 2604099..c76255b 100644 --- a/ScStwSrc/sources/climbingrace.cpp +++ b/ScStwSrc/sources/climbingrace.cpp @@ -193,26 +193,26 @@ int ClimbingRace::resetRace() { * @param data */ void ClimbingRace::handleBaseStationSignal(ScStw::SignalKey key, QVariant data) { - //qDebug() << "got update: " << data; + qDebug() << "got signal: " << data; switch (key) { case ScStw::RaceStateChanged: { // the remote race state has changed - this->setState( ScStw::RaceState( data.toMap()["data"].toInt() ) ); + this->setState( ScStw::RaceState( data.toInt() ) ); break; } case ScStw::TimersChanged: { // the remote timers have changed - this->refreshRemoteTimers(data.toMap()["data"].toList()); + this->refreshRemoteTimers(data.toList()); break; } case ScStw::NextStartActionChanged: { // the next start action has changed - this->nextStartActionTotalDelay = data.toMap()["data"].toMap()["nextActionDelay"].toDouble(); - this->nextStartActionDelayStartedAt = this->date->currentMSecsSinceEpoch() - (this->nextStartActionTotalDelay * data.toMap()["data"].toMap()["nextActionDelayProg"].toDouble()); - this->nextStartAction = ScStw::NextStartAction( data.toMap()["data"].toMap()["nextAction"].toInt() ); + this->nextStartActionTotalDelay = data.toMap()["nextActionDelay"].toDouble(); + this->nextStartActionDelayStartedAt = this->date->currentMSecsSinceEpoch() - (this->nextStartActionTotalDelay * data.toMap()["nextActionDelayProg"].toDouble()); + this->nextStartAction = ScStw::NextStartAction( data.toMap()["nextAction"].toInt() ); emit this->nextStartActionChanged(); break; @@ -222,6 +222,8 @@ void ClimbingRace::handleBaseStationSignal(ScStw::SignalKey key, QVariant data) emit this->baseStationConnectionsChanged(); break; } + case ScStw::InvalidSignal: + return; } } @@ -361,7 +363,6 @@ bool ClimbingRace::playSound(QString path) { } void ClimbingRace::setState(ScStw::RaceState newState) { - if(newState != this->state) { this->state = newState; this->stateChanged(newState); @@ -576,8 +577,8 @@ int ClimbingRace::getNextStartAction() { } void ClimbingRace::writeSetting(QString key, QVariant value) { - if(this->mode == REMOTE && this->remoteSettings.contains(key) ){ - this->scStwClient->writeRemoteSetting(remoteSettings[key], value.toString()); + if(this->mode == REMOTE && ScStw::baseStationSettingFromString(key) != ScStw::InvalidSetting ){ + this->scStwClient->writeRemoteSetting(ScStw::baseStationSettingFromString(key), value.toString()); } else { this->appSettings->writeSetting(key, value); @@ -585,8 +586,8 @@ void ClimbingRace::writeSetting(QString key, QVariant value) { } QString ClimbingRace::readSetting(QString key) { - if(this->mode == REMOTE && this->remoteSettings.contains(key)){ - return this->scStwClient->readRemoteSetting(this->remoteSettings[key]); + if(this->mode == REMOTE && ScStw::baseStationSettingFromString(key) != ScStw::InvalidSetting){ + return this->scStwClient->readRemoteSetting(ScStw::baseStationSettingFromString(key)); } else { return this->appSettings->loadSetting(key); diff --git a/shared-libraries b/shared-libraries index b752bde..e7ecd67 160000 --- a/shared-libraries +++ b/shared-libraries @@ -1 +1 @@ -Subproject commit b752bdeed25f17b4840b2b215e8695eca4bfa711 +Subproject commit e7ecd6730fa988f078f8fc052e94086f5acbcdac