diff --git a/ScStwLibraries/headers/client/scstwclient.h b/ScStwLibraries/headers/client/scstwclient.h index d3a3946..99e8dc3 100644 --- a/ScStwLibraries/headers/client/scstwclient.h +++ b/ScStwLibraries/headers/client/scstwclient.h @@ -60,7 +60,10 @@ public: * * \brief ScStwClient */ - explicit ScStwClient(QObject *parent = nullptr); + explicit ScStwClient( + QObject *parent = nullptr, + QList signalSubscriptions = {ScStw::ExtensionsChanged} + ); enum State {DISCONNECTED, CONNECTING, INITIALISING, CONNECTED}; Q_ENUM(State); @@ -76,6 +79,8 @@ private: QVariantList extensions; + QList signalSubscriptions; + //---general status values---// // some meta data of the base station @@ -200,6 +205,8 @@ public slots: */ void setIP(QString ipAdress); + void addSignalSubscription(ScStw::SignalKey key); + private slots: /*! * \brief called when timeout timer times out diff --git a/ScStwLibraries/headers/client/scstwqmlsetting.h b/ScStwLibraries/headers/client/scstwqmlsetting.h new file mode 100644 index 0000000..85e0809 --- /dev/null +++ b/ScStwLibraries/headers/client/scstwqmlsetting.h @@ -0,0 +1,16 @@ +#ifndef SCSTWQMLSETTING_H +#define SCSTWQMLSETTING_H + +#include + +class ScStwQmlSetting : public QObject +{ + Q_OBJECT +public: + explicit ScStwQmlSetting(QObject *parent = nullptr); + +signals: + +}; + +#endif // SCSTWQMLSETTING_H diff --git a/ScStwLibraries/sources/client/scstwclient.cpp b/ScStwLibraries/sources/client/scstwclient.cpp index 9e7d93c..0aebd03 100644 --- a/ScStwLibraries/sources/client/scstwclient.cpp +++ b/ScStwLibraries/sources/client/scstwclient.cpp @@ -20,11 +20,12 @@ ScStwClient * pGlobalScStwClient = nullptr; -ScStwClient::ScStwClient(QObject * parent) : QObject(parent) +ScStwClient::ScStwClient(QObject * parent, QList signalSubscriptions) : QObject(parent) { this->state = DISCONNECTED; this->nextConnectionId = 1; this->extensions = QVariantList({}); + this->signalSubscriptions = signalSubscriptions; this->socket = new QTcpSocket(this); @@ -72,9 +73,13 @@ bool ScStwClient::init() { this->setState(INITIALISING); this->timeoutTimer->stop(); + QJsonArray signalSubs; + foreach (ScStw::SignalKey key, this->signalSubscriptions) { + signalSubs.append(key); + } + // init remote session - QJsonArray updateSubs = {ScStw::RaceStateChanged, ScStw::TimersChanged, ScStw::ExtensionsChanged, ScStw::NextStartActionChanged}; - QJsonObject sessionParams = {{"updateSubs", updateSubs}, {"init", true}, {"usingTerminationKeys", true}}; + QJsonObject sessionParams = {{"signalSubscriptions", signalSubs}, {"init", true}, {"usingTerminationKeys", true}}; QVariantMap initResponse = this->sendCommand(1, sessionParams, 3000, false); @@ -368,7 +373,7 @@ void ScStwClient::handleSignal(QVariantMap data) { ScStw::SignalKey signalKey = ScStw::signalKeyFromInt(data["header"].toInt()); - //qDebug() << "got signal: " << signalKey << " with data: " << data["data"]; + qDebug() << "got signal: " << signalKey << " with data: " << data["data"]; switch (signalKey) { case ScStw::ExtensionsChanged: @@ -452,3 +457,9 @@ void ScStwClient::setExtensions(QVariantList extensions) { emit this->extensionsChanged(); } } + + +void ScStwClient::addSignalSubscription(ScStw::SignalKey key) { + if(!this->signalSubscriptions.contains(key)) + this->signalSubscriptions.append(key); +} diff --git a/ScStwLibraries/sources/client/scstwqmlsetting.cpp b/ScStwLibraries/sources/client/scstwqmlsetting.cpp new file mode 100644 index 0000000..86321c3 --- /dev/null +++ b/ScStwLibraries/sources/client/scstwqmlsetting.cpp @@ -0,0 +1,6 @@ +#include "../../headers/client/scstwqmlsetting.h" + +ScStwQmlSetting::ScStwQmlSetting(QObject *parent) : QObject(parent) +{ + +} diff --git a/ScStwLibraries/sources/client/scstwremotemonitorrace.cpp b/ScStwLibraries/sources/client/scstwremotemonitorrace.cpp index 553598f..b286927 100644 --- a/ScStwLibraries/sources/client/scstwremotemonitorrace.cpp +++ b/ScStwLibraries/sources/client/scstwremotemonitorrace.cpp @@ -22,6 +22,10 @@ ScStwRemoteMonitorRace::ScStwRemoteMonitorRace(ScStwClient *monitorClient, QObje { this->scStwClient = monitorClient; + this->scStwClient->addSignalSubscription(ScStw::RaceStateChanged); + this->scStwClient->addSignalSubscription(ScStw::TimersChanged); + this->scStwClient->addSignalSubscription(ScStw::NextStartActionChanged); + connect(this->scStwClient, &ScStwClient::stateChanged, this, &ScStwRemoteMonitorRace::handleClientStateChanged); connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteMonitorRace::handleBaseStationSignal); } diff --git a/ScStwLibraries/sources/client/scstwremotesettings.cpp b/ScStwLibraries/sources/client/scstwremotesettings.cpp index 8879dea..f653ebd 100644 --- a/ScStwLibraries/sources/client/scstwremotesettings.cpp +++ b/ScStwLibraries/sources/client/scstwremotesettings.cpp @@ -3,6 +3,7 @@ ScStwRemoteSettings::ScStwRemoteSettings(ScStwClient * scStwClient, QObject * parent) : ScStwSettings(parent) { this->scStwClient = scStwClient; + this->scStwClient->addSignalSubscription(ScStw::SettingChanged); connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteSettings::handleBaseStationSignal); } @@ -25,10 +26,11 @@ bool ScStwRemoteSettings::writeSetting(QString key, QVariant value, int keyInt, if(this->getMode() == LOCAL || keyLevel > 0) return ScStwSettings::writeSetting(key, value, keyInt, keyLevel); - this->scStwClient->writeRemoteSetting(ScStwSettings::BaseStationSetting(keyInt), value); - emit this->settingChanged(keyInt, keyLevel); + qDebug() << "changing setting"; + ScStw::StatusCode res = this->scStwClient->writeRemoteSetting(ScStwSettings::BaseStationSetting(keyInt), value); + qDebug() << "changed setting " << res; - return true; + return res == ScStw::Success; } void ScStwRemoteSettings::setDefaultSetting(QString key, QVariant defaultVariant, int keyInt, int keyLevel) {