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
bc10a8d2
Commit
bc10a8d2
authored
Jul 19, 2018
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Connection management
parent
1c29e15e
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
146 additions
and
46 deletions
+146
-46
AirMapManager.cc
src/Airmap/AirMapManager.cc
+48
-16
AirMapManager.h
src/Airmap/AirMapManager.h
+3
-0
AirmapSettings.qml
src/Airmap/AirmapSettings.qml
+66
-20
AirspaceControl.qml
src/Airmap/AirspaceControl.qml
+15
-7
AirspaceManager.h
src/AirspaceManagement/AirspaceManager.h
+6
-0
FlightDisplayViewMap.qml
src/FlightDisplay/FlightDisplayViewMap.qml
+5
-1
Drivers
src/GPS/Drivers
+1
-1
PlanView.qml
src/PlanView/PlanView.qml
+2
-1
No files found.
src/Airmap/AirMapManager.cc
View file @
bc10a8d2
...
...
@@ -42,9 +42,9 @@ AirMapManager::AirMapManager(QGCApplication* app, QGCToolbox* toolbox)
{
_logger
=
std
::
make_shared
<
qt
::
Logger
>
();
qt
::
register_types
();
// TODO: still needed?
_logger
->
logging_category
().
setEnabled
(
QtDebugMsg
,
fals
e
);
_logger
->
logging_category
().
setEnabled
(
QtInfoMsg
,
fals
e
);
_logger
->
logging_category
().
setEnabled
(
QtWarningMsg
,
fals
e
);
_logger
->
logging_category
().
setEnabled
(
QtDebugMsg
,
tru
e
);
_logger
->
logging_category
().
setEnabled
(
QtInfoMsg
,
tru
e
);
_logger
->
logging_category
().
setEnabled
(
QtWarningMsg
,
tru
e
);
_dispatchingLogger
=
std
::
make_shared
<
qt
::
DispatchingLogger
>
(
_logger
);
connect
(
&
_shared
,
&
AirMapSharedState
::
error
,
this
,
&
AirMapManager
::
_error
);
}
...
...
@@ -63,6 +63,7 @@ AirMapManager::setToolbox(QGCToolbox* toolbox)
{
AirspaceManager
::
setToolbox
(
toolbox
);
AirMapSettings
*
ap
=
toolbox
->
settingsManager
()
->
airMapSettings
();
connect
(
ap
->
enableAirMap
(),
&
Fact
::
rawValueChanged
,
this
,
&
AirMapManager
::
_settingsChanged
);
connect
(
ap
->
usePersonalApiKey
(),
&
Fact
::
rawValueChanged
,
this
,
&
AirMapManager
::
_settingsChanged
);
connect
(
ap
->
apiKey
(),
&
Fact
::
rawValueChanged
,
this
,
&
AirMapManager
::
_settingsChanged
);
connect
(
ap
->
clientID
(),
&
Fact
::
rawValueChanged
,
this
,
&
AirMapManager
::
_settingsChanged
);
...
...
@@ -71,6 +72,13 @@ AirMapManager::setToolbox(QGCToolbox* toolbox)
_settingsChanged
();
}
//-----------------------------------------------------------------------------
bool
AirMapManager
::
connected
()
const
{
return
_shared
.
client
()
!=
NULL
;
}
//-----------------------------------------------------------------------------
void
AirMapManager
::
_error
(
const
QString
&
what
,
const
QString
&
airmapdMessage
,
const
QString
&
airmapdDetails
)
...
...
@@ -84,29 +92,41 @@ void
AirMapManager
::
_settingsChanged
()
{
qCDebug
(
AirMapManagerLog
)
<<
"AirMap settings changed"
;
_connectStatus
.
clear
();
emit
connectStatusChanged
();
AirMapSettings
*
ap
=
_toolbox
->
settingsManager
()
->
airMapSettings
();
//-- If we are disabled, there is nothing else to do.
if
(
!
ap
->
enableAirMap
()
->
rawValue
().
toBool
())
{
if
(
_shared
.
client
())
{
delete
_shared
.
client
();
_shared
.
setClient
(
nullptr
);
emit
connectedChanged
();
}
return
;
}
AirMapSharedState
::
Settings
settings
;
settings
.
apiKey
=
ap
->
apiKey
()
->
rawValueString
();
#if defined(QGC_AIRMAP_KEY_AVAILABLE)
bool
apiKeyChanged
=
settings
.
apiKey
!=
_shared
.
settings
().
apiKey
||
settings
.
apiKey
.
isEmpty
();
#else
bool
apiKeyChanged
=
settings
.
apiKey
!=
_shared
.
settings
().
apiKey
;
#endif
settings
.
clientID
=
ap
->
clientID
()
->
rawValueString
();
if
(
ap
->
usePersonalApiKey
()
->
rawValue
().
toBool
())
{
settings
.
apiKey
=
ap
->
apiKey
()
->
rawValueString
();
settings
.
clientID
=
ap
->
clientID
()
->
rawValueString
();
}
settings
.
userName
=
ap
->
userName
()
->
rawValueString
();
settings
.
password
=
ap
->
password
()
->
rawValueString
();
//-- If we have a hardwired key (and no custom key is present
or enabled
), set it.
//-- If we have a hardwired key (and no custom key is present), set it.
#if defined(QGC_AIRMAP_KEY_AVAILABLE)
if
(
!
ap
->
usePersonalApiKey
()
->
rawValue
().
toBool
()
&&
(
settings
.
apiKey
.
isEmpty
()
||
settings
.
clientID
.
isEmpty
())
)
{
if
(
!
ap
->
usePersonalApiKey
()
->
rawValue
().
toBool
())
{
settings
.
apiKey
=
kAirmapAPIKey
;
settings
.
clientID
=
kAirmapClientID
;
}
bool
apiKeyChanged
=
settings
.
apiKey
!=
_shared
.
settings
().
apiKey
||
settings
.
apiKey
.
isEmpty
();
#else
bool
apiKeyChanged
=
settings
.
apiKey
!=
_shared
.
settings
().
apiKey
;
#endif
_shared
.
setSettings
(
settings
);
//-- Need to re-create the client if the API key changed
if
(
_shared
.
client
()
&&
apiKeyChanged
)
{
if
(
(
_shared
.
client
()
&&
apiKeyChanged
)
||
!
ap
->
enableAirMap
()
->
rawValue
().
toBool
()
)
{
delete
_shared
.
client
();
_shared
.
setClient
(
nullptr
);
emit
connectedChanged
();
}
if
(
!
_shared
.
client
()
&&
settings
.
apiKey
!=
""
)
{
qCDebug
(
AirMapManagerLog
)
<<
"Creating AirMap client"
;
...
...
@@ -119,16 +139,28 @@ AirMapManager::_settingsChanged()
if
(
result
)
{
qCDebug
(
AirMapManagerLog
)
<<
"Successfully created airmap::qt::Client instance"
;
_shared
.
setClient
(
result
.
value
());
emit
connectedChanged
();
_connectStatus
=
tr
(
"AirMap Enabled"
);
emit
connectStatusChanged
();
}
else
{
qWarning
(
"Failed to create airmap::qt::Client instance"
);
QString
description
=
QString
::
fromStdString
(
result
.
error
().
description
()
?
result
.
error
().
description
().
get
()
:
""
);
_error
(
"Failed to create airmap::qt::Client instance"
,
QString
::
fromStdString
(
result
.
error
().
message
()),
description
);
QString
error
=
QString
::
fromStdString
(
result
.
error
().
message
());
_error
(
tr
(
"Failed to create airmap::qt::Client instance"
),
error
,
description
);
_connectStatus
=
error
;
if
(
!
description
.
isEmpty
())
{
_connectStatus
+=
"
\n
"
;
_connectStatus
+=
description
;
}
emit
connectStatusChanged
();
}
});
}
else
{
if
(
settings
.
apiKey
==
""
)
{
qCDebug
(
AirMapManagerLog
)
<<
"No API key for AirMap"
;
_connectStatus
=
tr
(
"No API key for AirMap"
);
emit
connectStatusChanged
();
qCDebug
(
AirMapManagerLog
)
<<
_connectStatus
;
}
}
}
...
...
src/Airmap/AirMapManager.h
View file @
bc10a8d2
...
...
@@ -39,6 +39,8 @@ public:
QString
providerName
()
const
override
{
return
QString
(
"AirMap"
);
}
AirspaceVehicleManager
*
instantiateVehicle
(
const
Vehicle
&
vehicle
)
override
;
bool
connected
()
const
override
;
QString
connectStatus
()
const
override
{
return
_connectStatus
;
}
protected:
AirspaceRulesetsProvider
*
_instantiateRulesetsProvider
()
override
;
...
...
@@ -52,6 +54,7 @@ private slots:
void
_settingsChanged
();
private:
QString
_connectStatus
;
AirMapSharedState
_shared
;
std
::
shared_ptr
<
airmap
::
qt
::
Logger
>
_logger
;
std
::
shared_ptr
<
airmap
::
qt
::
DispatchingLogger
>
_dispatchingLogger
;
...
...
src/Airmap/AirmapSettings.qml
View file @
bc10a8d2
This diff is collapsed.
Click to expand it.
src/Airmap/AirspaceControl.qml
View file @
bc10a8d2
...
...
@@ -24,11 +24,11 @@ Item {
property
bool
planView
:
true
property
color
_airspaceColor
:
_validAdvisories
?
getAispaceColor
(
QGroundControl
.
airspaceManager
.
advisories
.
airspaceColor
)
:
_colorGray
property
bool
_validRules
:
QGroundControl
.
airspaceManager
.
ruleSets
.
valid
property
bool
_validAdvisories
:
QGroundControl
.
airspaceManager
.
advisories
.
valid
property
bool
_validRules
:
QGroundControl
.
airspaceManager
.
connected
&&
QGroundControl
.
airspaceManager
.
ruleSets
.
valid
property
bool
_validAdvisories
:
QGroundControl
.
airspaceManager
.
connected
&&
QGroundControl
.
airspaceManager
.
advisories
.
valid
property
color
_textColor
:
qgcPal
.
text
property
bool
_colapsed
:
!
QGroundControl
.
airspaceManager
.
airspaceVisible
property
var
_flightPermit
:
QGroundControl
.
airspaceManager
.
flightPlan
.
flightPermitStatus
property
bool
_colapsed
:
!
QGroundControl
.
airspaceManager
.
airspaceVisible
||
!
QGroundControl
.
airspaceManager
.
connected
property
int
_flightPermit
:
QGroundControl
.
airspaceManager
.
flightPlan
.
flightPermitStatus
property
bool
_dirty
:
false
readonly
property
real
_radius
:
ScreenTools
.
defaultFontPixelWidth
*
0.5
...
...
@@ -84,7 +84,7 @@ Item {
id
:
colapsedRect
width
:
parent
.
width
height
:
_colapsed
?
colapsedRow
.
height
+
ScreenTools
.
defaultFontPixelHeight
:
0
color
:
_validAdvisories
?
getAispaceColor
(
QGroundControl
.
airspaceManager
.
advisories
.
airspaceColor
)
:
_colorGray
color
:
QGroundControl
.
airspaceManager
.
connected
?
(
_validAdvisories
?
getAispaceColor
(
QGroundControl
.
airspaceManager
.
advisories
.
airspaceColor
)
:
_colorGray
)
:
_colorGray
radius
:
_radius
visible
:
_colapsed
Row
{
...
...
@@ -121,10 +121,16 @@ Item {
}
AirspaceWeather
{
iconHeight
:
ScreenTools
.
defaultFontPixelHeight
*
2
visible
:
QGroundControl
.
airspaceManager
.
weatherInfo
.
valid
visible
:
QGroundControl
.
airspaceManager
.
weatherInfo
.
valid
&&
QGroundControl
.
airspaceManager
.
connected
contentColor
:
_textColor
anchors.verticalCenter
:
parent
.
verticalCenter
}
QGCLabel
{
text
:
qsTr
(
"
Not Connected
"
)
color
:
qgcPal
.
text
visible
:
!
QGroundControl
.
airspaceManager
.
connected
anchors.verticalCenter
:
parent
.
verticalCenter
}
}
QGCColoredImage
{
width
:
height
...
...
@@ -133,12 +139,14 @@ Item {
source
:
"
qrc:/airmap/expand.svg
"
color
:
_textColor
fillMode
:
Image
.
PreserveAspectFit
visible
:
QGroundControl
.
airspaceManager
.
connected
anchors.right
:
parent
.
right
anchors.rightMargin
:
ScreenTools
.
defaultFontPixelWidth
anchors.verticalCenter
:
parent
.
verticalCenter
}
MouseArea
{
anchors.fill
:
parent
anchors.fill
:
parent
enabled
:
QGroundControl
.
airspaceManager
.
connected
onClicked
:
{
QGroundControl
.
airspaceManager
.
airspaceVisible
=
true
}
...
...
src/AirspaceManagement/AirspaceManager.h
View file @
bc10a8d2
...
...
@@ -63,6 +63,8 @@ public:
Q_PROPERTY
(
AirspaceRulesetsProvider
*
ruleSets
READ
ruleSets
CONSTANT
)
Q_PROPERTY
(
AirspaceRestrictionProvider
*
airspaces
READ
airspaces
CONSTANT
)
Q_PROPERTY
(
AirspaceFlightPlanProvider
*
flightPlan
READ
flightPlan
CONSTANT
)
Q_PROPERTY
(
bool
connected
READ
connected
NOTIFY
connectedChanged
)
Q_PROPERTY
(
QString
connectStatus
READ
connectStatus
NOTIFY
connectStatusChanged
)
Q_PROPERTY
(
bool
airspaceVisible
READ
airspaceVisible
WRITE
setAirspaceVisible
NOTIFY
airspaceVisibleChanged
)
Q_INVOKABLE
void
setROI
(
const
QGeoCoordinate
&
pointNW
,
const
QGeoCoordinate
&
pointSE
,
bool
planView
);
...
...
@@ -79,6 +81,8 @@ public:
virtual
bool
airspaceVisible
()
{
return
_airspaceVisible
;
}
virtual
void
setAirspaceVisible
(
bool
set
)
{
_airspaceVisible
=
set
;
emit
airspaceVisibleChanged
();
}
virtual
bool
connected
()
const
=
0
;
virtual
QString
connectStatus
()
const
{
return
QString
();
}
/**
* Factory method to create an AirspaceVehicleManager object
...
...
@@ -87,6 +91,8 @@ public:
signals:
void
airspaceVisibleChanged
();
void
connectedChanged
();
void
connectStatusChanged
();
protected:
/**
...
...
src/FlightDisplay/FlightDisplayViewMap.qml
View file @
bc10a8d2
...
...
@@ -51,7 +51,7 @@ FlightMap {
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
property
var
_activeVehicleCoordinate
:
_activeVehicle
?
_activeVehicle
.
coordinate
:
QtPositioning
.
coordinate
()
property
real
_toolButtonTopMargin
:
parent
.
height
-
ScreenTools
.
availableHeight
+
(
ScreenTools
.
defaultFontPixelHeight
/
2
)
property
bool
_airspaceEnabled
:
QGroundControl
.
airmapSupported
?
QGroundControl
.
settingsManager
.
airMapSettings
.
enableAirMap
.
rawValue
:
false
property
bool
_airspaceEnabled
:
QGroundControl
.
airmapSupported
?
(
QGroundControl
.
settingsManager
.
airMapSettings
.
enableAirMap
.
rawValue
&&
QGroundControl
.
airspaceManager
.
connected
)
:
false
property
bool
_disableVehicleTracking
:
false
property
bool
_keepVehicleCentered
:
_mainIsMap
?
false
:
true
...
...
@@ -87,6 +87,10 @@ FlightMap {
}
}
on_AirspaceEnabledChanged
:
{
updateAirspace
()
}
function
pointInRect
(
point
,
rect
)
{
return
point
.
x
>
rect
.
x
&&
point
.
x
<
rect
.
x
+
rect
.
width
&&
...
...
Drivers
@
e84bb0a7
Subproject commit
d7854b7bcf1610bb42d89f4bae553744cbe4408c
Subproject commit
e84bb0a7a702320fedade6c83bbdf2324e3be8fb
src/PlanView/PlanView.qml
View file @
bc10a8d2
...
...
@@ -47,7 +47,7 @@ QGCView {
readonly
property
var
_defaultVehicleCoordinate
:
QtPositioning
.
coordinate
(
37.803784
,
-
122.462276
)
readonly
property
bool
_waypointsOnlyMode
:
QGroundControl
.
corePlugin
.
options
.
missionWaypointsOnly
property
bool
_airspaceEnabled
:
QGroundControl
.
airmapSupported
?
QGroundControl
.
settingsManager
.
airMapSettings
.
enableAirMap
.
rawValue
:
false
property
bool
_airspaceEnabled
:
QGroundControl
.
airmapSupported
?
(
QGroundControl
.
settingsManager
.
airMapSettings
.
enableAirMap
.
rawValue
&&
QGroundControl
.
airspaceManager
.
connected
)
:
false
property
var
_planMasterController
:
masterController
property
var
_missionController
:
_planMasterController
.
missionController
property
var
_geoFenceController
:
_planMasterController
.
geoFenceController
...
...
@@ -115,6 +115,7 @@ QGCView {
if
(
QGroundControl
.
airmapSupported
)
{
if
(
_airspaceEnabled
)
{
planControlColapsed
=
QGroundControl
.
airspaceManager
.
airspaceVisible
updateAirspace
()
}
else
{
planControlColapsed
=
false
}
...
...
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