mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
74 lines
3.0 KiB
C++
74 lines
3.0 KiB
C++
/* Copyright (C) 2013
|
|
* 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. 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 "blackcore/application.h"
|
|
#include "blackcore/webdataservices.h"
|
|
#include "blackcore/context/contextownaircraft.h"
|
|
#include "blackcore/context/contextownaircraftempty.h"
|
|
#include "blackcore/context/contextownaircraftimpl.h"
|
|
#include "blackcore/context/contextownaircraftproxy.h"
|
|
#include "blackmisc/aviation/aircraftsituation.h"
|
|
#include "blackmisc/dbusserver.h"
|
|
|
|
using namespace BlackMisc;
|
|
using namespace BlackMisc::Aviation;
|
|
using namespace BlackMisc::PhysicalQuantities;
|
|
using namespace BlackMisc::Geo;
|
|
using namespace BlackMisc::Simulation;
|
|
|
|
namespace BlackCore
|
|
{
|
|
namespace Context
|
|
{
|
|
IContextOwnAircraft *IContextOwnAircraft::create(CCoreFacade *parent, CCoreFacadeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &connection)
|
|
{
|
|
switch (mode)
|
|
{
|
|
case CCoreFacadeConfig::Local:
|
|
case CCoreFacadeConfig::LocalInDBusServer:
|
|
return (new CContextOwnAircraft(mode, parent))->registerWithDBus(server);
|
|
case CCoreFacadeConfig::Remote:
|
|
return new CContextOwnAircraftProxy(CDBusServer::coreServiceName(connection), connection, mode, parent);
|
|
case CCoreFacadeConfig::NotUsed:
|
|
default:
|
|
return new CContextOwnAircraftEmpty(parent);
|
|
}
|
|
}
|
|
|
|
const CAircraftSituation &IContextOwnAircraft::getDefaultSituation()
|
|
{
|
|
static const CAircraftSituation situation(
|
|
CCoordinateGeodetic(
|
|
CLatitude::fromWgs84("N 049° 18' 17"),
|
|
CLongitude::fromWgs84("E 008° 27' 05"),
|
|
CAltitude(312, CAltitude::MeanSeaLevel, CLengthUnit::ft())
|
|
)
|
|
);
|
|
return situation;
|
|
}
|
|
|
|
CAircraftModel IContextOwnAircraft::getDefaultOwnAircraftModel()
|
|
{
|
|
// if all fails
|
|
static const CAircraftModel defaultModel(
|
|
"", CAircraftModel::TypeOwnSimulatorModel, "default model",
|
|
CAircraftIcaoCode("C172", "L1P", "Cessna", "172", "L", true, false, false, 0));
|
|
|
|
// create one from DB data
|
|
if (sApp && sApp->hasWebDataServices())
|
|
{
|
|
static const CAircraftIcaoCode icao = sApp->getWebDataServices()->getAircraftIcaoCodeForDesignator("C172");
|
|
static const CLivery livery = sApp->getWebDataServices()->getLiveryForCombinedCode("_CC_WHITE_WHITE");
|
|
static const CAircraftModel model("", CAircraftModel::TypeOwnSimulatorModel, icao, livery);
|
|
return model;
|
|
}
|
|
return defaultModel;
|
|
}
|
|
} // namespace
|
|
} // namespace
|