Browse Source

FactGroup: Add HygrometerFactGround

QGC4.4
honglang 4 years ago committed by Don Gagne
parent
commit
32bf236014
  1. 1
      custom-example/qgroundcontrol.qrc
  2. 4
      qgroundcontrol.pro
  3. 1
      qgroundcontrol.qrc
  4. 2
      src/Vehicle/CMakeLists.txt
  5. 27
      src/Vehicle/HygrometerFact.json
  6. 3
      src/Vehicle/Vehicle.cc
  7. 5
      src/Vehicle/Vehicle.h
  8. 52
      src/Vehicle/VehicleHygrometerFactGroup.cc
  9. 43
      src/Vehicle/VehicleHygrometerFactGroup.h

1
custom-example/qgroundcontrol.qrc

@ -329,6 +329,7 @@ @@ -329,6 +329,7 @@
<file alias="Vehicle/VehicleFact.json">../src/Vehicle/VehicleFact.json</file>
<file alias="Vehicle/VibrationFact.json">../src/Vehicle/VibrationFact.json</file>
<file alias="Vehicle/WindFact.json">../src/Vehicle/WindFact.json</file>
<file alias="Vehicle/HygrometerFact.json">../src/Vehicle/HygrometerFact.json</file>
<file alias="Video.SettingsGroup.json">../src/Settings/Video.SettingsGroup.json</file>
<file alias="VTOLLandingPattern.FactMetaData.json">../src/MissionManager/VTOLLandingPattern.FactMetaData.json</file>
</qresource>

4
qgroundcontrol.pro

@ -430,6 +430,7 @@ contains (DEFINES, QGC_ENABLE_PAIRING) { @@ -430,6 +430,7 @@ contains (DEFINES, QGC_ENABLE_PAIRING) {
HEADERS += \
src/QmlControls/QmlUnitsConversion.h \
src/Vehicle/VehicleEscStatusFactGroup.h \
src/Vehicle/VehicleHygrometerFactGroup.h \
src/api/QGCCorePlugin.h \
src/api/QGCOptions.h \
src/api/QGCSettings.h \
@ -443,6 +444,7 @@ contains (DEFINES, QGC_ENABLE_PAIRING) { @@ -443,6 +444,7 @@ contains (DEFINES, QGC_ENABLE_PAIRING) {
SOURCES += \
src/Vehicle/VehicleEscStatusFactGroup.cc \
src/Vehicle/VehicleHygrometerFactGroup.cc \
src/api/QGCCorePlugin.cc \
src/api/QGCOptions.cc \
src/api/QGCSettings.cc \
@ -723,6 +725,7 @@ HEADERS += \ @@ -723,6 +725,7 @@ HEADERS += \
src/Vehicle/VehicleTemperatureFactGroup.h \
src/Vehicle/VehicleVibrationFactGroup.h \
src/Vehicle/VehicleWindFactGroup.h \
src/Vehicle/VehicleHygrometerFactGroup.h \
src/VehicleSetup/JoystickConfigController.h \
src/comm/LinkConfiguration.h \
src/comm/LinkInterface.h \
@ -963,6 +966,7 @@ SOURCES += \ @@ -963,6 +966,7 @@ SOURCES += \
src/Vehicle/VehicleSetpointFactGroup.cc \
src/Vehicle/VehicleTemperatureFactGroup.cc \
src/Vehicle/VehicleVibrationFactGroup.cc \
src/Vehicle/VehicleHygrometerFactGroup.cc \
src/Vehicle/VehicleWindFactGroup.cc \
src/VehicleSetup/JoystickConfigController.cc \
src/comm/LinkConfiguration.cc \

1
qgroundcontrol.qrc

@ -337,6 +337,7 @@ @@ -337,6 +337,7 @@
<file alias="Vehicle/VehicleFact.json">src/Vehicle/VehicleFact.json</file>
<file alias="Vehicle/VibrationFact.json">src/Vehicle/VibrationFact.json</file>
<file alias="Vehicle/WindFact.json">src/Vehicle/WindFact.json</file>
<file alias="Vehicle/HygrometerFact.json">src/Vehicle/HygrometerFact.json</file>
<file alias="Video.SettingsGroup.json">src/Settings/Video.SettingsGroup.json</file>
<file alias="VTOLLandingPattern.FactMetaData.json">src/MissionManager/VTOLLandingPattern.FactMetaData.json</file>
</qresource>

2
src/Vehicle/CMakeLists.txt

@ -90,6 +90,8 @@ add_library(Vehicle @@ -90,6 +90,8 @@ add_library(Vehicle
VehicleVibrationFactGroup.h
VehicleWindFactGroup.cc
VehicleWindFactGroup.h
VehicleHygrometerFactGroup.cc
VehicleHygrometerFactGroup.h
${EXTRA_SRC}
)

27
src/Vehicle/HygrometerFact.json

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
{
"version": 1,
"fileType": "FactMetaData",
"QGC.MetaData.Facts":
[
{
"name": "temperature",
"shortDesc": "Temperature",
"type": "double",
"decimalPlaces": 3,
"units": "deg"
},
{
"name": "humidity",
"shortDesc": "Humidity %",
"type": "double",
"decimalPlaces": 3,
"units": "%"
},
{
"name": "hygrometerid",
"shortDesc": "ID",
"type": "uint16",
"decimalPlaces": 0
}
]
}

3
src/Vehicle/Vehicle.cc

@ -108,6 +108,7 @@ const char* Vehicle::_localPositionSetpointFactGroupName ="localPositionSetpoint @@ -108,6 +108,7 @@ const char* Vehicle::_localPositionSetpointFactGroupName ="localPositionSetpoint
const char* Vehicle::_escStatusFactGroupName = "escStatus";
const char* Vehicle::_estimatorStatusFactGroupName = "estimatorStatus";
const char* Vehicle::_terrainFactGroupName = "terrain";
const char* Vehicle::_hygrometerFactGroupName = "hygrometer";
// Standard connected vehicle
Vehicle::Vehicle(LinkInterface* link,
@ -167,6 +168,7 @@ Vehicle::Vehicle(LinkInterface* link, @@ -167,6 +168,7 @@ Vehicle::Vehicle(LinkInterface* link,
, _escStatusFactGroup (this)
, _estimatorStatusFactGroup (this)
, _terrainFactGroup (this)
, _hygrometerFactGroup (this)
, _terrainProtocolHandler (new TerrainProtocolHandler(this, &_terrainFactGroup, this))
{
_linkManager = _toolbox->linkManager();
@ -445,6 +447,7 @@ void Vehicle::_commonInit() @@ -445,6 +447,7 @@ void Vehicle::_commonInit()
_addFactGroup(&_escStatusFactGroup, _escStatusFactGroupName);
_addFactGroup(&_estimatorStatusFactGroup, _estimatorStatusFactGroupName);
_addFactGroup(&_terrainFactGroup, _terrainFactGroupName);
_addFactGroup(&_hygrometerFactGroup, _hygrometerFactGroupName);
// Add firmware-specific fact groups, if provided
QMap<QString, FactGroup*>* fwFactGroups = _firmwarePlugin->factGroups();

5
src/Vehicle/Vehicle.h

@ -39,6 +39,7 @@ @@ -39,6 +39,7 @@
#include "VehicleVibrationFactGroup.h"
#include "VehicleEscStatusFactGroup.h"
#include "VehicleEstimatorStatusFactGroup.h"
#include "VehicleHygrometerFactGroup.h"
#include "VehicleLinkManager.h"
#include "MissionManager.h"
#include "GeoFenceManager.h"
@ -314,6 +315,7 @@ public: @@ -314,6 +315,7 @@ public:
Q_PROPERTY(FactGroup* distanceSensors READ distanceSensorFactGroup CONSTANT)
Q_PROPERTY(FactGroup* localPosition READ localPositionFactGroup CONSTANT)
Q_PROPERTY(FactGroup* localPositionSetpoint READ localPositionSetpointFactGroup CONSTANT)
Q_PROPERTY(FactGroup* hygrometer READ hygrometerFactGroup CONSTANT)
Q_PROPERTY(QmlObjectListModel* batteries READ batteries CONSTANT)
Q_PROPERTY(int firmwareMajorVersion READ firmwareMajorVersion NOTIFY firmwareVersionChanged)
@ -655,6 +657,7 @@ public: @@ -655,6 +657,7 @@ public:
FactGroup* escStatusFactGroup () { return &_escStatusFactGroup; }
FactGroup* estimatorStatusFactGroup () { return &_estimatorStatusFactGroup; }
FactGroup* terrainFactGroup () { return &_terrainFactGroup; }
FactGroup* hygrometerFactGroup () { return &_hygrometerFactGroup; }
QmlObjectListModel* batteries () { return &_batteryFactGroupListModel; }
MissionManager* missionManager () { return _missionManager; }
@ -1308,6 +1311,7 @@ private: @@ -1308,6 +1311,7 @@ private:
VehicleLocalPositionSetpointFactGroup _localPositionSetpointFactGroup;
VehicleEscStatusFactGroup _escStatusFactGroup;
VehicleEstimatorStatusFactGroup _estimatorStatusFactGroup;
VehicleHygrometerFactGroup _hygrometerFactGroup;
TerrainFactGroup _terrainFactGroup;
QmlObjectListModel _batteryFactGroupListModel;
@ -1359,6 +1363,7 @@ private: @@ -1359,6 +1363,7 @@ private:
static const char* _escStatusFactGroupName;
static const char* _estimatorStatusFactGroupName;
static const char* _terrainFactGroupName;
static const char* _hygrometerFactGroupName;
static const int _vehicleUIUpdateRateMSecs = 100;

52
src/Vehicle/VehicleHygrometerFactGroup.cc

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "VehicleHygrometerFactGroup.h"
#include "Vehicle.h"
#include "QGCGeo.h"
const char* VehicleHygrometerFactGroup::_hygroHumiFactName = "humidity";
const char* VehicleHygrometerFactGroup::_hygroTempFactName = "temperature";
const char* VehicleHygrometerFactGroup::_hygroIDFactName = "hygrometerid";
VehicleHygrometerFactGroup::VehicleHygrometerFactGroup(QObject* parent)
: FactGroup(1000, ":/json/Vehicle/HygrometerFact.json", parent)
, _hygroTempFact (0, _hygroTempFactName, FactMetaData::valueTypeDouble)
, _hygroHumiFact (0, _hygroHumiFactName, FactMetaData::valueTypeDouble)
, _hygroIDFact (0, _hygroIDFactName, FactMetaData::valueTypeUint16)
{
_addFact(&_hygroTempFact, _hygroTempFactName);
_addFact(&_hygroHumiFact, _hygroHumiFactName);
_addFact(&_hygroIDFact, _hygroIDFactName);
_hygroTempFact.setRawValue(std::numeric_limits<float>::quiet_NaN());
_hygroHumiFact.setRawValue(std::numeric_limits<float>::quiet_NaN());
_hygroIDFact.setRawValue(std::numeric_limits<unsigned int>::quiet_NaN());
}
void VehicleHygrometerFactGroup::handleMessage(Vehicle* /* vehicle */, mavlink_message_t& message)
{
switch (message.msgid) {
case MAVLINK_MSG_ID_HYGROMETER_SENSOR:
_handleHygrometerSensor(message);
break;
default:
break;
}
}
void VehicleHygrometerFactGroup::_handleHygrometerSensor(mavlink_message_t& message)
{
mavlink_hygrometer_sensor_t hygrometer;
mavlink_msg_hygrometer_sensor_decode(&message, &hygrometer);
_hygroTempFact.setRawValue(hygrometer.temperature);
_hygroHumiFact.setRawValue(hygrometer.humidity);
_hygroIDFact.setRawValue(hygrometer.id);
}

43
src/Vehicle/VehicleHygrometerFactGroup.h

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#pragma once
#include "FactGroup.h"
#include "QGCMAVLink.h"
class VehicleHygrometerFactGroup : public FactGroup
{
Q_OBJECT
public:
VehicleHygrometerFactGroup(QObject* parent = nullptr);
Q_PROPERTY(Fact* hygroID READ hygroID CONSTANT)
Q_PROPERTY(Fact* hygroTemp READ hygroTemp CONSTANT)
Q_PROPERTY(Fact* hygroHumi READ hygroHumi CONSTANT)
Fact* hygroID () { return &_hygroIDFact; }
Fact* hygroTemp () { return &_hygroTempFact; }
Fact* hygroHumi () { return &_hygroHumiFact; }
// Overrides from FactGroup
virtual void handleMessage(Vehicle* vehicle, mavlink_message_t& message) override;
static const char* _hygroIDFactName;
static const char* _hygroTempFactName;
static const char* _hygroHumiFactName;
protected:
void _handleHygrometerSensor (mavlink_message_t& message);
Fact _hygroIDFact;
Fact _hygroTempFact;
Fact _hygroHumiFact;
};
Loading…
Cancel
Save