QGCCameraManager.h 2.56 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*!
 * @file
 *   @brief Camera Controller
 *   @author Gus Grubba <mavlink@grubba.com>
 *
 */

#pragma once

#include "QGCApplication.h"
#include <QLoggingCategory>
#include "QmlObjectListModel.h"
#include "QGCCameraControl.h"

#include <QObject>
#include <QTimer>

Q_DECLARE_LOGGING_CATEGORY(CameraManagerLog)

//-----------------------------------------------------------------------------
class QGCCameraManager : public QObject
{
    Q_OBJECT
public:
    QGCCameraManager(Vehicle* vehicle);
Gus Grubba's avatar
Gus Grubba committed
26
    virtual ~QGCCameraManager();
27

Gus Grubba's avatar
Gus Grubba committed
28 29 30
    Q_PROPERTY(QmlObjectListModel*  cameras             READ cameras            NOTIFY camerasChanged)
    Q_PROPERTY(QStringList          cameraLabels        READ cameraLabels       NOTIFY cameraLabelsChanged)
    Q_PROPERTY(int                  currentCamera       READ currentCamera      WRITE  setCurrentCamera     NOTIFY currentCameraChanged)
31 32

    //-- Return a list of cameras provided by this vehicle
Gus Grubba's avatar
Gus Grubba committed
33 34 35 36 37 38 39
    virtual QmlObjectListModel* cameras             () { return &_cameras; }
    //-- Camera names to show the user (for selection)
    virtual QStringList          cameraLabels       () { return _cameraLabels; }
    //-- Current selected camera
    virtual int                 currentCamera       () { return _currentCamera; }
    //-- Set current camera
    virtual void                setCurrentCamera    (int sel);
40 41

signals:
Gus Grubba's avatar
Gus Grubba committed
42 43 44
    void    camerasChanged          ();
    void    cameraLabelsChanged     ();
    void    currentCameraChanged    ();
45

Gus Grubba's avatar
Gus Grubba committed
46
protected slots:
Gus Grubba's avatar
Gus Grubba committed
47 48
    virtual void    _vehicleReady           (bool ready);
    virtual void    _mavlinkMessageReceived (const mavlink_message_t& message);
Gus Grubba's avatar
Gus Grubba committed
49 50

protected:
Gus Grubba's avatar
Gus Grubba committed
51 52 53 54 55 56 57 58 59
    virtual QGCCameraControl* _findCamera   (int id);
    virtual void    _requestCameraInfo      (int compID);
    virtual void    _handleHeartbeat        (const mavlink_message_t& message);
    virtual void    _handleCameraInfo       (const mavlink_message_t& message);
    virtual void    _handleStorageInfo      (const mavlink_message_t& message);
    virtual void    _handleCameraSettings   (const mavlink_message_t& message);
    virtual void    _handleParamAck         (const mavlink_message_t& message);
    virtual void    _handleParamValue       (const mavlink_message_t& message);
    virtual void    _handleCaptureStatus    (const mavlink_message_t& message);
60

Gus Grubba's avatar
Gus Grubba committed
61
protected:
62 63 64 65
    Vehicle*            _vehicle;
    bool                _vehicleReadyState;
    int                 _currentTask;
    QmlObjectListModel  _cameras;
Gus Grubba's avatar
Gus Grubba committed
66
    QStringList         _cameraLabels;
67
    QMap<int, bool>     _cameraInfoRequested;
Gus Grubba's avatar
Gus Grubba committed
68
    int                 _currentCamera;
69
};