Commit a4d09405 authored by Valentin Platzgummer's avatar Valentin Platzgummer

temp

parent 670dffae
......@@ -41,6 +41,7 @@ const char *variantNamesKey = "VariantNames";
const char *generatorArrayKey = "GeneratorArray";
const char *variantArrayKey = "VariantArray";
const char *generatorIndexKey = "GeneratorIndex";
const char *connectionsStringKey = "ConnectionString";
} // namespace
MeasurementComplexItem::MeasurementComplexItem(
......@@ -55,7 +56,8 @@ MeasurementComplexItem::MeasurementComplexItem(
_variantIndex(settingsGroup, _metaDataMap[variantIndexKey]),
_pAreaData(new AreaData(this)), _pEditorData(new AreaData(this)),
_pCurrentData(_pAreaData), _holdProgress(false), _pGenerator(nullptr),
_pWorker(new RoutingThread(this)) {
_pWorker(new RoutingThread(this)),
_nemoCString(settingsGroup, _metaDataMap[connectionsStringKey]) {
// Setup altitude.
_altitude.setRawValue(qgcApp()
......@@ -91,17 +93,17 @@ MeasurementComplexItem::MeasurementComplexItem(
&MeasurementComplexItem::_storeRoutingData);
// Connect coordinate and exitCoordinate.
connect(this, &MeasurementComplexItem::routeChanged,
connect(this, &MeasurementComplexItem::routeChanged, this,
[this] { emit this->coordinateChanged(this->coordinate()); });
connect(this, &MeasurementComplexItem::routeChanged,
connect(this, &MeasurementComplexItem::routeChanged, this,
[this] { emit this->exitCoordinateChanged(this->exitCoordinate()); });
connect(this, &MeasurementComplexItem::routeChanged, [this] {
connect(this, &MeasurementComplexItem::routeChanged, this, [this] {
emit this->exitCoordinateSameAsEntryChanged(
this->exitCoordinateSameAsEntry());
});
// Connect isIncomplete.
connect(this, &MeasurementComplexItem::idleChanged, [this] {
connect(this, &MeasurementComplexItem::idleChanged, this, [this] {
if (this->idle()) {
if (this->route().size() > 0 && this->_isIncomplete == true) {
this->_isIncomplete = false;
......@@ -124,14 +126,14 @@ MeasurementComplexItem::MeasurementComplexItem(
&MeasurementComplexItem::_updateFlightpathSegments);
// Connect complexDistance.
connect(this, &MeasurementComplexItem::routeChanged,
connect(this, &MeasurementComplexItem::routeChanged, this,
[this] { emit this->complexDistanceChanged(); });
resetGenerators();
startEditing();
// connect to nemo interface
connect(pNemoInterface, &NemoInterface::progressChanged, this,
connect(pNemoInterface, &Nemointerface::progressChanged, this,
&MeasurementComplexItem::_onNewProgress);
}
......@@ -773,6 +775,17 @@ void MeasurementComplexItem::_onAltitudeChanged() {
}
}
QString MeasurementComplexItem::nemoError() const { return _nemoError; }
void MeasurementComplexItem::_setNemoError(const QString &nemoError) {
if (_nemoError != nemoError) {
_nemoError = nemoError;
emit nemoErrorChanged();
}
}
Fact *MeasurementComplexItem::nemoCString() { return &_nemoCString; }
bool MeasurementComplexItem::holdProgress() const { return _holdProgress; }
void MeasurementComplexItem::setHoldProgress(bool holdProgress) {
......@@ -781,10 +794,10 @@ void MeasurementComplexItem::setHoldProgress(bool holdProgress) {
emit holdProgressChanged();
if (_holdProgress) {
disconnect(pNemoInterface, &NemoInterface::progressChanged, this,
disconnect(pNemoInterface, &Nemointerface::progressChanged, this,
&MeasurementComplexItem::_onNewProgress);
} else {
connect(pNemoInterface, &NemoInterface::progressChanged, this,
connect(pNemoInterface, &Nemointerface::progressChanged, this,
&MeasurementComplexItem::_onNewProgress);
_onNewProgress(pNemoInterface->getProgress());
}
......
......@@ -14,6 +14,7 @@
class RoutingThread;
class RoutingResult;
class Nemointerface;
namespace routing {
class GeneratorBase;
......@@ -51,6 +52,8 @@ public:
Q_PROPERTY(int generatorIndex READ generatorIndex NOTIFY generatorChanged)
Q_PROPERTY(AreaData *areaData READ areaData NOTIFY areaDataChanged)
Q_PROPERTY(QVariantList route READ route NOTIFY routeChanged)
Q_PROPERTY(QString nemoError READ nemoError NOTIFY nemoErrorChanged)
Q_PROPERTY(Fact *nemoCString READ nemoCString CONSTANT)
Q_INVOKABLE void reverseRoute(void);
......@@ -224,6 +227,10 @@ public:
bool holdProgress() const;
void setHoldProgress(bool holdProgress);
QString nemoError() const;
Fact *nemoCString();
signals:
void variantNamesChanged();
......@@ -238,6 +245,8 @@ signals:
void routeChanged();
void holdProgressChanged();
void nemoErrorChanged();
private slots:
// Worker functions.
......@@ -257,6 +266,7 @@ private:
static bool _idle(STATE state);
void _updateFlightpathSegments();
void _onAltitudeChanged();
void _setNemoError(const QString &nemoError);
// Hirarcical stuff.
int _sequenceNumber;
......@@ -285,4 +295,9 @@ private:
QVector<Variant> _variantVector;
Variant _route;
PtrWorker _pWorker;
// NemoInterface
std::shared_ptr<Nemointerface> _pNemointerface;
QString _nemoError;
SettingsFact _nemoCString;
};
......@@ -11,6 +11,7 @@
#include <QJsonArray>
#include <QJsonObject>
#include <QQmlEngine>
#include <QTimer>
#include <QUrl>
......@@ -52,7 +53,7 @@
Q_DECLARE_METATYPE(ProgressArray)
QGC_LOGGING_CATEGORY(NemoInterfaceLog, "NemoInterfaceLog")
QGC_LOGGING_CATEGORY(NemointerfaceLog, "NemointerfaceLog")
#define NO_HEARTBEAT_TIMEOUT 5000 // ms
#define RESTART_INTERVAl 600000 // ms == 10 min
......@@ -98,7 +99,7 @@ typedef ros_bridge::messages::nemo_msgs::heartbeat::Heartbeat Heartbeat;
typedef nemo_interface::TaskDispatcher Dispatcher;
typedef std::unique_lock<std::mutex> Lock;
class NemoInterface::Impl {
class Nemointerface::Impl {
enum class STATE {
STOPPED,
START_BRIDGE,
......@@ -113,7 +114,7 @@ class NemoInterface::Impl {
};
public:
Impl(NemoInterface *p);
Impl(const QString &connectionString, Nemointerface *p);
~Impl();
void start();
......@@ -136,12 +137,13 @@ public:
ProgressArray getProgress() const;
ProgressArray getProgress(const IDArray &idArray) const;
NemoInterface::STATUS status() const;
Nemointerface::STATUS status() const;
bool running() const; // thread safe
bool ready() const; // thread safe
const QString &infoString() const;
const QString &warningString() const;
const QString &connectionString() const;
private:
void _doSetup();
......@@ -167,9 +169,9 @@ private:
static bool _userSyncNotSafe(STATE s);
static bool _sysSyncNotSafe(STATE s);
static bool _runningNotSafe(STATE s);
static NemoInterface::STATUS _status(STATE state);
static Nemointerface::STATUS _status(STATE state);
static QString _toString(STATE s);
static QString _toString(NemoInterface::STATUS s);
static QString _toString(Nemointerface::STATUS s);
// impl functions
bool _addTilesImpl(
......@@ -201,10 +203,11 @@ private:
// static and const members
static const char *_localVersion;
NemoInterface *const _parent;
Nemointerface *const _parent;
const QString _connectionString;
// thread safe members
ROSBridgePtr _pRosbridge;
Rosbridge _rosbridge;
Dispatcher _dispatcher;
// protected by mutex
......@@ -221,51 +224,33 @@ private:
QTimer _restartTimer;
};
const char *NemoInterface::Impl::_localVersion("V_1.0");
const char *Nemointerface::Impl::_localVersion("V_1.0");
using StatusMap = std::map<NemoInterface::STATUS, QString>;
using StatusMap = std::map<Nemointerface::STATUS, QString>;
static StatusMap statusMap{
std::make_pair<NemoInterface::STATUS, QString>(
NemoInterface::STATUS::NOT_CONNECTED, "Not Connected"),
std::make_pair<NemoInterface::STATUS, QString>(NemoInterface::STATUS::ERROR,
std::make_pair<Nemointerface::STATUS, QString>(
Nemointerface::STATUS::NOT_CONNECTED, "Not Connected"),
std::make_pair<Nemointerface::STATUS, QString>(Nemointerface::STATUS::ERROR,
"ERROR"),
std::make_pair<NemoInterface::STATUS, QString>(NemoInterface::STATUS::SYNC,
std::make_pair<Nemointerface::STATUS, QString>(Nemointerface::STATUS::SYNC,
"Synchronizing"),
std::make_pair<NemoInterface::STATUS, QString>(NemoInterface::STATUS::READY,
std::make_pair<Nemointerface::STATUS, QString>(Nemointerface::STATUS::READY,
"Ready"),
std::make_pair<NemoInterface::STATUS, QString>(
NemoInterface::STATUS::TIMEOUT, "Timeout"),
std::make_pair<NemoInterface::STATUS, QString>(
NemoInterface::STATUS::WEBSOCKET_DETECTED, "Websocket Detected")};
NemoInterface::Impl::Impl(NemoInterface *p)
: _parent(p), _state(STATE::STOPPED) {
// ROS Bridge.
WimaSettings *wimaSettings =
qgcApp()->toolbox()->settingsManager()->wimaSettings();
auto connectionStringFact = wimaSettings->rosbridgeConnectionString();
auto setConnectionString = [connectionStringFact, this] {
auto connectionString = connectionStringFact->rawValue().toString();
bool wasRunning = this->running();
this->stop();
this->_pRosbridge = std::make_shared<Rosbridge>(
QUrl(QString("ws://") + connectionString.toLocal8Bit().data()));
if (wasRunning) {
this->start();
}
};
std::make_pair<Nemointerface::STATUS, QString>(
Nemointerface::STATUS::TIMEOUT, "Timeout"),
std::make_pair<Nemointerface::STATUS, QString>(
Nemointerface::STATUS::WEBSOCKET_DETECTED, "Websocket Detected")};
connect(connectionStringFact, &SettingsFact::rawValueChanged,
setConnectionString);
setConnectionString();
Nemointerface::Impl::Impl(const QString &connectionString, Nemointerface *p)
: _parent(p), _connectionString(connectionString),
_rosbridge(QUrl(QString("ws://") + connectionString)),
_state(STATE::STOPPED) {
// Heartbeat timeout.
connect(&this->_timeoutTimer, &QTimer::timeout,
std::bind(&Impl::_onHeartbeatTimeout, this));
connect(this->_pRosbridge.get(), &Rosbridge::stateChanged, this->_parent,
connect(&this->_rosbridge, &Rosbridge::stateChanged, this->_parent,
[this] { this->_onRosbridgeStateChanged(); });
connect(&this->_restartTimer, &QTimer::timeout, this->_parent,
......@@ -278,9 +263,9 @@ NemoInterface::Impl::Impl(NemoInterface *p)
std::call_once(flag, [] { qRegisterMetaType<ProgressArray>(); });
}
NemoInterface::Impl::~Impl() { this->_pRosbridge->stop(); }
Nemointerface::Impl::~Impl() { this->_rosbridge.stop(); }
void NemoInterface::Impl::start() {
void Nemointerface::Impl::start() {
Lock lk(this->_m);
if (!_runningNotSafe(this->_state)) {
this->_setStateNotSafe(STATE::START_BRIDGE);
......@@ -288,7 +273,7 @@ void NemoInterface::Impl::start() {
}
}
void NemoInterface::Impl::stop() {
void Nemointerface::Impl::stop() {
Lock lk(this->_m);
if (_runningNotSafe(this->_state)) {
this->_setStateNotSafe(STATE::STOPPED);
......@@ -297,7 +282,7 @@ void NemoInterface::Impl::stop() {
}
std::shared_future<QVariant>
NemoInterface::Impl::addTiles(const TilePtrArray &tileArray) {
Nemointerface::Impl::addTiles(const TilePtrArray &tileArray) {
using namespace nemo_interface;
// qDebug() << "addTiles called";
......@@ -320,7 +305,7 @@ NemoInterface::Impl::addTiles(const TilePtrArray &tileArray) {
pTileArray->push_back(pTileCopy);
pIdArray->push_back(id);
} else {
qCDebug(NemoInterfaceLog)
qCDebug(NemointerfaceLog)
<< "addTiles(): tile with id: " << pTile->id() << "already added.";
}
}
......@@ -364,7 +349,7 @@ NemoInterface::Impl::addTiles(const TilePtrArray &tileArray) {
}
std::shared_future<QVariant>
NemoInterface::Impl::removeTiles(const IDArray &idArray) {
Nemointerface::Impl::removeTiles(const IDArray &idArray) {
using namespace nemo_interface;
// qDebug() << "removeTiles called";
......@@ -382,7 +367,7 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) {
_localTiles.erase(it);
pIdArray->push_back(id);
} else {
qCDebug(NemoInterfaceLog) << "removeTiles(): unknown id: " << id << ".";
qCDebug(NemointerfaceLog) << "removeTiles(): unknown id: " << id << ".";
}
}
if (pIdArray->size() > 0) {
......@@ -426,7 +411,7 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) {
return p.get_future();
}
std::shared_future<QVariant> NemoInterface::Impl::clearTiles() {
std::shared_future<QVariant> Nemointerface::Impl::clearTiles() {
using namespace nemo_interface;
// qDebug() << "clearTiles called";
......@@ -472,7 +457,7 @@ std::shared_future<QVariant> NemoInterface::Impl::clearTiles() {
}
}
TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) const {
TileArray Nemointerface::Impl::getTiles(const IDArray &idArray) const {
TileArray tileArray;
Lock lk(this->_m);
......@@ -503,7 +488,7 @@ TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) const {
return tileArray;
}
TileArray NemoInterface::Impl::getAllTiles() const {
TileArray Nemointerface::Impl::getAllTiles() const {
TileArray tileArray;
Lock lk(this->_m);
......@@ -531,7 +516,7 @@ TileArray NemoInterface::Impl::getAllTiles() const {
return tileArray;
}
LogicalArray NemoInterface::Impl::containsTiles(const IDArray &idArray) const {
LogicalArray Nemointerface::Impl::containsTiles(const IDArray &idArray) const {
LogicalArray logicalArray;
Lock lk(this->_m);
......@@ -543,18 +528,18 @@ LogicalArray NemoInterface::Impl::containsTiles(const IDArray &idArray) const {
return logicalArray;
}
std::size_t NemoInterface::Impl::size() const {
std::size_t Nemointerface::Impl::size() const {
Lock lk(this->_m);
return _localTiles.size();
}
bool NemoInterface::Impl::empty() const {
bool Nemointerface::Impl::empty() const {
Lock lk(this->_m);
return _localTiles.empty();
}
ProgressArray NemoInterface::Impl::getProgress() const {
ProgressArray Nemointerface::Impl::getProgress() const {
ProgressArray progressArray;
Lock lk(this->_m);
......@@ -573,7 +558,7 @@ ProgressArray NemoInterface::Impl::getProgress() const {
return progressArray;
}
ProgressArray NemoInterface::Impl::getProgress(const IDArray &idArray) const {
ProgressArray Nemointerface::Impl::getProgress(const IDArray &idArray) const {
ProgressArray progressArray;
Lock lk(this->_m);
......@@ -598,34 +583,34 @@ ProgressArray NemoInterface::Impl::getProgress(const IDArray &idArray) const {
return progressArray;
}
NemoInterface::STATUS NemoInterface::Impl::status() const {
Nemointerface::STATUS Nemointerface::Impl::status() const {
Lock lk(this->_m);
return _status(this->_state);
}
bool NemoInterface::Impl::running() const {
bool Nemointerface::Impl::running() const {
Lock lk1(this->_m);
return _runningNotSafe(this->_state);
}
bool NemoInterface::Impl::ready() const {
bool Nemointerface::Impl::ready() const {
Lock lk1(this->_m);
return _readyNotSafe(this->_state);
}
bool NemoInterface::Impl::_sysSync() const {
bool Nemointerface::Impl::_sysSync() const {
Lock lk1(this->_m);
return _sysSyncNotSafe(this->_state);
}
void NemoInterface::Impl::_onHeartbeatTimeout() {
void Nemointerface::Impl::_onHeartbeatTimeout() {
Lock lk1(this->_m);
this->_setStateNotSafe(STATE::HEARTBEAT_TIMEOUT);
this->_doActionNotSafe();
}
void NemoInterface::Impl::_onRosbridgeStateChanged() {
auto rbState = this->_pRosbridge->state();
void Nemointerface::Impl::_onRosbridgeStateChanged() {
auto rbState = this->_rosbridge.state();
if (rbState == Rosbridge::STATE::CONNECTED) {
Lock lk1(this->_m);
if (this->_state == STATE::START_BRIDGE ||
......@@ -644,22 +629,26 @@ void NemoInterface::Impl::_onRosbridgeStateChanged() {
}
}
bool NemoInterface::Impl::_userSync() const {
bool Nemointerface::Impl::_userSync() const {
Lock lk1(this->_m);
return _userSyncNotSafe(this->_state);
}
const QString &NemoInterface::Impl::infoString() const {
const QString &Nemointerface::Impl::infoString() const {
Lock lk1(this->_m);
return _infoString;
}
const QString &NemoInterface::Impl::warningString() const {
const QString &Nemointerface::Impl::warningString() const {
Lock lk1(this->_m);
return _warningString;
}
bool NemoInterface::Impl::_updateProgress(const ProgressArray &pArray) {
const QString &Nemointerface::Impl::connectionString() const {
return this->_connectionString;
}
bool Nemointerface::Impl::_updateProgress(const ProgressArray &pArray) {
ProgressArray copy;
bool error = false;
......@@ -673,7 +662,7 @@ bool NemoInterface::Impl::_updateProgress(const ProgressArray &pArray) {
it->second->setProgress(itLP->progress());
copy.push_back(*itLP);
} else {
qCDebug(NemoInterfaceLog)
qCDebug(NemointerfaceLog)
<< "_updateProgress(): tile with id " << itLP->id() << " not found.";
error = true;
}
......@@ -687,7 +676,7 @@ bool NemoInterface::Impl::_updateProgress(const ProgressArray &pArray) {
return !error;
}
void NemoInterface::Impl::_onHeartbeatReceived(const QNemoHeartbeat &) {
void Nemointerface::Impl::_onHeartbeatReceived(const QNemoHeartbeat &) {
INVM(this->_parent,
([this]() mutable { this->_timeoutTimer.start(NO_HEARTBEAT_TIMEOUT); }))
......@@ -699,7 +688,7 @@ void NemoInterface::Impl::_onHeartbeatReceived(const QNemoHeartbeat &) {
}
}
void NemoInterface::Impl::_setInfoStringNotSafe(const QString &info) {
void Nemointerface::Impl::_setInfoStringNotSafe(const QString &info) {
if (_infoString != info) {
_infoString = info;
......@@ -709,7 +698,7 @@ void NemoInterface::Impl::_setInfoStringNotSafe(const QString &info) {
}
}
void NemoInterface::Impl::_setWarningStringNotSafe(const QString &warning) {
void Nemointerface::Impl::_setWarningStringNotSafe(const QString &warning) {
if (_warningString != warning) {
_warningString = warning;
......@@ -719,20 +708,20 @@ void NemoInterface::Impl::_setWarningStringNotSafe(const QString &warning) {
}
}
void NemoInterface::Impl::_setInfoString(const QString &info) {
void Nemointerface::Impl::_setInfoString(const QString &info) {
Lock lk(this->_m);
_setInfoStringNotSafe(info);
}
void NemoInterface::Impl::_setWarningString(const QString &warning) {
void Nemointerface::Impl::_setWarningString(const QString &warning) {
Lock lk(this->_m);
_setWarningStringNotSafe(warning);
}
void NemoInterface::Impl::_doSetup() {
void Nemointerface::Impl::_doSetup() {
// create task
auto pTask = std::make_unique<nemo_interface::Task>([this] {
auto rb = this->_pRosbridge;
auto &rb = this->_rosbridge;
auto &disp = this->_dispatcher;
// check if required services are available
......@@ -742,7 +731,7 @@ void NemoInterface::Impl::_doSetup() {
this->_setInfoString("Waiting for required service " + s);
auto available = rb->waitForService(cc, cond);
auto available = rb.waitForService(cc, cond);
if (!available) {
return QVariant(false);
}
......@@ -750,7 +739,7 @@ void NemoInterface::Impl::_doSetup() {
// check if version is compatible{
this->_setInfoString("Checking version.");
auto version = _callGetVersion(disp, *rb);
auto version = _callGetVersion(disp, rb);
if (version != _localVersion) {
this->_setWarningString(
"Version checking failed. Local protocol version (" +
......@@ -763,14 +752,14 @@ void NemoInterface::Impl::_doSetup() {
for (const auto &cc : requiredTopics) {
QString s(cc);
this->_setInfoString("Waiting for required topic " + s);
auto available = rb->waitForTopic(cc, cond);
auto available = rb.waitForTopic(cc, cond);
if (!available) {
return QVariant(false);
}
}
// subscribe topics
rb->subscribeTopic(progressTopic, [this](const QJsonObject &o) {
rb.subscribeTopic(progressTopic, [this](const QJsonObject &o) {
ros_bridge::messages::nemo_msgs::progress_array::ProgressArray
progressArray;
if (ros_bridge::messages::nemo_msgs::progress_array::fromJson(
......@@ -789,7 +778,7 @@ void NemoInterface::Impl::_doSetup() {
}
if (rangeError) {
qCWarning(NemoInterfaceLog) << progressTopic
qCWarning(NemointerfaceLog) << progressTopic
<< " progress out "
"of range, value was set to: "
<< lp.progress();
......@@ -799,7 +788,7 @@ void NemoInterface::Impl::_doSetup() {
if (!ret)
this->_setWarningString("Progress update failed.");
} else {
qCWarning(NemoInterfaceLog) << progressTopic
qCWarning(NemointerfaceLog) << progressTopic
<< " not able to "
"create ProgressArray form json: "
<< o;
......@@ -807,12 +796,12 @@ void NemoInterface::Impl::_doSetup() {
});
using namespace ros_bridge::messages;
rb->subscribeTopic(heartbeatTopic, [this](const QJsonObject &o) {
rb.subscribeTopic(heartbeatTopic, [this](const QJsonObject &o) {
nemo_msgs::heartbeat::Heartbeat heartbeat;
if (nemo_msgs::heartbeat::fromJson(o, heartbeat)) {
this->_onHeartbeatReceived(heartbeat);
} else {
qCWarning(NemoInterfaceLog) << heartbeatTopic
qCWarning(NemointerfaceLog) << heartbeatTopic
<< " not able to "
"create Heartbeat form json: "
<< o;
......@@ -832,7 +821,7 @@ void NemoInterface::Impl::_doSetup() {
Q_UNUSED(f);
}
void NemoInterface::Impl::_synchronize() {
void Nemointerface::Impl::_synchronize() {
Lock lk(this->_m);
if (this->_state == STATE::READY || this->_state == STATE::SYNC_ERROR) {
......@@ -848,11 +837,11 @@ void NemoInterface::Impl::_synchronize() {
// create cmd.
auto pTask = std::make_unique<nemo_interface::Task>([this, pTileArray] {
auto rb = this->_pRosbridge;
auto &rb = this->_rosbridge;
auto &disp = this->_dispatcher;
// are _localTiles and _remoteTiles synced?
auto remoteTiles = this->_callGetAllTiles(disp, *rb);
auto remoteTiles = this->_callGetAllTiles(disp, rb);
// create tile map;
std::map<QString, std::shared_ptr<Tile>> tempMap;
......@@ -861,7 +850,7 @@ void NemoInterface::Impl::_synchronize() {
if (Q_LIKELY(it == tempMap.end())) {
tempMap.insert(std::make_pair(pTile->id(), pTile));
} else {
qCDebug(NemoInterfaceLog)
qCDebug(NemointerfaceLog)
<< "_synchronizeIfNeccessary(): remoteTiles contains "
"duplicate id";
}
......@@ -918,7 +907,7 @@ void NemoInterface::Impl::_synchronize() {
this->_doActionNotSafe();
lk.unlock();
this->_setWarningString("Getting progress failed.");
qCDebug(NemoInterfaceLog)
qCDebug(NemointerfaceLog)
<< "_addTilesImpl(): _updateProgress failed: unknown id.";
return QVariant(false);
}
......@@ -947,7 +936,7 @@ void NemoInterface::Impl::_synchronize() {
}
}
void NemoInterface::Impl::_tryRestart() {
void Nemointerface::Impl::_tryRestart() {
if (this->running()) {
if (_dispatcher.idle()) {
qDebug() << "_tryRestart: restarting";
......@@ -960,19 +949,19 @@ void NemoInterface::Impl::_tryRestart() {
}
}
bool NemoInterface::Impl::_isSynchronizedNotSafe() const {
bool Nemointerface::Impl::_isSynchronizedNotSafe() const {
return _localTiles.size() == _remoteTiles.size() &&
std::equal(
_localTiles.begin(), _localTiles.end(), _remoteTiles.begin(),
[](const auto &a, const auto &b) { return a.first == b.first; });
}
bool NemoInterface::Impl::_isSynchronized() const {
bool Nemointerface::Impl::_isSynchronized() const {
Lock lk(this->_m);
return _isSynchronizedNotSafe();
}
void NemoInterface::Impl::_doActionNotSafe() {
void Nemointerface::Impl::_doActionNotSafe() {
static bool resetDone = false;
switch (this->_state) {
case STATE::STOPPED: {
......@@ -983,8 +972,8 @@ void NemoInterface::Impl::_doActionNotSafe() {
this->_syncTimer.stop();
}))
if (this->_pRosbridge->state() != Rosbridge::STATE::STOPPED) {
this->_pRosbridge->stop();
if (this->_rosbridge.state() != Rosbridge::STATE::STOPPED) {
this->_rosbridge.stop();
}
_dispatcher.stop();
_dispatcher.clear();
......@@ -998,7 +987,7 @@ void NemoInterface::Impl::_doActionNotSafe() {
INVM(this->_parent,
([this]() mutable { this->_restartTimer.start(RESTART_INTERVAl); }))
this->_pRosbridge->start();
this->_rosbridge.start();
} break;
case STATE::WEBSOCKET_DETECTED:
resetDone = false;
......@@ -1036,8 +1025,8 @@ void NemoInterface::Impl::_doActionNotSafe() {
if (!resetDone) {
resetDone = true;
this->_pRosbridge->stop();
this->_pRosbridge->start();
this->_rosbridge.stop();
this->_rosbridge.start();
}
_dispatcher.stop();
_dispatcher.clear();
......@@ -1048,7 +1037,7 @@ void NemoInterface::Impl::_doActionNotSafe() {
};
}
bool NemoInterface::Impl::_callAddTiles(
bool Nemointerface::Impl::_callAddTiles(
const QVector<std::shared_ptr<const Tile>> &tileArray, Dispatcher &d,
Rosbridge &rb) {
......@@ -1060,7 +1049,7 @@ bool NemoInterface::Impl::_callAddTiles(
using namespace ros_bridge::messages;
QJsonObject jsonTile;
if (!nemo_msgs::tile::toJson(*tile, jsonTile)) {
qCDebug(NemoInterfaceLog)
qCDebug(NemointerfaceLog)
<< "addTiles(): not able to create json object: tile id: "
<< tile->id() << " progress: " << tile->progress()
<< " points: " << tile->tile();
......@@ -1079,7 +1068,7 @@ bool NemoInterface::Impl::_callAddTiles(
if (o.contains("success") && o["success"].isBool()) {