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

appimage updated

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