/*===================================================================== QGroundControl Open Source Ground Control Station (c) 2009 - 2014 QGROUNDCONTROL PROJECT This file is part of the QGROUNDCONTROL project QGROUNDCONTROL is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. QGROUNDCONTROL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with QGROUNDCONTROL. If not, see . ======================================================================*/ /// @file /// @author Don Gagne #ifndef MultiVehicleManager_H #define MultiVehicleManager_H #include "Vehicle.h" #include "QGCMAVLink.h" #include "QmlObjectListModel.h" #include "QGCToolbox.h" #include "QGCLoggingCategory.h" class FirmwarePluginManager; class AutoPilotPluginManager; class JoystickManager; class QGCApplication; class MAVLinkProtocol; Q_DECLARE_LOGGING_CATEGORY(MultiVehicleManagerLog) class MultiVehicleManager : public QGCTool { Q_OBJECT public: MultiVehicleManager(QGCApplication* app); Q_INVOKABLE void saveSetting (const QString &key, const QString& value); Q_INVOKABLE QString loadSetting (const QString &key, const QString& defaultValue); Q_PROPERTY(bool activeVehicleAvailable READ activeVehicleAvailable NOTIFY activeVehicleAvailableChanged) Q_PROPERTY(bool parameterReadyVehicleAvailable READ parameterReadyVehicleAvailable NOTIFY parameterReadyVehicleAvailableChanged) Q_PROPERTY(Vehicle* activeVehicle READ activeVehicle WRITE setActiveVehicle NOTIFY activeVehicleChanged) Q_PROPERTY(QmlObjectListModel* vehicles READ vehiclesModel CONSTANT) // Methods /// Called to notify that a heartbeat was received with the specified information. MultiVehicleManager /// will create/update Vehicles as necessary. /// @param link Heartbeat came through on this link /// @param vehicleId Mavlink system id for vehicle /// @param heartbeat Mavlink heartbeat message /// @return true: continue further processing of this message, false: disregard this message bool notifyHeartbeatInfo(LinkInterface* link, int vehicleId, mavlink_heartbeat_t& heartbeat); Q_INVOKABLE Vehicle* getVehicleById(int vehicleId); UAS* activeUas(void) { return _activeVehicle ? _activeVehicle->uas() : NULL; } QList vehicles(void); // Property accessors bool activeVehicleAvailable(void) { return _activeVehicleAvailable; } bool parameterReadyVehicleAvailable(void) { return _parameterReadyVehicleAvailable; } Vehicle* activeVehicle(void) { return _activeVehicle; } void setActiveVehicle(Vehicle* vehicle); QmlObjectListModel* vehiclesModel(void) { return &_vehicles; } // Override from QGCTool virtual void setToolbox(QGCToolbox *toolbox); signals: void vehicleAdded(Vehicle* vehicle); void vehicleRemoved(Vehicle* vehicle); void activeVehicleAvailableChanged(bool activeVehicleAvailable); void parameterReadyVehicleAvailableChanged(bool parameterReadyVehicleAvailable); void activeVehicleChanged(Vehicle* activeVehicle); void _deleteVehiclePhase2Signal(void); private slots: void _deleteVehiclePhase1(Vehicle* vehicle); void _deleteVehiclePhase2(void); void _setActiveVehiclePhase2(void); void _autopilotParametersReadyChanged(bool parametersReady); private: bool _vehicleExists(int vehicleId); bool _activeVehicleAvailable; ///< true: An active vehicle is available bool _parameterReadyVehicleAvailable; ///< true: An active vehicle with ready parameters is available Vehicle* _activeVehicle; ///< Currently active vehicle from a ui perspective Vehicle* _vehicleBeingDeleted; ///< Vehicle being deleted in queued phases Vehicle* _vehicleBeingSetActive; ///< Vehicle being set active in queued phases QList _ignoreVehicleIds; ///< List of vehicle id for which we ignore further communication QmlObjectListModel _vehicles; FirmwarePluginManager* _firmwarePluginManager; AutoPilotPluginManager* _autopilotPluginManager; JoystickManager* _joystickManager; MAVLinkProtocol* _mavlinkProtocol; }; #endif