forked from mavlink/qgroundcontrol
-
Notifications
You must be signed in to change notification settings - Fork 2
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
cbc944f
commit e208322
Showing
7 changed files
with
150 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"version": 1, | ||
"fileType": "FactMetaData", | ||
"QGC.MetaData.Facts": | ||
[ | ||
{ | ||
"name": "rpm1", | ||
"shortDesc": "RPM 1", | ||
"type": "double", | ||
"decimalPlaces": 2, | ||
"units": "rpm" | ||
}, | ||
{ | ||
"name": "rpm2", | ||
"shortDesc": "RPM 2", | ||
"type": "double", | ||
"decimalPlaces": 2, | ||
"units": "rpm" | ||
}, | ||
{ | ||
"name": "rpm3", | ||
"shortDesc": "RPM 3", | ||
"type": "double", | ||
"decimalPlaces": 2, | ||
"units": "rpm" | ||
}, | ||
{ | ||
"name": "rpm4", | ||
"shortDesc": "RPM 4", | ||
"type": "double", | ||
"decimalPlaces": 2, | ||
"units": "rpm" | ||
} | ||
] | ||
} |
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,61 @@ | ||
/**************************************************************************** | ||
* | ||
* (c) 2009-2023 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 "VehicleSetpointFactGroup.h" | ||
#include "Vehicle.h" | ||
|
||
const char* VehicleRPMFactGroup::_rpm1FactName = "rpm1"; | ||
const char* VehicleRPMFactGroup::_rpm2FactName = "rpm2"; | ||
const char* VehicleRPMFactGroup::_rpm3FactName = "rpm3"; | ||
const char* VehicleRPMFactGroup::_rpm4FactName = "rpm4"; | ||
|
||
VehicleRPMFactGroup::VehicleRPMFactGroup(QObject* parent) | ||
: FactGroup(1000, ":/json/Vehicle/RPMFact.json", parent) | ||
, _rpm1Fact(0, _rpm1FactName, FactMetaData::valueTypeDouble) | ||
, _rpm2Fact(0, _rpm2FactName, FactMetaData::valueTypeDouble) | ||
, _rpm3Fact(0, _rpm3FactName, FactMetaData::valueTypeDouble) | ||
, _rpm4Fact(0, _rpm4FactName, FactMetaData::valueTypeDouble) | ||
{ | ||
_addFact(&_rpm1Fact, _rpm1FactName); | ||
_addFact(&_rpm2Fact, _rpm2FactName); | ||
_addFact(&_rpm3Fact, _rpm3FactName); | ||
_addFact(&_rpm4Fact, _rpm4FactName); | ||
|
||
// Start out as not available "--.--" | ||
_rpm1Fact.setRawValue(qQNaN()); | ||
_rpm2Fact.setRawValue(qQNaN()); | ||
_rpm3Fact.setRawValue(qQNaN()); | ||
_rpm4Fact.setRawValue(qQNaN()); | ||
} | ||
|
||
void VehicleRPMFactGroup::handleMessage(Vehicle* /* vehicle */, mavlink_message_t& message) | ||
{ | ||
if (message.msgid == MAVLINK_MSG_ID_RAW_RPM) { | ||
mavlink_raw_rpm_t raw_rpm; | ||
mavlink_msg_raw_rpm_decode(&message, &raw_rpm); | ||
switch (raw_rpm.index) { | ||
case 0: | ||
rpm1()->setRawValue(raw_rpm.frequency); | ||
break; | ||
case 1: | ||
rpm2()->setRawValue(raw_rpm.frequency); | ||
break; | ||
case 2: | ||
rpm3()->setRawValue(raw_rpm.frequency); | ||
break; | ||
case 3: | ||
rpm4()->setRawValue(raw_rpm.frequency); | ||
break; | ||
default: | ||
break; | ||
|
||
} | ||
_setTelemetryAvailable(true); | ||
} | ||
} |
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,45 @@ | ||
/**************************************************************************** | ||
* | ||
* (c) 2009-2023 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 VehicleRPMFactGroup : public FactGroup | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
VehicleRPMFactGroup(QObject* parent = nullptr); | ||
|
||
Q_PROPERTY(Fact* rpm1 READ rpm1 CONSTANT) | ||
Q_PROPERTY(Fact* rpm2 READ rpm2 CONSTANT) | ||
Q_PROPERTY(Fact* rpm3 READ rpm3 CONSTANT) | ||
Q_PROPERTY(Fact* rpm4 READ rpm4 CONSTANT) | ||
|
||
Fact* rpm1 () { return &_rpm1Fact; } | ||
Fact* rpm2 () { return &_rpm2Fact; } | ||
Fact* rpm3 () { return &_rpm3Fact; } | ||
Fact* rpm4 () { return &_rpm4Fact; } | ||
|
||
// Overrides from FactGroup | ||
void handleMessage(Vehicle* vehicle, mavlink_message_t& message) override; | ||
|
||
static const char* _rpm1FactName; | ||
static const char* _rpm2FactName; | ||
static const char* _rpm3FactName; | ||
static const char* _rpm4FactName; | ||
|
||
private: | ||
Fact _rpm1Fact; | ||
Fact _rpm2Fact; | ||
Fact _rpm3Fact; | ||
Fact _rpm4Fact; | ||
}; |
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