Commit 5598870e authored by Valentin Platzgummer's avatar Valentin Platzgummer

appimage updated

parent 7a0b738b
......@@ -97,6 +97,7 @@ LinuxBuild {
libQt5Sql.so.5 \
libQt5Svg.so.5 \
libQt5Test.so.5 \
libQt5WebSockets.so.5 \
libQt5Widgets.so.5 \
libQt5X11Extras.so.5 \
libQt5XcbQpa.so.5 \
......
......@@ -99,7 +99,6 @@ public:
const QString &warningString() const;
private:
void _doTopicServiceSetup();
void _checkVersion();
void _subscribeProgressTopic();
void _subscribeHearbeatTopic();
......@@ -143,8 +142,9 @@ private:
void
_addTilesRemote2(std::shared_ptr<QVector<std::shared_ptr<Tile>>> pTileArray,
std::promise<bool> promise);
void _setTiles(std::shared_ptr<QVector<std::shared_ptr<Tile>>> pTileArray,
std::promise<bool> promise);
void
_compareAndSync(std::shared_ptr<QVector<std::shared_ptr<Tile>>> pTileArray,
std::promise<bool> promise);
void _setVersion(QString version, std::promise<bool> promise);
void _removeTilesRemote(std::shared_ptr<IDArray> idArray,
std::promise<bool> promise);
......@@ -640,15 +640,11 @@ void NemoInterface::Impl::_setWarningString(const QString &warning) {
}
}
void NemoInterface::Impl::_doTopicServiceSetup() {}
void NemoInterface::Impl::_checkVersion() {
auto pTask = std::make_unique<nemo_interface::Task>([this] {
// wait for service
std::future<bool> fut;
long tries = 0;
long maxTries = 50;
do {
fut = this->_pRosbridge->serviceAvailable("/nemo/get_version");
......@@ -662,17 +658,6 @@ void NemoInterface::Impl::_checkVersion() {
break;
}
}
++tries;
if (tries > maxTries) {
qCWarning(NemoInterfaceLog)
<< "_checkVersion: service /nemo/get_version not available.";
bool value =
QMetaObject::invokeMethod(this->_parent /* context */, [this]() {
this->_setWarningString("Version checking failed.");
});
Q_ASSERT(value == true);
return QVariant(false);
}
} while (!fut.get());
// call service
......@@ -686,8 +671,6 @@ void NemoInterface::Impl::_subscribeProgressTopic() {
auto pTask = std::make_unique<nemo_interface::Task>([this] {
// wait for service
std::future<bool> fut;
long tries = 0;
long maxTries = 50;
do {
fut = this->_pRosbridge->topicAvailable(progressTopic);
......@@ -701,17 +684,6 @@ void NemoInterface::Impl::_subscribeProgressTopic() {
break;
}
}
++tries;
if (tries > maxTries) {
qCWarning(NemoInterfaceLog)
<< "_subscribeProgressTopic: topic /nemo/progress not available.";
bool value =
QMetaObject::invokeMethod(this->_parent /* context */, [this]() {
this->_setWarningString("Progress topic not available.");
});
Q_ASSERT(value == true);
return QVariant(false);
}
} while (!fut.get());
// subscribe
......@@ -772,8 +744,6 @@ void NemoInterface::Impl::_subscribeHearbeatTopic() {
auto pTask = std::make_unique<nemo_interface::Task>([this] {
// wait for service
std::future<bool> fut;
long tries = 0;
long maxTries = 50;
do {
fut = this->_pRosbridge->topicAvailable(heartbeatTopic);
......@@ -787,17 +757,6 @@ void NemoInterface::Impl::_subscribeHearbeatTopic() {
break;
}
}
++tries;
if (tries > maxTries) {
qCWarning(NemoInterfaceLog)
<< "_subscribeHeartbeatTopic: topic /nemo/hearbeat not available.";
bool value =
QMetaObject::invokeMethod(this->_parent /* context */, [this]() {
this->_setWarningString("Heartbeat topic not available.");
});
Q_ASSERT(value == true);
return QVariant(false);
}
} while (!fut.get());
// subscribe
......@@ -926,7 +885,7 @@ void NemoInterface::Impl::_tryRestart() {
}
bool NemoInterface::Impl::_isSynchronized() const {
return _localTiles.size() > 0 && _remoteTiles.size() > 0 &&
return _localTiles.size() == _remoteTiles.size() &&
std::equal(
_localTiles.begin(), _localTiles.end(), _remoteTiles.begin(),
[](const auto &a, const auto &b) { return a.first == b.first; });
......@@ -1416,7 +1375,7 @@ QVariant NemoInterface::Impl::_callGetAllTiles() {
auto future = promise.get_future();
bool value = QMetaObject::invokeMethod(
this->_parent, [this, pArray, promise = std::move(promise)]() mutable {
this->_setTiles(pArray, std::move(promise));
this->_compareAndSync(pArray, std::move(promise));
});
Q_ASSERT(value == true);
......@@ -1525,17 +1484,17 @@ void NemoInterface::Impl::_addTilesRemote2(
// qDebug() << "_addTilesRemote2 called";
bool anyChange = false;
bool error = false;
ProgressArray array;
for (auto &&pTile : *pTileArray) {
auto id = pTile->id();
auto it = _remoteTiles.find(id);
if (Q_LIKELY(it == _remoteTiles.end())) {
auto ret = _remoteTiles.insert(std::make_pair(id, pTile));
array.push_back(LabeledProgress(pTile->progress(), pTile->id()));
Q_ASSERT(ret.second == true);
Q_UNUSED(ret);
anyChange = true;
} else {
qCWarning(NemoInterfaceLog)
<< "_addTilesRemote: tile with id " << id << " already added.";
......@@ -1545,40 +1504,37 @@ void NemoInterface::Impl::_addTilesRemote2(
}
}
if (anyChange) {
if (array.size() > 0) {
if (this->_isSynchronized()) {
this->_setState(STATE::READY);
this->_doAction();
}
emit this->_parent->progressChanged(array);
}
promise.set_value(!error);
}
void NemoInterface::Impl::_setTiles(
void NemoInterface::Impl::_compareAndSync(
std::shared_ptr<QVector<std::shared_ptr<Tile>>> pTileArray,
std::promise<bool> promise) {
bool error = false;
_remoteTiles.clear();
for (auto &&pTile : *pTileArray) {
auto id = pTile->id();
auto it = _remoteTiles.find(id);
if (Q_LIKELY(it == _remoteTiles.end())) {
auto ret = _remoteTiles.insert(std::make_pair(id, pTile));
Q_ASSERT(ret.second == true);
Q_UNUSED(ret);
} else {
qCWarning(NemoInterfaceLog)
<< "_addTilesRemote: tile with id " << id << " already added.";
error = true;
bool synced = std::size_t(pTileArray->size()) == _localTiles.size();
if (synced) {
for (auto it = pTileArray->begin(); it != pTileArray->end(); ++it) {
auto match = _localTiles.find((*it)->id());
if (match == _localTiles.end()) {
synced = false;
}
}
}
if (error || !this->_isSynchronized()) {
qDebug() << "_setTiles: trying to synchronize";
if (!synced) {
qDebug() << "_compareAndSync: trying to synchronize";
_trySynchronize();
} else {
_remoteTiles.clear();
_addTilesRemote2(pTileArray, std::promise<bool>());
}
promise.set_value(true);
......@@ -1588,9 +1544,9 @@ void NemoInterface::Impl::_setVersion(QString version,
std::promise<bool> promise) {
_remoteVersion = version;
if (_remoteVersion != _localVersion) {
_setWarningString("Local protocol version (" + _localVersion +
") does not match remote version (" + _remoteVersion +
").");
_setWarningString("Version checking failed. Local protocol version (" +
_localVersion + ") does not match remote version (" +
_remoteVersion + ").");
} else {
_versionOK = true;
_doAction();
......
......@@ -52,8 +52,8 @@ void TaskDispatcher::start() {
ULock lk1(this->_mutex);
if (!_running) {
this->_running = true;
lk1.unlock();
_future = QtConcurrent::run([this]() mutable { return this->run(); });
lk1.unlock();
}
}
......@@ -67,8 +67,8 @@ void TaskDispatcher::stop() {
}
void TaskDispatcher::reset() {
clear();
stop();
clear();
}
bool TaskDispatcher::isInterruptionRequested() {
......@@ -102,7 +102,10 @@ void TaskDispatcher::run() {
lk1.unlock();
// exec task
promise.set_value(pTask->exec());
QVariant var = pTask->exec();
bool r = var.toBool();
Q_ASSERT(r == true || r == false);
promise.set_value(var);
} else {
this->_running = false;
lk1.unlock();
......
......@@ -20,7 +20,6 @@ Rectangle {
property bool checked: true
property var missionItem: undefined
property int availableWidth: 300
property bool error: errorString.lenght >= 0
readonly property bool running: _nemoInterface.running
property string warningString: _nemoInterface.warningString
property string infoString: _nemoInterface.infoString
......@@ -44,21 +43,6 @@ Rectangle {
rowSpacing: _margin
columns: 2
QGCLabel {
text: _root.errorString
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignLeft
color: "orange"
Layout.columnSpan: parent.columns
Layout.fillWidth: true
}
QGCLabel {
text: _root.infoString
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignLeft
Layout.columnSpan: parent.columns
Layout.fillWidth: true
}
QGCButton {
text: running ? qsTr("Stop") : qsTr("Start")
......@@ -81,6 +65,24 @@ Rectangle {
Layout.fillWidth: true
}
QGCLabel {
text: _root.warningString
visible: text.length > 0
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignLeft
color: "orange"
Layout.columnSpan: parent.columns
Layout.fillWidth: true
}
QGCLabel {
text: _root.infoString
visible: text.length > 0
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignLeft
Layout.columnSpan: parent.columns
Layout.fillWidth: true
}
SectionHeader {
id: progressHeader
Layout.fillWidth: true
......
......@@ -3,6 +3,7 @@
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QTimer>
static const char *advertiseOpKey = "advertise";
static const char *subscribeOpKey = "subscribe";
......@@ -259,6 +260,8 @@ void RosbridgeImpl::_clearAllPendingServiceCalls() {
}
}
void RosbridgeImpl::_checkIfConnected() {}
void RosbridgeImpl::callService(const QString &service,
const Rosbridge::CallBack &callback,
const QJsonObject &req) {
......@@ -368,6 +371,14 @@ void RosbridgeImpl::_doAction() {
break;
case STATE::STARTING:
_webSocket.open(_url);
// open again if no connection was established
QTimer::singleShot(2000, this, [this] {
if (this->_state == STATE::STARTING) {
_doAction();
}
});
break;
case STATE::TIMEOUT:
break;
......
......@@ -71,6 +71,7 @@ private:
void _serviceResponse(const QString &service, const QString &id, bool result,
const QJsonObject &values);
void _clearAllPendingServiceCalls();
void _checkIfConnected();
QWebSocket _webSocket;
QUrl _url;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment