- added list with settings that can be managed remotely

This commit is contained in:
Dorian Zedler 2019-03-27 22:23:12 +01:00
parent 80e4fcfafc
commit dadebe0d65
2 changed files with 13 additions and 14 deletions

View file

@ -52,6 +52,7 @@ private:
// helper vars // helper vars
QVariantList qmlTimers; QVariantList qmlTimers;
const QStringList remoteSettings = {"ready_en", "ready_delay", "at_marks_en", "at_marks_delay"};
private slots: private slots:
// helper functions // helper functions

View file

@ -7,7 +7,7 @@
* - sounds * - sounds
* - next start action * - next start action
* - next start action delay progress * - next start action delay progress
* * - settings (remote and local)
*/ */
ClimbingRace::ClimbingRace(QObject *parent) : QObject(parent) ClimbingRace::ClimbingRace(QObject *parent) : QObject(parent)
@ -18,7 +18,7 @@ ClimbingRace::ClimbingRace(QObject *parent) : QObject(parent)
this->appSettings = new AppSettings; this->appSettings = new AppSettings;
this->baseConn = new BaseConn; this->baseConn = new BaseConn;
this->baseConn->setIP("ScStw"); this->baseConn->setIP("192.168.4.1");
connect(this->baseConn, &BaseConn::stateChanged, this, &ClimbingRace::baseStationStateChanged); connect(this->baseConn, &BaseConn::stateChanged, this, &ClimbingRace::baseStationStateChanged);
this->speedTimers.append( new SpeedTimer ); this->speedTimers.append( new SpeedTimer );
@ -483,31 +483,29 @@ double ClimbingRace::getNextStartActionDelayProgress() {
void ClimbingRace::writeSetting(QString key, QVariant value) { void ClimbingRace::writeSetting(QString key, QVariant value) {
this->refreshMode(); this->refreshMode();
switch (this->mode) {
case LOCAL: if(this->mode == REMOTE && this->remoteSettings.contains(key)){
this->appSettings->writeSetting(key, value);
break;
case REMOTE:
this->baseConn->writeRemoteSetting(key, value.toString()); this->baseConn->writeRemoteSetting(key, value.toString());
break; }
else {
this->appSettings->writeSetting(key, value);
} }
} }
QString ClimbingRace::readSetting(QString key) { QString ClimbingRace::readSetting(QString key) {
this->refreshMode(); this->refreshMode();
switch (this->mode) {
case LOCAL: if(this->mode == REMOTE && this->remoteSettings.contains(key)){
return this->appSettings->loadSetting(key);
case REMOTE:
QVariantMap reply = this->baseConn->sendCommand(3001, key); QVariantMap reply = this->baseConn->sendCommand(3001, key);
if(reply["status"] != 200){ if(reply["status"] != 200){
return "false"; return "false";
} }
return reply["data"].toString(); return reply["data"].toString();
} }
else {
return this->appSettings->loadSetting(key);
}
} }
bool ClimbingRace::connectBaseStation() { bool ClimbingRace::connectBaseStation() {