mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 05:45:35 +08:00
refs #395, added isInRange to ATC stations
* use null as default values for some members to detect those are not yet set * used simplified bool formatter for views
This commit is contained in:
committed by
Mathew Sutcliffe
parent
a3b147d59a
commit
3300b1ad9b
@@ -49,6 +49,11 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
bool CAtcStation::hasBookingTimes() const
|
||||
{
|
||||
return !(this->m_bookedFromUtc.isNull() && this->m_bookedUntilUtc.isNull());
|
||||
}
|
||||
|
||||
bool CAtcStation::hasMetar() const
|
||||
{
|
||||
return this->m_metar.hasMessage();
|
||||
@@ -181,6 +186,24 @@ namespace BlackMisc
|
||||
otherStation.setController(otherController);
|
||||
}
|
||||
|
||||
bool CAtcStation::isInRange() const
|
||||
{
|
||||
if (m_range.isNull() || !hasValidDistance()) { return false; }
|
||||
return (this->getDistanceToOwnAircraft() <= m_range);
|
||||
}
|
||||
|
||||
bool CAtcStation::hasValidBookingTimes() const
|
||||
{
|
||||
return !this->m_bookedFromUtc.isNull() && this->m_bookedFromUtc.isValid() &&
|
||||
!this->m_bookedUntilUtc.isNull() && this->m_bookedUntilUtc.isValid();
|
||||
}
|
||||
|
||||
void CAtcStation::setBookedFromUntil(const CAtcStation &otherStation)
|
||||
{
|
||||
this->setBookedFromUtc(otherStation.getBookedFromUtc());
|
||||
this->setBookedUntilUtc(otherStation.getBookedUntilUtc());
|
||||
}
|
||||
|
||||
bool CAtcStation::isBookedNow() const
|
||||
{
|
||||
if (!this->hasValidBookingTimes()) return false;
|
||||
@@ -190,9 +213,14 @@ namespace BlackMisc
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAtcStation::isComUnitTunedIn25KHz(const CComSystem &comUnit) const
|
||||
{
|
||||
return comUnit.isActiveFrequencyWithin25kHzChannel(this->getFrequency());
|
||||
}
|
||||
|
||||
CTime CAtcStation::bookedWhen() const
|
||||
{
|
||||
if (!this->hasValidBookingTimes()) return CTime(-365.0, CTimeUnit::d());
|
||||
if (!this->hasValidBookingTimes()) { return CTime(0, CTimeUnit::nullUnit()); }
|
||||
QDateTime now = QDateTime::currentDateTimeUtc();
|
||||
qint64 diffMs;
|
||||
if (this->m_bookedFromUtc > now)
|
||||
@@ -257,6 +285,8 @@ namespace BlackMisc
|
||||
return this->m_position.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexRange:
|
||||
return this->m_range.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexIsInRange:
|
||||
return CVariant::fromValue(isInRange());
|
||||
case IndexAtis:
|
||||
return this->m_atis.propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexMetar:
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace BlackMisc
|
||||
IndexFrequency,
|
||||
IndexPosition,
|
||||
IndexRange,
|
||||
IndexIsInRange,
|
||||
IndexDistanceToOwnAircraft,
|
||||
IndexIsOnline,
|
||||
IndexBookedFrom,
|
||||
@@ -70,10 +71,7 @@ namespace BlackMisc
|
||||
BlackMisc::CIcon toIcon() const { return this->m_callsign.toIcon(); }
|
||||
|
||||
//! Has booking times?
|
||||
bool hasBookingTimes() const
|
||||
{
|
||||
return !(this->m_bookedFromUtc.isNull() && this->m_bookedUntilUtc.isNull());
|
||||
}
|
||||
bool hasBookingTimes() const;
|
||||
|
||||
//! Has ATIS?
|
||||
bool hasAtis() const
|
||||
@@ -135,10 +133,8 @@ namespace BlackMisc
|
||||
//! Set position
|
||||
void setPosition(const BlackMisc::Geo::CCoordinateGeodetic &position) { this->m_position = position; }
|
||||
|
||||
/*!
|
||||
* Syncronize controller data
|
||||
* Updates two stations (namely a booked and online ATC station) with complementary data
|
||||
*/
|
||||
//! Syncronize controller data
|
||||
//! Updates two stations (namely a booked and online ATC station) with complementary data
|
||||
void syncronizeControllerData(CAtcStation &otherStation);
|
||||
|
||||
//! Get the radius of the controller's area of visibility.
|
||||
@@ -147,6 +143,9 @@ namespace BlackMisc
|
||||
//! Set range
|
||||
void setRange(const BlackMisc::PhysicalQuantities::CLength &range) { this->m_range = range; }
|
||||
|
||||
//! In range? If range and distance to own aircraft are not available false
|
||||
bool isInRange() const;
|
||||
|
||||
//! Is station online (or just booked)?
|
||||
bool isOnline() const { return m_isOnline; }
|
||||
|
||||
@@ -165,50 +164,33 @@ namespace BlackMisc
|
||||
//! Valid voice room?
|
||||
bool hasValidVoiceRoom() const { return this->m_voiceRoom.isValid(); }
|
||||
|
||||
/*!
|
||||
* Booked date/time if any.
|
||||
* This represents the closest booking within a time frame as there can be multiple bookings.
|
||||
*/
|
||||
//! Booked date/time if any.
|
||||
//! This represents the closest booking within a time frame as there can be multiple bookings.
|
||||
const QDateTime &getBookedFromUtc() const { return m_bookedFromUtc; }
|
||||
|
||||
//! Booked date/time if any.
|
||||
//! This represents the closest booking within a time frame as there can be multiple bookings.
|
||||
const QDateTime &getBookedUntilUtc() const { return m_bookedUntilUtc; }
|
||||
|
||||
//! Has valid booking times?
|
||||
bool hasValidBookingTimes() const;
|
||||
|
||||
//! Set booked from
|
||||
void setBookedFromUtc(const QDateTime &from) { this->m_bookedFromUtc = from; }
|
||||
|
||||
/*!
|
||||
* Booked date/time if any.
|
||||
* This represents the closest booking within a time frame as there can be multiple bookings.
|
||||
*/
|
||||
const QDateTime &getBookedUntilUtc() const { return m_bookedUntilUtc; }
|
||||
|
||||
//! Has valid booking times?
|
||||
bool hasValidBookingTimes() const
|
||||
{
|
||||
return !this->m_bookedFromUtc.isNull() && this->m_bookedFromUtc.isValid() &&
|
||||
!this->m_bookedUntilUtc.isNull() && this->m_bookedUntilUtc.isValid();
|
||||
}
|
||||
|
||||
//! Transfer booking times
|
||||
void setBookedFromUntil(const CAtcStation &otherStation)
|
||||
{
|
||||
this->setBookedFromUtc(otherStation.getBookedFromUtc());
|
||||
this->setBookedUntilUtc(otherStation.getBookedUntilUtc());
|
||||
}
|
||||
void setBookedFromUntil(const CAtcStation &otherStation);
|
||||
|
||||
//! Booked now?
|
||||
bool isBookedNow() const;
|
||||
|
||||
//! Tuned in within 25KHz channel spacing
|
||||
bool isComUnitTunedIn25KHz(const BlackMisc::Aviation::CComSystem &comUnit) const
|
||||
{
|
||||
return comUnit.isActiveFrequencyWithin25kHzChannel(this->getFrequency());
|
||||
}
|
||||
bool isComUnitTunedIn25KHz(const BlackMisc::Aviation::CComSystem &comUnit) const;
|
||||
|
||||
/*!
|
||||
* When booked, 0 means now,
|
||||
* negative values mean booking in past,
|
||||
* positive values mean booking in future,
|
||||
* no booking dates will result in - 1 year
|
||||
*/
|
||||
//! When booked, 0 means now,
|
||||
//! negative values mean booking in past,
|
||||
//! positive values mean booking in future,
|
||||
//! no booking dates will result in null time
|
||||
BlackMisc::PhysicalQuantities::CTime bookedWhen() const;
|
||||
|
||||
//! Get ATIS
|
||||
@@ -282,7 +264,7 @@ BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CAtcStation, (
|
||||
o.m_voiceRoom,
|
||||
o.m_distanceToOwnAircraft,
|
||||
o.m_bearingToOwnAircraft
|
||||
))
|
||||
))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CAtcStation)
|
||||
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user