mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
[AFV], Ref T730 play audio "tuned in"/"out"
Replaces the former voice room connected sounds
This commit is contained in:
@@ -23,10 +23,11 @@
|
||||
#include "blackmisc/aviation/altitude.h"
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/aviation/transponder.h"
|
||||
#include "blackmisc/audio/notificationsounds.h"
|
||||
#include "blackcore/db/databaseutils.h"
|
||||
#include "blackmisc/pq/physicalquantity.h"
|
||||
#include "blackmisc/geo/latitude.h"
|
||||
#include "blackmisc/geo/longitude.h"
|
||||
#include "blackmisc/pq/physicalquantity.h"
|
||||
#include "blackmisc/pq/units.h"
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
#include "blackmisc/compare.h"
|
||||
@@ -245,6 +246,56 @@ namespace BlackCore
|
||||
return true;
|
||||
}
|
||||
|
||||
void CContextOwnAircraft::evaluateComStations(bool atcChanged)
|
||||
{
|
||||
if (!sApp || sApp->isShuttingDown() || !sApp->getCContextAudioBase() || !sApp->getIContextNetwork()) { return; }
|
||||
|
||||
CComSystem com1;
|
||||
CComSystem com2;
|
||||
CComSystem lastCom1;
|
||||
CComSystem lastCom2;
|
||||
{
|
||||
QReadLocker l(&m_lockAircraft);
|
||||
com1 = m_ownAircraft.getCom1System();
|
||||
com2 = m_ownAircraft.getCom2System();
|
||||
lastCom1 = m_lastEvaluatedCom1;
|
||||
lastCom2 = m_lastEvaluatedCom2;
|
||||
}
|
||||
|
||||
const bool changedCom1Freq = (lastCom1.getFrequencyActive() != com1.getFrequencyActive());
|
||||
const bool changedCom2Freq = (lastCom2.getFrequencyActive() != com2.getFrequencyActive());
|
||||
|
||||
if (!atcChanged && !changedCom1Freq && !changedCom2Freq) { return; }
|
||||
|
||||
const CAtcStationList atcs = sApp->getIContextNetwork()->getAtcStationsOnline(true).findInRange();
|
||||
const bool atcCom1 = atcs.hasComUnitTunedInChannelSpacing(com1);
|
||||
const bool atcCom2 = atcs.hasComUnitTunedInChannelSpacing(com2);
|
||||
|
||||
const bool tunedIn1 = atcCom1 && !lastCom1.isReceiveEnabled();
|
||||
const bool tunedIn2 = atcCom2 && !lastCom2.isReceiveEnabled();
|
||||
const bool tunedOut1 = !atcCom1 && lastCom1.isReceiveEnabled();
|
||||
const bool tunedOut2 = !atcCom2 && lastCom2.isReceiveEnabled();
|
||||
|
||||
if (sApp && sApp->getCContextAudioBase() && sApp->getIContextNetwork()->isConnected())
|
||||
{
|
||||
if (tunedIn1 || tunedIn2)
|
||||
{
|
||||
sApp->getCContextAudioBase()->playNotification(CNotificationSounds::NotificationAtcTunedIn, true);
|
||||
}
|
||||
else if (tunedOut1 || tunedOut2)
|
||||
{
|
||||
sApp->getCContextAudioBase()->playNotification(CNotificationSounds::NotificationAtcTunedOut, true);
|
||||
}
|
||||
}
|
||||
|
||||
// remember if I was tuned in, abusing the flag
|
||||
lastCom1.setReceiveEnabled(tunedIn1);
|
||||
lastCom2.setReceiveEnabled(tunedIn2);
|
||||
QWriteLocker l(&m_lockAircraft);
|
||||
m_lastEvaluatedCom1 = lastCom1;
|
||||
m_lastEvaluatedCom2 = lastCom2;
|
||||
}
|
||||
|
||||
bool CContextOwnAircraft::updateOwnSituation(const CAircraftSituation &situation)
|
||||
{
|
||||
QWriteLocker l(&m_lockAircraft);
|
||||
@@ -309,6 +360,7 @@ namespace BlackCore
|
||||
}
|
||||
if (changed)
|
||||
{
|
||||
this->evaluateComStations(false);
|
||||
emit this->changedAircraftCockpit(m_ownAircraft, originator);
|
||||
}
|
||||
return changed;
|
||||
@@ -349,7 +401,10 @@ namespace BlackCore
|
||||
{
|
||||
com2.setFrequencyActive(frequency);
|
||||
}
|
||||
return this->updateCockpit(com1, com2, xpdr, originator);
|
||||
|
||||
const bool changed = this->updateCockpit(com1, com2, xpdr, originator);
|
||||
if (changed) { this->evaluateComStations(false); }
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool CContextOwnAircraft::updateOwnAircraftPilot(const CUser &pilot)
|
||||
@@ -424,10 +479,9 @@ namespace BlackCore
|
||||
|
||||
void CContextOwnAircraft::xCtxChangedAtcStationOnlineConnectionStatus(const CAtcStation &atcStation, bool connected)
|
||||
{
|
||||
// any of our active frequencies?
|
||||
// keep this to play notification sounds maybe
|
||||
Q_UNUSED(connected)
|
||||
Q_UNUSED(atcStation)
|
||||
this->evaluateComStations(true);
|
||||
}
|
||||
|
||||
void CContextOwnAircraft::xCtxChangedSimulatorModel(const CAircraftModel &model, const CIdentifier &identifier)
|
||||
|
||||
@@ -223,6 +223,9 @@ namespace BlackCore
|
||||
std::atomic_bool m_history { true }; //!< enable history
|
||||
BlackMisc::Aviation::CAircraftSituationList m_situationHistory; //!< history, latest situation first
|
||||
|
||||
BlackMisc::Aviation::CComSystem m_lastEvaluatedCom1;
|
||||
BlackMisc::Aviation::CComSystem m_lastEvaluatedCom2;
|
||||
|
||||
BlackMisc::CSetting<BlackMisc::Network::Settings::TCurrentTrafficServer> m_currentNetworkServer { this };
|
||||
|
||||
//! Station has been changed, needed to tune in/out voice room
|
||||
@@ -254,6 +257,9 @@ namespace BlackCore
|
||||
//! Update own model and emit signal with identifier
|
||||
bool updateOwnModel(const BlackMisc::Simulation::CAircraftModel &model, const BlackMisc::CIdentifier &identifier);
|
||||
|
||||
//! Evaluate COM stations
|
||||
void evaluateComStations(bool atcChanged);
|
||||
|
||||
//! Reverse lookup of the model against DB data
|
||||
static BlackMisc::Simulation::CAircraftModel reverseLookupModel(const BlackMisc::Simulation::CAircraftModel &model);
|
||||
};
|
||||
|
||||
@@ -47,6 +47,14 @@ namespace BlackMisc
|
||||
});
|
||||
}
|
||||
|
||||
bool CAtcStationList::hasComUnitTunedInChannelSpacing(const CComSystem &comUnit) const
|
||||
{
|
||||
return this->containsBy([&](const CAtcStation & atcStation)
|
||||
{
|
||||
return atcStation.isComUnitTunedInChannelSpacing(comUnit);
|
||||
});
|
||||
}
|
||||
|
||||
CAtcStationList CAtcStationList::findIfFrequencyIsWithinSpacing(const CFrequency &frequency, CComSystem::ChannelSpacing spacing)
|
||||
{
|
||||
if (frequency.isNull()) { return CAtcStationList(); }
|
||||
@@ -110,6 +118,14 @@ namespace BlackMisc
|
||||
return this->removeIf(&CAtcStation::isInRange, false);
|
||||
}
|
||||
|
||||
CAtcStationList CAtcStationList::findInRange() const
|
||||
{
|
||||
if (this->isEmpty()) { return {}; }
|
||||
CAtcStationList copy(*this);
|
||||
copy.removeIfOutsideRange();
|
||||
return copy;
|
||||
}
|
||||
|
||||
int CAtcStationList::synchronizeWithBookedStation(CAtcStation &bookedAtcStation)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
@@ -46,12 +46,15 @@ namespace BlackMisc
|
||||
//! Construct from a base class object.
|
||||
CAtcStationList(const CSequence<CAtcStation> &other);
|
||||
|
||||
//! Find 0..n stations tune in frequency of COM unit (with 25kHz channel spacing)
|
||||
//! Find 0..n stations tuned 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)
|
||||
//! Find 0..n stations tuned in frequency of COM unit (with channel spacing)
|
||||
CAtcStationList findIfComUnitTunedInChannelSpacing(const CComSystem &comUnit) const;
|
||||
|
||||
//! Any stations tuned in frequency of COM unit (with channel spacing)
|
||||
bool hasComUnitTunedInChannelSpacing(const CComSystem &comUnit) const;
|
||||
|
||||
//! Find 0..n stations within channel spacing
|
||||
CAtcStationList findIfFrequencyIsWithinSpacing(const PhysicalQuantities::CFrequency &frequency, CComSystem::ChannelSpacing spacing);
|
||||
|
||||
@@ -71,6 +74,9 @@ namespace BlackMisc
|
||||
//! Remove if marked outside of range
|
||||
int removeIfOutsideRange();
|
||||
|
||||
//! Those in range
|
||||
CAtcStationList findInRange() const;
|
||||
|
||||
//! Synchronize with ATC station representing booking information.
|
||||
//! Both sides (booking, online station) will be updated.
|
||||
//! \pre Can be used only if the stored data in this list are online ATC stations
|
||||
|
||||
Reference in New Issue
Block a user