mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
@@ -633,11 +633,11 @@ namespace BlackGui::Components
|
||||
if (!station.getCallsign().isEmpty())
|
||||
{
|
||||
const CSimulatedAircraft ownAircraft(this->getOwnAircraft());
|
||||
if (ownAircraft.getCom1System().isActiveFrequencyWithinChannelSpacing(station.getFrequency()))
|
||||
if (ownAircraft.getCom1System().isActiveFrequencySameFrequency(station.getFrequency()))
|
||||
{
|
||||
return this->getTabWidget(TextMessagesCom1);
|
||||
}
|
||||
else if (ownAircraft.getCom2System().isActiveFrequencyWithinChannelSpacing(station.getFrequency()))
|
||||
else if (ownAircraft.getCom2System().isActiveFrequencySameFrequency(station.getFrequency()))
|
||||
{
|
||||
return this->getTabWidget(TextMessagesCom2);
|
||||
}
|
||||
|
||||
@@ -287,12 +287,12 @@ namespace BlackMisc::Aviation
|
||||
|
||||
bool CAtcStation::isComUnitTunedInChannelSpacing(const CComSystem &comUnit) const
|
||||
{
|
||||
return comUnit.isActiveFrequencyWithinChannelSpacing(this->getFrequency());
|
||||
return comUnit.isActiveFrequencySameFrequency(this->getFrequency());
|
||||
}
|
||||
|
||||
bool CAtcStation::isFrequencyWithinChannelSpacing(const CFrequency &frequency, CComSystem::ChannelSpacing spacing) const
|
||||
{
|
||||
return CComSystem::isWithinChannelSpacing(frequency, this->getFrequency(), spacing);
|
||||
return CComSystem::isSameFrequency(frequency, this->getFrequency());
|
||||
}
|
||||
|
||||
CTime CAtcStation::bookedWhen() const
|
||||
|
||||
@@ -55,24 +55,9 @@ namespace BlackMisc::Aviation
|
||||
this->CModulator::setFrequencyStandby(fRounded);
|
||||
}
|
||||
|
||||
bool CComSystem::isActiveFrequencyWithin8_33kHzChannel(const CFrequency &comFrequency) const
|
||||
bool CComSystem::isActiveFrequencySameFrequency(const CFrequency &comFrequency) const
|
||||
{
|
||||
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing8_33KHz);
|
||||
}
|
||||
|
||||
bool CComSystem::isActiveFrequencyWithin25kHzChannel(const CFrequency &comFrequency) const
|
||||
{
|
||||
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing25KHz);
|
||||
}
|
||||
|
||||
bool CComSystem::isActiveFrequencyWithin50kHzChannel(const CFrequency &comFrequency) const
|
||||
{
|
||||
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing50KHz);
|
||||
}
|
||||
|
||||
bool CComSystem::isActiveFrequencyWithinChannelSpacing(const CFrequency &comFrequency) const
|
||||
{
|
||||
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, m_channelSpacing);
|
||||
return isSameFrequency(this->getFrequencyActive(), comFrequency);
|
||||
}
|
||||
|
||||
void CComSystem::setActiveUnicom()
|
||||
@@ -194,15 +179,16 @@ namespace BlackMisc::Aviation
|
||||
return end == 0 || end == 25 || end == 50 || end == 75;
|
||||
}
|
||||
|
||||
bool CComSystem::isWithinChannelSpacing(const CFrequency &setFrequency, const CFrequency &compareFrequency, CComSystem::ChannelSpacing channelSpacing)
|
||||
bool CComSystem::isSameFrequency(const CFrequency &freq1, const CFrequency &freq2)
|
||||
{
|
||||
if (setFrequency.isNull() || compareFrequency.isNull()) { return false; }
|
||||
if (setFrequency == compareFrequency) { return true; } // shortcut for many of such comparisons
|
||||
const double channelSpacingKHz = 0.5 * CComSystem::channelSpacingToFrequencyKHz(channelSpacing);
|
||||
const double compareFrequencyKHz = compareFrequency.value(CFrequencyUnit::kHz());
|
||||
const double setFrequencyKHz = setFrequency.value(CFrequencyUnit::kHz());
|
||||
return (setFrequencyKHz - channelSpacingKHz < compareFrequencyKHz) &&
|
||||
(setFrequencyKHz + channelSpacingKHz > compareFrequencyKHz);
|
||||
if (freq1.isNull() || freq2.isNull()) { return false; }
|
||||
if (freq1 == freq2) { return true; } // shortcut for many of such comparisons
|
||||
// .x20 == .x25 and .x70 == .x75
|
||||
const int freq1End = static_cast<int>(freq1.value(CFrequencyUnit::kHz())) % 100;
|
||||
const int freq2End = static_cast<int>(freq2.value(CFrequencyUnit::kHz())) % 100;
|
||||
if (freq1End != 20 && freq1End != 25 && freq1End != 70 && freq1End != 75) { return false; }
|
||||
if (freq2End != 20 && freq2End != 25 && freq2End != 70 && freq2End != 75) { return false; }
|
||||
return std::abs(freq1End - freq2End) == 5;
|
||||
}
|
||||
|
||||
CFrequency CComSystem::parseComFrequency(const QString &input, CPqString::SeparatorMode sep)
|
||||
|
||||
@@ -85,17 +85,8 @@ namespace BlackMisc::Aviation
|
||||
//! \remarks will be rounded to channel spacing
|
||||
void setFrequencyStandby(const PhysicalQuantities::CFrequency &frequency);
|
||||
|
||||
//! Is active frequency within 8.3383kHz channel?
|
||||
bool isActiveFrequencyWithin8_33kHzChannel(const PhysicalQuantities::CFrequency &comFrequency) const;
|
||||
|
||||
//! Is active frequency within 25kHz channel?
|
||||
bool isActiveFrequencyWithin25kHzChannel(const PhysicalQuantities::CFrequency &comFrequency) const;
|
||||
|
||||
//! Is active frequency within 25kHz channel?
|
||||
bool isActiveFrequencyWithin50kHzChannel(const PhysicalQuantities::CFrequency &comFrequency) const;
|
||||
|
||||
//! Is active frequency within the channel spacing?
|
||||
bool isActiveFrequencyWithinChannelSpacing(const PhysicalQuantities::CFrequency &comFrequency) const;
|
||||
//! Is active frequency the same frequency
|
||||
bool isActiveFrequencySameFrequency(const PhysicalQuantities::CFrequency &comFrequency) const;
|
||||
|
||||
//! Set UNICOM frequency as active
|
||||
void setActiveUnicom();
|
||||
@@ -136,10 +127,10 @@ namespace BlackMisc::Aviation
|
||||
static void roundToChannelSpacing(PhysicalQuantities::CFrequency &frequency,
|
||||
ChannelSpacing channelSpacing);
|
||||
|
||||
//! Is compareFrequency within channel spacing of setFrequency
|
||||
static bool isWithinChannelSpacing(const PhysicalQuantities::CFrequency &setFrequency,
|
||||
const PhysicalQuantities::CFrequency &compareFrequency,
|
||||
ChannelSpacing channelSpacing);
|
||||
//! Compare frequencies under consideration that on VATSIM
|
||||
//! frequencies .x20/.x25 and .x70/.x75 are the same
|
||||
static bool isSameFrequency(const PhysicalQuantities::CFrequency &freq1,
|
||||
const PhysicalQuantities::CFrequency &freq2);
|
||||
|
||||
//! Is passed frequency in kHz a valid 8.33 channel. This does not check if
|
||||
//! the frequency is within the correct bounds.
|
||||
|
||||
@@ -493,11 +493,11 @@ namespace BlackMisc::Simulation::Settings
|
||||
const CFrequency f(msg.getFrequency());
|
||||
if (mt.testFlag(TextMessagesCom1))
|
||||
{
|
||||
if (aircraft.getCom1System().isActiveFrequencyWithin8_33kHzChannel(f)) { return true; }
|
||||
if (aircraft.getCom1System().isActiveFrequencySameFrequency(f)) { return true; }
|
||||
}
|
||||
if (mt.testFlag(TextMessagesCom2))
|
||||
{
|
||||
if (aircraft.getCom2System().isActiveFrequencyWithin8_33kHzChannel(f)) { return true; }
|
||||
if (aircraft.getCom2System().isActiveFrequencySameFrequency(f)) { return true; }
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -577,8 +577,8 @@ namespace BlackMisc::Simulation
|
||||
|
||||
bool CSimulatedAircraft::isActiveFrequencyWithinChannelSpacing(const CFrequency &comFrequency) const
|
||||
{
|
||||
return m_com1system.isActiveFrequencyWithinChannelSpacing(comFrequency) ||
|
||||
m_com2system.isActiveFrequencyWithinChannelSpacing(comFrequency);
|
||||
return m_com1system.isActiveFrequencySameFrequency(comFrequency) ||
|
||||
m_com2system.isActiveFrequencySameFrequency(comFrequency);
|
||||
}
|
||||
|
||||
bool CSimulatedAircraft::setTransponderMode(CTransponder::TransponderMode mode)
|
||||
|
||||
Reference in New Issue
Block a user