style and consistency:

* rename CStatusMessages to CStatusMessageList
* rename NetworkVatlib to CNetworkVatlib
* replace all occurrences of Realname with RealName (correct camel case)
* CSequence method corresponding to CList::append is push_back
* don't compile the qdbuscpp2xml metadata plugin by default
* CAircraftIcao string members always trimmed and capitalized
* added CComSystem::roundTo25KHz
* using epsilon comparison in a couple of places

refs #81
This commit is contained in:
Klaus Basan
2014-01-07 23:00:39 +00:00
committed by Mathew Sutcliffe
parent b5c3a5543f
commit bb61654a29
80 changed files with 846 additions and 753 deletions

View File

@@ -0,0 +1,66 @@
/* 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/. */
#include "blackmisc/aviocomsystem.h"
using namespace BlackMisc::PhysicalQuantities;
namespace BlackMisc
{
namespace Aviation
{
/*
* Valid values?
*/
bool CComSystem::validValues() const
{
if (this->isDefaultValue()) return true; // special case
return
(CComSystem::isValidCivilAviationFrequency(this->getFrequencyActive()) ||
CComSystem::isValidMilitaryFrequency(this->getFrequencyActive())) &&
(CComSystem::isValidCivilAviationFrequency(this->getFrequencyStandby()) ||
CComSystem::isValidMilitaryFrequency(this->getFrequencyStandby()));
}
/*
* Validate
*/
bool CComSystem::validate(bool strict) const
{
if (this->isDefaultValue()) return true;
bool valid = this->validValues();
if (!strict) return valid;
Q_ASSERT_X(valid, "CComSystem::validate", "illegal values");
if (!valid) throw std::range_error("Illegal values in CComSystem::validate");
return true;
}
void CComSystem::setFrequencyActiveMHz(double frequencyMHz)
{
CFrequency f(frequencyMHz, CFrequencyUnit::MHz());
CComSystem::roundTo25KHz(f);
this->CModulator::setFrequencyActive(f);
this->validate(true);
}
void CComSystem::setFrequencyStandbyMHz(double frequencyMHz)
{
CFrequency f(frequencyMHz, CFrequencyUnit::MHz());
CComSystem::roundTo25KHz(f);
this->CModulator::setFrequencyStandby(f);
this->validate(true);
}
/*
* Round to 25KHz
*/
void CComSystem::roundTo25KHz(PhysicalQuantities::CFrequency &frequency)
{
double f = frequency.valueRounded(CFrequencyUnit::kHz(), 0);
quint32 d = static_cast<quint32>(f / 25.0);
frequency.setCurrentUnitValue(d * (25.0 / 1000.0));
}
} // namespace
}