QGCParamWidget.h 4.63 KB
Newer Older
1 2 3 4
/*=====================================================================

QGroundControl Open Source Ground Control Station

5
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

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/>.

======================================================================*/

/**
 * @file
 *   @brief Declaration of class QGCParamWidget
 *   @author Lorenz Meier <mail@qgroundcontrol.org>
 */

pixhawk's avatar
pixhawk committed
30 31 32 33 34 35 36
#ifndef QGCPARAMWIDGET_H
#define QGCPARAMWIDGET_H

#include <QWidget>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QMap>
lm's avatar
lm committed
37
#include <QLabel>
38
#include <QTimer>
pixhawk's avatar
pixhawk committed
39 40 41

#include "UASInterface.h"

42 43 44
/**
 * @brief Widget to read/set onboard parameters
 */
pixhawk's avatar
pixhawk committed
45 46 47 48 49
class QGCParamWidget : public QWidget
{
Q_OBJECT
public:
    explicit QGCParamWidget(UASInterface* uas, QWidget *parent = 0);
50
    /** @brief Get the UAS of this widget */
pixhawk's avatar
pixhawk committed
51 52
    UASInterface* getUAS();
signals:
53
    /** @brief A parameter was changed in the widget, NOT onboard */
54
    void parameterChanged(int component, QString parametername, float value);
55 56
    /** @brief Request a single parameter */
    void requestParameter(int component, int parameter);
pixhawk's avatar
pixhawk committed
57
public slots:
58 59
    /** @brief Add a component to the list */
    void addComponent(int uas, int component, QString componentName);
lm's avatar
lm committed
60 61
    /** @brief Add a parameter to the list with retransmission / safety checks */
    void addParameter(int uas, int component, int paramCount, int paramId, QString parameterName, float value);
62 63 64 65 66 67 68 69 70 71
    /** @brief Add a parameter to the list */
    void addParameter(int uas, int component, QString parameterName, float value);
    /** @brief Request list of parameters from MAV */
    void requestParameterList();
    /** @brief Set one parameter, changes value in RAM of MAV */
    void setParameter(int component, QString parameterName, float value);
    /** @brief Set all parameters, changes the value in RAM of MAV */
    void setParameters();
    /** @brief Write the current parameters to permanent storage (EEPROM/HDD) */
    void writeParameters();
72 73
    /** @brief Read the parameters from permanent storage to RAM */
    void readParameters();
74
    /** @brief Clear the parameter list */
pixhawk's avatar
pixhawk committed
75
    void clear();
lm's avatar
lm committed
76
    /** @brief Update when user changes parameters */
77
    void parameterItemChanged(QTreeWidgetItem* prev, int column);
78 79 80 81 82

    /** @brief Store parameters to a file */
    void saveParameters();
    /** @brief Load parameters from a file */
    void loadParameters();
83 84 85 86

    /** @brief Check for missing parameters */
    void retransmissionGuardTick();

pixhawk's avatar
pixhawk committed
87
protected:
lm's avatar
lm committed
88 89 90
    UASInterface* mav;   ///< The MAV this widget is controlling
    QTreeWidget* tree;   ///< The parameter tree
    QLabel* statusLabel; ///< Parameter transmission label
91
    QMap<int, QTreeWidgetItem*>* components; ///< The list of components
pixhawk's avatar
pixhawk committed
92
    QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups
lm's avatar
lm committed
93
    QMap<int, QMap<QString, float>* > changedValues; ///< Changed values
94
    QMap<int, QMap<QString, float>* > parameters; ///< All parameters
lm's avatar
lm committed
95
    QVector<bool> received; ///< Successfully received parameters
lm's avatar
lm committed
96
    QMap<int, QList<int>* > transmissionMissingPackets; ///< Missing packets
lm's avatar
lm committed
97
    QMap<int, QMap<QString, float>* > transmissionMissingWriteAckPackets; ///< Missing write ACK packets
lm's avatar
lm committed
98 99 100
    bool transmissionListMode;       ///< Currently requesting list
    QMap<int, bool> transmissionListSizeKnown;  ///< List size initialized?
    bool transmissionActive;         ///< Missing packets, working on list?
lm's avatar
lm committed
101
    quint64 transmissionTimeout;     ///< Timeout
102
    QTimer retransmissionTimer;      ///< Timer handling parameter retransmission
103 104
    int retransmissionTimeout; ///< Retransmission request timeout, in milliseconds
    int rewriteTimeout; ///< Write request timeout, in milliseconds
lm's avatar
lm committed
105
    int retransmissionBurstRequestSize; ///< Number of packets requested for retransmission per burst
106 107 108

    /** @brief Activate / deactivate parameter retransmission */
    void setRetransmissionGuardEnabled(bool enabled);
109 110
    /** @brief Load  settings */
    void loadSettings();
pixhawk's avatar
pixhawk committed
111 112 113
};

#endif // QGCPARAMWIDGET_H