QGCUASParamManager.h 3.34 KB
Newer Older
1 2 3 4 5 6
#ifndef QGCUASPARAMMANAGER_H
#define QGCUASPARAMMANAGER_H

#include <QWidget>
#include <QMap>
#include <QTimer>
7
#include <QVariant>
8 9

class UASInterface;
10
class UASParameterDataModel;
11 12 13 14 15 16 17

class QGCUASParamManager : public QWidget
{
    Q_OBJECT
public:
    QGCUASParamManager(UASInterface* uas, QWidget *parent = 0);

18 19 20
    QList<QString> getParameterNames(int component) const {
        return parameters.value(component)->keys();
    }
21
    QList<QVariant> getParameterValues(int component) const {
22 23
        return parameters.value(component)->values();
    }
24 25 26 27 28 29 30 31 32 33 34 35 36 37
    bool getParameterValue(int component, const QString& parameter, QVariant& value) const {
        if (!parameters.contains(component))
        {
            return false;
        }

        if (!parameters.value(component)->contains(parameter))
        {
            return false;
        }

        value = parameters.value(component)->value(parameter);

        return true;
38
    }
39

LM's avatar
LM committed
40 41 42 43 44 45
    virtual bool isParamMinKnown(const QString& param) = 0;
    virtual bool isParamMaxKnown(const QString& param) = 0;
    virtual bool isParamDefaultKnown(const QString& param) = 0;
    virtual double getParamMin(const QString& param) = 0;
    virtual double getParamMax(const QString& param) = 0;
    virtual double getParamDefault(const QString& param) = 0;
Lorenz Meier's avatar
Lorenz Meier committed
46
    virtual QString getParamInfo(const QString& param) = 0;
47
    virtual void setParamInfo(const QMap<QString,QString>& param) = 0;
LM's avatar
LM committed
48

49 50 51
    /** @brief Request an update for the parameter list */
    void requestParameterListUpdate(int component = 0);
    /** @brief Request an update for this specific parameter */
52
    virtual void requestParameterUpdate(int component, const QString& parameter) = 0;
53

54
signals:
55 56
    void parameterChanged(int component, QString parameter, QVariant value);
    void parameterChanged(int component, int parameterIndex, QVariant value);
57 58 59
    void parameterListUpToDate(int component);

public slots:
60
    /** @brief Write one parameter to the MAV */
61
    virtual void setParameter(int component, QString parameterName, QVariant value) = 0;
62 63
    /** @brief Request list of parameters from MAV */
    virtual void requestParameterList() = 0;
64 65

protected:
66 67

    //Parameter data model
68
    UASInterface* mav;   ///< The MAV this widget is controlling
69
//    QMap<int, QMap<QString, QVariant>* > changedValues; ///< Changed values
70
    QMap<int, QMap<QString, QVariant>* > parameters; ///< All parameters
71 72 73
    UASParameterDataModel* paramDataModel;///< Shared data model of parameters

    // Communications management
74 75
    QVector<bool> received; ///< Successfully received parameters
    QMap<int, QList<int>* > transmissionMissingPackets; ///< Missing packets
76
    QMap<int, QMap<QString, QVariant>* > transmissionMissingWriteAckPackets; ///< Missing write ACK packets
77 78 79 80 81 82 83 84 85 86 87 88
    bool transmissionListMode;       ///< Currently requesting list
    QMap<int, bool> transmissionListSizeKnown;  ///< List size initialized?
    bool transmissionActive;         ///< Missing packets, working on list?
    quint64 transmissionTimeout;     ///< Timeout
    QTimer retransmissionTimer;      ///< Timer handling parameter retransmission
    int retransmissionTimeout; ///< Retransmission request timeout, in milliseconds
    int rewriteTimeout; ///< Write request timeout, in milliseconds
    int retransmissionBurstRequestSize; ///< Number of packets requested for retransmission per burst

};

#endif // QGCUASPARAMMANAGER_H