PositionManager.h 2.25 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8
 *
 * 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
    int                 _updateInterval =   0;
60 61
    QGeoPositionInfo    _geoPositionInfo;
    QGeoCoordinate      _gcsPosition;
62
    qreal               _gcsHeading =       qQNaN();
63

64 65 66 67 68
    QGeoPositionInfoSource*     _currentSource =        nullptr;
    QGeoPositionInfoSource*     _defaultSource =        nullptr;
    QNmeaPositionInfoSource*    _nmeaSource =           nullptr;
    QGeoPositionInfoSource*     _simulatedSource =      nullptr;
    bool                        _usingPluginSource =    false;
Jimmy Johnson's avatar
Jimmy Johnson committed
69
};