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:
Klaus Basan
2019-05-01 02:11:02 +02:00
parent 8df7404f2b
commit bcbdaaf1a7
19 changed files with 99 additions and 29 deletions

View File

@@ -288,7 +288,7 @@ namespace BlackCore
CAtcStation CAirspaceMonitor::getAtcStationForComUnit(const CComSystem &comSystem) const
{
CAtcStation station;
CAtcStationList stations = m_atcStationsOnline.findIfComUnitTunedIn25KHz(comSystem);
CAtcStationList stations = m_atcStationsOnline.findIfComUnitTunedInChannelSpacing(comSystem);
if (stations.isEmpty()) { return station; }
stations.sortByDistanceToReferencePosition();
return stations.front();

View File

@@ -87,7 +87,7 @@ namespace BlackCore
m_selcalPlayer = new CSelcalPlayer(QAudioDeviceInfo::defaultOutputDevice(), this);
changeDeviceSettings();
this->changeDeviceSettings();
}
CContextAudio *CContextAudio::registerWithDBus(CDBusServer *server)
@@ -160,17 +160,23 @@ namespace BlackCore
Q_ASSERT(m_voice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO;}
m_voiceChannelMapping.clear();
m_channel1->leaveVoiceRoom();
m_channel2->leaveVoiceRoom();
m_unusedVoiceChannels.push_back(m_channel1);
m_unusedVoiceChannels.push_back(m_channel2);
if (m_channel1)
{
m_channel1->leaveVoiceRoom();
m_unusedVoiceChannels.push_back(m_channel1);
}
if (m_channel2)
{
m_channel2->leaveVoiceRoom();
m_unusedVoiceChannels.push_back(m_channel2);
}
}
CIdentifier CContextAudio::audioRunsWhere() const
{
Q_ASSERT(m_voice);
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
static const BlackMisc::CIdentifier i("CContextAudio");
static const CIdentifier i("CContextAudio");
return i;
}
@@ -299,8 +305,8 @@ namespace BlackCore
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << newRooms; }
const CVoiceRoomList currentRooms = this->getComVoiceRooms();
const CVoiceRoom currentRoomCom1 = currentRooms[0];
const CVoiceRoom currentRoomCom2 = currentRooms[1];
const CVoiceRoom currentRoomCom1 = currentRooms[0];
const CVoiceRoom currentRoomCom2 = currentRooms[1];
CVoiceRoom newRoomCom1 = newRooms[0];
CVoiceRoom newRoomCom2 = newRooms[1];
const CCallsign ownCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());

View File

@@ -195,7 +195,7 @@ namespace BlackCore
if (!m_voiceRoom1UrlOverride.isEmpty()) { rooms[0] = CVoiceRoom(m_voiceRoom1UrlOverride); }
if (!m_voiceRoom2UrlOverride.isEmpty()) { rooms[1] = CVoiceRoom(m_voiceRoom2UrlOverride); }
// set the rooms
// set the rooms on the side where the audio is located
emit this->getIContextApplication()->fakedSetComVoiceRoom(rooms);
}
@@ -442,7 +442,7 @@ namespace BlackCore
const CSimulatedAircraft myAircraft(this->getOwnAircraft());
// relevant frequency
if (myAircraft.getCom1System().isActiveFrequencyWithin8_33kHzChannel(atcStation.getFrequency()) || myAircraft.getCom2System().isActiveFrequencyWithin8_33kHzChannel(atcStation.getFrequency()))
if (myAircraft.getCom1System().isActiveFrequencyWithinChannelSpacing(atcStation.getFrequency()) || myAircraft.getCom2System().isActiveFrequencyWithinChannelSpacing(atcStation.getFrequency()))
{
this->resolveVoiceRooms(); // online status changed
}

View File

@@ -58,8 +58,7 @@ namespace BlackGui
ui->setupUi(this);
// init from aircraft
const CSimulatedAircraft ownAircraft = this->getOwnAircraft();
this->updateCockpitFromContext(ownAircraft, CIdentifier("dummyInitialValues")); // intentionally different name here
this->forceCockpitUpdateFromOwnAircraftContext();
// COM form
connect(ui->editor_Com, &CCockpitComForm::testSelcal, this, &CCockpitComComponent::testSelcal);
@@ -75,11 +74,15 @@ namespace BlackGui
// hook up with changes from own aircraft context
if (sGui)
{
// own aircraft
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CCockpitComComponent::updateCockpitFromContext, Qt::QueuedConnection);
connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedSelcal, this, &CCockpitComComponent::updateSelcalFromContext, Qt::QueuedConnection);
// hook up with audio context
connect(sGui->getIContextAudio(), &IContextAudio::changedVoiceRooms, this, &CCockpitComComponent::updateVoiceRoomStatusFromContext, Qt::QueuedConnection);
// network
connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnlineDigest, this, &CCockpitComComponent::onAtcStationsChanged, Qt::QueuedConnection);
}
}
@@ -171,6 +174,18 @@ namespace BlackGui
ui->editor_Com->setVoiceRoomStatus(selectedVoiceRooms);
}
void CCockpitComComponent::forceCockpitUpdateFromOwnAircraftContext()
{
if (!sGui || sGui->isShuttingDown()) { return; }
const CSimulatedAircraft ownAircraft = this->getOwnAircraft();
this->updateCockpitFromContext(ownAircraft, CIdentifier("dummyInitialValues")); // intentionally different name here
}
void CCockpitComComponent::onAtcStationsChanged()
{
// void
}
void CCockpitComComponent::updateSelcalInContext(const CSelcal &selcal)
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextOwnAircraft()) { return; }

View File

@@ -89,6 +89,12 @@ namespace BlackGui
//! Update voice room related information
void updateVoiceRoomStatusFromContext(const BlackMisc::Audio::CVoiceRoomList &selectedVoiceRooms, bool connected);
//! Update the cockpit from aircraft context
void forceCockpitUpdateFromOwnAircraftContext();
//! Stations changed
void onAtcStationsChanged();
QScopedPointer<Ui::CCockpitComComponent> ui;
};
} // namespace

View File

@@ -79,7 +79,7 @@ namespace BlackGui
static const QSize defaultSizeHidden(300, 150);
// keep old size
QSize manuallySetSize = this->window()->size();
const QSize manuallySetSize = this->window()->size();
// hide area
ui->comp_CockpitInfoArea->setVisible(show);
@@ -134,6 +134,11 @@ namespace BlackGui
this->requestTextMessageEntryTab(TextMessagesCom2);
}
void CCockpitComponent::onATCStationsChanged()
{
// void
}
void CCockpitComponent::onToggleFloating(bool floating)
{
ui->wip_CockpitComPanelShowHideBar->setVisible(floating);

View File

@@ -69,6 +69,9 @@ namespace BlackGui
void onRequestTextMessageCom2();
//! @}
//! ATC stations have been changed
void onATCStationsChanged();
QScopedPointer<Ui::CCockpitComponent> ui;
QSize m_sizeFloatingShown; //! size when info area is shown
QSize m_sizeFloatingHidden; //! size when info area is hidden

View File

@@ -66,6 +66,7 @@ namespace BlackGui
ui->tw_TextMessages->setCurrentIndex(0);
ui->fr_TextMessage->setVisible(false);
ui->tvp_TextMessagesAll->setResizeMode(CTextMessageView::ResizingAuto);
ui->tvp_TextMessagesAll->setWordWrap(false);
ui->comp_AtcStations->setWithIcons(false);
// lep_textMessages is the own line edit
@@ -499,11 +500,11 @@ namespace BlackGui
if (!station.getCallsign().isEmpty())
{
const CSimulatedAircraft ownAircraft(this->getOwnAircraft());
if (ownAircraft.getCom1System().isActiveFrequencyWithin25kHzChannel(station.getFrequency()))
if (ownAircraft.getCom1System().isActiveFrequencyWithinChannelSpacing(station.getFrequency()))
{
return this->getTabWidget(TextMessagesCom1);
}
else if (ownAircraft.getCom2System().isActiveFrequencyWithin25kHzChannel(station.getFrequency()))
else if (ownAircraft.getCom2System().isActiveFrequencyWithinChannelSpacing(station.getFrequency()))
{
return this->getTabWidget(TextMessagesCom2);
}

View File

@@ -22,6 +22,7 @@ using namespace BlackMisc::Audio;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Math;
using namespace BlackMisc::Simulation;
using namespace BlackCore::Context;
using namespace BlackGui::Components;
namespace BlackGui
@@ -90,7 +91,7 @@ namespace BlackGui
return msgs;
}
void CCockpitComForm::setVoiceRoomStatus(const Audio::CVoiceRoomList &selectedVoiceRooms)
void CCockpitComForm::setVoiceRoomStatus(const CVoiceRoomList &selectedVoiceRooms)
{
Q_ASSERT_X(selectedVoiceRooms.size() == 2, Q_FUNC_INFO, "Expect 2 voice rooms");
const CVoiceRoom room1 = selectedVoiceRooms[0];
@@ -229,7 +230,7 @@ namespace BlackGui
ui->ds_ComPanelCom2Standby->setValue(freq);
}
this->updateIntegrateFromSimulatorContext();
this->updateIntegratedFlagFromSimulatorContext();
this->updateActiveCOMUnitLEDs(m_integratedWithSim, com1.isSendEnabled(), com1.isReceiveEnabled(), com2.isSendEnabled(), com2.isReceiveEnabled());
}
@@ -313,7 +314,7 @@ namespace BlackGui
}
}
void CCockpitComForm::updateIntegrateFromSimulatorContext()
void CCockpitComForm::updateIntegratedFlagFromSimulatorContext()
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator())
{

View File

@@ -112,7 +112,7 @@ namespace BlackGui
void updateActiveCOMUnitLEDs(bool integratedWithSim, bool com1S, bool com1R, bool com2S, bool com2R);
//! Update from simulator context
void updateIntegrateFromSimulatorContext();
void updateIntegratedFlagFromSimulatorContext();
//! Compare 2 frequencies (consider epsilon)
static bool isFrequenceEqual(double f1, double f2);

View File

@@ -56,7 +56,7 @@ namespace BlackGui
if (textMessage.isRadioMessage())
{
if (!this->popupFrequencyMessages()) { return false; }
if (ownAircraft.isActiveFrequencyWithin25kHzChannel(textMessage.getFrequency())) { return true; }
if (ownAircraft.isActiveFrequencyWithinChannelSpacing(textMessage.getFrequency())) { return true; }
}
return false;
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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(); }

View File

@@ -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);

View File

@@ -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());

View File

@@ -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);

View File

@@ -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

View File

@@ -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; }