mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
COM audio did not tune in (voice room) if channel was already selected at startup
Reason was: hardcoded channel spacing to 8.33kHz As a result changed to channel spacing based on COM unit, which could also be changed at runtime * the issue itself was in own aircraft context * added functions for channel spacing * changed to COM unit channel spacing (instead of hardcoded spacing)
This commit is contained in:
@@ -280,6 +280,11 @@ namespace BlackMisc
|
||||
return comUnit.isActiveFrequencyWithin25kHzChannel(this->getFrequency());
|
||||
}
|
||||
|
||||
bool CAtcStation::isComUnitTunedInChannelSpacing(const CComSystem &comUnit) const
|
||||
{
|
||||
return comUnit.isActiveFrequencyWithinChannelSpacing(this->getFrequency());
|
||||
}
|
||||
|
||||
bool CAtcStation::isFrequencyWithinChannelSpacing(const CFrequency &frequency, CComSystem::ChannelSpacing spacing) const
|
||||
{
|
||||
return CComSystem::isWithinChannelSpacing(frequency, this->getFrequency(), spacing);
|
||||
|
||||
@@ -204,6 +204,9 @@ namespace BlackMisc
|
||||
//! Tuned in within 25KHz channel spacing
|
||||
bool isComUnitTunedIn25KHz(const Aviation::CComSystem &comUnit) const;
|
||||
|
||||
//! Tuned in within channel spacing
|
||||
bool isComUnitTunedInChannelSpacing(const Aviation::CComSystem &comUnit) const;
|
||||
|
||||
//! Is frequency within channel spacing
|
||||
bool isFrequencyWithinChannelSpacing(const PhysicalQuantities::CFrequency &frequency, CComSystem::ChannelSpacing spacing) const;
|
||||
|
||||
|
||||
@@ -39,6 +39,14 @@ namespace BlackMisc
|
||||
});
|
||||
}
|
||||
|
||||
CAtcStationList CAtcStationList::findIfComUnitTunedInChannelSpacing(const CComSystem &comUnit) const
|
||||
{
|
||||
return this->findBy([&](const CAtcStation & atcStation)
|
||||
{
|
||||
return atcStation.isComUnitTunedInChannelSpacing(comUnit);
|
||||
});
|
||||
}
|
||||
|
||||
CAtcStationList CAtcStationList::findIfFrequencyIsWithinSpacing(const CFrequency &frequency, CComSystem::ChannelSpacing spacing)
|
||||
{
|
||||
if (frequency.isNull()) { return CAtcStationList(); }
|
||||
|
||||
@@ -46,9 +46,12 @@ namespace BlackMisc
|
||||
//! Construct from a base class object.
|
||||
CAtcStationList(const CSequence<CAtcStation> &other);
|
||||
|
||||
//! Find 0..n stations tune in frequency of COM unit (with 25kHt channel spacing
|
||||
//! Find 0..n stations tune in frequency of COM unit (with 25kHz channel spacing)
|
||||
CAtcStationList findIfComUnitTunedIn25KHz(const CComSystem &comUnit) const;
|
||||
|
||||
//! Find 0..n stations tune in frequency of COM unit (with channel spacing)
|
||||
CAtcStationList findIfComUnitTunedInChannelSpacing(const CComSystem &comUnit) const;
|
||||
|
||||
//! Find 0..n stations within channel spacing
|
||||
CAtcStationList findIfFrequencyIsWithinSpacing(const PhysicalQuantities::CFrequency &frequency, CComSystem::ChannelSpacing spacing);
|
||||
|
||||
|
||||
@@ -73,9 +73,9 @@ namespace BlackMisc
|
||||
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing50KHz);
|
||||
}
|
||||
|
||||
bool CComSystem::isActiveFrequencyWithinChannelSpacing(const CFrequency &comFrequency, CComSystem::ChannelSpacing channelSpacing) const
|
||||
bool CComSystem::isActiveFrequencyWithinChannelSpacing(const CFrequency &comFrequency) const
|
||||
{
|
||||
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, channelSpacing);
|
||||
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, m_channelSpacing);
|
||||
}
|
||||
|
||||
void CComSystem::setActiveUnicom()
|
||||
@@ -149,7 +149,7 @@ namespace BlackMisc
|
||||
bool CComSystem::isWithinChannelSpacing(const CFrequency &setFrequency, const CFrequency &compareFrequency, CComSystem::ChannelSpacing channelSpacing)
|
||||
{
|
||||
if (setFrequency.isNull() || compareFrequency.isNull()) { return false; }
|
||||
if (setFrequency == compareFrequency) return true; // shortcut for many of such comparisons
|
||||
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());
|
||||
|
||||
@@ -96,8 +96,8 @@ namespace BlackMisc
|
||||
//! Is active frequency within 25kHz channel?
|
||||
bool isActiveFrequencyWithin50kHzChannel(const PhysicalQuantities::CFrequency &comFrequency) const;
|
||||
|
||||
//! Is active frequency within 25kHz channel?
|
||||
bool isActiveFrequencyWithinChannelSpacing(const PhysicalQuantities::CFrequency &comFrequency, CComSystem::ChannelSpacing channelSpacing) const;
|
||||
//! Is active frequency within the channel spacing?
|
||||
bool isActiveFrequencyWithinChannelSpacing(const PhysicalQuantities::CFrequency &comFrequency) const;
|
||||
|
||||
//! Set UNICOM frequency as active
|
||||
void setActiveUnicom();
|
||||
@@ -105,13 +105,18 @@ namespace BlackMisc
|
||||
//! Set International Air Distress 121.5MHz
|
||||
void setActiveInternationalAirDistress();
|
||||
|
||||
//! Get channel spacing
|
||||
ChannelSpacing getChannelSpacing() const { return m_channelSpacing; }
|
||||
|
||||
//! Set channel spacing
|
||||
void setChannelSpacing(ChannelSpacing spacing) { m_channelSpacing = spacing; }
|
||||
|
||||
//! COM1 unit
|
||||
static CComSystem getCom1System(double activeFrequencyMHz, double standbyFrequencyMHz = -1);
|
||||
|
||||
//! COM1 unit
|
||||
static CComSystem getCom1System(const PhysicalQuantities::CFrequency &activeFrequency,
|
||||
const PhysicalQuantities::CFrequency &standbyFrequency = { 0, PhysicalQuantities::CFrequencyUnit::nullUnit() });
|
||||
|
||||
//! COM2 unit
|
||||
static CComSystem getCom2System(double activeFrequencyMHz, double standbyFrequencyMHz = -1);
|
||||
|
||||
|
||||
@@ -565,6 +565,12 @@ namespace BlackMisc
|
||||
m_com2system.isActiveFrequencyWithin25kHzChannel(comFrequency);
|
||||
}
|
||||
|
||||
bool CSimulatedAircraft::isActiveFrequencyWithinChannelSpacing(const CFrequency &comFrequency) const
|
||||
{
|
||||
return m_com1system.isActiveFrequencyWithinChannelSpacing(comFrequency) ||
|
||||
m_com2system.isActiveFrequencyWithinChannelSpacing(comFrequency);
|
||||
}
|
||||
|
||||
bool CSimulatedAircraft::setTransponderMode(CTransponder::TransponderMode mode)
|
||||
{
|
||||
return (m_transponder.setTransponderMode(mode));
|
||||
@@ -580,7 +586,7 @@ namespace BlackMisc
|
||||
u' ' % m_transponder.toQString(i18n) %
|
||||
u" enabled: " % BlackMisc::boolToYesNo(this->isEnabled()) %
|
||||
u" rendered: " % BlackMisc::boolToYesNo(this->isRendered()) %
|
||||
u' '% this->getModel().toQString(i18n);
|
||||
u' ' % this->getModel().toQString(i18n);
|
||||
return s;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -290,6 +290,9 @@ namespace BlackMisc
|
||||
//! Is any (COM1/2) active frequency within 25kHz channel?
|
||||
bool isActiveFrequencyWithin25kHzChannel(const PhysicalQuantities::CFrequency &comFrequency) const;
|
||||
|
||||
//! Is any (COM1/2) active frequency within the COM units channel spacing?
|
||||
bool isActiveFrequencyWithinChannelSpacing(const PhysicalQuantities::CFrequency &comFrequency) const;
|
||||
|
||||
//! Get transponder
|
||||
const Aviation::CTransponder &getTransponder() const { return m_transponder; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user