mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
312 lines
9.0 KiB
C++
312 lines
9.0 KiB
C++
/* Copyright (C) 2013 VATSIM Community / authors
|
||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||
|
||
#include "testservice.h"
|
||
#include "blackmisc/blackmiscfreefunctions.h"
|
||
|
||
using namespace BlackMisc::Aviation;
|
||
using namespace BlackMisc::Geo;
|
||
using namespace BlackMisc::PhysicalQuantities;
|
||
using namespace BlackMisc::Network;
|
||
|
||
namespace BlackMiscTest
|
||
{
|
||
|
||
const QString Testservice::ServiceName = QString(BLACKMISCKTEST_TESTSERVICE_INTERFACENAME);
|
||
const QString Testservice::ServicePath = QString(BLACKMISCKTEST_TESTSERVICE_SERVICEPATH);
|
||
|
||
/*
|
||
* Constructor
|
||
*/
|
||
Testservice::Testservice(QObject *parent) : QObject(parent)
|
||
{
|
||
// void
|
||
}
|
||
|
||
/*
|
||
* Slot to receive messages
|
||
*/
|
||
void Testservice::receiveStringMessage(const QString &message)
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received message:" << message;
|
||
}
|
||
|
||
/*
|
||
* Receive variant
|
||
*/
|
||
void Testservice::receiveVariant(const QDBusVariant &variant, int localMetaType)
|
||
{
|
||
QVariant qv = variant.variant();
|
||
QVariant qvF = BlackMisc::fixQVariantFromDbusArgument(qv, localMetaType);
|
||
QString s = BlackMisc::qVariantToString(qvF, true);
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received variant:" << s;
|
||
}
|
||
|
||
/*
|
||
* Receive speed
|
||
*/
|
||
void Testservice::receiveSpeed(const BlackMisc::PhysicalQuantities::CSpeed &speed)
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received speed:" << speed;
|
||
}
|
||
|
||
/*
|
||
* Ping speed
|
||
*/
|
||
BlackMisc::PhysicalQuantities::CSpeed Testservice::pingSpeed(const BlackMisc::PhysicalQuantities::CSpeed &speed)
|
||
{
|
||
return speed;
|
||
}
|
||
|
||
/*
|
||
* Get speed
|
||
*/
|
||
BlackMisc::PhysicalQuantities::CSpeed Testservice::getSpeed() const
|
||
{
|
||
return BlackMisc::PhysicalQuantities::CSpeed(666, BlackMisc::PhysicalQuantities::CSpeedUnit::km_h());
|
||
}
|
||
|
||
/*
|
||
* Station
|
||
*/
|
||
BlackMisc::Aviation::CAtcStation Testservice::getAtcStation() const
|
||
{
|
||
CCoordinateGeodetic geoPos = CCoordinateGeodetic::fromWgs84("48° 21′ 13″ N", "11° 47′ 09″ E", CLength(1487, CLengthUnit::ft())); // Munich
|
||
CAtcStation station(CCallsign("eddm_twr"), CUser("654321", "client"),
|
||
CFrequency(118.7, CFrequencyUnit::MHz()),
|
||
geoPos, CLength(50, CLengthUnit::km()));
|
||
return station;
|
||
}
|
||
|
||
/*
|
||
* Receive COM unit
|
||
*/
|
||
void Testservice::receiveComUnit(const BlackMisc::Aviation::CComSystem &comUnit)
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received COM:" << comUnit;
|
||
}
|
||
|
||
/*
|
||
* Receive altitude
|
||
*/
|
||
void Testservice::receiveAltitude(const BlackMisc::Aviation::CAltitude &altitude)
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received altitude:" << altitude;
|
||
}
|
||
|
||
/*
|
||
* Receive matrix
|
||
*/
|
||
void Testservice::receiveMatrix(const BlackMisc::Math::CMatrix3x3 &matrix)
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received matrix:" << matrix;
|
||
}
|
||
|
||
/*
|
||
* Receive a list
|
||
*/
|
||
void Testservice::receiveList(const QList<double> &list)
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received list:" << list;
|
||
}
|
||
|
||
/*
|
||
* Receive a geo position
|
||
*/
|
||
void Testservice::receiveGeoPosition(const BlackMisc::Geo::CCoordinateGeodetic &geo) const
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received geo data:" << geo;
|
||
}
|
||
|
||
/*
|
||
* Receive transponder
|
||
*/
|
||
void Testservice::receiveTransponder(const BlackMisc::Aviation::CTransponder &transponder) const
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received transponder:" << transponder;
|
||
}
|
||
|
||
/*
|
||
* Receive track
|
||
*/
|
||
void Testservice::receiveTrack(const BlackMisc::Aviation::CTrack &track) const
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received track:" << track;
|
||
}
|
||
|
||
/*
|
||
* Receive a length
|
||
*/
|
||
void Testservice::receiveLength(const BlackMisc::PhysicalQuantities::CLength &length) const
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received length:" << length;
|
||
}
|
||
|
||
/*
|
||
* Receive lengths
|
||
*/
|
||
void Testservice::receiveLengthsQvl(const QVariantList &lengthsVariantList) const
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << lengthsVariantList;
|
||
foreach(QVariant lv, lengthsVariantList)
|
||
{
|
||
BlackMisc::PhysicalQuantities::CLength l;
|
||
lv.value<QDBusArgument>() >> l;
|
||
qDebug() << " Received length in list:" << l;
|
||
}
|
||
}
|
||
|
||
/*
|
||
* Receive lengths
|
||
*/
|
||
void Testservice::receiveLengthsQl(const QList<QVariant> &lengthsList) const
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received " << lengthsList;
|
||
foreach(QVariant lv, lengthsList)
|
||
{
|
||
BlackMisc::PhysicalQuantities::CLength l;
|
||
lv.value<QDBusArgument>() >> l;
|
||
qDebug() << " Received length in list:" << l;
|
||
}
|
||
}
|
||
|
||
/*
|
||
* Receive callsign
|
||
*/
|
||
void Testservice::receiveCallsign(const BlackMisc::Aviation::CCallsign &callsign) const
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received callsign:" << callsign;
|
||
}
|
||
|
||
/*
|
||
* Receive ATC list
|
||
*/
|
||
void Testservice::receiveAtcStationList(const BlackMisc::Aviation::CAtcStationList &atcStationList) const
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received ATC list:" << atcStationList;
|
||
}
|
||
|
||
/*
|
||
* Receive value map
|
||
*/
|
||
void Testservice::receiveValueMap(const BlackMisc::CIndexVariantMap &valueMap) const
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received value map:" << valueMap;
|
||
}
|
||
|
||
/*
|
||
* Receive callsign
|
||
*/
|
||
void Testservice::receiveAtcStation(const BlackMisc::Aviation::CAtcStation &station) const
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "Received ATC station:" << station;
|
||
}
|
||
|
||
/*
|
||
* Object paths
|
||
*/
|
||
const QList<QDBusObjectPath> Testservice::getObjectPaths(const qint32 number) const
|
||
{
|
||
QList<QDBusObjectPath> paths;
|
||
for (int i = 0; i < number; i++)
|
||
{
|
||
paths.append(QDBusObjectPath(BLACKMISCKTEST_TESTSERVICE_SERVICEPATH));
|
||
}
|
||
return paths;
|
||
}
|
||
|
||
/*
|
||
* Ping ATC station
|
||
*/
|
||
const BlackMisc::Aviation::CAtcStationList Testservice::getAtcStationList(const qint32 number) const
|
||
{
|
||
return BlackMisc::Aviation::CAtcStationList(ServiceTool::getStations(number));
|
||
}
|
||
|
||
/*
|
||
* Ping ATC list
|
||
*/
|
||
BlackMisc::Aviation::CAtcStationList Testservice::pingAtcStationList(const BlackMisc::Aviation::CAtcStationList &atcStationList) const
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping ATCs:" << atcStationList;
|
||
return atcStationList;
|
||
}
|
||
|
||
/*
|
||
* Ping aircrafts
|
||
*/
|
||
CAircraftList Testservice::pingAircraftList(const CAircraftList &aircraftList)
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping ATCs:" << aircraftList;
|
||
return aircraftList;
|
||
}
|
||
|
||
/*
|
||
* Ping airports
|
||
*/
|
||
CAirportList Testservice::pingAirportList(const CAirportList &airportList)
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping airports:" << airportList;
|
||
return airportList;
|
||
}
|
||
|
||
/*
|
||
* NW client
|
||
*/
|
||
CClient Testservice::pingClient(const CClient &client)
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping client:" << client;
|
||
return client;
|
||
}
|
||
|
||
/*
|
||
* NW clients
|
||
*/
|
||
CClientList Testservice::pingClientList(const CClientList &clientList)
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping clients:" << clientList;
|
||
return clientList;
|
||
}
|
||
|
||
/*
|
||
* Ping altitude
|
||
*/
|
||
BlackMisc::Aviation::CAltitude Testservice::pingAltitude(const BlackMisc::Aviation::CAltitude &altitude)
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping alt:" << altitude;
|
||
return altitude;
|
||
}
|
||
|
||
/*
|
||
* Ping ATC station
|
||
*/
|
||
BlackMisc::Aviation::CAtcStation Testservice::pingAtcStation(const BlackMisc::Aviation::CAtcStation &station)
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping ATC:" << station;
|
||
return station;
|
||
}
|
||
|
||
/*
|
||
* Ping aircraft
|
||
*/
|
||
BlackMisc::Aviation::CAircraft Testservice::pingAircraft(const BlackMisc::Aviation::CAircraft &aircraft)
|
||
{
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "ping aircraft:" << aircraft;
|
||
return aircraft;
|
||
}
|
||
|
||
/*
|
||
* Ping variant
|
||
*/
|
||
BlackMisc::CVariant Testservice::pingCVariant(const BlackMisc::Network::CClient &client)
|
||
{
|
||
// we receive as QVariant, but return as CVariant!
|
||
qDebug() << "Pid:" << ServiceTool::getPid() << "client sent back as CVariant:" << client.toQString();
|
||
return BlackMisc::CVariant::fromValue(client);
|
||
}
|
||
|
||
|
||
} // namespace
|