clang-format samples

This commit is contained in:
Lars Toenning
2023-04-09 17:00:46 +02:00
parent a3b5a9b780
commit 674710f146
24 changed files with 220 additions and 212 deletions

View File

@@ -10,14 +10,13 @@
using namespace BlackCore::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::connectionStatusChanged, this, &CAfvClientBridge::connectionStatusChanged);
connect(afvClient, &CAfvClient::updatedFromOwnAircraftCockpit, this, &CAfvClientBridge::updatedFromOwnAircraftCockpit);
connect(afvClient, &CAfvClient::ptt, this, &CAfvClientBridge::ptt);
connect(afvClient, &CAfvClient::inputVolumePeakVU, this, &CAfvClientBridge::inputVolumePeakVU);
connect(afvClient, &CAfvClient::inputVolumePeakVU, this, &CAfvClientBridge::inputVolumePeakVU);
connect(afvClient, &CAfvClient::outputVolumePeakVU, this, &CAfvClientBridge::outputVolumePeakVU);
}

View File

@@ -21,7 +21,7 @@ class CAfvClientBridge : public QObject
//! Bridge properties
//! @{
Q_PROPERTY(double inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU)
Q_PROPERTY(double inputVolumePeakVU READ getInputVolumePeakVU NOTIFY inputVolumePeakVU)
Q_PROPERTY(double outputVolumePeakVU READ getOutputVolumePeakVU NOTIFY outputVolumePeakVU)
Q_PROPERTY(BlackCore::Afv::Clients::CAfvClient::ConnectionStatus connectionStatus READ getConnectionStatus NOTIFY connectionStatusChanged)
Q_PROPERTY(QString receivingCallsignsCom1 READ getReceivingCallsignsCom1 NOTIFY receivingCallsignsChanged)
@@ -34,7 +34,7 @@ public:
//! VU values, 0..1
//! @{
double getInputVolumePeakVU() const { return m_afvClient->getInputVolumePeakVU(); }
double getInputVolumePeakVU() const { return m_afvClient->getInputVolumePeakVU(); }
double getOutputVolumePeakVU() const { return m_afvClient->getOutputVolumePeakVU(); }
//! @}
@@ -90,7 +90,7 @@ public:
//! Loopback
//! @{
Q_INVOKABLE void setLoopBack(bool on) { m_afvClient->setLoopBack(on); }
Q_INVOKABLE bool isLoopback() const { return m_afvClient->isLoopback(); }
Q_INVOKABLE bool isLoopback() const { return m_afvClient->isLoopback(); }
//! @}
//! \copydoc BlackCore::Afv::Clients::CAfvClient::setInputVolumeDb

View File

@@ -38,8 +38,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]()
{
QObject::connect(&qa, &QCoreApplication::aboutToQuit, [voiceClient]() {
voiceClient->quitAndWait();
});
@@ -54,8 +53,8 @@ int main(int argc, char *argv[])
QQmlApplicationEngine engine;
QQmlContext *ctxt = engine.rootContext();
ctxt->setContextProperty("afvMapReader", afvMapReader);
ctxt->setContextProperty("voiceClient", voiceClientBridge);
ctxt->setContextProperty("userName", defaultUserName);
ctxt->setContextProperty("voiceClient", voiceClientBridge);
ctxt->setContextProperty("userName", defaultUserName);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return a.exec();

View File

@@ -62,10 +62,10 @@ int main(int argc, char *argv[])
const QString s = qtin.readLine().toLower().trimmed();
if (s.startsWith("1")) { CSamplesJson::samples(); }
else if (s.startsWith("2")) { CSamplesChangeObject::samples(); }
else if (s.startsWith("2")) { CSamplesChangeObject::samples(); }
else if (s.startsWith("3a")) { CSamplesContainer::samples(); }
else if (s.startsWith("3b")) { CSamplesPerformance::sampleQMapVsQHashByCallsign(qtout); }
else if (s.startsWith("4")) { CSamplesMetadata::samples(); }
else if (s.startsWith("4")) { CSamplesMetadata::samples(); }
else if (s.startsWith("6a")) { CSamplesPerformance::samplesMisc(qtout); }
else if (s.startsWith("6b")) { CSamplesPerformance::interpolatorScenario(qtout, 40, 20); }
else if (s.startsWith("6c")) { CSamplesPerformance::samplesJson(qtout); }
@@ -73,9 +73,9 @@ int main(int argc, char *argv[])
else if (s.startsWith("6e")) { CSamplesPerformance::samplesStringUtilsVsRegEx(qtout); }
else if (s.startsWith("6f")) { CSamplesPerformance::samplesStringConcat(qtout); }
else if (s.startsWith("6g")) { CSamplesPerformance::samplesStringLiteralVsConstQString(qtout); }
else if (s.startsWith("7")) { CSamplesAlgorithm::samples(); }
else if (s.startsWith("8")) { CSamplesFile::samples(qtout); }
else if (s.startsWith("x")) { break; }
else if (s.startsWith("7")) { CSamplesAlgorithm::samples(); }
else if (s.startsWith("8")) { CSamplesFile::samples(qtout); }
else if (s.startsWith("x")) { break; }
}
while (true);
return 0;

View File

@@ -45,7 +45,7 @@ namespace BlackSample
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;
@@ -59,7 +59,7 @@ namespace BlackSample
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;
@@ -72,7 +72,7 @@ namespace BlackSample
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) { BlackMisc::topologicallySortedInsert(dst, s, cmp); }
qDebug() << count << "comparisons";
qDebug() << dst;

View File

@@ -46,8 +46,8 @@ namespace BlackSample
geoPos, CLength(50, CLengthUnit::km()), false, dtFrom, dtUntil);
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, dtFrom2, dtUntil2);
CFrequency(120.7, CFrequencyUnit::MHz()),
geoPos, CLength(100, CLengthUnit::km()), false, dtFrom2, dtUntil2);
Q_ASSERT_X(station1 == station2, Q_FUNC_INFO, "Unequal stations");
@@ -74,7 +74,7 @@ namespace BlackSample
// now Jane's time is over
CPropertyIndexVariantMap anotherController;
anotherController.addValue(CAtcStation::IndexController, CVariant::fromValue(CUser("445566", "Fuzzy")));
atcList.applyIf([ = ](const auto &arg) { return newController.matches(arg); }, anotherController);
atcList.applyIf([=](const auto &arg) { return newController.matches(arg); }, anotherController);
qDebug() << "-- after update via value map";
qDebug() << atcList.toQString();

View File

@@ -54,7 +54,7 @@ namespace BlackSample
QTextStream cin(stdin);
CLength l(123.456, CLengthUnit::NM());
QJsonObject json = l.toJson();
l = CLength(); //convert back
l = CLength(); // convert back
l.convertFromJson(json);
qDebug() << json << l;
qDebug() << "-------";

View File

@@ -105,7 +105,7 @@ namespace BlackSample
timer.start();
CSamplesPerformance::accessStationsData(atcs2, false);
ms = timer.elapsed();
out << "Read (getters) " << atcs2.size() << " ATC stations in " << ms << "ms" << Qt::endl;
out << "Read (getters) " << atcs2.size() << " ATC stations in " << ms << "ms" << Qt::endl;
timer.start();
CSamplesPerformance::accessStationsData(atcs1, true);
@@ -163,26 +163,38 @@ namespace BlackSample
QString containsStr("aaa");
number = 0;
timer.start();
for (const auto &str : std::as_const(strList1)) { if (newRegex.match(str).hasMatch()) number++; }
for (const auto &str : std::as_const(strList1))
{
if (newRegex.match(str).hasMatch()) number++;
}
ms = timer.elapsed();
out << "new regex matched " << number << " of" << strList1.size() << " strings in " << ms << "ms" << Qt::endl;
out << "new regex matched " << number << " of" << strList1.size() << " strings in " << ms << "ms" << Qt::endl;
number = 0;
timer.start();
for (const auto &str : std::as_const(strList2)) { if (fullRegex.exactMatch(str)) number++; }
for (const auto &str : std::as_const(strList2))
{
if (fullRegex.exactMatch(str)) number++;
}
ms = timer.elapsed();
out << "full regex matched " << number << " of" << strList2.size() << " strings in " << ms << "ms" << Qt::endl;
out << "full regex matched " << number << " of" << strList2.size() << " strings in " << ms << "ms" << Qt::endl;
number = 0;
timer.start();
for (const auto &str : std::as_const(strList3)) { if (wildcardRegex.exactMatch(str)) number++; }
for (const auto &str : std::as_const(strList3))
{
if (wildcardRegex.exactMatch(str)) number++;
}
ms = timer.elapsed();
out << "wildcard matched " << number << " of " << strList3.size() << " strings in " << ms << "ms" << Qt::endl;
out << "wildcard matched " << number << " of " << strList3.size() << " strings in " << ms << "ms" << Qt::endl;
number = 0;
timer.start();
for (const auto &str : std::as_const(strList4)) { if (str.contains(containsStr)) number++; }
for (const auto &str : std::as_const(strList4))
{
if (str.contains(containsStr)) number++;
}
ms = timer.elapsed();
out << "contains matched " << number << " of " << strList4.size() << " strings in " << ms << "ms" << Qt::endl;
out << "-----------------------------------------------" << Qt::endl;
out << "-----------------------------------------------" << Qt::endl;
return EXIT_SUCCESS;
}
@@ -256,7 +268,8 @@ namespace BlackSample
timer.start();
situations.convertFromJson(json);
out << "Convert 100,000 aircraft situations from JSON: " << timer.elapsed() << "ms" << endl << Qt::endl;
out << "Convert 100,000 aircraft situations from JSON: " << timer.elapsed() << "ms" << endl
<< Qt::endl;
timer.start();
json = models.toJson();
@@ -264,7 +277,8 @@ namespace BlackSample
timer.start();
models.convertFromJson(json);
out << "Convert 10,000 aircraft models from JSON (naive): " << timer.elapsed() << "ms" << endl << Qt::endl;
out << "Convert 10,000 aircraft models from JSON (naive): " << timer.elapsed() << "ms" << endl
<< Qt::endl;
timer.start();
json = models.toMemoizedJson();
@@ -272,7 +286,8 @@ namespace BlackSample
timer.start();
models.convertFromMemoizedJson(json);
out << "Convert 10,000 aircraft models from JSON (memoize): " << timer.elapsed() << "ms" << endl << Qt::endl;
out << "Convert 10,000 aircraft models from JSON (memoize): " << timer.elapsed() << "ms" << endl
<< Qt::endl;
return EXIT_SUCCESS;
}
@@ -349,8 +364,7 @@ namespace BlackSample
QElapsedTimer timer;
static const QString chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~_-=+!\"@#$%^&*()[]{} \t;:\\/?,.<>";
QStringList strings;
std::generate_n(std::back_inserter(strings), 100000, []
{
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)]; });
return s;
@@ -374,7 +388,8 @@ namespace BlackSample
auto c = s.contains(upperRegex);
Q_UNUSED(c);
}
out << "Check 100,000 strings for containing uppercase letter: (regex) " << timer.elapsed() << "ms" << endl << Qt::endl;
out << "Check 100,000 strings for containing uppercase letter: (regex) " << timer.elapsed() << "ms" << endl
<< Qt::endl;
timer.start();
for (const QString &s : std::as_const(strings))
@@ -390,7 +405,8 @@ namespace BlackSample
auto i = s.indexOf(upperRegex);
Q_UNUSED(i);
}
out << "Check 100,000 strings for index of first uppercase letter: (regex) " << timer.elapsed() << "ms" << endl << Qt::endl;
out << "Check 100,000 strings for index of first uppercase letter: (regex) " << timer.elapsed() << "ms" << endl
<< Qt::endl;
auto temp = strings;
timer.start();
@@ -406,7 +422,8 @@ namespace BlackSample
{
s.remove(upperRegex);
}
out << "Remove from 100,000 strings all uppercase letters: (regex) " << timer.elapsed() << "ms" << endl << Qt::endl;
out << "Remove from 100,000 strings all uppercase letters: (regex) " << timer.elapsed() << "ms" << endl
<< Qt::endl;
timer.start();
{
@@ -714,16 +731,13 @@ namespace BlackSample
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(70.0, 70.0, 70.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++)
{
@@ -745,13 +759,11 @@ namespace BlackSample
void CSamplesPerformance::parseWgs(int times)
{
static QStringList wgsLatLng(
{
"12° 11 10″ N", "11° 22 33W",
"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"
});
{ "12° 11 10″ N", "11° 22 33″ W",
"48° 21 13″ N", "11° 47 09E",
" 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());
@@ -775,12 +787,12 @@ namespace BlackSample
QStringList CSamplesPerformance::generateList()
{
return QStringList({"1", "2", "3", "4"});
return QStringList({ "1", "2", "3", "4" });
}
QStringList CSamplesPerformance::replacedList()
{
static const QStringList l({"1", "2", "3", "4"});
static const QStringList l({ "1", "2", "3", "4" });
QStringList lc(l);
lc[1] = QStringLiteral("6");
lc[3] = QStringLiteral("7");
@@ -840,13 +852,13 @@ namespace BlackSample
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::IndexBookedFrom}).toDateTime().toString("yyyy-MM-dd hh:mm"));
r.append(station.propertyByIndex(CPropertyIndex { CAtcStation::IndexBookedUntil}).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::IndexBookedFrom }).toDateTime().toString("yyyy-MM-dd hh:mm"));
r.append(station.propertyByIndex(CPropertyIndex { CAtcStation::IndexBookedUntil }).toDateTime().toString("yyyy-MM-dd hh:mm"));
}
else
{

View File

@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
if (mode.startsWith("2"))
{
out << "---------------------------------" << Qt::endl;
//BlackMisc::CDBusUtils::showDBusSignatures(out);
// BlackMisc::CDBusUtils::showDBusSignatures(out);
out << "---------------------------------" << Qt::endl;
goto Menu;
}

View File

@@ -73,8 +73,8 @@ namespace BlackSample
// 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::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;
@@ -95,8 +95,8 @@ namespace BlackSample
while (true)
{
QDBusMessage m = QDBusMessage::createSignal(
CTestService::ObjectPath(), CTestService::InterfaceName(),
"sendStringMessage");
CTestService::ObjectPath(), CTestService::InterfaceName(),
"sendStringMessage");
// The << operator is used to add the parameters for the slot
const QDateTime dtnow = QDateTime::currentDateTimeUtc();
@@ -138,7 +138,7 @@ namespace BlackSample
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());
@@ -263,7 +263,7 @@ namespace BlackSample
atcStationList = testServiceInterface.getAtcStationList(1000);
if (atcStationList.size() != 1000) qtout << "wrong list size" << atcStationList.size() << Qt::endl;
t1000 = timer.elapsed(); // ms
qtout << "Reading station list 10/100/1000 in ms: " << t10 << " " << t100 << " " << t1000 << Qt::endl;
qtout << "Reading station list 10/100/1000 in ms: " << t10 << " " << t100 << " " << t1000 << Qt::endl;
// test reading model entries with a realistic size
timer.restart();
@@ -285,7 +285,7 @@ namespace BlackSample
objectPaths = testServiceInterface.getObjectPaths(1000);
if (objectPaths.size() != 1000) qtout << "wrong list size" << objectPaths.size() << Qt::endl;
t1000 = timer.elapsed(); // ms
qtout << "Reading paths list 10/100/1000 in ms: " << t10 << " " << t100 << " " << t1000 << Qt::endl;
qtout << "Reading paths list 10/100/1000 in ms: " << t10 << " " << t100 << " " << t1000 << Qt::endl;
timer.invalidate();
// next round?

View File

@@ -22,7 +22,10 @@ class QDBusConnection;
class QObject;
class QProcess;
namespace BlackMisc { class CDBusServer; }
namespace BlackMisc
{
class CDBusServer;
}
namespace BlackSample
{
class Testservice; // forward declaration

View File

@@ -17,7 +17,7 @@ class QTextStream;
namespace BlackSample
{
//! Samples for aviation
//! Samples for aviation
class CSamplesAviation
{
public:

View File

@@ -46,19 +46,13 @@ namespace BlackSample
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? " <<
BlackMisc::boolToYesNo(lat == geo.latitude()) << " " <<
BlackMisc::boolToYesNo(lng == geo.longitude()) << Qt::endl;
out << "Equal? " << BlackMisc::boolToYesNo(lat == geo.latitude()) << " " << BlackMisc::boolToYesNo(lng == geo.longitude()) << Qt::endl;
// check if conversions to xyz have messed something up
QVector3D geoVector = geo.normalVector();

View File

@@ -53,7 +53,7 @@ namespace BlackSample
l2.switchUnit(CLengthUnit::ft()); // now in ft
l3 += l3; // 2km now
l3 *= 1.5;// 3km now
l3 *= 1.5; // 3km now
out << l2 << " " << l3 << Qt::endl;
l3 = l3 * 2;
@@ -104,7 +104,8 @@ namespace BlackSample
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) << " " << "I18N/UTF" << Qt::endl;
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
// CLengthUnit duA(CSpeedUnit::ft_min()); // no longer possible
@@ -125,7 +126,8 @@ namespace BlackSample
out << ti6 << " " << ti7 << " " << ti8 << Qt::endl;
CAcceleration ac1(10, CAccelerationUnit::m_s2());
out << ac1 << " " << ac1.toQString(true) << " " << ac1.valueRoundedWithUnit(-1, true) << " " << "I18N/UTF" << Qt::endl;
out << ac1 << " " << ac1.toQString(true) << " " << ac1.valueRoundedWithUnit(-1, true) << " "
<< "I18N/UTF" << Qt::endl;
// bye
out << "-----------------------------------------------" << Qt::endl;

View File

@@ -46,11 +46,11 @@ int main(int argc, char *argv[])
{
streamOut << "Run samples:" << Qt::endl;
streamOut << "1 .. FS common / Simulation (with cfg files reading)" << Qt::endl;
streamOut << "2 .. FSX" << Qt::endl;
streamOut << "3 .. Mappings" << Qt::endl;
streamOut << "4 .. vPilot rules" << Qt::endl;
streamOut << "2 .. FSX" << Qt::endl;
streamOut << "3 .. Mappings" << Qt::endl;
streamOut << "4 .. vPilot rules" << Qt::endl;
streamOut << "5 .. P3D cfg files" << Qt::endl;
streamOut << "6 .. FSUIPC read" << Qt::endl;
streamOut << "6 .. FSUIPC read" << Qt::endl;
streamOut << "x .. exit" << Qt::endl;
QString i = streamIn.readLine().toLower().trimmed();
@@ -61,7 +61,11 @@ int main(int argc, char *argv[])
else if (i.startsWith("4")) { CSamplesVPilotRules::samples(streamOut, streamIn); }
else if (i.startsWith("5")) { CSamplesP3D::samplesMisc(streamOut); }
else if (i.startsWith("6")) { CSamplesFsuipc::samplesFsuipc(streamOut); }
else if (i.startsWith("x")) { run = false; streamOut << "terminating" << Qt::endl; }
else if (i.startsWith("x"))
{
run = false;
streamOut << "terminating" << Qt::endl;
}
streamOut << Qt::endl;
streamOut << Qt::endl;

View File

@@ -35,10 +35,9 @@ namespace BlackSample
void CSamplesFsCommon::samples(QTextStream &streamOut, QTextStream &streamIn)
{
const QString fsDir = CSampleUtils::selectDirectory(
{
"C:/Program Files (x86)/Microsoft Games/Microsoft Flight Simulator X/SimObjects",
"C:/Flight Simulator 9/Aircraft"
}, streamOut, streamIn);
{ "C:/Program Files (x86)/Microsoft Games/Microsoft Flight Simulator X/SimObjects",
"C:/Flight Simulator 9/Aircraft" },
streamOut, streamIn);
const QDir dir(fsDir);
if (!dir.exists())
@@ -74,7 +73,7 @@ namespace BlackSample
tempFile.open();
tempFile.write(jsonArray);
tempFile.close();
streamOut << "written to " << tempFile.fileName() << " in " << time.restart() << "ms" << Qt::endl;
streamOut << "written to " << tempFile.fileName() << " in " << time.restart() << "ms" << Qt::endl;
// re-read
tempFile.open();

View File

@@ -46,11 +46,10 @@ namespace BlackSample
// 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);
{ 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;
CMultiSimulatorSettings multiSettings;

View File

@@ -27,7 +27,7 @@ namespace BlackMisc
for (int i = 0; i < directoryOptions.size(); i++)
{
if (i > 0) { streamOut << " "; }
streamOut << (i + 1) << ") " << directoryOptions.at(i) ;
streamOut << (i + 1) << ") " << directoryOptions.at(i);
}
streamOut << Qt::endl;
streamOut << "Select [1-" << directoryOptions.size() << "]: ";

View File

@@ -63,73 +63,73 @@ namespace BlackSample
CRemoteAircraftProviderDummy::instance(),
this))
{
connect(m_net, &INetwork::atcPositionUpdate, this, &Client::atcPositionUpdate);
connect(m_net, &INetwork::atcDisconnected, this, &Client::atcDisconnected);
connect(m_net, &INetwork::connectionStatusChanged, this, &Client::connectionStatusChanged);
connect(m_net, &INetwork::ipReplyReceived, this, &Client::ipReplyReceived);
connect(m_net, &INetwork::frequencyReplyReceived, this, &Client::freqReplyReceived);
connect(m_net, &INetwork::serverReplyReceived, this, &Client::serverReplyReceived);
connect(m_net, &INetwork::atcReplyReceived, this, &Client::atcReplyReceived);
connect(m_net, &INetwork::atisReplyReceived, this, &Client::atisReplyReceived);
connect(m_net, &INetwork::realNameReplyReceived, this, &Client::realNameReplyReceived);
connect(m_net, &INetwork::capabilitiesReplyReceived, this, &Client::capabilitiesReplyReceived);
connect(m_net, &INetwork::kicked, this, &Client::kicked);
connect(m_net, &INetwork::metarReplyReceived, this, &Client::metarReplyReceived);
connect(m_net, &INetwork::flightPlanReplyReceived, this, &Client::flightPlanReplyReceived);
connect(m_net, &INetwork::pilotDisconnected, this, &Client::pilotDisconnected);
connect(m_net, &INetwork::icaoCodesReplyReceived, this, &Client::icaoCodesReplyReceived);
connect(m_net, &INetwork::pongReceived, this, &Client::pongReceived);
connect(m_net, &INetwork::textMessagesReceived, this, &Client::textMessagesReceived);
connect(m_net, &INetwork::atcPositionUpdate, this, &Client::atcPositionUpdate);
connect(m_net, &INetwork::atcDisconnected, this, &Client::atcDisconnected);
connect(m_net, &INetwork::connectionStatusChanged, this, &Client::connectionStatusChanged);
connect(m_net, &INetwork::ipReplyReceived, this, &Client::ipReplyReceived);
connect(m_net, &INetwork::frequencyReplyReceived, this, &Client::freqReplyReceived);
connect(m_net, &INetwork::serverReplyReceived, this, &Client::serverReplyReceived);
connect(m_net, &INetwork::atcReplyReceived, this, &Client::atcReplyReceived);
connect(m_net, &INetwork::atisReplyReceived, this, &Client::atisReplyReceived);
connect(m_net, &INetwork::realNameReplyReceived, this, &Client::realNameReplyReceived);
connect(m_net, &INetwork::capabilitiesReplyReceived, this, &Client::capabilitiesReplyReceived);
connect(m_net, &INetwork::kicked, this, &Client::kicked);
connect(m_net, &INetwork::metarReplyReceived, this, &Client::metarReplyReceived);
connect(m_net, &INetwork::flightPlanReplyReceived, this, &Client::flightPlanReplyReceived);
connect(m_net, &INetwork::pilotDisconnected, this, &Client::pilotDisconnected);
connect(m_net, &INetwork::icaoCodesReplyReceived, this, &Client::icaoCodesReplyReceived);
connect(m_net, &INetwork::pongReceived, this, &Client::pongReceived);
connect(m_net, &INetwork::textMessagesReceived, this, &Client::textMessagesReceived);
connect(this, &Client::presetServer, m_net, &INetwork::presetServer);
connect(this, &Client::presetCallsign, m_net, &INetwork::presetCallsign);
connect(this, &Client::presetIcaoCodes, m_net, &INetwork::presetIcaoCodes);
connect(this, &Client::presetLoginMode, m_net, &INetwork::presetLoginMode);
connect(this, &Client::initiateConnection, m_net, &INetwork::initiateConnection);
connect(this, &Client::terminateConnection, m_net, &INetwork::terminateConnection);
connect(this, &Client::sendTextMessages, m_net, &INetwork::sendTextMessages);
connect(this, &Client::sendIpQuery, m_net, &INetwork::sendIpQuery);
connect(this, &Client::sendFreqQuery, m_net, &INetwork::sendFrequencyQuery);
connect(this, &Client::sendServerQuery, m_net, &INetwork::sendServerQuery);
connect(this, &Client::sendAtcQuery, m_net, &INetwork::sendAtcQuery);
connect(this, &Client::sendAtisQuery, m_net, &INetwork::sendAtisQuery);
connect(this, &Client::sendFlightPlan, m_net, &INetwork::sendFlightPlan);
connect(this, &Client::sendFlightPlanQuery, m_net, &INetwork::sendFlightPlanQuery);
connect(this, &Client::sendRealNameQuery, m_net, &INetwork::sendRealNameQuery);
connect(this, &Client::sendCapabilitiesQuery, m_net, &INetwork::sendCapabilitiesQuery);
connect(this, &Client::sendIcaoCodesQuery, m_net, &INetwork::sendIcaoCodesQuery);
connect(this, &Client::setOwnAircraftCockpit, COwnAircraftProviderDummy::instance(), &COwnAircraftProviderDummy::updateCockpit);
connect(this, &Client::sendPing, m_net, &INetwork::sendPing);
connect(this, &Client::sendMetarQuery, m_net, &INetwork::sendMetarQuery);
connect(this, &Client::presetServer, m_net, &INetwork::presetServer);
connect(this, &Client::presetCallsign, m_net, &INetwork::presetCallsign);
connect(this, &Client::presetIcaoCodes, m_net, &INetwork::presetIcaoCodes);
connect(this, &Client::presetLoginMode, m_net, &INetwork::presetLoginMode);
connect(this, &Client::initiateConnection, m_net, &INetwork::initiateConnection);
connect(this, &Client::terminateConnection, m_net, &INetwork::terminateConnection);
connect(this, &Client::sendTextMessages, m_net, &INetwork::sendTextMessages);
connect(this, &Client::sendIpQuery, m_net, &INetwork::sendIpQuery);
connect(this, &Client::sendFreqQuery, m_net, &INetwork::sendFrequencyQuery);
connect(this, &Client::sendServerQuery, m_net, &INetwork::sendServerQuery);
connect(this, &Client::sendAtcQuery, m_net, &INetwork::sendAtcQuery);
connect(this, &Client::sendAtisQuery, m_net, &INetwork::sendAtisQuery);
connect(this, &Client::sendFlightPlan, m_net, &INetwork::sendFlightPlan);
connect(this, &Client::sendFlightPlanQuery, m_net, &INetwork::sendFlightPlanQuery);
connect(this, &Client::sendRealNameQuery, m_net, &INetwork::sendRealNameQuery);
connect(this, &Client::sendCapabilitiesQuery, m_net, &INetwork::sendCapabilitiesQuery);
connect(this, &Client::sendIcaoCodesQuery, m_net, &INetwork::sendIcaoCodesQuery);
connect(this, &Client::setOwnAircraftCockpit, COwnAircraftProviderDummy::instance(), &COwnAircraftProviderDummy::updateCockpit);
connect(this, &Client::sendPing, m_net, &INetwork::sendPing);
connect(this, &Client::sendMetarQuery, m_net, &INetwork::sendMetarQuery);
using namespace std::placeholders;
m_commands["help"] = std::bind(&Client::help, this, _1);
m_commands["echo"] = std::bind(&Client::echo, this, _1);
m_commands["exit"] = std::bind(&Client::exit, this, _1);
m_commands["setserver"] = std::bind(&Client::presetServerCmd, this, _1);
m_commands["setcallsign"] = std::bind(&Client::presetCallsignCmd, this, _1);
m_commands["icaocodes"] = std::bind(&Client::presetIcaoCodesCmd, this, _1);
m_commands["loginmode"] = std::bind(&Client::presetLoginModeCmd, this, _1);
m_commands["initconnect"] = std::bind(&Client::initiateConnectionCmd, this, _1);
m_commands["termconnect"] = std::bind(&Client::terminateConnectionCmd, this, _1);
m_commands["privmsg"] = std::bind(&Client::sendPrivateTextMessageCmd, this, _1);
m_commands["textmsg"] = std::bind(&Client::sendRadioTextMessageCmd, this, _1);
m_commands["ip"] = std::bind(&Client::sendIpQueryCmd, this, _1);
m_commands["freq"] = std::bind(&Client::sendFreqQueryCmd, this, _1);
m_commands["server"] = std::bind(&Client::sendServerQueryCmd, this, _1);
m_commands["atc"] = std::bind(&Client::sendAtcQueryCmd, this, _1);
m_commands["atis"] = std::bind(&Client::sendAtisQueryCmd, this, _1);
m_commands["flightplan"] = std::bind(&Client::sendFlightPlanCmd, this, _1);
m_commands["getflightplan"] = std::bind(&Client::sendFlightPlanQueryCmd, this, _1);
m_commands["name"] = std::bind(&Client::sendRealNameQueryCmd, this, _1);
m_commands["caps"] = std::bind(&Client::sendCapabilitiesQueryCmd, this, _1);
m_commands["icao"] = std::bind(&Client::sendIcaoCodesQueryCmd, this, _1);
m_commands["setaircraft"] = std::bind(&Client::setOwnAircraftCmd, this, _1);
m_commands["setposition"] = std::bind(&Client::setOwnAircraftPositionCmd, this, _1);
m_commands["setsituation"] = std::bind(&Client::setOwnAircraftSituationCmd, this, _1);
m_commands["setcockpit"] = std::bind(&Client::setOwnAircraftCockpitCmd, this, _1);
m_commands["ping"] = std::bind(&Client::sendPingCmd, this, _1);
m_commands["metar"] = std::bind(&Client::sendMetarQueryCmd, this, _1);
m_commands["help"] = std::bind(&Client::help, this, _1);
m_commands["echo"] = std::bind(&Client::echo, this, _1);
m_commands["exit"] = std::bind(&Client::exit, this, _1);
m_commands["setserver"] = std::bind(&Client::presetServerCmd, this, _1);
m_commands["setcallsign"] = std::bind(&Client::presetCallsignCmd, this, _1);
m_commands["icaocodes"] = std::bind(&Client::presetIcaoCodesCmd, this, _1);
m_commands["loginmode"] = std::bind(&Client::presetLoginModeCmd, this, _1);
m_commands["initconnect"] = std::bind(&Client::initiateConnectionCmd, this, _1);
m_commands["termconnect"] = std::bind(&Client::terminateConnectionCmd, this, _1);
m_commands["privmsg"] = std::bind(&Client::sendPrivateTextMessageCmd, this, _1);
m_commands["textmsg"] = std::bind(&Client::sendRadioTextMessageCmd, this, _1);
m_commands["ip"] = std::bind(&Client::sendIpQueryCmd, this, _1);
m_commands["freq"] = std::bind(&Client::sendFreqQueryCmd, this, _1);
m_commands["server"] = std::bind(&Client::sendServerQueryCmd, this, _1);
m_commands["atc"] = std::bind(&Client::sendAtcQueryCmd, this, _1);
m_commands["atis"] = std::bind(&Client::sendAtisQueryCmd, this, _1);
m_commands["flightplan"] = std::bind(&Client::sendFlightPlanCmd, this, _1);
m_commands["getflightplan"] = std::bind(&Client::sendFlightPlanQueryCmd, this, _1);
m_commands["name"] = std::bind(&Client::sendRealNameQueryCmd, this, _1);
m_commands["caps"] = std::bind(&Client::sendCapabilitiesQueryCmd, this, _1);
m_commands["icao"] = std::bind(&Client::sendIcaoCodesQueryCmd, this, _1);
m_commands["setaircraft"] = std::bind(&Client::setOwnAircraftCmd, this, _1);
m_commands["setposition"] = std::bind(&Client::setOwnAircraftPositionCmd, this, _1);
m_commands["setsituation"] = std::bind(&Client::setOwnAircraftSituationCmd, this, _1);
m_commands["setcockpit"] = std::bind(&Client::setOwnAircraftCockpitCmd, this, _1);
m_commands["ping"] = std::bind(&Client::sendPingCmd, this, _1);
m_commands["metar"] = std::bind(&Client::sendMetarQueryCmd, this, _1);
}
void Client::command(QString line)
@@ -275,8 +275,7 @@ namespace BlackSample
int cruiseTrueAirspeed;
QString flightRulesString;
QString route;
args >> equipmentIcao >> originAirportIcao >> destinationAirportIcao >> alternateAirportIcao >> takeoffTimePlanned >> takeoffTimeActual
>> enrouteTime >> fuelTime >> cruiseAltitude >> cruiseTrueAirspeed >> flightRulesString >> route;
args >> equipmentIcao >> originAirportIcao >> destinationAirportIcao >> alternateAirportIcao >> takeoffTimePlanned >> takeoffTimeActual >> enrouteTime >> fuelTime >> cruiseAltitude >> cruiseTrueAirspeed >> flightRulesString >> route;
const CFlightPlan::FlightRules flightRules = CFlightPlan::stringToFlightRules(flightRulesString);
const CCallsign callsign("DAMBZ");
@@ -353,13 +352,7 @@ namespace BlackSample
int xpdrCode;
QString xpdrMode;
args >> lat >> lon >> alt >> hdg >> pitch >> bank >> gs >> com1 >> com2 >> xpdrCode >> xpdrMode;
BlackMisc::Simulation::CSimulatedAircraft aircraft("", BlackMisc::Network::CUser(), BlackMisc::Aviation::CAircraftSituation(
BlackMisc::Geo::CCoordinateGeodetic(lat, lon, alt),
BlackMisc::Aviation::CHeading(hdg, BlackMisc::Aviation::CHeading::True, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
BlackMisc::PhysicalQuantities::CAngle(pitch, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
BlackMisc::PhysicalQuantities::CAngle(bank, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
BlackMisc::PhysicalQuantities::CSpeed(gs, BlackMisc::PhysicalQuantities::CSpeedUnit::kts())
));
BlackMisc::Simulation::CSimulatedAircraft aircraft("", BlackMisc::Network::CUser(), BlackMisc::Aviation::CAircraftSituation(BlackMisc::Geo::CCoordinateGeodetic(lat, lon, alt), BlackMisc::Aviation::CHeading(hdg, BlackMisc::Aviation::CHeading::True, BlackMisc::PhysicalQuantities::CAngleUnit::deg()), BlackMisc::PhysicalQuantities::CAngle(pitch, BlackMisc::PhysicalQuantities::CAngleUnit::deg()), BlackMisc::PhysicalQuantities::CAngle(bank, BlackMisc::PhysicalQuantities::CAngleUnit::deg()), BlackMisc::PhysicalQuantities::CSpeed(gs, BlackMisc::PhysicalQuantities::CSpeedUnit::kts())));
updateCockpit(
BlackMisc::Aviation::CComSystem("COM1", BlackMisc::PhysicalQuantities::CFrequency(com1, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())),
BlackMisc::Aviation::CComSystem("COM2", BlackMisc::PhysicalQuantities::CFrequency(com2, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())),
@@ -391,12 +384,11 @@ namespace BlackSample
double gs;
args >> lat >> lon >> alt >> hdg >> pitch >> bank >> gs;
updateOwnSituation(BlackMisc::Aviation::CAircraftSituation(
BlackMisc::Geo::CCoordinateGeodetic(lat, lon, alt),
BlackMisc::Aviation::CHeading(hdg, BlackMisc::Aviation::CHeading::True, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
BlackMisc::PhysicalQuantities::CAngle(pitch, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
BlackMisc::PhysicalQuantities::CAngle(bank, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
BlackMisc::PhysicalQuantities::CSpeed(gs, BlackMisc::PhysicalQuantities::CSpeedUnit::kts())
));
BlackMisc::Geo::CCoordinateGeodetic(lat, lon, alt),
BlackMisc::Aviation::CHeading(hdg, BlackMisc::Aviation::CHeading::True, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
BlackMisc::PhysicalQuantities::CAngle(pitch, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
BlackMisc::PhysicalQuantities::CAngle(bank, BlackMisc::PhysicalQuantities::CAngleUnit::deg()),
BlackMisc::PhysicalQuantities::CSpeed(gs, BlackMisc::PhysicalQuantities::CSpeedUnit::kts())));
}
void Client::setOwnAircraftCockpitCmd(QTextStream &args)
@@ -410,8 +402,7 @@ namespace BlackSample
BlackMisc::Aviation::CComSystem("COM1", BlackMisc::PhysicalQuantities::CFrequency(com1, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())),
BlackMisc::Aviation::CComSystem("COM2", BlackMisc::PhysicalQuantities::CFrequency(com2, BlackMisc::PhysicalQuantities::CFrequencyUnit::MHz())),
BlackMisc::Aviation::CTransponder(xpdrCode, xpdrMode),
"testclient"
);
"testclient");
}
void Client::sendPingCmd(QTextStream &args)
@@ -447,23 +438,23 @@ namespace BlackSample
{
switch (newStatus)
{
case BlackCore::INetwork::Disconnected: std::cout << "CONN_STATUS_DISCONNECTED"; break;
case BlackCore::INetwork::Disconnecting: std::cout << "CONN_STATUS_DISCONNECTING"; break;
case BlackCore::INetwork::DisconnectedError: std::cout << "CONN_STATUS_DISCONNECTED_ERROR"; break;
case BlackCore::INetwork::DisconnectedFailed: std::cout << "CONN_STATUS_DISCONNECTED_FAILED"; break;
case BlackCore::INetwork::DisconnectedLost: std::cout << "CONN_STATUS_DISCONNECTED_LOST"; break;
case BlackCore::INetwork::Connecting: std::cout << "CONN_STATUS_CONNECTING"; break;
case BlackCore::INetwork::Connected: std::cout << "CONN_STATUS_CONNECTED"; break;
case BlackCore::INetwork::Disconnected: std::cout << "CONN_STATUS_DISCONNECTED"; break;
case BlackCore::INetwork::Disconnecting: std::cout << "CONN_STATUS_DISCONNECTING"; break;
case BlackCore::INetwork::DisconnectedError: std::cout << "CONN_STATUS_DISCONNECTED_ERROR"; break;
case BlackCore::INetwork::DisconnectedFailed: std::cout << "CONN_STATUS_DISCONNECTED_FAILED"; break;
case BlackCore::INetwork::DisconnectedLost: std::cout << "CONN_STATUS_DISCONNECTED_LOST"; break;
case BlackCore::INetwork::Connecting: std::cout << "CONN_STATUS_CONNECTING"; break;
case BlackCore::INetwork::Connected: std::cout << "CONN_STATUS_CONNECTED"; break;
}
switch (oldStatus)
{
case BlackCore::INetwork::Disconnected: std::cout << " (was CONN_STATUS_DISCONNECTED)\n"; break;
case BlackCore::INetwork::Disconnecting: std::cout << " (was CONN_STATUS_DISCONNECTING)\n"; break;
case BlackCore::INetwork::DisconnectedError: std::cout << " (was CONN_STATUS_DISCONNECTED_ERROR)\n"; break;
case BlackCore::INetwork::DisconnectedFailed: std::cout << " (was CONN_STATUS_DISCONNECTED_FAILED)\n"; break;
case BlackCore::INetwork::DisconnectedLost: std::cout << " (was CONN_STATUS_DISCONNECTED_LOST)\n"; break;
case BlackCore::INetwork::Connecting: std::cout << " (was CONN_STATUS_CONNECTING)\n"; break;
case BlackCore::INetwork::Connected: std::cout << " (was CONN_STATUS_CONNECTED)\n"; break;
case BlackCore::INetwork::Disconnected: std::cout << " (was CONN_STATUS_DISCONNECTED)\n"; break;
case BlackCore::INetwork::Disconnecting: std::cout << " (was CONN_STATUS_DISCONNECTING)\n"; break;
case BlackCore::INetwork::DisconnectedError: std::cout << " (was CONN_STATUS_DISCONNECTED_ERROR)\n"; break;
case BlackCore::INetwork::DisconnectedFailed: std::cout << " (was CONN_STATUS_DISCONNECTED_FAILED)\n"; break;
case BlackCore::INetwork::DisconnectedLost: std::cout << " (was CONN_STATUS_DISCONNECTED_LOST)\n"; break;
case BlackCore::INetwork::Connecting: std::cout << " (was CONN_STATUS_CONNECTING)\n"; break;
case BlackCore::INetwork::Connected: std::cout << " (was CONN_STATUS_CONNECTED)\n"; break;
}
}
@@ -515,7 +506,7 @@ namespace BlackSample
void Client::flightPlanReplyReceived(const CCallsign &callsign, const CFlightPlan &flightPlan)
{
const QString rules = flightPlan.getFlightRulesAsString();
std::cout << "FLIGHTPLAN " << callsign
std::cout << "FLIGHTPLAN " << callsign
<< flightPlan.getCombinedPrefixIcaoSuffix().toStdString() << " " << flightPlan.getOriginAirportIcao() << " "
<< flightPlan.getDestinationAirportIcao() << " " << flightPlan.getAlternateAirportIcao() << " "
<< flightPlan.getTakeoffTimePlannedHourMin().toStdString() << " " << flightPlan.getTakeoffTimeActualHourMin().toStdString() << " "

View File

@@ -40,10 +40,17 @@ namespace BlackMisc
class CInformationMessage;
class CTransponder;
}
namespace Network { class CServer; }
namespace Simulation { class CSimulatedAircraft; }
namespace Network
{
class CServer;
}
namespace Simulation
{
class CSimulatedAircraft;
}
}
template <class T> class QVector;
template <class T>
class QVector;
namespace BlackSample
{
@@ -74,7 +81,7 @@ namespace BlackSample
//! Handle command
void command(QString line);
private: //commands
private: // commands
void help(QTextStream &args);
void echo(QTextStream &args);
void exit(QTextStream &args);

View File

@@ -23,7 +23,7 @@ using namespace BlackMisc;
//! main
int main(int argc, char *argv[])
{
QCoreApplication app (argc, argv);
QCoreApplication app(argc, argv);
BlackMisc::CLogHandler::instance()->install();
Client client(&app);

View File

@@ -27,7 +27,7 @@ namespace BlackSample
forever
{
QString line = file.readLine().trimmed();
if (! line.isEmpty())
if (!line.isEmpty())
{
emit command(line);
}

View File

@@ -47,11 +47,11 @@ void CLineReader::run()
const QStringList parts = line.split(' ');
if (parts.size() == 2)
{
const CLatitude latitude(CAngle::parsedFromString(parts.front(), CPqString::SeparatorBestGuess, CAngleUnit::deg()));
const CLatitude latitude(CAngle::parsedFromString(parts.front(), CPqString::SeparatorBestGuess, CAngleUnit::deg()));
const CLongitude longitude(CAngle::parsedFromString(parts.back(), CPqString::SeparatorBestGuess, CAngleUnit::deg()));
const CAltitude alt(600, CLengthUnit::m());
const CAltitude alt(600, CLengthUnit::m());
const CCoordinateGeodetic position { latitude, longitude, alt};
const CCoordinateGeodetic position { latitude, longitude, alt };
emit weatherDataRequest(position);
}
else

View File

@@ -41,9 +41,8 @@ using namespace BlackMisc::Geo;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackCore;
CWeatherDataPrinter::CWeatherDataPrinter(QObject *parent) : QObject(parent)
{ }
{}
void CWeatherDataPrinter::fetchAndPrintWeatherData(const CCoordinateGeodetic &position)
{