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;
};
......@@ -13,20 +13,20 @@
#include "TilePtrArray.h"
#include "geometry/ProgressArray.h"
// Singelton class used to interface measurement devices implementing the nemo
// interface.
class NemoInterface : public QObject {
class NemointerfaceFactory;
class Nemointerface : public QObject {
Q_OBJECT
class Impl;
using PImpl = std::unique_ptr<Impl>;
NemoInterface();
NemoInterface(NemoInterface &other) = delete;
static NemoInterface *createInstance();
Nemointerface(const QString &connectionString);
Nemointerface(Nemointerface &other) = delete;
friend class NemointerfaceFactory;
public:
~NemoInterface() override;
static NemoInterface *instance();
~Nemointerface() override;
enum class STATUS {
NOT_CONNECTED,
......@@ -90,6 +90,7 @@ public:
QString infoString() const;
QString warningString() const;
bool running() const;
QString connectionString();
signals:
void statusChanged();
......@@ -103,4 +104,25 @@ private:
PImpl pImpl;
};
#define pNemoInterface NemoInterface::instance()
// Singelton class used for nemo interface creation.
class NemointerfaceFactory {
NemointerfaceFactory();
NemointerfaceFactory(const NemointerfaceFactory &other) = delete;
static NemointerfaceFactory *createInstance();
public:
~NemointerfaceFactory();
static NemointerfaceFactory *instance();
// Creates a interface with a connection string connectionString.
// Two different interfaces can't share the same connection string.
std::shared_ptr<Nemointerface> create(const QString &connectionString);
// Returns true if an interface with connection string connectionString can
// be created (i.e. doesn't exist yet), returns false either.
bool isCreatable(const QString &connectionString);
private:
std::map<QString, std::weak_ptr<Nemointerface>> _map;
};
#define pNemoInterfaceFactory NemointerfaceFactory::instance()
......@@ -17,6 +17,13 @@
"min": 1,
"decimalPlaces": 1,
"default": 10.0
},
{
"name": "ConnectionString",
"shrotDesc": "Nemo Connection String.",
"longDesc": "Nemo Connection String (e.g. host_ip:port).",
"type": "string",
"default": "localhost:9090"
}
]
}
......@@ -672,7 +672,7 @@ void QGCApplication::_initCommon() {
qmlRegisterUncreatableType<routing::LinearGenerator>(
"MeasurementComplexItem", 1, 0, "LinearGenerator", kRefOnly);
qmlRegisterType<AreaData>("MeasurementComplexItem", 1, 0, "AreaData");
qmlRegisterSingletonType<NemoInterface>("MeasurementComplexItem", 1, 0,
qmlRegisterSingletonType<Nemointerface>("MeasurementComplexItem", 1, 0,
"NemoInterface", getNemoInterface);
qmlRegisterInterface<routing::GeneratorBase>("GeneratorBase");
qmlRegisterUncreatableType<routing::CircularGenerator>(
......
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