mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 02:35:33 +08:00
Renaming, header, Doxygen, formatting (during refs #314)
This commit is contained in:
@@ -1,26 +1,29 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_AVIOCOMSYSTEM_H
|
||||
#define BLACKMISC_AVIOCOMSYSTEM_H
|
||||
#include "blackmisc/aviomodulator.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
/*!
|
||||
* \brief COM system (aka "radio")
|
||||
* COM system (aka "radio")
|
||||
*/
|
||||
class CComSystem : public CModulator<CComSystem>
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* Channel spacing frequency
|
||||
*/
|
||||
//! Channel spacing frequency
|
||||
enum ChannelSpacing
|
||||
{
|
||||
ChannelSpacing50KHz,
|
||||
@@ -28,34 +31,10 @@ namespace BlackMisc
|
||||
ChannelSpacing8_33KHz
|
||||
};
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CComSystem)
|
||||
ChannelSpacing m_channelSpacing;
|
||||
|
||||
/*!
|
||||
* \brief Give me channel spacing in KHz
|
||||
* \remarks Just a helper method, that is why no CFrequency is returned
|
||||
*/
|
||||
static double channelSpacingToFrequencyKHz(ChannelSpacing channelSpacing);
|
||||
|
||||
protected:
|
||||
//! \copydoc CAvionicsBase::validValues
|
||||
virtual bool validValues() const override;
|
||||
|
||||
//! \copydoc CValueObject::marshallFromDbus()
|
||||
virtual void marshallToDbus(QDBusArgument &argument) const override;
|
||||
|
||||
//! \copydoc CValueObject::unmarshallFromDbus()
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument) override;
|
||||
|
||||
//! \copydoc CValueObject::compareImpl
|
||||
virtual int compareImpl(const CValueObject &other) const override;
|
||||
|
||||
public:
|
||||
//! \brief Default constructor
|
||||
//! Default constructor
|
||||
CComSystem() : CModulator(), m_channelSpacing(ChannelSpacing25KHz) {}
|
||||
|
||||
//! \brief Constructor
|
||||
//! Constructor
|
||||
CComSystem(const QString &name, const BlackMisc::PhysicalQuantities::CFrequency &activeFrequency, const BlackMisc::PhysicalQuantities::CFrequency &standbyFrequency = CModulator::FrequencyNotSet(), int digits = 3):
|
||||
CModulator(name, activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency, digits), m_channelSpacing(ChannelSpacing25KHz)
|
||||
{ }
|
||||
@@ -63,34 +42,34 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||
|
||||
//! \brief Set active frequency
|
||||
//! Set active frequency
|
||||
//! \remarks will be rounded to channel spacing
|
||||
void setFrequencyActiveMHz(double frequencyMHz);
|
||||
|
||||
//! \brief Set standby frequency
|
||||
//! Set standby frequency
|
||||
//! \remarks will be rounded to channel spacing
|
||||
void setFrequencyStandbyMHz(double frequencyMHz);
|
||||
|
||||
//! \brief Is active frequency within 8.3383kHz channel?
|
||||
//! Is active frequency within 8.3383kHz channel?
|
||||
bool isActiveFrequencyWithin8_33kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const
|
||||
{
|
||||
return CComSystem::isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing8_33KHz);
|
||||
}
|
||||
|
||||
//! \brief Is active frequency within 25kHz channel?
|
||||
//! Is active frequency within 25kHz channel?
|
||||
bool isActiveFrequencyWithin25kHzChannel(const BlackMisc::PhysicalQuantities::CFrequency &comFrequency) const
|
||||
{
|
||||
return CComSystem::isWithinChannelSpacing(this->getFrequencyActive(), comFrequency, ChannelSpacing25KHz);
|
||||
}
|
||||
|
||||
//! \brief Set UNICOM frequency as active
|
||||
//! Set UNICOM frequency as active
|
||||
void setActiveUnicom()
|
||||
{
|
||||
this->toggleActiveStandby();
|
||||
this->setFrequencyActive(BlackMisc::PhysicalQuantities::CPhysicalQuantitiesConstants::FrequencyUnicom());
|
||||
}
|
||||
|
||||
//! \brief Set International Air Distress 121.5MHz
|
||||
//! Set International Air Distress 121.5MHz
|
||||
void setActiveInternationalAirDistress()
|
||||
{
|
||||
this->toggleActiveStandby();
|
||||
@@ -106,59 +85,59 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::fromJson
|
||||
virtual void fromJson(const QJsonObject &json) override;
|
||||
|
||||
//! \brief Members
|
||||
//! Members
|
||||
static const QStringList &jsonMembers();
|
||||
|
||||
//! \brief operator ==
|
||||
//! operator ==
|
||||
bool operator ==(const CComSystem &other) const;
|
||||
|
||||
//! \brief operator !=
|
||||
//! operator !=
|
||||
bool operator !=(const CComSystem &other) const;
|
||||
|
||||
//! \brief COM1 unit
|
||||
//! COM1 unit
|
||||
static CComSystem getCom1System(double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
||||
{
|
||||
return CComSystem(CModulator::NameCom1(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
||||
}
|
||||
|
||||
//! \brief COM1 unit
|
||||
//! COM1 unit
|
||||
static CComSystem getCom1System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
||||
{
|
||||
return CComSystem(CModulator::NameCom1(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
||||
}
|
||||
|
||||
//! \brief COM2 unit
|
||||
//! COM2 unit
|
||||
static CComSystem getCom2System(double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
||||
{
|
||||
return CComSystem(CModulator::NameCom2(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
||||
}
|
||||
|
||||
//! \brief COM2 unit
|
||||
//! COM2 unit
|
||||
static CComSystem getCom2System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
||||
{
|
||||
return CComSystem(CModulator::NameCom2(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
||||
}
|
||||
|
||||
//! \brief COM3 unit
|
||||
//! COM3 unit
|
||||
static CComSystem getCom3System(double activeFrequencyMHz, double standbyFrequencyMHz = -1)
|
||||
{
|
||||
return CComSystem(CModulator::NameCom3(), BlackMisc::PhysicalQuantities::CFrequency(activeFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()), BlackMisc::PhysicalQuantities::CFrequency(standbyFrequencyMHz < 0 ? activeFrequencyMHz : standbyFrequencyMHz, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz()));
|
||||
}
|
||||
|
||||
//! \brief COM3 unit
|
||||
//! COM3 unit
|
||||
static CComSystem getCom3System(BlackMisc::PhysicalQuantities::CFrequency activeFrequency, BlackMisc::PhysicalQuantities::CFrequency standbyFrequency = CModulator::FrequencyNotSet())
|
||||
{
|
||||
return CComSystem(CModulator::NameCom3(), activeFrequency, standbyFrequency == CModulator::FrequencyNotSet() ? activeFrequency : standbyFrequency);
|
||||
}
|
||||
|
||||
//! \brief Valid civil aviation frequency?
|
||||
//! Valid civil aviation frequency?
|
||||
static bool isValidCivilAviationFrequency(const BlackMisc::PhysicalQuantities::CFrequency &f)
|
||||
{
|
||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), 3);
|
||||
return fr >= 118.0 && fr <= 136.975;
|
||||
}
|
||||
|
||||
//! \brief Valid military aviation frequency?
|
||||
//! Valid military aviation frequency?
|
||||
static bool isValidMilitaryFrequency(const BlackMisc::PhysicalQuantities::CFrequency &f)
|
||||
{
|
||||
double fr = f.valueRounded(BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz(), 3);
|
||||
@@ -166,14 +145,37 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Round to channel spacing, set MHz as unit
|
||||
* Round to channel spacing, set MHz as unit
|
||||
* \see ChannelSpacing
|
||||
*/
|
||||
static void roundToChannelSpacing(BlackMisc::PhysicalQuantities::CFrequency &frequency, ChannelSpacing channelSpacing);
|
||||
|
||||
//! \brief Is compareFrequency within channel spacing of setFrequency
|
||||
//! Is compareFrequency within channel spacing of setFrequency
|
||||
static bool isWithinChannelSpacing(const BlackMisc::PhysicalQuantities::CFrequency &setFrequency, const BlackMisc::PhysicalQuantities::CFrequency &compareFrequency, ChannelSpacing channelSpacing);
|
||||
|
||||
protected:
|
||||
//! \copydoc CAvionicsBase::validValues
|
||||
virtual bool validValues() const override;
|
||||
|
||||
//! \copydoc CValueObject::marshallFromDbus()
|
||||
virtual void marshallToDbus(QDBusArgument &argument) const override;
|
||||
|
||||
//! \copydoc CValueObject::unmarshallFromDbus()
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument) override;
|
||||
|
||||
//! \copydoc CValueObject::compareImpl
|
||||
virtual int compareImpl(const CValueObject &other) const override;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CComSystem)
|
||||
ChannelSpacing m_channelSpacing;
|
||||
|
||||
/*!
|
||||
* Give me channel spacing in KHz
|
||||
* \remarks Just a helper method, that is why no CFrequency is returned
|
||||
*/
|
||||
static double channelSpacingToFrequencyKHz(ChannelSpacing channelSpacing);
|
||||
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user