mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T26, preparing to use flight plan data
* stub utility class (no function yet) * use value objects in matcher signature instead of strings) * removed initNewAircraft, use reverseLookupModelWithFlightplanData
This commit is contained in:
committed by
Mathew Sutcliffe
parent
c106c7f894
commit
e10ab7b9de
@@ -114,11 +114,11 @@ namespace BlackCore
|
||||
return matchedModel;
|
||||
}
|
||||
|
||||
CAircraftModel CAircraftMatcher::reverselLookupModel(const CCallsign &callsign, const QString &networkAircraftIcao, const QString &networkAirlineIcao, const QString &networkLiveryInfo, const QString &networkModelString, CAircraftModel::ModelType type, CStatusMessageList *log)
|
||||
CAircraftModel CAircraftMatcher::reverselLookupModel(const CCallsign &callsign, const CAircraftIcaoCode &networkAircraftIcao, const CAirlineIcaoCode &networkAirlineIcao, const QString &networkLiveryInfo, const QString &networkModelString, CAircraftModel::ModelType type, CStatusMessageList *log)
|
||||
{
|
||||
CLivery livery;
|
||||
livery.setAirlineIcaoCode(networkAirlineIcao);
|
||||
CAircraftModel model(networkModelString, type, "", CAircraftIcaoCode(networkAircraftIcao), livery);
|
||||
CAircraftModel model(networkModelString, type, "", networkAircraftIcao, livery);
|
||||
model.setCallsign(callsign);
|
||||
model = CAircraftMatcher::reverselLookupModel(model, networkLiveryInfo, log);
|
||||
return model;
|
||||
|
||||
@@ -73,11 +73,10 @@ namespace BlackCore
|
||||
|
||||
//! Try to find the corresponding data in DB and get best information for given data
|
||||
//! \threadsafe
|
||||
static BlackMisc::Simulation::CAircraftModel reverselLookupModel(
|
||||
const BlackMisc::Aviation::CCallsign &callsign,
|
||||
const QString &networkAircraftIcao, const QString &networkAirlineIcao, const QString &networkLiveryInfo, const QString &networkModelString,
|
||||
BlackMisc::Simulation::CAircraftModel::ModelType type,
|
||||
BlackMisc::CStatusMessageList *log = nullptr);
|
||||
static BlackMisc::Simulation::CAircraftModel reverselLookupModel(const BlackMisc::Aviation::CCallsign &callsign,
|
||||
const BlackMisc::Aviation::CAircraftIcaoCode &networkAircraftIcao, const BlackMisc::Aviation::CAirlineIcaoCode &networkAirlineIcao, const QString &networkLiveryInfo, const QString &networkModelString,
|
||||
BlackMisc::Simulation::CAircraftModel::ModelType type,
|
||||
BlackMisc::CStatusMessageList *log = nullptr);
|
||||
|
||||
//! Try to find the corresponding data in DB and get best information for following matching
|
||||
//! \threadsafe
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "blackmisc/aviation/comsystem.h"
|
||||
#include "blackmisc/aviation/modulator.h"
|
||||
#include "blackmisc/aviation/transponder.h"
|
||||
#include "blackmisc/aviation/flightplanutils.h"
|
||||
#include "blackmisc/geo/elevationplane.h"
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "blackmisc/network/voicecapabilities.h"
|
||||
@@ -914,6 +915,16 @@ namespace BlackCore
|
||||
this->addReverseLookupMessage(callsign, m);
|
||||
}
|
||||
|
||||
CAircraftModel CAirspaceMonitor::reverseLookupModelWithFlightplanData(const CCallsign &callsign, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery, const QString &modelString, CAircraftModel::ModelType type, CStatusMessageList *log) const
|
||||
{
|
||||
const QString fpRemarks = this->tryToGetFlightPlanRemarks(callsign);
|
||||
if (!fpRemarks.isEmpty())
|
||||
{
|
||||
CFlightPlanUtils::parseFlightPlanRemarks(fpRemarks);
|
||||
}
|
||||
return CAircraftMatcher::reverselLookupModel(callsign, aircraftIcao, airlineIcao, livery, modelString, type, log);
|
||||
}
|
||||
|
||||
bool CAirspaceMonitor::addNewAircraftInRange(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
const CCallsign callsign = aircraft.getCallsign();
|
||||
@@ -1008,10 +1019,11 @@ namespace BlackCore
|
||||
|
||||
CSimulatedAircraft CAirspaceMonitor::addOrUpdateAircraftInRange(const CCallsign &callsign, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery, const QString &modelString, CAircraftModel::ModelType type, CStatusMessageList *log)
|
||||
{
|
||||
CSimulatedAircraft aircraft = this->getAircraftInRangeForCallsign(callsign);
|
||||
CAircraftModel model = this->reverseLookupModelWithFlightplanData(callsign, aircraftIcao, airlineIcao, livery, modelString, type, log);
|
||||
const CSimulatedAircraft aircraft = this->getAircraftInRangeForCallsign(callsign);
|
||||
|
||||
if (aircraft.hasValidCallsign())
|
||||
{
|
||||
CAircraftModel model = CAircraftMatcher::reverselLookupModel(callsign, aircraftIcao, airlineIcao, livery, modelString, type, log);
|
||||
model.updateMissingParts(aircraft.getModel());
|
||||
// Use anonymous as originator here, since the remote aircraft provider is ourselves and the call to updateAircraftModel() would
|
||||
// return without doing anything.
|
||||
@@ -1020,19 +1032,12 @@ namespace BlackCore
|
||||
}
|
||||
else
|
||||
{
|
||||
aircraft = CAirspaceMonitor::initNewAircraft(callsign, aircraftIcao, airlineIcao, livery, modelString, type, log);
|
||||
this->addNewAircraftInRange(aircraft);
|
||||
const CSimulatedAircraft initAircraft(model);
|
||||
this->addNewAircraftInRange(initAircraft);
|
||||
}
|
||||
return aircraft;
|
||||
}
|
||||
|
||||
CSimulatedAircraft CAirspaceMonitor::initNewAircraft(const CCallsign &callsign, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery, const QString &modelString, CAircraftModel::ModelType type, CStatusMessageList *log)
|
||||
{
|
||||
const CAircraftModel model = CAircraftMatcher::reverselLookupModel(callsign, aircraftIcao, airlineIcao, livery, modelString, type, log);
|
||||
const CSimulatedAircraft aircraft(model);
|
||||
return aircraft;
|
||||
}
|
||||
|
||||
void CAirspaceMonitor::ps_aircraftUpdateReceived(const CAircraftSituation &situation, const CTransponder &transponder)
|
||||
{
|
||||
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Called in different thread");
|
||||
@@ -1058,8 +1063,8 @@ namespace BlackCore
|
||||
this->sendInitialPilotQueries(callsign, true, !hasFsInnPacket);
|
||||
|
||||
// new client, there is a chance it has been already created by custom packet
|
||||
const CClient c(callsign);
|
||||
this->addNewClient(c);
|
||||
const CClient client(callsign);
|
||||
this->addNewClient(client);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -360,12 +360,11 @@ namespace BlackCore
|
||||
const BlackMisc::Aviation::CCallsign &callsign, const QString &message,
|
||||
BlackMisc::CStatusMessage::StatusSeverity severity = BlackMisc::CStatusMessage::SeverityInfo);
|
||||
|
||||
//! Init a new aircraft
|
||||
//! \threadsafe
|
||||
static BlackMisc::Simulation::CSimulatedAircraft initNewAircraft(
|
||||
const BlackMisc::Aviation::CCallsign &callsign,
|
||||
const QString &aircraftIcao, const QString &airlineIcao, const QString &livery,
|
||||
const QString &modelString, BlackMisc::Simulation::CAircraftModel::ModelType type, BlackMisc::CStatusMessageList *log = nullptr);
|
||||
//! Reverse lookup, if available flight plan data are considered
|
||||
BlackMisc::Simulation::CAircraftModel reverseLookupModelWithFlightplanData(
|
||||
const BlackMisc::Aviation::CCallsign &callsign, const QString &aircraftIcao,
|
||||
const QString &airlineIcao, const QString &livery, const QString &modelString,
|
||||
BlackMisc::Simulation::CAircraftModel::ModelType type, BlackMisc::CStatusMessageList *log) const;
|
||||
|
||||
private slots:
|
||||
//! Create aircraft in range, this is the only place where a new aircraft should be added
|
||||
|
||||
22
src/blackmisc/aviation/flightplanutils.cpp
Normal file
22
src/blackmisc/aviation/flightplanutils.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/* Copyright (C) 2017
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "flightplanutils.h"
|
||||
#include <QStringBuilder>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
void CFlightPlanUtils::parseFlightPlanRemarks(const QString &remarks)
|
||||
{
|
||||
if (remarks.isEmpty()) { return; }
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
34
src/blackmisc/aviation/flightplanutils.h
Normal file
34
src/blackmisc/aviation/flightplanutils.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* Copyright (C) 2017
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_AVIATION_FLIGHTPLANUTILS_H
|
||||
#define BLACKMISC_AVIATION_FLIGHTPLANUTILS_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
//! Flight plan utils
|
||||
class BLACKMISC_EXPORT CFlightPlanUtils
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CFlightPlanUtils() = delete;
|
||||
|
||||
//! Parse remarks from a flight plan
|
||||
static void parseFlightPlanRemarks(const QString &remarks);
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user