some fixes and improvements

This commit is contained in:
Dorian Zedler 2020-04-06 22:54:28 +02:00
parent e01c00ded8
commit e5080e7118
Signed by: dorian
GPG key ID: 989DE36109AFA354
3 changed files with 13 additions and 20 deletions

View file

@ -55,14 +55,6 @@ private:
// helper vars
QVariantList qmlTimers;
const QMap<QString, ScStw::BaseStationSetting> 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();

View file

@ -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);

@ -1 +1 @@
Subproject commit b752bdeed25f17b4840b2b215e8695eca4bfa711
Subproject commit e7ecd6730fa988f078f8fc052e94086f5acbcdac