mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-11 12:15:36 +08:00
refactor: clang format line length
This commit is contained in:
@@ -5,12 +5,12 @@
|
||||
|
||||
using namespace swift::core::afv::clients;
|
||||
|
||||
CAfvClientBridge::CAfvClientBridge(CAfvClient *afvClient, QObject *parent) : QObject(parent),
|
||||
m_afvClient(afvClient)
|
||||
CAfvClientBridge::CAfvClientBridge(CAfvClient *afvClient, QObject *parent) : QObject(parent), m_afvClient(afvClient)
|
||||
{
|
||||
connect(afvClient, &CAfvClient::receivingCallsignsChanged, this, &CAfvClientBridge::receivingCallsignsChanged);
|
||||
connect(afvClient, &CAfvClient::connectionStatusChanged, this, &CAfvClientBridge::connectionStatusChanged);
|
||||
connect(afvClient, &CAfvClient::updatedFromOwnAircraftCockpit, this, &CAfvClientBridge::updatedFromOwnAircraftCockpit);
|
||||
connect(afvClient, &CAfvClient::updatedFromOwnAircraftCockpit, this,
|
||||
&CAfvClientBridge::updatedFromOwnAircraftCockpit);
|
||||
connect(afvClient, &CAfvClient::ptt, this, &CAfvClientBridge::ptt);
|
||||
connect(afvClient, &CAfvClient::inputVolumePeakVU, this, &CAfvClientBridge::inputVolumePeakVU);
|
||||
connect(afvClient, &CAfvClient::outputVolumePeakVU, this, &CAfvClientBridge::outputVolumePeakVU);
|
||||
|
||||
@@ -19,7 +19,8 @@ class CAfvClientBridge : public QObject
|
||||
//! @{
|
||||
Q_PROPERTY(double inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU)
|
||||
Q_PROPERTY(double outputVolumePeakVU READ getOutputVolumePeakVU NOTIFY outputVolumePeakVU)
|
||||
Q_PROPERTY(swift::core::afv::clients::CAfvClient::ConnectionStatus connectionStatus READ getConnectionStatus NOTIFY connectionStatusChanged)
|
||||
Q_PROPERTY(swift::core::afv::clients::CAfvClient::ConnectionStatus connectionStatus READ getConnectionStatus NOTIFY
|
||||
connectionStatusChanged)
|
||||
Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsCom1 NOTIFY receivingCallsignsChanged)
|
||||
Q_PROPERTY(QString receivingCallsignsCom2 READ getReceivingCallsignsCom2 NOTIFY receivingCallsignsChanged)
|
||||
//! @}
|
||||
@@ -66,13 +67,19 @@ public:
|
||||
Q_INVOKABLE void setBypassEffects(bool value) { m_afvClient->setBypassEffects(value); }
|
||||
|
||||
//! \copydoc swift::core::afv::clients::CAfvClient::startAudio
|
||||
Q_INVOKABLE void startAudio(const QString &inputDeviceName, const QString &outputDeviceName) { m_afvClient->startAudio(inputDeviceName, outputDeviceName); }
|
||||
Q_INVOKABLE void startAudio(const QString &inputDeviceName, const QString &outputDeviceName)
|
||||
{
|
||||
m_afvClient->startAudio(inputDeviceName, outputDeviceName);
|
||||
}
|
||||
|
||||
//! \copydoc swift::core::afv::clients::CAfvClient::enableTransceiver
|
||||
Q_INVOKABLE void enableTransceiver(quint16 id, bool enable) { m_afvClient->enableTransceiver(id, enable); }
|
||||
|
||||
//! \copydoc swift::core::afv::clients::CAfvClient::updateComFrequency
|
||||
Q_INVOKABLE void updateComFrequency(quint16 id, quint32 frequencyHz) { m_afvClient->updateComFrequency(id, frequencyHz); }
|
||||
Q_INVOKABLE void updateComFrequency(quint16 id, quint32 frequencyHz)
|
||||
{
|
||||
m_afvClient->updateComFrequency(id, frequencyHz);
|
||||
}
|
||||
|
||||
//! \copydoc swift::core::afv::clients::CAfvClient::updatePosition
|
||||
Q_INVOKABLE void updatePosition(double latitudeDeg, double longitudeDeg, double heightMeters)
|
||||
@@ -93,7 +100,10 @@ public:
|
||||
Q_INVOKABLE void setInputVolumeDb(double valueDb) { m_afvClient->setInputVolumeDb(valueDb); }
|
||||
|
||||
//! \copydoc swift::core::afv::clients::CAfvClient::setNormalizedMasterOutputVolume
|
||||
Q_INVOKABLE void setNormalizedMasterOutputVolume(double valueDb) { m_afvClient->setNormalizedMasterOutputVolume(valueDb); }
|
||||
Q_INVOKABLE void setNormalizedMasterOutputVolume(double valueDb)
|
||||
{
|
||||
m_afvClient->setNormalizedMasterOutputVolume(valueDb);
|
||||
}
|
||||
|
||||
signals:
|
||||
//! Receiving callsigns have been changed
|
||||
|
||||
@@ -41,9 +41,7 @@ int main(int argc, char *argv[])
|
||||
voiceClient->start(QThread::TimeCriticalPriority); // background thread
|
||||
CAfvClientBridge *voiceClientBridge = new CAfvClientBridge(voiceClient, &qa);
|
||||
|
||||
QObject::connect(&qa, &QCoreApplication::aboutToQuit, [voiceClient]() {
|
||||
voiceClient->quitAndWait();
|
||||
});
|
||||
QObject::connect(&qa, &QCoreApplication::aboutToQuit, [voiceClient]() { voiceClient->quitAndWait(); });
|
||||
|
||||
// default user name
|
||||
QString defaultUserName("1234567");
|
||||
|
||||
@@ -22,7 +22,8 @@ int main(int argc, char *argv[])
|
||||
QCoreApplication qa(argc, argv);
|
||||
COwnAircraftProviderDummy::instance()->updateOwnCallsign("BER368");
|
||||
|
||||
CFSDClient client(CClientProviderDummy::instance(), COwnAircraftProviderDummy::instance(), CRemoteAircraftProviderDummy::instance(), &qa);
|
||||
CFSDClient client(CClientProviderDummy::instance(), COwnAircraftProviderDummy::instance(),
|
||||
CRemoteAircraftProviderDummy::instance(), &qa);
|
||||
client.setClientName("Test Client");
|
||||
client.setHostApplication("None");
|
||||
client.setVersion(0, 8);
|
||||
@@ -48,8 +49,8 @@ int main(int argc, char *argv[])
|
||||
client.sendFsdMessage("$CRLOWW_F_APP:LHA449:ATIS:E:6\r\n");
|
||||
client.sendFsdMessage("$CRN1234:BAW345:CAPS:INTERIMPOS=1:MODELDESC=1:ATCINFO=1:STEALTH=1:ACCONFIG=1\r\n");
|
||||
client.sendFsdMessage("#SBBAW106:LHA449:PI:GEN:EQUIPMENT=B744:AIRLINE=BAW:LIVERY=UNION\r\n");
|
||||
client.sendFsdMessage("#SBGEC55F:DESWL:FSIPIR:1::MD11:12.93209:-0.01354:3648.00000:4.CB8FB1E0.984745A0::PMDG MD-11F Lufthansa Cargo WOW\r\n");
|
||||
client.sendFsdMessage("#TMAFR529:@20500&@26000:taxi to entry N1 via M A4\r\n");
|
||||
client.sendFsdMessage("#SBGEC55F:DESWL:FSIPIR:1::MD11:12.93209:-0.01354:3648.00000:4.CB8FB1E0.984745A0::PMDG MD-11F
|
||||
Lufthansa Cargo WOW\r\n"); client.sendFsdMessage("#TMAFR529:@20500&@26000:taxi to entry N1 via M A4\r\n");
|
||||
client.sendFsdMessage("$CQDLH123:BER368:ACC:json config\r\n");
|
||||
client.sendFsdMessage("$CQDLH123:@94836:ACC:{\"request\":\"full\"}\r\n");
|
||||
client.sendFsdMessage("#SBAUA417C:LHA449:PI:X:0:1:~B737");
|
||||
|
||||
@@ -37,8 +37,7 @@ int main(int argc, char *argv[])
|
||||
QTextStream qtout(stdout);
|
||||
QTextStream qtin(stdin);
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
qtout << Qt::endl;
|
||||
qtout << "1 .. JSON" << Qt::endl;
|
||||
qtout << "2 .. Change object" << Qt::endl;
|
||||
|
||||
@@ -29,10 +29,7 @@ namespace swift::sample
|
||||
int CSamplesAlgorithm::samples()
|
||||
{
|
||||
swift::misc::CSequence<int> seq;
|
||||
for (int i = 1; i <= 100; ++i)
|
||||
{
|
||||
seq.push_back(i);
|
||||
}
|
||||
for (int i = 1; i <= 100; ++i) { seq.push_back(i); }
|
||||
const int samples = 200;
|
||||
swift::misc::CSequence<int> means;
|
||||
{
|
||||
@@ -42,7 +39,9 @@ namespace swift::sample
|
||||
means.push_back(std::accumulate(randoms.cbegin(), randoms.cend(), 0) / 10);
|
||||
}
|
||||
int mean = std::accumulate(means.cbegin(), means.cend(), 0) / samples;
|
||||
int stdDev = std::sqrt(std::accumulate(means.cbegin(), means.cend(), 0, [&](int a, int n) { return a + (n - mean) * (n - mean); }) / samples);
|
||||
int stdDev = std::sqrt(std::accumulate(means.cbegin(), means.cend(), 0,
|
||||
[&](int a, int n) { return a + (n - mean) * (n - mean); }) /
|
||||
samples);
|
||||
qDebug() << "randomElements";
|
||||
qDebug() << "means:" << means;
|
||||
qDebug() << "mean of the means:" << mean;
|
||||
@@ -56,7 +55,9 @@ namespace swift::sample
|
||||
means.push_back(std::accumulate(randoms.cbegin(), randoms.cend(), 0) / 10);
|
||||
}
|
||||
int mean = std::accumulate(means.cbegin(), means.cend(), 0) / samples;
|
||||
int stdDev = std::sqrt(std::accumulate(means.cbegin(), means.cend(), 0, [&](int a, int n) { return a + (n - mean) * (n - mean); }) / samples);
|
||||
int stdDev = std::sqrt(std::accumulate(means.cbegin(), means.cend(), 0,
|
||||
[&](int a, int n) { return a + (n - mean) * (n - mean); }) /
|
||||
samples);
|
||||
qDebug() << "sampleElements";
|
||||
qDebug() << "means:" << means;
|
||||
qDebug() << "mean of the means:" << mean;
|
||||
@@ -69,7 +70,10 @@ namespace swift::sample
|
||||
qDebug() << "topologicallySortedInsert";
|
||||
QStringList dst;
|
||||
int count = 0;
|
||||
auto cmp = [&](const QString &a, const QString &b) { count++; return a[0] == b[0] && a[1] < b[1]; };
|
||||
auto cmp = [&](const QString &a, const QString &b) {
|
||||
count++;
|
||||
return a[0] == b[0] && a[1] < b[1];
|
||||
};
|
||||
for (const auto &s : src) { swift::misc::topologicallySortedInsert(dst, s, cmp); }
|
||||
qDebug() << count << "comparisons";
|
||||
qDebug() << dst;
|
||||
|
||||
@@ -32,14 +32,15 @@ namespace swift::sample
|
||||
int CSamplesChangeObject::samples()
|
||||
{
|
||||
// ATC station
|
||||
const CCoordinateGeodetic geoPos = CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() });
|
||||
const CCoordinateGeodetic geoPos =
|
||||
CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", { 1487, CLengthUnit::ft() });
|
||||
const CAtcStation station1(CCallsign("eddm_twr"), CUser("123456", "Joe Doe"),
|
||||
CFrequency(118.7, CFrequencyUnit::MHz()),
|
||||
geoPos, CLength(50, CLengthUnit::km()), false);
|
||||
CFrequency(118.7, CFrequencyUnit::MHz()), geoPos, CLength(50, CLengthUnit::km()),
|
||||
false);
|
||||
const CAtcStation station2(station1);
|
||||
const CAtcStation station3(CCallsign("eddm_app"), CUser("654321", "Jen Doe"),
|
||||
CFrequency(120.7, CFrequencyUnit::MHz()),
|
||||
geoPos, CLength(100, CLengthUnit::km()), false);
|
||||
CFrequency(120.7, CFrequencyUnit::MHz()), geoPos, CLength(100, CLengthUnit::km()),
|
||||
false);
|
||||
|
||||
Q_ASSERT_X(station1 == station2, Q_FUNC_INFO, "Unequal stations");
|
||||
|
||||
@@ -57,9 +58,8 @@ namespace swift::sample
|
||||
// put Jane in the tower
|
||||
CPropertyIndexVariantMap newController;
|
||||
newController.addValue(CAtcStation::IndexController, CVariant::fromValue(CUser("112233", "Jane Doe")));
|
||||
atcList.applyIf(
|
||||
swift::misc::predicates::MemberEqual(&CAtcStation::getCallsign, CCallsign("eddm_twr")),
|
||||
newController);
|
||||
atcList.applyIf(swift::misc::predicates::MemberEqual(&CAtcStation::getCallsign, CCallsign("eddm_twr")),
|
||||
newController);
|
||||
qDebug() << "-- after update via predicates";
|
||||
qDebug() << atcList.toQString();
|
||||
|
||||
|
||||
@@ -53,7 +53,8 @@ namespace swift::sample
|
||||
qDebug() << "-- list:";
|
||||
qDebug() << atcList.toQString();
|
||||
|
||||
CAtcStationList atcListFind = atcList.findBy(&CAtcStation::getCallsign, "eddm_twr", &CAtcStation::getFrequency, CFrequency(118.7, CFrequencyUnit::MHz()));
|
||||
CAtcStationList atcListFind = atcList.findBy(&CAtcStation::getCallsign, "eddm_twr", &CAtcStation::getFrequency,
|
||||
CFrequency(118.7, CFrequencyUnit::MHz()));
|
||||
qDebug() << "-- find by:";
|
||||
qDebug() << atcListFind.toQString();
|
||||
|
||||
|
||||
@@ -67,7 +67,8 @@ namespace swift::sample
|
||||
qDebug() << "------- Enter -----";
|
||||
cin.readLine();
|
||||
|
||||
CSimulatedAircraft aircraft(CCallsign("DAMBZ"), CUser("123456", "Joe Pilot"), CTestData::getAircraftSituationAboveMunichTower());
|
||||
CSimulatedAircraft aircraft(CCallsign("DAMBZ"), CUser("123456", "Joe Pilot"),
|
||||
CTestData::getAircraftSituationAboveMunichTower());
|
||||
aircraft.setCom1System(CComSystem::getCom1System(122.8, 118.75));
|
||||
aircraft.setCom2System(CComSystem::getCom2System(123.8, 124.00));
|
||||
aircraft.setTransponder(CTransponder::getStandardTransponder(7000, CTransponder::ModeC));
|
||||
|
||||
@@ -329,7 +329,8 @@ namespace swift::sample
|
||||
timer.start();
|
||||
const CLiveryList dbLiveries3 = CLiveryList::fromDatabaseJsonCaching(response, liveryAirlines);
|
||||
ms = timer.elapsed();
|
||||
out << "Read via DB JSON format (new, passing airlines): " << dbLiveries3.size() << " liveries in " << ms << "ms" << Qt::endl;
|
||||
out << "Read via DB JSON format (new, passing airlines): " << dbLiveries3.size() << " liveries in " << ms
|
||||
<< "ms" << Qt::endl;
|
||||
|
||||
CDatabaseReader::stringToDatastoreResponse(modelData, response);
|
||||
timer.start();
|
||||
@@ -359,11 +360,13 @@ namespace swift::sample
|
||||
int CSamplesPerformance::samplesStringUtilsVsRegEx(QTextStream &out)
|
||||
{
|
||||
QElapsedTimer timer;
|
||||
static const QString chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~_-=+!\"@#$%^&*()[]{} \t;:\\/?,.<>";
|
||||
static const QString chars =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~_-=+!\"@#$%^&*()[]{} \t;:\\/?,.<>";
|
||||
QStringList strings;
|
||||
std::generate_n(std::back_inserter(strings), 100000, [] {
|
||||
QString s;
|
||||
std::generate_n(std::back_inserter(s), 10, [] { return chars[CMathUtils::randomInteger(0, chars.size() - 1)]; });
|
||||
std::generate_n(std::back_inserter(s), 10,
|
||||
[] { return chars[CMathUtils::randomInteger(0, chars.size() - 1)]; });
|
||||
return s;
|
||||
});
|
||||
QString bigString = strings.join("\n");
|
||||
@@ -377,7 +380,8 @@ namespace swift::sample
|
||||
auto c = containsChar(s, [](QChar c) { return c.isUpper(); });
|
||||
Q_UNUSED(c);
|
||||
}
|
||||
out << "Check 100,000 strings for containing uppercase letter: (utility) " << timer.elapsed() << "ms" << Qt::endl;
|
||||
out << "Check 100,000 strings for containing uppercase letter: (utility) " << timer.elapsed() << "ms"
|
||||
<< Qt::endl;
|
||||
|
||||
timer.start();
|
||||
for (const QString &s : std::as_const(strings))
|
||||
@@ -385,7 +389,8 @@ namespace swift::sample
|
||||
auto c = s.contains(upperRegex);
|
||||
Q_UNUSED(c);
|
||||
}
|
||||
out << "Check 100,000 strings for containing uppercase letter: (regex) " << timer.elapsed() << "ms" << Qt::endl
|
||||
out << "Check 100,000 strings for containing uppercase letter: (regex) " << timer.elapsed() << "ms"
|
||||
<< Qt::endl
|
||||
<< Qt::endl;
|
||||
|
||||
timer.start();
|
||||
@@ -394,7 +399,8 @@ namespace swift::sample
|
||||
auto i = indexOfChar(s, [](QChar c) { return c.isUpper(); });
|
||||
Q_UNUSED(i);
|
||||
}
|
||||
out << "Check 100,000 strings for index of first uppercase letter: (utility) " << timer.elapsed() << "ms" << Qt::endl;
|
||||
out << "Check 100,000 strings for index of first uppercase letter: (utility) " << timer.elapsed() << "ms"
|
||||
<< Qt::endl;
|
||||
|
||||
timer.start();
|
||||
for (const QString &s : std::as_const(strings))
|
||||
@@ -402,7 +408,8 @@ namespace swift::sample
|
||||
auto i = s.indexOf(upperRegex);
|
||||
Q_UNUSED(i);
|
||||
}
|
||||
out << "Check 100,000 strings for index of first uppercase letter: (regex) " << timer.elapsed() << "ms" << Qt::endl
|
||||
out << "Check 100,000 strings for index of first uppercase letter: (regex) " << timer.elapsed() << "ms"
|
||||
<< Qt::endl
|
||||
<< Qt::endl;
|
||||
|
||||
auto temp = strings;
|
||||
@@ -411,15 +418,14 @@ namespace swift::sample
|
||||
{
|
||||
removeChars(s, [](QChar c) { return c.isUpper(); });
|
||||
}
|
||||
out << "Remove from 100,000 strings all uppercase letters: (utility) " << timer.elapsed() << "ms" << Qt::endl;
|
||||
out << "Remove from 100,000 strings all uppercase letters: (utility) " << timer.elapsed() << "ms"
|
||||
<< Qt::endl;
|
||||
strings = temp;
|
||||
|
||||
timer.start();
|
||||
for (QString &s : strings)
|
||||
{
|
||||
s.remove(upperRegex);
|
||||
}
|
||||
out << "Remove from 100,000 strings all uppercase letters: (regex) " << timer.elapsed() << "ms" << Qt::endl
|
||||
for (QString &s : strings) { s.remove(upperRegex); }
|
||||
out << "Remove from 100,000 strings all uppercase letters: (regex) " << timer.elapsed() << "ms"
|
||||
<< Qt::endl
|
||||
<< Qt::endl;
|
||||
|
||||
timer.start();
|
||||
@@ -427,14 +433,16 @@ namespace swift::sample
|
||||
auto lines = splitLines(bigString);
|
||||
Q_UNUSED(lines);
|
||||
}
|
||||
out << "Split 100,000 line string into list of lines: (QStringList) " << timer.elapsed() << "ms" << Qt::endl;
|
||||
out << "Split 100,000 line string into list of lines: (QStringList) " << timer.elapsed() << "ms"
|
||||
<< Qt::endl;
|
||||
|
||||
timer.start();
|
||||
{
|
||||
auto lines = splitLinesRefs(bigString);
|
||||
Q_UNUSED(lines);
|
||||
}
|
||||
out << "Split 100,000 line string into list of lines: (QList<QStringRef>) " << timer.elapsed() << "ms" << Qt::endl;
|
||||
out << "Split 100,000 line string into list of lines: (QList<QStringRef>) " << timer.elapsed() << "ms"
|
||||
<< Qt::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -455,10 +463,7 @@ namespace swift::sample
|
||||
|
||||
QElapsedTimer time;
|
||||
time.start();
|
||||
for (int i = 0; i < loop; i++)
|
||||
{
|
||||
x += "12-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
}
|
||||
for (int i = 0; i < loop; i++) { x += "12-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; }
|
||||
out << "+= String " << time.elapsed() << "ms" << Qt::endl;
|
||||
x.clear();
|
||||
|
||||
@@ -479,18 +484,12 @@ namespace swift::sample
|
||||
x.clear();
|
||||
|
||||
time.start();
|
||||
for (int i = 0; i < loop; i++)
|
||||
{
|
||||
x = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9;
|
||||
}
|
||||
for (int i = 0; i < loop; i++) { x = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9; }
|
||||
out << "+ String multiple " << time.elapsed() << "ms" << Qt::endl;
|
||||
x.clear();
|
||||
|
||||
time.start();
|
||||
for (int i = 0; i < loop; i++)
|
||||
{
|
||||
x = x1 % x2 % x3 % x4 % x5 % x6 % x7 % x8 % x9;
|
||||
}
|
||||
for (int i = 0; i < loop; i++) { x = x1 % x2 % x3 % x4 % x5 % x6 % x7 % x8 % x9; }
|
||||
out << "% String multiple " << time.elapsed() << "ms" << Qt::endl;
|
||||
x.clear();
|
||||
|
||||
@@ -504,10 +503,7 @@ namespace swift::sample
|
||||
|
||||
static const QString xArgString("%1 %2 %3 %4 %5 %6 %7 %8 %9");
|
||||
time.start();
|
||||
for (int i = 0; i < loop; i++)
|
||||
{
|
||||
x = xArgString.arg(x1, x2, x3, x4, x5, x6, x7, x8, x9);
|
||||
}
|
||||
for (int i = 0; i < loop; i++) { x = xArgString.arg(x1, x2, x3, x4, x5, x6, x7, x8, x9); }
|
||||
out << "arg String multiple " << time.elapsed() << "ms" << Qt::endl;
|
||||
x.clear();
|
||||
|
||||
@@ -528,25 +524,20 @@ namespace swift::sample
|
||||
QElapsedTimer time;
|
||||
QString x;
|
||||
time.start();
|
||||
for (int i = 0; i < loop; i++)
|
||||
{
|
||||
x = fooString();
|
||||
}
|
||||
for (int i = 0; i < loop; i++) { x = fooString(); }
|
||||
out << "by constQString " << time.elapsed() << "ms" << Qt::endl;
|
||||
x.clear();
|
||||
|
||||
time.start();
|
||||
for (int i = 0; i < loop; i++)
|
||||
{
|
||||
x = fooStringLiteral();
|
||||
}
|
||||
for (int i = 0; i < loop; i++) { x = fooStringLiteral(); }
|
||||
out << "by QStringLiteral " << time.elapsed() << "ms" << Qt::endl;
|
||||
x.clear();
|
||||
|
||||
time.start();
|
||||
for (int i = 0; i < loop; i++)
|
||||
{
|
||||
x = QString("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.");
|
||||
x = QString("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. "
|
||||
"Sed cursus ante dapibus diam. Sed nisi.");
|
||||
}
|
||||
out << "by QString(\"...\") " << time.elapsed() << "ms" << Qt::endl;
|
||||
x.clear();
|
||||
@@ -554,7 +545,8 @@ namespace swift::sample
|
||||
time.start();
|
||||
for (int i = 0; i < loop; i++)
|
||||
{
|
||||
x = QStringLiteral("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.");
|
||||
x = QStringLiteral("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent "
|
||||
"libero. Sed cursus ante dapibus diam. Sed nisi.");
|
||||
}
|
||||
out << "by QStringLiteral(\"...\") " << time.elapsed() << "ms" << Qt::endl;
|
||||
x.clear();
|
||||
@@ -682,7 +674,8 @@ namespace swift::sample
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
CAircraftSituationList CSamplesPerformance::createSituations(qint64 baseTimeEpoch, int numberOfCallsigns, int numberOfTimes)
|
||||
CAircraftSituationList CSamplesPerformance::createSituations(qint64 baseTimeEpoch, int numberOfCallsigns,
|
||||
int numberOfTimes)
|
||||
{
|
||||
CAircraftSituationList situations;
|
||||
for (int cs = 0; cs < numberOfCallsigns; cs++)
|
||||
@@ -706,8 +699,12 @@ namespace swift::sample
|
||||
CDistributorList distributors;
|
||||
for (int i = 0; i < numberOfMemoParts; ++i)
|
||||
{
|
||||
aircraftIcaos.push_back(CAircraftIcaoCode("A" + QString::number(i), "A" + QString::number(i), "L1P", "Lego", "Foo", CWakeTurbulenceCategory::MEDIUM, false, false, false, 0));
|
||||
liveries.push_back(CLivery("A" + QString::number(i), CAirlineIcaoCode("A" + QString::number(i), "Foo", CCountry("DE", "Germany"), "Foo", false, false), "Foo", "red", "blue", false));
|
||||
aircraftIcaos.push_back(CAircraftIcaoCode("A" + QString::number(i), "A" + QString::number(i), "L1P", "Lego",
|
||||
"Foo", CWakeTurbulenceCategory::MEDIUM, false, false, false, 0));
|
||||
liveries.push_back(CLivery(
|
||||
"A" + QString::number(i),
|
||||
CAirlineIcaoCode("A" + QString::number(i), "Foo", CCountry("DE", "Germany"), "Foo", false, false),
|
||||
"Foo", "red", "blue", false));
|
||||
distributors.push_back(CDistributor(QString::number(i), "Foo", {}, {}, CSimulatorInfo::FSX));
|
||||
}
|
||||
|
||||
@@ -717,7 +714,8 @@ namespace swift::sample
|
||||
const auto &aircraftIcao = aircraftIcaos[CMathUtils::randomInteger(0, numberOfMemoParts - 1)];
|
||||
const auto &livery = liveries[CMathUtils::randomInteger(0, numberOfMemoParts - 1)];
|
||||
const auto &distributor = distributors[CMathUtils::randomInteger(0, numberOfMemoParts - 1)];
|
||||
models.push_back(CAircraftModel(QString::number(i), CAircraftModel::TypeUnknown, CSimulatorInfo::FSX, QString::number(i), QString::number(i), aircraftIcao, livery));
|
||||
models.push_back(CAircraftModel(QString::number(i), CAircraftModel::TypeUnknown, CSimulatorInfo::FSX,
|
||||
QString::number(i), QString::number(i), aircraftIcao, livery));
|
||||
models.back().setDistributor(distributor);
|
||||
}
|
||||
return models;
|
||||
@@ -728,12 +726,9 @@ namespace swift::sample
|
||||
if (n < 1) { return; }
|
||||
CAtcStation atc = CTesting::createStation(1);
|
||||
const QList<CCoordinateGeodetic> pos(
|
||||
{ CCoordinateGeodetic(10.0, 10.0, 10.0),
|
||||
CCoordinateGeodetic(20.0, 20.0, 20.0),
|
||||
CCoordinateGeodetic(30.0, 30.0, 30.0),
|
||||
CCoordinateGeodetic(40.0, 40.0, 40.0),
|
||||
CCoordinateGeodetic(50.0, 50.0, 50.0),
|
||||
CCoordinateGeodetic(60.0, 60.0, 60.0),
|
||||
{ CCoordinateGeodetic(10.0, 10.0, 10.0), CCoordinateGeodetic(20.0, 20.0, 20.0),
|
||||
CCoordinateGeodetic(30.0, 30.0, 30.0), CCoordinateGeodetic(40.0, 40.0, 40.0),
|
||||
CCoordinateGeodetic(50.0, 50.0, 50.0), CCoordinateGeodetic(60.0, 60.0, 60.0),
|
||||
CCoordinateGeodetic(70.0, 70.0, 70.0) });
|
||||
const int s = pos.size();
|
||||
for (int i = 0; i < n; i++)
|
||||
@@ -755,12 +750,9 @@ namespace swift::sample
|
||||
|
||||
void CSamplesPerformance::parseWgs(int times)
|
||||
{
|
||||
static QStringList wgsLatLng(
|
||||
{ "12° 11′ 10″ N", "11° 22′ 33″ W",
|
||||
"48° 21′ 13″ N", "11° 47′ 09″ E",
|
||||
" 8° 21′ 13″ N", "11° 47′ 09″ W",
|
||||
"18° 21′ 13″ S", "11° 47′ 09″ E",
|
||||
"09° 12′ 13″ S", "11° 47′ 09″ W" });
|
||||
static QStringList wgsLatLng({ "12° 11′ 10″ N", "11° 22′ 33″ W", "48° 21′ 13″ N", "11° 47′ 09″ E",
|
||||
" 8° 21′ 13″ N", "11° 47′ 09″ W", "18° 21′ 13″ S", "11° 47′ 09″ E",
|
||||
"09° 12′ 13″ S", "11° 47′ 09″ W" });
|
||||
|
||||
CCoordinateGeodetic c;
|
||||
const CAltitude a(333, CLengthUnit::m());
|
||||
@@ -773,19 +765,18 @@ namespace swift::sample
|
||||
|
||||
const QString &CSamplesPerformance::fooString()
|
||||
{
|
||||
static const QString s("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.");
|
||||
static const QString s("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent "
|
||||
"libero. Sed cursus ante dapibus diam. Sed nisi.");
|
||||
return s;
|
||||
}
|
||||
|
||||
QString CSamplesPerformance::fooStringLiteral()
|
||||
{
|
||||
return QStringLiteral("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.");
|
||||
return QStringLiteral("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent "
|
||||
"libero. Sed cursus ante dapibus diam. Sed nisi.");
|
||||
}
|
||||
|
||||
QStringList CSamplesPerformance::generateList()
|
||||
{
|
||||
return QStringList({ "1", "2", "3", "4" });
|
||||
}
|
||||
QStringList CSamplesPerformance::generateList() { return QStringList({ "1", "2", "3", "4" }); }
|
||||
|
||||
QStringList CSamplesPerformance::replacedList()
|
||||
{
|
||||
@@ -800,10 +791,7 @@ namespace swift::sample
|
||||
{
|
||||
CCallsignSet set;
|
||||
static const QString cs("FOO%1");
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
set.insert(CCallsign(cs.arg(i)));
|
||||
}
|
||||
for (int i = 0; i < number; i++) { set.insert(CCallsign(cs.arg(i))); }
|
||||
return set;
|
||||
}
|
||||
|
||||
@@ -849,12 +837,25 @@ namespace swift::sample
|
||||
QString r;
|
||||
if (byPropertyIndex)
|
||||
{
|
||||
r.append(station.propertyByIndex(CPropertyIndex { CAtcStation::IndexCallsign, CCallsign::IndexString }).toString());
|
||||
r.append(station.propertyByIndex(CPropertyIndex { CAtcStation::IndexController, CUser::IndexRealName }).toString());
|
||||
r.append(station.propertyByIndex(CPropertyIndex { CAtcStation::IndexPosition, CCoordinateGeodetic::IndexLatitudeAsString }).toString());
|
||||
r.append(station.propertyByIndex(CPropertyIndex { CAtcStation::IndexPosition, CCoordinateGeodetic::IndexLongitudeAsString }).toString());
|
||||
r.append(station.propertyByIndex(CPropertyIndex { CAtcStation::IndexRelativeDistance, CLength::IndexValueRounded2DigitsWithUnit }).toString());
|
||||
r.append(station.propertyByIndex(CPropertyIndex { CAtcStation::IndexLogoffTime }).toDateTime().toString("yyyy-MM-dd hh:mm"));
|
||||
r.append(station.propertyByIndex(CPropertyIndex { CAtcStation::IndexCallsign, CCallsign::IndexString })
|
||||
.toString());
|
||||
r.append(station.propertyByIndex(CPropertyIndex { CAtcStation::IndexController, CUser::IndexRealName })
|
||||
.toString());
|
||||
r.append(station
|
||||
.propertyByIndex(
|
||||
CPropertyIndex { CAtcStation::IndexPosition, CCoordinateGeodetic::IndexLatitudeAsString })
|
||||
.toString());
|
||||
r.append(station
|
||||
.propertyByIndex(
|
||||
CPropertyIndex { CAtcStation::IndexPosition, CCoordinateGeodetic::IndexLongitudeAsString })
|
||||
.toString());
|
||||
r.append(station
|
||||
.propertyByIndex(CPropertyIndex { CAtcStation::IndexRelativeDistance,
|
||||
CLength::IndexValueRounded2DigitsWithUnit })
|
||||
.toString());
|
||||
r.append(station.propertyByIndex(CPropertyIndex { CAtcStation::IndexLogoffTime })
|
||||
.toDateTime()
|
||||
.toString("yyyy-MM-dd hh:mm"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -53,7 +53,8 @@ namespace swift::sample
|
||||
static const qint64 DeltaTime = 10;
|
||||
|
||||
//! Situation values for testing
|
||||
static swift::misc::aviation::CAircraftSituationList createSituations(qint64 baseTimeEpoch, int numberOfCallsigns, int numberOfTimes);
|
||||
static swift::misc::aviation::CAircraftSituationList createSituations(qint64 baseTimeEpoch,
|
||||
int numberOfCallsigns, int numberOfTimes);
|
||||
|
||||
//! Model values for testing
|
||||
static swift::misc::simulation::CAircraftModelList createModels(int numberOfModels, int numberOfMemoParts);
|
||||
@@ -68,10 +69,12 @@ namespace swift::sample
|
||||
static const swift::misc::aviation::CAtcStationList &stations10k();
|
||||
|
||||
//! Access properties of given stations
|
||||
static void accessStationsData(const swift::misc::aviation::CAtcStationList &stations, bool byPropertyIndex = false);
|
||||
static void accessStationsData(const swift::misc::aviation::CAtcStationList &stations,
|
||||
bool byPropertyIndex = false);
|
||||
|
||||
//! Read properties of a station and concatenate them
|
||||
static QString accessStationData(const swift::misc::aviation::CAtcStation &station, bool byPropertyIndex = false);
|
||||
static QString accessStationData(const swift::misc::aviation::CAtcStation &station,
|
||||
bool byPropertyIndex = false);
|
||||
|
||||
//! parse coordinates from WGS
|
||||
static void parseWgs(int times);
|
||||
@@ -92,10 +95,12 @@ namespace swift::sample
|
||||
static swift::misc::aviation::CCallsignSet callsigns(int number);
|
||||
|
||||
//! Situations map
|
||||
static QMap<swift::misc::aviation::CCallsign, swift::misc::aviation::CAircraftSituation> situationsMap(const swift::misc::aviation::CCallsignSet &callsigns);
|
||||
static QMap<swift::misc::aviation::CCallsign, swift::misc::aviation::CAircraftSituation>
|
||||
situationsMap(const swift::misc::aviation::CCallsignSet &callsigns);
|
||||
|
||||
//! Situations hash
|
||||
static QHash<swift::misc::aviation::CCallsign, swift::misc::aviation::CAircraftSituation> situationsHash(const swift::misc::aviation::CCallsignSet &callsigns);
|
||||
static QHash<swift::misc::aviation::CCallsign, swift::misc::aviation::CAircraftSituation>
|
||||
situationsHash(const swift::misc::aviation::CCallsignSet &callsigns);
|
||||
};
|
||||
} // namespace swift::sample
|
||||
|
||||
|
||||
@@ -142,14 +142,8 @@ int main(int argc, char *argv[])
|
||||
// start DBus
|
||||
address = QString(useSessionBusForServer ? "session" : addressTcp); // testing with real transfer
|
||||
if (mode.contains("sb", Qt::CaseInsensitive)) address = "session";
|
||||
if (mode.startsWith("1"))
|
||||
{
|
||||
mode = "testservice";
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (mode.startsWith("1")) { mode = "testservice"; }
|
||||
else { return 0; }
|
||||
|
||||
// I know I am in the "server process here", so I can safely create a CDBusServer
|
||||
// this runs in the original process and can be directly debugged
|
||||
@@ -176,10 +170,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// run tests
|
||||
if (mode == "testservice")
|
||||
{
|
||||
swift::sample::ServiceTool::dataTransferTestServer(dBusServer, verbose);
|
||||
}
|
||||
if (mode == "testservice") { swift::sample::ServiceTool::dataTransferTestServer(dBusServer, verbose); }
|
||||
|
||||
// testing in new process
|
||||
CProcessCtrl::startDetached(executable, args, true);
|
||||
|
||||
@@ -61,7 +61,8 @@ namespace swift::sample
|
||||
}
|
||||
|
||||
// as this is the receiver side, the slots can be debugged too
|
||||
CTestService *testService = CTestService::registerTestService(sessionBusConnection, verbose, QCoreApplication::instance());
|
||||
CTestService *testService =
|
||||
CTestService::registerTestService(sessionBusConnection, verbose, QCoreApplication::instance());
|
||||
dBusServer->addObject(CTestService::ObjectPath(), testService);
|
||||
}
|
||||
|
||||
@@ -69,13 +70,11 @@ namespace swift::sample
|
||||
{
|
||||
// send data as P2P to server (this can be session bus, too, but usually is P2P)
|
||||
const bool sb = address.startsWith("session", Qt::CaseInsensitive);
|
||||
QDBusConnection connection = sb ?
|
||||
QDBusConnection::sessionBus() :
|
||||
QDBusConnection::connectToPeer(address, "p2pConnection");
|
||||
QDBusConnection connection =
|
||||
sb ? QDBusConnection::sessionBus() : QDBusConnection::connectToPeer(address, "p2pConnection");
|
||||
|
||||
// qtout << "server connection has interface? " << connection.interface(); // returns 0 with server and a real interface with session bus
|
||||
// qtout << "address: " << address;
|
||||
// qtout << "name: " << connection.name();
|
||||
// qtout << "server connection has interface? " << connection.interface(); // returns 0 with server and a real
|
||||
// interface with session bus qtout << "address: " << address; qtout << "name: " << connection.name();
|
||||
|
||||
ServiceTool::sendDataToTestservice(connection);
|
||||
}
|
||||
@@ -83,7 +82,8 @@ namespace swift::sample
|
||||
void ServiceTool::sendDataToTestservice(const QDBusConnection &connection)
|
||||
{
|
||||
// on the client's side
|
||||
ITestServiceInterface testServiceInterface(CTestService::InterfaceName(), CTestService::ObjectPath(), connection);
|
||||
ITestServiceInterface testServiceInterface(CTestService::InterfaceName(), CTestService::ObjectPath(),
|
||||
connection);
|
||||
QTextStream qtin(stdin);
|
||||
QTextStream qtout(stdout);
|
||||
|
||||
@@ -91,13 +91,13 @@ namespace swift::sample
|
||||
|
||||
while (true)
|
||||
{
|
||||
QDBusMessage m = QDBusMessage::createSignal(
|
||||
CTestService::ObjectPath(), CTestService::InterfaceName(),
|
||||
"sendStringMessage");
|
||||
QDBusMessage m = QDBusMessage::createSignal(CTestService::ObjectPath(), CTestService::InterfaceName(),
|
||||
"sendStringMessage");
|
||||
|
||||
// The << operator is used to add the parameters for the slot
|
||||
const QDateTime dtnow = QDateTime::currentDateTimeUtc();
|
||||
const QString msg = QStringLiteral("Con.: %1, message at %2").arg(connection.name(), dtnow.toString("MM/dd/yyyy @ hh:mm:ss"));
|
||||
const QString msg = QStringLiteral("Con.: %1, message at %2")
|
||||
.arg(connection.name(), dtnow.toString("MM/dd/yyyy @ hh:mm:ss"));
|
||||
m << msg;
|
||||
|
||||
// We send this as a non-replying message. This is used for sending errors, replys, signals.
|
||||
@@ -135,10 +135,13 @@ namespace swift::sample
|
||||
QVariant tsqv = QVariant::fromValue(trafficServer);
|
||||
QDBusVariant tsv(tsqv);
|
||||
testServiceInterface.receiveVariant(tsv, tsqv.userType());
|
||||
qtout << "Send server via interface and variant '" << trafficServer << QLatin1String("' ") << tsqv.userType() << Qt::endl;
|
||||
qtout << "Send server via interface and variant '" << trafficServer << QLatin1String("' ")
|
||||
<< tsqv.userType() << Qt::endl;
|
||||
|
||||
// Aviation
|
||||
const CComSystem comSystem = CComSystem("DBUS COM1", CPhysicalQuantitiesConstants::FrequencyInternationalAirDistress(), CPhysicalQuantitiesConstants::FrequencyUnicom());
|
||||
const CComSystem comSystem =
|
||||
CComSystem("DBUS COM1", CPhysicalQuantitiesConstants::FrequencyInternationalAirDistress(),
|
||||
CPhysicalQuantitiesConstants::FrequencyUnicom());
|
||||
testServiceInterface.receiveComUnit(comSystem);
|
||||
qtout << "Send COM via interface " << comSystem << Qt::endl;
|
||||
|
||||
|
||||
@@ -80,7 +80,8 @@ namespace swift::sample
|
||||
// ATC List
|
||||
CAtcStationList atcList = CTestData::getAtcStations();
|
||||
atcList.push_back(CTestData::getAtcStations());
|
||||
atcList = atcList.findBy(&CAtcStation::getCallsign, "eddm_twr", &CAtcStation::getFrequency, CFrequency(118.7, CFrequencyUnit::MHz()));
|
||||
atcList = atcList.findBy(&CAtcStation::getCallsign, "eddm_twr", &CAtcStation::getFrequency,
|
||||
CFrequency(118.7, CFrequencyUnit::MHz()));
|
||||
atcList = atcList.sortedBy(&CAtcStation::getCallsign, &CAtcStation::getControllerRealName);
|
||||
out << atcList << Qt::endl;
|
||||
out << "-----------------------------------------------" << Qt::endl;
|
||||
|
||||
@@ -33,7 +33,8 @@ namespace swift::sample
|
||||
const QString latStr("N 48° 7′ 6.3588"); // 48.118433
|
||||
const QString lngStr("E 16° 33′ 39.924");
|
||||
out.setRealNumberPrecision(digits);
|
||||
CCoordinateGeodetic geo = CCoordinateGeodetic::fromWgs84(latStr, lngStr, CAltitude(100, CAltitude::MeanSeaLevel, CLengthUnit::m()));
|
||||
CCoordinateGeodetic geo =
|
||||
CCoordinateGeodetic::fromWgs84(latStr, lngStr, CAltitude(100, CAltitude::MeanSeaLevel, CLengthUnit::m()));
|
||||
CLatitude lat = CLatitude::fromWgs84(latStr);
|
||||
CLongitude lng = CLongitude::fromWgs84(lngStr);
|
||||
|
||||
@@ -42,13 +43,17 @@ namespace swift::sample
|
||||
CLongitude deltaLng = geo.longitude() - lng;
|
||||
|
||||
out << latStr << " " << lngStr << Qt::endl;
|
||||
out << lat.value(CAngleUnit::deg()) << " " << lat.value(CAngleUnit::sexagesimalDeg()) << " " << lng.value(CAngleUnit::deg()) << " " << lng.value(CAngleUnit::sexagesimalDeg()) << Qt::endl;
|
||||
out << geo.latitude().value(CAngleUnit::deg()) << " " << geo.latitude().value(CAngleUnit::sexagesimalDeg()) << " " << geo.longitude().value(CAngleUnit::deg()) << " " << geo.longitude().value(CAngleUnit::sexagesimalDeg()) << Qt::endl;
|
||||
out << lat.value(CAngleUnit::deg()) << " " << lat.value(CAngleUnit::sexagesimalDeg()) << " "
|
||||
<< lng.value(CAngleUnit::deg()) << " " << lng.value(CAngleUnit::sexagesimalDeg()) << Qt::endl;
|
||||
out << geo.latitude().value(CAngleUnit::deg()) << " " << geo.latitude().value(CAngleUnit::sexagesimalDeg())
|
||||
<< " " << geo.longitude().value(CAngleUnit::deg()) << " "
|
||||
<< geo.longitude().value(CAngleUnit::sexagesimalDeg()) << Qt::endl;
|
||||
|
||||
out << deltaLat.valueRoundedWithUnit(digits) << " " << deltaLng.valueRoundedWithUnit(digits) << Qt::endl;
|
||||
|
||||
// equal test
|
||||
out << "Equal? " << swift::misc::boolToYesNo(lat == geo.latitude()) << " " << swift::misc::boolToYesNo(lng == geo.longitude()) << Qt::endl;
|
||||
out << "Equal? " << swift::misc::boolToYesNo(lat == geo.latitude()) << " "
|
||||
<< swift::misc::boolToYesNo(lng == geo.longitude()) << Qt::endl;
|
||||
|
||||
// check if conversions to xyz have messed something up
|
||||
QVector3D geoVector = geo.normalVector();
|
||||
@@ -60,12 +65,14 @@ namespace swift::sample
|
||||
// Heading/bearing of same values
|
||||
CAngle bearing = geo.calculateBearing(geo);
|
||||
CLength distance = geo.calculateGreatCircleDistance(geo);
|
||||
out << bearing.valueRoundedWithUnit(CAngleUnit::deg(), 2) << " " << distance.valueRoundedWithUnit(CLengthUnit::m(), 2) << Qt::endl;
|
||||
out << bearing.valueRoundedWithUnit(CAngleUnit::deg(), 2) << " "
|
||||
<< distance.valueRoundedWithUnit(CLengthUnit::m(), 2) << Qt::endl;
|
||||
|
||||
const CCoordinateGeodetic nullCoordinate;
|
||||
bearing = geo.calculateBearing(nullCoordinate);
|
||||
distance = geo.calculateGreatCircleDistance(nullCoordinate);
|
||||
out << bearing.valueRoundedWithUnit(CAngleUnit::deg(), 2) << " " << distance.valueRoundedWithUnit(CLengthUnit::m(), 2) << Qt::endl;
|
||||
out << bearing.valueRoundedWithUnit(CAngleUnit::deg(), 2) << " "
|
||||
<< distance.valueRoundedWithUnit(CLengthUnit::m(), 2) << Qt::endl;
|
||||
|
||||
// bye
|
||||
out << "-----------------------------------------------" << Qt::endl;
|
||||
|
||||
@@ -36,7 +36,8 @@ namespace swift::sample
|
||||
CLengthUnit lu2(CLengthUnit::ft());
|
||||
QString lu1s = lu1.toQString(true);
|
||||
QString lu2s = lu2.toQString(true);
|
||||
out << "units: " << lu1 << " " << lu2 << " " << lu1s << " " << lu2s << " " << lu1.getName(true) << " " << lu2.getName(true) << Qt::endl;
|
||||
out << "units: " << lu1 << " " << lu2 << " " << lu1s << " " << lu2s << " " << lu1.getName(true) << " "
|
||||
<< lu2.getName(true) << Qt::endl;
|
||||
const CLength l1(5.0, CLengthUnit::ft()); // 5 ft
|
||||
CLength l2(1, CLengthUnit::NM()); // 1NM
|
||||
CLength l3(1, CLengthUnit::km());
|
||||
@@ -44,7 +45,8 @@ namespace swift::sample
|
||||
|
||||
out << CLengthUnit::ft() << Qt::endl;
|
||||
out << l1 << " " << l2 << " " << l3 << " " << l4 << Qt::endl;
|
||||
out << l1.valueRoundedWithUnit(CLengthUnit::ft(), 5) << " " << l2.valueRoundedWithUnit(CLengthUnit::km()) << Qt::endl;
|
||||
out << l1.valueRoundedWithUnit(CLengthUnit::ft(), 5) << " " << l2.valueRoundedWithUnit(CLengthUnit::km())
|
||||
<< Qt::endl;
|
||||
out << l3.getUnit() << Qt::endl;
|
||||
|
||||
l2.switchUnit(CLengthUnit::ft()); // now in ft
|
||||
@@ -57,17 +59,20 @@ namespace swift::sample
|
||||
|
||||
// null test
|
||||
CLength nullLength(0, CLengthUnit::nullUnit());
|
||||
out << "Null PQ: " << nullLength << " converted " << nullLength.valueRoundedWithUnit(CLengthUnit::m(), 2) << Qt::endl;
|
||||
out << "Null PQ: " << nullLength << " converted " << nullLength.valueRoundedWithUnit(CLengthUnit::m(), 2)
|
||||
<< Qt::endl;
|
||||
|
||||
// more tests
|
||||
CFrequency f1(1E6, CFrequencyUnit::Hz()); // 1MHz
|
||||
out << f1 << " " << f1.valueRoundedWithUnit(CFrequencyUnit::MHz()) << " " << f1.valueRoundedWithUnit(CFrequencyUnit::GHz(), 3);
|
||||
out << f1 << " " << f1.valueRoundedWithUnit(CFrequencyUnit::MHz()) << " "
|
||||
<< f1.valueRoundedWithUnit(CFrequencyUnit::GHz(), 3);
|
||||
|
||||
CSpeed s1 = CSpeed(100, CSpeedUnit::km_h());
|
||||
CSpeed s2 = CSpeed(1000, CSpeedUnit::ft_min());
|
||||
CSpeed s3 = CSpeed(s2);
|
||||
s3.switchUnit(CSpeedUnit::m_s());
|
||||
out << s1 << " " << s1.valueRoundedWithUnit(CSpeedUnit::defaultUnit()) << " " << s1.valueRoundedWithUnit(CSpeedUnit::NM_h());
|
||||
out << s1 << " " << s1.valueRoundedWithUnit(CSpeedUnit::defaultUnit()) << " "
|
||||
<< s1.valueRoundedWithUnit(CSpeedUnit::NM_h());
|
||||
out << s2 << " " << s3 << Qt::endl;
|
||||
|
||||
CAngle a1(180, CAngleUnit::deg());
|
||||
@@ -94,13 +99,15 @@ namespace swift::sample
|
||||
out << w1 << " " << w1.valueRoundedWithUnit(CMassUnit::kg()) << " " << w2 << Qt::endl;
|
||||
|
||||
CPressure p1(CAltitude::standardISASeaLevelPressure());
|
||||
out << p1 << " " << p1.valueRoundedWithUnit(CPressureUnit::psi()) << " " << p1.valueRoundedWithUnit(CPressureUnit::inHg()) << Qt::endl;
|
||||
out << p1 << " " << p1.valueRoundedWithUnit(CPressureUnit::psi()) << " "
|
||||
<< p1.valueRoundedWithUnit(CPressureUnit::inHg()) << Qt::endl;
|
||||
|
||||
CTemperature t1;
|
||||
CTemperature t2(20, CTemperatureUnit::C());
|
||||
CTemperature t3(1, CTemperatureUnit::F());
|
||||
out << t1 << " " << t2 << " " << t2.valueRoundedWithUnit(CTemperatureUnit::defaultUnit(), -1, true);
|
||||
out << t3.valueRoundedWithUnit(CTemperatureUnit::F(), -1, true) << " " << t3.valueRoundedWithUnit(CTemperatureUnit::C(), -1, true) << " "
|
||||
out << t3.valueRoundedWithUnit(CTemperatureUnit::F(), -1, true) << " "
|
||||
<< t3.valueRoundedWithUnit(CTemperatureUnit::C(), -1, true) << " "
|
||||
<< "I18N/UTF" << Qt::endl;
|
||||
|
||||
(t1 - t2).switchUnit(CTemperatureUnit::F()); // was not working since wrong return type const
|
||||
|
||||
@@ -43,7 +43,8 @@ namespace swift::sample
|
||||
return;
|
||||
}
|
||||
|
||||
const CSimulatorInfo sim = fsDir.contains("simobjects", Qt::CaseInsensitive) ? CSimulatorInfo::FSX : CSimulatorInfo::FS9;
|
||||
const CSimulatorInfo sim =
|
||||
fsDir.contains("simobjects", Qt::CaseInsensitive) ? CSimulatorInfo::FSX : CSimulatorInfo::FS9;
|
||||
CMultiSimulatorSettings multiSettings;
|
||||
const CSimulatorSettings originalSettings = multiSettings.getSettings(sim);
|
||||
CSimulatorSettings newSettings(originalSettings);
|
||||
@@ -60,7 +61,8 @@ namespace swift::sample
|
||||
time.start();
|
||||
streamOut << "reading " << parser.getFirstModelDirectoryOrDefault() << Qt::endl;
|
||||
parser.startLoading();
|
||||
streamOut << "read entries: " << parser.getAircraftCfgEntriesList().size() << " in " << time.restart() << "ms" << Qt::endl;
|
||||
streamOut << "read entries: " << parser.getAircraftCfgEntriesList().size() << " in " << time.restart() << "ms"
|
||||
<< Qt::endl;
|
||||
|
||||
CAircraftCfgEntriesList entriesList = parser.getAircraftCfgEntriesList();
|
||||
QJsonDocument doc(entriesList.toJson());
|
||||
|
||||
@@ -27,10 +27,7 @@ namespace swift::sample
|
||||
QScopedPointer<CFsuipc> fsuipc(new CFsuipc());
|
||||
streamOut << "FSUIPC initialized" << Qt::endl;
|
||||
|
||||
if (fsuipc->open())
|
||||
{
|
||||
streamOut << "FSUIPC connected" << Qt::endl;
|
||||
}
|
||||
if (fsuipc->open()) { streamOut << "FSUIPC connected" << Qt::endl; }
|
||||
else
|
||||
{
|
||||
streamOut << "FSUIPC NOT(!) connected" << Qt::endl;
|
||||
@@ -48,9 +45,7 @@ namespace swift::sample
|
||||
}
|
||||
|
||||
#else
|
||||
void CSamplesFsuipc::samplesFsuipc(QTextStream &)
|
||||
{
|
||||
}
|
||||
void CSamplesFsuipc::samplesFsuipc(QTextStream &) {}
|
||||
#endif
|
||||
|
||||
} // namespace swift::sample
|
||||
|
||||
@@ -18,8 +18,12 @@ namespace swift::sample
|
||||
void CSamplesFsx::samplesMisc(QTextStream &streamOut)
|
||||
{
|
||||
swift::misc::registerMetadata();
|
||||
streamOut << CSimConnectUtilities::simConnectExceptionToString(CSimConnectUtilities::SIMCONNECT_EXCEPTION_ALREADY_SUBSCRIBED) << Qt::endl;
|
||||
streamOut << CSimConnectUtilities::simConnectExceptionToString(CSimConnectUtilities::SIMCONNECT_EXCEPTION_ILLEGAL_OPERATION) << Qt::endl;
|
||||
streamOut << CSimConnectUtilities::simConnectExceptionToString(
|
||||
CSimConnectUtilities::SIMCONNECT_EXCEPTION_ALREADY_SUBSCRIBED)
|
||||
<< Qt::endl;
|
||||
streamOut << CSimConnectUtilities::simConnectExceptionToString(
|
||||
CSimConnectUtilities::SIMCONNECT_EXCEPTION_ILLEGAL_OPERATION)
|
||||
<< Qt::endl;
|
||||
streamOut << CSimConnectUtilities::simConnectSurfaceTypeToString(CSimConnectUtilities::Bituminus) << Qt::endl;
|
||||
}
|
||||
} // namespace swift::sample
|
||||
|
||||
@@ -39,16 +39,17 @@ namespace swift::sample
|
||||
CVPilotRulesReader vpRulesReader;
|
||||
const bool s = vpRulesReader.read(true);
|
||||
streamOut << "directory: " << CVPilotRulesReader::standardMappingsDirectory() << Qt::endl;
|
||||
streamOut << "loaded: " << swift::misc::boolToYesNo(s) << " size: " << vpRulesReader.getAsModelsFromCache().size() << Qt::endl;
|
||||
streamOut << "loaded: " << swift::misc::boolToYesNo(s)
|
||||
<< " size: " << vpRulesReader.getAsModelsFromCache().size() << Qt::endl;
|
||||
|
||||
// mapper with rule set, handing over ownership
|
||||
const QString fsDir = CSampleUtils::selectDirectory(
|
||||
{ QStringLiteral("P:/FlightSimulatorX (MSI)/SimObjects"),
|
||||
QStringLiteral("P:/Temp/SimObjects"),
|
||||
QStringLiteral("C:/Flight Simulator 9/Aircraft") },
|
||||
streamOut, streamIn);
|
||||
const QString fsDir = CSampleUtils::selectDirectory({ QStringLiteral("P:/FlightSimulatorX (MSI)/SimObjects"),
|
||||
QStringLiteral("P:/Temp/SimObjects"),
|
||||
QStringLiteral("C:/Flight Simulator 9/Aircraft") },
|
||||
streamOut, streamIn);
|
||||
|
||||
const CSimulatorInfo sim = fsDir.contains("simobjects", Qt::CaseInsensitive) ? CSimulatorInfo::FSX : CSimulatorInfo::FS9;
|
||||
const CSimulatorInfo sim =
|
||||
fsDir.contains("simobjects", Qt::CaseInsensitive) ? CSimulatorInfo::FSX : CSimulatorInfo::FS9;
|
||||
CMultiSimulatorSettings multiSettings;
|
||||
const CSimulatorSettings originalSettings = multiSettings.getSettings(sim);
|
||||
CSimulatorSettings newSettings(originalSettings);
|
||||
@@ -59,7 +60,8 @@ namespace swift::sample
|
||||
streamOut << "Start reading models" << Qt::endl;
|
||||
cfgParser.startLoading(CAircraftCfgParser::CacheSkipped | CAircraftCfgParser::LoadDirectly);
|
||||
streamOut << "Read models: " << cfgParser.getAircraftCfgEntriesList().size() << Qt::endl;
|
||||
streamOut << "Ambigious models: " << cfgParser.getAircraftCfgEntriesList().detectAmbiguousTitles().join(", ") << Qt::endl;
|
||||
streamOut << "Ambigious models: " << cfgParser.getAircraftCfgEntriesList().detectAmbiguousTitles().join(", ")
|
||||
<< Qt::endl;
|
||||
|
||||
// sync definitions, remove redundant ones
|
||||
CAircraftMatcher matcher;
|
||||
|
||||
@@ -32,7 +32,8 @@ namespace swift::sample
|
||||
QScopedPointer<CVPilotRulesReader> vPilotReader(new CVPilotRulesReader());
|
||||
bool s = vPilotReader->read(false);
|
||||
streamOut << "Read success: " << swift::misc::boolToYesNo(s) << Qt::endl;
|
||||
streamOut << "Read " << vPilotReader->countRulesLoaded() << " rules from " << vPilotReader->countFilesLoaded() << " files" << Qt::endl;
|
||||
streamOut << "Read " << vPilotReader->countRulesLoaded() << " rules from " << vPilotReader->countFilesLoaded()
|
||||
<< " files" << Qt::endl;
|
||||
streamOut << "Distributors: " << vPilotReader->getRules().getSortedDistributors().join(", ");
|
||||
|
||||
Q_UNUSED(streamIn);
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
|
||||
namespace swift::misc
|
||||
{
|
||||
QString CSampleUtils::selectDirectory(const QStringList &directoryOptions, QTextStream &streamOut, QTextStream &streamIn)
|
||||
QString CSampleUtils::selectDirectory(const QStringList &directoryOptions, QTextStream &streamOut,
|
||||
QTextStream &streamIn)
|
||||
{
|
||||
Q_ASSERT(!directoryOptions.isEmpty());
|
||||
if (directoryOptions.isEmpty()) { return {}; }
|
||||
if (directoryOptions.size() < 2) { return directoryOptions.first(); }
|
||||
|
||||
QString selectedDir;
|
||||
do
|
||||
{
|
||||
do {
|
||||
for (int i = 0; i < directoryOptions.size(); i++)
|
||||
{
|
||||
if (i > 0) { streamOut << " "; }
|
||||
|
||||
@@ -18,7 +18,8 @@ namespace swift::misc
|
||||
{
|
||||
public:
|
||||
//! Select directory among given ones
|
||||
static QString selectDirectory(const QStringList &directoryOptions, QTextStream &streamOut, QTextStream &streamIn);
|
||||
static QString selectDirectory(const QStringList &directoryOptions, QTextStream &streamOut,
|
||||
QTextStream &streamIn);
|
||||
|
||||
private:
|
||||
CSampleUtils() = delete;
|
||||
|
||||
Reference in New Issue
Block a user