UASWaypointManager.h 2.01 KB
Newer Older
1 2 3 4
#ifndef UASWAYPOINTMANAGER_H
#define UASWAYPOINTMANAGER_H

#include <QObject>
5
#include <QVector>
6
#include "Waypoint.h"
pixhawk's avatar
pixhawk committed
7
#include <mavlink.h>
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
class UAS;

class UASWaypointManager : public QObject
{
Q_OBJECT
private:
    enum WaypointState {
        WP_IDLE = 0,
        WP_SENDLIST,
        WP_SENDLIST_SENDWPS,
        WP_GETLIST,
        WP_GETLIST_GETWPS
    }; ///< The possible states for the waypoint protocol

public:
    UASWaypointManager(UAS&);

    void handleWaypointCount(quint8 systemId, quint8 compId, quint16 count);
pixhawk's avatar
pixhawk committed
26
    void handleWaypoint(quint8 systemId, quint8 compId, mavlink_waypoint_t *wp);
pixhawk's avatar
pixhawk committed
27
    void handleWaypointRequest(quint8 systemId, quint8 compId, mavlink_waypoint_request_t *wpr);
28 29

private:
30
    void sendWaypointRequest(quint16 seq);
pixhawk's avatar
pixhawk committed
31
    void sendWaypoint(quint16 seq);
32 33

public slots:
pixhawk's avatar
pixhawk committed
34
    void clearWaypointList();
35 36
    void currentWaypointChanged(quint16);
    void removeWaypointId(quint16);
37
    void requestWaypoints();
38
    void sendWaypoints(const QVector<Waypoint *> &list);
pixhawk's avatar
pixhawk committed
39
    void waypointChanged(Waypoint*);
40

pixhawk's avatar
pixhawk committed
41
signals:
42
    void waypointUpdated(int,quint16,double,double,double,double,bool,bool);    ///< Adds a waypoint to the waypoint list widget
43
    void updateStatusString(const QString &);                         ///< updates the current status string
pixhawk's avatar
pixhawk committed
44

45
private:
46 47 48 49 50 51 52 53
    UAS &uas;                                       ///< Reference to the corresponding UAS
    quint16 current_wp_id;                          ///< The last used waypoint ID in the current protocol transaction
    quint16 current_count;                          ///< The number of waypoints in the current protocol transaction
    WaypointState current_state;                    ///< The current protocol state
    quint8 current_partner_systemid;                ///< The current protocol communication target system
    quint8 current_partner_compid;                  ///< The current protocol communication target component

    QVector<mavlink_waypoint_t *> waypoint_buffer;  ///< communication buffer for waypoints
54 55 56
};

#endif // UASWAYPOINTMANAGER_H