- added icons in the top left corner which indicate connection status to the bas estation and off extentions connected to the base station
- minor changes
This commit is contained in:
parent
1f8fdab69f
commit
ef60a4065a
13 changed files with 117 additions and 71 deletions
BIN
graphics/BaseStation.xcf
Normal file
BIN
graphics/BaseStation.xcf
Normal file
Binary file not shown.
BIN
graphics/icons/BaseStation.png
Normal file
BIN
graphics/icons/BaseStation.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.1 KiB |
BIN
graphics/icons/BaseStation_black.png
Normal file
BIN
graphics/icons/BaseStation_black.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
|
@ -24,7 +24,7 @@ signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QVariant getStyle();
|
QVariant getStyle();
|
||||||
Q_INVOKABLE bool changeTheme();
|
Q_INVOKABLE void changeTheme();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPTHEME_H
|
#endif // APPTHEME_H
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
// values for the socket connection
|
// values for the socket connection
|
||||||
int connection_progress;
|
int connection_progress;
|
||||||
QString ip;
|
QString ip;
|
||||||
qint16 port = 3563;
|
ushort port = 3563;
|
||||||
int errors;
|
int errors;
|
||||||
int errors_until_disconnect = 4;
|
int errors_until_disconnect = 4;
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ class ClimbingRace : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(int state READ getState NOTIFY stateChanged)
|
Q_PROPERTY(int state READ getState NOTIFY stateChanged)
|
||||||
|
Q_PROPERTY(int mode READ getMode NOTIFY modeChanged)
|
||||||
Q_PROPERTY(QVariant timers READ getTimerTextList NOTIFY timerTextChanged)
|
Q_PROPERTY(QVariant timers READ getTimerTextList NOTIFY timerTextChanged)
|
||||||
Q_PROPERTY(QString baseStationState READ getBaseStationState NOTIFY baseStationStateChanged)
|
Q_PROPERTY(QString baseStationState READ getBaseStationState NOTIFY baseStationStateChanged)
|
||||||
Q_PROPERTY(QVariant baseStationConnections READ getBaseStationConnections NOTIFY baseStationConnectionsChanged)
|
Q_PROPERTY(QVariant baseStationConnections READ getBaseStationConnections NOTIFY baseStationConnectionsChanged)
|
||||||
|
@ -38,6 +39,8 @@ private:
|
||||||
QTimer * timerTextRefreshTimer;
|
QTimer * timerTextRefreshTimer;
|
||||||
QTimer * nextStartActionTimer;
|
QTimer * nextStartActionTimer;
|
||||||
|
|
||||||
|
QDateTime *date;
|
||||||
|
|
||||||
QList<SpeedTimer *> speedTimers;
|
QList<SpeedTimer *> speedTimers;
|
||||||
|
|
||||||
int nextStartAction;
|
int nextStartAction;
|
||||||
|
@ -63,6 +66,7 @@ signals:
|
||||||
void nextStartActionDelayProgressChanged();
|
void nextStartActionDelayProgressChanged();
|
||||||
|
|
||||||
void stateChanged(int state);
|
void stateChanged(int state);
|
||||||
|
void modeChanged();
|
||||||
void timerTextChanged();
|
void timerTextChanged();
|
||||||
void baseStationStateChanged();
|
void baseStationStateChanged();
|
||||||
void baseStationConnectionsChanged();
|
void baseStationConnectionsChanged();
|
||||||
|
@ -76,6 +80,7 @@ public slots:
|
||||||
|
|
||||||
// functions for qml
|
// functions for qml
|
||||||
Q_INVOKABLE int getState();
|
Q_INVOKABLE int getState();
|
||||||
|
Q_INVOKABLE int getMode();
|
||||||
Q_INVOKABLE QVariant getTimerTextList();
|
Q_INVOKABLE QVariant getTimerTextList();
|
||||||
Q_INVOKABLE double getNextStartActionDelayProgress();
|
Q_INVOKABLE double getNextStartActionDelayProgress();
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ Image {
|
||||||
source: "qrc:/graphics/icons/buzzer_black.png"
|
source: "qrc:/graphics/icons/buzzer_black.png"
|
||||||
mipmap: true
|
mipmap: true
|
||||||
|
|
||||||
opacity: status !== "disconnected" ? 1:0
|
opacity: status === "connected" || status === "connecting" ? 1:0
|
||||||
visible: false
|
visible: true
|
||||||
|
|
||||||
width: height
|
width: height
|
||||||
onOpacityChanged: visible = true
|
onOpacityChanged: visible = true
|
||||||
|
|
|
@ -47,7 +47,7 @@ Item {
|
||||||
enabled: true
|
enabled: true
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: root.animationDuration
|
duration: root.animationDuration
|
||||||
easing.type: Easing.InOutCubic
|
easing.type: Easing.Linear
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ Item {
|
||||||
enabled: true
|
enabled: true
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: root.animationDuration
|
duration: root.animationDuration
|
||||||
easing.type: Easing.InOutCubic
|
easing.type: Easing.Linear
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
59
qml/main.qml
59
qml/main.qml
|
@ -141,6 +141,63 @@ Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: connectionIconContainer
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
top: parent.top
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
bottom: parent.bottom
|
||||||
|
bottomMargin: root.landscape() ? 0:parent.height * 0.8
|
||||||
|
rightMargin: root.landscape() ? parent.width * 0.8:0
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionIcon {
|
||||||
|
id: baseConnConnIcon
|
||||||
|
status: speedBackend.baseStationState
|
||||||
|
|
||||||
|
source: "qrc:/graphics/icons/BaseStation_black.png"
|
||||||
|
anchors {
|
||||||
|
top: parent.top
|
||||||
|
topMargin: 10
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: 10
|
||||||
|
}
|
||||||
|
scale: 1.3
|
||||||
|
height: !root.landscape()? parent.height*0.3:parent.width*0.3
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionIcon {
|
||||||
|
id: buzzerConnIcon
|
||||||
|
status: speedBackend.baseStationConnections[1]["state"]
|
||||||
|
|
||||||
|
source: "qrc:/graphics/icons/buzzer_black.png"
|
||||||
|
anchors {
|
||||||
|
top: parent.top
|
||||||
|
topMargin: 10
|
||||||
|
left: baseConnConnIcon.right
|
||||||
|
leftMargin: 1
|
||||||
|
}
|
||||||
|
height: !root.landscape()? parent.height*0.17:parent.width*0.17
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionIcon {
|
||||||
|
id: startpadConnIcon
|
||||||
|
status: speedBackend.baseStationConnections[0]["state"]
|
||||||
|
|
||||||
|
source: "qrc:/graphics/icons/startpad_black.png"
|
||||||
|
anchors {
|
||||||
|
top: parent.top
|
||||||
|
topMargin: 10
|
||||||
|
left: buzzerConnIcon.right
|
||||||
|
leftMargin: 0
|
||||||
|
}
|
||||||
|
height: !root.landscape() ? parent.height*0.17:parent.width*0.17
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: upper_line
|
id: upper_line
|
||||||
width: root.landscape() ? 1:parent.width
|
width: root.landscape() ? 1:parent.width
|
||||||
|
@ -226,7 +283,7 @@ Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
animationDuration: 0
|
animationDuration: speedBackend.mode === 1 ? 150:0
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------
|
/*----------------------
|
||||||
|
|
|
@ -22,5 +22,7 @@
|
||||||
<file>graphics/icons/startpad_black.png</file>
|
<file>graphics/icons/startpad_black.png</file>
|
||||||
<file>sounds/false.wav</file>
|
<file>sounds/false.wav</file>
|
||||||
<file>graphics/icons/error.png</file>
|
<file>graphics/icons/error.png</file>
|
||||||
|
<file>graphics/icons/BaseStation.png</file>
|
||||||
|
<file>graphics/icons/BaseStation_black.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -82,7 +82,7 @@ QVariant AppTheme::getStyle() {
|
||||||
return *this->currentTheme;
|
return *this->currentTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppTheme::changeTheme() {
|
void AppTheme::changeTheme() {
|
||||||
QString currentThemeString = pGlobalAppSettings->loadSetting("theme");
|
QString currentThemeString = pGlobalAppSettings->loadSetting("theme");
|
||||||
QString newThemeString = "Light";
|
QString newThemeString = "Light";
|
||||||
|
|
||||||
|
|
|
@ -122,14 +122,6 @@ QVariantMap BaseConn::sendCommand(int header, QJsonValue data){
|
||||||
|
|
||||||
QString jsonRequest = QJsonDocument(requestObj).toJson();
|
QString jsonRequest = QJsonDocument(requestObj).toJson();
|
||||||
|
|
||||||
QByteArray arrBlock;
|
|
||||||
QDataStream out(&arrBlock, QIODevice::WriteOnly);
|
|
||||||
//out.setVersion(QDataStream::Qt_5_10);
|
|
||||||
out << quint16(0) << jsonRequest;
|
|
||||||
|
|
||||||
out.device()->seek(0);
|
|
||||||
out << quint16(ulong(arrBlock.size()) - sizeof(quint16));
|
|
||||||
|
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
|
|
||||||
timer.setSingleShot(true);
|
timer.setSingleShot(true);
|
||||||
|
@ -142,7 +134,7 @@ QVariantMap BaseConn::sendCommand(int header, QJsonValue data){
|
||||||
|
|
||||||
//write data
|
//write data
|
||||||
|
|
||||||
socket->write(arrBlock);
|
socket->write(jsonRequest.toLatin1());
|
||||||
|
|
||||||
//wait for an answer to finish (programm gets stuck in here)
|
//wait for an answer to finish (programm gets stuck in here)
|
||||||
loop.exec();
|
loop.exec();
|
||||||
|
@ -171,50 +163,27 @@ QVariantMap BaseConn::sendCommand(int header, QJsonValue data){
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseConn::readyRead() {
|
void BaseConn::readyRead() {
|
||||||
QDataStream in(socket);
|
|
||||||
//in.setVersion(QDataStream::Qt_5_10);
|
|
||||||
qint16 nextBlockSize = 0;
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (!nextBlockSize)
|
|
||||||
{
|
|
||||||
if (ulong(socket->bytesAvailable()) < sizeof(quint16)) { break; }
|
|
||||||
in >> nextBlockSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (socket->bytesAvailable() < nextBlockSize) { break; }
|
QString reply = socket->readAll();
|
||||||
|
int id = 0;
|
||||||
|
|
||||||
QString str; in >> str;
|
QJsonDocument jsonReply = QJsonDocument::fromJson(reply.toUtf8());
|
||||||
|
QJsonObject replyObj = jsonReply.object();
|
||||||
|
|
||||||
// if (str == "0")
|
if(!replyObj.isEmpty()){
|
||||||
// {
|
id = replyObj.value("id").toInt();
|
||||||
// str = "Connection closed";
|
|
||||||
// closeConnection();
|
|
||||||
// }
|
|
||||||
|
|
||||||
nextBlockSize = 0;
|
for(int i = 0; i < this->waitingRequests.length(); i++){
|
||||||
QString reply = str;
|
if(this->waitingRequests[i].id == id){
|
||||||
int id = 0;
|
this->waitingRequests[i].reply = replyObj;
|
||||||
|
this->waitingRequests[i].loop->quit();
|
||||||
QJsonDocument jsonReply = QJsonDocument::fromJson(reply.toUtf8());
|
return;
|
||||||
QJsonObject replyObj = jsonReply.object();
|
|
||||||
|
|
||||||
if(!replyObj.isEmpty()){
|
|
||||||
id = replyObj.value("id").toInt();
|
|
||||||
|
|
||||||
for(int i = 0; i < this->waitingRequests.length(); i++){
|
|
||||||
if(this->waitingRequests[i].id == id){
|
|
||||||
this->waitingRequests[i].reply = replyObj;
|
|
||||||
this->waitingRequests[i].loop->quit();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
latestReadReply = str;
|
|
||||||
emit gotUnexpectedReply(str);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
latestReadReply = reply;
|
||||||
|
emit gotUnexpectedReply(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BaseConn::writeRemoteSetting(QString key, QString value) {
|
int BaseConn::writeRemoteSetting(QString key, QString value) {
|
||||||
|
|
|
@ -18,18 +18,19 @@ 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("192.168.4.1");
|
this->baseConn->setIP("ScStw");
|
||||||
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 );
|
||||||
|
|
||||||
this->player = new QMediaPlayer;
|
this->player = new QMediaPlayer;
|
||||||
|
this->date = new QDateTime;
|
||||||
|
|
||||||
this->nextStartActionTimer = new QTimer(this);
|
this->nextStartActionTimer = new QTimer(this);
|
||||||
nextStartActionTimer->setSingleShot(true);
|
nextStartActionTimer->setSingleShot(true);
|
||||||
|
|
||||||
this->baseStationSyncTimer = new QTimer();
|
this->baseStationSyncTimer = new QTimer();
|
||||||
this->baseStationSyncTimer->setInterval(10);
|
this->baseStationSyncTimer->setInterval(100);
|
||||||
this->baseStationSyncTimer->setSingleShot(true);
|
this->baseStationSyncTimer->setSingleShot(true);
|
||||||
this->baseStationSyncTimer->connect(this->baseStationSyncTimer, &QTimer::timeout, this, &ClimbingRace::syncWithBaseStation);
|
this->baseStationSyncTimer->connect(this->baseStationSyncTimer, &QTimer::timeout, this, &ClimbingRace::syncWithBaseStation);
|
||||||
this->baseStationSyncTimer->start();
|
this->baseStationSyncTimer->start();
|
||||||
|
@ -228,19 +229,19 @@ void ClimbingRace::syncWithBaseStation() {
|
||||||
speedTimers[0]->setState(SpeedTimer::STARTING);
|
speedTimers[0]->setState(SpeedTimer::STARTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpReply = this->baseConn->sendCommand(2004);
|
// tmpReply = this->baseConn->sendCommand(2004);
|
||||||
if(tmpReply["status"] != 200){
|
// if(tmpReply["status"] != 200){
|
||||||
//handle Error!!
|
// //handle Error!!
|
||||||
qDebug() << "+ --- getting next start action from basestation failed: " << tmpReply["status"];
|
// qDebug() << "+ --- getting next start action from basestation failed: " << tmpReply["status"];
|
||||||
this->baseStationSyncTimer->start();
|
// this->baseStationSyncTimer->start();
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
if(this->nextStartAction != tmpReply["data"].toInt()){
|
// if(this->nextStartAction != tmpReply["data"].toInt()){
|
||||||
this->nextStartAction = tmpReply["data"].toInt();
|
// this->nextStartAction = tmpReply["data"].toInt();
|
||||||
this->nextStartActionChanged(this->nextStartAction);
|
// this->nextStartActionChanged(this->nextStartAction);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
tmpReply = this->baseConn->sendCommand(2005);
|
tmpReply = this->baseConn->sendCommand(2005);
|
||||||
if(tmpReply["status"] != 200){
|
if(tmpReply["status"] != 200){
|
||||||
|
@ -270,6 +271,7 @@ void ClimbingRace::syncWithBaseStation() {
|
||||||
else {
|
else {
|
||||||
QVariantList timers = tmpReply["data"].toList();
|
QVariantList timers = tmpReply["data"].toList();
|
||||||
|
|
||||||
|
speedTimers[0]->startTime = this->date->currentMSecsSinceEpoch() - timers[0].toMap()["currTime"].toDouble();
|
||||||
speedTimers[0]->stoppedTime = timers[0].toMap()["currTime"].toDouble();
|
speedTimers[0]->stoppedTime = timers[0].toMap()["currTime"].toDouble();
|
||||||
speedTimers[0]->reactionTime = timers[0].toMap()["reactTime"].toDouble();
|
speedTimers[0]->reactionTime = timers[0].toMap()["reactTime"].toDouble();
|
||||||
|
|
||||||
|
@ -392,12 +394,19 @@ void ClimbingRace::setState(raceState newState) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClimbingRace::refreshMode() {
|
void ClimbingRace::refreshMode() {
|
||||||
|
raceMode newMode;
|
||||||
if(this->baseConn->state == "connected"){
|
if(this->baseConn->state == "connected"){
|
||||||
this->mode = REMOTE;
|
newMode = REMOTE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this->mode = LOCAL;
|
newMode = LOCAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this->mode != newMode){
|
||||||
|
this->mode = newMode;
|
||||||
|
emit this->modeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClimbingRace::refreshTimerText() {
|
void ClimbingRace::refreshTimerText() {
|
||||||
|
@ -456,6 +465,10 @@ int ClimbingRace::getState() {
|
||||||
return this->state;
|
return this->state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ClimbingRace::getMode() {
|
||||||
|
return this->mode;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant ClimbingRace::getTimerTextList() {
|
QVariant ClimbingRace::getTimerTextList() {
|
||||||
return this->qmlTimers;
|
return this->qmlTimers;
|
||||||
// QVariantList test;
|
// QVariantList test;
|
||||||
|
|
Reference in a new issue