forked from FlexiGroBots-H2020/qgroundcontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9eda817
commit 32bf236
Showing
9 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |