QGCParamWidget.h 3.83 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>
pixhawk's avatar
pixhawk committed
38 39 40

#include "UASInterface.h"

41 42 43
/**
 * @brief Widget to read/set onboard parameters
 */
pixhawk's avatar
pixhawk committed
44 45 46 47 48
class QGCParamWidget : public QWidget
{
Q_OBJECT
public:
    explicit QGCParamWidget(UASInterface* uas, QWidget *parent = 0);
49
    /** @brief Get the UAS of this widget */
pixhawk's avatar
pixhawk committed
50 51
    UASInterface* getUAS();
signals:
52
    /** @brief A parameter was changed in the widget, NOT onboard */
53
    void parameterChanged(int component, QString parametername, float value);
pixhawk's avatar
pixhawk committed
54
public slots:
55 56
    /** @brief Add a component to the list */
    void addComponent(int uas, int component, QString componentName);
lm's avatar
lm committed
57 58
    /** @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);
59 60 61 62 63 64 65 66 67 68
    /** @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();
69 70
    /** @brief Read the parameters from permanent storage to RAM */
    void readParameters();
71
    /** @brief Clear the parameter list */
pixhawk's avatar
pixhawk committed
72
    void clear();
lm's avatar
lm committed
73
    /** @brief Update when user changes parameters */
74
    void parameterItemChanged(QTreeWidgetItem* prev, int column);
75 76 77 78 79

    /** @brief Store parameters to a file */
    void saveParameters();
    /** @brief Load parameters from a file */
    void loadParameters();
pixhawk's avatar
pixhawk committed
80
protected:
lm's avatar
lm committed
81 82 83
    UASInterface* mav;   ///< The MAV this widget is controlling
    QTreeWidget* tree;   ///< The parameter tree
    QLabel* statusLabel; ///< Parameter transmission label
84
    QMap<int, QTreeWidgetItem*>* components; ///< The list of components
pixhawk's avatar
pixhawk committed
85
    QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups
lm's avatar
lm committed
86
    QMap<int, QMap<QString, float>* > changedValues; ///< Changed values
87
    QMap<int, QMap<QString, float>* > parameters; ///< All parameters
lm's avatar
lm committed
88
    QVector<bool> received; ///< Successfully received parameters
lm's avatar
lm committed
89 90 91 92 93
    QMap<int, QList<int>* > transmissionMissingPackets; ///< Missing packets
    bool transmissionListMode;       ///< Currently requesting list
    QMap<int, bool> transmissionListSizeKnown;  ///< List size initialized?
    bool transmissionActive;         ///< Missing packets, working on list?
    quint64 transmissionStarted;     ///< Timeout
pixhawk's avatar
pixhawk committed
94 95 96
};

#endif // QGCPARAMWIDGET_H