mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 12:55:31 +08:00
Ref T432, find ATC station for frequency utility functions
This commit is contained in:
@@ -76,6 +76,13 @@ namespace BlackMisc
|
|||||||
m_controller.setCallsign(callsign);
|
m_controller.setCallsign(callsign);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CAtcStation::getCallsignAndControllerRealName() const
|
||||||
|
{
|
||||||
|
if (m_callsign.isEmpty()) { return this->getControllerRealName(); }
|
||||||
|
if (!m_controller.hasRealName()) { return m_callsign.asString(); }
|
||||||
|
return m_callsign.asString() % QStringLiteral(" ") % this->getControllerRealName();
|
||||||
|
}
|
||||||
|
|
||||||
void CAtcStation::setController(const CUser &controller)
|
void CAtcStation::setController(const CUser &controller)
|
||||||
{
|
{
|
||||||
m_controller = controller;
|
m_controller = controller;
|
||||||
@@ -269,6 +276,11 @@ namespace BlackMisc
|
|||||||
return comUnit.isActiveFrequencyWithin25kHzChannel(this->getFrequency());
|
return comUnit.isActiveFrequencyWithin25kHzChannel(this->getFrequency());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAtcStation::isFrequencyWithinChannelSpacing(const CFrequency &frequency, CComSystem::ChannelSpacing spacing) const
|
||||||
|
{
|
||||||
|
return CComSystem::isWithinChannelSpacing(frequency, this->getFrequency(), spacing);
|
||||||
|
}
|
||||||
|
|
||||||
CTime CAtcStation::bookedWhen() const
|
CTime CAtcStation::bookedWhen() const
|
||||||
{
|
{
|
||||||
if (!this->hasValidBookingTimes()) { return CTime(0, nullptr); }
|
if (!this->hasValidBookingTimes()) { return CTime(0, nullptr); }
|
||||||
|
|||||||
@@ -71,9 +71,9 @@ namespace BlackMisc
|
|||||||
CAtcStation(const QString &callsign);
|
CAtcStation(const QString &callsign);
|
||||||
|
|
||||||
//! ATC station constructor
|
//! ATC station constructor
|
||||||
CAtcStation(const CCallsign &callsign, const BlackMisc::Network::CUser &controller,
|
CAtcStation(const CCallsign &callsign, const Network::CUser &controller,
|
||||||
const BlackMisc::PhysicalQuantities::CFrequency &frequency,
|
const PhysicalQuantities::CFrequency &frequency,
|
||||||
const BlackMisc::Geo::CCoordinateGeodetic &pos, const BlackMisc::PhysicalQuantities::CLength &range,
|
const Geo::CCoordinateGeodetic &pos, const PhysicalQuantities::CLength &range,
|
||||||
bool isOnline = false, const QDateTime &bookedFromUtc = QDateTime(), const QDateTime &bookedUntilUtc = QDateTime(),
|
bool isOnline = false, const QDateTime &bookedFromUtc = QDateTime(), const QDateTime &bookedUntilUtc = QDateTime(),
|
||||||
const CInformationMessage &atis = CInformationMessage(CInformationMessage::ATIS), const CInformationMessage &metar = CInformationMessage(CInformationMessage::METAR));
|
const CInformationMessage &atis = CInformationMessage(CInformationMessage::ATIS), const CInformationMessage &metar = CInformationMessage(CInformationMessage::METAR));
|
||||||
|
|
||||||
@@ -104,6 +104,9 @@ namespace BlackMisc
|
|||||||
//! Get controller name.
|
//! Get controller name.
|
||||||
QString getControllerRealName() const { return m_controller.getRealName(); }
|
QString getControllerRealName() const { return m_controller.getRealName(); }
|
||||||
|
|
||||||
|
//! Callsign and controller's name if available
|
||||||
|
QString getCallsignAndControllerRealName() const;
|
||||||
|
|
||||||
//! Get controller name.
|
//! Get controller name.
|
||||||
QString getControllerId() const { return m_controller.getId(); }
|
QString getControllerId() const { return m_controller.getId(); }
|
||||||
|
|
||||||
@@ -194,7 +197,10 @@ namespace BlackMisc
|
|||||||
bool isBookedNow() const;
|
bool isBookedNow() const;
|
||||||
|
|
||||||
//! Tuned in within 25KHz channel spacing
|
//! Tuned in within 25KHz channel spacing
|
||||||
bool isComUnitTunedIn25KHz(const BlackMisc::Aviation::CComSystem &comUnit) const;
|
bool isComUnitTunedIn25KHz(const Aviation::CComSystem &comUnit) const;
|
||||||
|
|
||||||
|
//! Is frequency within channel spacing
|
||||||
|
bool isFrequencyWithinChannelSpacing(const PhysicalQuantities::CFrequency &frequency, CComSystem::ChannelSpacing spacing) const;
|
||||||
|
|
||||||
//! When booked, 0 means now,
|
//! When booked, 0 means now,
|
||||||
//! negative values mean booking in past,
|
//! negative values mean booking in past,
|
||||||
|
|||||||
@@ -40,6 +40,15 @@ namespace BlackMisc
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAtcStationList CAtcStationList::findIfFrequencyIsWithinSpacing(const CFrequency &frequency, CComSystem::ChannelSpacing spacing)
|
||||||
|
{
|
||||||
|
if (frequency.isNull()) { return CAtcStationList(); }
|
||||||
|
return this->findBy([&](const CAtcStation & atcStation)
|
||||||
|
{
|
||||||
|
return atcStation.isFrequencyWithinChannelSpacing(frequency, spacing);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bool CAtcStationList::updateIfMessageChanged(const CInformationMessage &im, const CCallsign &callsign, bool overrideWithNewer)
|
bool CAtcStationList::updateIfMessageChanged(const CInformationMessage &im, const CCallsign &callsign, bool overrideWithNewer)
|
||||||
{
|
{
|
||||||
const CInformationMessage::InformationType t = im.getType();
|
const CInformationMessage::InformationType t = im.getType();
|
||||||
|
|||||||
@@ -13,11 +13,13 @@
|
|||||||
#define BLACKMISC_AVIATION_ATCSTATIONLIST_H
|
#define BLACKMISC_AVIATION_ATCSTATIONLIST_H
|
||||||
|
|
||||||
#include "blackmisc/aviation/atcstation.h"
|
#include "blackmisc/aviation/atcstation.h"
|
||||||
|
#include "blackmisc/aviation/comsystem.h"
|
||||||
#include "blackmisc/aviation/callsignobjectlist.h"
|
#include "blackmisc/aviation/callsignobjectlist.h"
|
||||||
#include "blackmisc/blackmiscexport.h"
|
#include "blackmisc/pq/frequency.h"
|
||||||
#include "blackmisc/collection.h"
|
|
||||||
#include "blackmisc/geo/geoobjectlist.h"
|
#include "blackmisc/geo/geoobjectlist.h"
|
||||||
#include "blackmisc/network/userlist.h"
|
#include "blackmisc/network/userlist.h"
|
||||||
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
#include "blackmisc/collection.h"
|
||||||
#include "blackmisc/sequence.h"
|
#include "blackmisc/sequence.h"
|
||||||
#include "blackmisc/variant.h"
|
#include "blackmisc/variant.h"
|
||||||
|
|
||||||
@@ -27,8 +29,6 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
namespace Aviation
|
namespace Aviation
|
||||||
{
|
{
|
||||||
class CComSystem;
|
|
||||||
|
|
||||||
//! Value object for a list of ATC stations.
|
//! Value object for a list of ATC stations.
|
||||||
class BLACKMISC_EXPORT CAtcStationList :
|
class BLACKMISC_EXPORT CAtcStationList :
|
||||||
public CSequence<CAtcStation>,
|
public CSequence<CAtcStation>,
|
||||||
@@ -48,6 +48,9 @@ namespace BlackMisc
|
|||||||
//! 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 25kHt channel spacing
|
||||||
CAtcStationList findIfComUnitTunedIn25KHz(const CComSystem &comUnit) const;
|
CAtcStationList findIfComUnitTunedIn25KHz(const CComSystem &comUnit) const;
|
||||||
|
|
||||||
|
//! Find 0..n stations within channel spacing
|
||||||
|
CAtcStationList findIfFrequencyIsWithinSpacing(const PhysicalQuantities::CFrequency &frequency, CComSystem::ChannelSpacing spacing);
|
||||||
|
|
||||||
//! Update if message changed
|
//! Update if message changed
|
||||||
bool updateIfMessageChanged(const CInformationMessage &im, const CCallsign &callsign, bool overrideWithNewer);
|
bool updateIfMessageChanged(const CInformationMessage &im, const CCallsign &callsign, bool overrideWithNewer);
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,16 @@ namespace BlackMisc
|
|||||||
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing25KHz);
|
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing25KHz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CComSystem::isActiveFrequencyWithin50kHzChannel(const CFrequency &comFrequency) const
|
||||||
|
{
|
||||||
|
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing50KHz);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CComSystem::isActiveFrequencyWithinChannelSpacing(const CFrequency &comFrequency, CComSystem::ChannelSpacing channelSpacing) const
|
||||||
|
{
|
||||||
|
return isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, channelSpacing);
|
||||||
|
}
|
||||||
|
|
||||||
void CComSystem::setActiveUnicom()
|
void CComSystem::setActiveUnicom()
|
||||||
{
|
{
|
||||||
this->toggleActiveStandby();
|
this->toggleActiveStandby();
|
||||||
@@ -139,9 +149,9 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
if (setFrequency.isNull() || compareFrequency.isNull()) { return false; }
|
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
|
||||||
double channelSpacingKHz = 0.5 * CComSystem::channelSpacingToFrequencyKHz(channelSpacing);
|
const double channelSpacingKHz = 0.5 * CComSystem::channelSpacingToFrequencyKHz(channelSpacing);
|
||||||
double compareFrequencyKHz = compareFrequency.value(CFrequencyUnit::kHz());
|
const double compareFrequencyKHz = compareFrequency.value(CFrequencyUnit::kHz());
|
||||||
double setFrequencyKHz = setFrequency.value(CFrequencyUnit::kHz());
|
const double setFrequencyKHz = setFrequency.value(CFrequencyUnit::kHz());
|
||||||
return (setFrequencyKHz - channelSpacingKHz < compareFrequencyKHz) &&
|
return (setFrequencyKHz - channelSpacingKHz < compareFrequencyKHz) &&
|
||||||
(setFrequencyKHz + channelSpacingKHz > compareFrequencyKHz);
|
(setFrequencyKHz + channelSpacingKHz > compareFrequencyKHz);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,12 @@ namespace BlackMisc
|
|||||||
//! Is active frequency within 25kHz channel?
|
//! Is active frequency within 25kHz channel?
|
||||||
bool isActiveFrequencyWithin25kHzChannel(const PhysicalQuantities::CFrequency &comFrequency) const;
|
bool isActiveFrequencyWithin25kHzChannel(const PhysicalQuantities::CFrequency &comFrequency) const;
|
||||||
|
|
||||||
|
//! 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;
|
||||||
|
|
||||||
//! Set UNICOM frequency as active
|
//! Set UNICOM frequency as active
|
||||||
void setActiveUnicom();
|
void setActiveUnicom();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user