Commit 9ca7bbe7 authored by DonLakeFlyer's avatar DonLakeFlyer

parent 0d1a709d
/****************************************************************************
*
* (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.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.2
import QGroundControl 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controllers 1.0
// Exposes the set of battery parameters for new and old firmwares
// Older firmware: BAT_* naming
// Newer firmware: BAT#_* naming, with indices starting at 1
QtObject {
property var controller ///< FactPanelController
property int batteryIndex ///< 1-based battery index
property bool battVoltageDividerAvailable: controller.parameterExists(-1, "BAT#_V_DIV".replace("#", _indexedBatteryParamsAvailable ? batteryIndex : ""))
property bool battAmpsPerVoltAvailable: controller.parameterExists(-1, "BAT#_A_PER_V".replace("#", _indexedBatteryParamsAvailable ? batteryIndex : ""))
property Fact battNumCells: controller.getParameterFact(-1, "BAT#_N_CELLS".replace("#", _indexedBatteryParamsAvailable ? batteryIndex : ""))
property Fact battHighVolt: controller.getParameterFact(-1, "BAT#_V_CHARGED".replace("#", _indexedBatteryParamsAvailable ? batteryIndex : ""))
property Fact battLowVolt: controller.getParameterFact(-1, "BAT#_V_EMPTY".replace("#", _indexedBatteryParamsAvailable ? batteryIndex : ""))
property Fact battVoltLoadDrop: controller.getParameterFact(-1, "BAT#_V_LOAD_DROP".replace("#", _indexedBatteryParamsAvailable ? batteryIndex : ""))
property Fact battVoltageDivider: controller.getParameterFact(-1, "BAT#_V_DIV".replace("#", _indexedBatteryParamsAvailable ? batteryIndex : ""), false)
property Fact battAmpsPerVolt: controller.getParameterFact(-1, "BAT#_A_PER_V".replace("#", _indexedBatteryParamsAvailable ? batteryIndex : ""), false)
property string _batNCellsIndexedParamName: "BAT#_N_CELLS"
property bool _indexedBatteryParamsAvailable: controller.parameterExists(-1, _batNCellsIndexedParamName.replace("#", 1))
property int _indexedBatteryParamCount: getIndexedBatteryParamCount()
Component.onCompleted: {
if (batteryIndex > 1 && !_indexedBatteryParamsAvailable) {
console.warn("Internal Error: BatteryParams.qml batteryIndex > 1 while indexed params are not available", batteryIndex)
}
}
function getIndexedBatteryParamCount() {
var batteryIndex = 1
do {
if (!controller.parameterExists(-1, _batNCellsIndexedParamName.replace("#", batteryIndex))) {
return batteryIndex - 1
}
batteryIndex++
} while (true)
}
}
This diff is collapsed.
......@@ -22,26 +22,26 @@ PowerComponentController::PowerComponentController(void)
void PowerComponentController::calibrateEsc(void)
{
_warningMessages.clear();
connect(_vehicle, &Vehicle::textMessageReceived, this, &PowerComponentController::_handleUASTextMessage);
connect(_vehicle, &Vehicle::textMessageReceived, this, &PowerComponentController::_handleVehicleTextMessage);
_vehicle->startCalibration(Vehicle::CalibrationEsc);
}
void PowerComponentController::busConfigureActuators(void)
void PowerComponentController::startBusConfigureActuators(void)
{
_warningMessages.clear();
connect(_vehicle, &Vehicle::textMessageReceived, this, &PowerComponentController::_handleUASTextMessage);
_uas->startBusConfig(UASInterface::StartBusConfigActuators);
connect(_vehicle, &Vehicle::textMessageReceived, this, &PowerComponentController::_handleVehicleTextMessage);
_vehicle->startUAVCANBusConfig();
}
void PowerComponentController::stopBusConfigureActuators(void)
{
disconnect(_vehicle, &Vehicle::textMessageReceived, this, &PowerComponentController::_handleUASTextMessage);
_uas->startBusConfig(UASInterface::EndBusConfigActuators);
disconnect(_vehicle, &Vehicle::textMessageReceived, this, &PowerComponentController::_handleVehicleTextMessage);
_vehicle->stopUAVCANBusConfig();
}
void PowerComponentController::_stopCalibration(void)
{
disconnect(_vehicle, &Vehicle::textMessageReceived, this, &PowerComponentController::_handleUASTextMessage);
disconnect(_vehicle, &Vehicle::textMessageReceived, this, &PowerComponentController::_handleVehicleTextMessage);
}
void PowerComponentController::_stopBusConfig(void)
......@@ -49,12 +49,9 @@ void PowerComponentController::_stopBusConfig(void)
_stopCalibration();
}
void PowerComponentController::_handleUASTextMessage(int uasId, int compId, int severity, QString text)
void PowerComponentController::_handleVehicleTextMessage(int vehicleId, int /* compId */, int /* severity */, QString text)
{
Q_UNUSED(compId);
Q_UNUSED(severity);
if (uasId != _vehicle->id()) {
if (vehicleId != _vehicle->id()) {
return;
}
......
......@@ -29,7 +29,7 @@ public:
PowerComponentController(void);
Q_INVOKABLE void calibrateEsc(void);
Q_INVOKABLE void busConfigureActuators(void);
Q_INVOKABLE void startBusConfigureActuators(void);
Q_INVOKABLE void stopBusConfigureActuators(void);
signals:
......@@ -43,7 +43,7 @@ signals:
void calibrationSuccess(const QStringList& warningMessages);
private slots:
void _handleUASTextMessage(int uasId, int compId, int severity, QString text);
void _handleVehicleTextMessage(int vehicleId, int compId, int severity, QString text);
private:
void _stopCalibration(void);
......
......@@ -21,6 +21,7 @@
<file alias="SensorsComponentSummaryFixedWing.qml">../../AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml</file>
<file alias="SensorsSetup.qml">../../AutoPilotPlugins/PX4/SensorsSetup.qml</file>
<file alias="QGroundControl/PX4/qmldir">../../QmlControls/QGroundControl/PX4/qmldir</file>
<file alias="QGroundControl/PX4/BatteryParams.qml">../../AutoPilotPlugins/PX4/BatteryParams.qml</file>
</qresource>
<qresource prefix="/json">
<file alias="PX4-MavCmdInfoCommon.json">PX4-MavCmdInfoCommon.json</file>
......
Module QGroundControl.PX4
BatteryParams 1.0 BatteryParams.qml
SensorSetupPage 1.0 SensorSetupPage.qml
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