You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.6 KiB
85 lines
2.6 KiB
7 years ago
|
|
||
|
#include "AirMapVehicleManager.h"
|
||
|
#include "AirMapFlightManager.h"
|
||
|
#include "AirMapTelemetry.h"
|
||
|
#include "AirMapTrafficMonitor.h"
|
||
|
|
||
|
AirMapVehicleManager::AirMapVehicleManager(AirMapSharedState& shared, const Vehicle& vehicle, QGCToolbox& toolbox)
|
||
|
: AirspaceVehicleManager(vehicle)
|
||
|
, _shared(shared)
|
||
|
, _flightManager(shared)
|
||
|
, _telemetry(shared)
|
||
|
, _trafficMonitor(shared)
|
||
|
, _toolbox(toolbox)
|
||
|
{
|
||
|
connect(&_flightManager, &AirMapFlightManager::flightPermitStatusChanged, this, &AirMapVehicleManager::flightPermitStatusChanged);
|
||
|
connect(&_flightManager, &AirMapFlightManager::flightPermitStatusChanged, this, &AirMapVehicleManager::_flightPermitStatusChanged);
|
||
|
connect(&_flightManager, &AirMapFlightManager::error, this, &AirMapVehicleManager::error);
|
||
|
connect(&_telemetry, &AirMapTelemetry::error, this, &AirMapVehicleManager::error);
|
||
|
connect(&_trafficMonitor, &AirMapTrafficMonitor::error, this, &AirMapVehicleManager::error);
|
||
|
connect(&_trafficMonitor, &AirMapTrafficMonitor::trafficUpdate, this, &AirspaceVehicleManager::trafficUpdate);
|
||
|
}
|
||
|
|
||
|
void
|
||
|
AirMapVehicleManager::createFlight(const QList<MissionItem*>& missionItems)
|
||
|
{
|
||
|
if (!_shared.client()) {
|
||
|
qCDebug(AirMapManagerLog) << "No AirMap client instance. Will not create a flight";
|
||
|
return;
|
||
|
}
|
||
|
_flightManager.createFlight(missionItems);
|
||
|
}
|
||
|
|
||
|
AirspaceAuthorization::PermitStatus
|
||
|
AirMapVehicleManager::flightPermitStatus() const
|
||
|
{
|
||
|
return _flightManager.flightPermitStatus();
|
||
|
}
|
||
|
|
||
|
void
|
||
|
AirMapVehicleManager::startTelemetryStream()
|
||
|
{
|
||
|
if (_flightManager.flightID() != "") {
|
||
|
_telemetry.startTelemetryStream(_flightManager.flightID());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void
|
||
|
AirMapVehicleManager::stopTelemetryStream()
|
||
|
{
|
||
|
_telemetry.stopTelemetryStream();
|
||
|
}
|
||
|
|
||
|
bool
|
||
|
AirMapVehicleManager::isTelemetryStreaming() const
|
||
|
{
|
||
|
return _telemetry.isTelemetryStreaming();
|
||
|
}
|
||
|
|
||
|
void
|
||
|
AirMapVehicleManager::endFlight()
|
||
|
{
|
||
|
_flightManager.endFlight();
|
||
|
_trafficMonitor.stop();
|
||
|
}
|
||
|
|
||
|
void
|
||
|
AirMapVehicleManager::vehicleMavlinkMessageReceived(const mavlink_message_t& message)
|
||
|
{
|
||
|
if (isTelemetryStreaming()) {
|
||
|
_telemetry.vehicleMavlinkMessageReceived(message);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void
|
||
|
AirMapVehicleManager::_flightPermitStatusChanged()
|
||
|
{
|
||
|
// activate traffic alerts
|
||
|
if (_flightManager.flightPermitStatus() == AirspaceAuthorization::PermitAccepted) {
|
||
|
qCDebug(AirMapManagerLog) << "Subscribing to Traffic Alerts";
|
||
|
// since we already created the flight, we know that we have a valid login token
|
||
|
_trafficMonitor.startConnection(_flightManager.flightID());
|
||
|
}
|
||
|
}
|
||
|
|