PositionManager.h 1.43 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 28 29
    ~QGCPositionManager();

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

    void setPositionSource(QGCPositionSource source);

    int updateInterval() const;

39 40
    void setToolbox(QGCToolbox* toolbox);

41 42
    void setNmeaSourceDevice(QIODevice* device);

Jimmy Johnson's avatar
Jimmy Johnson committed
43
private slots:
44 45
    void _positionUpdated(const QGeoPositionInfo &update);
    void _error(QGeoPositionInfoSource::Error positioningError);
Jimmy Johnson's avatar
Jimmy Johnson committed
46 47 48 49 50 51 52 53 54

signals:
    void lastPositionUpdated(bool valid, QVariant lastPosition);
    void positionInfoUpdated(QGeoPositionInfo update);

private:
    int _updateInterval;
    QGeoPositionInfoSource * _currentSource;
    QGeoPositionInfoSource * _defaultSource;
55
    QNmeaPositionInfoSource * _nmeaSource;
Jimmy Johnson's avatar
Jimmy Johnson committed
56 57
    QGeoPositionInfoSource * _simulatedSource;
};