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); }
|
||||||
@@ -346,20 +358,20 @@ namespace BlackMisc
|
|||||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexBookedFrom: return CVariant::from(m_bookedFromUtc);
|
case IndexBookedFrom: return CVariant::from(m_bookedFromUtc);
|
||||||
case IndexBookedUntil: return CVariant::from(m_bookedUntilUtc);
|
case IndexBookedUntil: return CVariant::from(m_bookedUntilUtc);
|
||||||
case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
|
case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexController: return m_controller.propertyByIndex(index.copyFrontRemoved());
|
case IndexController: return m_controller.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexFrequency: return m_frequency.propertyByIndex(index.copyFrontRemoved());
|
case IndexFrequency: return m_frequency.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexIsOnline: return CVariant::from(m_isOnline);
|
case IndexIsOnline: return CVariant::from(m_isOnline);
|
||||||
case IndexLatitude: return this->latitude().propertyByIndex(index.copyFrontRemoved());
|
case IndexLatitude: return this->latitude().propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexLongitude: return this->longitude().propertyByIndex(index.copyFrontRemoved());
|
case IndexLongitude: return this->longitude().propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexPosition: return m_position.propertyByIndex(index.copyFrontRemoved());
|
case IndexPosition: return m_position.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexRange: return m_range.propertyByIndex(index.copyFrontRemoved());
|
case IndexRange: return m_range.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexIsInRange: return CVariant::fromValue(isInRange());
|
case IndexIsInRange: return CVariant::fromValue(isInRange());
|
||||||
case IndexAtis: return m_atis.propertyByIndex(index.copyFrontRemoved());
|
case IndexAtis: return m_atis.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexMetar: return m_metar.propertyByIndex(index.copyFrontRemoved());
|
case IndexMetar: return m_metar.propertyByIndex(index.copyFrontRemoved());
|
||||||
case IndexVoiceRoom: return m_voiceRoom.propertyByIndex(index.copyFrontRemoved());
|
case IndexVoiceRoom: return m_voiceRoom.propertyByIndex(index.copyFrontRemoved());
|
||||||
default:
|
default:
|
||||||
return (ICoordinateWithRelativePosition::canHandleIndex(index)) ?
|
return (ICoordinateWithRelativePosition::canHandleIndex(index)) ?
|
||||||
ICoordinateWithRelativePosition::propertyByIndex(index) :
|
ICoordinateWithRelativePosition::propertyByIndex(index) :
|
||||||
@@ -403,20 +415,20 @@ namespace BlackMisc
|
|||||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexBookedFrom: return Compare::compare(this->getBookedFromUtc(), compareValue.getBookedFromUtc());
|
case IndexBookedFrom: return Compare::compare(this->getBookedFromUtc(), compareValue.getBookedFromUtc());
|
||||||
case IndexBookedUntil: return Compare::compare(this->getBookedUntilUtc(), compareValue.getBookedUntilUtc());
|
case IndexBookedUntil: return Compare::compare(this->getBookedUntilUtc(), compareValue.getBookedUntilUtc());
|
||||||
case IndexCallsign: return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
case IndexCallsign: return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||||
case IndexController: return m_controller.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getController());
|
case IndexController: return m_controller.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getController());
|
||||||
case IndexFrequency: return m_frequency.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getFrequency());
|
case IndexFrequency: return m_frequency.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getFrequency());
|
||||||
case IndexIsOnline: return Compare::compare(this->isOnline(), compareValue.isOnline());
|
case IndexIsOnline: return Compare::compare(this->isOnline(), compareValue.isOnline());
|
||||||
case IndexLatitude: return this->latitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.latitude());
|
case IndexLatitude: return this->latitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.latitude());
|
||||||
case IndexLongitude: return this->longitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.longitude());
|
case IndexLongitude: return this->longitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.longitude());
|
||||||
case IndexPosition: return m_position.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPosition());
|
case IndexPosition: return m_position.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getPosition());
|
||||||
case IndexRange: return m_range.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRange());
|
case IndexRange: return m_range.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRange());
|
||||||
case IndexIsInRange: return Compare::compare(this->isInRange(), compareValue.isInRange());
|
case IndexIsInRange: return Compare::compare(this->isInRange(), compareValue.isInRange());
|
||||||
case IndexAtis: return m_atis.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getAtis());
|
case IndexAtis: return m_atis.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getAtis());
|
||||||
case IndexMetar: return m_metar.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getMetar());
|
case IndexMetar: return m_metar.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getMetar());
|
||||||
case IndexVoiceRoom: return this->getVoiceRoom().getVoiceRoomUrl().compare(compareValue.getVoiceRoom().getVoiceRoomUrl());
|
case IndexVoiceRoom: return this->getVoiceRoom().getVoiceRoomUrl().compare(compareValue.getVoiceRoom().getVoiceRoomUrl());
|
||||||
default:
|
default:
|
||||||
if (ICoordinateWithRelativePosition::canHandleIndex(index))
|
if (ICoordinateWithRelativePosition::canHandleIndex(index))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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