13 #include <QDBusConnection>
14 #include <QDBusConnectionInterface>
16 #include <QDBusMessage>
17 #include <QDBusObjectPath>
18 #include <QDBusPendingReply>
20 #include <QDBusVariant>
23 #include <QElapsedTimer>
25 #include <QLatin1Char>
30 #include <QTextStream>
43 using namespace swift::misc::simulation;
44 using namespace swift::misc::physical_quantities;
45 using namespace swift::misc::aviation;
46 using namespace swift::misc::math;
47 using namespace swift::misc::geo;
48 using namespace swift::misc::network;
49 using namespace swift::misc::simulation::fscommon;
53 namespace swift::sample
55 void ServiceTool::dataTransferTestServer(
CDBusServer *dBusServer,
bool verbose)
60 qFatal(
"Testservice already registed on session bus");
66 dBusServer->
addObject(CTestService::ObjectPath(), testService);
69 void ServiceTool::dataTransferTestClient(
const QString &address)
79 ServiceTool::sendDataToTestservice(connection);
99 const QString msg = QStringLiteral(
"Con.: %1, message at %2")
105 qtout <<
"----------------- receiver tests ----------------" <<
Qt::endl;
108 if (connection.
send(m)) { qtout <<
"Send via low level method " <<
Qt::endl; }
113 qtout <<
"Send string via interface " << msg <<
Qt::endl;
117 qtout <<
"Send list via interface " << list.size() <<
Qt::endl;
120 CSpeed speed(200, CSpeedUnit::km_h());
121 const CSpeed speedNull(0,
nullptr);
124 qtout <<
"Send speed via interface " << speed <<
Qt::endl;
126 qtout <<
"Send null speed via interface " << speedNull <<
Qt::endl;
129 qtout <<
"Send speed via interface " << speed <<
Qt::endl;
134 const CServer trafficServer = CTestData::getTrafficServer();
138 qtout <<
"Send server via interface and variant '" << trafficServer <<
QLatin1String(
"' ")
142 const CComSystem comSystem =
CComSystem(
"DBUS COM1", CPhysicalQuantitiesConstants::FrequencyUnicom(),
143 CPhysicalQuantitiesConstants::FrequencyUnicom());
145 qtout <<
"Send COM via interface " << comSystem <<
Qt::endl;
147 CAltitude altitude(1000, CAltitude::MeanSeaLevel, CLengthUnit::ft());
152 qtout <<
"Send altitude via interface and variant " << altitude << qvAl.
userType() <<
Qt::endl;
155 const CTransponder transponder(7000, CTransponder::ModeC);
157 qtout <<
"Send transponder via interface " << transponder <<
Qt::endl;
159 const CTrack track(123.45, CTrack::Magnetic, CAngleUnit::deg());
161 qtout <<
"Send track via interface " << track <<
Qt::endl;
163 const CLength len(33, CLengthUnit::m());
165 qtout <<
"Send length via interface " << len <<
Qt::endl;
167 const CAltitude alt(44, CAltitude::MeanSeaLevel, CLengthUnit::m());
169 qtout <<
"Send altitude via interface " << alt <<
Qt::endl;
171 const CCallsign callsign = CTestData::getRandomPilotCallsign();
173 qtout <<
"Send callsign via interface " << callsign <<
Qt::endl;
175 const CAtcStation station = CTestData::getMunichTower();
177 qtout <<
"Send ATC " << station <<
Qt::endl;
182 qtout <<
"Send geo position " << geoPos <<
Qt::endl;
183 CApplication::processEventsFor(1000);
185 qtout <<
"----------------- variant tests ----------------" <<
Qt::endl;
186 const CVariantList cvList = CTestData::getCVariantList();
188 qtout <<
"Send " << cvList.
size() <<
" variants via interface as CVariantList" <<
Qt::endl;
192 qtout <<
"Send " << valueMap.
size() <<
" index variant map entries" <<
Qt::endl;
193 CApplication::processEventsFor(1000);
195 qtout <<
"----------------- pings ----------------" <<
Qt::endl;
196 const int errors = ITestServiceInterface::pingTests(testServiceInterface,
false);
197 qtout <<
"Ping errors " << errors <<
Qt::endl;
198 CApplication::processEventsFor(1000);
201 qtout <<
"----------------- performance ----------------" <<
Qt::endl;
205 for (
int i = 0; i < 10; i++)
208 Q_UNUSED(speedDummy);
213 for (
int i = 0; i < 100; i++)
216 Q_UNUSED(speedDummy);
221 for (
int i = 0; i < 1000; i++)
224 Q_UNUSED(speedDummy);
226 qint64 t1000 = timer.
elapsed();
228 qtout <<
"Reading speed objects 10/100/1000 in ms: " << t10 <<
" " << t100 <<
" " << t1000 <<
Qt::endl;
231 for (
int i = 0; i < 10; i++)
234 Q_UNUSED(stationDummy);
238 for (
int i = 0; i < 100; i++)
241 Q_UNUSED(stationDummy);
245 for (
int i = 0; i < 1000; i++)
248 Q_UNUSED(stationDummy);
251 qtout <<
"Reading station objects 10/100/1000 in ms: " << t10 <<
" " << t100 <<
" " << t1000 <<
Qt::endl;
255 if (atcStationList.
size() != 10) qtout <<
"wrong list size" << atcStationList.
size() <<
Qt::endl;
259 if (atcStationList.
size() != 100) qtout <<
"wrong list size" << atcStationList.
size() <<
Qt::endl;
263 if (atcStationList.
size() != 1000) qtout <<
"wrong list size" << atcStationList.
size() <<
Qt::endl;
265 qtout <<
"Reading station list 10/100/1000 in ms: " << t10 <<
" " << t100 <<
" " << t1000 <<
Qt::endl;
270 if (entriesList.
size() != 5000) qtout <<
"wrong list size" << entriesList.
size() <<
Qt::endl;
271 qint64 t5000 = timer.
elapsed();
272 qtout <<
"Reading aircraft cfg entries in ms: " << t5000 <<
Qt::endl;
277 if (objectPaths.
size() != 10) qtout <<
"wrong list size" << objectPaths.
size() <<
Qt::endl;
281 if (objectPaths.
size() != 100) qtout <<
"wrong list size" << objectPaths.
size() <<
Qt::endl;
285 if (objectPaths.
size() != 1000) qtout <<
"wrong list size" << objectPaths.
size() <<
Qt::endl;
287 qtout <<
"Reading paths list 10/100/1000 in ms: " << t10 <<
" " << t100 <<
" " << t1000 <<
Qt::endl;
291 qtout <<
"---------------------------------------" <<
Qt::endl;
292 qtout <<
"Key ....... x to exit" <<
Qt::endl;
void addObject(const QString &name, QObject *object)
Add a QObject to be exposed via DBus.
Specialized value object compliant map for variants, based on indexes.
int size() const
Number of elements.
size_type size() const
Returns number of elements in the sequence.
Value object encapsulating a list of variants.
Altitude as used in aviation, can be AGL or MSL altitude.
Value object encapsulating information about an ATC station.
Value object for a list of ATC stations.
Value object encapsulating information of a callsign.
Track as used in aviation, can be true or magnetic Track.
Value object encapsulating information of a server.
Physical unit length (length)
PQ & switchUnit(const MU &newUnit)
Change unit, and convert value to maintain the same quantity.
void addValueSameUnit(double value)
Add to the value in the current unit.
Utility, providing FS aircraft.cfg entries.
Testservice for PQ / CValueObject DBus tests. This part is the callee.
Proxy class for swift::misc::Test::CTestService. This part is the caller.
QDBusPendingReply receiveAtcStation(const swift::misc::aviation::CAtcStation &station)
DBus calls.
QDBusPendingReply receiveStringMessage(const QString &message)
DBus calls.
QDBusPendingReply< swift::misc::simulation::fscommon::CAircraftCfgEntriesList > getAircraftCfgEntriesList(int number)
DBus calls.
QDBusPendingReply receiveSpeed(const swift::misc::physical_quantities::CSpeed &speed)
DBus calls.
QDBusPendingReply receiveVariantList(const swift::misc::CVariantList &list)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CAtcStation > getAtcStation()
DBus calls.
QDBusPendingReply receiveCallsign(const swift::misc::aviation::CCallsign &callsign)
DBus calls.
QDBusPendingReply receiveLength(const swift::misc::physical_quantities::CLength &length)
DBus calls.
QDBusPendingReply receiveList(const QList< double > &list)
DBus calls.
QDBusPendingReply receiveComUnit(const swift::misc::aviation::CComSystem &comUnit)
DBus calls.
QDBusPendingReply receiveGeoPosition(const swift::misc::geo::CCoordinateGeodetic &geo)
DBus calls.
QDBusPendingReply receiveTransponder(const swift::misc::aviation::CTransponder &transponder)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CAltitude > receiveAltitude(const swift::misc::aviation::CAltitude &altitude)
DBus calls.
QDBusPendingReply< QList< QDBusObjectPath > > getObjectPaths(int number)
DBus calls.
QDBusPendingReply< swift::misc::physical_quantities::CSpeed > getSpeed()
DBus calls.
QDBusPendingReply receiveTrack(const swift::misc::aviation::CTrack &track)
DBus calls.
QDBusPendingReply receiveVariant(const QDBusVariant &variant, int localMetyType)
DBus calls.
QDBusPendingReply receiveValueMap(const swift::misc::CPropertyIndexVariantMap &valueMap)
DBus calls.
QDBusPendingReply< swift::misc::aviation::CAtcStationList > getAtcStationList(int number)
DBus calls.
Backend services of the swift project, like dealing with the network or the simulators.
Generate data for testing purposes.
Free functions in swift::misc.
QCoreApplication * instance()
QDateTime currentDateTimeUtc()
QString toString(QStringView format) const const
QDBusConnection connectToPeer(const QString &address, const QString &name)
QDBusConnectionInterface * interface() const const
QString name() const const
bool send(const QDBusMessage &message) const const
QDBusConnection sessionBus()
QDBusReply< bool > isServiceRegistered(const QString &serviceName) const const
QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name)
qint64 elapsed() const const
qsizetype size() const const
QString arg(Args &&... args) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QString toLower() const const
QString trimmed() const const
QTextStream & endl(QTextStream &stream)
QString readLine(qint64 maxlen)
QVariant fromValue(T &&value)
int userType() const const