PositionManager.h 1.83 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
Jimmy Johnson's avatar
Jimmy Johnson committed
9 10 11

#pragma once

12
#include <QGeoPositionInfoSource>
13
#include <QNmeaPositionInfoSource>
Jimmy Johnson's avatar
Jimmy Johnson committed
14 15 16 17 18 19 20 21 22 23 24

#include <QVariant>

#include "QGCToolbox.h"
#include "SimulatedPosition.h"

class QGCPositionManager : public QGCTool {
    Q_OBJECT

public:

25
    QGCPositionManager(QGCApplication* app, QGCToolbox* toolbox);
Jimmy Johnson's avatar
Jimmy Johnson committed
26 27
    ~QGCPositionManager();

28 29
    Q_PROPERTY(QGeoCoordinate gcsPosition  READ gcsPosition  NOTIFY gcsPositionChanged)
    Q_PROPERTY(qreal          gcsHeading   READ gcsHeading   NOTIFY gcsHeadingChanged)
30

Jimmy Johnson's avatar
Jimmy Johnson committed
31 32
    enum QGCPositionSource {
        Simulated,
33 34 35
        InternalGPS,
        Log,
        NmeaGPS
Jimmy Johnson's avatar
Jimmy Johnson committed
36 37
    };

38 39
    QGeoCoordinate gcsPosition(void) { return _gcsPosition; }

40 41
    qreal gcsHeading() { return _gcsHeading; }

Jimmy Johnson's avatar
Jimmy Johnson committed
42 43 44 45
    void setPositionSource(QGCPositionSource source);

    int updateInterval() const;

46 47
    void setToolbox(QGCToolbox* toolbox);

48 49
    void setNmeaSourceDevice(QIODevice* device);

Jimmy Johnson's avatar
Jimmy Johnson committed
50
private slots:
51 52
    void _positionUpdated(const QGeoPositionInfo &update);
    void _error(QGeoPositionInfoSource::Error positioningError);
Jimmy Johnson's avatar
Jimmy Johnson committed
53 54

signals:
55
    void gcsPositionChanged(QGeoCoordinate gcsPosition);
56
    void gcsHeadingChanged(qreal gcsHeading);
Jimmy Johnson's avatar
Jimmy Johnson committed
57 58 59
    void positionInfoUpdated(QGeoPositionInfo update);

private:
60 61
    int             _updateInterval;
    QGeoCoordinate  _gcsPosition;
62
    qreal           _gcsHeading;
63 64 65 66 67

    QGeoPositionInfoSource*     _currentSource;
    QGeoPositionInfoSource*     _defaultSource;
    QNmeaPositionInfoSource*    _nmeaSource;
    QGeoPositionInfoSource*     _simulatedSource;
Jimmy Johnson's avatar
Jimmy Johnson committed
68
};