QGCUASParamManager.h 3.05 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 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;

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

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

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

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