Commit 9a33de6d authored by Lorenz Meier's avatar Lorenz Meier

Merge pull request #453 from DonLakeFlyer/FlightModeConfig

Flight mode config rewrite plus Unit Test
parents 87f5c5b5 3b059a31
......@@ -753,7 +753,8 @@ CONFIG(debug, debug|release) {
src/qgcunittest/MockUAS.h \
src/qgcunittest/MockQGCUASParamManager.h \
src/qgcunittest/MultiSignalSpy.h \
src/qgcunittest/TCPLinkTest.h
src/qgcunittest/TCPLinkTest.h \
src/qgcunittest/FlightModeConfigTest.h
SOURCES += \
src/qgcunittest/UASUnitTest.cc \
......@@ -761,7 +762,8 @@ CONFIG(debug, debug|release) {
src/qgcunittest/MockUAS.cc \
src/qgcunittest/MockQGCUASParamManager.cc \
src/qgcunittest/MultiSignalSpy.cc \
src/qgcunittest/TCPLinkTest.cc
src/qgcunittest/TCPLinkTest.cc \
src/qgcunittest/FlightModeConfigTest.cc
}
# Enable Google Earth only on Mac OS and Windows with Visual Studio compiler
......
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef FLIGHTMODECONFIGTEST_H
#define FLIGHTMODECONFIGTEST_H
#include "AutoTest.h"
#include "MockUASManager.h"
#include "MockUAS.h"
#include <QLabel>
#include <QComboBox>
#include <QCheckBox>
#include <QLabel>
#include <QPushButton>
class FlightModeConfig;
/// @file
/// @brief FlightModeConfig unit test
///
/// @author Don Gagne <don@thegagnes.com>
class FlightModeConfigUnitTest : public QObject
{
Q_OBJECT
public:
FlightModeConfigUnitTest(void);
private slots:
void init(void);
void cleanup(void);
void _nullUAS_test(void);
void _validUAS_test(void);
void _nullToValidUAS_test(void);
void _simpleModeFixedWing_test(void);
void _simpleModeRover_test(void);
void _simpleModeRotor_test(void);
void _modeSwitchParam_test(void);
void _pwmFixedWing_test(void);
void _pwmRotor_test(void);
void _pwmRover_test(void);
void _pwmInvalidChannel_test(void);
void _unknownSystemType_test(void);
void _unknownMode_test(void);
private:
void _findControls(QObject* fmc);
void _pwmTestWorker(int systemType, int modeSwitchChannel, const char* modeSwitchParam);
private:
MockUASManager* _mockUASManager;
MockUAS* _mockUAS;
// FlightModeConfig ui elements
static const size_t _cCombo = 6;
QLabel* _rgLabel[_cCombo];
QComboBox* _rgCombo[_cCombo];
QCheckBox* _rgSimpleModeCheckBox[_cCombo];
QLabel* _rgPWMLabel[_cCombo];
QPushButton* _saveButton;
};
DECLARE_TEST(FlightModeConfigUnitTest)
#endif
This diff is collapsed.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef FLIGHTMODECONFIG_H
#define FLIGHTMODECONFIG_H
#include <QWidget>
#include <QComboBox>
#include "ui_FlightModeConfig.h"
#include "UASInterface.h"
#include "UASManager.h"
#include "AP2ConfigWidget.h"
class FlightModeConfig : public AP2ConfigWidget
......@@ -13,19 +35,55 @@ class FlightModeConfig : public AP2ConfigWidget
public:
explicit FlightModeConfig(QWidget *parent = 0);
~FlightModeConfig();
private slots:
void activeUASSet(UASInterface *uas);
void saveButtonClicked();
void modeChanged(int sysId, QString status, QString description);
// Overrides from AP2ConfigWidget
virtual void activeUASSet(UASInterface *uas);
virtual void parameterChanged(int uas, int component, QString parameterName, QVariant value);
// Signalled from UAS
void remoteControlChannelRawChanged(int chan,float val);
void parameterChanged(int uas, int component, QString parameterName, QVariant value);
// Signalled from FlightModeConfig UI
void saveButtonClicked(void);
private:
QMap<int,int> roverModeIndexToUiIndex;
QMap<int,int> planeModeIndexToUiIndex;
QMap<int,int> roverModeUiIndexToIndex;
QMap<int,int> planeModeUiIndexToIndex;
Ui::FlightModeConfig ui;
typedef struct {
const char* label;
int value;
} FlightModeInfo_t;
static const FlightModeInfo_t _rgModeInfoFixedWing[];
static const FlightModeInfo_t _rgModeInfoRotor[];
static const FlightModeInfo_t _rgModeInfoRover[];
const FlightModeInfo_t* _rgModeInfo;
size_t _cModeInfo;
static const size_t _cModes = 6;
static const char* _rgModeParamFixedWing[_cModes];
static const char* _rgModeParamRotor[_cModes];
static const char* _rgModeParamRover[_cModes];
const char** _rgModeParam;
static const int _rgModePWMBoundary[_cModes];
bool _simpleModeSupported;
static const char* _simpleModeBitMaskParam;
static const char* _modeSwitchRCChannelParamFixedWing;
static const char* _modeSwitchRCChannelParamRover;
const char* _modeSwitchRCChannelParam;
static const int _modeSwitchRCChannelRotor = 4; // ArduCopter harcoded to 0-based channel 4
static const int _modeSwitchRCChannelInvalid = -1;
int _modeSwitchRCChannel;
QLabel* _rgLabel[_cModes];
QComboBox* _rgCombo[_cModes];
QCheckBox* _rgSimpleModeCheckBox[_cModes];
QLabel* _rgPWMLabel[_cModes];
Ui::FlightModeConfig _ui;
};
#endif // FLIGHTMODECONFIG_H
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>818</width>
<height>359</height>
<height>435</height>
</rect>
</property>
<property name="windowTitle">
......@@ -40,15 +40,15 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="labelLayout">
<property name="spacing">
<number>8</number>
<number>-1</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_11">
<widget class="QLabel" name="mode0Label">
<property name="text">
<string>Flight Mode 1</string>
</property>
......@@ -58,7 +58,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="mode1Label">
<property name="text">
<string>Flight Mode 2</string>
</property>
......@@ -68,7 +68,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<widget class="QLabel" name="mode2Label">
<property name="text">
<string>Flight Mode 3</string>
</property>
......@@ -78,7 +78,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="mode3Label">
<property name="text">
<string>Flight Mode 4</string>
</property>
......@@ -88,7 +88,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<widget class="QLabel" name="mode4Label">
<property name="text">
<string>Flight Mode 5</string>
</property>
......@@ -98,7 +98,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_13">
<widget class="QLabel" name="mode5Label">
<property name="text">
<string>Flight Mode 6</string>
</property>
......@@ -110,21 +110,33 @@
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QVBoxLayout" name="comboLayout">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="mode1ComboBox">
<widget class="QComboBox" name="mode0ComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frame">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="mode2ComboBox">
<widget class="QComboBox" name="mode1ComboBox">
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="mode2ComboBox"/>
</item>
<item>
<widget class="QComboBox" name="mode3ComboBox"/>
</item>
......@@ -134,56 +146,53 @@
<item>
<widget class="QComboBox" name="mode5ComboBox"/>
</item>
<item>
<widget class="QComboBox" name="mode6ComboBox"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QVBoxLayout" name="simpleCheckBoxLayout">
<property name="spacing">
<number>8</number>
<number>12</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="mode1SimpleCheckBox">
<widget class="QCheckBox" name="mode0SimpleCheckBox">
<property name="text">
<string>Simple Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mode2SimpleCheckBox">
<widget class="QCheckBox" name="mode1SimpleCheckBox">
<property name="text">
<string>Simple Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mode3SimpleCheckBox">
<widget class="QCheckBox" name="mode2SimpleCheckBox">
<property name="text">
<string>Simple Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mode4SimpleCheckBox">
<widget class="QCheckBox" name="mode3SimpleCheckBox">
<property name="text">
<string>Simple Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mode5SimpleCheckBox">
<widget class="QCheckBox" name="mode4SimpleCheckBox">
<property name="text">
<string>Simple Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mode6SimpleCheckBox">
<widget class="QCheckBox" name="mode5SimpleCheckBox">
<property name="text">
<string>Simple Mode</string>
</property>
......@@ -192,9 +201,12 @@
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="PWMLabelLayout">
<property name="spacing">
<number>-1</number>
</property>
<item>
<widget class="QLabel" name="mode1Label">
<widget class="QLabel" name="mode0PWMLabel">
<property name="styleSheet">
<string notr="true"/>
</property>
......@@ -204,35 +216,35 @@
</widget>
</item>
<item>
<widget class="QLabel" name="mode2Label">
<widget class="QLabel" name="mode1PWMLabel">
<property name="text">
<string>PWM 1231 - 1360</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mode3Label">
<widget class="QLabel" name="mode2PWMLabel">
<property name="text">
<string>PWM 1361 - 1490</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mode4Label">
<widget class="QLabel" name="mode3PWMLabel">
<property name="text">
<string>PWM 1491 - 1620</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mode5Label">
<widget class="QLabel" name="mode4PWMLabel">
<property name="text">
<string>PWM 1621 - 1749</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mode6Label">
<widget class="QLabel" name="mode5PWMLabel">
<property name="styleSheet">
<string notr="true"/>
</property>
......
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