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
Compare Revisions
master...dev1
Source
dev1
Select Git revision
...
Target
master
Select Git revision
Compare
Commits (2)
temp
· a4d09405
Valentin Platzgummer
authored
Jan 31, 2021
a4d09405
MeasurementArea.cc better randmomId
· cc4588e6
Valentin Platzgummer
authored
Jan 31, 2021
cc4588e6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
343 additions
and
221 deletions
+343
-221
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
MeasurementArea.cc
src/MeasurementComplexItem/geometry/MeasurementArea.cc
+19
-8
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 @
cc4588e6
...
...
@@ -41,6 +41,7 @@ const char *variantNamesKey = "VariantNames";
const
char
*
generatorArrayKey
=
"GeneratorArray"
;
const
char
*
variantArrayKey
=
"VariantArray"
;
const
char
*
generatorIndexKey
=
"GeneratorIndex"
;
const
char
*
connectionsStringKey
=
"ConnectionString"
;
}
// namespace
MeasurementComplexItem
::
MeasurementComplexItem
(
...
...
@@ -55,7 +56,8 @@ MeasurementComplexItem::MeasurementComplexItem(
_variantIndex
(
settingsGroup
,
_metaDataMap
[
variantIndexKey
]),
_pAreaData
(
new
AreaData
(
this
)),
_pEditorData
(
new
AreaData
(
this
)),
_pCurrentData
(
_pAreaData
),
_holdProgress
(
false
),
_pGenerator
(
nullptr
),
_pWorker
(
new
RoutingThread
(
this
))
{
_pWorker
(
new
RoutingThread
(
this
)),
_nemoCString
(
settingsGroup
,
_metaDataMap
[
connectionsStringKey
])
{
// Setup altitude.
_altitude
.
setRawValue
(
qgcApp
()
...
...
@@ -91,17 +93,17 @@ MeasurementComplexItem::MeasurementComplexItem(
&
MeasurementComplexItem
::
_storeRoutingData
);
// Connect coordinate and exitCoordinate.
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
this
,
[
this
]
{
emit
this
->
coordinateChanged
(
this
->
coordinate
());
});
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
this
,
[
this
]
{
emit
this
->
exitCoordinateChanged
(
this
->
exitCoordinate
());
});
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
[
this
]
{
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
this
,
[
this
]
{
emit
this
->
exitCoordinateSameAsEntryChanged
(
this
->
exitCoordinateSameAsEntry
());
});
// Connect isIncomplete.
connect
(
this
,
&
MeasurementComplexItem
::
idleChanged
,
[
this
]
{
connect
(
this
,
&
MeasurementComplexItem
::
idleChanged
,
this
,
[
this
]
{
if
(
this
->
idle
())
{
if
(
this
->
route
().
size
()
>
0
&&
this
->
_isIncomplete
==
true
)
{
this
->
_isIncomplete
=
false
;
...
...
@@ -124,14 +126,14 @@ MeasurementComplexItem::MeasurementComplexItem(
&
MeasurementComplexItem
::
_updateFlightpathSegments
);
// Connect complexDistance.
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
connect
(
this
,
&
MeasurementComplexItem
::
routeChanged
,
this
,
[
this
]
{
emit
this
->
complexDistanceChanged
();
});
resetGenerators
();
startEditing
();
// connect to nemo interface
connect
(
pNemoInterface
,
&
Nemo
I
nterface
::
progressChanged
,
this
,
connect
(
pNemoInterface
,
&
Nemo
i
nterface
::
progressChanged
,
this
,
&
MeasurementComplexItem
::
_onNewProgress
);
}
...
...
@@ -773,6 +775,17 @@ void MeasurementComplexItem::_onAltitudeChanged() {
}
}
QString
MeasurementComplexItem
::
nemoError
()
const
{
return
_nemoError
;
}
void
MeasurementComplexItem
::
_setNemoError
(
const
QString
&
nemoError
)
{
if
(
_nemoError
!=
nemoError
)
{
_nemoError
=
nemoError
;
emit
nemoErrorChanged
();
}
}
Fact
*
MeasurementComplexItem
::
nemoCString
()
{
return
&
_nemoCString
;
}
bool
MeasurementComplexItem
::
holdProgress
()
const
{
return
_holdProgress
;
}
void
MeasurementComplexItem
::
setHoldProgress
(
bool
holdProgress
)
{
...
...
@@ -781,10 +794,10 @@ void MeasurementComplexItem::setHoldProgress(bool holdProgress) {
emit
holdProgressChanged
();
if
(
_holdProgress
)
{
disconnect
(
pNemoInterface
,
&
Nemo
I
nterface
::
progressChanged
,
this
,
disconnect
(
pNemoInterface
,
&
Nemo
i
nterface
::
progressChanged
,
this
,
&
MeasurementComplexItem
::
_onNewProgress
);
}
else
{
connect
(
pNemoInterface
,
&
Nemo
I
nterface
::
progressChanged
,
this
,
connect
(
pNemoInterface
,
&
Nemo
i
nterface
::
progressChanged
,
this
,
&
MeasurementComplexItem
::
_onNewProgress
);
_onNewProgress
(
pNemoInterface
->
getProgress
());
}
...
...
src/MeasurementComplexItem/MeasurementComplexItem.h
View file @
cc4588e6
...
...
@@ -14,6 +14,7 @@
class
RoutingThread
;
class
RoutingResult
;
class
Nemointerface
;
namespace
routing
{
class
GeneratorBase
;
...
...
@@ -51,6 +52,8 @@ public:
Q_PROPERTY
(
int
generatorIndex
READ
generatorIndex
NOTIFY
generatorChanged
)
Q_PROPERTY
(
AreaData
*
areaData
READ
areaData
NOTIFY
areaDataChanged
)
Q_PROPERTY
(
QVariantList
route
READ
route
NOTIFY
routeChanged
)
Q_PROPERTY
(
QString
nemoError
READ
nemoError
NOTIFY
nemoErrorChanged
)
Q_PROPERTY
(
Fact
*
nemoCString
READ
nemoCString
CONSTANT
)
Q_INVOKABLE
void
reverseRoute
(
void
);
...
...
@@ -224,6 +227,10 @@ public:
bool
holdProgress
()
const
;
void
setHoldProgress
(
bool
holdProgress
);
QString
nemoError
()
const
;
Fact
*
nemoCString
();
signals:
void
variantNamesChanged
();
...
...
@@ -238,6 +245,8 @@ signals:
void
routeChanged
();
void
holdProgressChanged
();
void
nemoErrorChanged
();
private
slots
:
// Worker functions.
...
...
@@ -257,6 +266,7 @@ private:
static
bool
_idle
(
STATE
state
);
void
_updateFlightpathSegments
();
void
_onAltitudeChanged
();
void
_setNemoError
(
const
QString
&
nemoError
);
// Hirarcical stuff.
int
_sequenceNumber
;
...
...
@@ -285,4 +295,9 @@ private:
QVector
<
Variant
>
_variantVector
;
Variant
_route
;
PtrWorker
_pWorker
;
// NemoInterface
std
::
shared_ptr
<
Nemointerface
>
_pNemointerface
;
QString
_nemoError
;
SettingsFact
_nemoCString
;
};
src/MeasurementComplexItem/NemoInterface.cpp
View file @
cc4588e6
This diff is collapsed.
Click to expand it.
src/MeasurementComplexItem/NemoInterface.h
View file @
cc4588e6
...
...
@@ -13,20 +13,20 @@
#include "TilePtrArray.h"
#include "geometry/ProgressArray.h"
// Singelton class used to interface measurement devices implementing the nemo
// interface.
class
Nemo
I
nterface
:
public
QObject
{
class
NemointerfaceFactory
;
class
Nemo
i
nterface
:
public
QObject
{
Q_OBJECT
class
Impl
;
using
PImpl
=
std
::
unique_ptr
<
Impl
>
;
NemoInterface
();
NemoInterface
(
NemoInterface
&
other
)
=
delete
;
static
NemoInterface
*
createInstance
();
Nemointerface
(
const
QString
&
connectionString
);
Nemointerface
(
Nemointerface
&
other
)
=
delete
;
friend
class
NemointerfaceFactory
;
public:
~
NemoInterface
()
override
;
static
NemoInterface
*
instance
();
~
Nemointerface
()
override
;
enum
class
STATUS
{
NOT_CONNECTED
,
...
...
@@ -90,6 +90,7 @@ public:
QString
infoString
()
const
;
QString
warningString
()
const
;
bool
running
()
const
;
QString
connectionString
();
signals:
void
statusChanged
();
...
...
@@ -103,4 +104,25 @@ private:
PImpl
pImpl
;
};
#define pNemoInterface NemoInterface::instance()
// Singelton class used for nemo interface creation.
class
NemointerfaceFactory
{
NemointerfaceFactory
();
NemointerfaceFactory
(
const
NemointerfaceFactory
&
other
)
=
delete
;
static
NemointerfaceFactory
*
createInstance
();
public:
~
NemointerfaceFactory
();
static
NemointerfaceFactory
*
instance
();
// Creates a interface with a connection string connectionString.
// Two different interfaces can't share the same connection string.
std
::
shared_ptr
<
Nemointerface
>
create
(
const
QString
&
connectionString
);
// Returns true if an interface with connection string connectionString can
// be created (i.e. doesn't exist yet), returns false either.
bool
isCreatable
(
const
QString
&
connectionString
);
private:
std
::
map
<
QString
,
std
::
weak_ptr
<
Nemointerface
>>
_map
;
};
#define pNemoInterfaceFactory NemointerfaceFactory::instance()
src/MeasurementComplexItem/geometry/MeasurementArea.cc
View file @
cc4588e6
...
...
@@ -19,7 +19,7 @@
#define MAX_TILES 1000
#endif
QString
randomId
();
QString
randomId
(
std
::
size_t
length
=
10
);
using
namespace
geometry
;
namespace
trans
=
bg
::
strategy
::
transform
;
...
...
@@ -726,13 +726,24 @@ bool getTiles(const FPolygon &area, Length tileHeight, Length tileWidth,
return
true
;
}
QString
randomId
()
{
std
::
srand
(
std
::
time
(
nullptr
));
std
::
int64_t
r
=
0
;
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
r
^=
std
::
rand
();
QString
randomId
(
std
::
size_t
length
)
{
static
const
QString
values
(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
);
static
std
::
uint64_t
counter
=
0
;
static
auto
firstCall
=
std
::
chrono
::
high_resolution_clock
::
now
();
auto
delta
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
nanoseconds
>
(
std
::
chrono
::
high_resolution_clock
::
now
()
-
firstCall
)
.
count
();
std
::
srand
((
unsigned
int
)
delta
^
counter
);
QString
str
;
for
(
int
i
=
0
;
i
<
length
;
++
i
)
{
int
index
=
std
::
rand
()
%
values
.
length
();
QChar
c
=
values
.
at
(
index
);
str
.
append
(
c
);
}
return
QString
::
number
(
r
);
++
counter
;
return
str
;
}
src/MeasurementComplexItem/json/MeasurementComplexItem.SettingsGroup.json
View file @
cc4588e6
...
...
@@ -17,6 +17,13 @@
"min"
:
1
,
"decimalPlaces"
:
1
,
"default"
:
10.0
},
{
"name"
:
"ConnectionString"
,
"shrotDesc"
:
"Nemo Connection String."
,
"longDesc"
:
"Nemo Connection String (e.g. host_ip:port)."
,
"type"
:
"string"
,
"default"
:
"localhost:9090"
}
]
}
src/QGCApplication.cc
View file @
cc4588e6
...
...
@@ -672,7 +672,7 @@ void QGCApplication::_initCommon() {
qmlRegisterUncreatableType
<
routing
::
LinearGenerator
>
(
"MeasurementComplexItem"
,
1
,
0
,
"LinearGenerator"
,
kRefOnly
);
qmlRegisterType
<
AreaData
>
(
"MeasurementComplexItem"
,
1
,
0
,
"AreaData"
);
qmlRegisterSingletonType
<
Nemo
I
nterface
>
(
"MeasurementComplexItem"
,
1
,
0
,
qmlRegisterSingletonType
<
Nemo
i
nterface
>
(
"MeasurementComplexItem"
,
1
,
0
,
"NemoInterface"
,
getNemoInterface
);
qmlRegisterInterface
<
routing
::
GeneratorBase
>
(
"GeneratorBase"
);
qmlRegisterUncreatableType
<
routing
::
CircularGenerator
>
(
...
...