mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
[AFV] style, const, formatting
This commit is contained in:
@@ -53,8 +53,8 @@ namespace BlackCore
|
||||
{
|
||||
OutputVolumeStreamArgs outputVolumeStreamArgs;
|
||||
outputVolumeStreamArgs.PeakRaw = m_maxSampleOutput / 1.0;
|
||||
outputVolumeStreamArgs.PeakDB = static_cast<float>(20 * std::log10(outputVolumeStreamArgs.PeakRaw));
|
||||
const double db = qBound(m_minDb, outputVolumeStreamArgs.PeakDB, m_maxDb);
|
||||
outputVolumeStreamArgs.PeakDb = static_cast<float>(20 * std::log10(outputVolumeStreamArgs.PeakRaw));
|
||||
const double db = qBound(m_minDb, outputVolumeStreamArgs.PeakDb, m_maxDb);
|
||||
double ratio = (db - m_minDb) / (m_maxDb - m_minDb);
|
||||
if (ratio < 0.30) { ratio = 0.0; }
|
||||
if (ratio > 1.0) { ratio = 1.0; }
|
||||
|
||||
@@ -26,9 +26,9 @@ namespace BlackCore
|
||||
//! Stream args
|
||||
struct OutputVolumeStreamArgs
|
||||
{
|
||||
double PeakRaw = 0.0;
|
||||
double PeakDB = -1 * std::numeric_limits<double>::infinity();
|
||||
double PeakVU = 0.0;
|
||||
double PeakRaw = 0.0; //!< raw peak
|
||||
double PeakDb = -1 * std::numeric_limits<double>::infinity(); //!< dB peak
|
||||
double PeakVU = 0.0; //!< VU peak
|
||||
};
|
||||
|
||||
//! Output buffer
|
||||
@@ -60,9 +60,9 @@ namespace BlackCore
|
||||
static constexpr int SampleCountPerEvent = 4800;
|
||||
QAudioFormat m_outputFormat;
|
||||
float m_maxSampleOutput = 0.0;
|
||||
int m_sampleCount = 0;
|
||||
const double m_maxDb = 0;
|
||||
const double m_minDb = -40;
|
||||
int m_sampleCount = 0;
|
||||
const double m_maxDb = 0;
|
||||
const double m_minDb = -40;
|
||||
};
|
||||
|
||||
//! Output
|
||||
@@ -95,10 +95,9 @@ namespace BlackCore
|
||||
|
||||
private:
|
||||
bool m_started = false;
|
||||
|
||||
BlackMisc::Audio::CAudioDeviceInfo m_device;
|
||||
QScopedPointer<QAudioOutput> m_audioOutputCom;
|
||||
CAudioOutputBuffer *m_audioOutputBuffer = nullptr;
|
||||
QScopedPointer<QAudioOutput> m_audioOutputCom;
|
||||
CAudioOutputBuffer *m_audioOutputBuffer = nullptr;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -38,24 +38,24 @@ namespace BlackCore
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDoc.isObject())
|
||||
{
|
||||
QJsonObject rootObject = jsonDoc.object();
|
||||
const QJsonObject rootObject = jsonDoc.object();
|
||||
QVector<CSampleAtcStation> transceivers;
|
||||
|
||||
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)
|
||||
{
|
||||
QString callsign = it.key();
|
||||
const QString callsign = it.key();
|
||||
if (it.value().isObject())
|
||||
{
|
||||
QJsonObject stationObject = it.value().toObject();
|
||||
const QJsonObject stationObject = it.value().toObject();
|
||||
if (stationObject.contains("transceivers"))
|
||||
{
|
||||
QJsonArray txArray = stationObject.value("transceivers").toArray();
|
||||
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});
|
||||
}
|
||||
}
|
||||
@@ -65,19 +65,19 @@ namespace BlackCore
|
||||
|
||||
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)
|
||||
{
|
||||
QString callsign = it.key();
|
||||
const QString callsign = it.key();
|
||||
if (it.value().isObject())
|
||||
{
|
||||
QJsonObject stationObject = it.value().toObject();
|
||||
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)
|
||||
{
|
||||
TransceiverDto transceiver = TransceiverDto::fromJson(jt->toObject());
|
||||
const TransceiverDto transceiver = TransceiverDto::fromJson(jt->toObject());
|
||||
transceivers.push_back({ callsign, transceiver});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,13 @@ namespace BlackCore
|
||||
//! Ctor
|
||||
CAfvMapReader(QObject *parent = nullptr);
|
||||
|
||||
//! Own callsign
|
||||
Q_INVOKABLE void setOwnCallsign(const QString &callsign) { m_callsign = callsign; }
|
||||
|
||||
//! Update ATC stations in model
|
||||
void updateFromMap();
|
||||
|
||||
//! ATC model
|
||||
CSampleAtcStationModel *getAtcStationModel() { return m_model; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -44,9 +44,8 @@ namespace BlackCore
|
||||
|
||||
double CSampleAtcStation::radioDistanceM() const
|
||||
{
|
||||
double sqrtAltM = qSqrt(m_transceiver.HeightMslM);
|
||||
const double sqrtAltM = qSqrt(m_transceiver.HeightMslM);
|
||||
const double radioFactor = 4193.18014745372;
|
||||
|
||||
return radioFactor * sqrtAltM;
|
||||
}
|
||||
|
||||
@@ -68,7 +67,7 @@ namespace BlackCore
|
||||
for (int i = m_atcStations.size() - 1; i >= 0; i--)
|
||||
{
|
||||
CSampleAtcStation &station = m_atcStations[i];
|
||||
if (! m_atcStations.contains(station))
|
||||
if (!m_atcStations.contains(station))
|
||||
{
|
||||
removeStationAtPosition(i);
|
||||
}
|
||||
@@ -113,12 +112,12 @@ namespace BlackCore
|
||||
QHash<int, QByteArray> CSampleAtcStationModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[CallsignRole] = "callsign";
|
||||
roles[LatitudeRole] = "latitude";
|
||||
roles[LongitudeRole] = "longitude";
|
||||
roles[CallsignRole] = "callsign";
|
||||
roles[LatitudeRole] = "latitude";
|
||||
roles[LongitudeRole] = "longitude";
|
||||
roles[RadioDistanceRole] = "radioDistanceM";
|
||||
roles[FrequencyRole] = "frequencyAsString";
|
||||
roles[FrequencyKhzRole] = "frequencyKhz";
|
||||
roles[FrequencyRole] = "frequencyAsString";
|
||||
roles[FrequencyKhzRole] = "frequencyKhz";
|
||||
return roles;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user