PositionManager.h 1.62 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)

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

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

Jimmy Johnson's avatar
Jimmy Johnson committed
39 40 41 42
    void setPositionSource(QGCPositionSource source);

    int updateInterval() const;

43 44
    void setToolbox(QGCToolbox* toolbox);

45 46
    void setNmeaSourceDevice(QIODevice* device);

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

signals:
52
    void gcsPositionChanged(QGeoCoordinate gcsPosition);
Jimmy Johnson's avatar
Jimmy Johnson committed
53 54 55
    void positionInfoUpdated(QGeoPositionInfo update);

private:
56 57 58 59 60 61 62
    int             _updateInterval;
    QGeoCoordinate  _gcsPosition;

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