QGCParamWidget.h 3.19 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/*=====================================================================

QGroundControl Open Source Ground Control Station

(c) 2009, 2010 QGROUNDCONTROL/PIXHAWK PROJECT
<http://www.qgroundcontrol.org>
<http://pixhawk.ethz.ch>

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
32 33 34 35 36 37 38 39 40 41
#ifndef QGCPARAMWIDGET_H
#define QGCPARAMWIDGET_H

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

#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);
pixhawk's avatar
pixhawk committed
55
public slots:
56 57 58 59 60 61 62 63 64 65 66 67
    /** @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();
68 69
    /** @brief Read the parameters from permanent storage to RAM */
    void readParameters();
70
    /** @brief Clear the parameter list */
pixhawk's avatar
pixhawk committed
71
    void clear();
lm's avatar
lm committed
72
    /** @brief Update when user changes parameters */
73
    void parameterItemChanged(QTreeWidgetItem* prev, int column);
74 75 76 77 78

    /** @brief Store parameters to a file */
    void saveParameters();
    /** @brief Load parameters from a file */
    void loadParameters();
pixhawk's avatar
pixhawk committed
79
protected:
80 81 82
    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
83
    QMap<int, QMap<QString, QTreeWidgetItem*>* > paramGroups; ///< Parameter groups
lm's avatar
lm committed
84
    QMap<int, QMap<QString, float>* > changedValues; ///< Changed values
85
    QMap<int, QMap<QString, float>* > parameters; ///< All parameters
pixhawk's avatar
pixhawk committed
86 87 88 89

};

#endif // QGCPARAMWIDGET_H