QGCParamWidget.h 3.22 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 37 38 39
#ifndef QGCPARAMWIDGET_H
#define QGCPARAMWIDGET_H

#include <QWidget>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QMap>

#include "UASInterface.h"

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

    /** @brief Store parameters to a file */
    void saveParameters();
    /** @brief Load parameters from a file */
    void loadParameters();
pixhawk's avatar
pixhawk committed
77
protected:
78 79 80
    UASInterface* mav;  ///< The MAV this widget is controlling
    QTreeWidget* tree;  ///< The parameter tree
    QMap<int, QTreeWidgetItem*>* components; ///< The list of components
pixhawk's avatar
pixhawk committed
81
    QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups
lm's avatar
lm committed
82
    QMap<int, QMap<QString, float>* > changedValues; ///< Changed values
83
    QMap<int, QMap<QString, float>* > parameters; ///< All parameters
lm's avatar
lm committed
84
    QVector<bool> received; ///< Successfully received parameters
pixhawk's avatar
pixhawk committed
85 86 87 88

};

#endif // QGCPARAMWIDGET_H