Skip to content
UASWaypointManager.h 1.97 KiB
Newer Older
#ifndef UASWAYPOINTMANAGER_H
#define UASWAYPOINTMANAGER_H

#include <QObject>
#include <QVector>
#include "Waypoint.h"
pixhawk's avatar
pixhawk committed
#include <mavlink.h>
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
    void handleWaypoint(quint8 systemId, quint8 compId, mavlink_waypoint_t *wp);
pixhawk's avatar
pixhawk committed
    void handleWaypointRequest(quint8 systemId, quint8 compId, mavlink_waypoint_request_t *wpr);
    void sendWaypointRequest(quint16 seq);

public slots:
pixhawk's avatar
pixhawk committed
    void clearWaypointList();
    void currentWaypointChanged(quint16);
    void removeWaypointId(quint16);
    void requestWaypoints();
    void sendWaypoints(const QVector<Waypoint *> &list);
pixhawk's avatar
pixhawk committed
    void waypointChanged(Waypoint*);
pixhawk's avatar
pixhawk committed
signals:
    void waypointUpdated(int,quint16,double,double,double,double,bool,bool);    ///< Adds a waypoint to the waypoint list widget
    void updateStatusString(const QString &);                         ///< updates the current status string
pixhawk's avatar
pixhawk committed

private:
    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
};

#endif // UASWAYPOINTMANAGER_H