Library migration #36
9 changed files with 84 additions and 121 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
|
|
||||||
#include <scstwclient.h>
|
#include <scstwclient.h>
|
||||||
|
#include <ScStw.hpp>
|
||||||
|
|
||||||
#include "headers/appsettings.h"
|
#include "headers/appsettings.h"
|
||||||
#include "headers/speedtimer.h"
|
#include "headers/speedtimer.h"
|
||||||
|
@ -27,13 +28,8 @@ class ClimbingRace : public QObject
|
||||||
public:
|
public:
|
||||||
explicit ClimbingRace(QObject *parent = nullptr);
|
explicit ClimbingRace(QObject *parent = nullptr);
|
||||||
|
|
||||||
enum raceState { IDLE, STARTING, WAITING, RUNNING, STOPPED };
|
enum RaceMode { LOCAL, REMOTE };
|
||||||
raceState state;
|
RaceMode mode;
|
||||||
|
|
||||||
enum raceMode { LOCAL, REMOTE };
|
|
||||||
raceMode mode;
|
|
||||||
|
|
||||||
enum NextStartAction { AtYourMarks, Ready, Start, None };
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AppSettings * appSettings;
|
AppSettings * appSettings;
|
||||||
|
@ -48,7 +44,8 @@ private:
|
||||||
|
|
||||||
QList<SpeedTimer *> speedTimers;
|
QList<SpeedTimer *> speedTimers;
|
||||||
|
|
||||||
NextStartAction nextStartAction;
|
ScStw::NextStartAction nextStartAction;
|
||||||
|
ScStw::RaceState state;
|
||||||
|
|
||||||
double nextStartActionDelayProgress;
|
double nextStartActionDelayProgress;
|
||||||
// only used in remote mode:
|
// only used in remote mode:
|
||||||
|
@ -57,14 +54,20 @@ private:
|
||||||
|
|
||||||
// helper vars
|
// helper vars
|
||||||
QVariantList qmlTimers;
|
QVariantList qmlTimers;
|
||||||
const QStringList remoteSettings = {"ready_en", "ready_delay", "at_marks_en", "at_marks_delay"};
|
|
||||||
const QStringList remoteOnlySettings = {"soundVolume"};
|
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:
|
private slots:
|
||||||
// helper functions
|
// helper functions
|
||||||
void playSoundsAndStartRace();
|
void playSoundsAndStartRace();
|
||||||
bool playSound(QString path);
|
bool playSound(QString path);
|
||||||
void setState(raceState newState);
|
void setState(ScStw::RaceState newState);
|
||||||
void refreshMode();
|
void refreshMode();
|
||||||
void refreshTimerText();
|
void refreshTimerText();
|
||||||
|
|
||||||
|
@ -87,7 +90,7 @@ public slots:
|
||||||
Q_INVOKABLE int resetRace();
|
Q_INVOKABLE int resetRace();
|
||||||
|
|
||||||
// base station sync
|
// base station sync
|
||||||
void handleBaseStationUpdate(QVariant data);
|
void handleBaseStationSignal(ScStw::SignalKey key, QVariant data);
|
||||||
Q_INVOKABLE bool pairConnectedUsbExtensions();
|
Q_INVOKABLE bool pairConnectedUsbExtensions();
|
||||||
|
|
||||||
// functions for qml
|
// functions for qml
|
||||||
|
|
|
@ -21,7 +21,7 @@ import QtQuick.Window 2.2
|
||||||
import QtQuick.Controls 2.4
|
import QtQuick.Controls 2.4
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
import com.itsblue.speedclimbingstopwatch 1.0
|
import com.itsblue.speedclimbingstopwatch 2.0
|
||||||
|
|
||||||
import "../components"
|
import "../components"
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import QtQuick.Window 2.2
|
||||||
import QtQuick.Controls 2.4
|
import QtQuick.Controls 2.4
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
import com.itsblue.speedclimbingstopwatch 1.0
|
import com.itsblue.speedclimbingstopwatch 2.0
|
||||||
|
|
||||||
import "../components"
|
import "../components"
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import QtQuick.Window 2.2
|
||||||
import QtQuick.Controls 2.4
|
import QtQuick.Controls 2.4
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
import com.itsblue.speedclimbingstopwatch 1.0
|
import com.itsblue.speedclimbingstopwatch 2.0
|
||||||
import "../components"
|
import "../components"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import QtQuick.Window 2.2
|
||||||
import QtQuick.Controls 2.4
|
import QtQuick.Controls 2.4
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
import com.itsblue.speedclimbingstopwatch 1.0
|
import com.itsblue.speedclimbingstopwatch 2.0
|
||||||
|
|
||||||
import "../components"
|
import "../components"
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import QtQuick.Window 2.2
|
||||||
import QtQuick.Controls 2.4
|
import QtQuick.Controls 2.4
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
import com.itsblue.speedclimbingstopwatch 1.0
|
import com.itsblue.speedclimbingstopwatch 2.0
|
||||||
import "../components"
|
import "../components"
|
||||||
|
|
||||||
RemoteDataListView {
|
RemoteDataListView {
|
||||||
|
|
|
@ -12,18 +12,17 @@
|
||||||
|
|
||||||
ClimbingRace::ClimbingRace(QObject *parent) : QObject(parent)
|
ClimbingRace::ClimbingRace(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
this->state = IDLE;
|
this->state = ScStw::ScStw::IDLE;
|
||||||
this->mode = LOCAL;
|
this->mode = LOCAL;
|
||||||
|
|
||||||
this->appSettings = new AppSettings(this);
|
this->appSettings = new AppSettings(this);
|
||||||
this->scStwClient = new ScStwClient(this);
|
this->scStwClient = new ScStwClient();
|
||||||
|
|
||||||
this->scStwClient->setIP(pGlobalAppSettings->loadSetting("baseStationIpAdress"));
|
this->scStwClient->setIP(pGlobalAppSettings->loadSetting("baseStationIpAdress"));
|
||||||
connect(this->scStwClient, &ScStwClient::stateChanged, this, &ClimbingRace::baseStationStateChanged);
|
connect(this->scStwClient, &ScStwClient::stateChanged, this, &ClimbingRace::baseStationStateChanged);
|
||||||
connect(this->scStwClient, &ScStwClient::stateChanged, this, &ClimbingRace::refreshMode);
|
connect(this->scStwClient, &ScStwClient::stateChanged, this, &ClimbingRace::refreshMode);
|
||||||
connect(this->scStwClient, &ScStwClient::connectionsChanged, this, &ClimbingRace::baseStationConnectionsChanged);
|
connect(this->scStwClient, &ScStwClient::gotSignal, this, &ClimbingRace::handleBaseStationSignal);
|
||||||
connect(this->scStwClient, &ScStwClient::gotUpdate, this, &ClimbingRace::handleBaseStationUpdate);
|
connect(this, &ClimbingRace::baseStationStateChanged, this, &ClimbingRace::baseStationPropertiesChanged);
|
||||||
connect(this->scStwClient, &ScStwClient::propertiesChanged, this, &ClimbingRace::baseStationPropertiesChanged);
|
|
||||||
|
|
||||||
this->speedTimers.append( new SpeedTimer(this) );
|
this->speedTimers.append( new SpeedTimer(this) );
|
||||||
|
|
||||||
|
@ -46,7 +45,7 @@ ClimbingRace::ClimbingRace(QObject *parent) : QObject(parent)
|
||||||
|
|
||||||
int ClimbingRace::startRace() {
|
int ClimbingRace::startRace() {
|
||||||
|
|
||||||
if(this->state != IDLE) {
|
if(this->state != ScStw::IDLE) {
|
||||||
return 904;
|
return 904;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +57,9 @@ int ClimbingRace::startRace() {
|
||||||
case LOCAL:
|
case LOCAL:
|
||||||
{
|
{
|
||||||
|
|
||||||
this->setState(STARTING);
|
this->setState(ScStw::STARTING);
|
||||||
|
|
||||||
this->nextStartAction = None;
|
this->nextStartAction = ScStw::None;
|
||||||
this->playSoundsAndStartRace();
|
this->playSoundsAndStartRace();
|
||||||
|
|
||||||
returnCode = 200;
|
returnCode = 200;
|
||||||
|
@ -90,7 +89,7 @@ int ClimbingRace::startRace() {
|
||||||
|
|
||||||
int ClimbingRace::stopRace(int type) {
|
int ClimbingRace::stopRace(int type) {
|
||||||
|
|
||||||
if(this->state != RUNNING && this->state != STARTING) {
|
if(this->state != ScStw::RUNNING && this->state != ScStw::STARTING) {
|
||||||
return 904;
|
return 904;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,13 +109,13 @@ int ClimbingRace::stopRace(int type) {
|
||||||
if(type == 1){
|
if(type == 1){
|
||||||
this->nextStartActionTimer->stop();
|
this->nextStartActionTimer->stop();
|
||||||
this->player->stop();
|
this->player->stop();
|
||||||
this->nextStartAction = None;
|
this->nextStartAction = ScStw::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
returnCode = this->speedTimers[0]->stop(type) ? 200:904;
|
returnCode = this->speedTimers[0]->stop(type) ? 200:904;
|
||||||
|
|
||||||
if(returnCode == 200) {
|
if(returnCode == 200) {
|
||||||
this->setState(STOPPED);
|
this->setState(ScStw::STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -141,7 +140,7 @@ int ClimbingRace::stopRace(int type) {
|
||||||
|
|
||||||
int ClimbingRace::resetRace() {
|
int ClimbingRace::resetRace() {
|
||||||
|
|
||||||
if(this->state != STOPPED) {
|
if(this->state != ScStw::STOPPED) {
|
||||||
return 904;
|
return 904;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +155,7 @@ int ClimbingRace::resetRace() {
|
||||||
returnCode = this->speedTimers[0]->reset() ? 200:904;
|
returnCode = this->speedTimers[0]->reset() ? 200:904;
|
||||||
|
|
||||||
if(returnCode == 200){
|
if(returnCode == 200){
|
||||||
this->setState(IDLE);
|
this->setState(ScStw::IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -193,36 +192,35 @@ int ClimbingRace::resetRace() {
|
||||||
*
|
*
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
void ClimbingRace::handleBaseStationUpdate(QVariant data) {
|
void ClimbingRace::handleBaseStationSignal(ScStw::SignalKey key, QVariant data) {
|
||||||
//qDebug() << "got update: " << data;
|
//qDebug() << "got update: " << data;
|
||||||
int header = data.toMap()["header"].toInt();
|
switch (key) {
|
||||||
switch (header) {
|
case ScStw::RaceStateChanged:
|
||||||
case 9000:
|
|
||||||
{
|
{
|
||||||
// the remote race state has changed
|
// the remote race state has changed
|
||||||
this->setState( raceState( data.toMap()["data"].toInt() ) );
|
this->setState( ScStw::RaceState( data.toMap()["data"].toInt() ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 9001:
|
case ScStw::TimersChanged:
|
||||||
{
|
{
|
||||||
// the remote timers have changed
|
// the remote timers have changed
|
||||||
this->refreshRemoteTimers(data.toMap()["data"].toList());
|
this->refreshRemoteTimers(data.toMap()["data"].toList());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 9002:
|
case ScStw::NextStartActionChanged:
|
||||||
{
|
|
||||||
// the extension connections have changed
|
|
||||||
this->scStwClient->setConnections(data.toMap()["data"].toList());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 9003:
|
|
||||||
{
|
{
|
||||||
// the next start action has changed
|
// the next start action has changed
|
||||||
this->nextStartActionTotalDelay = data.toMap()["data"].toMap()["nextActionDelay"].toDouble();
|
this->nextStartActionTotalDelay = data.toMap()["data"].toMap()["nextActionDelay"].toDouble();
|
||||||
this->nextStartActionDelayStartedAt = this->date->currentMSecsSinceEpoch() - (this->nextStartActionTotalDelay * data.toMap()["data"].toMap()["nextActionDelayProg"].toDouble());
|
this->nextStartActionDelayStartedAt = this->date->currentMSecsSinceEpoch() - (this->nextStartActionTotalDelay * data.toMap()["data"].toMap()["nextActionDelayProg"].toDouble());
|
||||||
this->nextStartAction = NextStartAction( data.toMap()["data"].toMap()["nextAction"].toInt() );
|
this->nextStartAction = ScStw::NextStartAction( data.toMap()["data"].toMap()["nextAction"].toInt() );
|
||||||
|
|
||||||
emit this->nextStartActionChanged();
|
emit this->nextStartActionChanged();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ScStw::ExtensionsChanged:
|
||||||
|
{
|
||||||
|
emit this->baseStationConnectionsChanged();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -269,60 +267,60 @@ void ClimbingRace::playSoundsAndStartRace() {
|
||||||
nextStartActionTimer->disconnect(nextStartActionTimer, SIGNAL(timeout()), this, SLOT(playSoundsAndStartRace()));
|
nextStartActionTimer->disconnect(nextStartActionTimer, SIGNAL(timeout()), this, SLOT(playSoundsAndStartRace()));
|
||||||
|
|
||||||
switch (this->nextStartAction) {
|
switch (this->nextStartAction) {
|
||||||
case AtYourMarks:
|
case ScStw::AtYourMarks:
|
||||||
{
|
{
|
||||||
if(!playSound("qrc:/sounds/at_marks_1.wav")){
|
if(!playSound("qrc:/sounds/at_marks_1.wav")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(appSettings->loadSetting("ready_en") == "true"){
|
if(appSettings->loadSetting("ready_en") == "true"){
|
||||||
nextStartAction = Ready;
|
nextStartAction = ScStw::Ready;
|
||||||
nextStartActionTimer->setInterval(appSettings->loadSetting("ready_delay").toInt() <= 0 ? 1:appSettings->loadSetting("ready_delay").toInt());
|
nextStartActionTimer->setInterval(appSettings->loadSetting("ready_delay").toInt() <= 0 ? 1:appSettings->loadSetting("ready_delay").toInt());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
nextStartAction = Start;
|
nextStartAction = ScStw::Start;
|
||||||
nextStartActionTimer->setInterval(1);
|
nextStartActionTimer->setInterval(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Ready:
|
case ScStw::Ready:
|
||||||
{
|
{
|
||||||
if(!playSound("qrc:/sounds/ready_1.wav")){
|
if(!playSound("qrc:/sounds/ready_1.wav")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nextStartAction = Start;
|
nextStartAction = ScStw::Start;
|
||||||
nextStartActionTimer->setInterval(1);
|
nextStartActionTimer->setInterval(1);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Start:
|
case ScStw::Start:
|
||||||
{
|
{
|
||||||
if(!playSound("qrc:/sounds/IFSC_STARTSIGNAL_SINE.wav")){
|
if(!playSound("qrc:/sounds/IFSC_STARTSIGNAL_SINE.wav")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nextStartAction = None;
|
nextStartAction = ScStw::None;
|
||||||
nextStartActionTimer->disconnect(nextStartActionTimer, SIGNAL(timeout()), this, SLOT(playSoundsAndStartRace()));
|
nextStartActionTimer->disconnect(nextStartActionTimer, SIGNAL(timeout()), this, SLOT(playSoundsAndStartRace()));
|
||||||
|
|
||||||
this->setState(RUNNING);
|
this->setState(ScStw::RUNNING);
|
||||||
speedTimers[0]->start();
|
speedTimers[0]->start();
|
||||||
|
|
||||||
emit this->nextStartActionChanged();
|
emit this->nextStartActionChanged();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case None:
|
case ScStw::None:
|
||||||
{
|
{
|
||||||
this->speedTimers[0]->setState(SpeedTimer::STARTING);
|
this->speedTimers[0]->setState(SpeedTimer::STARTING);
|
||||||
if(appSettings->loadSetting("at_marks_en") == "true"){
|
if(appSettings->loadSetting("at_marks_en") == "true"){
|
||||||
nextStartAction = AtYourMarks;
|
nextStartAction = ScStw::AtYourMarks;
|
||||||
nextStartActionTimer->setInterval(appSettings->loadSetting("at_marks_delay").toInt() <= 0 ? 1:appSettings->loadSetting("at_marks_delay").toInt());
|
nextStartActionTimer->setInterval(appSettings->loadSetting("at_marks_delay").toInt() <= 0 ? 1:appSettings->loadSetting("at_marks_delay").toInt());
|
||||||
}
|
}
|
||||||
else if(appSettings->loadSetting("ready_en") == "true"){
|
else if(appSettings->loadSetting("ready_en") == "true"){
|
||||||
nextStartAction = Ready;
|
nextStartAction = ScStw::Ready;
|
||||||
nextStartActionTimer->setInterval(appSettings->loadSetting("ready_delay").toInt() <= 0 ? 1:appSettings->loadSetting("ready_delay").toInt());
|
nextStartActionTimer->setInterval(appSettings->loadSetting("ready_delay").toInt() <= 0 ? 1:appSettings->loadSetting("ready_delay").toInt());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
nextStartAction = Start;
|
nextStartAction = ScStw::Start;
|
||||||
nextStartActionTimer->setInterval(1);
|
nextStartActionTimer->setInterval(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +360,7 @@ bool ClimbingRace::playSound(QString path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClimbingRace::setState(raceState newState) {
|
void ClimbingRace::setState(ScStw::RaceState newState) {
|
||||||
|
|
||||||
if(newState != this->state) {
|
if(newState != this->state) {
|
||||||
this->state = newState;
|
this->state = newState;
|
||||||
|
@ -371,8 +369,8 @@ void ClimbingRace::setState(raceState newState) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClimbingRace::refreshMode() {
|
void ClimbingRace::refreshMode() {
|
||||||
raceMode newMode;
|
RaceMode newMode;
|
||||||
if(this->scStwClient->getState() == "connected"){
|
if(this->scStwClient->getState() == ScStwClient::CONNECTED){
|
||||||
newMode = REMOTE;
|
newMode = REMOTE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -386,7 +384,7 @@ void ClimbingRace::refreshMode() {
|
||||||
|
|
||||||
// reset race
|
// reset race
|
||||||
// reset state
|
// reset state
|
||||||
this->setState(IDLE);
|
this->setState(ScStw::IDLE);
|
||||||
|
|
||||||
// reset timers
|
// reset timers
|
||||||
// go back to one timer
|
// go back to one timer
|
||||||
|
@ -397,10 +395,6 @@ void ClimbingRace::refreshMode() {
|
||||||
this->speedTimers.clear();
|
this->speedTimers.clear();
|
||||||
|
|
||||||
this->speedTimers.append(new SpeedTimer);
|
this->speedTimers.append(new SpeedTimer);
|
||||||
|
|
||||||
// reset base conn
|
|
||||||
// clear extensions
|
|
||||||
this->scStwClient->connections.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->mode = newMode;
|
this->mode = newMode;
|
||||||
|
@ -462,7 +456,7 @@ void ClimbingRace::refreshTimerText() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*if (this->mode == REMOTE && this->state == IDLE) {
|
/*if (this->mode == REMOTE && this->state == ScStw::IDLE) {
|
||||||
this->nextStartActionDelayProgress = 0;
|
this->nextStartActionDelayProgress = 0;
|
||||||
emit this->nextStartActionDelayProgressChanged();
|
emit this->nextStartActionDelayProgressChanged();
|
||||||
}*/
|
}*/
|
||||||
|
@ -582,31 +576,20 @@ int ClimbingRace::getNextStartAction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClimbingRace::writeSetting(QString key, QVariant value) {
|
void ClimbingRace::writeSetting(QString key, QVariant value) {
|
||||||
this->refreshMode();
|
if(this->mode == REMOTE && this->remoteSettings.contains(key) ){
|
||||||
|
this->scStwClient->writeRemoteSetting(remoteSettings[key], value.toString());
|
||||||
if(this->mode == REMOTE && ( this->remoteSettings.contains(key) || this->remoteOnlySettings.contains(key) ) ){
|
|
||||||
this->scStwClient->writeRemoteSetting(key, value.toString());
|
|
||||||
}
|
}
|
||||||
else if(!this->remoteOnlySettings.contains(key)){
|
else {
|
||||||
this->appSettings->writeSetting(key, value);
|
this->appSettings->writeSetting(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ClimbingRace::readSetting(QString key) {
|
QString ClimbingRace::readSetting(QString key) {
|
||||||
this->refreshMode();
|
if(this->mode == REMOTE && this->remoteSettings.contains(key)){
|
||||||
|
return this->scStwClient->readRemoteSetting(this->remoteSettings[key]);
|
||||||
if(this->mode == REMOTE && ( this->remoteSettings.contains(key) || this->remoteOnlySettings.contains(key) )){
|
|
||||||
QVariantMap reply = this->scStwClient->sendCommand(3001, key);
|
|
||||||
if(reply["status"] != 200){
|
|
||||||
return "false";
|
|
||||||
}
|
|
||||||
return reply["data"].toString();
|
|
||||||
}
|
|
||||||
else if(!this->remoteOnlySettings.contains(key)){
|
|
||||||
return this->appSettings->loadSetting(key);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "false";
|
return this->appSettings->loadSetting(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,7 +603,17 @@ void ClimbingRace::disconnectBaseStation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ClimbingRace::getBaseStationState() {
|
QString ClimbingRace::getBaseStationState() {
|
||||||
return this->scStwClient->getState();
|
switch (this->scStwClient->getState()) {
|
||||||
|
case ScStwClient::CONNECTED:
|
||||||
|
return "connected";
|
||||||
|
case ScStwClient::CONNECTING:
|
||||||
|
return "connecting";
|
||||||
|
case ScStwClient::DISCONNECTED:
|
||||||
|
return "disconnected";
|
||||||
|
case ScStwClient::INITIALISING:
|
||||||
|
return "initialising";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ClimbingRace::getBaseStationConnections() {
|
QVariant ClimbingRace::getBaseStationConnections() {
|
||||||
|
@ -628,8 +621,8 @@ QVariant ClimbingRace::getBaseStationConnections() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap ClimbingRace::getBaseStationProperties() {
|
QVariantMap ClimbingRace::getBaseStationProperties() {
|
||||||
QVariantMap firmware = {{"version", this->scStwClient->firmwareVersion}, {"upToDate", this->scStwClient->firmwareUpToDate}};
|
QVariantMap firmware = {{"version", this->scStwClient->getFirmwareVersion()}, {"upToDate", this->scStwClient->isFirmwareUpToDate()}};
|
||||||
return {{"firmware", firmware}, {"timeOffset", this->scStwClient->timeOffset}};
|
return {{"firmware", firmware}, {"timeOffset", this->scStwClient->getTimeOffset()}};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClimbingRace::updateBasestationFirmware() {
|
bool ClimbingRace::updateBasestationFirmware() {
|
||||||
|
@ -641,7 +634,7 @@ bool ClimbingRace::updateBasestationTime() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClimbingRace::reloadBaseStationIpAdress() {
|
bool ClimbingRace::reloadBaseStationIpAdress() {
|
||||||
if(this->scStwClient->getState() == "disconnected"){
|
if(this->scStwClient->getState() == ScStwClient::DISCONNECTED){
|
||||||
this->scStwClient->setIP(pGlobalAppSettings->loadSetting("baseStationIpAdress"));
|
this->scStwClient->setIP(pGlobalAppSettings->loadSetting("baseStationIpAdress"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,40 +48,13 @@
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
#include <QtAndroidExtras>
|
#include <QtAndroidExtras>
|
||||||
#endif
|
#endif
|
||||||
#include "headers/sqlstoragemodel.h"
|
|
||||||
#include "headers/sqlprofilemodel.h"
|
|
||||||
#include "headers/appsettings.h"
|
#include "headers/appsettings.h"
|
||||||
#include "headers/speedtimer.h"
|
#include "headers/speedtimer.h"
|
||||||
#include "headers/climbingrace.h"
|
#include "headers/climbingrace.h"
|
||||||
#include "headers/apptheme.h"
|
#include "headers/apptheme.h"
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
static void connectToDatabase()
|
|
||||||
{
|
|
||||||
QSqlDatabase database = QSqlDatabase::database();
|
|
||||||
if (!database.isValid()) {
|
|
||||||
database = QSqlDatabase::addDatabase("QSQLITE");
|
|
||||||
if (!database.isValid())
|
|
||||||
qFatal("Cannot add database: %s", qPrintable(database.lastError().text()));
|
|
||||||
}
|
|
||||||
|
|
||||||
const QDir writeDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
|
||||||
|
|
||||||
if (!writeDir.mkpath("."))
|
|
||||||
qFatal("Failed to create writable directory at %s", qPrintable(writeDir.absolutePath()));
|
|
||||||
|
|
||||||
// Ensure that we have a writable location on all devices.
|
|
||||||
const QString fileName = writeDir.absolutePath() + "/chat-database.sqlite3";
|
|
||||||
//QFile::remove(fileName);
|
|
||||||
// When using the SQLite driver, open() will create the SQLite database if it doesn't exist.
|
|
||||||
database.setDatabaseName(fileName);
|
|
||||||
if (!database.open()) {
|
|
||||||
QFile::remove(fileName);
|
|
||||||
qFatal("Cannot open database: %s", qPrintable(database.lastError().text()));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
@ -106,14 +79,8 @@ int main(int argc, char *argv[])
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
connectToDatabase();
|
|
||||||
|
|
||||||
AppSettings * pAppSettings = new AppSettings();
|
AppSettings * pAppSettings = new AppSettings();
|
||||||
|
|
||||||
//setup the sql storage model as a qml model
|
|
||||||
qmlRegisterType<SqlProfileModel>("com.itsblue.speedclimbingstopwatch", 1, 0, "SqlProfileModel");
|
|
||||||
qmlRegisterType<SqlStorageModel>("com.itsblue.speedclimbingstopwatch", 1, 0, "SqlStorageModel");
|
|
||||||
|
|
||||||
// setup speed backend and App themes
|
// setup speed backend and App themes
|
||||||
qmlRegisterType<ClimbingRace>("com.itsblue.speedclimbingstopwatch", 2, 0, "SpeedBackend");
|
qmlRegisterType<ClimbingRace>("com.itsblue.speedclimbingstopwatch", 2, 0, "SpeedBackend");
|
||||||
qmlRegisterType<AppTheme>("com.itsblue.speedclimbingstopwatch", 2, 0, "AppTheme");
|
qmlRegisterType<AppTheme>("com.itsblue.speedclimbingstopwatch", 2, 0, "AppTheme");
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5ea17449e7cb9fceda20b9e78733512d5b2e1575
|
Subproject commit b752bdeed25f17b4840b2b215e8695eca4bfa711
|
Reference in a new issue