mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
refs #369, adjusted value objects
* convenience functions * removed COM3
This commit is contained in:
@@ -79,6 +79,52 @@ namespace BlackMisc
|
||||
m_situation.setCallsign(this->getCallsign());
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
@@ -150,12 +150,27 @@ namespace BlackMisc
|
||||
//! 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; }
|
||||
|
||||
|
||||
@@ -46,8 +46,7 @@ namespace BlackMisc
|
||||
enum ComUnit
|
||||
{
|
||||
Com1,
|
||||
Com2,
|
||||
Com3
|
||||
Com2
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
@@ -124,18 +123,6 @@ namespace BlackMisc
|
||||
return CComSystem(CModulator::NameCom2(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
||||
}
|
||||
|
||||
//! COM3 unit
|
||||
static CComSystem getCom3System(double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
||||
{
|
||||
return CComSystem(CModulator::NameCom3(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
||||
}
|
||||
|
||||
//! COM3 unit
|
||||
static CComSystem getCom3System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
||||
{
|
||||
return CComSystem(CModulator::NameCom3(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
||||
}
|
||||
|
||||
//! Valid civil aviation frequency?
|
||||
static bool isValidCivilAviationFrequency(const BlackMisc::PhysicalQuantities::CFrequency &f)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace BlackMisc
|
||||
// sync some values, order here is crucial
|
||||
this->setCallsign(this->getCallsign());
|
||||
this->setIcaoInfo(this->getIcaoInfo());
|
||||
this->setModel(this->getModel());
|
||||
this->setModel(this->getModel()); // fix internal values
|
||||
this->setPilot(this->hasValidRealName() ? this->getPilot() : this->getClient().getUser());
|
||||
}
|
||||
|
||||
@@ -89,6 +89,11 @@ namespace BlackMisc
|
||||
this->setIcaoInfo(model.getIcao());
|
||||
}
|
||||
|
||||
void CSimulatedAircraft::setModelString(const QString &modelString)
|
||||
{
|
||||
this->m_model.setModelString(modelString);
|
||||
}
|
||||
|
||||
void CSimulatedAircraft::setCallsign(const CCallsign &callsign)
|
||||
{
|
||||
this->m_model.setCallsign(callsign);
|
||||
|
||||
@@ -53,6 +53,9 @@ namespace BlackMisc
|
||||
//! Set model
|
||||
void setModel(const BlackMisc::Simulation::CAircraftModel &model);
|
||||
|
||||
//! Set model string
|
||||
void setModelString(const QString &modelString);
|
||||
|
||||
//! \copydoc CAircraft::setCallsign
|
||||
virtual void setCallsign(const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user