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
42fe8ce4
Commit
42fe8ce4
authored
Jan 20, 2021
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nemo interface working
parent
47586728
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
253 additions
and
189 deletions
+253
-189
MeasurementComplexItem.cc
src/MeasurementComplexItem/MeasurementComplexItem.cc
+23
-28
MeasurementComplexItem.h
src/MeasurementComplexItem/MeasurementComplexItem.h
+7
-0
NemoInterface.cpp
src/MeasurementComplexItem/NemoInterface.cpp
+208
-90
NemoInterface.h
src/MeasurementComplexItem/NemoInterface.h
+8
-8
MeasurementArea.cc
src/MeasurementComplexItem/geometry/MeasurementArea.cc
+3
-14
MeasurementArea.h
src/MeasurementComplexItem/geometry/MeasurementArea.h
+0
-16
NemoEditor.qml
src/MeasurementComplexItem/qml/NemoEditor.qml
+4
-33
No files found.
src/MeasurementComplexItem/MeasurementComplexItem.cc
View file @
42fe8ce4
...
...
@@ -54,7 +54,7 @@ MeasurementComplexItem::MeasurementComplexItem(
_altitude
(
settingsGroup
,
_metaDataMap
[
altitudeKey
]),
_variantIndex
(
settingsGroup
,
_metaDataMap
[
variantIndexKey
]),
_pAreaData
(
new
AreaData
(
this
)),
_pEditorData
(
new
AreaData
(
this
)),
_pCurrentData
(
_pAreaData
),
_pGenerator
(
nullptr
),
_pCurrentData
(
_pAreaData
),
_
holdProgress
(
false
),
_
pGenerator
(
nullptr
),
_pWorker
(
new
RoutingThread
(
this
))
{
// Setup altitude.
...
...
@@ -772,6 +772,24 @@ void MeasurementComplexItem::_onAltitudeChanged() {
emit
routeChanged
();
}
}
bool
MeasurementComplexItem
::
holdProgress
()
const
{
return
_holdProgress
;
}
void
MeasurementComplexItem
::
setHoldProgress
(
bool
holdProgress
)
{
if
(
_holdProgress
!=
holdProgress
)
{
_holdProgress
=
holdProgress
;
emit
holdProgressChanged
();
if
(
_holdProgress
)
{
disconnect
(
pNemoInterface
,
&
NemoInterface
::
progressChanged
,
this
,
&
MeasurementComplexItem
::
_onNewProgress
);
}
else
{
connect
(
pNemoInterface
,
&
NemoInterface
::
progressChanged
,
this
,
&
MeasurementComplexItem
::
_onNewProgress
);
_onNewProgress
(
pNemoInterface
->
getProgress
());
}
}
}
void
MeasurementComplexItem
::
_setAreaData
(
MeasurementComplexItem
::
PtrAreaData
data
)
{
if
(
_pCurrentData
!=
data
)
{
...
...
@@ -940,30 +958,9 @@ void MeasurementComplexItem::_syncTiles() {
}
if
(
tilePtrArray
.
size
()
>
0
)
{
// create id array
IDArray
idArray
;
for
(
const
auto
*
pTile
:
tilePtrArray
)
{
idArray
.
push_back
(
pTile
->
id
());
}
// sync. necessary?
bool
doSync
=
false
;
auto
contains
=
pNemoInterface
->
containsTiles
(
idArray
);
for
(
auto
&&
logical
:
contains
)
{
if
(
logical
==
false
)
{
doSync
=
true
;
break
;
}
}
if
(
doSync
)
{
if
(
!
pNemoInterface
->
empty
())
{
(
void
)
pNemoInterface
->
clearTiles
();
}
(
void
)
pNemoInterface
->
addTiles
(
tilePtrArray
);
return
;
}
(
void
)
pNemoInterface
->
clearTiles
();
(
void
)
pNemoInterface
->
addTiles
(
tilePtrArray
);
return
;
}
else
{
clear
=
true
;
}
...
...
@@ -972,9 +969,7 @@ void MeasurementComplexItem::_syncTiles() {
}
if
(
clear
)
{
if
(
!
pNemoInterface
->
empty
())
{
(
void
)
pNemoInterface
->
clearTiles
();
}
(
void
)
pNemoInterface
->
clearTiles
();
}
}
...
...
src/MeasurementComplexItem/MeasurementComplexItem.h
View file @
42fe8ce4
...
...
@@ -43,6 +43,8 @@ public:
generatorListChanged
)
Q_PROPERTY
(
bool
calculating
READ
calculating
NOTIFY
calculatingChanged
)
Q_PROPERTY
(
bool
editing
READ
editing
NOTIFY
editingChanged
)
Q_PROPERTY
(
bool
holdProgress
READ
holdProgress
WRITE
setHoldProgress
NOTIFY
holdProgressChanged
)
Q_PROPERTY
(
bool
idle
READ
idle
NOTIFY
idleChanged
)
Q_PROPERTY
(
routing
::
GeneratorBase
*
generator
READ
generator
NOTIFY
generatorChanged
)
...
...
@@ -219,6 +221,9 @@ public:
static
const
char
*
jsonComplexItemTypeValue
;
static
const
QString
name
;
bool
holdProgress
()
const
;
void
setHoldProgress
(
bool
holdProgress
);
signals:
void
variantNamesChanged
();
...
...
@@ -231,6 +236,7 @@ signals:
void
areaDataChanged
();
void
routeChanged
();
void
holdProgressChanged
();
private
slots
:
...
...
@@ -269,6 +275,7 @@ private:
PtrAreaData
_pAreaData
;
PtrAreaData
_pEditorData
;
PtrAreaData
_pCurrentData
;
bool
_holdProgress
;
// Generators
QList
<
PtrGenerator
>
_generatorList
;
...
...
src/MeasurementComplexItem/NemoInterface.cpp
View file @
42fe8ce4
...
...
@@ -77,31 +77,32 @@ public:
std
::
shared_future
<
QVariant
>
clearTiles
();
// Functions that don't require communication to device.
TileArray
getTiles
(
const
IDArray
&
idArray
);
TileArray
getAllTiles
();
LogicalArray
containsTiles
(
const
IDArray
&
idArray
);
std
::
size_t
size
();
bool
empty
();
TileArray
getTiles
(
const
IDArray
&
idArray
)
const
;
TileArray
getAllTiles
()
const
;
LogicalArray
containsTiles
(
const
IDArray
&
idArray
)
const
;
std
::
size_t
size
()
const
;
bool
empty
()
const
;
// Progress.
ProgressArray
getProgress
();
ProgressArray
getProgress
(
const
IDArray
&
idArray
);
ProgressArray
getProgress
()
const
;
ProgressArray
getProgress
(
const
IDArray
&
idArray
)
const
;
NemoInterface
::
STATUS
status
();
bool
running
();
// thread safe
bool
ready
();
// thread safe
NemoInterface
::
STATUS
status
()
const
;
bool
running
()
const
;
// thread safe
bool
ready
()
const
;
// thread safe
const
QString
&
infoString
();
const
QString
&
warningString
();
const
QString
&
infoString
()
const
;
const
QString
&
warningString
()
const
;
private:
void
_doTopicServiceSetup
();
void
_doAction
();
void
_trySynchronize
();
bool
_isSynchronized
();
bool
_userSync
()
;
// thread safe
bool
_sysSync
()
;
// thread safe
bool
_isSynchronized
()
const
;
bool
_userSync
()
const
;
// thread safe
bool
_sysSync
()
const
;
// thread safe
void
_onFutureWatcherFinished
();
// thread safe
void
_onHeartbeatTimeout
();
// thread safe
// called from dispatcher thread!
QVariant
_callAddTiles
(
...
...
@@ -120,15 +121,21 @@ private:
GET_PROGRESS
,
GET_ALL_PROGRESS
};
QString
_toString
(
CALL_NAME
name
);
void
_addTilesRemote
(
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
const
Tile
>>>
pTileArray
);
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
const
Tile
>>>
pTileArray
,
std
::
promise
<
bool
>
promise
);
void
_addTilesRemote
(
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
Tile
>>>
pTileArray
);
void
_removeTilesRemote
(
std
::
shared_ptr
<
IDArray
>
idArray
);
void
_clearTilesRemote
();
void
_updateProgress
(
std
::
shared_ptr
<
ProgressArray
>
pArray
);
void
_onHeartbeatReceived
(
const
QNemoHeartbeat
&
hb
);
_addTilesRemote2
(
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
Tile
>>>
pTileArray
,
std
::
promise
<
bool
>
promise
);
void
_removeTilesRemote
(
std
::
shared_ptr
<
IDArray
>
idArray
,
std
::
promise
<
bool
>
promise
);
void
_clearTilesRemote
(
std
::
promise
<
bool
>
promise
);
void
_updateProgress
(
std
::
shared_ptr
<
ProgressArray
>
pArray
,
std
::
promise
<
bool
>
promise
);
void
_onHeartbeatReceived
(
const
QNemoHeartbeat
&
hb
,
std
::
promise
<
bool
>
promise
);
void
_setInfoString
(
const
QString
&
info
);
void
_setWarningString
(
const
QString
&
warning
);
...
...
@@ -198,10 +205,8 @@ NemoInterface::Impl::Impl(NemoInterface *p)
setConnectionString
();
// Heartbeat timeout.
connect
(
&
this
->
_timeoutTimer
,
&
QTimer
::
timeout
,
[
this
]
{
this
->
_setState
(
STATE
::
HEARTBEAT_TIMEOUT
);
this
->
_doAction
();
});
connect
(
&
this
->
_timeoutTimer
,
&
QTimer
::
timeout
,
std
::
bind
(
&
Impl
::
_onHeartbeatTimeout
,
this
));
// Connection timer (temporary workaround)
connect
(
&
this
->
_connectionTimer
,
&
QTimer
::
timeout
,
[
this
]
{
...
...
@@ -226,7 +231,7 @@ NemoInterface::Impl::Impl(NemoInterface *p)
[
this
]
{
this
->
_onFutureWatcherFinished
();
});
}
NemoInterface
::
Impl
::~
Impl
()
{}
NemoInterface
::
Impl
::~
Impl
()
{
this
->
_pRosBridge
->
reset
();
}
void
NemoInterface
::
Impl
::
start
()
{
if
(
!
running
())
{
...
...
@@ -246,6 +251,8 @@ std::shared_future<QVariant>
NemoInterface
::
Impl
::
addTiles
(
const
TilePtrArray
&
tileArray
)
{
using
namespace
nemo_interface
;
qDebug
()
<<
"addTiles called"
;
if
(
tileArray
.
size
()
>
0
)
{
// copy unknown tiles
...
...
@@ -266,6 +273,9 @@ NemoInterface::Impl::addTiles(const TilePtrArray &tileArray) {
<<
"addTiles(): tile with id: "
<<
pTile
->
id
()
<<
"already added."
;
}
}
if
(
pTileArray
->
size
()
>
0
)
{
this
->
_parent
->
tilesChanged
();
}
// ready for send?
if
(
pTileArray
->
size
()
>
0
&&
(
this
->
ready
()
||
this
->
_userSync
()))
{
...
...
@@ -308,6 +318,8 @@ std::shared_future<QVariant>
NemoInterface
::
Impl
::
removeTiles
(
const
IDArray
&
idArray
)
{
using
namespace
nemo_interface
;
qDebug
()
<<
"removeTiles called"
;
if
(
idArray
.
size
()
>
0
)
{
// copy known ids
...
...
@@ -322,6 +334,9 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) {
qCDebug
(
NemoInterfaceLog
)
<<
"removeTiles(): unknown id: "
<<
id
<<
"."
;
}
}
if
(
pIdArray
->
size
()
>
0
)
{
this
->
_parent
->
tilesChanged
();
}
// ready for send?
if
(
pIdArray
->
size
()
>
0
&&
(
this
->
ready
()
||
this
->
_userSync
()))
{
...
...
@@ -349,10 +364,15 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) {
std
::
shared_future
<
QVariant
>
NemoInterface
::
Impl
::
clearTiles
()
{
using
namespace
nemo_interface
;
qDebug
()
<<
"clearTiles called"
;
// clear local tiles (_localTiles)
this
->
_localTiles
.
clear
();
if
(
!
_localTiles
.
empty
())
{
this
->
_localTiles
.
clear
();
this
->
_parent
->
tilesChanged
();
}
if
(
this
->
_localTiles
.
size
()
>
0
&&
(
this
->
ready
()
||
this
->
_userSync
()
))
{
if
(
this
->
ready
()
||
this
->
_userSync
(
))
{
this
->
_setState
(
STATE
::
USER_SYNC
);
this
->
_doAction
();
...
...
@@ -373,7 +393,7 @@ std::shared_future<QVariant> NemoInterface::Impl::clearTiles() {
}
}
TileArray
NemoInterface
::
Impl
::
getTiles
(
const
IDArray
&
idArray
)
{
TileArray
NemoInterface
::
Impl
::
getTiles
(
const
IDArray
&
idArray
)
const
{
TileArray
tileArray
;
for
(
const
auto
&
id
:
idArray
)
{
...
...
@@ -390,7 +410,7 @@ TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) {
return
tileArray
;
}
TileArray
NemoInterface
::
Impl
::
getAllTiles
()
{
TileArray
NemoInterface
::
Impl
::
getAllTiles
()
const
{
TileArray
tileArray
;
for
(
const
auto
&
entry
:
_localTiles
)
{
...
...
@@ -405,7 +425,7 @@ TileArray NemoInterface::Impl::getAllTiles() {
return
tileArray
;
}
LogicalArray
NemoInterface
::
Impl
::
containsTiles
(
const
IDArray
&
idArray
)
{
LogicalArray
NemoInterface
::
Impl
::
containsTiles
(
const
IDArray
&
idArray
)
const
{
LogicalArray
logicalArray
;
for
(
const
auto
&
id
:
idArray
)
{
...
...
@@ -416,11 +436,11 @@ LogicalArray NemoInterface::Impl::containsTiles(const IDArray &idArray) {
return
logicalArray
;
}
std
::
size_t
NemoInterface
::
Impl
::
size
()
{
return
_localTiles
.
size
();
}
std
::
size_t
NemoInterface
::
Impl
::
size
()
const
{
return
_localTiles
.
size
();
}
bool
NemoInterface
::
Impl
::
empty
()
{
return
_localTiles
.
empty
();
}
bool
NemoInterface
::
Impl
::
empty
()
const
{
return
_localTiles
.
empty
();
}
ProgressArray
NemoInterface
::
Impl
::
getProgress
()
{
ProgressArray
NemoInterface
::
Impl
::
getProgress
()
const
{
ProgressArray
progressArray
;
if
(
this
->
_isSynchronized
())
{
...
...
@@ -438,7 +458,7 @@ ProgressArray NemoInterface::Impl::getProgress() {
return
progressArray
;
}
ProgressArray
NemoInterface
::
Impl
::
getProgress
(
const
IDArray
&
idArray
)
{
ProgressArray
NemoInterface
::
Impl
::
getProgress
(
const
IDArray
&
idArray
)
const
{
ProgressArray
progressArray
;
if
(
this
->
_isSynchronized
())
{
...
...
@@ -462,33 +482,45 @@ ProgressArray NemoInterface::Impl::getProgress(const IDArray &idArray) {
return
progressArray
;
}
NemoInterface
::
STATUS
NemoInterface
::
Impl
::
status
()
{
NemoInterface
::
STATUS
NemoInterface
::
Impl
::
status
()
const
{
return
_status
(
this
->
_state
);
}
bool
NemoInterface
::
Impl
::
running
()
{
return
_running
(
this
->
_state
);
}
bool
NemoInterface
::
Impl
::
running
()
const
{
return
_running
(
this
->
_state
);
}
bool
NemoInterface
::
Impl
::
ready
()
{
return
_ready
(
this
->
_state
.
load
());
}
bool
NemoInterface
::
Impl
::
ready
()
const
{
return
_ready
(
this
->
_state
.
load
());
}
bool
NemoInterface
::
Impl
::
_sysSync
()
{
return
_sysSync
(
this
->
_state
);
}
bool
NemoInterface
::
Impl
::
_sysSync
()
const
{
return
_sysSync
(
this
->
_state
);
}
void
NemoInterface
::
Impl
::
_onFutureWatcherFinished
()
{
if
(
this
->
_userSync
()
||
this
->
_sysSync
())
{
if
(
this
->
ready
()
||
this
->
_userSync
()
||
this
->
_sysSync
())
{
auto
lastTransactionSuccessfull
=
_futureWatcher
.
result
().
toBool
();
if
(
!
lastTransactionSuccessfull
)
{
QTimer
::
singleShot
(
1000
,
[
this
]
{
this
->
_trySynchronize
();
});
qCDebug
(
NemoInterfaceLog
)
<<
"last transaction unsuccessfull: "
<<
_toString
(
_lastCall
);
QTimer
::
singleShot
(
5000
,
[
this
]
{
this
->
_trySynchronize
();
});
}
}
}
bool
NemoInterface
::
Impl
::
_userSync
()
{
return
_userSync
(
this
->
_state
);
}
void
NemoInterface
::
Impl
::
_onHeartbeatTimeout
()
{
this
->
_setState
(
STATE
::
HEARTBEAT_TIMEOUT
);
this
->
_doAction
();
}
bool
NemoInterface
::
Impl
::
_userSync
()
const
{
return
_userSync
(
this
->
_state
);
}
const
QString
&
NemoInterface
::
Impl
::
infoString
()
{
return
_infoString
;
}
const
QString
&
NemoInterface
::
Impl
::
infoString
()
const
{
return
_infoString
;
}
const
QString
&
NemoInterface
::
Impl
::
warningString
()
{
return
_warningString
;
}
const
QString
&
NemoInterface
::
Impl
::
warningString
()
const
{
return
_warningString
;
}
void
NemoInterface
::
Impl
::
_updateProgress
(
std
::
shared_ptr
<
ProgressArray
>
pArray
)
{
void
NemoInterface
::
Impl
::
_updateProgress
(
std
::
shared_ptr
<
ProgressArray
>
pArray
,
std
::
promise
<
bool
>
promise
)
{
qDebug
()
<<
"_updateProgress called"
;
bool
error
=
false
;
for
(
auto
itLP
=
pArray
->
begin
();
itLP
!=
pArray
->
end
();)
{
auto
it
=
_remoteTiles
.
find
(
itLP
->
id
());
...
...
@@ -500,15 +532,19 @@ void NemoInterface::Impl::_updateProgress(
qCDebug
(
NemoInterfaceLog
)
<<
"_updateProgress(): tile with id "
<<
itLP
->
id
()
<<
" not found."
;
itLP
=
pArray
->
erase
(
itLP
);
error
=
true
;
}
}
if
(
pArray
->
size
()
>
0
)
{
emit
_parent
->
progressChanged
(
*
pArray
);
}
promise
.
set_value
(
!
error
);
}
void
NemoInterface
::
Impl
::
_onHeartbeatReceived
(
const
QNemoHeartbeat
&
hb
)
{
void
NemoInterface
::
Impl
::
_onHeartbeatReceived
(
const
QNemoHeartbeat
&
hb
,
std
::
promise
<
bool
>
promise
)
{
_lastHeartbeat
=
hb
;
this
->
_timeoutTimer
.
start
(
NO_HEARTBEAT_TIMEOUT
);
if
(
this
->
_state
==
STATE
::
TRY_TOPIC_SERVICE_SETUP
)
{
...
...
@@ -518,6 +554,7 @@ void NemoInterface::Impl::_onHeartbeatReceived(const QNemoHeartbeat &hb) {
this
->
_setState
(
STATE
::
READY
);
this
->
_doAction
();
}
promise
.
set_value
(
true
);
}
void
NemoInterface
::
Impl
::
_setInfoString
(
const
QString
&
info
)
{
...
...
@@ -577,9 +614,15 @@ void NemoInterface::Impl::_doTopicServiceSetup() {
auto
p
=
std
::
make_shared
<
ProgressArray
>
();
*
p
=
std
::
move
(
progressArray
.
progress_array
());
QMetaObject
::
invokeMethod
(
std
::
promise
<
bool
>
promise
;
auto
future
=
promise
.
get_future
();
bool
value
=
QMetaObject
::
invokeMethod
(
this
->
_parent
,
std
::
bind
(
&
NemoInterface
::
Impl
::
_updateProgress
,
this
,
p
));
[
this
,
p
,
promise
=
std
::
move
(
promise
)]()
mutable
{
this
->
_updateProgress
(
p
,
std
::
move
(
promise
));
});
Q_ASSERT
(
value
==
true
);
future
.
wait
();
}
else
{
qCWarning
(
NemoInterfaceLog
)
<<
"/nemo/progress not able to "
"create ProgressArray form json: "
...
...
@@ -614,10 +657,15 @@ void NemoInterface::Impl::_doTopicServiceSetup() {
// create obj from json
nemo_msgs
::
heartbeat
::
Heartbeat
heartbeat
;
if
(
nemo_msgs
::
heartbeat
::
fromJson
(
d
[
"msg"
],
heartbeat
))
{
QMetaObject
::
invokeMethod
(
std
::
promise
<
bool
>
promise
;
auto
future
=
promise
.
get_future
();
bool
value
=
QMetaObject
::
invokeMethod
(
this
->
_parent
,
std
::
bind
(
&
NemoInterface
::
Impl
::
_onHeartbeatReceived
,
this
,
heartbeat
));
[
this
,
heartbeat
,
promise
=
std
::
move
(
promise
)]()
mutable
{
this
->
_onHeartbeatReceived
(
heartbeat
,
std
::
move
(
promise
));
});
Q_ASSERT
(
value
==
true
);
future
.
wait
();
}
else
{
qCWarning
(
NemoInterfaceLog
)
<<
"/nemo/heartbeat not able to "
"create Heartbeat form json: "
...
...
@@ -640,6 +688,9 @@ void NemoInterface::Impl::_trySynchronize() {
if
((
this
->
_state
==
STATE
::
READY
||
this
->
_state
==
STATE
::
SYS_SYNC
||
this
->
_state
==
STATE
::
USER_SYNC
)
&&
!
_isSynchronized
())
{
qCWarning
(
NemoInterfaceLog
)
<<
"trying to synchronize"
;
this
->
_setState
(
STATE
::
SYS_SYNC
);
this
->
_doAction
();
...
...
@@ -691,7 +742,7 @@ void NemoInterface::Impl::_trySynchronize() {
}
}
bool
NemoInterface
::
Impl
::
_isSynchronized
()
{
bool
NemoInterface
::
Impl
::
_isSynchronized
()
const
{
return
_localTiles
.
size
()
>
0
&&
_remoteTiles
.
size
()
>
0
&&
std
::
equal
(
_localTiles
.
begin
(),
_localTiles
.
end
(),
_remoteTiles
.
begin
(),
...
...
@@ -704,7 +755,7 @@ void NemoInterface::Impl::_doAction() {
case
STATE
:
:
STOPPED
:
this
->
_connectionTimer
.
stop
();
this
->
_timeoutTimer
.
stop
();
this
->
_clearTilesRemote
();
this
->
_clearTilesRemote
(
std
::
promise
<
bool
>
()
);
if
(
this
->
_pRosBridge
->
running
())
{
this
->
_pRosBridge
->
reset
();
}
...
...
@@ -731,7 +782,7 @@ void NemoInterface::Impl::_doAction() {
case
STATE
:
:
SYS_SYNC
:
break
;
case
STATE
:
:
HEARTBEAT_TIMEOUT
:
this
->
_clearTilesRemote
();
this
->
_clearTilesRemote
(
std
::
promise
<
bool
>
()
);
break
;
case
STATE
:
:
WEBSOCKET_TIMEOUT
:
if
(
!
resetDone
)
{
...
...
@@ -739,7 +790,8 @@ void NemoInterface::Impl::_doAction() {
this
->
_pRosBridge
->
reset
();
this
->
_pRosBridge
->
run
();
}
this
->
_clearTilesRemote
();
this
->
_timeoutTimer
.
stop
();
this
->
_clearTilesRemote
(
std
::
promise
<
bool
>
());
break
;
};
}
...
...
@@ -747,6 +799,8 @@ void NemoInterface::Impl::_doAction() {
QVariant
NemoInterface
::
Impl
::
_callAddTiles
(
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
const
Tile
>>>
pTileArray
)
{
qDebug
()
<<
"_callAddTiles called"
;
this
->
_lastCall
=
CALL_NAME
::
ADD_TILES
;
// create json object
...
...
@@ -831,16 +885,22 @@ QVariant NemoInterface::Impl::_callAddTiles(
}
// add remote tiles (_remoteTiles)
QMetaObject
::
invokeMethod
(
this
->
_parent
/* context */
,
[
this
,
pTileArray
]
{
this
->
_addTilesRemote
(
pTileArray
);
});
std
::
promise
<
bool
>
promise
;
auto
future
=
promise
.
get_future
();
bool
value
=
QMetaObject
::
invokeMethod
(
this
->
_parent
/* context */
,
[
this
,
pTileArray
,
promise
=
std
::
move
(
promise
)]()
mutable
{
this
->
_addTilesRemote
(
pTileArray
,
std
::
move
(
promise
));
});
Q_ASSERT
(
value
==
true
);
// return success
return
QVariant
(
true
);
return
QVariant
(
future
.
get
()
);
}
QVariant
NemoInterface
::
Impl
::
_callRemoveTiles
(
std
::
shared_ptr
<
IDArray
>
pIdArray
)
{
qDebug
()
<<
"_callRemoveTiles called"
;
this
->
_lastCall
=
CALL_NAME
::
REMOVE_TILES
;
...
...
@@ -920,16 +980,22 @@ NemoInterface::Impl::_callRemoveTiles(std::shared_ptr<IDArray> pIdArray) {
}
// remove remote tiles (_remoteTiles)
QMetaObject
::
invokeMethod
(
this
->
_parent
/* context */
,
[
this
,
pIdArray
]
{
this
->
_removeTilesRemote
(
pIdArray
);
});
std
::
promise
<
bool
>
promise
;
auto
future
=
promise
.
get_future
();
bool
value
=
QMetaObject
::
invokeMethod
(
this
->
_parent
/* context */
,
[
this
,
pIdArray
,
promise
=
std
::
move
(
promise
)]()
mutable
{
this
->
_removeTilesRemote
(
pIdArray
,
std
::
move
(
promise
));
});
Q_ASSERT
(
value
==
true
);
// return success
return
QVariant
(
true
);
return
QVariant
(
future
.
get
()
);
}
QVariant
NemoInterface
::
Impl
::
_callClearTiles
()
{
qDebug
()
<<
"_callClearTiles called"
;
this
->
_lastCall
=
CALL_NAME
::
CLEAR_TILES
;
// create response handler.
...
...
@@ -988,15 +1054,21 @@ QVariant NemoInterface::Impl::_callClearTiles() {
}
// clear remote tiles (_remoteTiles)
QMetaObject
::
invokeMethod
(
this
->
_parent
,
std
::
bind
(
&
Impl
::
_clearTilesRemote
,
this
));
std
::
promise
<
bool
>
promise
;
auto
future
=
promise
.
get_future
();
bool
value
=
QMetaObject
::
invokeMethod
(
this
->
_parent
,
[
this
,
promise
=
std
::
move
(
promise
)]()
mutable
{
this
->
_clearTilesRemote
(
std
::
move
(
promise
));
});
Q_ASSERT
(
value
==
true
);
// return success
return
QVariant
(
true
);
return
QVariant
(
future
.
get
()
);
}
QVariant
NemoInterface
::
Impl
::
_callGetProgress
(
std
::
shared_ptr
<
IDArray
>
pIdArray
)
{
qDebug
()
<<
"_callGetProgress called"
;
this
->
_lastCall
=
CALL_NAME
::
GET_PROGRESS
;
...
...
@@ -1083,14 +1155,20 @@ NemoInterface::Impl::_callGetProgress(std::shared_ptr<IDArray> pIdArray) {
}
// remove remote tiles (_remoteTiles)
QMetaObject
::
invokeMethod
(
this
->
_parent
/* context */
,
[
this
,
pArray
]
{
this
->
_updateProgress
(
pArray
);
});
std
::
promise
<
bool
>
promise
;
auto
future
=
promise
.
get_future
();
bool
value
=
QMetaObject
::
invokeMethod
(
this
->
_parent
,
[
this
,
pArray
,
promise
=
std
::
move
(
promise
)]()
mutable
{
this
->
_updateProgress
(
pArray
,
std
::
move
(
promise
));
});
Q_ASSERT
(
value
==
true
);
// return success
return
QVariant
(
true
);
return
QVariant
(
future
.
get
()
);
}
QVariant
NemoInterface
::
Impl
::
_callGetAllProgress
()
{
qDebug
()
<<
"_callGetAllProgress called"
;
this
->
_lastCall
=
CALL_NAME
::
GET_ALL_PROGRESS
;
...
...
@@ -1168,26 +1246,56 @@ QVariant NemoInterface::Impl::_callGetAllProgress() {
}
// remove remote tiles (_remoteTiles)
QMetaObject
::
invokeMethod
(
this
->
_parent
/* context */
,
[
this
,
pArray
]
{
this
->
_updateProgress
(
pArray
);
});
std
::
promise
<
bool
>
promise
;
auto
future
=
promise
.
get_future
();
bool
value
=
QMetaObject
::
invokeMethod
(
this
->
_parent
,
[
this
,
pArray
,
promise
=
std
::
move
(
promise
)]()
mutable
{
this
->
_updateProgress
(
pArray
,
std
::
move
(
promise
));
});
Q_ASSERT
(
value
==
true
);
// return success
return
QVariant
(
true
);
return
QVariant
(
future
.
get
());
}
QString
NemoInterface
::
Impl
::
_toString
(
NemoInterface
::
Impl
::
CALL_NAME
name
)
{
switch
(
name
)
{
case
CALL_NAME
:
:
ADD_TILES
:
return
QString
(
"ADD_TILES"
);
case
CALL_NAME
:
:
REMOVE_TILES
:
return
QString
(
"REMOVE_TILES"
);
case
CALL_NAME
:
:
CLEAR_TILES
:
return
QString
(
"CLEAR_TILES"
);
case
CALL_NAME
:
:
GET_PROGRESS
:
return
QString
(
"GET_PROGRESS"
);
case
CALL_NAME
:
:
GET_ALL_PROGRESS
:
return
QString
(
"GET_ALL_PROGRESS"
);
}
return
QString
(
"unknown CALL_NAME"
);
}
void
NemoInterface
::
Impl
::
_addTilesRemote
(
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
const
Tile
>>>
pTileArray
)
{
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
const
Tile
>>>
pTileArray
,
std
::
promise
<
bool
>
promise
)
{
qDebug
()
<<
"_addTilesRemote called"
;
auto
pArrayDup
=
std
::
make_shared
<
QVector
<
std
::
shared_ptr
<
Tile
>>>
();
for
(
auto
pTile
:
*
pTileArray
)
{
pArrayDup
->
push_back
(
std
::
make_shared
<
Tile
>
(
*
pTile
));
}
_addTilesRemote
(
pArrayDup
);
_addTilesRemote
2
(
pArrayDup
,
std
::
move
(
promise
)
);
}
void
NemoInterface
::
Impl
::
_addTilesRemote
(
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
Tile
>>>
pTileArray
)
{
void
NemoInterface
::
Impl
::
_addTilesRemote2
(
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
Tile
>>>
pTileArray
,
std
::
promise
<
bool
>
promise
)
{
qDebug
()
<<
"_addTilesRemote2 called"
;
bool
anyChange
=
false
;
bool
error
=
false
;
for
(
auto
pTile
:
*
pTileArray
)
{
auto
id
=
pTile
->
id
();
...
...
@@ -1200,6 +1308,9 @@ void NemoInterface::Impl::_addTilesRemote(
}
else
{
qCWarning
(
NemoInterfaceLog
)
<<
"_addTilesRemote: tile with id "
<<
id
<<
" already added."
;
if
(
pTile
->
tile
()
!=
it
->
second
->
tile
())
{
error
=
true
;
}
}
}
...
...
@@ -1208,11 +1319,14 @@ void NemoInterface::Impl::_addTilesRemote(
this
->
_setState
(
STATE
::
READY
);
this
->
_doAction
();
}
this
->
_parent
->
tilesChanged
();
}
promise
.
set_value
(
!
error
);
}
void
NemoInterface
::
Impl
::
_removeTilesRemote
(
std
::
shared_ptr
<
IDArray
>
idArray
)
{
void
NemoInterface
::
Impl
::
_removeTilesRemote
(
std
::
shared_ptr
<
IDArray
>
idArray
,
std
::
promise
<
bool
>
promise
)
{
qDebug
()
<<
"_removeTilesRemote called"
;
bool
anyChange
=
false
;
for
(
const
auto
id
:
*
idArray
)
{
...
...
@@ -1231,19 +1345,21 @@ void NemoInterface::Impl::_removeTilesRemote(std::shared_ptr<IDArray> idArray) {
this
->
_setState
(
STATE
::
READY
);
this
->
_doAction
();
}
this
->
_parent
->
tilesChanged
();
}
promise
.
set_value
(
true
);
}
void
NemoInterface
::
Impl
::
_clearTilesRemote
()
{
void
NemoInterface
::
Impl
::
_clearTilesRemote
(
std
::
promise
<
bool
>
promise
)
{
qDebug
()
<<
"_clearTilesRemote called"
;
if
(
_remoteTiles
.
size
()
>
0
)
{
_remoteTiles
.
clear
();
if
(
this
->
_isSynchronized
())
{
this
->
_setState
(
STATE
::
READY
);
this
->
_doAction
();
}
this
->
_parent
->
tilesChanged
();
}
promise
.
set_value
(
true
);
}
bool
NemoInterface
::
Impl
::
_setState
(
STATE
newState
)
{
...
...
@@ -1398,25 +1514,27 @@ std::shared_future<QVariant> NemoInterface::clearTiles() {
return
this
->
pImpl
->
clearTiles
();
}
TileArray
NemoInterface
::
getTiles
(
const
IDArray
&
idArray
)
{
TileArray
NemoInterface
::
getTiles
(
const
IDArray
&
idArray
)
const
{
return
this
->
pImpl
->
getTiles
(
idArray
);