Commit b754891c authored by dogmaphobic's avatar dogmaphobic

Merge remote-tracking branch 'MavLink/master' into esp8266Component

* MavLink/master:
  New initial map position handling
  Default map position support
  Bad english, plus unit test check
  Add Reboot Required fact meta data
parents 6e12a7e8 f9874376
......@@ -482,3 +482,13 @@ QString Fact::validate(const QString& cookedValue, bool convertOnly)
return QString("Internal error: Meta data pointer missing");
}
}
bool Fact::rebootRequired(void) const
{
if (_metaData) {
return _metaData->rebootRequired();
} else {
qWarning() << "Meta data pointer missing";
return false;
}
}
......@@ -66,6 +66,7 @@ public:
Q_PROPERTY(QString minString READ cookedMinString CONSTANT)
Q_PROPERTY(bool minIsDefaultForType READ minIsDefaultForType CONSTANT)
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(bool rebootRequired READ rebootRequired CONSTANT)
Q_PROPERTY(QString shortDescription READ shortDescription CONSTANT)
Q_PROPERTY(FactMetaData::ValueType_t type READ type CONSTANT)
Q_PROPERTY(QString units READ cookedUnits CONSTANT)
......@@ -109,6 +110,7 @@ public:
QString rawValueString (void) const;
QString cookedValueString (void) const;
bool valueEqualsDefault (void) const;
bool rebootRequired (void) const;
void setRawValue (const QVariant& value);
void setCookedValue (const QVariant& value);
......
......@@ -51,6 +51,7 @@ FactMetaData::FactMetaData(QObject* parent)
, _minIsDefaultForType(true)
, _rawTranslator(_defaultTranslator)
, _cookedTranslator(_defaultTranslator)
, _rebootRequired(false)
{
}
......@@ -68,6 +69,7 @@ FactMetaData::FactMetaData(ValueType_t type, QObject* parent)
, _minIsDefaultForType(true)
, _rawTranslator(_defaultTranslator)
, _cookedTranslator(_defaultTranslator)
, _rebootRequired(false)
{
}
......@@ -100,6 +102,7 @@ const FactMetaData& FactMetaData::operator=(const FactMetaData& other)
_cookedUnits = other._cookedUnits;
_rawTranslator = other._rawTranslator;
_cookedTranslator = other._cookedTranslator;
_rebootRequired = other._rebootRequired;
return *this;
}
......
......@@ -81,6 +81,7 @@ public:
ValueType_t type (void) const { return _type; }
QString rawUnits (void) const { return _rawUnits; }
QString cookedUnits (void) const { return _cookedUnits; }
bool rebootRequired (void) const { return _rebootRequired; }
Translator rawTranslator (void) const { return _rawTranslator; }
Translator cookedTranslator (void) const { return _cookedTranslator; }
......@@ -102,6 +103,7 @@ public:
void setName (const QString& name) { _name = name; }
void setShortDescription(const QString& shortDescription) { _shortDescription = shortDescription; }
void setRawUnits (const QString& rawUnits);
void setRebootRequired (bool rebootRequired) { _rebootRequired = rebootRequired; }
void setTranslators(Translator rawTranslator, Translator cookedTranslator);
......@@ -150,6 +152,7 @@ private:
QString _cookedUnits;
Translator _rawTranslator;
Translator _cookedTranslator;
bool _rebootRequired;
struct BuiltInTranslation_s {
const char* rawUnits;
......
......@@ -295,6 +295,10 @@ void ParameterLoader::_valueUpdated(const QVariant& value)
_writeParameterRaw(componentId, fact->name(), value);
qCDebug(ParameterLoaderLog) << "Set parameter (componentId:" << componentId << "name:" << name << value << ")";
if (fact->rebootRequired() && !qgcApp()->runningUnitTests()) {
qgcApp()->showMessage(QStringLiteral("Change of parameter %1 requires a Vehicle reboot to take effect").arg(name));
}
}
void ParameterLoader::refreshAllParameters(uint8_t componentID)
......
......@@ -342,6 +342,7 @@ bool APMParameterMetaData::parseParameterAttributes(QXmlStreamReader& xml, APMFa
// skip empty elements. Somehow I am getting lot of these. Dont know what to do with them.
} else if (elementName == "field") {
QString attributeName = xml.attributes().value("name").toString();
if ( attributeName == "Range") {
QString range = xml.readElementText().trimmed();
QStringList rangeList = range.split(' ');
......@@ -402,6 +403,11 @@ bool APMParameterMetaData::parseParameterAttributes(QXmlStreamReader& xml, APMFa
if (parseError) {
rawMetaData->bitmask.clear();
}
} else if (attributeName == "RebootRequired") {
QString strValue = xml.readElementText().trimmed();
if (strValue.compare("true", Qt::CaseInsensitive) == 0) {
rawMetaData->rebootRequired = true;
}
}
} else if (elementName == "values") {
// doing nothing individual value will follow anyway. May be used for sanity checking.
......@@ -447,6 +453,7 @@ void APMParameterMetaData::addMetaDataToFact(Fact* fact, MAV_TYPE vehicleType)
metaData->setName(rawMetaData->name);
metaData->setGroup(rawMetaData->group);
metaData->setRebootRequired(rawMetaData->rebootRequired);
if (!rawMetaData->shortDescription.isEmpty()) {
metaData->setShortDescription(rawMetaData->shortDescription);
......
......@@ -37,14 +37,19 @@
class APMFactMetaDataRaw
{
public:
QString name;
QString group;
QString shortDescription;
QString longDescription;
QString min;
QString max;
QString incrementSize;
QString units;
APMFactMetaDataRaw(void)
: rebootRequired(false)
{ }
QString name;
QString group;
QString shortDescription;
QString longDescription;
QString min;
QString max;
QString incrementSize;
QString units;
bool rebootRequired;
QList<QPair<QString, QString> > values;
QList<QPair<QString, QString> > bitmask;
};
......
......@@ -312,6 +312,14 @@ void PX4ParameterMetaData::_loadParameterFactMetaData(void)
qCWarning(PX4ParameterMetaDataLog) << "Invalid decimals value, name:" << metaData->name() << " type:" << metaData->type() << " decimals:" << text << " error: invalid number";
}
} else if (elementName == "reboot_required") {
Q_ASSERT(metaData);
QString text = xml.readElementText();
qCDebug(PX4ParameterMetaDataLog) << "RebootRequired:" << text;
if (text.compare("true", Qt::CaseInsensitive) == 0) {
metaData->setRebootRequired(true);
}
} else {
qDebug() << "Unknown element in XML: " << elementName;
}
......
......@@ -50,7 +50,6 @@ Item {
property var _activeVehicle: multiVehicleManager.activeVehicle
readonly property var _defaultVehicleCoordinate: mainWindow.tabletPosition
readonly property real _defaultRoll: 0
readonly property real _defaultPitch: 0
readonly property real _defaultHeading: 0
......@@ -71,8 +70,6 @@ Item {
property real _pitch: _activeVehicle ? (isNaN(_activeVehicle.pitch) ? _defaultPitch : _activeVehicle.pitch) : _defaultPitch
property real _heading: _activeVehicle ? (isNaN(_activeVehicle.heading) ? _defaultHeading : _activeVehicle.heading) : _defaultHeading
property var _vehicleCoordinate: _activeVehicle ? (_activeVehicle.coordinateValid ? _activeVehicle.coordinate : _defaultVehicleCoordinate) : _defaultVehicleCoordinate
property real _altitudeWGS84: _activeVehicle ? _activeVehicle.altitudeWGS84 : _defaultAltitudeWGS84
property real _groundSpeed: _activeVehicle ? _activeVehicle.groundSpeed : _defaultGroundSpeed
property real _airSpeed: _activeVehicle ? _activeVehicle.airSpeed : _defaultAirSpeed
......@@ -120,7 +117,6 @@ Item {
_flightMap.zoomLevel = _savedZoomLevel
else
_savedZoomLevel = _flightMap.zoomLevel
_flightMap.updateMapPosition(true /* force */)
} else {
_flightVideo = item
}
......
......@@ -39,18 +39,15 @@ FlightMap {
id: flightMap
anchors.fill: parent
mapName: _mapName
latitude: mainWindow.tabletPosition.latitude
longitude: mainWindow.tabletPosition.longitude
property var rootVehicleCoordinate: _vehicleCoordinate
property bool _followVehicle: true
property bool _followVehicle: true
property bool _activeVehicleCoordinateValid: multiVehicleManager.activeVehicle ? multiVehicleManager.activeVehicle.coordinateValid : false
property var activeVehicleCoordinate: multiVehicleManager.activeVehicle ? multiVehicleManager.activeVehicle.coordinate : QtPositioning.coordinate()
onRootVehicleCoordinateChanged: updateMapPosition(false /* force */)
function updateMapPosition(force) {
if (_followVehicle || force) {
flightMap.latitude = root._vehicleCoordinate.latitude
flightMap.longitude = root._vehicleCoordinate.longitude
onActiveVehicleCoordinateChanged: {
if (_followVehicle && activeVehicleCoordinate.isValid) {
_initialMapPositionSet = true
flightMap.center = activeVehicleCoordinate
}
}
......
......@@ -43,22 +43,16 @@ import QGroundControl.Mavlink 1.0
Map {
id: _map
property real latitude: 64.154549 //-- If you find yourself here on startup, something went wrong :)
property real longitude: -22.023540
property real heading: 0
property bool interactive: true
property string mapName: 'defaultMap'
property string mapType: QGroundControl.flightMapSettings.mapTypeForMapName(mapName)
// property alias mapWidgets: controlWidgets
property bool isSatelliteMap: mapType == "Satellite Map" || mapType == "Hybrid Map"
property real lon: (longitude >= -180 && longitude <= 180) ? longitude : 0
property real lat: (latitude >= -90 && latitude <= 90) ? latitude : 0
readonly property real maxZoomLevel: 20
zoomLevel: 18
center: QtPositioning.coordinate(lat, lon)
center: QGroundControl.defaultMapPosition
gesture.flickDeceleration: 3000
gesture.enabled: interactive
gesture.activeGestures: MapGestureArea.ZoomGesture | MapGestureArea.PanGesture | MapGestureArea.FlickGesture
......@@ -69,6 +63,18 @@ Map {
Component.onCompleted: onMapTypeChanged
property bool _initialMapPositionSet: false
Connections {
target: mainWindow
onGcsPositionChanged: {
if (!_initialMapPositionSet) {
_initialMapPositionSet = true
flightMap.center = mainWindow.gcsPosition
}
}
}
onMapTypeChanged: {
QGroundControl.flightMapSettings.setMapTypeForMapName(mapName, mapType)
var fullMapName = QGroundControl.flightMapSettings.mapProvider + " " + mapType
......@@ -80,7 +86,18 @@ Map {
}
}
/*********************************************
MapQuickItem {
anchorPoint.x: sourceItem.width / 2
anchorPoint.y: sourceItem.height / 2
visible: mainWindow.gcsPosition.isValid
coordinate: mainWindow.gcsPosition
sourceItem: MissionItemIndexLabel {
label: "Q"
}
}
/*********************************************
/// Map control widgets
Column {
id: controlWidgets
......
......@@ -62,13 +62,8 @@ QGCView {
property var _missionItems: controller.missionItems
property var _currentMissionItem
property bool gpsLock: _activeVehicle ? _activeVehicle.coordinateValid : false
property bool _firstGpsLock: true
//property var _homePositionManager: QGroundControl.homePositionManager
//property string _homePositionName: _homePositionManager.homePositions.get(0).name
//property var offlineHomePosition: _homePositionManager.homePositions.get(0).coordinate
property bool _firstVehiclePosition: true
property var activeVehiclePosition: _activeVehicle ? _activeVehicle.coordinate : QtPositioning.coordinate()
property var liveHomePosition: controller.liveHomePosition
property var liveHomePositionAvailable: controller.liveHomePositionAvailable
......@@ -76,17 +71,23 @@ QGCView {
property bool _syncInProgress: _activeVehicle ? _activeVehicle.missionManager.inProgress : false
onGpsLockChanged: updateMapToVehiclePosition()
Component.onCompleted: updateMapToVehiclePosition()
onActiveVehiclePositionChanged: updateMapToVehiclePosition()
Component.onCompleted: {
updateMapToVehiclePosition()
Connections {
target: multiVehicleManager
onActiveVehicleChanged: {
// When the active vehicle changes we need to allow the first vehicle position to move the map again
_firstVehiclePosition = true
updateMapToVehiclePosition()
}
}
function updateMapToVehiclePosition() {
if (gpsLock && _firstGpsLock) {
_firstGpsLock = false
editorMap.latitude = _activeVehicle.latitude
editorMap.longitude = _activeVehicle.longitude
if (_activeVehicle && _activeVehicle.coordinateValid && _firstVehiclePosition) {
_firstVehiclePosition = false
editorMap.center = _activeVehicle.coordinate
}
}
......@@ -178,8 +179,6 @@ QGCView {
id: editorMap
anchors.fill: parent
mapName: "MissionEditor"
latitude: mainWindow.tabletPosition.latitude
longitude: mainWindow.tabletPosition.longitude
readonly property real animationDuration: 500
......@@ -190,20 +189,6 @@ QGCView {
}
}
Behavior on latitude {
NumberAnimation {
duration: editorMap.animationDuration
easing.type: Easing.InOutQuad
}
}
Behavior on longitude {
NumberAnimation {
duration: editorMap.animationDuration
easing.type: Easing.InOutQuad
}
}
MouseArea {
anchors.fill: parent
......
......@@ -122,6 +122,8 @@ const char* QGCApplication::_settingsVersionKey = "SettingsVersion";
const char* QGCApplication::_promptFlightDataSave = "PromptFLightDataSave";
const char* QGCApplication::_promptFlightDataSaveNotArmed = "PromptFLightDataSaveNotArmed";
const char* QGCApplication::_styleKey = "StyleIsDark";
const char* QGCApplication::_defaultMapPositionLatKey = "DefaultMapPositionLat";
const char* QGCApplication::_defaultMapPositionLonKey = "DefaultMapPositionLon";
const char* QGCApplication::_darkStyleFile = ":/res/styles/style-dark.css";
const char* QGCApplication::_lightStyleFile = ":/res/styles/style-light.css";
......@@ -177,6 +179,7 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
#endif
, _toolbox(NULL)
, _bluetoothAvailable(false)
, _defaultMapPosition(37.803784, -122.462276)
{
Q_ASSERT(_app == NULL);
_app = this;
......@@ -319,6 +322,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
settings.setValue(_settingsVersionKey, QGC_SETTINGS_VERSION);
}
_defaultMapPosition.setLatitude(settings.value(_defaultMapPositionLatKey, 37.803784).toDouble());
_defaultMapPosition.setLongitude(settings.value(_defaultMapPositionLonKey, -122.462276).toDouble());
// Initialize Bluetooth
#ifdef QGC_ENABLE_BLUETOOTH
QBluetoothLocalDevice localDevice;
......@@ -713,3 +719,12 @@ void QGCApplication::_showSetupVehicleComponent(VehicleComponent* vehicleCompone
QMetaObject::invokeMethod(_rootQmlObject(), "showSetupVehicleComponent", Q_RETURN_ARG(QVariant, varReturn), Q_ARG(QVariant, varComponent));
}
void QGCApplication::setDefaultMapPosition(QGeoCoordinate& defaultMapPosition)
{
QSettings settings;
settings.setValue(_defaultMapPositionLatKey, defaultMapPosition.latitude());
settings.setValue(_defaultMapPositionLonKey, defaultMapPosition.longitude());
_defaultMapPosition = defaultMapPosition;
}
......@@ -121,6 +121,9 @@ public:
/// Do we have Bluetooth Support?
bool isBluetoothAvailable() { return _bluetoothAvailable; }
QGeoCoordinate defaultMapPosition(void) { return _defaultMapPosition; }
void setDefaultMapPosition(QGeoCoordinate& defaultMapPosition);
public slots:
/// You can connect to this slot to show an information message box from a different thread.
void informationMessageBoxOnMainThread(const QString& title, const QString& msg);
......@@ -184,12 +187,6 @@ private:
QQmlApplicationEngine* _qmlAppEngine;
#endif
static const char* _settingsVersionKey; ///< Settings key which hold settings version
static const char* _deleteAllSettingsKey; ///< If this settings key is set on boot, all settings will be deleted
static const char* _promptFlightDataSave; ///< Settings key for promptFlightDataSave
static const char* _promptFlightDataSaveNotArmed; ///< Settings key for promptFlightDataSaveNotArmed
static const char* _styleKey; ///< Settings key for UI style
bool _runningUnitTests; ///< true: running unit tests, false: normal app
static const char* _darkStyleFile;
......@@ -210,6 +207,16 @@ private:
bool _bluetoothAvailable;
QGeoCoordinate _defaultMapPosition; ///< Map position when all other sources fail
static const char* _settingsVersionKey; ///< Settings key which hold settings version
static const char* _deleteAllSettingsKey; ///< If this settings key is set on boot, all settings will be deleted
static const char* _promptFlightDataSave; ///< Settings key for promptFlightDataSave
static const char* _promptFlightDataSaveNotArmed; ///< Settings key for promptFlightDataSaveNotArmed
static const char* _styleKey; ///< Settings key for UI style
static const char* _defaultMapPositionLatKey; ///< Settings key for default map location
static const char* _defaultMapPositionLonKey; ///< Settings key for default map location
/// Unit Test have access to creating and destroying singletons
friend class UnitTest;
};
......
......@@ -42,7 +42,6 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app)
, _virtualTabletJoystick(false)
, _offlineEditingFirmwareTypeFact(QString(), "OfflineEditingFirmwareType", FactMetaData::valueTypeUint32, (uint32_t)MAV_AUTOPILOT_ARDUPILOTMEGA)
, _offlineEditingFirmwareTypeMetaData(FactMetaData::valueTypeUint32)
{
QSettings settings;
_virtualTabletJoystick = settings.value(_virtualTabletJoystickKey, false). toBool();
......
......@@ -76,6 +76,8 @@ public:
Q_PROPERTY(Fact* offlineEditingFirmwareType READ offlineEditingFirmwareType CONSTANT)
Q_PROPERTY(QGeoCoordinate defaultMapPosition READ defaultMapPosition CONSTANT)
Q_INVOKABLE void saveGlobalSetting (const QString& key, const QString& value);
Q_INVOKABLE QString loadGlobalSetting (const QString& key, const QString& defaultValue);
Q_INVOKABLE void saveBoolGlobalSetting (const QString& key, bool value);
......@@ -113,6 +115,8 @@ public:
bool isVersionCheckEnabled () { return _toolbox->mavlinkProtocol()->versionCheckEnabled(); }
int mavlinkSystemID () { return _toolbox->mavlinkProtocol()->getSystemId(); }
QGeoCoordinate defaultMapPosition() { return qgcApp()->defaultMapPosition(); }
Fact* offlineEditingFirmwareType () { return &_offlineEditingFirmwareTypeFact; }
//-- TODO: Make this into an actual preference.
......@@ -144,7 +148,6 @@ signals:
void mavlinkSystemIDChanged (int id);
private:
FlightMapSettings* _flightMapSettings;
HomePositionManager* _homePositionManager;
LinkManager* _linkManager;
......
......@@ -281,6 +281,7 @@ void Vehicle::_handleHomePosition(mavlink_message_t& message)
if (emitHomePositionChanged) {
qCDebug(VehicleLog) << "New home position" << newHomePosition;
qgcApp()->setDefaultMapPosition(_homePosition);
emit homePositionChanged(_homePosition);
}
if (emitHomePositionAvailableChanged) {
......
......@@ -33,9 +33,9 @@ import QGroundControl.FlightDisplay 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.MultiVehicleManager 1.0
/// Inner common QML for MainWindow
/// Inner common QML for mainWindow
Item {
id: mainWindow
id: mainWindow
signal reallyClose
......@@ -50,10 +50,7 @@ Item {
property real tbButtonWidth: tbCellHeight * 1.35
property real availableHeight: height - tbHeight
property real menuButtonWidth: (tbButtonWidth * 2) + (tbSpacing * 4) + 1
property var defaultPosition: QtPositioning.coordinate(37.803784, -122.462276)
property var tabletPosition: defaultPosition
property var gcsPosition: QtPositioning.coordinate() // Starts as invalid coordinate
property var currentPopUp: null
property real currentCenterX: 0
property var activeVehicle: multiVehicleManager.activeVehicle
......@@ -179,20 +176,20 @@ Item {
PositionSource {
id: positionSource
updateInterval: 1000
active: false
active: true
onPositionChanged: {
if(positionSource.valid) {
if(positionSource.position.coordinate.latitude) {
if(Math.abs(positionSource.position.coordinate.latitude) > 0.001) {
if(positionSource.position.coordinate.longitude) {
if(Math.abs(positionSource.position.coordinate.longitude) > 0.001) {
tabletPosition = positionSource.position.coordinate
gcsPosition = positionSource.position.coordinate
}
}
}
}
}
positionSource.stop()
}
}
......@@ -299,9 +296,6 @@ Item {
anchors.fill: parent
availableHeight: mainWindow.availableHeight
visible: true
Component.onCompleted: {
positionSource.start()
}
}
Loader {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment