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

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