SlugsPIDControl.h 7.06 KB
Newer Older
1 2 3 4
#ifndef SLUGSPIDCONTROL_H
#define SLUGSPIDCONTROL_H

#include <QWidget>
5
#include <QGroupBox>
6 7 8
#include "UASInterface.h"
#include "QGCMAVLink.h"
#include "SlugsMAV.h"
9
#include "mavlink.h"
10 11
#include <QTimer>
#include <QMutex>
12 13 14 15 16 17 18 19 20 21 22 23 24

namespace Ui {
    class SlugsPIDControl;
}

class SlugsPIDControl : public QWidget
{
    Q_OBJECT

public:
    explicit SlugsPIDControl(QWidget *parent = 0);
    ~SlugsPIDControl();

25
public slots:
26

27 28 29 30 31 32 33 34 35 36 37
    /**
     * @brief Called when the a new UAS is set to active.
     *
     * Called when the a new UAS is set to active.
     *
     * @param uas The new active UAS
     */
    void activeUasSet(UASInterface* uas);

    /**
     */
38
    void setRedColorStyle();
39 40 41 42 43
    /**
     * @brief Set color StyleSheet GREEN
     *
     * @param
     */
44 45
    void setGreenColorStyle();

46 47 48 49 50 51 52
    /**
     * @brief Connect Set pushButtons to change the color GroupBox
     *
     * @param
     */
    void connect_set_pushButtons();

53 54 55 56 57 58 59
    /**
     * @brief Connect Set pushButtons to change the color GroupBox
     *
     * @param
     */
    void connect_get_pushButtons();

60 61 62 63 64 65
    /**
     * @brief Connect Edition Lines for PID Values
     *
     * @param
     */
    void connect_editLinesPDIvalues();
66

67 68 69 70 71 72 73
    /**
     * @brief send a PDI request message to UAS
     *
     * @param
     */
    void sendMessagePIDStatus(int PIDtype);

74 75 76 77 78 79 80
// Fuctions for Air Speed GroupBox
    /**
     * @brief Change color style to red when PID values of Air Speed are edited
     *
     *
     * @param
     */
81
    void changeColor_RED_AirSpeed_groupBox(QString text);
82 83 84 85 86
    /**
     * @brief Change color style to green when PID values of Air Speed are send to UAS
     *
     * @param
     */
87 88 89 90 91 92
    void changeColor_GREEN_AirSpeed_groupBox();
    /**
     * @brief Connects the SIGNALS from the editline to SLOT changeColor_RED_AirSpeed_groupBox()
     *
     * @param
     */
93
    void connect_AirSpeed_LineEdit();
94 95 96 97 98 99 100
    /**
     * @brief get message PID Air Speed(loop index = 0) from UAS
     *
     * @param
     */
    void get_AirSpeed_PID();

101

102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
// Functions for Pitch Followei GroupBox
    /**
     * @brief Change color style to red when PID values of Pitch Followei are edited
     *
     *
     * @param
     */
     void changeColor_RED_PitchFollowei_groupBox(QString text);
     /**
         * @brief Change color style to green when PID values of Pitch Followei are send to UAS
         *
         * @param
         */
     void changeColor_GREEN_PitchFollowei_groupBox();
     /**
         * @brief Connects the SIGNALS from the editline to SLOT PitchFlowei_groupBox
         *
         * @param
         */
     void connect_PitchFollowei_LineEdit();
122 123 124 125 126 127 128
     /**
      * @brief get message PID Pitch Followei(loop index = 2) from UAS
      *
      * @param
      */
     void get_PitchFollowei_PID();

129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149

     // Functions for Roll Control GroupBox
     /**
          * @brief Change color style to red when PID values of Roll Control are edited
          *
          *
          * @param
          */
     void changeColor_RED_RollControl_groupBox(QString text);
     /**
              * @brief Change color style to green when PID values of Roll Control are send to UAS
              *
              * @param
              */
     void changeColor_GREEN_RollControl_groupBox();
     /**
              * @brief Connects the SIGNALS from the editline to SLOT RollControl_groupBox
              *
              * @param
              */
     void connect_RollControl_LineEdit();
150 151 152 153 154 155 156
     /**
      * @brief get message PID Roll Control(loop index = 4) from UAS
      *
      * @param
      */
     void get_RollControl_PID();

157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177

     // Functions for Heigth Error GroupBox
     /**
          * @brief Change color style to red when PID values of Heigth Error are edited
          *
          *
          * @param
          */
     void changeColor_RED_HeigthError_groupBox(QString text);
     /**
              * @brief Change color style to green when PID values of Heigth Error are send to UAS
              *
              * @param
              */
     void changeColor_GREEN_HeigthError_groupBox();
     /**
              * @brief Connects the SIGNALS from the editline to SLOT HeigthError_groupBox
              *
              * @param
              */
     void connect_HeigthError_LineEdit();
178 179 180 181 182 183
     /**
      * @brief get message PID Heigth Error(loop index = 1) from UAS
      *
      * @param
      */
     void get_HeigthError_PID();
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204

     // Functions for Yaw Damper GroupBox
     /**
          * @brief Change color style to red when PID values of Yaw Damper are edited
          *
          *
          * @param
          */
     void changeColor_RED_YawDamper_groupBox(QString text);
     /**
              * @brief Change color style to green when PID values of Yaw Damper are send to UAS
              *
              * @param
              */
     void changeColor_GREEN_YawDamper_groupBox();
     /**
              * @brief Connects the SIGNALS from the editline to SLOT YawDamper_groupBox
              *
              * @param
              */
     void connect_YawDamper_LineEdit();
205 206 207 208 209 210 211 212
     /**
      * @brief get message PID Yaw Damper(loop index = 3) from UAS
      *
      * @param
      */
     void get_YawDamper_PID();


213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233

     // Functions for Pitch to dT GroupBox
     /**
          * @brief Change color style to red when PID values of Pitch to dT are edited
          *
          *
          * @param
          */
     void changeColor_RED_Pitch2dT_groupBox(QString text);
     /**
              * @brief Change color style to green when PID values of Pitch to dT are send to UAS
              *
              * @param
              */
     void changeColor_GREEN_Pitch2dT_groupBox();
     /**
              * @brief Connects the SIGNALS from the editline to SLOT Pitch2dT_groupBox
              *
              * @param
              */
     void connect_Pitch2dT_LineEdit();
234 235 236 237 238 239
     /**
      * @brief get message PID Pitch2dT(loop index = 8) from UAS
      *
      * @param
      */
     void get_Pitch2dT_PID();
240

241 242 243 244 245 246 247 248 249 250 251 252 253 254
     /**
          * @brief get and updates the values on widget
     */
      void slugsGetGeneral();
      /**
           * @brief Sent all values to UAS
      */
       void slugsSetGeneral();

       void slugsTimerStartSet();
       void slugsTimerStartGet();
       void slugsTimerStop();


255 256 257

     //Create, send and get Messages PID
    // void createMessagePID();
258
#ifdef MAVLINK_ENABLED_SLUGS
259

260
     void recibeMensaje(int systemId, const mavlink_action_ack_t& action);
261
     void receivePidValues(int systemId, const mavlink_pid_t& pidValues);
262

263
#endif // MAVLINK_ENABLED_SLUG
264

265 266
private:
    Ui::SlugsPIDControl *ui;
267 268 269 270

     UASInterface* activeUAS;
     int systemId;

271 272
    bool change_dT;

273

274 275 276 277
    //Color Styles
    QString REDcolorStyle;
    QString GREENcolorStyle;
    QString ORIGINcolorStyle;
278 279

    //SlugsMav Message
280
    #ifdef MAVLINK_ENABLED_SLUGS
281
    mavlink_pid_t pidMessage;
282
    mavlink_slugs_action_t actionSlugs;
283
#endif
284 285

    QTimer* refreshTimerSet;      ///< The main timer, controls the update view
286
    QTimer* refreshTimerGet;      ///< The main timer, controls the update view
287 288
    int counterRefreshSet;
    int counterRefreshGet;
289
    QMutex valuesMutex;
290 291 292
};

#endif // SLUGSPIDCONTROL_H