2020-06-07 14:43:47 +02:00
|
|
|
/****************************************************************************
|
|
|
|
** ScStw Libraries
|
|
|
|
** Copyright (C) 2020 Itsblue development
|
|
|
|
**
|
|
|
|
** This program is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This program is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-10-02 19:56:08 +02:00
|
|
|
#include "scstwremoterace.h"
|
2020-04-18 14:25:48 +02:00
|
|
|
|
2020-10-09 15:18:56 +02:00
|
|
|
ScStwRemoteRace::ScStwRemoteRace(QObject* parent) : ScStwRemoteRace(nullptr, nullptr, parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-10-03 15:15:49 +02:00
|
|
|
ScStwRemoteRace::ScStwRemoteRace(ScStwClient *scStwClient, ScStwSettings *settings, QObject *parent) : ScStwRace(settings, parent)
|
2020-04-18 14:25:48 +02:00
|
|
|
{
|
2020-10-03 11:10:15 +02:00
|
|
|
this->isReadyForNextState = true;
|
2020-10-02 16:49:24 +02:00
|
|
|
|
2020-10-07 09:48:15 +02:00
|
|
|
this->remoteTimers = {};
|
2020-10-07 11:57:50 +02:00
|
|
|
this->localTimers = {};
|
2020-10-07 09:48:15 +02:00
|
|
|
|
2020-10-09 15:18:56 +02:00
|
|
|
this->setScStwClient(scStwClient);
|
2020-04-18 14:25:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------
|
|
|
|
// --- Main Functionality ---
|
|
|
|
// --------------------------
|
|
|
|
|
2020-10-03 13:06:14 +02:00
|
|
|
ScStw::StatusCode ScStwRemoteRace::start(bool asyncronous) {
|
|
|
|
if(this->local())
|
|
|
|
return ScStwRace::start(asyncronous);
|
2020-10-02 19:56:08 +02:00
|
|
|
|
2020-10-02 16:49:24 +02:00
|
|
|
if(this->getState() != ScStwRace::IDLE && this->getState() != ScStwRace::WAITING)
|
|
|
|
return ScStw::CurrentStateNotVaildForOperationError;
|
2020-04-18 14:25:48 +02:00
|
|
|
|
|
|
|
qDebug() << "+ --- starting race";
|
|
|
|
|
2020-10-02 16:49:24 +02:00
|
|
|
QVariantMap reply = this->scStwClient->sendCommand(ScStw::StartRaceCommand);
|
2020-04-18 14:25:48 +02:00
|
|
|
|
2020-10-02 16:49:24 +02:00
|
|
|
return ScStw::StatusCode(reply["status"].toInt());
|
|
|
|
}
|
2020-04-18 14:25:48 +02:00
|
|
|
|
2020-10-02 19:56:08 +02:00
|
|
|
ScStw::StatusCode ScStwRemoteRace::cancel() {
|
2020-10-03 13:06:14 +02:00
|
|
|
if(this->local())
|
|
|
|
return ScStwRace::cancel();
|
|
|
|
|
2020-10-02 16:49:24 +02:00
|
|
|
if(this->getState() != PREPAIRING && this->getState() != WAITING && this->getState() != STARTING && this->getState() != RUNNING)
|
|
|
|
return ScStw::CurrentStateNotVaildForOperationError;
|
2020-04-18 14:25:48 +02:00
|
|
|
|
2020-10-02 16:49:24 +02:00
|
|
|
qDebug() << "+ --- stopping race";
|
2020-04-18 14:25:48 +02:00
|
|
|
|
2020-10-02 16:49:24 +02:00
|
|
|
QVariantMap reply = this->scStwClient->sendCommand(ScStw::CancelRaceCommand);
|
2020-05-26 17:57:32 +02:00
|
|
|
|
2020-10-02 16:49:24 +02:00
|
|
|
return ScStw::StatusCode(reply["status"].toInt());
|
2020-04-18 14:25:48 +02:00
|
|
|
}
|
|
|
|
|
2020-10-02 19:56:08 +02:00
|
|
|
ScStw::StatusCode ScStwRemoteRace::stop() {
|
2020-10-03 13:06:14 +02:00
|
|
|
if(this->local())
|
|
|
|
return ScStwRace::stop();
|
|
|
|
|
2020-10-02 16:49:24 +02:00
|
|
|
if(this->getState() != ScStwRace::RUNNING && this->getState() != ScStwRace::STARTING)
|
|
|
|
return ScStw::CurrentStateNotVaildForOperationError;
|
2020-04-18 14:25:48 +02:00
|
|
|
|
|
|
|
qDebug() << "+ --- stopping race";
|
|
|
|
|
2020-10-02 16:49:24 +02:00
|
|
|
QVariantMap reply = this->scStwClient->sendCommand(ScStw::StopRaceCommand);
|
2020-04-18 14:25:48 +02:00
|
|
|
|
2020-10-02 16:49:24 +02:00
|
|
|
return ScStw::StatusCode(reply["status"].toInt());
|
2020-04-18 14:25:48 +02:00
|
|
|
}
|
|
|
|
|
2020-10-02 19:56:08 +02:00
|
|
|
ScStw::StatusCode ScStwRemoteRace::reset() {
|
2020-10-03 13:06:14 +02:00
|
|
|
if(this->local())
|
|
|
|
return ScStwRace::reset();
|
|
|
|
|
2020-10-02 16:49:24 +02:00
|
|
|
if(this->getState() != ScStwRace::STOPPED && this->getState() != ScStwRace::INCIDENT)
|
|
|
|
return ScStw::CurrentStateNotVaildForOperationError;
|
2020-04-18 14:25:48 +02:00
|
|
|
|
|
|
|
qDebug() << "+ --- resetting race";
|
|
|
|
|
2020-10-02 16:49:24 +02:00
|
|
|
QVariantMap reply = this->scStwClient->sendCommand(ScStw::ResetRaceCommand);
|
2020-04-18 14:25:48 +02:00
|
|
|
|
2020-10-02 16:49:24 +02:00
|
|
|
return ScStw::StatusCode(reply["status"].toInt());
|
2020-04-18 14:25:48 +02:00
|
|
|
}
|
|
|
|
|
2020-10-06 14:00:22 +02:00
|
|
|
ScStw::StatusCode ScStwRemoteRace::setTimerDisabled(int timerId, bool disabled) {
|
|
|
|
if(this->state != IDLE && this->state != WAITING)
|
|
|
|
return ScStw::CurrentStateNotVaildForOperationError;
|
|
|
|
|
|
|
|
if(timerId < 0 || timerId - 1 > this->timers.length())
|
|
|
|
return ScStw::ItemNotFoundError;
|
|
|
|
|
|
|
|
qDebug() << "+ --- setting timer " << timerId << " to disabled: " << disabled;
|
|
|
|
|
|
|
|
QVariantMap requestData = {
|
|
|
|
{"timerId", timerId},
|
|
|
|
{"disabled", disabled}
|
|
|
|
};
|
|
|
|
|
|
|
|
QVariantMap reply = this->scStwClient->sendCommand(ScStw::SetTimerDisabledCommand, QJsonValue::fromVariant(requestData));
|
|
|
|
|
|
|
|
qDebug() << "+ --- timer disabled command returned: " << reply;
|
|
|
|
|
|
|
|
return ScStw::StatusCode(reply["status"].toInt());
|
|
|
|
}
|
|
|
|
|
2020-04-18 14:25:48 +02:00
|
|
|
// -------------------------
|
|
|
|
// --- Base Station sync ---
|
|
|
|
// -------------------------
|
|
|
|
|
2020-10-03 13:06:14 +02:00
|
|
|
void ScStwRemoteRace::handleClientStateChange() {
|
2020-04-18 14:25:48 +02:00
|
|
|
switch (this->scStwClient->getState()) {
|
2020-10-19 11:15:49 +02:00
|
|
|
case ScStwClient::INITIALISING:
|
|
|
|
// disconnect all local timers from race
|
|
|
|
this->setTimers({}, false);
|
|
|
|
// delete all obsolete remote timers
|
|
|
|
for(ScStwRemoteTimer* oldRemoteTimer : this->remoteTimers)
|
|
|
|
oldRemoteTimer->deleteLater();
|
2020-10-03 21:47:53 +02:00
|
|
|
this->remoteTimers.clear();
|
2020-04-18 14:25:48 +02:00
|
|
|
break;
|
2020-10-03 13:06:14 +02:00
|
|
|
case ScStwClient::DISCONNECTED:
|
|
|
|
this->remoteTimers.clear();
|
2020-10-19 11:15:49 +02:00
|
|
|
this->setTimers(this->localTimers, true);
|
2020-10-03 13:06:14 +02:00
|
|
|
emit this->timersChanged();
|
2020-10-04 16:05:16 +02:00
|
|
|
emit this->detailsChanged();
|
|
|
|
emit this->currentStartDelayChanged();
|
2020-10-03 13:06:14 +02:00
|
|
|
this->competitionMode = false;
|
2020-04-19 13:09:24 +02:00
|
|
|
this->setState(IDLE);
|
2020-04-18 14:25:48 +02:00
|
|
|
break;
|
2020-10-03 13:06:14 +02:00
|
|
|
default:
|
|
|
|
break;
|
2020-04-18 14:25:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-03 13:06:14 +02:00
|
|
|
ScStwRemoteRace::RaceMode ScStwRemoteRace::getMode() {
|
2020-10-09 15:18:56 +02:00
|
|
|
if(this->scStwClient == nullptr || this->scStwClient->getState() != ScStwClient::CONNECTED)
|
|
|
|
return LOCAL;
|
2020-10-03 13:06:14 +02:00
|
|
|
else
|
2020-10-09 15:18:56 +02:00
|
|
|
return REMOTE;
|
2020-10-03 13:06:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ScStwRemoteRace::local() {
|
|
|
|
return this->getMode() == LOCAL;
|
|
|
|
}
|
|
|
|
|
2020-04-18 14:25:48 +02:00
|
|
|
/**
|
|
|
|
* @brief ScStwAppBackend::handleBaseStationUpdate
|
|
|
|
*
|
|
|
|
* Function to handle an update, sent by the base station, which indicates
|
|
|
|
* that some remote value (like a state) has changed
|
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
*/
|
2020-10-02 19:56:08 +02:00
|
|
|
void ScStwRemoteRace::handleBaseStationSignal(ScStw::SignalKey key, QVariant data) {
|
2020-04-18 14:25:48 +02:00
|
|
|
switch (key) {
|
2020-10-03 11:10:15 +02:00
|
|
|
case ScStw::RaceDetailsChanged:
|
2020-04-18 14:25:48 +02:00
|
|
|
{
|
2020-10-03 11:10:15 +02:00
|
|
|
this->refreshDetails(data.toMap());
|
2020-04-18 14:25:48 +02:00
|
|
|
break;
|
|
|
|
}
|
2020-10-03 11:10:15 +02:00
|
|
|
default:
|
|
|
|
return;
|
2020-04-18 14:25:48 +02:00
|
|
|
}
|
2020-10-03 11:10:15 +02:00
|
|
|
}
|
2020-10-02 16:49:24 +02:00
|
|
|
|
2020-10-03 11:10:15 +02:00
|
|
|
void ScStwRemoteRace::refreshDetails(QVariantMap details) {
|
|
|
|
// the details of the race have changed:
|
2020-10-02 16:49:24 +02:00
|
|
|
|
2020-10-04 17:55:39 +02:00
|
|
|
qDebug() << "RACE DETAILS: " << details;
|
|
|
|
|
2020-10-03 11:10:15 +02:00
|
|
|
// competition mode
|
2020-10-03 11:44:56 +02:00
|
|
|
if(this->competitionMode != details["competitionMode"].toBool()) {
|
|
|
|
this->competitionMode = details["competitionMode"].toBool();
|
|
|
|
emit this->competitionModeChanged();
|
|
|
|
}
|
2020-04-18 14:25:48 +02:00
|
|
|
|
2020-10-03 11:10:15 +02:00
|
|
|
// ready sound enabled
|
2020-10-03 13:06:14 +02:00
|
|
|
if(this->readySoundEnabled != details["readySoundEnabled"].toBool()) {
|
|
|
|
this->readySoundEnabled = details["readySoundEnabled"].toBool();
|
2020-10-03 11:44:56 +02:00
|
|
|
emit this->readySoundEnabledChanged();
|
|
|
|
}
|
2020-10-03 11:10:15 +02:00
|
|
|
|
|
|
|
// current start delay
|
2020-10-03 11:44:56 +02:00
|
|
|
this->currentStartTotalDelay = details["currentStartDelay"].toMap()["total"].toInt();
|
|
|
|
this->latestStartDelayProgress = details["currentStartDelay"].toMap()["progress"].toDouble();
|
|
|
|
this->currentStartDelayStartedAt = QDateTime::currentMSecsSinceEpoch() - (this->currentStartTotalDelay * this->latestStartDelayProgress);
|
2020-10-03 11:10:15 +02:00
|
|
|
|
|
|
|
emit this->currentStartDelayChanged();
|
|
|
|
|
|
|
|
// timers
|
|
|
|
this->refreshRemoteTimers(details["timers"].toList());
|
|
|
|
|
2020-10-05 20:41:43 +02:00
|
|
|
// state
|
|
|
|
this->setState(ScStwRace::RaceState(details["state"].toInt()));
|
|
|
|
|
2020-10-03 11:10:15 +02:00
|
|
|
// isReady
|
|
|
|
if(this->state == WAITING) {
|
|
|
|
this->isReadyForNextState = details["isReadyForNextState"].toBool();
|
|
|
|
emit this->isReadyForNextStateChanged();
|
2020-04-18 14:25:48 +02:00
|
|
|
}
|
2020-10-03 11:10:15 +02:00
|
|
|
|
|
|
|
emit this->detailsChanged();
|
2020-04-18 14:25:48 +02:00
|
|
|
}
|
|
|
|
|
2020-10-03 13:06:14 +02:00
|
|
|
void ScStwRemoteRace::rebuildRemoteTimers(QVariantList remoteTimers) {
|
2020-10-07 09:48:15 +02:00
|
|
|
|
|
|
|
qDebug() << "REBUILDING TIMERS";
|
|
|
|
|
2020-10-03 13:06:14 +02:00
|
|
|
// delete all current timers
|
|
|
|
foreach(ScStwTimer * oldTimer, this->timers){
|
|
|
|
oldTimer->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
this->remoteTimers.clear();
|
|
|
|
this->timers.clear();
|
|
|
|
|
|
|
|
foreach(QVariant remoteTimer, remoteTimers){
|
|
|
|
// create a local timer for each remote timer
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-02 19:56:08 +02:00
|
|
|
bool ScStwRemoteRace::refreshRemoteTimers(QVariantList remoteTimers) {
|
2020-04-18 14:25:48 +02:00
|
|
|
|
2020-10-05 20:41:43 +02:00
|
|
|
qDebug() << "REFRESHING TIMERS";
|
|
|
|
|
2020-10-03 13:06:14 +02:00
|
|
|
if(remoteTimers.length() != this->remoteTimers.length()){
|
2020-04-18 14:25:48 +02:00
|
|
|
// local timers are out of sync
|
2020-10-03 13:06:14 +02:00
|
|
|
this->rebuildRemoteTimers(remoteTimers);
|
2020-10-03 21:47:53 +02:00
|
|
|
qDebug() << "rebuilding remote timers";
|
2020-04-18 14:25:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach(QVariant remoteTimer, remoteTimers){
|
|
|
|
int currId = remoteTimer.toMap()["id"].toInt();
|
2020-10-02 19:56:08 +02:00
|
|
|
|
2020-10-03 13:06:14 +02:00
|
|
|
if(this->remoteTimers.length() <= currId)
|
|
|
|
this->rebuildRemoteTimers(remoteTimers);
|
|
|
|
|
2020-04-18 14:25:48 +02:00
|
|
|
ScStwTimer::TimerState newState = ScStwTimer::TimerState(remoteTimer.toMap()["state"].toInt());
|
2020-10-02 19:56:08 +02:00
|
|
|
|
2020-10-03 13:06:14 +02:00
|
|
|
qDebug() << "refreshing timers: id: " << currId << " state: " << newState << " readyState: " << remoteTimer.toMap()["readyState"].toInt() << " currentTime: " << remoteTimer.toMap()["currentTime"].toDouble();
|
2020-10-02 19:56:08 +02:00
|
|
|
|
2020-04-18 14:25:48 +02:00
|
|
|
double currentMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch();
|
|
|
|
|
2020-10-02 19:56:08 +02:00
|
|
|
this->remoteTimers[currId]->setStartTime(currentMSecsSinceEpoch - remoteTimer.toMap()["currentTime"].toDouble());
|
2020-04-18 14:25:48 +02:00
|
|
|
|
|
|
|
if(newState >= ScStwTimer::WAITING)
|
2020-10-02 19:56:08 +02:00
|
|
|
this->remoteTimers[currId]->setStopTime(currentMSecsSinceEpoch);
|
2020-04-18 14:25:48 +02:00
|
|
|
|
2020-10-02 19:56:08 +02:00
|
|
|
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()));
|
2020-06-13 15:57:27 +02:00
|
|
|
|
2020-10-02 19:56:08 +02:00
|
|
|
this->remoteTimers[currId]->setState(newState);
|
2020-04-18 14:25:48 +02:00
|
|
|
}
|
|
|
|
|
2020-10-05 20:41:43 +02:00
|
|
|
emit this->timersChanged();
|
|
|
|
|
2020-04-18 14:25:48 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-10-02 19:56:08 +02:00
|
|
|
bool ScStwRemoteRace::addTimer(ScStwTimer* timer) {
|
2020-10-07 09:48:15 +02:00
|
|
|
if(this->local()) {
|
|
|
|
this->localTimers.append(timer);
|
2020-10-03 13:06:14 +02:00
|
|
|
return ScStwRace::addTimer(timer);
|
2020-10-07 09:48:15 +02:00
|
|
|
}
|
2020-10-03 13:06:14 +02:00
|
|
|
|
2020-04-18 14:25:48 +02:00
|
|
|
return false;
|
|
|
|
}
|
2020-04-19 13:09:24 +02:00
|
|
|
|
2020-10-19 11:15:49 +02:00
|
|
|
void ScStwRemoteRace::setTimers(QList<ScStwTimer*> timers, bool deleteOldTimers) {
|
|
|
|
|
|
|
|
// disconnect all signals of all current timers
|
|
|
|
qDebug() << "SETTING TIMERS";
|
|
|
|
|
|
|
|
foreach(ScStwTimer *existingTimer, this->timers) {
|
|
|
|
disconnect(existingTimer, &ScStwTimer::stateChanged, this, &ScStwRace::handleTimerStateChange);
|
|
|
|
disconnect(existingTimer, &ScStwTimer::stateChanged, this, &ScStwRace::timersChanged);
|
|
|
|
disconnect(existingTimer, &ScStwTimer::wantsToBeDisabledChanged, this, &ScStwRace::handleTimerWantsToBeDisabledChange);
|
|
|
|
disconnect(existingTimer, &ScStwTimer::reactionTimeChanged, this, &ScStwRace::timersChanged);
|
|
|
|
disconnect(existingTimer, &ScStwTimer::readyStateChanged, this, &ScStwRace::handleTimerReadyStateChange);
|
|
|
|
disconnect(existingTimer, &ScStwTimer::readyStateChanged, this, &ScStwRace::isReadyForNextStateChanged);
|
|
|
|
|
|
|
|
if(deleteOldTimers)
|
|
|
|
existingTimer->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
this->timers.clear();
|
|
|
|
|
|
|
|
for(ScStwTimer* timer : timers) {
|
|
|
|
this->addTimer(timer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-03 11:44:56 +02:00
|
|
|
QVariantMap ScStwRemoteRace::getCurrentStartDelay() {
|
2020-10-03 13:06:14 +02:00
|
|
|
if(this->local())
|
|
|
|
return ScStwRace::getCurrentStartDelay();
|
2020-04-19 13:09:24 +02:00
|
|
|
|
2020-10-03 11:44:56 +02:00
|
|
|
QVariantMap currentStartDelay = {
|
|
|
|
{"total", -1.0},
|
|
|
|
{"progress", -1.0}
|
|
|
|
};
|
|
|
|
|
|
|
|
if(this->currentStartTotalDelay == -1) {
|
|
|
|
currentStartDelay["progress"] = this->latestStartDelayProgress;
|
2020-10-02 16:49:24 +02:00
|
|
|
}
|
|
|
|
else if(this->getState() == PREPAIRING || this->getState() == WAITING) {
|
2020-04-19 13:09:24 +02:00
|
|
|
// get the total delay and the delay progress of the next action timer
|
2020-10-02 16:49:24 +02:00
|
|
|
double elapsed = QDateTime::currentMSecsSinceEpoch() - this->currentStartDelayStartedAt;
|
2020-10-03 11:44:56 +02:00
|
|
|
currentStartDelay["total"] = this->currentStartTotalDelay;
|
|
|
|
if(elapsed < 0 || elapsed > currentStartDelay["total"].toDouble()) {
|
|
|
|
elapsed = currentStartDelay["total"].toDouble();
|
2020-04-19 13:09:24 +02:00
|
|
|
}
|
2020-10-03 11:44:56 +02:00
|
|
|
currentStartDelay["progress"] = elapsed / currentStartDelay["total"].toDouble();
|
2020-04-19 13:09:24 +02:00
|
|
|
}
|
|
|
|
|
2020-10-03 11:44:56 +02:00
|
|
|
return currentStartDelay;
|
2020-04-19 13:09:24 +02:00
|
|
|
}
|
2020-10-03 11:10:15 +02:00
|
|
|
|
|
|
|
bool ScStwRemoteRace::getIsReadyForNextState() {
|
2020-10-03 13:06:14 +02:00
|
|
|
if(this->local())
|
|
|
|
return ScStwRace::getIsReadyForNextState();
|
|
|
|
|
2020-10-03 11:10:15 +02:00
|
|
|
return this->isReadyForNextState;
|
|
|
|
}
|
2020-10-03 13:06:14 +02:00
|
|
|
|
|
|
|
bool ScStwRemoteRace::getReadySoundEnabled() {
|
|
|
|
if(this->local())
|
|
|
|
return ScStwRace::getReadySoundEnabled();
|
|
|
|
|
|
|
|
return this->readySoundEnabled;
|
|
|
|
}
|
2020-10-03 18:32:39 +02:00
|
|
|
|
|
|
|
void ScStwRemoteRace::refreshCompetitionMode() {
|
|
|
|
if(this->local())
|
|
|
|
return ScStwRace::refreshCompetitionMode();
|
|
|
|
}
|
2020-10-09 15:18:56 +02:00
|
|
|
|
|
|
|
ScStwClient* ScStwRemoteRace::getScStwClient() {
|
|
|
|
return this->scStwClient;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScStwRemoteRace::setScStwClient(ScStwClient* client) {
|
|
|
|
if(client == this->scStwClient)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this->scStwClient = client;
|
|
|
|
|
|
|
|
if(this->scStwClient != nullptr) {
|
|
|
|
this->scStwClient->addSignalSubscription(ScStw::RaceDetailsChanged);
|
|
|
|
|
|
|
|
connect(this->scStwClient, &ScStwClient::stateChanged, this, &ScStwRemoteRace::handleClientStateChange);
|
|
|
|
connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteRace::handleBaseStationSignal);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|