Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
a4d09405
Commit
a4d09405
authored
Jan 31, 2021
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp
parent
670dffae
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
324 additions
and
213 deletions
+324
-213
MeasurementComplexItem.cc
src/MeasurementComplexItem/MeasurementComplexItem.cc
+22
-9
MeasurementComplexItem.h
src/MeasurementComplexItem/MeasurementComplexItem.h
+15
-0
NemoInterface.cpp
src/MeasurementComplexItem/NemoInterface.cpp
+248
-194
NemoInterface.h
src/MeasurementComplexItem/NemoInterface.h
+31
-9
MeasurementComplexItem.SettingsGroup.json
...omplexItem/json/MeasurementComplexItem.SettingsGroup.json
+7
-0
QGCApplication.cc
src/QGCApplication.cc
+1
-1
No files found.
src/MeasurementComplexItem/MeasurementComplexItem.cc
View file @
a4d09405
...
@@ -41,6 +41,7 @@ const char *variantNamesKey = "VariantNames";
...
@@ -41,6 +41,7 @@ const char *variantNamesKey = "VariantNames";
const
char
*
generatorArrayKey
=
"GeneratorArray"
;
const
char
*
generatorArrayKey
=
"GeneratorArray"
;
const
char
*
variantArrayKey
=
"VariantArray"
;
const
char
*
variantArrayKey
=
"VariantArray"
;
const
char
*
generatorIndexKey
=
"GeneratorIndex"
;
const
char
*
generatorIndexKey
=
"GeneratorIndex"
;
const
char
*
connectionsStringKey
=
"ConnectionString"
;
}
// namespace
}
// namespace
MeasurementComplexItem
::
MeasurementComplexItem
(
MeasurementComplexItem
::
MeasurementComplexItem
(
...
@@ -55,7 +56,8 @@ MeasurementComplexItem::MeasurementComplexItem(
...
@@ -55,7 +56,8 @@ MeasurementComplexItem::MeasurementComplexItem(
_variantIndex
(
settingsGroup
,
_metaDataMap
[
variantIndexKey
]),
_variantIndex
(
settingsGroup
,
_metaDataMap
[
variantIndexKey
]),
_pAreaData
(
new
AreaData
(
this
)),
_pEditorData
(
new
AreaData
(
this
)),
_pAreaData
(
new
AreaData
(
this
)),
_pEditorData
(
new
AreaData
(
this
)),
_pCurrentData
(
_pAreaData
),
_holdProgress
(
false
),
_pGenerator
(
nullptr
),
_pCurrentData
(
_pAreaData
),
_holdProgress
(
false
),
_pGenerator
(
nullptr
),
_pWorker
(
new
RoutingThread
(
this
))
{
_pWorker
(
new
RoutingThread
(
this
)),
_nemoCString
(
settingsGroup
,
_metaDataMap
[
connectionsStringKey
])
{
// Setup altitude.
// Setup altitude.
_altitude
.
setRawValue
(
qgcApp
()
_altitude
.
setRawValue
(
qgcApp
()
...
@@ -91,17 +93,17 @@ MeasurementComplexItem::MeasurementComplexItem(
...
@@ -91,17 +93,17 @@ MeasurementComplexItem::MeasurementComplexItem(
&
MeasurementComplexItem
::
_storeRoutingData
);
&
MeasurementComplexItem
::
_storeRoutingData
);
// Connect coordinate and exitCoordinate.
// Connect coordinate and exitCoordinate.
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
this
,
[
this
]
{
emit
this
->
coordinateChanged
(
this
->
coordinate
());
});
[
this
]
{
emit
this
->
coordinateChanged
(
this
->
coordinate
());
});
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
this
,
[
this
]
{
emit
this
->
exitCoordinateChanged
(
this
->
exitCoordinate
());
});
[
this
]
{
emit
this
->
exitCoordinateChanged
(
this
->
exitCoordinate
());
});
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
[
this
]
{
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
this
,
[
this
]
{
emit
this
->
exitCoordinateSameAsEntryChanged
(
emit
this
->
exitCoordinateSameAsEntryChanged
(
this
->
exitCoordinateSameAsEntry
());
this
->
exitCoordinateSameAsEntry
());
});
});
// Connect isIncomplete.
// Connect isIncomplete.
connect
(
this
,
&
MeasurementComplexItem
::
idleChanged
,
[
this
]
{
connect
(
this
,
&
MeasurementComplexItem
::
idleChanged
,
this
,
[
this
]
{
if
(
this
->
idle
())
{
if
(
this
->
idle
())
{
if
(
this
->
route
().
size
()
>
0
&&
this
->
_isIncomplete
==
true
)
{
if
(
this
->
route
().
size
()
>
0
&&
this
->
_isIncomplete
==
true
)
{
this
->
_isIncomplete
=
false
;
this
->
_isIncomplete
=
false
;
...
@@ -124,14 +126,14 @@ MeasurementComplexItem::MeasurementComplexItem(
...
@@ -124,14 +126,14 @@ MeasurementComplexItem::MeasurementComplexItem(
&
MeasurementComplexItem
::
_updateFlightpathSegments
);
&
MeasurementComplexItem
::
_updateFlightpathSegments
);
// Connect complexDistance.
// Connect complexDistance.
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
this
,
[
this
]
{
emit
this
->
complexDistanceChanged
();
});
[
this
]
{
emit
this
->
complexDistanceChanged
();
});
resetGenerators
();
resetGenerators
();
startEditing
();
startEditing
();
// connect to nemo interface
// connect to nemo interface
connect
(
pNemoInterface
,
&
Nemo
I
nterface
::
progressChanged
,
this
,
connect
(
pNemoInterface
,
&
Nemo
i
nterface
::
progressChanged
,
this
,
&
MeasurementComplexItem
::
_onNewProgress
);
&
MeasurementComplexItem
::
_onNewProgress
);
}
}
...
@@ -773,6 +775,17 @@ void MeasurementComplexItem::_onAltitudeChanged() {
...
@@ -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
;
}
bool
MeasurementComplexItem
::
holdProgress
()
const
{
return
_holdProgress
;
}
void
MeasurementComplexItem
::
setHoldProgress
(
bool
holdProgress
)
{
void
MeasurementComplexItem
::
setHoldProgress
(
bool
holdProgress
)
{
...
@@ -781,10 +794,10 @@ void MeasurementComplexItem::setHoldProgress(bool holdProgress) {
...
@@ -781,10 +794,10 @@ void MeasurementComplexItem::setHoldProgress(bool holdProgress) {
emit
holdProgressChanged
();
emit
holdProgressChanged
();
if
(
_holdProgress
)
{
if
(
_holdProgress
)
{
disconnect
(
pNemoInterface
,
&
Nemo
I
nterface
::
progressChanged
,
this
,
disconnect
(
pNemoInterface
,
&
Nemo
i
nterface
::
progressChanged
,
this
,
&
MeasurementComplexItem
::
_onNewProgress
);
&
MeasurementComplexItem
::
_onNewProgress
);
}
else
{
}
else
{
connect
(
pNemoInterface
,
&
Nemo
I
nterface
::
progressChanged
,
this
,
connect
(
pNemoInterface
,
&
Nemo
i
nterface
::
progressChanged
,
this
,
&
MeasurementComplexItem
::
_onNewProgress
);
&
MeasurementComplexItem
::
_onNewProgress
);
_onNewProgress
(
pNemoInterface
->
getProgress
());
_onNewProgress
(
pNemoInterface
->
getProgress
());
}
}
...
...
src/MeasurementComplexItem/MeasurementComplexItem.h
View file @
a4d09405
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
class
RoutingThread
;
class
RoutingThread
;
class
RoutingResult
;
class
RoutingResult
;
class
Nemointerface
;
namespace
routing
{
namespace
routing
{
class
GeneratorBase
;
class
GeneratorBase
;
...
@@ -51,6 +52,8 @@ public:
...
@@ -51,6 +52,8 @@ public:
Q_PROPERTY
(
int
generatorIndex
READ
generatorIndex
NOTIFY
generatorChanged
)
Q_PROPERTY
(
int
generatorIndex
READ
generatorIndex
NOTIFY
generatorChanged
)
Q_PROPERTY
(
AreaData
*
areaData
READ
areaData
NOTIFY
areaDataChanged
)
Q_PROPERTY
(
AreaData
*
areaData
READ
areaData
NOTIFY
areaDataChanged
)
Q_PROPERTY
(
QVariantList
route
READ
route
NOTIFY
routeChanged
)
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
);
Q_INVOKABLE
void
reverseRoute
(
void
);
...
@@ -224,6 +227,10 @@ public:
...
@@ -224,6 +227,10 @@ public:
bool
holdProgress
()
const
;
bool
holdProgress
()
const
;
void
setHoldProgress
(
bool
holdProgress
);
void
setHoldProgress
(
bool
holdProgress
);
QString
nemoError
()
const
;
Fact
*
nemoCString
();
signals:
signals:
void
variantNamesChanged
();
void
variantNamesChanged
();
...
@@ -238,6 +245,8 @@ signals:
...
@@ -238,6 +245,8 @@ signals:
void
routeChanged
();
void
routeChanged
();
void
holdProgressChanged
();
void
holdProgressChanged
();
void
nemoErrorChanged
();
private
slots
:
private
slots
:
// Worker functions.
// Worker functions.
...
@@ -257,6 +266,7 @@ private:
...
@@ -257,6 +266,7 @@ private:
static
bool
_idle
(
STATE
state
);
static
bool
_idle
(
STATE
state
);
void
_updateFlightpathSegments
();
void
_updateFlightpathSegments
();
void
_onAltitudeChanged
();
void
_onAltitudeChanged
();
void
_setNemoError
(
const
QString
&
nemoError
);
// Hirarcical stuff.
// Hirarcical stuff.
int
_sequenceNumber
;
int
_sequenceNumber
;
...
@@ -285,4 +295,9 @@ private:
...
@@ -285,4 +295,9 @@ private:
QVector
<
Variant
>
_variantVector
;
QVector
<
Variant
>
_variantVector
;
Variant
_route
;
Variant
_route
;
PtrWorker
_pWorker
;
PtrWorker
_pWorker
;
// NemoInterface
std
::
shared_ptr
<
Nemointerface
>
_pNemointerface
;
QString
_nemoError
;
SettingsFact
_nemoCString
;
};
};
src/MeasurementComplexItem/NemoInterface.cpp
View file @
a4d09405
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include <QJsonArray>
#include <QJsonArray>
#include <QJsonObject>
#include <QJsonObject>
#include <QQmlEngine>
#include <QTimer>
#include <QTimer>
#include <QUrl>
#include <QUrl>
...
@@ -52,7 +53,7 @@
...
@@ -52,7 +53,7 @@
Q_DECLARE_METATYPE
(
ProgressArray
)
Q_DECLARE_METATYPE
(
ProgressArray
)
QGC_LOGGING_CATEGORY
(
Nemo
InterfaceLog
,
"NemoI
nterfaceLog"
)
QGC_LOGGING_CATEGORY
(
Nemo
interfaceLog
,
"Nemoi
nterfaceLog"
)
#define NO_HEARTBEAT_TIMEOUT 5000 // ms
#define NO_HEARTBEAT_TIMEOUT 5000 // ms
#define RESTART_INTERVAl 600000 // ms == 10 min
#define RESTART_INTERVAl 600000 // ms == 10 min
...
@@ -98,7 +99,7 @@ typedef ros_bridge::messages::nemo_msgs::heartbeat::Heartbeat Heartbeat;
...
@@ -98,7 +99,7 @@ typedef ros_bridge::messages::nemo_msgs::heartbeat::Heartbeat Heartbeat;
typedef
nemo_interface
::
TaskDispatcher
Dispatcher
;
typedef
nemo_interface
::
TaskDispatcher
Dispatcher
;
typedef
std
::
unique_lock
<
std
::
mutex
>
Lock
;
typedef
std
::
unique_lock
<
std
::
mutex
>
Lock
;
class
Nemo
I
nterface
::
Impl
{
class
Nemo
i
nterface
::
Impl
{
enum
class
STATE
{
enum
class
STATE
{
STOPPED
,
STOPPED
,
START_BRIDGE
,
START_BRIDGE
,
...
@@ -113,7 +114,7 @@ class NemoInterface::Impl {
...
@@ -113,7 +114,7 @@ class NemoInterface::Impl {
};
};
public:
public:
Impl
(
NemoI
nterface
*
p
);
Impl
(
const
QString
&
connectionString
,
Nemoi
nterface
*
p
);
~
Impl
();
~
Impl
();
void
start
();
void
start
();
...
@@ -136,12 +137,13 @@ public:
...
@@ -136,12 +137,13 @@ public:
ProgressArray
getProgress
()
const
;
ProgressArray
getProgress
()
const
;
ProgressArray
getProgress
(
const
IDArray
&
idArray
)
const
;
ProgressArray
getProgress
(
const
IDArray
&
idArray
)
const
;
Nemo
I
nterface
::
STATUS
status
()
const
;
Nemo
i
nterface
::
STATUS
status
()
const
;
bool
running
()
const
;
// thread safe
bool
running
()
const
;
// thread safe
bool
ready
()
const
;
// thread safe
bool
ready
()
const
;
// thread safe
const
QString
&
infoString
()
const
;
const
QString
&
infoString
()
const
;
const
QString
&
warningString
()
const
;
const
QString
&
warningString
()
const
;
const
QString
&
connectionString
()
const
;
private:
private:
void
_doSetup
();
void
_doSetup
();
...
@@ -167,9 +169,9 @@ private:
...
@@ -167,9 +169,9 @@ private:
static
bool
_userSyncNotSafe
(
STATE
s
);
static
bool
_userSyncNotSafe
(
STATE
s
);
static
bool
_sysSyncNotSafe
(
STATE
s
);
static
bool
_sysSyncNotSafe
(
STATE
s
);
static
bool
_runningNotSafe
(
STATE
s
);
static
bool
_runningNotSafe
(
STATE
s
);
static
Nemo
I
nterface
::
STATUS
_status
(
STATE
state
);
static
Nemo
i
nterface
::
STATUS
_status
(
STATE
state
);
static
QString
_toString
(
STATE
s
);
static
QString
_toString
(
STATE
s
);
static
QString
_toString
(
Nemo
I
nterface
::
STATUS
s
);
static
QString
_toString
(
Nemo
i
nterface
::
STATUS
s
);
// impl functions
// impl functions
bool
_addTilesImpl
(
bool
_addTilesImpl
(
...
@@ -201,10 +203,11 @@ private:
...
@@ -201,10 +203,11 @@ private:
// static and const members
// static and const members
static
const
char
*
_localVersion
;
static
const
char
*
_localVersion
;
NemoInterface
*
const
_parent
;
Nemointerface
*
const
_parent
;
const
QString
_connectionString
;
// thread safe members
// thread safe members
R
OSBridgePtr
_pR
osbridge
;
R
osbridge
_r
osbridge
;
Dispatcher
_dispatcher
;
Dispatcher
_dispatcher
;
// protected by mutex
// protected by mutex
...
@@ -221,51 +224,33 @@ private:
...
@@ -221,51 +224,33 @@ private:
QTimer
_restartTimer
;
QTimer
_restartTimer
;
};
};
const
char
*
Nemo
I
nterface
::
Impl
::
_localVersion
(
"V_1.0"
);
const
char
*
Nemo
i
nterface
::
Impl
::
_localVersion
(
"V_1.0"
);
using
StatusMap
=
std
::
map
<
Nemo
I
nterface
::
STATUS
,
QString
>
;
using
StatusMap
=
std
::
map
<
Nemo
i
nterface
::
STATUS
,
QString
>
;
static
StatusMap
statusMap
{
static
StatusMap
statusMap
{
std
::
make_pair
<
Nemo
I
nterface
::
STATUS
,
QString
>
(
std
::
make_pair
<
Nemo
i
nterface
::
STATUS
,
QString
>
(
Nemo
I
nterface
::
STATUS
::
NOT_CONNECTED
,
"Not Connected"
),
Nemo
i
nterface
::
STATUS
::
NOT_CONNECTED
,
"Not Connected"
),
std
::
make_pair
<
Nemo
Interface
::
STATUS
,
QString
>
(
NemoI
nterface
::
STATUS
::
ERROR
,
std
::
make_pair
<
Nemo
interface
::
STATUS
,
QString
>
(
Nemoi
nterface
::
STATUS
::
ERROR
,
"ERROR"
),
"ERROR"
),
std
::
make_pair
<
Nemo
Interface
::
STATUS
,
QString
>
(
NemoI
nterface
::
STATUS
::
SYNC
,
std
::
make_pair
<
Nemo
interface
::
STATUS
,
QString
>
(
Nemoi
nterface
::
STATUS
::
SYNC
,
"Synchronizing"
),
"Synchronizing"
),
std
::
make_pair
<
Nemo
Interface
::
STATUS
,
QString
>
(
NemoI
nterface
::
STATUS
::
READY
,
std
::
make_pair
<
Nemo
interface
::
STATUS
,
QString
>
(
Nemoi
nterface
::
STATUS
::
READY
,
"Ready"
),
"Ready"
),
std
::
make_pair
<
NemoInterface
::
STATUS
,
QString
>
(
std
::
make_pair
<
Nemointerface
::
STATUS
,
QString
>
(
NemoInterface
::
STATUS
::
TIMEOUT
,
"Timeout"
),
Nemointerface
::
STATUS
::
TIMEOUT
,
"Timeout"
),
std
::
make_pair
<
NemoInterface
::
STATUS
,
QString
>
(
std
::
make_pair
<
Nemointerface
::
STATUS
,
QString
>
(
NemoInterface
::
STATUS
::
WEBSOCKET_DETECTED
,
"Websocket Detected"
)};
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
();
}
};
connect
(
connectionStringFact
,
&
SettingsFact
::
rawValueChanged
,
Nemointerface
::
Impl
::
Impl
(
const
QString
&
connectionString
,
Nemointerface
*
p
)
setConnectionString
);
:
_parent
(
p
),
_connectionString
(
connectionString
),
setConnectionString
();
_rosbridge
(
QUrl
(
QString
(
"ws://"
)
+
connectionString
)),
_state
(
STATE
::
STOPPED
)
{
// Heartbeat timeout.
// Heartbeat timeout.
connect
(
&
this
->
_timeoutTimer
,
&
QTimer
::
timeout
,
connect
(
&
this
->
_timeoutTimer
,
&
QTimer
::
timeout
,
std
::
bind
(
&
Impl
::
_onHeartbeatTimeout
,
this
));
std
::
bind
(
&
Impl
::
_onHeartbeatTimeout
,
this
));
connect
(
this
->
_pRosbridge
.
get
()
,
&
Rosbridge
::
stateChanged
,
this
->
_parent
,
connect
(
&
this
->
_rosbridge
,
&
Rosbridge
::
stateChanged
,
this
->
_parent
,
[
this
]
{
this
->
_onRosbridgeStateChanged
();
});
[
this
]
{
this
->
_onRosbridgeStateChanged
();
});
connect
(
&
this
->
_restartTimer
,
&
QTimer
::
timeout
,
this
->
_parent
,
connect
(
&
this
->
_restartTimer
,
&
QTimer
::
timeout
,
this
->
_parent
,
...
@@ -278,9 +263,9 @@ NemoInterface::Impl::Impl(NemoInterface *p)
...
@@ -278,9 +263,9 @@ NemoInterface::Impl::Impl(NemoInterface *p)
std
::
call_once
(
flag
,
[]
{
qRegisterMetaType
<
ProgressArray
>
();
});
std
::
call_once
(
flag
,
[]
{
qRegisterMetaType
<
ProgressArray
>
();
});
}
}
Nemo
Interface
::
Impl
::~
Impl
()
{
this
->
_pRosbridge
->
stop
();
}
Nemo
interface
::
Impl
::~
Impl
()
{
this
->
_rosbridge
.
stop
();
}
void
Nemo
I
nterface
::
Impl
::
start
()
{
void
Nemo
i
nterface
::
Impl
::
start
()
{
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
if
(
!
_runningNotSafe
(
this
->
_state
))
{
if
(
!
_runningNotSafe
(
this
->
_state
))
{
this
->
_setStateNotSafe
(
STATE
::
START_BRIDGE
);
this
->
_setStateNotSafe
(
STATE
::
START_BRIDGE
);
...
@@ -288,7 +273,7 @@ void NemoInterface::Impl::start() {
...
@@ -288,7 +273,7 @@ void NemoInterface::Impl::start() {
}
}
}
}
void
Nemo
I
nterface
::
Impl
::
stop
()
{
void
Nemo
i
nterface
::
Impl
::
stop
()
{
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
if
(
_runningNotSafe
(
this
->
_state
))
{
if
(
_runningNotSafe
(
this
->
_state
))
{
this
->
_setStateNotSafe
(
STATE
::
STOPPED
);
this
->
_setStateNotSafe
(
STATE
::
STOPPED
);
...
@@ -297,7 +282,7 @@ void NemoInterface::Impl::stop() {
...
@@ -297,7 +282,7 @@ void NemoInterface::Impl::stop() {
}
}
std
::
shared_future
<
QVariant
>
std
::
shared_future
<
QVariant
>
Nemo
I
nterface
::
Impl
::
addTiles
(
const
TilePtrArray
&
tileArray
)
{
Nemo
i
nterface
::
Impl
::
addTiles
(
const
TilePtrArray
&
tileArray
)
{
using
namespace
nemo_interface
;
using
namespace
nemo_interface
;
// qDebug() << "addTiles called";
// qDebug() << "addTiles called";
...
@@ -320,7 +305,7 @@ NemoInterface::Impl::addTiles(const TilePtrArray &tileArray) {
...
@@ -320,7 +305,7 @@ NemoInterface::Impl::addTiles(const TilePtrArray &tileArray) {
pTileArray
->
push_back
(
pTileCopy
);
pTileArray
->
push_back
(
pTileCopy
);
pIdArray
->
push_back
(
id
);
pIdArray
->
push_back
(
id
);
}
else
{
}
else
{
qCDebug
(
Nemo
I
nterfaceLog
)
qCDebug
(
Nemo
i
nterfaceLog
)
<<
"addTiles(): tile with id: "
<<
pTile
->
id
()
<<
"already added."
;
<<
"addTiles(): tile with id: "
<<
pTile
->
id
()
<<
"already added."
;
}
}
}
}
...
@@ -364,7 +349,7 @@ NemoInterface::Impl::addTiles(const TilePtrArray &tileArray) {
...
@@ -364,7 +349,7 @@ NemoInterface::Impl::addTiles(const TilePtrArray &tileArray) {
}
}
std
::
shared_future
<
QVariant
>
std
::
shared_future
<
QVariant
>
Nemo
I
nterface
::
Impl
::
removeTiles
(
const
IDArray
&
idArray
)
{
Nemo
i
nterface
::
Impl
::
removeTiles
(
const
IDArray
&
idArray
)
{
using
namespace
nemo_interface
;
using
namespace
nemo_interface
;
// qDebug() << "removeTiles called";
// qDebug() << "removeTiles called";
...
@@ -382,7 +367,7 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) {
...
@@ -382,7 +367,7 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) {
_localTiles
.
erase
(
it
);
_localTiles
.
erase
(
it
);
pIdArray
->
push_back
(
id
);
pIdArray
->
push_back
(
id
);
}
else
{
}
else
{
qCDebug
(
Nemo
I
nterfaceLog
)
<<
"removeTiles(): unknown id: "
<<
id
<<
"."
;
qCDebug
(
Nemo
i
nterfaceLog
)
<<
"removeTiles(): unknown id: "
<<
id
<<
"."
;
}
}
}
}
if
(
pIdArray
->
size
()
>
0
)
{
if
(
pIdArray
->
size
()
>
0
)
{
...
@@ -426,7 +411,7 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) {
...
@@ -426,7 +411,7 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) {
return
p
.
get_future
();
return
p
.
get_future
();
}
}
std
::
shared_future
<
QVariant
>
Nemo
I
nterface
::
Impl
::
clearTiles
()
{
std
::
shared_future
<
QVariant
>
Nemo
i
nterface
::
Impl
::
clearTiles
()
{
using
namespace
nemo_interface
;
using
namespace
nemo_interface
;
// qDebug() << "clearTiles called";
// qDebug() << "clearTiles called";
...
@@ -472,7 +457,7 @@ std::shared_future<QVariant> NemoInterface::Impl::clearTiles() {
...
@@ -472,7 +457,7 @@ std::shared_future<QVariant> NemoInterface::Impl::clearTiles() {
}
}
}
}
TileArray
Nemo
I
nterface
::
Impl
::
getTiles
(
const
IDArray
&
idArray
)
const
{
TileArray
Nemo
i
nterface
::
Impl
::
getTiles
(
const
IDArray
&
idArray
)
const
{
TileArray
tileArray
;
TileArray
tileArray
;
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
...
@@ -503,7 +488,7 @@ TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) const {
...
@@ -503,7 +488,7 @@ TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) const {
return
tileArray
;
return
tileArray
;
}
}
TileArray
Nemo
I
nterface
::
Impl
::
getAllTiles
()
const
{
TileArray
Nemo
i
nterface
::
Impl
::
getAllTiles
()
const
{
TileArray
tileArray
;
TileArray
tileArray
;
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
...
@@ -531,7 +516,7 @@ TileArray NemoInterface::Impl::getAllTiles() const {
...
@@ -531,7 +516,7 @@ TileArray NemoInterface::Impl::getAllTiles() const {
return
tileArray
;
return
tileArray
;
}
}
LogicalArray
Nemo
I
nterface
::
Impl
::
containsTiles
(
const
IDArray
&
idArray
)
const
{
LogicalArray
Nemo
i
nterface
::
Impl
::
containsTiles
(
const
IDArray
&
idArray
)
const
{
LogicalArray
logicalArray
;
LogicalArray
logicalArray
;
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
...
@@ -543,18 +528,18 @@ LogicalArray NemoInterface::Impl::containsTiles(const IDArray &idArray) const {
...
@@ -543,18 +528,18 @@ LogicalArray NemoInterface::Impl::containsTiles(const IDArray &idArray) const {
return
logicalArray
;
return
logicalArray
;
}
}
std
::
size_t
Nemo
I
nterface
::
Impl
::
size
()
const
{
std
::
size_t
Nemo
i
nterface
::
Impl
::
size
()
const
{
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
return
_localTiles
.
size
();
return
_localTiles
.
size
();
}
}
bool
Nemo
I
nterface
::
Impl
::
empty
()
const
{
bool
Nemo
i
nterface
::
Impl
::
empty
()
const
{
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
return
_localTiles
.
empty
();
return
_localTiles
.
empty
();
}
}
ProgressArray
Nemo
I
nterface
::
Impl
::
getProgress
()
const
{
ProgressArray
Nemo
i
nterface
::
Impl
::
getProgress
()
const
{
ProgressArray
progressArray
;
ProgressArray
progressArray
;
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
...
@@ -573,7 +558,7 @@ ProgressArray NemoInterface::Impl::getProgress() const {
...
@@ -573,7 +558,7 @@ ProgressArray NemoInterface::Impl::getProgress() const {
return
progressArray
;
return
progressArray
;
}
}
ProgressArray
Nemo
I
nterface
::
Impl
::
getProgress
(
const
IDArray
&
idArray
)
const
{
ProgressArray
Nemo
i
nterface
::
Impl
::
getProgress
(
const
IDArray
&
idArray
)
const
{
ProgressArray
progressArray
;
ProgressArray
progressArray
;
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
...
@@ -598,34 +583,34 @@ ProgressArray NemoInterface::Impl::getProgress(const IDArray &idArray) const {
...
@@ -598,34 +583,34 @@ ProgressArray NemoInterface::Impl::getProgress(const IDArray &idArray) const {
return
progressArray
;
return
progressArray
;
}
}
Nemo
Interface
::
STATUS
NemoI
nterface
::
Impl
::
status
()
const
{
Nemo
interface
::
STATUS
Nemoi
nterface
::
Impl
::
status
()
const
{
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
return
_status
(
this
->
_state
);
return
_status
(
this
->
_state
);
}
}
bool
Nemo
I
nterface
::
Impl
::
running
()
const
{
bool
Nemo
i
nterface
::
Impl
::
running
()
const
{
Lock
lk1
(
this
->
_m
);
Lock
lk1
(
this
->
_m
);
return
_runningNotSafe
(
this
->
_state
);
return
_runningNotSafe
(
this
->
_state
);
}
}
bool
Nemo
I
nterface
::
Impl
::
ready
()
const
{
bool
Nemo
i
nterface
::
Impl
::
ready
()
const
{
Lock
lk1
(
this
->
_m
);
Lock
lk1
(
this
->
_m
);
return
_readyNotSafe
(
this
->
_state
);
return
_readyNotSafe
(
this
->
_state
);
}
}
bool
Nemo
I
nterface
::
Impl
::
_sysSync
()
const
{
bool
Nemo
i
nterface
::
Impl
::
_sysSync
()
const
{
Lock
lk1
(
this
->
_m
);
Lock
lk1
(
this
->
_m
);
return
_sysSyncNotSafe
(
this
->
_state
);
return
_sysSyncNotSafe
(
this
->
_state
);
}
}
void
Nemo
I
nterface
::
Impl
::
_onHeartbeatTimeout
()
{
void
Nemo
i
nterface
::
Impl
::
_onHeartbeatTimeout
()
{
Lock
lk1
(
this
->
_m
);
Lock
lk1
(
this
->
_m
);
this
->
_setStateNotSafe
(
STATE
::
HEARTBEAT_TIMEOUT
);
this
->
_setStateNotSafe
(
STATE
::
HEARTBEAT_TIMEOUT
);
this
->
_doActionNotSafe
();
this
->
_doActionNotSafe
();
}
}
void
Nemo
I
nterface
::
Impl
::
_onRosbridgeStateChanged
()
{
void
Nemo
i
nterface
::
Impl
::
_onRosbridgeStateChanged
()
{
auto
rbState
=
this
->
_
pRosbridge
->
state
();
auto
rbState
=
this
->
_
rosbridge
.
state
();
if
(
rbState
==
Rosbridge
::
STATE
::
CONNECTED
)
{
if
(
rbState
==
Rosbridge
::
STATE
::
CONNECTED
)
{
Lock
lk1
(
this
->
_m
);
Lock
lk1
(
this
->
_m
);
if
(
this
->
_state
==
STATE
::
START_BRIDGE
||
if
(
this
->
_state
==
STATE
::
START_BRIDGE
||
...
@@ -644,22 +629,26 @@ void NemoInterface::Impl::_onRosbridgeStateChanged() {
...
@@ -644,22 +629,26 @@ void NemoInterface::Impl::_onRosbridgeStateChanged() {
}
}
}
}
bool
Nemo
I
nterface
::
Impl
::
_userSync
()
const
{
bool
Nemo
i
nterface
::
Impl
::
_userSync
()
const
{
Lock
lk1
(
this
->
_m
);
Lock
lk1
(
this
->
_m
);
return
_userSyncNotSafe
(
this
->
_state
);
return
_userSyncNotSafe
(
this
->
_state
);
}
}
const
QString
&
Nemo
I
nterface
::
Impl
::
infoString
()
const
{
const
QString
&
Nemo
i
nterface
::
Impl
::
infoString
()
const
{
Lock
lk1
(
this
->
_m
);
Lock
lk1
(
this
->
_m
);
return
_infoString
;
return
_infoString
;
}
}
const
QString
&
Nemo
I
nterface
::
Impl
::
warningString
()
const
{
const
QString
&
Nemo
i
nterface
::
Impl
::
warningString
()
const
{
Lock
lk1
(
this
->
_m
);
Lock
lk1
(
this
->
_m
);
return
_warningString
;
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
;
ProgressArray
copy
;
bool
error
=
false
;
bool
error
=
false
;
...
@@ -673,7 +662,7 @@ bool NemoInterface::Impl::_updateProgress(const ProgressArray &pArray) {
...
@@ -673,7 +662,7 @@ bool NemoInterface::Impl::_updateProgress(const ProgressArray &pArray) {
it
->
second
->
setProgress
(
itLP
->
progress
());
it
->
second
->
setProgress
(
itLP
->
progress
());
copy
.
push_back
(
*
itLP
);
copy
.
push_back
(
*
itLP
);
}
else
{
}
else
{
qCDebug
(
Nemo
I
nterfaceLog
)
qCDebug
(
Nemo
i
nterfaceLog
)
<<
"_updateProgress(): tile with id "
<<
itLP
->
id
()
<<
" not found."
;
<<
"_updateProgress(): tile with id "
<<
itLP
->
id
()
<<
" not found."
;
error
=
true
;
error
=
true
;
}
}
...
@@ -687,7 +676,7 @@ bool NemoInterface::Impl::_updateProgress(const ProgressArray &pArray) {
...
@@ -687,7 +676,7 @@ bool NemoInterface::Impl::_updateProgress(const ProgressArray &pArray) {
return
!
error
;
return
!
error
;
}
}
void
Nemo
I
nterface
::
Impl
::
_onHeartbeatReceived
(
const
QNemoHeartbeat
&
)
{
void
Nemo
i
nterface
::
Impl
::
_onHeartbeatReceived
(
const
QNemoHeartbeat
&
)
{
INVM
(
this
->
_parent
,
INVM
(
this
->
_parent
,
([
this
]()
mutable
{
this
->
_timeoutTimer
.
start
(
NO_HEARTBEAT_TIMEOUT
);
}))
([
this
]()
mutable
{
this
->
_timeoutTimer
.
start
(
NO_HEARTBEAT_TIMEOUT
);
}))
...
@@ -699,7 +688,7 @@ void NemoInterface::Impl::_onHeartbeatReceived(const QNemoHeartbeat &) {
...
@@ -699,7 +688,7 @@ void NemoInterface::Impl::_onHeartbeatReceived(const QNemoHeartbeat &) {
}
}
}
}
void
Nemo
I
nterface
::
Impl
::
_setInfoStringNotSafe
(
const
QString
&
info
)
{
void
Nemo
i
nterface
::
Impl
::
_setInfoStringNotSafe
(
const
QString
&
info
)
{
if
(
_infoString
!=
info
)
{
if
(
_infoString
!=
info
)
{
_infoString
=
info
;
_infoString
=
info
;
...
@@ -709,7 +698,7 @@ void NemoInterface::Impl::_setInfoStringNotSafe(const QString &info) {
...
@@ -709,7 +698,7 @@ void NemoInterface::Impl::_setInfoStringNotSafe(const QString &info) {
}
}
}
}
void
Nemo
I
nterface
::
Impl
::
_setWarningStringNotSafe
(
const
QString
&
warning
)
{
void
Nemo
i
nterface
::
Impl
::
_setWarningStringNotSafe
(
const
QString
&
warning
)
{
if
(
_warningString
!=
warning
)
{
if
(
_warningString
!=
warning
)
{
_warningString
=
warning
;
_warningString
=
warning
;
...
@@ -719,20 +708,20 @@ void NemoInterface::Impl::_setWarningStringNotSafe(const QString &warning) {
...
@@ -719,20 +708,20 @@ void NemoInterface::Impl::_setWarningStringNotSafe(const QString &warning) {
}
}
}
}
void
Nemo
I
nterface
::
Impl
::
_setInfoString
(
const
QString
&
info
)
{
void
Nemo
i
nterface
::
Impl
::
_setInfoString
(
const
QString
&
info
)
{
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
_setInfoStringNotSafe
(
info
);
_setInfoStringNotSafe
(
info
);
}
}
void
Nemo
I
nterface
::
Impl
::
_setWarningString
(
const
QString
&
warning
)
{
void
Nemo
i
nterface
::
Impl
::
_setWarningString
(
const
QString
&
warning
)
{
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
_setWarningStringNotSafe
(
warning
);
_setWarningStringNotSafe
(
warning
);
}
}
void
Nemo
I
nterface
::
Impl
::
_doSetup
()
{
void
Nemo
i
nterface
::
Impl
::
_doSetup
()
{
// create task
// create task
auto
pTask
=
std
::
make_unique
<
nemo_interface
::
Task
>
([
this
]
{
auto
pTask
=
std
::
make_unique
<
nemo_interface
::
Task
>
([
this
]
{
auto
rb
=
this
->
_pR
osbridge
;
auto
&
rb
=
this
->
_r
osbridge
;
auto
&
disp
=
this
->
_dispatcher
;
auto
&
disp
=
this
->
_dispatcher
;
// check if required services are available
// check if required services are available
...
@@ -742,7 +731,7 @@ void NemoInterface::Impl::_doSetup() {
...
@@ -742,7 +731,7 @@ void NemoInterface::Impl::_doSetup() {
this
->
_setInfoString
(
"Waiting for required service "
+
s
);
this
->
_setInfoString
(
"Waiting for required service "
+
s
);
auto
available
=
rb
->
waitForService
(
cc
,
cond
);
auto
available
=
rb
.
waitForService
(
cc
,
cond
);
if
(
!
available
)
{
if
(
!
available
)
{
return
QVariant
(
false
);
return
QVariant
(
false
);
}
}
...
@@ -750,7 +739,7 @@ void NemoInterface::Impl::_doSetup() {
...
@@ -750,7 +739,7 @@ void NemoInterface::Impl::_doSetup() {
// check if version is compatible{
// check if version is compatible{
this
->
_setInfoString
(
"Checking version."
);
this
->
_setInfoString
(
"Checking version."
);
auto
version
=
_callGetVersion
(
disp
,
*
rb
);
auto
version
=
_callGetVersion
(
disp
,
rb
);
if
(
version
!=
_localVersion
)
{
if
(
version
!=
_localVersion
)
{
this
->
_setWarningString
(
this
->
_setWarningString
(
"Version checking failed. Local protocol version ("
+
"Version checking failed. Local protocol version ("
+
...
@@ -763,14 +752,14 @@ void NemoInterface::Impl::_doSetup() {
...
@@ -763,14 +752,14 @@ void NemoInterface::Impl::_doSetup() {
for
(
const
auto
&
cc
:
requiredTopics
)
{
for
(
const
auto
&
cc
:
requiredTopics
)
{
QString
s
(
cc
);
QString
s
(
cc
);
this
->
_setInfoString
(
"Waiting for required topic "
+
s
);
this
->
_setInfoString
(
"Waiting for required topic "
+
s
);
auto
available
=
rb
->
waitForTopic
(
cc
,
cond
);
auto
available
=
rb
.
waitForTopic
(
cc
,
cond
);
if
(
!
available
)
{
if
(
!
available
)
{
return
QVariant
(
false
);
return
QVariant
(
false
);
}
}
}
}
// subscribe topics
// subscribe topics
rb
->
subscribeTopic
(
progressTopic
,
[
this
](
const
QJsonObject
&
o
)
{
rb
.
subscribeTopic
(
progressTopic
,
[
this
](
const
QJsonObject
&
o
)
{
ros_bridge
::
messages
::
nemo_msgs
::
progress_array
::
ProgressArray
ros_bridge
::
messages
::
nemo_msgs
::
progress_array
::
ProgressArray
progressArray
;
progressArray
;
if
(
ros_bridge
::
messages
::
nemo_msgs
::
progress_array
::
fromJson
(
if
(
ros_bridge
::
messages
::
nemo_msgs
::
progress_array
::
fromJson
(
...
@@ -789,7 +778,7 @@ void NemoInterface::Impl::_doSetup() {
...
@@ -789,7 +778,7 @@ void NemoInterface::Impl::_doSetup() {
}
}
if
(
rangeError
)
{
if
(
rangeError
)
{
qCWarning
(
Nemo
I
nterfaceLog
)
<<
progressTopic
qCWarning
(
Nemo
i
nterfaceLog
)
<<
progressTopic
<<
" progress out "
<<
" progress out "
"of range, value was set to: "
"of range, value was set to: "
<<
lp
.
progress
();
<<
lp
.
progress
();
...
@@ -799,7 +788,7 @@ void NemoInterface::Impl::_doSetup() {
...
@@ -799,7 +788,7 @@ void NemoInterface::Impl::_doSetup() {
if
(
!
ret
)
if
(
!
ret
)
this
->
_setWarningString
(
"Progress update failed."
);
this
->
_setWarningString
(
"Progress update failed."
);
}
else
{
}
else
{
qCWarning
(
Nemo
I
nterfaceLog
)
<<
progressTopic
qCWarning
(
Nemo
i
nterfaceLog
)
<<
progressTopic
<<
" not able to "
<<
" not able to "
"create ProgressArray form json: "
"create ProgressArray form json: "
<<
o
;
<<
o
;
...
@@ -807,12 +796,12 @@ void NemoInterface::Impl::_doSetup() {
...
@@ -807,12 +796,12 @@ void NemoInterface::Impl::_doSetup() {
});
});
using
namespace
ros_bridge
::
messages
;
using
namespace
ros_bridge
::
messages
;
rb
->
subscribeTopic
(
heartbeatTopic
,
[
this
](
const
QJsonObject
&
o
)
{
rb
.
subscribeTopic
(
heartbeatTopic
,
[
this
](
const
QJsonObject
&
o
)
{
nemo_msgs
::
heartbeat
::
Heartbeat
heartbeat
;
nemo_msgs
::
heartbeat
::
Heartbeat
heartbeat
;
if
(
nemo_msgs
::
heartbeat
::
fromJson
(
o
,
heartbeat
))
{
if
(
nemo_msgs
::
heartbeat
::
fromJson
(
o
,
heartbeat
))
{
this
->
_onHeartbeatReceived
(
heartbeat
);
this
->
_onHeartbeatReceived
(
heartbeat
);
}
else
{
}
else
{
qCWarning
(
Nemo
I
nterfaceLog
)
<<
heartbeatTopic
qCWarning
(
Nemo
i
nterfaceLog
)
<<
heartbeatTopic
<<
" not able to "
<<
" not able to "
"create Heartbeat form json: "
"create Heartbeat form json: "
<<
o
;
<<
o
;
...
@@ -832,7 +821,7 @@ void NemoInterface::Impl::_doSetup() {
...
@@ -832,7 +821,7 @@ void NemoInterface::Impl::_doSetup() {
Q_UNUSED
(
f
);
Q_UNUSED
(
f
);
}
}
void
Nemo
I
nterface
::
Impl
::
_synchronize
()
{
void
Nemo
i
nterface
::
Impl
::
_synchronize
()
{
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
if
(
this
->
_state
==
STATE
::
READY
||
this
->
_state
==
STATE
::
SYNC_ERROR
)
{
if
(
this
->
_state
==
STATE
::
READY
||
this
->
_state
==
STATE
::
SYNC_ERROR
)
{
...
@@ -848,11 +837,11 @@ void NemoInterface::Impl::_synchronize() {
...
@@ -848,11 +837,11 @@ void NemoInterface::Impl::_synchronize() {
// create cmd.
// create cmd.
auto
pTask
=
std
::
make_unique
<
nemo_interface
::
Task
>
([
this
,
pTileArray
]
{
auto
pTask
=
std
::
make_unique
<
nemo_interface
::
Task
>
([
this
,
pTileArray
]
{
auto
rb
=
this
->
_pR
osbridge
;
auto
&
rb
=
this
->
_r
osbridge
;
auto
&
disp
=
this
->
_dispatcher
;
auto
&
disp
=
this
->
_dispatcher
;
// are _localTiles and _remoteTiles synced?
// are _localTiles and _remoteTiles synced?
auto
remoteTiles
=
this
->
_callGetAllTiles
(
disp
,
*
rb
);
auto
remoteTiles
=
this
->
_callGetAllTiles
(
disp
,
rb
);
// create tile map;
// create tile map;
std
::
map
<
QString
,
std
::
shared_ptr
<
Tile
>>
tempMap
;
std
::
map
<
QString
,
std
::
shared_ptr
<
Tile
>>
tempMap
;
...
@@ -861,7 +850,7 @@ void NemoInterface::Impl::_synchronize() {
...
@@ -861,7 +850,7 @@ void NemoInterface::Impl::_synchronize() {
if
(
Q_LIKELY
(
it
==
tempMap
.
end
()))
{
if
(
Q_LIKELY
(
it
==
tempMap
.
end
()))
{
tempMap
.
insert
(
std
::
make_pair
(
pTile
->
id
(),
pTile
));
tempMap
.
insert
(
std
::
make_pair
(
pTile
->
id
(),
pTile
));
}
else
{
}
else
{
qCDebug
(
Nemo
I
nterfaceLog
)
qCDebug
(
Nemo
i
nterfaceLog
)
<<
"_synchronizeIfNeccessary(): remoteTiles contains "
<<
"_synchronizeIfNeccessary(): remoteTiles contains "
"duplicate id"
;
"duplicate id"
;
}
}
...
@@ -918,7 +907,7 @@ void NemoInterface::Impl::_synchronize() {
...
@@ -918,7 +907,7 @@ void NemoInterface::Impl::_synchronize() {
this
->
_doActionNotSafe
();
this
->
_doActionNotSafe
();
lk
.
unlock
();
lk
.
unlock
();
this
->
_setWarningString
(
"Getting progress failed."
);
this
->
_setWarningString
(
"Getting progress failed."
);
qCDebug
(
Nemo
I
nterfaceLog
)
qCDebug
(
Nemo
i
nterfaceLog
)
<<
"_addTilesImpl(): _updateProgress failed: unknown id."
;
<<
"_addTilesImpl(): _updateProgress failed: unknown id."
;
return
QVariant
(
false
);
return
QVariant
(
false
);
}
}
...
@@ -947,7 +936,7 @@ void NemoInterface::Impl::_synchronize() {
...
@@ -947,7 +936,7 @@ void NemoInterface::Impl::_synchronize() {
}
}
}
}
void
Nemo
I
nterface
::
Impl
::
_tryRestart
()
{
void
Nemo
i
nterface
::
Impl
::
_tryRestart
()
{
if
(
this
->
running
())
{
if
(
this
->
running
())
{
if
(
_dispatcher
.
idle
())
{
if
(
_dispatcher
.
idle
())
{
qDebug
()
<<
"_tryRestart: restarting"
;
qDebug
()
<<
"_tryRestart: restarting"
;
...
@@ -960,19 +949,19 @@ void NemoInterface::Impl::_tryRestart() {
...
@@ -960,19 +949,19 @@ void NemoInterface::Impl::_tryRestart() {
}
}
}
}
bool
Nemo
I
nterface
::
Impl
::
_isSynchronizedNotSafe
()
const
{
bool
Nemo
i
nterface
::
Impl
::
_isSynchronizedNotSafe
()
const
{
return
_localTiles
.
size
()
==
_remoteTiles
.
size
()
&&
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
;
});
}
}
bool
Nemo
I
nterface
::
Impl
::
_isSynchronized
()
const
{
bool
Nemo
i
nterface
::
Impl
::
_isSynchronized
()
const
{
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
return
_isSynchronizedNotSafe
();
return
_isSynchronizedNotSafe
();
}
}
void
Nemo
I
nterface
::
Impl
::
_doActionNotSafe
()
{
void
Nemo
i
nterface
::
Impl
::
_doActionNotSafe
()
{
static
bool
resetDone
=
false
;
static
bool
resetDone
=
false
;
switch
(
this
->
_state
)
{
switch
(
this
->
_state
)
{
case
STATE
:
:
STOPPED
:
{
case
STATE
:
:
STOPPED
:
{
...
@@ -983,8 +972,8 @@ void NemoInterface::Impl::_doActionNotSafe() {
...
@@ -983,8 +972,8 @@ void NemoInterface::Impl::_doActionNotSafe() {
this
->
_syncTimer
.
stop
();
this
->
_syncTimer
.
stop
();
}))
}))
if
(
this
->
_
pRosbridge
->
state
()
!=
Rosbridge
::
STATE
::
STOPPED
)
{
if
(
this
->
_
rosbridge
.
state
()
!=
Rosbridge
::
STATE
::
STOPPED
)
{
this
->
_
pRosbridge
->
stop
();
this
->
_
rosbridge
.
stop
();
}
}
_dispatcher
.
stop
();
_dispatcher
.
stop
();
_dispatcher
.
clear
();
_dispatcher
.
clear
();
...
@@ -998,7 +987,7 @@ void NemoInterface::Impl::_doActionNotSafe() {
...
@@ -998,7 +987,7 @@ void NemoInterface::Impl::_doActionNotSafe() {
INVM
(
this
->
_parent
,
INVM
(
this
->
_parent
,
([
this
]()
mutable
{
this
->
_restartTimer
.
start
(
RESTART_INTERVAl
);
}))
([
this
]()
mutable
{
this
->
_restartTimer
.
start
(
RESTART_INTERVAl
);
}))
this
->
_
pRosbridge
->
start
();
this
->
_
rosbridge
.
start
();
}
break
;
}
break
;
case
STATE
:
:
WEBSOCKET_DETECTED
:
case
STATE
:
:
WEBSOCKET_DETECTED
:
resetDone
=
false
;
resetDone
=
false
;
...
@@ -1036,8 +1025,8 @@ void NemoInterface::Impl::_doActionNotSafe() {
...
@@ -1036,8 +1025,8 @@ void NemoInterface::Impl::_doActionNotSafe() {
if
(
!
resetDone
)
{
if
(
!
resetDone
)
{
resetDone
=
true
;
resetDone
=
true
;
this
->
_
pRosbridge
->
stop
();
this
->
_
rosbridge
.
stop
();
this
->
_
pRosbridge
->
start
();
this
->
_
rosbridge
.
start
();
}
}
_dispatcher
.
stop
();
_dispatcher
.
stop
();
_dispatcher
.
clear
();
_dispatcher
.
clear
();
...
@@ -1048,7 +1037,7 @@ void NemoInterface::Impl::_doActionNotSafe() {
...
@@ -1048,7 +1037,7 @@ void NemoInterface::Impl::_doActionNotSafe() {
};
};
}
}
bool
Nemo
I
nterface
::
Impl
::
_callAddTiles
(
bool
Nemo
i
nterface
::
Impl
::
_callAddTiles
(
const
QVector
<
std
::
shared_ptr
<
const
Tile
>>
&
tileArray
,
Dispatcher
&
d
,
const
QVector
<
std
::
shared_ptr
<
const
Tile
>>
&
tileArray
,
Dispatcher
&
d
,
Rosbridge
&
rb
)
{
Rosbridge
&
rb
)
{
...
@@ -1060,7 +1049,7 @@ bool NemoInterface::Impl::_callAddTiles(
...
@@ -1060,7 +1049,7 @@ bool NemoInterface::Impl::_callAddTiles(
using
namespace
ros_bridge
::
messages
;
using
namespace
ros_bridge
::
messages
;
QJsonObject
jsonTile
;
QJsonObject
jsonTile
;
if
(
!
nemo_msgs
::
tile
::
toJson
(
*
tile
,
jsonTile
))
{
if
(
!
nemo_msgs
::
tile
::
toJson
(
*
tile
,
jsonTile
))
{
qCDebug
(
Nemo
I
nterfaceLog
)
qCDebug
(
Nemo
i
nterfaceLog
)
<<
"addTiles(): not able to create json object: tile id: "
<<
"addTiles(): not able to create json object: tile id: "
<<
tile
->
id
()
<<
" progress: "
<<
tile
->
progress
()
<<
tile
->
id
()
<<
" progress: "
<<
tile
->
progress
()
<<
" points: "
<<
tile
->
tile
();
<<
" points: "
<<
tile
->
tile
();
...
@@ -1079,7 +1068,7 @@ bool NemoInterface::Impl::_callAddTiles(
...
@@ -1079,7 +1068,7 @@ bool NemoInterface::Impl::_callAddTiles(
if
(
o
.
contains
(
"success"
)
&&
o
[
"success"
].
isBool
())
{
if
(
o
.
contains
(
"success"
)
&&
o
[
"success"
].
isBool
())
{
promise_response
->
set_value
(
o
[
"success"
].
toBool
());
promise_response
->
set_value
(
o
[
"success"
].
toBool
());
}
else
{
}
else
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
addTilesService
<<
" no
\"
success
\"
key or wrong type: "
<<
o
;
<<
addTilesService
<<
" no
\"
success
\"
key or wrong type: "
<<
o
;
promise_response
->
set_value
(
false
);
promise_response
->
set_value
(
false
);
}
}
...
@@ -1101,7 +1090,7 @@ bool NemoInterface::Impl::_callAddTiles(
...
@@ -1101,7 +1090,7 @@ bool NemoInterface::Impl::_callAddTiles(
d
.
isInterruptionRequested
());
d
.
isInterruptionRequested
());
if
(
abort
)
{
if
(
abort
)
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
"addTiles(): Websocket not responding to request."
;
<<
"addTiles(): Websocket not responding to request."
;
return
false
;
return
false
;
}
}
...
@@ -1115,7 +1104,7 @@ bool NemoInterface::Impl::_callAddTiles(
...
@@ -1115,7 +1104,7 @@ bool NemoInterface::Impl::_callAddTiles(
return
true
;
return
true
;
}
}
bool
Nemo
I
nterface
::
Impl
::
_callRemoveTiles
(
const
IDArray
&
pIdArray
,
bool
Nemo
i
nterface
::
Impl
::
_callRemoveTiles
(
const
IDArray
&
pIdArray
,
Dispatcher
&
disp
,
Rosbridge
&
rb
)
{
Dispatcher
&
disp
,
Rosbridge
&
rb
)
{
// qDebug() << "_callRemoveTiles called";
// qDebug() << "_callRemoveTiles called";
...
@@ -1137,7 +1126,7 @@ bool NemoInterface::Impl::_callRemoveTiles(const IDArray &pIdArray,
...
@@ -1137,7 +1126,7 @@ bool NemoInterface::Impl::_callRemoveTiles(const IDArray &pIdArray,
if
(
o
.
contains
(
"success"
)
&&
o
[
"success"
].
isBool
())
{
if
(
o
.
contains
(
"success"
)
&&
o
[
"success"
].
isBool
())
{
promise_response
->
set_value
(
o
[
"success"
].
toBool
());
promise_response
->
set_value
(
o
[
"success"
].
toBool
());
}
else
{
}
else
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
removeTilesService
<<
" no
\"
success
\"
key or wrong type: "
<<
msg
;
<<
removeTilesService
<<
" no
\"
success
\"
key or wrong type: "
<<
msg
;
promise_response
->
set_value
(
false
);
promise_response
->
set_value
(
false
);
}
}
...
@@ -1159,7 +1148,7 @@ bool NemoInterface::Impl::_callRemoveTiles(const IDArray &pIdArray,
...
@@ -1159,7 +1148,7 @@ bool NemoInterface::Impl::_callRemoveTiles(const IDArray &pIdArray,
disp
.
isInterruptionRequested
());
disp
.
isInterruptionRequested
());
if
(
abort
)
{
if
(
abort
)
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
"remove_tiles(): Websocket not responding to request."
;
<<
"remove_tiles(): Websocket not responding to request."
;
return
false
;
return
false
;
}
}
...
@@ -1172,7 +1161,7 @@ bool NemoInterface::Impl::_callRemoveTiles(const IDArray &pIdArray,
...
@@ -1172,7 +1161,7 @@ bool NemoInterface::Impl::_callRemoveTiles(const IDArray &pIdArray,
return
true
;
return
true
;
}
}
bool
Nemo
I
nterface
::
Impl
::
_callClearTiles
(
Dispatcher
&
disp
,
Rosbridge
&
rb
)
{
bool
Nemo
i
nterface
::
Impl
::
_callClearTiles
(
Dispatcher
&
disp
,
Rosbridge
&
rb
)
{
// create response handler.
// create response handler.
auto
promise_response
=
std
::
make_shared
<
std
::
promise
<
bool
>>
();
auto
promise_response
=
std
::
make_shared
<
std
::
promise
<
bool
>>
();
...
@@ -1198,7 +1187,7 @@ bool NemoInterface::Impl::_callClearTiles(Dispatcher &disp, Rosbridge &rb) {
...
@@ -1198,7 +1187,7 @@ bool NemoInterface::Impl::_callClearTiles(Dispatcher &disp, Rosbridge &rb) {
disp
.
isInterruptionRequested
());
disp
.
isInterruptionRequested
());
if
(
abort
)
{
if
(
abort
)
{
qCWarning
(
Nemo
I
nterfaceLog
)
<<
"Websocket not responding to request."
;
qCWarning
(
Nemo
i
nterfaceLog
)
<<
"Websocket not responding to request."
;
return
false
;
return
false
;
}
}
...
@@ -1210,7 +1199,7 @@ bool NemoInterface::Impl::_callClearTiles(Dispatcher &disp, Rosbridge &rb) {
...
@@ -1210,7 +1199,7 @@ bool NemoInterface::Impl::_callClearTiles(Dispatcher &disp, Rosbridge &rb) {
return
true
;
return
true
;
}
}
ProgressArray
Nemo
I
nterface
::
Impl
::
_callGetProgress
(
const
IDArray
&
pIdArray
,
ProgressArray
Nemo
i
nterface
::
Impl
::
_callGetProgress
(
const
IDArray
&
pIdArray
,
Dispatcher
&
disp
,
Dispatcher
&
disp
,
Rosbridge
&
rb
)
{
Rosbridge
&
rb
)
{
// qDebug() << "_callGetProgress called";
// qDebug() << "_callGetProgress called";
...
@@ -1238,7 +1227,7 @@ ProgressArray NemoInterface::Impl::_callGetProgress(const IDArray &pIdArray,
...
@@ -1238,7 +1227,7 @@ ProgressArray NemoInterface::Impl::_callGetProgress(const IDArray &pIdArray,
*
pArray
=
std
::
move
(
progressArrayMsg
.
progress_array
());
*
pArray
=
std
::
move
(
progressArrayMsg
.
progress_array
());
promise_response
->
set_value
(
pArray
);
promise_response
->
set_value
(
pArray
);
}
else
{
}
else
{
qCWarning
(
Nemo
I
nterfaceLog
)
<<
getProgressService
qCWarning
(
Nemo
i
nterfaceLog
)
<<
getProgressService
<<
" error while creating ProgressArray "
<<
" error while creating ProgressArray "
"from json."
;
"from json."
;
promise_response
->
set_value
(
nullptr
);
promise_response
->
set_value
(
nullptr
);
...
@@ -1261,7 +1250,7 @@ ProgressArray NemoInterface::Impl::_callGetProgress(const IDArray &pIdArray,
...
@@ -1261,7 +1250,7 @@ ProgressArray NemoInterface::Impl::_callGetProgress(const IDArray &pIdArray,
disp
.
isInterruptionRequested
());
disp
.
isInterruptionRequested
());
if
(
abort
)
{
if
(
abort
)
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
"all_remove_tiles(): Websocket not responding to request."
;
<<
"all_remove_tiles(): Websocket not responding to request."
;
return
ProgressArray
();
return
ProgressArray
();
}
}
...
@@ -1270,7 +1259,7 @@ ProgressArray NemoInterface::Impl::_callGetProgress(const IDArray &pIdArray,
...
@@ -1270,7 +1259,7 @@ ProgressArray NemoInterface::Impl::_callGetProgress(const IDArray &pIdArray,
return
*
future_response
.
get
();
return
*
future_response
.
get
();
}
}
ProgressArray
Nemo
I
nterface
::
Impl
::
_callGetAllProgress
(
Dispatcher
&
disp
,
ProgressArray
Nemo
i
nterface
::
Impl
::
_callGetAllProgress
(
Dispatcher
&
disp
,
Rosbridge
&
rb
)
{
Rosbridge
&
rb
)
{
// qDebug() << "_callGetAllProgress called";
// qDebug() << "_callGetAllProgress called";
...
@@ -1288,7 +1277,7 @@ ProgressArray NemoInterface::Impl::_callGetAllProgress(Dispatcher &disp,
...
@@ -1288,7 +1277,7 @@ ProgressArray NemoInterface::Impl::_callGetAllProgress(Dispatcher &disp,
*
pArray
=
std
::
move
(
progressArrayMsg
.
progress_array
());
*
pArray
=
std
::
move
(
progressArrayMsg
.
progress_array
());
promise_response
->
set_value
(
pArray
);
promise_response
->
set_value
(
pArray
);
}
else
{
}
else
{
qCWarning
(
Nemo
I
nterfaceLog
)
<<
getAllProgressService
qCWarning
(
Nemo
i
nterfaceLog
)
<<
getAllProgressService
<<
" error while creating ProgressArray "
<<
" error while creating ProgressArray "
"from json. msg: "
"from json. msg: "
<<
o
;
<<
o
;
...
@@ -1312,7 +1301,7 @@ ProgressArray NemoInterface::Impl::_callGetAllProgress(Dispatcher &disp,
...
@@ -1312,7 +1301,7 @@ ProgressArray NemoInterface::Impl::_callGetAllProgress(Dispatcher &disp,
disp
.
isInterruptionRequested
());
disp
.
isInterruptionRequested
());
if
(
abort
)
{
if
(
abort
)
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
"_callGetAllProgress(): Websocket not responding to request."
;
<<
"_callGetAllProgress(): Websocket not responding to request."
;
return
ProgressArray
();
return
ProgressArray
();
}
}
...
@@ -1322,7 +1311,7 @@ ProgressArray NemoInterface::Impl::_callGetAllProgress(Dispatcher &disp,
...
@@ -1322,7 +1311,7 @@ ProgressArray NemoInterface::Impl::_callGetAllProgress(Dispatcher &disp,
}
}
QVector
<
std
::
shared_ptr
<
Tile
>>
QVector
<
std
::
shared_ptr
<
Tile
>>
Nemo
I
nterface
::
Impl
::
_callGetAllTiles
(
Dispatcher
&
disp
,
Rosbridge
&
rb
)
{
Nemo
i
nterface
::
Impl
::
_callGetAllTiles
(
Dispatcher
&
disp
,
Rosbridge
&
rb
)
{
// qDebug() << "_callGetAllProgress called";
// qDebug() << "_callGetAllProgress called";
// create response handler.
// create response handler.
...
@@ -1343,12 +1332,12 @@ NemoInterface::Impl::_callGetAllTiles(Dispatcher &disp, Rosbridge &rb) {
...
@@ -1343,12 +1332,12 @@ NemoInterface::Impl::_callGetAllTiles(Dispatcher &disp, Rosbridge &rb) {
if
(
ros_bridge
::
messages
::
nemo_msgs
::
tile
::
fromJson
(
o
,
*
tile
))
{
if
(
ros_bridge
::
messages
::
nemo_msgs
::
tile
::
fromJson
(
o
,
*
tile
))
{
pArray
->
push_back
(
tile
);
pArray
->
push_back
(
tile
);
}
else
{
}
else
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
getAllTilesService
<<
" error while creating tile."
;
<<
getAllTilesService
<<
" error while creating tile."
;
promise_response
->
set_value
(
nullptr
);
promise_response
->
set_value
(
nullptr
);
}
}
}
else
{
}
else
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
getAllTilesService
<<
" json array does not contain objects."
;
<<
getAllTilesService
<<
" json array does not contain objects."
;
promise_response
->
set_value
(
nullptr
);
promise_response
->
set_value
(
nullptr
);
}
}
...
@@ -1356,7 +1345,7 @@ NemoInterface::Impl::_callGetAllTiles(Dispatcher &disp, Rosbridge &rb) {
...
@@ -1356,7 +1345,7 @@ NemoInterface::Impl::_callGetAllTiles(Dispatcher &disp, Rosbridge &rb) {
// success!
// success!
promise_response
->
set_value
(
pArray
);
promise_response
->
set_value
(
pArray
);
}
else
{
}
else
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
getAllTilesService
<<
" no tile_array key or wrong type."
;
<<
getAllTilesService
<<
" no tile_array key or wrong type."
;
promise_response
->
set_value
(
nullptr
);
promise_response
->
set_value
(
nullptr
);
}
}
...
@@ -1378,7 +1367,7 @@ NemoInterface::Impl::_callGetAllTiles(Dispatcher &disp, Rosbridge &rb) {
...
@@ -1378,7 +1367,7 @@ NemoInterface::Impl::_callGetAllTiles(Dispatcher &disp, Rosbridge &rb) {
disp
.
isInterruptionRequested
());
disp
.
isInterruptionRequested
());
if
(
abort
)
{
if
(
abort
)
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
"all_remove_tiles(): Websocket not responding to request."
;
<<
"all_remove_tiles(): Websocket not responding to request."
;
return
QVector
<
std
::
shared_ptr
<
Tile
>>
();
return
QVector
<
std
::
shared_ptr
<
Tile
>>
();
}
}
...
@@ -1386,7 +1375,7 @@ NemoInterface::Impl::_callGetAllTiles(Dispatcher &disp, Rosbridge &rb) {
...
@@ -1386,7 +1375,7 @@ NemoInterface::Impl::_callGetAllTiles(Dispatcher &disp, Rosbridge &rb) {
return
*
future_response
.
get
();
return
*
future_response
.
get
();
}
}
QString
Nemo
I
nterface
::
Impl
::
_callGetVersion
(
Dispatcher
&
d
,
Rosbridge
&
rb
)
{
QString
Nemo
i
nterface
::
Impl
::
_callGetVersion
(
Dispatcher
&
d
,
Rosbridge
&
rb
)
{
// create response handler.
// create response handler.
typedef
QString
ResponseType
;
typedef
QString
ResponseType
;
...
@@ -1400,7 +1389,7 @@ QString NemoInterface::Impl::_callGetVersion(Dispatcher &d, Rosbridge &rb) {
...
@@ -1400,7 +1389,7 @@ QString NemoInterface::Impl::_callGetVersion(Dispatcher &d, Rosbridge &rb) {
const
auto
version
=
o
[
versionKey
].
toString
();
const
auto
version
=
o
[
versionKey
].
toString
();
promise_response
->
set_value
(
version
);
promise_response
->
set_value
(
version
);
}
else
{
}
else
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
getVersionService
<<
" no version key or wrong type."
;
<<
getVersionService
<<
" no version key or wrong type."
;
promise_response
->
set_value
(
"error!"
);
promise_response
->
set_value
(
"error!"
);
}
}
...
@@ -1422,7 +1411,7 @@ QString NemoInterface::Impl::_callGetVersion(Dispatcher &d, Rosbridge &rb) {
...
@@ -1422,7 +1411,7 @@ QString NemoInterface::Impl::_callGetVersion(Dispatcher &d, Rosbridge &rb) {
d
.
isInterruptionRequested
());
d
.
isInterruptionRequested
());
if
(
abort
)
{
if
(
abort
)
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
"all_remove_tiles(): Websocket not responding to request."
;
<<
"all_remove_tiles(): Websocket not responding to request."
;
return
"unknown_version"
;
return
"unknown_version"
;
}
}
...
@@ -1437,7 +1426,7 @@ QString NemoInterface::Impl::_callGetVersion(Dispatcher &d, Rosbridge &rb) {
...
@@ -1437,7 +1426,7 @@ QString NemoInterface::Impl::_callGetVersion(Dispatcher &d, Rosbridge &rb) {
return
version
;
return
version
;
}
}
bool
Nemo
I
nterface
::
Impl
::
_addTilesRemote
(
bool
Nemo
i
nterface
::
Impl
::
_addTilesRemote
(
const
QVector
<
std
::
shared_ptr
<
const
Tile
>>
tileArray
)
{
const
QVector
<
std
::
shared_ptr
<
const
Tile
>>
tileArray
)
{
// qDebug() << "_addTilesRemote called";
// qDebug() << "_addTilesRemote called";
...
@@ -1449,7 +1438,7 @@ bool NemoInterface::Impl::_addTilesRemote(
...
@@ -1449,7 +1438,7 @@ bool NemoInterface::Impl::_addTilesRemote(
return
_addTilesRemote
(
copy
);
return
_addTilesRemote
(
copy
);
}
}
bool
Nemo
I
nterface
::
Impl
::
_addTilesRemote
(
bool
Nemo
i
nterface
::
Impl
::
_addTilesRemote
(
const
QVector
<
std
::
shared_ptr
<
Tile
>>
&
tileArray
)
{
const
QVector
<
std
::
shared_ptr
<
Tile
>>
&
tileArray
)
{
bool
error
=
false
;
bool
error
=
false
;
...
@@ -1466,7 +1455,7 @@ bool NemoInterface::Impl::_addTilesRemote(
...
@@ -1466,7 +1455,7 @@ bool NemoInterface::Impl::_addTilesRemote(
Q_UNUSED
(
ret
);
Q_UNUSED
(
ret
);
}
else
{
}
else
{
if
(
pTile
->
tile
()
!=
it
->
second
->
tile
())
{
if
(
pTile
->
tile
()
!=
it
->
second
->
tile
())
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
"_addTilesRemote: tiles differ but have the same id."
;
<<
"_addTilesRemote: tiles differ but have the same id."
;
error
=
true
;
error
=
true
;
}
}
...
@@ -1481,7 +1470,7 @@ bool NemoInterface::Impl::_addTilesRemote(
...
@@ -1481,7 +1470,7 @@ bool NemoInterface::Impl::_addTilesRemote(
return
!
error
;
return
!
error
;
}
}
void
Nemo
I
nterface
::
Impl
::
_removeTilesRemote
(
const
IDArray
&
idArray
)
{
void
Nemo
i
nterface
::
Impl
::
_removeTilesRemote
(
const
IDArray
&
idArray
)
{
// qDebug() << "_removeTilesRemote called";
// qDebug() << "_removeTilesRemote called";
bool
anyChange
=
false
;
bool
anyChange
=
false
;
...
@@ -1492,7 +1481,7 @@ void NemoInterface::Impl::_removeTilesRemote(const IDArray &idArray) {
...
@@ -1492,7 +1481,7 @@ void NemoInterface::Impl::_removeTilesRemote(const IDArray &idArray) {
_remoteTiles
.
erase
(
it
);
_remoteTiles
.
erase
(
it
);
anyChange
=
true
;
anyChange
=
true
;
}
else
{
}
else
{
qCWarning
(
Nemo
I
nterfaceLog
)
qCWarning
(
Nemo
i
nterfaceLog
)
<<
"_removeTilesRemote: tile with unknown id "
<<
id
<<
"."
;
<<
"_removeTilesRemote: tile with unknown id "
<<
id
<<
"."
;
}
}
}
}
...
@@ -1502,24 +1491,24 @@ void NemoInterface::Impl::_removeTilesRemote(const IDArray &idArray) {
...
@@ -1502,24 +1491,24 @@ void NemoInterface::Impl::_removeTilesRemote(const IDArray &idArray) {
}
}
}
}
void
Nemo
I
nterface
::
Impl
::
_clearTilesRemote
()
{
void
Nemo
i
nterface
::
Impl
::
_clearTilesRemote
()
{
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
_clearTilesRemoteNotSafe
();
_clearTilesRemoteNotSafe
();
}
}
void
Nemo
I
nterface
::
Impl
::
_clearTilesRemoteNotSafe
()
{
void
Nemo
i
nterface
::
Impl
::
_clearTilesRemoteNotSafe
()
{
// qDebug() << "_clearTilesRemote called";
// qDebug() << "_clearTilesRemote called";
if
(
_remoteTiles
.
size
()
>
0
)
{
if
(
_remoteTiles
.
size
()
>
0
)
{
_remoteTiles
.
clear
();
_remoteTiles
.
clear
();
}
}
}
}
bool
Nemo
I
nterface
::
Impl
::
_setStateNotSafe
(
STATE
newState
)
{
bool
Nemo
i
nterface
::
Impl
::
_setStateNotSafe
(
STATE
newState
)
{
if
(
newState
!=
this
->
_state
)
{
if
(
newState
!=
this
->
_state
)
{
auto
oldState
=
this
->
_state
;
auto
oldState
=
this
->
_state
;
this
->
_state
=
newState
;
this
->
_state
=
newState
;
qCDebug
(
Nemo
I
nterfaceLog
)
qCDebug
(
Nemo
i
nterfaceLog
)
<<
"state: "
<<
_toString
(
oldState
)
<<
" -> "
<<
_toString
(
newState
);
<<
"state: "
<<
_toString
(
oldState
)
<<
" -> "
<<
_toString
(
newState
);
auto
oldStatus
=
_status
(
oldState
);
auto
oldStatus
=
_status
(
oldState
);
auto
newStatus
=
_status
(
newState
);
auto
newStatus
=
_status
(
newState
);
...
@@ -1541,58 +1530,58 @@ bool NemoInterface::Impl::_setStateNotSafe(STATE newState) {
...
@@ -1541,58 +1530,58 @@ bool NemoInterface::Impl::_setStateNotSafe(STATE newState) {
}
}
}
}
bool
Nemo
Interface
::
Impl
::
_readyNotSafe
(
NemoI
nterface
::
Impl
::
STATE
s
)
{
bool
Nemo
interface
::
Impl
::
_readyNotSafe
(
Nemoi
nterface
::
Impl
::
STATE
s
)
{
return
s
==
STATE
::
READY
;
return
s
==
STATE
::
READY
;
}
}
bool
Nemo
Interface
::
Impl
::
_userSyncNotSafe
(
NemoI
nterface
::
Impl
::
STATE
s
)
{
bool
Nemo
interface
::
Impl
::
_userSyncNotSafe
(
Nemoi
nterface
::
Impl
::
STATE
s
)
{
return
s
==
STATE
::
USER_SYNC
;
return
s
==
STATE
::
USER_SYNC
;
}
}
bool
Nemo
Interface
::
Impl
::
_sysSyncNotSafe
(
NemoI
nterface
::
Impl
::
STATE
s
)
{
bool
Nemo
interface
::
Impl
::
_sysSyncNotSafe
(
Nemoi
nterface
::
Impl
::
STATE
s
)
{
return
s
==
STATE
::
SYS_SYNC
;
return
s
==
STATE
::
SYS_SYNC
;
}
}
bool
Nemo
Interface
::
Impl
::
_runningNotSafe
(
NemoI
nterface
::
Impl
::
STATE
s
)
{
bool
Nemo
interface
::
Impl
::
_runningNotSafe
(
Nemoi
nterface
::
Impl
::
STATE
s
)
{
return
s
!=
STATE
::
STOPPED
;
return
s
!=
STATE
::
STOPPED
;
}
}
Nemo
I
nterface
::
STATUS
Nemo
i
nterface
::
STATUS
Nemo
Interface
::
Impl
::
_status
(
NemoI
nterface
::
Impl
::
STATE
state
)
{
Nemo
interface
::
Impl
::
_status
(
Nemoi
nterface
::
Impl
::
STATE
state
)
{
Nemo
I
nterface
::
STATUS
status
;
Nemo
i
nterface
::
STATUS
status
;
switch
(
state
)
{
switch
(
state
)
{
case
STATE
:
:
STOPPED
:
case
STATE
:
:
STOPPED
:
status
=
Nemo
I
nterface
::
STATUS
::
NOT_CONNECTED
;
status
=
Nemo
i
nterface
::
STATUS
::
NOT_CONNECTED
;
break
;
break
;
case
STATE
:
:
START_BRIDGE
:
case
STATE
:
:
START_BRIDGE
:
status
=
Nemo
I
nterface
::
STATUS
::
NOT_CONNECTED
;
status
=
Nemo
i
nterface
::
STATUS
::
NOT_CONNECTED
;
break
;
break
;
case
STATE
:
:
WEBSOCKET_DETECTED
:
case
STATE
:
:
WEBSOCKET_DETECTED
:
status
=
Nemo
I
nterface
::
STATUS
::
WEBSOCKET_DETECTED
;
status
=
Nemo
i
nterface
::
STATUS
::
WEBSOCKET_DETECTED
;
break
;
break
;
case
STATE
:
:
TRY_SETUP
:
case
STATE
:
:
TRY_SETUP
:
status
=
Nemo
I
nterface
::
STATUS
::
WEBSOCKET_DETECTED
;
status
=
Nemo
i
nterface
::
STATUS
::
WEBSOCKET_DETECTED
;
break
;
break
;
case
STATE
:
:
READY
:
case
STATE
:
:
READY
:
status
=
Nemo
I
nterface
::
STATUS
::
READY
;
status
=
Nemo
i
nterface
::
STATUS
::
READY
;
break
;
break
;
case
STATE
:
:
USER_SYNC
:
case
STATE
:
:
USER_SYNC
:
case
STATE
:
:
SYS_SYNC
:
case
STATE
:
:
SYS_SYNC
:
status
=
Nemo
I
nterface
::
STATUS
::
SYNC
;
status
=
Nemo
i
nterface
::
STATUS
::
SYNC
;
break
;
break
;
case
STATE
:
:
SYNC_ERROR
:
case
STATE
:
:
SYNC_ERROR
:
status
=
Nemo
I
nterface
::
STATUS
::
ERROR
;
status
=
Nemo
i
nterface
::
STATUS
::
ERROR
;
break
;
break
;
case
STATE
:
:
WEBSOCKET_TIMEOUT
:
case
STATE
:
:
WEBSOCKET_TIMEOUT
:
case
STATE
:
:
HEARTBEAT_TIMEOUT
:
case
STATE
:
:
HEARTBEAT_TIMEOUT
:
status
=
Nemo
I
nterface
::
STATUS
::
TIMEOUT
;
status
=
Nemo
i
nterface
::
STATUS
::
TIMEOUT
;
break
;
break
;
}
}
return
status
;
return
status
;
}
}
QString
Nemo
Interface
::
Impl
::
_toString
(
NemoI
nterface
::
Impl
::
STATE
s
)
{
QString
Nemo
interface
::
Impl
::
_toString
(
Nemoi
nterface
::
Impl
::
STATE
s
)
{
switch
(
s
)
{
switch
(
s
)
{
case
STATE
:
:
STOPPED
:
case
STATE
:
:
STOPPED
:
return
QString
(
"STOPPED"
);
return
QString
(
"STOPPED"
);
...
@@ -1618,32 +1607,32 @@ QString NemoInterface::Impl::_toString(NemoInterface::Impl::STATE s) {
...
@@ -1618,32 +1607,32 @@ QString NemoInterface::Impl::_toString(NemoInterface::Impl::STATE s) {
return
"unknown state!"
;
return
"unknown state!"
;
}
}
QString
Nemo
Interface
::
Impl
::
_toString
(
NemoI
nterface
::
STATUS
s
)
{
QString
Nemo
interface
::
Impl
::
_toString
(
Nemoi
nterface
::
STATUS
s
)
{
switch
(
s
)
{
switch
(
s
)
{
case
Nemo
I
nterface
:
:
STATUS
::
NOT_CONNECTED
:
case
Nemo
i
nterface
:
:
STATUS
::
NOT_CONNECTED
:
return
QString
(
"NOT_CONNECTED"
);
return
QString
(
"NOT_CONNECTED"
);
case
Nemo
I
nterface
:
:
STATUS
::
ERROR
:
case
Nemo
i
nterface
:
:
STATUS
::
ERROR
:
return
QString
(
"ERROR"
);
return
QString
(
"ERROR"
);
case
Nemo
I
nterface
:
:
STATUS
::
READY
:
case
Nemo
i
nterface
:
:
STATUS
::
READY
:
return
QString
(
"READY"
);
return
QString
(
"READY"
);
case
Nemo
I
nterface
:
:
STATUS
::
TIMEOUT
:
case
Nemo
i
nterface
:
:
STATUS
::
TIMEOUT
:
return
QString
(
"TIMEOUT"
);
return
QString
(
"TIMEOUT"
);
case
Nemo
I
nterface
:
:
STATUS
::
WEBSOCKET_DETECTED
:
case
Nemo
i
nterface
:
:
STATUS
::
WEBSOCKET_DETECTED
:
return
QString
(
"WEBSOCKET_DETECTED"
);
return
QString
(
"WEBSOCKET_DETECTED"
);
case
Nemo
I
nterface
:
:
STATUS
::
SYNC
:
case
Nemo
i
nterface
:
:
STATUS
::
SYNC
:
return
QString
(
"SYNC"
);
return
QString
(
"SYNC"
);
}
}
return
"unknown state!"
;
return
"unknown state!"
;
}
}
bool
Nemo
I
nterface
::
Impl
::
_addTilesImpl
(
bool
Nemo
i
nterface
::
Impl
::
_addTilesImpl
(
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
const
Tile
>>>
pTileArray
,
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
const
Tile
>>>
pTileArray
,
std
::
shared_ptr
<
const
IDArray
>
pIdArray
)
{
std
::
shared_ptr
<
const
IDArray
>
pIdArray
)
{
auto
rb
=
this
->
_pR
osbridge
;
auto
&
rb
=
this
->
_r
osbridge
;
auto
&
disp
=
this
->
_dispatcher
;
auto
&
disp
=
this
->
_dispatcher
;
// add tiles
// add tiles
bool
success
=
this
->
_callAddTiles
(
*
pTileArray
,
disp
,
*
rb
);
bool
success
=
this
->
_callAddTiles
(
*
pTileArray
,
disp
,
rb
);
if
(
!
success
)
{
if
(
!
success
)
{
this
->
_setWarningString
(
this
->
_setWarningString
(
"Adding tiles failed. This might indicate a poor connection."
);
"Adding tiles failed. This might indicate a poor connection."
);
...
@@ -1657,13 +1646,13 @@ bool NemoInterface::Impl::_addTilesImpl(
...
@@ -1657,13 +1646,13 @@ bool NemoInterface::Impl::_addTilesImpl(
this
->
_doActionNotSafe
();
this
->
_doActionNotSafe
();
lk
.
unlock
();
lk
.
unlock
();
this
->
_setWarningString
(
"Adding tiles failed."
);
this
->
_setWarningString
(
"Adding tiles failed."
);
qCDebug
(
Nemo
I
nterfaceLog
)
<<
"_addTilesImpl(): _addTilesRemote return "
qCDebug
(
Nemo
i
nterfaceLog
)
<<
"_addTilesImpl(): _addTilesRemote return "
"false: different tiles with same id."
;
"false: different tiles with same id."
;
return
false
;
return
false
;
}
}
// fetch progress
// fetch progress
auto
array
=
this
->
_callGetProgress
(
*
pIdArray
,
disp
,
*
rb
);
auto
array
=
this
->
_callGetProgress
(
*
pIdArray
,
disp
,
rb
);
if
(
array
.
size
()
!=
pIdArray
->
size
())
{
if
(
array
.
size
()
!=
pIdArray
->
size
())
{
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
this
->
_setStateNotSafe
(
STATE
::
SYNC_ERROR
);
this
->
_setStateNotSafe
(
STATE
::
SYNC_ERROR
);
...
@@ -1681,7 +1670,7 @@ bool NemoInterface::Impl::_addTilesImpl(
...
@@ -1681,7 +1670,7 @@ bool NemoInterface::Impl::_addTilesImpl(
this
->
_doActionNotSafe
();
this
->
_doActionNotSafe
();
lk
.
unlock
();
lk
.
unlock
();
this
->
_setWarningString
(
"Getting progress failed."
);
this
->
_setWarningString
(
"Getting progress failed."
);
qCDebug
(
Nemo
I
nterfaceLog
)
qCDebug
(
Nemo
i
nterfaceLog
)
<<
"_addTilesImpl(): _updateProgress failed: unknown id."
;
<<
"_addTilesImpl(): _updateProgress failed: unknown id."
;
return
false
;
return
false
;
}
}
...
@@ -1689,12 +1678,12 @@ bool NemoInterface::Impl::_addTilesImpl(
...
@@ -1689,12 +1678,12 @@ bool NemoInterface::Impl::_addTilesImpl(
return
true
;
return
true
;
}
}
bool
Nemo
I
nterface
::
Impl
::
_removeTilesImpl
(
bool
Nemo
i
nterface
::
Impl
::
_removeTilesImpl
(
std
::
shared_ptr
<
const
IDArray
>
pIdArray
)
{
std
::
shared_ptr
<
const
IDArray
>
pIdArray
)
{
auto
rb
=
this
->
_pR
osbridge
;
auto
&
rb
=
this
->
_r
osbridge
;
auto
&
disp
=
this
->
_dispatcher
;
auto
&
disp
=
this
->
_dispatcher
;
auto
success
=
this
->
_callRemoveTiles
(
*
pIdArray
,
disp
,
*
rb
);
auto
success
=
this
->
_callRemoveTiles
(
*
pIdArray
,
disp
,
rb
);
if
(
!
success
)
{
if
(
!
success
)
{
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
this
->
_setStateNotSafe
(
STATE
::
SYNC_ERROR
);
this
->
_setStateNotSafe
(
STATE
::
SYNC_ERROR
);
...
@@ -1709,11 +1698,11 @@ bool NemoInterface::Impl::_removeTilesImpl(
...
@@ -1709,11 +1698,11 @@ bool NemoInterface::Impl::_removeTilesImpl(
return
true
;
return
true
;
}
}
bool
Nemo
I
nterface
::
Impl
::
_clearTilesImpl
()
{
bool
Nemo
i
nterface
::
Impl
::
_clearTilesImpl
()
{
auto
rb
=
this
->
_pR
osbridge
;
auto
&
rb
=
this
->
_r
osbridge
;
auto
&
disp
=
this
->
_dispatcher
;
auto
&
disp
=
this
->
_dispatcher
;
auto
success
=
this
->
_callClearTiles
(
disp
,
*
rb
);
auto
success
=
this
->
_callClearTiles
(
disp
,
rb
);
if
(
!
success
)
{
if
(
!
success
)
{
Lock
lk
(
this
->
_m
);
Lock
lk
(
this
->
_m
);
this
->
_setStateNotSafe
(
STATE
::
SYNC_ERROR
);
this
->
_setStateNotSafe
(
STATE
::
SYNC_ERROR
);
...
@@ -1730,24 +1719,18 @@ bool NemoInterface::Impl::_clearTilesImpl() {
...
@@ -1730,24 +1719,18 @@ bool NemoInterface::Impl::_clearTilesImpl() {
// ===============================================================
// ===============================================================
// NemoInterface
// NemoInterface
NemoInterface
::
NemoInterface
()
Nemointerface
::
Nemointerface
(
const
QString
&
connectionString
)
:
QObject
(),
pImpl
(
std
::
make_unique
<
NemoInterface
::
Impl
>
(
this
))
{}
:
QObject
(),
pImpl
(
std
::
make_unique
<
Nemointerface
::
Impl
>
(
connectionString
,
this
))
{}
Nemo
Interface
*
NemoInterface
::
createInstance
()
{
return
new
NemoInterface
();
}
Nemo
interface
::~
Nemointerface
()
{
}
NemoInterface
*
NemoInterface
::
instance
()
{
void
Nemointerface
::
start
()
{
this
->
pImpl
->
start
();
}
return
GenericSingelton
<
NemoInterface
>::
instance
(
NemoInterface
::
createInstance
);
}
NemoInterface
::~
NemoInterface
()
{}
void
NemoInterface
::
start
()
{
this
->
pImpl
->
start
();
}
void
Nemo
I
nterface
::
stop
()
{
this
->
pImpl
->
stop
();
}
void
Nemo
i
nterface
::
stop
()
{
this
->
pImpl
->
stop
();
}
std
::
shared_future
<
QVariant
>
std
::
shared_future
<
QVariant
>
Nemo
I
nterface
::
addTiles
(
const
TileArray
&
tileArray
)
{
Nemo
i
nterface
::
addTiles
(
const
TileArray
&
tileArray
)
{
TilePtrArray
ptrArray
;
TilePtrArray
ptrArray
;
for
(
const
auto
&
tile
:
tileArray
)
{
for
(
const
auto
&
tile
:
tileArray
)
{
ptrArray
.
push_back
(
const_cast
<
MeasurementTile
*>
(
&
tile
));
ptrArray
.
push_back
(
const_cast
<
MeasurementTile
*>
(
&
tile
));
...
@@ -1756,59 +1739,130 @@ NemoInterface::addTiles(const TileArray &tileArray) {
...
@@ -1756,59 +1739,130 @@ NemoInterface::addTiles(const TileArray &tileArray) {
}
}
std
::
shared_future
<
QVariant
>
std
::
shared_future
<
QVariant
>
Nemo
I
nterface
::
addTiles
(
const
TilePtrArray
&
tileArray
)
{
Nemo
i
nterface
::
addTiles
(
const
TilePtrArray
&
tileArray
)
{
return
this
->
pImpl
->
addTiles
(
tileArray
);
return
this
->
pImpl
->
addTiles
(
tileArray
);
}
}
std
::
shared_future
<
QVariant
>
std
::
shared_future
<
QVariant
>
Nemo
I
nterface
::
removeTiles
(
const
IDArray
&
idArray
)
{
Nemo
i
nterface
::
removeTiles
(
const
IDArray
&
idArray
)
{
return
this
->
pImpl
->
removeTiles
(
idArray
);
return
this
->
pImpl
->
removeTiles
(
idArray
);
}
}
std
::
shared_future
<
QVariant
>
Nemo
I
nterface
::
clearTiles
()
{
std
::
shared_future
<
QVariant
>
Nemo
i
nterface
::
clearTiles
()
{
return
this
->
pImpl
->
clearTiles
();
return
this
->
pImpl
->
clearTiles
();
}
}
TileArray
Nemo
I
nterface
::
getTiles
(
const
IDArray
&
idArray
)
const
{
TileArray
Nemo
i
nterface
::
getTiles
(
const
IDArray
&
idArray
)
const
{
return
this
->
pImpl
->
getTiles
(
idArray
);
return
this
->
pImpl
->
getTiles
(
idArray
);
}
}
TileArray
Nemo
I
nterface
::
getAllTiles
()
const
{
TileArray
Nemo
i
nterface
::
getAllTiles
()
const
{
return
this
->
pImpl
->
getAllTiles
();
return
this
->
pImpl
->
getAllTiles
();
}
}
LogicalArray
Nemo
I
nterface
::
containsTiles
(
const
IDArray
&
idArray
)
const
{
LogicalArray
Nemo
i
nterface
::
containsTiles
(
const
IDArray
&
idArray
)
const
{
return
this
->
pImpl
->
containsTiles
(
idArray
);
return
this
->
pImpl
->
containsTiles
(
idArray
);
}
}
std
::
size_t
Nemo
I
nterface
::
size
()
const
{
return
this
->
pImpl
->
size
();
}
std
::
size_t
Nemo
i
nterface
::
size
()
const
{
return
this
->
pImpl
->
size
();
}
bool
Nemo
I
nterface
::
empty
()
const
{
return
this
->
pImpl
->
empty
();
}
bool
Nemo
i
nterface
::
empty
()
const
{
return
this
->
pImpl
->
empty
();
}
ProgressArray
Nemo
I
nterface
::
getProgress
()
const
{
ProgressArray
Nemo
i
nterface
::
getProgress
()
const
{
return
this
->
pImpl
->
getProgress
();
return
this
->
pImpl
->
getProgress
();
}
}
ProgressArray
Nemo
I
nterface
::
getProgress
(
const
IDArray
&
idArray
)
const
{
ProgressArray
Nemo
i
nterface
::
getProgress
(
const
IDArray
&
idArray
)
const
{
return
this
->
pImpl
->
getProgress
(
idArray
);
return
this
->
pImpl
->
getProgress
(
idArray
);
}
}
Nemo
Interface
::
STATUS
NemoI
nterface
::
status
()
const
{
Nemo
interface
::
STATUS
Nemoi
nterface
::
status
()
const
{
return
this
->
pImpl
->
status
();
return
this
->
pImpl
->
status
();
}
}
QString
Nemo
I
nterface
::
statusString
()
const
{
QString
Nemo
i
nterface
::
statusString
()
const
{
return
statusMap
.
at
(
this
->
pImpl
->
status
());
return
statusMap
.
at
(
this
->
pImpl
->
status
());
}
}
QString
Nemo
I
nterface
::
infoString
()
const
{
return
this
->
pImpl
->
infoString
();
}
QString
Nemo
i
nterface
::
infoString
()
const
{
return
this
->
pImpl
->
infoString
();
}
QString
Nemo
I
nterface
::
warningString
()
const
{
QString
Nemo
i
nterface
::
warningString
()
const
{
return
this
->
pImpl
->
warningString
();
return
this
->
pImpl
->
warningString
();
}
}
QString
Nemo
I
nterface
::
editorQml
()
{
QString
Nemo
i
nterface
::
editorQml
()
{
return
QStringLiteral
(
"NemoInterface.qml"
);
return
QStringLiteral
(
"NemoInterface.qml"
);
}
}
bool
NemoInterface
::
running
()
const
{
return
this
->
pImpl
->
running
();
}
bool
Nemointerface
::
running
()
const
{
return
this
->
pImpl
->
running
();
}
QString
Nemointerface
::
connectionString
()
{
return
this
->
pImpl
->
connectionString
();
}
NemointerfaceFactory
*
NemointerfaceFactory
::
createInstance
()
{
return
new
NemointerfaceFactory
();
}
NemointerfaceFactory
*
NemointerfaceFactory
::
instance
()
{
return
GenericSingelton
<
NemointerfaceFactory
>::
instance
(
NemointerfaceFactory
::
createInstance
);
}
std
::
shared_ptr
<
Nemointerface
>
NemointerfaceFactory
::
create
(
const
QString
&
connectionString
)
{
auto
it
=
_map
.
find
(
connectionString
);
// If the interface was cereated, is it still in use?
if
(
it
!=
_map
.
end
())
{
auto
weak
=
it
->
second
;
if
(
!
weak
.
expired
())
{
// Still in use, can't create an other instance.
return
nullptr
;
}
else
{
// Not in use, erase map entry.
it
=
_map
.
erase
(
it
);
}
}
Q_ASSERT
(
it
==
_map
.
end
());
if
(
it
==
_map
.
end
())
{
auto
p
=
std
::
make_shared
<
Nemointerface
>
(
connectionString
);
if
(
p
)
{
QQmlEngine
::
setObjectOwnership
(
p
.
get
(),
QQmlEngine
::
CppOwnership
);
auto
ret
=
_map
.
insert
(
std
::
make_pair
(
connectionString
,
std
::
weak_ptr
<
Nemointerface
>
(
p
)));
// insert error?
Q_ASSERT
(
ret
.
second
==
true
);
if
(
ret
.
second
!=
true
)
{
qCCritical
(
NemointerfaceLog
)
<<
"NemointerfaceFactory::create() not able to insert pair."
;
return
nullptr
;
}
}
return
p
;
}
else
{
qCCritical
(
NemointerfaceLog
)
<<
"NemointerfaceFactory::create() logical error."
;
return
nullptr
;
}
}
bool
NemointerfaceFactory
::
isCreatable
(
const
QString
&
connectionString
)
{
auto
it
=
_map
.
find
(
connectionString
);
// if it was creaded, is it still in use?
if
(
it
!=
_map
.
end
())
{
if
(
it
->
second
.
expired
())
{
it
=
_map
.
erase
(
it
);
return
true
;
}
else
{
return
false
;
}
}
else
{
return
true
;
}
}
src/MeasurementComplexItem/NemoInterface.h
View file @
a4d09405
...
@@ -13,20 +13,20 @@
...
@@ -13,20 +13,20 @@
#include "TilePtrArray.h"
#include "TilePtrArray.h"
#include "geometry/ProgressArray.h"
#include "geometry/ProgressArray.h"
// Singelton class used to interface measurement devices implementing the nemo
class
NemointerfaceFactory
;
// interface.
class
Nemo
I
nterface
:
public
QObject
{
class
Nemo
i
nterface
:
public
QObject
{
Q_OBJECT
Q_OBJECT
class
Impl
;
class
Impl
;
using
PImpl
=
std
::
unique_ptr
<
Impl
>
;
using
PImpl
=
std
::
unique_ptr
<
Impl
>
;
NemoInterface
();
Nemointerface
(
const
QString
&
connectionString
);
NemoInterface
(
NemoInterface
&
other
)
=
delete
;
Nemointerface
(
Nemointerface
&
other
)
=
delete
;
static
NemoInterface
*
createInstance
();
friend
class
NemointerfaceFactory
;
public:
public:
~
NemoInterface
()
override
;
~
Nemointerface
()
override
;
static
NemoInterface
*
instance
();
enum
class
STATUS
{
enum
class
STATUS
{
NOT_CONNECTED
,
NOT_CONNECTED
,
...
@@ -90,6 +90,7 @@ public:
...
@@ -90,6 +90,7 @@ public:
QString
infoString
()
const
;
QString
infoString
()
const
;
QString
warningString
()
const
;
QString
warningString
()
const
;
bool
running
()
const
;
bool
running
()
const
;
QString
connectionString
();
signals:
signals:
void
statusChanged
();
void
statusChanged
();
...
@@ -103,4 +104,25 @@ private:
...
@@ -103,4 +104,25 @@ private:
PImpl
pImpl
;
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()
src/MeasurementComplexItem/json/MeasurementComplexItem.SettingsGroup.json
View file @
a4d09405
...
@@ -17,6 +17,13 @@
...
@@ -17,6 +17,13 @@
"min"
:
1
,
"min"
:
1
,
"decimalPlaces"
:
1
,
"decimalPlaces"
:
1
,
"default"
:
10.0
"default"
:
10.0
},
{
"name"
:
"ConnectionString"
,
"shrotDesc"
:
"Nemo Connection String."
,
"longDesc"
:
"Nemo Connection String (e.g. host_ip:port)."
,
"type"
:
"string"
,
"default"
:
"localhost:9090"
}
}
]
]
}
}
src/QGCApplication.cc
View file @
a4d09405
...
@@ -672,7 +672,7 @@ void QGCApplication::_initCommon() {
...
@@ -672,7 +672,7 @@ void QGCApplication::_initCommon() {
qmlRegisterUncreatableType
<
routing
::
LinearGenerator
>
(
qmlRegisterUncreatableType
<
routing
::
LinearGenerator
>
(
"MeasurementComplexItem"
,
1
,
0
,
"LinearGenerator"
,
kRefOnly
);
"MeasurementComplexItem"
,
1
,
0
,
"LinearGenerator"
,
kRefOnly
);
qmlRegisterType
<
AreaData
>
(
"MeasurementComplexItem"
,
1
,
0
,
"AreaData"
);
qmlRegisterType
<
AreaData
>
(
"MeasurementComplexItem"
,
1
,
0
,
"AreaData"
);
qmlRegisterSingletonType
<
Nemo
I
nterface
>
(
"MeasurementComplexItem"
,
1
,
0
,
qmlRegisterSingletonType
<
Nemo
i
nterface
>
(
"MeasurementComplexItem"
,
1
,
0
,
"NemoInterface"
,
getNemoInterface
);
"NemoInterface"
,
getNemoInterface
);
qmlRegisterInterface
<
routing
::
GeneratorBase
>
(
"GeneratorBase"
);
qmlRegisterInterface
<
routing
::
GeneratorBase
>
(
"GeneratorBase"
);
qmlRegisterUncreatableType
<
routing
::
CircularGenerator
>
(
qmlRegisterUncreatableType
<
routing
::
CircularGenerator
>
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment