PositionManager.h 2.1 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 40 41 42 43
    QGeoCoordinate      gcsPosition         (void) { return _gcsPosition; }
    qreal               gcsHeading          (void) { return _gcsHeading; }
    QGeoPositionInfo    geoPositionInfo     (void) const { return _geoPositionInfo; }
    void                setPositionSource   (QGCPositionSource source);
    int                 updateInterval      (void) const;
    void                setNmeaSourceDevice (QIODevice* device);
44

45 46
    // Overrides from QGCTool
    void setToolbox(QGCToolbox* toolbox) override;
47

48

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

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

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

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