QGCUASParamManager.h 3.18 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 10 11 12 13 14 15 16

class UASInterface;

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

17 18 19
    QList<QString> getParameterNames(int component) const {
        return parameters.value(component)->keys();
    }
20
    QList<QVariant> getParameterValues(int component) const {
21 22
        return parameters.value(component)->values();
    }
23 24 25 26 27 28 29 30 31 32 33 34 35 36
    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;
37
    }
38

LM's avatar
LM committed
39 40 41 42 43 44
    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
45
    virtual QString getParamInfo(const QString& param) = 0;
46
    virtual void setParamInfo(const QMap<QString,QString>& param) = 0;
LM's avatar
LM committed
47

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

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

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

protected:
    UASInterface* mav;   ///< The MAV this widget is controlling
66 67
    QMap<int, QMap<QString, QVariant>* > changedValues; ///< Changed values
    QMap<int, QMap<QString, QVariant>* > parameters; ///< All parameters
68 69
    QVector<bool> received; ///< Successfully received parameters
    QMap<int, QList<int>* > transmissionMissingPackets; ///< Missing packets
70
    QMap<int, QMap<QString, QVariant>* > transmissionMissingWriteAckPackets; ///< Missing write ACK packets
71 72 73 74 75 76 77 78 79 80 81 82
    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