mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 18:55:38 +08:00
[AFV] style, const, formatting
This commit is contained in:
@@ -53,8 +53,8 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
OutputVolumeStreamArgs outputVolumeStreamArgs;
|
OutputVolumeStreamArgs outputVolumeStreamArgs;
|
||||||
outputVolumeStreamArgs.PeakRaw = m_maxSampleOutput / 1.0;
|
outputVolumeStreamArgs.PeakRaw = m_maxSampleOutput / 1.0;
|
||||||
outputVolumeStreamArgs.PeakDB = static_cast<float>(20 * std::log10(outputVolumeStreamArgs.PeakRaw));
|
outputVolumeStreamArgs.PeakDb = static_cast<float>(20 * std::log10(outputVolumeStreamArgs.PeakRaw));
|
||||||
const double db = qBound(m_minDb, outputVolumeStreamArgs.PeakDB, m_maxDb);
|
const double db = qBound(m_minDb, outputVolumeStreamArgs.PeakDb, m_maxDb);
|
||||||
double ratio = (db - m_minDb) / (m_maxDb - m_minDb);
|
double ratio = (db - m_minDb) / (m_maxDb - m_minDb);
|
||||||
if (ratio < 0.30) { ratio = 0.0; }
|
if (ratio < 0.30) { ratio = 0.0; }
|
||||||
if (ratio > 1.0) { ratio = 1.0; }
|
if (ratio > 1.0) { ratio = 1.0; }
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ namespace BlackCore
|
|||||||
//! Stream args
|
//! Stream args
|
||||||
struct OutputVolumeStreamArgs
|
struct OutputVolumeStreamArgs
|
||||||
{
|
{
|
||||||
double PeakRaw = 0.0;
|
double PeakRaw = 0.0; //!< raw peak
|
||||||
double PeakDB = -1 * std::numeric_limits<double>::infinity();
|
double PeakDb = -1 * std::numeric_limits<double>::infinity(); //!< dB peak
|
||||||
double PeakVU = 0.0;
|
double PeakVU = 0.0; //!< VU peak
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Output buffer
|
//! Output buffer
|
||||||
@@ -95,7 +95,6 @@ namespace BlackCore
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_started = false;
|
bool m_started = false;
|
||||||
|
|
||||||
BlackMisc::Audio::CAudioDeviceInfo m_device;
|
BlackMisc::Audio::CAudioDeviceInfo m_device;
|
||||||
QScopedPointer<QAudioOutput> m_audioOutputCom;
|
QScopedPointer<QAudioOutput> m_audioOutputCom;
|
||||||
CAudioOutputBuffer *m_audioOutputBuffer = nullptr;
|
CAudioOutputBuffer *m_audioOutputBuffer = nullptr;
|
||||||
|
|||||||
@@ -38,24 +38,24 @@ namespace BlackCore
|
|||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||||
if (jsonDoc.isObject())
|
if (jsonDoc.isObject())
|
||||||
{
|
{
|
||||||
QJsonObject rootObject = jsonDoc.object();
|
const QJsonObject rootObject = jsonDoc.object();
|
||||||
QVector<CSampleAtcStation> transceivers;
|
QVector<CSampleAtcStation> transceivers;
|
||||||
|
|
||||||
if (rootObject.contains("controllers"))
|
if (rootObject.contains("controllers"))
|
||||||
{
|
{
|
||||||
QJsonObject otherObject = rootObject.value("controllers").toObject();
|
const QJsonObject otherObject = rootObject.value("controllers").toObject();
|
||||||
for (auto it = otherObject.begin(); it != otherObject.end(); ++it)
|
for (auto it = otherObject.begin(); it != otherObject.end(); ++it)
|
||||||
{
|
{
|
||||||
QString callsign = it.key();
|
const QString callsign = it.key();
|
||||||
if (it.value().isObject())
|
if (it.value().isObject())
|
||||||
{
|
{
|
||||||
QJsonObject stationObject = it.value().toObject();
|
const QJsonObject stationObject = it.value().toObject();
|
||||||
if (stationObject.contains("transceivers"))
|
if (stationObject.contains("transceivers"))
|
||||||
{
|
{
|
||||||
QJsonArray txArray = stationObject.value("transceivers").toArray();
|
QJsonArray txArray = stationObject.value("transceivers").toArray();
|
||||||
for (auto jt = txArray.begin(); jt != txArray.end(); ++jt)
|
for (auto jt = txArray.begin(); jt != txArray.end(); ++jt)
|
||||||
{
|
{
|
||||||
TransceiverDto transceiver = TransceiverDto::fromJson(jt->toObject());
|
const TransceiverDto transceiver = TransceiverDto::fromJson(jt->toObject());
|
||||||
transceivers.push_back({ callsign, transceiver});
|
transceivers.push_back({ callsign, transceiver});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,19 +65,19 @@ namespace BlackCore
|
|||||||
|
|
||||||
if (rootObject.contains("other") && rootObject.value("other").isObject())
|
if (rootObject.contains("other") && rootObject.value("other").isObject())
|
||||||
{
|
{
|
||||||
QJsonObject otherObject = rootObject.value("other").toObject();
|
const QJsonObject otherObject = rootObject.value("other").toObject();
|
||||||
for (auto it = otherObject.begin(); it != otherObject.end(); ++it)
|
for (auto it = otherObject.begin(); it != otherObject.end(); ++it)
|
||||||
{
|
{
|
||||||
QString callsign = it.key();
|
const QString callsign = it.key();
|
||||||
if (it.value().isObject())
|
if (it.value().isObject())
|
||||||
{
|
{
|
||||||
QJsonObject stationObject = it.value().toObject();
|
QJsonObject stationObject = it.value().toObject();
|
||||||
if (stationObject.contains("transceivers"))
|
if (stationObject.contains("transceivers"))
|
||||||
{
|
{
|
||||||
QJsonArray txArray = stationObject.value("transceivers").toArray();
|
const QJsonArray txArray = stationObject.value("transceivers").toArray();
|
||||||
for (auto jt = txArray.begin(); jt != txArray.end(); ++jt)
|
for (auto jt = txArray.begin(); jt != txArray.end(); ++jt)
|
||||||
{
|
{
|
||||||
TransceiverDto transceiver = TransceiverDto::fromJson(jt->toObject());
|
const TransceiverDto transceiver = TransceiverDto::fromJson(jt->toObject());
|
||||||
transceivers.push_back({ callsign, transceiver});
|
transceivers.push_back({ callsign, transceiver});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,10 +31,13 @@ namespace BlackCore
|
|||||||
//! Ctor
|
//! Ctor
|
||||||
CAfvMapReader(QObject *parent = nullptr);
|
CAfvMapReader(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
//! Own callsign
|
||||||
Q_INVOKABLE void setOwnCallsign(const QString &callsign) { m_callsign = callsign; }
|
Q_INVOKABLE void setOwnCallsign(const QString &callsign) { m_callsign = callsign; }
|
||||||
|
|
||||||
|
//! Update ATC stations in model
|
||||||
void updateFromMap();
|
void updateFromMap();
|
||||||
|
|
||||||
|
//! ATC model
|
||||||
CSampleAtcStationModel *getAtcStationModel() { return m_model; }
|
CSampleAtcStationModel *getAtcStationModel() { return m_model; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -44,9 +44,8 @@ namespace BlackCore
|
|||||||
|
|
||||||
double CSampleAtcStation::radioDistanceM() const
|
double CSampleAtcStation::radioDistanceM() const
|
||||||
{
|
{
|
||||||
double sqrtAltM = qSqrt(m_transceiver.HeightMslM);
|
const double sqrtAltM = qSqrt(m_transceiver.HeightMslM);
|
||||||
const double radioFactor = 4193.18014745372;
|
const double radioFactor = 4193.18014745372;
|
||||||
|
|
||||||
return radioFactor * sqrtAltM;
|
return radioFactor * sqrtAltM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user