mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
[AFV] Fix aliased frequency handling
* ONLY use HF frequency if stations match and is closest station * better log messages
This commit is contained in:
committed by
Mat Sutcliffe
parent
ae5ede5667
commit
881ec39043
@@ -14,6 +14,7 @@
|
|||||||
#include "blacksound/audioutilities.h"
|
#include "blacksound/audioutilities.h"
|
||||||
#include "blackmisc/audio/audiodeviceinfolist.h"
|
#include "blackmisc/audio/audiodeviceinfolist.h"
|
||||||
#include "blackmisc/threadutils.h"
|
#include "blackmisc/threadutils.h"
|
||||||
|
#include "blackmisc/stringutils.h"
|
||||||
#include "blackmisc/verify.h"
|
#include "blackmisc/verify.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
@@ -1039,7 +1040,6 @@ namespace BlackCore
|
|||||||
|
|
||||||
if (it != m_aliasedStations.end())
|
if (it != m_aliasedStations.end())
|
||||||
{
|
{
|
||||||
roundedFrequencyHz = it->frequencyHz; // we use this frequency
|
|
||||||
if (sApp->getIContextNetwork())
|
if (sApp->getIContextNetwork())
|
||||||
{
|
{
|
||||||
// Get the callsign for this frequency and fuzzy compare with our alias station
|
// Get the callsign for this frequency and fuzzy compare with our alias station
|
||||||
@@ -1049,29 +1049,33 @@ namespace BlackCore
|
|||||||
const CAtcStationList matchingAtcStations = sApp->getIContextNetwork()->getOnlineStationsForFrequency(f, spacing);
|
const CAtcStationList matchingAtcStations = sApp->getIContextNetwork()->getOnlineStationsForFrequency(f, spacing);
|
||||||
const CAtcStation closest = matchingAtcStations.findClosest(1, sApp->getIContextOwnAircraft()->getOwnAircraftSituation().getPosition()).frontOrDefault();
|
const CAtcStation closest = matchingAtcStations.findClosest(1, sApp->getIContextOwnAircraft()->getOwnAircraftSituation().getPosition()).frontOrDefault();
|
||||||
|
|
||||||
if (fuzzyMatchCallSign(it->name, closest.getCallsign().asString()))
|
if (fuzzyMatchCallsign(it->name, closest.getCallsign().asString()))
|
||||||
{
|
{
|
||||||
// this is how it should be
|
// this is how it should be
|
||||||
CLogMessage(this).debug(u"%1 Aliasing %2Hz [VHF] to %3Hz [HF]") << closest.getCallsign() << frequencyHz << it->frequencyHz;
|
roundedFrequencyHz = it->frequencyHz;
|
||||||
|
CLogMessage(this).debug(u"Aliasing '%1' %2Hz [VHF] to %3Hz [HF]") << closest.getCallsign() << frequencyHz << it->frequencyHz;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Ups!
|
// Ups!
|
||||||
CLogMessage(this).debug(u"Aliasing %1Hz [VHF] to %2Hz [HF], BUT station NOT found!") << frequencyHz << it->frequencyHz;
|
CLogMessage(this).debug(u"Station '%1' NOT found! Using original frequency %2Hz") << it->name << roundedFrequencyHz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// without contexts
|
// without contexts always use HF frequency if found
|
||||||
CLogMessage(this).debug(u"Aliasing %1Hz [VHF] to %2Hz [HF]") << frequencyHz << it->frequencyHz;
|
roundedFrequencyHz = it->frequencyHz; // we use this frequency
|
||||||
|
CLogMessage(this).debug(u"Aliasing %1Hz [VHF] to %2Hz [HF] (no context)") << frequencyHz << it->frequencyHz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return roundedFrequencyHz;
|
return roundedFrequencyHz;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAfvClient::fuzzyMatchCallSign(const QString &callsign, const QString &compareTo) const
|
bool CAfvClient::fuzzyMatchCallsign(const QString &callsign, const QString &compareTo) const
|
||||||
{
|
{
|
||||||
|
if (callsign.isEmpty() || compareTo.isEmpty()) { return false; } // empty callsigns should NOT match
|
||||||
|
|
||||||
QString prefixA;
|
QString prefixA;
|
||||||
QString suffixA;
|
QString suffixA;
|
||||||
QString prefixB;
|
QString prefixB;
|
||||||
@@ -1083,10 +1087,12 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CAfvClient::getPrefixSuffix(const QString &callsign, QString &prefix, QString &suffix) const
|
void CAfvClient::getPrefixSuffix(const QString &callsign, QString &prefix, QString &suffix) const
|
||||||
{
|
{
|
||||||
QRegularExpression separator("[(-|_)]");
|
thread_local const QRegularExpression separator("[(\\-|_)]");
|
||||||
QStringList parts = callsign.split(separator);
|
const QStringList parts = callsign.split(separator);
|
||||||
prefix = parts.first();
|
|
||||||
suffix = parts.last();
|
// avoid issues if there are no parts, or only one
|
||||||
|
prefix = parts.size() > 0 ? parts.first() : QString();
|
||||||
|
suffix = parts.size() > 1 ? parts.last() : QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
quint16 CAfvClient::comUnitToTransceiverId(CComSystem::ComUnit comUnit)
|
quint16 CAfvClient::comUnitToTransceiverId(CComSystem::ComUnit comUnit)
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ namespace BlackCore
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
quint32 getAliasFrequencyHz(quint32 frequencyHz) const;
|
quint32 getAliasFrequencyHz(quint32 frequencyHz) const;
|
||||||
|
|
||||||
bool fuzzyMatchCallSign(const QString &callsign, const QString &compareTo) const;
|
bool fuzzyMatchCallsign(const QString &callsign, const QString &compareTo) const;
|
||||||
void getPrefixSuffix(const QString &callsign, QString &prefix, QString &suffix) const;
|
void getPrefixSuffix(const QString &callsign, QString &prefix, QString &suffix) const;
|
||||||
|
|
||||||
static constexpr int PositionUpdatesMs = 20000; //!< position timer
|
static constexpr int PositionUpdatesMs = 20000; //!< position timer
|
||||||
|
|||||||
Reference in New Issue
Block a user