Skip to content
Snippets Groups Projects
AirMapTrafficMonitor.h 1.5 KiB
Newer Older
  • Learn to ignore specific revisions
  • /****************************************************************************
     *
     *   (c) 2017 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.
     *
     ****************************************************************************/
    
    #pragma once
    
    
    Gus Grubba's avatar
    Gus Grubba committed
    #include "LifetimeChecker.h"
    
    Gus Grubba's avatar
    Gus Grubba committed
    #include "AirMapSharedState.h"
    
    Gus Grubba's avatar
    Gus Grubba committed
    
    
    #include <QObject>
    
    Gus Grubba's avatar
    Gus Grubba committed
    #include <QGeoCoordinate>
    
    #include "airmap/traffic.h"
    
    #include <memory>
    
    
    /**
     * @class AirMapTrafficMonitor
     *
     */
    
    class AirMapTrafficMonitor : public QObject, public LifetimeChecker
    {
        Q_OBJECT
    public:
    
        AirMapTrafficMonitor            (AirMapSharedState& shared);
        virtual ~AirMapTrafficMonitor   ();
    
        void startConnection            (const QString& flightID);
    
    
        void stop();
    
    signals:
    
        void error                      (const QString& what, const QString& airmapdMessage, const QString& airmapdDetails);
        void trafficUpdate              (bool alert, QString traffic_id, QString vehicle_id, QGeoCoordinate location, float heading);
    
    
    private:
    
        void _update                    (airmap::Traffic::Update::Type type, const std::vector<airmap::Traffic::Update>& update);
    
    
    private:
        QString                                               _flightID;
        AirMapSharedState&                                    _shared;
        std::shared_ptr<airmap::Traffic::Monitor>             _monitor;
        std::shared_ptr<airmap::Traffic::Monitor::Subscriber> _subscriber;
    };