mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 23:35:33 +08:00
refs #452, removed some classes which will be replaced by new classes
* CAircraftMappings -> will be replace by CAircraftModel * CAircraftIcaoData aircraft ICAO data -> aircraft/airline ICAO code and livery * CAircraft class no longer to be used, but CSimulatedAircraft * removed corresponding GUI model classes / filters
This commit is contained in:
committed by
Mathew Sutcliffe
parent
51e8a6a208
commit
874f29098b
@@ -1,270 +0,0 @@
|
||||
/* 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 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 "blackmisc/aviation/aircraft.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/pq/constants.h"
|
||||
#include "blackmisc/icon.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
CAircraft::CAircraft(const CCallsign &callsign, const Network::CUser &user, const CAircraftSituation &situation)
|
||||
: m_callsign(callsign), m_pilot(user), m_situation(situation)
|
||||
{
|
||||
// sync callsigns
|
||||
this->m_callsign.setTypeHint(CCallsign::Aircraft);
|
||||
if (!callsign.isEmpty())
|
||||
{
|
||||
this->setCallsign(callsign);
|
||||
}
|
||||
else if (!user.getCallsign().isEmpty())
|
||||
{
|
||||
this->setCallsign(user.getCallsign());
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraft::setCallsign(const CCallsign &callsign)
|
||||
{
|
||||
this->m_callsign = callsign;
|
||||
this->m_callsign.setTypeHint(CCallsign::Aircraft);
|
||||
this->m_pilot.setCallsign(this->m_callsign);
|
||||
this->m_situation.setCallsign(this->m_callsign);
|
||||
}
|
||||
|
||||
QString CAircraft::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s(this->m_callsign.toQString(i18n));
|
||||
s.append(" ").append(this->m_pilot.toQString(i18n));
|
||||
s.append(" ").append(this->m_situation.toQString(i18n));
|
||||
s.append(" ").append(this->m_com1system.toQString(i18n));
|
||||
s.append(" ").append(this->m_com2system.toQString(i18n));
|
||||
s.append(" ").append(this->m_transponder.toQString(i18n));
|
||||
s.append(" ").append(this->m_parts.toQString(i18n));
|
||||
return s;
|
||||
}
|
||||
|
||||
void CAircraft::setCockpit(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder)
|
||||
{
|
||||
this->setCom1System(com1);
|
||||
this->setCom2System(com2);
|
||||
this->setTransponder(transponder);
|
||||
}
|
||||
|
||||
void CAircraft::setCockpit(const CComSystem &com1, const CComSystem &com2, int transponderCode, CTransponder::TransponderMode transponderMode)
|
||||
{
|
||||
this->setCom1System(com1);
|
||||
this->setCom2System(com2);
|
||||
this->m_transponder.setTransponderCode(transponderCode);
|
||||
this->m_transponder.setTransponderMode(transponderMode);
|
||||
}
|
||||
|
||||
bool CAircraft::hasChangedCockpitData(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder) const
|
||||
{
|
||||
return this->getCom1System() != com1 || this->getCom2System() != com2 || this->getTransponder() != transponder;
|
||||
}
|
||||
|
||||
bool CAircraft::hasSameComData(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder)
|
||||
{
|
||||
return this->getCom1System() == com1 && this->getCom2System() == com2 && this->getTransponder() == transponder;
|
||||
}
|
||||
|
||||
bool CAircraft::isValidForLogin() const
|
||||
{
|
||||
if (this->m_callsign.asString().isEmpty()) { return false; }
|
||||
if (!this->m_pilot.isValid()) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
void CAircraft::setSituation(const CAircraftSituation &situation)
|
||||
{
|
||||
m_situation = situation;
|
||||
m_situation.setCallsign(this->getCallsign());
|
||||
}
|
||||
|
||||
void CAircraft::setPilot(const Network::CUser &user)
|
||||
{
|
||||
m_pilot = user;
|
||||
this->m_pilot.setCallsign(this->m_callsign);
|
||||
}
|
||||
|
||||
const CComSystem CAircraft::getComSystem(CComSystem::ComUnit unit) const
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case CComSystem::Com1: return this->getCom1System();
|
||||
case CComSystem::Com2: return this->getCom2System();
|
||||
default: break;
|
||||
}
|
||||
Q_ASSERT(false);
|
||||
return CComSystem(); // avoid warning
|
||||
}
|
||||
|
||||
void CAircraft::setComSystem(const CComSystem &com, CComSystem::ComUnit unit)
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case CComSystem::Com1: this->setCom1System(com); break;
|
||||
case CComSystem::Com2: this->setCom2System(com); break;
|
||||
}
|
||||
}
|
||||
|
||||
bool CAircraft::setCom1ActiveFrequency(const CFrequency &frequency)
|
||||
{
|
||||
if (!CComSystem::isValidComFrequency(frequency)) { return false; }
|
||||
this->m_com1system.setFrequencyActive(frequency);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAircraft::setCom2ActiveFrequency(const CFrequency &frequency)
|
||||
{
|
||||
if (!CComSystem::isValidComFrequency(frequency)) { return false; }
|
||||
this->m_com2system.setFrequencyActive(frequency);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAircraft::setComActiveFrequency(const CFrequency &frequency, CComSystem::ComUnit unit)
|
||||
{
|
||||
if (!CComSystem::isValidComFrequency(frequency)) { return false; }
|
||||
switch (unit)
|
||||
{
|
||||
case CComSystem::Com1: return this->setCom1ActiveFrequency(frequency);
|
||||
case CComSystem::Com2: return this->setCom2ActiveFrequency(frequency);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CAircraft::initComSystems()
|
||||
{
|
||||
CComSystem com1("COM1", CPhysicalQuantitiesConstants::FrequencyUnicom(), CPhysicalQuantitiesConstants::FrequencyUnicom());
|
||||
CComSystem com2("COM2", CPhysicalQuantitiesConstants::FrequencyUnicom(), CPhysicalQuantitiesConstants::FrequencyUnicom());
|
||||
this->setCom1System(com1);
|
||||
this->setCom2System(com2);
|
||||
}
|
||||
|
||||
void CAircraft::initTransponder()
|
||||
{
|
||||
CTransponder xpdr(7000, CTransponder::StateStandby);
|
||||
this->setTransponder(xpdr);
|
||||
}
|
||||
|
||||
CAircraftLights CAircraft::getLights() const
|
||||
{
|
||||
return m_parts.getLights();
|
||||
}
|
||||
|
||||
void CAircraft::setParts(const CAircraftParts &parts)
|
||||
{
|
||||
m_parts = parts;
|
||||
}
|
||||
|
||||
void CAircraft::setLights(CAircraftLights &lights)
|
||||
{
|
||||
m_parts.setLights(lights);
|
||||
}
|
||||
|
||||
void CAircraft::setAllLightsOn()
|
||||
{
|
||||
m_parts.setAllLightsOn();
|
||||
}
|
||||
|
||||
void CAircraft::setAllLightsOff()
|
||||
{
|
||||
m_parts.setAllLightsOff();
|
||||
}
|
||||
|
||||
bool CAircraft::isVtol() const
|
||||
{
|
||||
return m_icao.isVtol();
|
||||
}
|
||||
|
||||
CVariant CAircraft::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCallsign:
|
||||
return this->m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexPilot:
|
||||
return this->m_pilot.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexDistanceToOwnAircraft:
|
||||
return this->m_distanceToOwnAircraft.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexCom1System:
|
||||
return this->m_com1system.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexCom2System:
|
||||
return this->m_com2system.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexTransponder:
|
||||
return this->m_transponder.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexSituation:
|
||||
return this->m_situation.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexIcao:
|
||||
return this->m_icao.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexLivery:
|
||||
return this->m_livery.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexParts:
|
||||
return this->m_parts.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexIsVtol:
|
||||
return CVariant::fromValue(this->isVtol());
|
||||
default:
|
||||
return (ICoordinateGeodetic::canHandleIndex(index)) ?
|
||||
ICoordinateGeodetic::propertyByIndex(index) :
|
||||
CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraft::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CAircraft>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCallsign:
|
||||
this->m_callsign.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexPilot:
|
||||
this->m_pilot.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexDistanceToOwnAircraft:
|
||||
this->m_distanceToOwnAircraft.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexCom1System:
|
||||
this->m_com1system.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexCom2System:
|
||||
this->m_com2system.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexTransponder:
|
||||
this->m_transponder.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexIcao:
|
||||
this->m_icao.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexLivery:
|
||||
this->m_livery.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexSituation:
|
||||
this->m_situation.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexParts:
|
||||
this->m_parts.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
@@ -1,321 +0,0 @@
|
||||
/* 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 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_AIRCRAFT_H
|
||||
#define BLACKMISC_AVIATION_AIRCRAFT_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "blackmisc/aviation/aircraftsituation.h"
|
||||
#include "blackmisc/aviation/aircrafticaodata.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/aviation/selcal.h"
|
||||
#include "blackmisc/aviation/transponder.h"
|
||||
#include "blackmisc/aviation/comsystem.h"
|
||||
#include "blackmisc/aviation/aircraftparts.h"
|
||||
#include "blackmisc/aviation/livery.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/namevariantpairlist.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
//! Value object encapsulating information of an aircraft
|
||||
class BLACKMISC_EXPORT CAircraft :
|
||||
public CValueObject<CAircraft>,
|
||||
public BlackMisc::Geo::ICoordinateWithRelativePosition
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexCallsign = BlackMisc::CPropertyIndex::GlobalIndexCAircraft,
|
||||
IndexPilot,
|
||||
IndexDistanceToOwnAircraft,
|
||||
IndexCom1System,
|
||||
IndexCom2System,
|
||||
IndexTransponder,
|
||||
IndexSituation,
|
||||
IndexIcao,
|
||||
IndexLivery,
|
||||
IndexParts,
|
||||
IndexIsVtol
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
CAircraft() {}
|
||||
|
||||
//! Constructor.
|
||||
CAircraft(const CCallsign &callsign, const BlackMisc::Network::CUser &user, const CAircraftSituation &situation);
|
||||
|
||||
//! \copydoc CValueObject::toIcon()
|
||||
BlackMisc::CIcon toIcon() const { return this->m_callsign.toIcon(); }
|
||||
|
||||
//! Get callsign.
|
||||
const CCallsign &getCallsign() const { return m_callsign; }
|
||||
|
||||
//! Get callsign.
|
||||
QString getCallsignAsString() const { return m_callsign.asString(); }
|
||||
|
||||
//! Set callsign
|
||||
virtual void setCallsign(const CCallsign &callsign);
|
||||
|
||||
//! Get situation.
|
||||
const CAircraftSituation &getSituation() const { return m_situation; }
|
||||
|
||||
//! Set situation.
|
||||
void setSituation(const CAircraftSituation &situation);
|
||||
|
||||
//! Get user
|
||||
const BlackMisc::Network::CUser &getPilot() const { return m_pilot; }
|
||||
|
||||
//! Get user's real name
|
||||
QString getPilotRealname() const { return m_pilot.getRealName(); }
|
||||
|
||||
//! Get user's real id
|
||||
QString getPilotId() { return m_pilot.getId(); }
|
||||
|
||||
//! Set pilot (user)
|
||||
virtual void setPilot(const BlackMisc::Network::CUser &user);
|
||||
|
||||
//! Get ICAO info
|
||||
const CAircraftIcaoData &getIcaoInfo() const { return m_icao; }
|
||||
|
||||
//! Set ICAO info
|
||||
virtual void setIcaoInfo(const CAircraftIcaoData &icao) { m_icao = icao; }
|
||||
|
||||
//! Get livery
|
||||
const BlackMisc::Aviation::CLivery &getLivery() const { return m_livery; }
|
||||
|
||||
//! Livery
|
||||
virtual void setLivery(const BlackMisc::Aviation::CLivery &livery) { this->m_livery = livery; }
|
||||
|
||||
//! Set aircraft ICAO designator
|
||||
virtual void setAircraftIcaoDesignator(const QString &designator) { m_icao.setAircraftDesignator(designator); }
|
||||
|
||||
//! Has valid realname?
|
||||
bool hasValidRealName() const { return this->m_pilot.hasValidRealName(); }
|
||||
|
||||
//! Has valid id?
|
||||
bool hasValidId() const { return this->m_pilot.hasValidId(); }
|
||||
|
||||
//! Valid designator?
|
||||
bool hasValidAircraftDesignator() const { return this->m_icao.hasAircraftDesignator(); }
|
||||
|
||||
//! Valid designators?
|
||||
bool hasValidAircraftAndAirlineDesignator() const { return this->m_icao.hasAircraftAndAirlineDesignator(); }
|
||||
|
||||
//! Valid callsign
|
||||
bool hasValidCallsign() const { return CCallsign::isValidCallsign(this->getCallsign().asString()); }
|
||||
|
||||
//! Get position
|
||||
BlackMisc::Geo::CCoordinateGeodetic getPosition() const { return this->m_situation.getPosition(); }
|
||||
|
||||
//! Set position
|
||||
void setPosition(const BlackMisc::Geo::CCoordinateGeodetic &position) { this->m_situation.setPosition(position); }
|
||||
|
||||
//! Get altitude
|
||||
const BlackMisc::Aviation::CAltitude &getAltitude() const { return this->m_situation.getAltitude(); }
|
||||
|
||||
//! Set altitude
|
||||
void setAltitude(const BlackMisc::Aviation::CAltitude &altitude) { this->m_situation.setAltitude(altitude); }
|
||||
|
||||
//! Get groundspeed
|
||||
const BlackMisc::PhysicalQuantities::CSpeed &getGroundSpeed() const { return this->m_situation.getGroundSpeed(); }
|
||||
|
||||
//! \copydoc ICoordinateGeodetic::latitude
|
||||
virtual const BlackMisc::Geo::CLatitude &latitude() const override { return this->m_situation.latitude(); }
|
||||
|
||||
//! \copydoc ICoordinateGeodetic::longitude
|
||||
virtual const BlackMisc::Geo::CLongitude &longitude() const override { return this->m_situation.longitude(); }
|
||||
|
||||
//! \copydoc ICoordinateGeodetic::geodeticHeight
|
||||
//! \remarks this should be used for elevation as depicted here: http://en.wikipedia.org/wiki/Altitude#mediaviewer/File:Vertical_distances.svg
|
||||
const BlackMisc::PhysicalQuantities::CLength &geodeticHeight() const override { return this->m_situation.geodeticHeight(); }
|
||||
|
||||
//! Elevation
|
||||
//! \sa geodeticHeight
|
||||
const BlackMisc::PhysicalQuantities::CLength getElevation() const { return this->geodeticHeight(); }
|
||||
|
||||
//! Elevation
|
||||
//! \sa setGeodeticHeight
|
||||
void setElevation(const BlackMisc::PhysicalQuantities::CLength &elevation) { return this->m_situation.setElevation(elevation); }
|
||||
|
||||
//! Get heading
|
||||
const BlackMisc::Aviation::CHeading &getHeading() const { return this->m_situation.getHeading(); }
|
||||
|
||||
//! Get pitch
|
||||
const BlackMisc::PhysicalQuantities::CAngle &getPitch() const { return this->m_situation.getPitch(); }
|
||||
|
||||
//! Get bank
|
||||
const BlackMisc::PhysicalQuantities::CAngle &getBank() const { return this->m_situation.getBank(); }
|
||||
|
||||
//! Get COM1 system
|
||||
const CComSystem &getCom1System() const { return this->m_com1system; }
|
||||
|
||||
//! Get COM2 system
|
||||
const CComSystem &getCom2System() const { return this->m_com2system; }
|
||||
|
||||
//! Get COM unit
|
||||
const CComSystem getComSystem(CComSystem::ComUnit unit) const;
|
||||
|
||||
//! Set COM unit
|
||||
void setComSystem(const CComSystem &com, CComSystem::ComUnit unit);
|
||||
|
||||
//! Set COM1 system
|
||||
void setCom1System(const CComSystem &comSystem) { this->m_com1system = comSystem; }
|
||||
|
||||
//! Set COM2 system
|
||||
void setCom2System(const CComSystem &comSystem) { this->m_com2system = comSystem; }
|
||||
|
||||
//! Set COM1 frequency
|
||||
bool setCom1ActiveFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency);
|
||||
|
||||
//! Set COM2 frequency
|
||||
bool setCom2ActiveFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency);
|
||||
|
||||
//! Set COM frequency
|
||||
bool setComActiveFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, CComSystem::ComUnit unit);
|
||||
|
||||
//! Given SELCAL selected?
|
||||
bool isSelcalSelected(const BlackMisc::Aviation::CSelcal &selcal) const { return this->m_selcal == selcal; }
|
||||
|
||||
//! Valid SELCAL?
|
||||
bool hasValidSelcal() const { return this->m_selcal.isValid(); }
|
||||
|
||||
//! SELCAL
|
||||
const CSelcal getSelcal() const { return m_selcal; }
|
||||
|
||||
//! Cockpit data
|
||||
void setCockpit(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder);
|
||||
|
||||
//! Cockpit data
|
||||
void setCockpit(const CComSystem &com1, const CComSystem &com2, int transponderCode, CTransponder::TransponderMode mode);
|
||||
|
||||
//! Own SELCAL code
|
||||
void setSelcal(const BlackMisc::Aviation::CSelcal &selcal) { this->m_selcal = selcal; }
|
||||
|
||||
//! Changed cockpit data?
|
||||
bool hasChangedCockpitData(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder) const;
|
||||
|
||||
//! Identical COM system?
|
||||
bool hasSameComData(const CComSystem &com1, const CComSystem &com2, const CTransponder &transponder);
|
||||
|
||||
//! Is any (COM1/2) active frequency within 8.3383kHz channel?
|
||||
bool isActiveFrequencyWithin8_33kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const
|
||||
{
|
||||
return this->m_com1system.isActiveFrequencyWithin8_33kHzChannel(comFrequency) ||
|
||||
this->m_com2system.isActiveFrequencyWithin8_33kHzChannel(comFrequency);
|
||||
}
|
||||
|
||||
//! Is any (COM1/2) active frequency within 25kHz channel?
|
||||
bool isActiveFrequencyWithin25kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const
|
||||
{
|
||||
return this->m_com1system.isActiveFrequencyWithin25kHzChannel(comFrequency) ||
|
||||
this->m_com2system.isActiveFrequencyWithin25kHzChannel(comFrequency);
|
||||
}
|
||||
|
||||
//! Get transponder
|
||||
const BlackMisc::Aviation::CTransponder &getTransponder() const { return this->m_transponder; }
|
||||
|
||||
//! Set transponder
|
||||
void setTransponder(const CTransponder &transponder) { this->m_transponder = transponder; }
|
||||
|
||||
//! Set transponder mode
|
||||
void setTransponderMode(CTransponder::TransponderMode mode) { this->m_transponder.setTransponderMode(mode); }
|
||||
|
||||
//! Set transponder code
|
||||
void setTransponderCode(int code) { this->m_transponder.setTransponderCode(code); }
|
||||
|
||||
//! Get transponder code
|
||||
QString getTransponderCodeFormatted() const { return this->m_transponder.getTransponderCodeFormatted(); }
|
||||
|
||||
//! Get transponder code
|
||||
qint32 getTransponderCode() const { return this->m_transponder.getTransponderCode(); }
|
||||
|
||||
//! Get transponder mode
|
||||
BlackMisc::Aviation::CTransponder::TransponderMode getTransponderMode() const { return this->m_transponder.getTransponderMode(); }
|
||||
|
||||
//! Is valid for login?
|
||||
bool isValidForLogin() const;
|
||||
|
||||
//! Meaningful default settings for COM Systems
|
||||
void initComSystems();
|
||||
|
||||
//! Meaningful default settings for Transponder
|
||||
void initTransponder();
|
||||
|
||||
//! Get aircraft parts
|
||||
const BlackMisc::Aviation::CAircraftParts &getParts() const { return m_parts; }
|
||||
|
||||
//! Get aircraft parts
|
||||
CAircraftLights getLights() const;
|
||||
|
||||
//! Set aircraft parts
|
||||
void setParts(const BlackMisc::Aviation::CAircraftParts &parts);
|
||||
|
||||
//! Set aircraft lights
|
||||
void setLights(BlackMisc::Aviation::CAircraftLights &lights);
|
||||
|
||||
//! Set aircraft lights on
|
||||
void setAllLightsOn();
|
||||
|
||||
//! Set aircraft lights off
|
||||
void setAllLightsOff();
|
||||
|
||||
//! VTOL aircraft?
|
||||
bool isVtol() const;
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! \copydoc CValueObject::convertToQString()
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CAircraft)
|
||||
CCallsign m_callsign;
|
||||
BlackMisc::Network::CUser m_pilot;
|
||||
CAircraftSituation m_situation;
|
||||
CComSystem m_com1system;
|
||||
CComSystem m_com2system;
|
||||
CTransponder m_transponder;
|
||||
CAircraftParts m_parts;
|
||||
CSelcal m_selcal;
|
||||
CAircraftIcaoData m_icao;
|
||||
CLivery m_livery;
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAircraft, (
|
||||
o.m_callsign,
|
||||
o.m_pilot,
|
||||
o.m_situation,
|
||||
o.m_com1system,
|
||||
o.m_com2system,
|
||||
o.m_transponder,
|
||||
o.m_parts,
|
||||
o.m_icao,
|
||||
o.m_livery,
|
||||
o.m_distanceToOwnAircraft,
|
||||
o.m_bearingToOwnAircraft
|
||||
))
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraft)
|
||||
|
||||
#endif // guard
|
||||
@@ -1,103 +0,0 @@
|
||||
/* 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 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 "blackmisc/aviation/aircrafticaodata.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <tuple>
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
CAircraftIcaoData::CAircraftIcaoData(const QString &aircraftIcao, const QString &airlineIcao)
|
||||
: m_aircraftIcao(aircraftIcao), m_airlineIcao(airlineIcao)
|
||||
{}
|
||||
|
||||
CAircraftIcaoData::CAircraftIcaoData(const CAircraftIcaoCode &aircraftIcao, const CAirlineIcaoCode &airlineIcao)
|
||||
: m_aircraftIcao(aircraftIcao), m_airlineIcao(airlineIcao)
|
||||
{}
|
||||
|
||||
QString CAircraftIcaoData::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
QString s(this->m_aircraftIcao.toQString(i18n));
|
||||
s.append(" ").append(this->m_airlineIcao.toQString(i18n));
|
||||
return s;
|
||||
}
|
||||
|
||||
QString CAircraftIcaoData::asString() const
|
||||
{
|
||||
if (!this->hasAircraftDesignator()) { return ""; }
|
||||
QString s(this->getAircraftDesignator());
|
||||
if (this->hasAirlineDesignator())
|
||||
{
|
||||
s.append(" (").append(this->getAirlineDesignator()).append(")");
|
||||
return s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void CAircraftIcaoData::updateMissingParts(const CAircraftIcaoData &icao)
|
||||
{
|
||||
if (!this->hasAircraftDesignator()) { this->setAircraftDesignator(icao.getAircraftDesignator()); }
|
||||
if (!this->hasAirlineDesignator()) { this->setAirlineDesignator(icao.getAirlineDesignator()); }
|
||||
if (!this->hasAircraftCombinedType()) { this->setAircraftCombinedType(icao.getAircraftCombinedType()); }
|
||||
}
|
||||
|
||||
bool CAircraftIcaoData::matchesWildcardIcao(const CAircraftIcaoData &otherIcao) const
|
||||
{
|
||||
if ((*this) == otherIcao) { return true; }
|
||||
if (otherIcao.hasAircraftDesignator() && otherIcao.getAircraftDesignator() != this->getAircraftDesignator()) { return false; }
|
||||
if (otherIcao.hasAirlineDesignator() && otherIcao.getAirlineDesignator() != this->getAirlineDesignator()) { return false; }
|
||||
if (otherIcao.hasAircraftCombinedType() && otherIcao.getAircraftCombinedType() != this->getAircraftCombinedType()) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
CVariant CAircraftIcaoData::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAircraftIcao:
|
||||
return CVariant::fromValue(this->m_aircraftIcao);
|
||||
case IndexAirlineIcao:
|
||||
return CVariant::fromValue(this->m_airlineIcao);
|
||||
case IndexAsString:
|
||||
return CVariant::fromValue(this->asString());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftIcaoData::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CAircraftIcaoData>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAircraftIcao:
|
||||
this->m_aircraftIcao.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexAirlineIcao:
|
||||
this->m_airlineIcao.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
@@ -1,127 +0,0 @@
|
||||
/* 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 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_AIRCRAFTICAODATA_H
|
||||
#define BLACKMISC_AVIATION_AIRCRAFTICAODATA_H
|
||||
|
||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
||||
#include "blackmisc/aviation/airlineicaocode.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
//! Value object for ICAO classification (airline ICAO, aircraft ICAO)
|
||||
class BLACKMISC_EXPORT CAircraftIcaoData : public CValueObject<CAircraftIcaoData>
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexAircraftIcao = BlackMisc::CPropertyIndex::GlobalIndexCAircraftIcaoData,
|
||||
IndexAirlineIcao,
|
||||
IndexAsString,
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
CAircraftIcaoData() = default;
|
||||
|
||||
//! Constructor.
|
||||
//! \param aircraftIcao "B737"
|
||||
//! \param airlineIcao "DLH"
|
||||
CAircraftIcaoData(const QString &aircraftIcao, const QString &airlineIcao = "");
|
||||
|
||||
//! Constructor
|
||||
CAircraftIcaoData(const CAircraftIcaoCode &aircraftIcao, const CAirlineIcaoCode &airlineIcao);
|
||||
|
||||
//! Get ICAO designator, e.g. "B737"
|
||||
const QString &getAircraftDesignator() const { return m_aircraftIcao.getDesignator(); }
|
||||
|
||||
//! Get aircraft ICAO object
|
||||
const BlackMisc::Aviation::CAircraftIcaoCode &getAircraftIcaoCode() const { return this->m_aircraftIcao; }
|
||||
|
||||
//! Set ICAO designator, e.g. "B737"
|
||||
void setAircraftDesignator(const QString &icaoDesignator) { this->m_aircraftIcao.setDesignator(icaoDesignator); }
|
||||
|
||||
//! Aircraft designator?
|
||||
bool hasAircraftDesignator() const { return this->m_aircraftIcao.hasDesignator(); }
|
||||
|
||||
//! Has designator and designator is not "ZZZZ"
|
||||
bool hasKnownAircraftDesignator() const { return (this->m_aircraftIcao.hasKnownDesignator()); }
|
||||
|
||||
//! Get airline, e.g. "DLH"
|
||||
const QString &getAirlineDesignator() const { return this->m_airlineIcao.getDesignator(); }
|
||||
|
||||
//! Get airline ICAO object
|
||||
const BlackMisc::Aviation::CAirlineIcaoCode &getAirlineIcaoCode() const { return this->m_airlineIcao; }
|
||||
|
||||
//! Set airline, e.g. "DLH"
|
||||
void setAirlineDesignator(const QString &icaoDesignator) { this->m_airlineIcao.setDesignator(icaoDesignator); }
|
||||
|
||||
//! Airline available?
|
||||
bool hasAirlineDesignator() const { return this->m_airlineIcao.hasDesignator(); }
|
||||
|
||||
//! Airline and Aircraft designator?
|
||||
bool hasAircraftAndAirlineDesignator() const { return this->hasAirlineDesignator() && this->hasAircraftDesignator(); }
|
||||
|
||||
//! Get type, e.g. "L2J"
|
||||
const QString &getAircraftCombinedType() const { return this->m_aircraftIcao.getCombinedType(); }
|
||||
|
||||
//! Combined type available?
|
||||
bool hasAircraftCombinedType() const { return this->m_aircraftIcao.hasCombinedType(); }
|
||||
|
||||
//! Get engine type, e.g. "J"
|
||||
QString getEngineType() const { return this->m_aircraftIcao.getEngineType(); }
|
||||
|
||||
//! As string for GUI representation by index
|
||||
//! \remarks Different from toQString()
|
||||
QString asString() const;
|
||||
|
||||
//! Set type
|
||||
void setAircraftCombinedType(const QString &type) { this->m_aircraftIcao.setCombinedType(type); }
|
||||
|
||||
//! Missing parts from another ICAO object
|
||||
void updateMissingParts(const CAircraftIcaoData &icao);
|
||||
|
||||
//! Matches wildcard icao object
|
||||
bool matchesWildcardIcao(const CAircraftIcaoData &otherIcao) const;
|
||||
|
||||
//! Is VTOL aircraft
|
||||
bool isVtol() const { return m_aircraftIcao.isVtol(); }
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CAircraftIcaoData)
|
||||
BlackMisc::Aviation::CAircraftIcaoCode m_aircraftIcao; //!< "B737", ...
|
||||
BlackMisc::Aviation::CAirlineIcaoCode m_airlineIcao; //!< "DLH", ...
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftIcaoData)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAircraftIcaoData, (
|
||||
o.m_aircraftIcao,
|
||||
o.m_airlineIcao
|
||||
))
|
||||
|
||||
#endif // guard
|
||||
@@ -1,58 +0,0 @@
|
||||
/* 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 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 "blackmisc/aviation/aircraftlist.h"
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
#include "blackmisc/propertyindexallclasses.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
CAircraftList::CAircraftList() { }
|
||||
|
||||
CAircraftList::CAircraftList(const CSequence<CAircraft> &other) :
|
||||
CSequence<CAircraft>(other)
|
||||
{ }
|
||||
|
||||
CUserList CAircraftList::getPilots() const
|
||||
{
|
||||
return this->findBy(Predicates::MemberValid(&CAircraft::getPilot)).transform(Predicates::MemberTransform(&CAircraft::getPilot));
|
||||
}
|
||||
|
||||
bool CAircraftList::updateWithVatsimDataFileData(CAircraft &aircraftToBeUpdated) const
|
||||
{
|
||||
if (this->isEmpty()) return false;
|
||||
if (aircraftToBeUpdated.hasValidRealName() && aircraftToBeUpdated.hasValidId() && aircraftToBeUpdated.hasValidAircraftAndAirlineDesignator()) return false;
|
||||
|
||||
CAircraft currentDataFileAircraft = this->findFirstByCallsign(aircraftToBeUpdated.getCallsign());
|
||||
if (currentDataFileAircraft.getCallsign().isEmpty()) return false;
|
||||
|
||||
CUser user = aircraftToBeUpdated.getPilot();
|
||||
if (!aircraftToBeUpdated.hasValidRealName()) user.setRealName(currentDataFileAircraft.getPilotRealname());
|
||||
if (!aircraftToBeUpdated.hasValidId()) user.setId(currentDataFileAircraft.getPilotId());
|
||||
aircraftToBeUpdated.setPilot(user);
|
||||
|
||||
CAircraftIcaoData icao = aircraftToBeUpdated.getIcaoInfo();
|
||||
CAircraftIcaoData dataFileIcao = currentDataFileAircraft.getIcaoInfo();
|
||||
if (!icao.hasAircraftDesignator()) icao.setAircraftDesignator(dataFileIcao.getAircraftDesignator());
|
||||
if (!icao.hasAirlineDesignator()) icao.setAirlineDesignator(dataFileIcao.getAirlineDesignator());
|
||||
if (!icao.hasAircraftCombinedType()) icao.setAircraftCombinedType(dataFileIcao.getAircraftCombinedType());
|
||||
aircraftToBeUpdated.setIcaoInfo(icao);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
@@ -1,64 +0,0 @@
|
||||
/* 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 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_AIRCRAFTLIST_H
|
||||
#define BLACKMISC_AVIATION_AIRCRAFTLIST_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/aviation/aircraft.h"
|
||||
#include "blackmisc/aviation/callsignset.h"
|
||||
#include "blackmisc/aviation/callsignobjectlist.h"
|
||||
#include "blackmisc/geo/geoobjectlist.h"
|
||||
#include "blackmisc/network/userlist.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
//! Value object encapsulating a list of aircraft.
|
||||
//! \deprecated consider using CSimulatedAircraftList
|
||||
class BLACKMISC_EXPORT CAircraftList :
|
||||
public CSequence<CAircraft>,
|
||||
public ICallsignObjectList<CAircraft, CAircraftList>,
|
||||
public BlackMisc::Geo::IGeoObjectWithRelativePositionList<CAircraft, CAircraftList>,
|
||||
public BlackMisc::Mixin::MetaType<CAircraftList>
|
||||
{
|
||||
public:
|
||||
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CAircraftList)
|
||||
|
||||
//! Default constructor.
|
||||
CAircraftList();
|
||||
|
||||
//! Construct from a base class object.
|
||||
CAircraftList(const CSequence<CAircraft> &other);
|
||||
|
||||
//! All pilots (with valid data)
|
||||
BlackMisc::Network::CUserList getPilots() const;
|
||||
|
||||
//! Update aircraft with data from VATSIM data file
|
||||
//! \remarks The list used ("this") needs to contain the VATSIM data file objects
|
||||
bool updateWithVatsimDataFileData(CAircraft &aircraftToBeUpdated) const;
|
||||
|
||||
};
|
||||
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAircraftList)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Aviation::CAircraft>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Aviation::CAircraft>)
|
||||
|
||||
#endif //guard
|
||||
@@ -30,8 +30,6 @@ void BlackMisc::Aviation::registerMetadata()
|
||||
CCallsignSet::registerMetadata();
|
||||
CAtcStation::registerMetadata();
|
||||
CAtcStationList::registerMetadata();
|
||||
CAircraft::registerMetadata();
|
||||
CAircraftList::registerMetadata();
|
||||
CAirport::registerMetadata();
|
||||
CAirportList::registerMetadata();
|
||||
CAirportIcaoCode::registerMetadata();
|
||||
@@ -39,7 +37,6 @@ void BlackMisc::Aviation::registerMetadata()
|
||||
CAircraftSituationList::registerMetadata();
|
||||
CAircraftIcaoCode::registerMetadata();
|
||||
CAircraftIcaoCodeList::registerMetadata();
|
||||
CAircraftIcaoData::registerMetadata();
|
||||
CAirlineIcaoCode::registerMetadata();
|
||||
CAirlineIcaoCodeList::registerMetadata();
|
||||
CSelcal::registerMetadata();
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "blackmisc/aviation/callsignobjectlist.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
#include "blackmisc/aviation/atcstationlist.h"
|
||||
#include "blackmisc/aviation/aircraftlist.h"
|
||||
#include "blackmisc/aviation/aircraftsituationlist.h"
|
||||
#include "blackmisc/aviation/aircraftpartslist.h"
|
||||
#include "blackmisc/network/clientlist.h"
|
||||
@@ -201,7 +200,6 @@ namespace BlackMisc
|
||||
// see here for the reason of thess forward instantiations
|
||||
// http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html
|
||||
template class ICallsignObjectList<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||
template class ICallsignObjectList<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
||||
template class ICallsignObjectList<BlackMisc::Aviation::CAircraftSituation, BlackMisc::Aviation::CAircraftSituationList>;
|
||||
template class ICallsignObjectList<BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::Simulation::CSimulatedAircraftList>;
|
||||
template class ICallsignObjectList<BlackMisc::Network::CClient, BlackMisc::Network::CClientList>;
|
||||
|
||||
Reference in New Issue
Block a user