dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
vehicleconfig.h
Go to the documentation of this file.
1 
12 /*
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  * for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, see <http://www.gnu.org/licenses/>
25  */
26 #ifndef GUIVEHICLECONFIG_H
27 #define GUIVEHICLECONFIG_H
28 
29 #ifdef _MSC_VER
30 #define PACK(__Declaration__) __pragma(pack(push, 1)) __Declaration__ __pragma(pack(pop))
31 #else
32 #define PACK(__Declaration__) __Declaration__ __attribute__((__packed__))
33 #endif
34 
38 #include "uavobjects/uavobject.h"
39 #include "mixersettings.h"
40 #include "systemsettings.h"
41 
42 #include <QComboBox>
43 
44 PACK(typedef struct {
45  uint VTOLMotorN : 4;
46  uint VTOLMotorS : 4;
47  uint VTOLMotorE : 4;
48  uint VTOLMotorW : 4;
49  uint VTOLMotorNW : 4;
50  uint VTOLMotorNE : 4;
51  uint VTOLMotorSW : 4;
52  uint VTOLMotorSE : 4; // 32bits
53  uint TRIYaw : 4;
54  quint32 padding : 28; // 64bits
55  quint32 padding1;
56  quint32 padding2; // 128bits
57 })
58 multiGUISettingsStruct;
59 
60 PACK(typedef struct {
61  uint SwashplateType : 3;
62  uint FirstServoIndex : 2;
63  uint CorrectionAngle : 9;
64  uint ccpmCollectivePassthroughState : 1;
65  uint ccpmLinkCyclicState : 1;
66  uint ccpmLinkRollState : 1;
67  uint SliderValue0 : 7;
68  uint SliderValue1 : 7;
69  uint SliderValue2 : 7; // 41bits
70  uint ServoIndexW : 4;
71  uint ServoIndexX : 4;
72  uint ServoIndexY : 4;
73  uint ServoIndexZ : 4; // 57bits
74  uint Throttle : 4;
75  uint Tail : 4; // 65bits
76  quint32 padding : 31; // 96bits
77  quint32 padding1; // 128bits
78 })
79 heliGUISettingsStruct;
80 
81 PACK(typedef struct {
82  uint FixedWingThrottle : 4;
83  uint FixedWingRoll1 : 4;
84  uint FixedWingRoll2 : 4;
85  uint FixedWingPitch1 : 4;
86  uint FixedWingPitch2 : 4;
87  uint FixedWingYaw1 : 4;
88  uint FixedWingYaw2 : 4;
89  uint padding : 4; // 32bits
90  quint32 padding1;
91  quint32 padding2;
92  quint32 padding3; // 128bits
93 })
94 fixedGUISettingsStruct;
95 
96 PACK(typedef struct {
97  uint GroundVehicleThrottle1 : 4;
98  uint GroundVehicleThrottle2 : 4;
99  uint GroundVehicleSteering1 : 4;
100  uint GroundVehicleSteering2 : 4;
101  uint padding : 16; // 32bits
102  quint32 padding1;
103  quint32 padding2;
104  quint32 padding3; // 128bits
105 })
106 groundGUISettingsStruct;
107 
108 typedef union {
109  uint UAVObject[4]; // 32bits * 4
110  heliGUISettingsStruct heli; // 128bits
111  fixedGUISettingsStruct fixedwing;
112  multiGUISettingsStruct multi;
113  groundGUISettingsStruct ground;
115 
117 {
118  Q_OBJECT
119 
120 public:
121  VehicleConfig(QWidget *parent = nullptr);
122  ~VehicleConfig();
123 
125  static void SetConfigData(GUIConfigDataUnion configData,
126  SystemSettings::AirframeTypeOptions vehicle);
127  static void resetField(UAVObjectField *field);
128  static void setComboCurrentIndex(QComboBox *box, int index);
129  static void enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable);
130  double getMixerVectorValue(UAVDataObject *mixer, int channel,
131  MixerSettings::Mixer1VectorElem elementName);
132  void setMixerVectorValue(UAVDataObject *mixer, int channel,
133  MixerSettings::Mixer1VectorElem elementName, double value);
134  void resetMixerVector(UAVDataObject *mixer, int channel);
135  void resetMixers(UAVDataObject *mixer);
136  QString getMixerType(UAVDataObject *mixer, int channel);
137  void setMixerType(UAVDataObject *mixer, int channel,
138  MixerSettings::Mixer1TypeOptions mixerType);
139  double getMixerValue(UAVDataObject *mixer, QString elementName);
140  void setMixerValue(UAVDataObject *mixer, QString elementName, double value);
141  void setThrottleCurve(UAVDataObject *mixer, MixerSettings::Mixer1VectorElem curveType,
142  QList<double> curve);
143  void getThrottleCurve(UAVDataObject *mixer, MixerSettings::Mixer1VectorElem curveType,
144  QList<double> *curve);
145  bool isValidThrottleCurve(QList<double> *curve);
146  double getCurveMin(QList<double> *curve);
147  double getCurveMax(QList<double> *curve);
148  virtual void ResetActuators(GUIConfigDataUnion *configData);
149 
150  QStringList channelNames;
151  QStringList mixerTypes;
152  QStringList mixerVectors;
154 
155  const static double mixerScale;
156  const static double mixerRange;
157 
158 protected:
159  void setLabelText(QWidget *owner, const QString &boxName, const QStringList &labels);
160 
161 private:
162  static UAVObjectManager *getUAVObjectManager();
163 
164 private slots:
165 
166 public slots:
167 
168 signals:
169  // void ConfigurationChanged();
170 
171 protected:
172 };
173 #endif // GUIVEHICLECONFIG_H
VehicleConfig(QWidget *parent=nullptr)
QStringList mixerTypes
QStringList mixerTypeDescriptions
QString getMixerType(UAVDataObject *mixer, int channel)
static void SetConfigData(GUIConfigDataUnion configData, SystemSettings::AirframeTypeOptions vehicle)
static GUIConfigDataUnion GetConfigData()
static void resetField(UAVObjectField *field)
static const double mixerRange
PACK(typedef struct{uint VTOLMotorN:4;uint VTOLMotorS:4;uint VTOLMotorE:4;uint VTOLMotorW:4;uint VTOLMotorNW:4;uint VTOLMotorNE:4;uint VTOLMotorSW:4;uint VTOLMotorSE:4;uint TRIYaw:4;quint32 padding:28;quint32 padding1;quint32 padding2;}) multiGUISettingsStruct
bool isValidThrottleCurve(QList< double > *curve)
double getMixerVectorValue(UAVDataObject *mixer, int channel, MixerSettings::Mixer1VectorElem elementName)
groundGUISettingsStruct ground
fixedGUISettingsStruct fixedwing
virtual void ResetActuators(GUIConfigDataUnion *configData)
void getThrottleCurve(UAVDataObject *mixer, MixerSettings::Mixer1VectorElem curveType, QList< double > *curve)
double getMixerValue(UAVDataObject *mixer, QString elementName)
void resetMixerVector(UAVDataObject *mixer, int channel)
void resetMixers(UAVDataObject *mixer)
void setMixerType(UAVDataObject *mixer, int channel, MixerSettings::Mixer1TypeOptions mixerType)
QStringList mixerVectors
QStringList channelNames
heliGUISettingsStruct heli
multiGUISettingsStruct multi
void setMixerVectorValue(UAVDataObject *mixer, int channel, MixerSettings::Mixer1VectorElem elementName, double value)
static void enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable)
void setThrottleCurve(UAVDataObject *mixer, MixerSettings::Mixer1VectorElem curveType, QList< double > curve)
double getCurveMax(QList< double > *curve)
void setMixerValue(UAVDataObject *mixer, QString elementName, double value)
void setLabelText(QWidget *owner, const QString &boxName, const QStringList &labels)
static const double mixerScale
double getCurveMin(QList< double > *curve)
static void setComboCurrentIndex(QComboBox *box, int index)