1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/****************************************************************************
*
* (c) 2009-2016 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.
*
****************************************************************************/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "SensorsComponent.h"
#include "PX4AutoPilotPlugin.h"
#include "QGCQmlWidgetHolder.h"
#include "SensorsComponentController.h"
const char* SensorsComponent::_airspeedBreakerParam = "CBRK_AIRSPD_CHK";
const char* SensorsComponent::_airspeedDisabledParam = "FW_ARSP_MODE";
const char* SensorsComponent::_airspeedCalParam = "SENS_DPRES_OFF";
const char* SensorsComponent::_magEnabledParam = "SYS_HAS_MAG";
const char* SensorsComponent::_magCalParam = "CAL_MAG0_ID";
SensorsComponent::SensorsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
VehicleComponent(vehicle, autopilot, parent),
_name(tr("Sensors"))
{
_deviceIds << QStringLiteral("CAL_GYRO0_ID") << QStringLiteral("CAL_ACC0_ID");
}
QString SensorsComponent::name(void) const
{
return _name;
}
QString SensorsComponent::description(void) const
{
return tr("Sensors Setup is used to calibrate the sensors within your vehicle.");
}
QString SensorsComponent::iconResource(void) const
{
return "/qmlimages/SensorsComponentIcon.png";
}
bool SensorsComponent::requiresSetup(void) const
{
return true;
}
bool SensorsComponent::setupComplete(void) const
{
foreach (const QString &triggerParam, _deviceIds) {
if (_vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, triggerParam)->rawValue().toFloat() == 0.0f) {
return false;
}
}
bool magEnabled = true;
if (_vehicle->parameterManager()->parameterExists(FactSystem::defaultComponentId, _magEnabledParam)) {
magEnabled = _vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, _magEnabledParam)->rawValue().toBool();
}
if (magEnabled && _vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, _magCalParam)->rawValue().toFloat() == 0.0f) {
return false;
}
if (_vehicle->fixedWing() || _vehicle->vtol()) {
if (!_vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, _airspeedDisabledParam)->rawValue().toBool() &&
_vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, _airspeedBreakerParam)->rawValue().toInt() != 162128 &&
_vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, _airspeedCalParam)->rawValue().toFloat() == 0.0f) {
return false;
}
}
return true;
}
QStringList SensorsComponent::setupCompleteChangedTriggerList(void) const
{
QStringList triggers;
triggers << _deviceIds << _magCalParam << _magEnabledParam;
if (_vehicle->fixedWing() || _vehicle->vtol()) {
triggers << _airspeedCalParam << _airspeedBreakerParam;
}
return triggers;
}
QUrl SensorsComponent::setupSource(void) const
{
return QUrl::fromUserInput("qrc:/qml/SensorsComponent.qml");
}
QUrl SensorsComponent::summaryQmlSource(void) const
{
QString summaryQml;
if (_vehicle->fixedWing() || _vehicle->vtol()) {
summaryQml = "qrc:/qml/SensorsComponentSummaryFixedWing.qml";
} else {
summaryQml = "qrc:/qml/SensorsComponentSummary.qml";
}
return QUrl::fromUserInput(summaryQml);
}