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(
...
@@ -54,7 +54,7 @@ MeasurementComplexItem::MeasurementComplexItem(
_altitude
(
settingsGroup
,
_metaDataMap
[
altitudeKey
]),
_altitude
(
settingsGroup
,
_metaDataMap
[
altitudeKey
]),
_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
),
_pGenerator
(
nullptr
),
_pCurrentData
(
_pAreaData
),
_
holdProgress
(
false
),
_
pGenerator
(
nullptr
),
_pWorker
(
new
RoutingThread
(
this
))
{
_pWorker
(
new
RoutingThread
(
this
))
{
// Setup altitude.
// Setup altitude.
...
@@ -772,6 +772,24 @@ void MeasurementComplexItem::_onAltitudeChanged() {
...
@@ -772,6 +772,24 @@ void MeasurementComplexItem::_onAltitudeChanged() {
emit
routeChanged
();
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
(
void
MeasurementComplexItem
::
_setAreaData
(
MeasurementComplexItem
::
PtrAreaData
data
)
{
MeasurementComplexItem
::
PtrAreaData
data
)
{
if
(
_pCurrentData
!=
data
)
{
if
(
_pCurrentData
!=
data
)
{
...
@@ -940,30 +958,9 @@ void MeasurementComplexItem::_syncTiles() {
...
@@ -940,30 +958,9 @@ void MeasurementComplexItem::_syncTiles() {
}
}
if
(
tilePtrArray
.
size
()
>
0
)
{
if
(
tilePtrArray
.
size
()
>
0
)
{
(
void
)
pNemoInterface
->
clearTiles
();
// create id array
(
void
)
pNemoInterface
->
addTiles
(
tilePtrArray
);
IDArray
idArray
;
return
;
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
;
}
}
else
{
}
else
{
clear
=
true
;
clear
=
true
;
}
}
...
@@ -972,9 +969,7 @@ void MeasurementComplexItem::_syncTiles() {
...
@@ -972,9 +969,7 @@ void MeasurementComplexItem::_syncTiles() {
}
}
if
(
clear
)
{
if
(
clear
)
{
if
(
!
pNemoInterface
->
empty
())
{
(
void
)
pNemoInterface
->
clearTiles
();
(
void
)
pNemoInterface
->
clearTiles
();
}
}
}
}
}
...
...
src/MeasurementComplexItem/MeasurementComplexItem.h
View file @
42fe8ce4
...
@@ -43,6 +43,8 @@ public:
...
@@ -43,6 +43,8 @@ public:
generatorListChanged
)
generatorListChanged
)
Q_PROPERTY
(
bool
calculating
READ
calculating
NOTIFY
calculatingChanged
)
Q_PROPERTY
(
bool
calculating
READ
calculating
NOTIFY
calculatingChanged
)
Q_PROPERTY
(
bool
editing
READ
editing
NOTIFY
editingChanged
)
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
(
bool
idle
READ
idle
NOTIFY
idleChanged
)
Q_PROPERTY
(
Q_PROPERTY
(
routing
::
GeneratorBase
*
generator
READ
generator
NOTIFY
generatorChanged
)
routing
::
GeneratorBase
*
generator
READ
generator
NOTIFY
generatorChanged
)
...
@@ -219,6 +221,9 @@ public:
...
@@ -219,6 +221,9 @@ public:
static
const
char
*
jsonComplexItemTypeValue
;
static
const
char
*
jsonComplexItemTypeValue
;
static
const
QString
name
;
static
const
QString
name
;
bool
holdProgress
()
const
;
void
setHoldProgress
(
bool
holdProgress
);
signals:
signals:
void
variantNamesChanged
();
void
variantNamesChanged
();
...
@@ -231,6 +236,7 @@ signals:
...
@@ -231,6 +236,7 @@ signals:
void
areaDataChanged
();
void
areaDataChanged
();
void
routeChanged
();
void
routeChanged
();
void
holdProgressChanged
();
private
slots
:
private
slots
:
...
@@ -269,6 +275,7 @@ private:
...
@@ -269,6 +275,7 @@ private:
PtrAreaData
_pAreaData
;
PtrAreaData
_pAreaData
;
PtrAreaData
_pEditorData
;
PtrAreaData
_pEditorData
;
PtrAreaData
_pCurrentData
;
PtrAreaData
_pCurrentData
;
bool
_holdProgress
;
// Generators
// Generators
QList
<
PtrGenerator
>
_generatorList
;
QList
<
PtrGenerator
>
_generatorList
;
...
...
src/MeasurementComplexItem/NemoInterface.cpp
View file @
42fe8ce4
...
@@ -77,31 +77,32 @@ public:
...
@@ -77,31 +77,32 @@ public:
std
::
shared_future
<
QVariant
>
clearTiles
();
std
::
shared_future
<
QVariant
>
clearTiles
();
// Functions that don't require communication to device.
// Functions that don't require communication to device.
TileArray
getTiles
(
const
IDArray
&
idArray
);
TileArray
getTiles
(
const
IDArray
&
idArray
)
const
;
TileArray
getAllTiles
();
TileArray
getAllTiles
()
const
;
LogicalArray
containsTiles
(
const
IDArray
&
idArray
);
LogicalArray
containsTiles
(
const
IDArray
&
idArray
)
const
;
std
::
size_t
size
();
std
::
size_t
size
()
const
;
bool
empty
();
bool
empty
()
const
;
// Progress.
// Progress.
ProgressArray
getProgress
();
ProgressArray
getProgress
()
const
;
ProgressArray
getProgress
(
const
IDArray
&
idArray
);
ProgressArray
getProgress
(
const
IDArray
&
idArray
)
const
;
NemoInterface
::
STATUS
status
();
NemoInterface
::
STATUS
status
()
const
;
bool
running
();
// thread safe
bool
running
()
const
;
// thread safe
bool
ready
();
// thread safe
bool
ready
()
const
;
// thread safe
const
QString
&
infoString
();
const
QString
&
infoString
()
const
;
const
QString
&
warningString
();
const
QString
&
warningString
()
const
;
private:
private:
void
_doTopicServiceSetup
();
void
_doTopicServiceSetup
();
void
_doAction
();
void
_doAction
();
void
_trySynchronize
();
void
_trySynchronize
();
bool
_isSynchronized
();
bool
_isSynchronized
()
const
;
bool
_userSync
()
;
// thread safe
bool
_userSync
()
const
;
// thread safe
bool
_sysSync
()
;
// thread safe
bool
_sysSync
()
const
;
// thread safe
void
_onFutureWatcherFinished
();
// thread safe
void
_onFutureWatcherFinished
();
// thread safe
void
_onHeartbeatTimeout
();
// thread safe
// called from dispatcher thread!
// called from dispatcher thread!
QVariant
_callAddTiles
(
QVariant
_callAddTiles
(
...
@@ -120,15 +121,21 @@ private:
...
@@ -120,15 +121,21 @@ private:
GET_PROGRESS
,
GET_PROGRESS
,
GET_ALL_PROGRESS
GET_ALL_PROGRESS
};
};
QString
_toString
(
CALL_NAME
name
);
void
_addTilesRemote
(
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
void
_addTilesRemote
(
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
Tile
>>>
pTileArray
);
_addTilesRemote2
(
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
Tile
>>>
pTileArray
,
void
_removeTilesRemote
(
std
::
shared_ptr
<
IDArray
>
idArray
);
std
::
promise
<
bool
>
promise
);
void
_clearTilesRemote
();
void
_removeTilesRemote
(
std
::
shared_ptr
<
IDArray
>
idArray
,
void
_updateProgress
(
std
::
shared_ptr
<
ProgressArray
>
pArray
);
std
::
promise
<
bool
>
promise
);
void
_onHeartbeatReceived
(
const
QNemoHeartbeat
&
hb
);
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
_setInfoString
(
const
QString
&
info
);
void
_setWarningString
(
const
QString
&
warning
);
void
_setWarningString
(
const
QString
&
warning
);
...
@@ -198,10 +205,8 @@ NemoInterface::Impl::Impl(NemoInterface *p)
...
@@ -198,10 +205,8 @@ NemoInterface::Impl::Impl(NemoInterface *p)
setConnectionString
();
setConnectionString
();
// Heartbeat timeout.
// Heartbeat timeout.
connect
(
&
this
->
_timeoutTimer
,
&
QTimer
::
timeout
,
[
this
]
{
connect
(
&
this
->
_timeoutTimer
,
&
QTimer
::
timeout
,
this
->
_setState
(
STATE
::
HEARTBEAT_TIMEOUT
);
std
::
bind
(
&
Impl
::
_onHeartbeatTimeout
,
this
));
this
->
_doAction
();
});
// Connection timer (temporary workaround)
// Connection timer (temporary workaround)
connect
(
&
this
->
_connectionTimer
,
&
QTimer
::
timeout
,
[
this
]
{
connect
(
&
this
->
_connectionTimer
,
&
QTimer
::
timeout
,
[
this
]
{
...
@@ -226,7 +231,7 @@ NemoInterface::Impl::Impl(NemoInterface *p)
...
@@ -226,7 +231,7 @@ NemoInterface::Impl::Impl(NemoInterface *p)
[
this
]
{
this
->
_onFutureWatcherFinished
();
});
[
this
]
{
this
->
_onFutureWatcherFinished
();
});
}
}
NemoInterface
::
Impl
::~
Impl
()
{}
NemoInterface
::
Impl
::~
Impl
()
{
this
->
_pRosBridge
->
reset
();
}
void
NemoInterface
::
Impl
::
start
()
{
void
NemoInterface
::
Impl
::
start
()
{
if
(
!
running
())
{
if
(
!
running
())
{
...
@@ -246,6 +251,8 @@ std::shared_future<QVariant>
...
@@ -246,6 +251,8 @@ std::shared_future<QVariant>
NemoInterface
::
Impl
::
addTiles
(
const
TilePtrArray
&
tileArray
)
{
NemoInterface
::
Impl
::
addTiles
(
const
TilePtrArray
&
tileArray
)
{
using
namespace
nemo_interface
;
using
namespace
nemo_interface
;
qDebug
()
<<
"addTiles called"
;
if
(
tileArray
.
size
()
>
0
)
{
if
(
tileArray
.
size
()
>
0
)
{
// copy unknown tiles
// copy unknown tiles
...
@@ -266,6 +273,9 @@ NemoInterface::Impl::addTiles(const TilePtrArray &tileArray) {
...
@@ -266,6 +273,9 @@ NemoInterface::Impl::addTiles(const TilePtrArray &tileArray) {
<<
"addTiles(): tile with id: "
<<
pTile
->
id
()
<<
"already added."
;
<<
"addTiles(): tile with id: "
<<
pTile
->
id
()
<<
"already added."
;
}
}
}
}
if
(
pTileArray
->
size
()
>
0
)
{
this
->
_parent
->
tilesChanged
();
}
// ready for send?
// ready for send?
if
(
pTileArray
->
size
()
>
0
&&
(
this
->
ready
()
||
this
->
_userSync
()))
{
if
(
pTileArray
->
size
()
>
0
&&
(
this
->
ready
()
||
this
->
_userSync
()))
{
...
@@ -308,6 +318,8 @@ std::shared_future<QVariant>
...
@@ -308,6 +318,8 @@ std::shared_future<QVariant>
NemoInterface
::
Impl
::
removeTiles
(
const
IDArray
&
idArray
)
{
NemoInterface
::
Impl
::
removeTiles
(
const
IDArray
&
idArray
)
{
using
namespace
nemo_interface
;
using
namespace
nemo_interface
;
qDebug
()
<<
"removeTiles called"
;
if
(
idArray
.
size
()
>
0
)
{
if
(
idArray
.
size
()
>
0
)
{
// copy known ids
// copy known ids
...
@@ -322,6 +334,9 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) {
...
@@ -322,6 +334,9 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) {
qCDebug
(
NemoInterfaceLog
)
<<
"removeTiles(): unknown id: "
<<
id
<<
"."
;
qCDebug
(
NemoInterfaceLog
)
<<
"removeTiles(): unknown id: "
<<
id
<<
"."
;
}
}
}
}
if
(
pIdArray
->
size
()
>
0
)
{
this
->
_parent
->
tilesChanged
();
}
// ready for send?
// ready for send?
if
(
pIdArray
->
size
()
>
0
&&
(
this
->
ready
()
||
this
->
_userSync
()))
{
if
(
pIdArray
->
size
()
>
0
&&
(
this
->
ready
()
||
this
->
_userSync
()))
{
...
@@ -349,10 +364,15 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) {
...
@@ -349,10 +364,15 @@ NemoInterface::Impl::removeTiles(const IDArray &idArray) {
std
::
shared_future
<
QVariant
>
NemoInterface
::
Impl
::
clearTiles
()
{
std
::
shared_future
<
QVariant
>
NemoInterface
::
Impl
::
clearTiles
()
{
using
namespace
nemo_interface
;
using
namespace
nemo_interface
;
qDebug
()
<<
"clearTiles called"
;
// clear local tiles (_localTiles)
// 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
->
_setState
(
STATE
::
USER_SYNC
);
this
->
_doAction
();
this
->
_doAction
();
...
@@ -373,7 +393,7 @@ std::shared_future<QVariant> NemoInterface::Impl::clearTiles() {
...
@@ -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
;
TileArray
tileArray
;
for
(
const
auto
&
id
:
idArray
)
{
for
(
const
auto
&
id
:
idArray
)
{
...
@@ -390,7 +410,7 @@ TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) {
...
@@ -390,7 +410,7 @@ TileArray NemoInterface::Impl::getTiles(const IDArray &idArray) {
return
tileArray
;
return
tileArray
;
}
}
TileArray
NemoInterface
::
Impl
::
getAllTiles
()
{
TileArray
NemoInterface
::
Impl
::
getAllTiles
()
const
{
TileArray
tileArray
;
TileArray
tileArray
;
for
(
const
auto
&
entry
:
_localTiles
)
{
for
(
const
auto
&
entry
:
_localTiles
)
{
...
@@ -405,7 +425,7 @@ TileArray NemoInterface::Impl::getAllTiles() {
...
@@ -405,7 +425,7 @@ TileArray NemoInterface::Impl::getAllTiles() {
return
tileArray
;
return
tileArray
;
}
}
LogicalArray
NemoInterface
::
Impl
::
containsTiles
(
const
IDArray
&
idArray
)
{
LogicalArray
NemoInterface
::
Impl
::
containsTiles
(
const
IDArray
&
idArray
)
const
{
LogicalArray
logicalArray
;
LogicalArray
logicalArray
;
for
(
const
auto
&
id
:
idArray
)
{
for
(
const
auto
&
id
:
idArray
)
{
...
@@ -416,11 +436,11 @@ LogicalArray NemoInterface::Impl::containsTiles(const IDArray &idArray) {
...
@@ -416,11 +436,11 @@ LogicalArray NemoInterface::Impl::containsTiles(const IDArray &idArray) {
return
logicalArray
;
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
;
ProgressArray
progressArray
;
if
(
this
->
_isSynchronized
())
{
if
(
this
->
_isSynchronized
())
{
...
@@ -438,7 +458,7 @@ ProgressArray NemoInterface::Impl::getProgress() {
...
@@ -438,7 +458,7 @@ ProgressArray NemoInterface::Impl::getProgress() {
return
progressArray
;
return
progressArray
;
}
}
ProgressArray
NemoInterface
::
Impl
::
getProgress
(
const
IDArray
&
idArray
)
{
ProgressArray
NemoInterface
::
Impl
::
getProgress
(
const
IDArray
&
idArray
)
const
{
ProgressArray
progressArray
;
ProgressArray
progressArray
;
if
(
this
->
_isSynchronized
())
{
if
(
this
->
_isSynchronized
())
{
...
@@ -462,33 +482,45 @@ ProgressArray NemoInterface::Impl::getProgress(const IDArray &idArray) {
...
@@ -462,33 +482,45 @@ ProgressArray NemoInterface::Impl::getProgress(const IDArray &idArray) {
return
progressArray
;
return
progressArray
;
}
}
NemoInterface
::
STATUS
NemoInterface
::
Impl
::
status
()
{
NemoInterface
::
STATUS
NemoInterface
::
Impl
::
status
()
const
{
return
_status
(
this
->
_state
);
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
()
{
void
NemoInterface
::
Impl
::
_onFutureWatcherFinished
()
{
if
(
this
->
_userSync
()
||
this
->
_sysSync
())
{
if
(
this
->
ready
()
||
this
->
_userSync
()
||
this
->
_sysSync
())
{
auto
lastTransactionSuccessfull
=
_futureWatcher
.
result
().
toBool
();
auto
lastTransactionSuccessfull
=
_futureWatcher
.
result
().
toBool
();
if
(
!
lastTransactionSuccessfull
)
{
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
(
void
NemoInterface
::
Impl
::
_updateProgress
(
std
::
shared_ptr
<
ProgressArray
>
pArray
,
std
::
shared_ptr
<
ProgressArray
>
pArray
)
{
std
::
promise
<
bool
>
promise
)
{
qDebug
()
<<
"_updateProgress called"
;
bool
error
=
false
;
for
(
auto
itLP
=
pArray
->
begin
();
itLP
!=
pArray
->
end
();)
{
for
(
auto
itLP
=
pArray
->
begin
();
itLP
!=
pArray
->
end
();)
{
auto
it
=
_remoteTiles
.
find
(
itLP
->
id
());
auto
it
=
_remoteTiles
.
find
(
itLP
->
id
());
...
@@ -500,15 +532,19 @@ void NemoInterface::Impl::_updateProgress(
...
@@ -500,15 +532,19 @@ void NemoInterface::Impl::_updateProgress(
qCDebug
(
NemoInterfaceLog
)
qCDebug
(
NemoInterfaceLog
)
<<
"_updateProgress(): tile with id "
<<
itLP
->
id
()
<<
" not found."
;
<<
"_updateProgress(): tile with id "
<<
itLP
->
id
()
<<
" not found."
;
itLP
=
pArray
->
erase
(
itLP
);
itLP
=
pArray
->
erase
(
itLP
);
error
=
true
;
}
}
}
}
if
(
pArray
->
size
()
>
0
)
{
if
(
pArray
->
size
()
>
0
)
{
emit
_parent
->
progressChanged
(
*
pArray
);
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
;
_lastHeartbeat
=
hb
;
this
->
_timeoutTimer
.
start
(
NO_HEARTBEAT_TIMEOUT
);
this
->
_timeoutTimer
.
start
(
NO_HEARTBEAT_TIMEOUT
);
if
(
this
->
_state
==
STATE
::
TRY_TOPIC_SERVICE_SETUP
)
{
if
(
this
->
_state
==
STATE
::
TRY_TOPIC_SERVICE_SETUP
)
{
...
@@ -518,6 +554,7 @@ void NemoInterface::Impl::_onHeartbeatReceived(const QNemoHeartbeat &hb) {
...
@@ -518,6 +554,7 @@ void NemoInterface::Impl::_onHeartbeatReceived(const QNemoHeartbeat &hb) {
this
->
_setState
(
STATE
::
READY
);
this
->
_setState
(
STATE
::
READY
);
this
->
_doAction
();
this
->
_doAction
();
}
}
promise
.
set_value
(
true
);
}
}
void
NemoInterface
::
Impl
::
_setInfoString
(
const
QString
&
info
)
{
void
NemoInterface
::
Impl
::
_setInfoString
(
const
QString
&
info
)
{
...
@@ -577,9 +614,15 @@ void NemoInterface::Impl::_doTopicServiceSetup() {
...
@@ -577,9 +614,15 @@ void NemoInterface::Impl::_doTopicServiceSetup() {
auto
p
=
std
::
make_shared
<
ProgressArray
>
();
auto
p
=
std
::
make_shared
<
ProgressArray
>
();
*
p
=
std
::
move
(
progressArray
.
progress_array
());
*
p
=
std
::
move
(
progressArray
.
progress_array
());
QMetaObject
::
invokeMethod
(
std
::
promise
<
bool
>
promise
;
auto
future
=
promise
.
get_future
();
bool
value
=
QMetaObject
::
invokeMethod
(
this
->
_parent
,
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
{
}
else
{
qCWarning
(
NemoInterfaceLog
)
<<
"/nemo/progress not able to "
qCWarning
(
NemoInterfaceLog
)
<<
"/nemo/progress not able to "
"create ProgressArray form json: "
"create ProgressArray form json: "
...
@@ -614,10 +657,15 @@ void NemoInterface::Impl::_doTopicServiceSetup() {
...
@@ -614,10 +657,15 @@ void NemoInterface::Impl::_doTopicServiceSetup() {
// create obj from json
// create obj from json
nemo_msgs
::
heartbeat
::
Heartbeat
heartbeat
;
nemo_msgs
::
heartbeat
::
Heartbeat
heartbeat
;
if
(
nemo_msgs
::
heartbeat
::
fromJson
(
d
[
"msg"
],
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
,
this
->
_parent
,
std
::
bind
(
&
NemoInterface
::
Impl
::
_onHeartbeatReceived
,
this
,
[
this
,
heartbeat
,
promise
=
std
::
move
(
promise
)]()
mutable
{
heartbeat
));
this
->
_onHeartbeatReceived
(
heartbeat
,
std
::
move
(
promise
));
});
Q_ASSERT
(
value
==
true
);
future
.
wait
();
}
else
{
}
else
{
qCWarning
(
NemoInterfaceLog
)
<<
"/nemo/heartbeat not able to "
qCWarning
(
NemoInterfaceLog
)
<<
"/nemo/heartbeat not able to "
"create Heartbeat form json: "
"create Heartbeat form json: "
...
@@ -640,6 +688,9 @@ void NemoInterface::Impl::_trySynchronize() {
...
@@ -640,6 +688,9 @@ void NemoInterface::Impl::_trySynchronize() {
if
((
this
->
_state
==
STATE
::
READY
||
this
->
_state
==
STATE
::
SYS_SYNC
||
if
((
this
->
_state
==
STATE
::
READY
||
this
->
_state
==
STATE
::
SYS_SYNC
||
this
->
_state
==
STATE
::
USER_SYNC
)
&&
this
->
_state
==
STATE
::
USER_SYNC
)
&&
!
_isSynchronized
())
{
!
_isSynchronized
())
{
qCWarning
(
NemoInterfaceLog
)
<<
"trying to synchronize"
;
this
->
_setState
(
STATE
::
SYS_SYNC
);
this
->
_setState
(
STATE
::
SYS_SYNC
);
this
->
_doAction
();
this
->
_doAction
();
...
@@ -691,7 +742,7 @@ void NemoInterface::Impl::_trySynchronize() {
...
@@ -691,7 +742,7 @@ void NemoInterface::Impl::_trySynchronize() {
}
}
}
}
bool
NemoInterface
::
Impl
::
_isSynchronized
()
{
bool
NemoInterface
::
Impl
::
_isSynchronized
()
const
{
return
_localTiles
.
size
()
>
0
&&
_remoteTiles
.
size
()
>
0
&&
return
_localTiles
.
size
()
>
0
&&
_remoteTiles
.
size
()
>
0
&&
std
::
equal
(
std
::
equal
(
_localTiles
.
begin
(),
_localTiles
.
end
(),
_remoteTiles
.
begin
(),
_localTiles
.
begin
(),
_localTiles
.
end
(),
_remoteTiles
.
begin
(),
...
@@ -704,7 +755,7 @@ void NemoInterface::Impl::_doAction() {
...
@@ -704,7 +755,7 @@ void NemoInterface::Impl::_doAction() {
case
STATE
:
:
STOPPED
:
case
STATE
:
:
STOPPED
:
this
->
_connectionTimer
.
stop
();
this
->
_connectionTimer
.
stop
();
this
->
_timeoutTimer
.
stop
();
this
->
_timeoutTimer
.
stop
();
this
->
_clearTilesRemote
();
this
->
_clearTilesRemote
(
std
::
promise
<
bool
>
()
);
if
(
this
->
_pRosBridge
->
running
())
{
if
(
this
->
_pRosBridge
->
running
())
{
this
->
_pRosBridge
->
reset
();
this
->
_pRosBridge
->
reset
();
}
}
...
@@ -731,7 +782,7 @@ void NemoInterface::Impl::_doAction() {
...
@@ -731,7 +782,7 @@ void NemoInterface::Impl::_doAction() {
case
STATE
:
:
SYS_SYNC
:
case
STATE
:
:
SYS_SYNC
:
break
;
break
;
case
STATE
:
:
HEARTBEAT_TIMEOUT
:
case
STATE
:
:
HEARTBEAT_TIMEOUT
:
this
->
_clearTilesRemote
();
this
->
_clearTilesRemote
(
std
::
promise
<
bool
>
()
);
break
;
break
;
case
STATE
:
:
WEBSOCKET_TIMEOUT
:
case
STATE
:
:
WEBSOCKET_TIMEOUT
:
if
(
!
resetDone
)
{
if
(
!
resetDone
)
{
...
@@ -739,7 +790,8 @@ void NemoInterface::Impl::_doAction() {
...
@@ -739,7 +790,8 @@ void NemoInterface::Impl::_doAction() {
this
->
_pRosBridge
->
reset
();
this
->
_pRosBridge
->
reset
();
this
->
_pRosBridge
->
run
();
this
->
_pRosBridge
->
run
();
}
}
this
->
_clearTilesRemote
();
this
->
_timeoutTimer
.
stop
();
this
->
_clearTilesRemote
(
std
::
promise
<
bool
>
());
break
;
break
;
};
};
}
}
...
@@ -747,6 +799,8 @@ void NemoInterface::Impl::_doAction() {
...
@@ -747,6 +799,8 @@ void NemoInterface::Impl::_doAction() {
QVariant
NemoInterface
::
Impl
::
_callAddTiles
(
QVariant
NemoInterface
::
Impl
::
_callAddTiles
(
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
const
Tile
>>>
pTileArray
)
{
std
::
shared_ptr
<
QVector
<
std
::
shared_ptr
<
const
Tile
>>>
pTileArray
)
{
qDebug
()
<<
"_callAddTiles called"
;
this
->
_lastCall
=
CALL_NAME
::
ADD_TILES
;
this
->
_lastCall
=
CALL_NAME
::
ADD_TILES
;
// create json object
// create json object
...
@@ -831,16 +885,22 @@ QVariant NemoInterface::Impl::_callAddTiles(
...
@@ -831,16 +885,22 @@ QVariant NemoInterface::Impl::_callAddTiles(
}
}
// add remote tiles (_remoteTiles)
// add remote tiles (_remoteTiles)
QMetaObject
::
invokeMethod
(
this
->
_parent
/* context */
,
[
this
,
pTileArray
]
{
std
::
promise
<
bool
>
promise
;
this
->
_addTilesRemote
(
pTileArray
);
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 success
return
QVariant
(
true
);
return
QVariant
(
future
.
get
()
);
}
}
QVariant
QVariant
NemoInterface
::
Impl
::
_callRemoveTiles
(
std
::
shared_ptr
<
IDArray
>
pIdArray
)
{
NemoInterface
::
Impl
::
_callRemoveTiles
(
std
::
shared_ptr
<
IDArray
>
pIdArray
)
{
qDebug
()
<<
"_callRemoveTiles called"
;
this
->
_lastCall
=
CALL_NAME
::
REMOVE_TILES
;
this
->
_lastCall
=
CALL_NAME
::
REMOVE_TILES
;
...
@@ -920,16 +980,22 @@ NemoInterface::Impl::_callRemoveTiles(std::shared_ptr<IDArray> pIdArray) {
...
@@ -920,16 +980,22 @@ NemoInterface::Impl::_callRemoveTiles(std::shared_ptr<IDArray> pIdArray) {
}
}
// remove remote tiles (_remoteTiles)
// remove remote tiles (_remoteTiles)
QMetaObject
::
invokeMethod
(
this
->
_parent
/* context */
,
[
this
,
pIdArray
]
{
std
::
promise
<
bool
>
promise
;