mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 23:45:35 +08:00
213 lines
10 KiB
C++
213 lines
10 KiB
C++
/* Copyright (C) 2013
|
|
* swift Project Community / Contributors
|
|
*
|
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
* contained in the LICENSE file.
|
|
*/
|
|
|
|
#include "blackcore/context/contextsimulatorproxy.h"
|
|
#include "blackmisc/dbus.h"
|
|
#include "blackmisc/genericdbusinterface.h"
|
|
#include "blackmisc/simulation/simulatedaircraft.h"
|
|
|
|
#include <QDBusConnection>
|
|
#include <QLatin1Literal>
|
|
#include <QObject>
|
|
#include <QtGlobal>
|
|
|
|
using namespace BlackMisc;
|
|
using namespace BlackMisc::PhysicalQuantities;
|
|
using namespace BlackMisc::Aviation;
|
|
using namespace BlackMisc::Network;
|
|
using namespace BlackMisc::Geo;
|
|
using namespace BlackMisc::Simulation;
|
|
|
|
namespace BlackCore
|
|
{
|
|
namespace Context
|
|
{
|
|
CContextSimulatorProxy::CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : IContextSimulator(mode, runtime), m_dBusInterface(nullptr)
|
|
{
|
|
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
|
serviceName , IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
|
connection, this);
|
|
this->relaySignals(serviceName, connection);
|
|
}
|
|
|
|
void CContextSimulatorProxy::relaySignals(const QString &serviceName, QDBusConnection &connection)
|
|
{
|
|
bool s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
|
"simulatorStatusChanged", this, SIGNAL(simulatorStatusChanged(int)));
|
|
Q_ASSERT(s);
|
|
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
|
"modelSetChanged", this, SIGNAL(modelSetChanged()));
|
|
Q_ASSERT(s);
|
|
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
|
"ownAircraftModelChanged", this, SIGNAL(ownAircraftModelChanged(BlackMisc::Simulation::CAircraftModel)));
|
|
Q_ASSERT(s);
|
|
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
|
"modelMatchingCompleted", this, SIGNAL(modelMatchingCompleted(BlackMisc::Simulation::CSimulatedAircraft)));
|
|
Q_ASSERT(s);
|
|
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
|
"renderRestrictionsChanged", this, SIGNAL(renderRestrictionsChanged(bool, bool, int, BlackMisc::PhysicalQuantities::CLength)));
|
|
Q_ASSERT(s);
|
|
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
|
"simulatorPluginChanged", this, SIGNAL(simulatorPluginChanged(BlackMisc::Simulation::CSimulatorPluginInfo)));
|
|
Q_ASSERT(s);
|
|
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
|
"airspaceSnapshotHandled", this, SIGNAL(airspaceSnapshotHandled()));
|
|
Q_ASSERT(s);
|
|
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
|
"weatherGridReceived", this, SIGNAL(weatherGridReceived(BlackMisc::Weather::CWeatherGrid, BlackMisc::CIdentifier)));
|
|
Q_ASSERT(s);
|
|
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
|
"addingRemoteModelFailed", this, SIGNAL(addingRemoteModelFailed(BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::CStatusMessage)));
|
|
Q_ASSERT(s);
|
|
Q_UNUSED(s);
|
|
this->relayBaseClassSignals(serviceName, connection, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName());
|
|
}
|
|
|
|
CSimulatorPluginInfoList CContextSimulatorProxy::getAvailableSimulatorPlugins() const
|
|
{
|
|
return m_dBusInterface->callDBusRet<CSimulatorPluginInfoList>(QLatin1Literal("getAvailableSimulatorPlugins"));
|
|
}
|
|
|
|
int CContextSimulatorProxy::getSimulatorStatus() const
|
|
{
|
|
return m_dBusInterface->callDBusRet<int>(QLatin1Literal("getSimulatorStatus"));
|
|
}
|
|
|
|
CAirportList CContextSimulatorProxy::getAirportsInRange() const
|
|
{
|
|
return m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAirportList>(QLatin1Literal("getAirportsInRange"));
|
|
}
|
|
|
|
CAircraftModelList CContextSimulatorProxy::getModelSet() const
|
|
{
|
|
return m_dBusInterface->callDBusRet<BlackMisc::Simulation::CAircraftModelList>(QLatin1Literal("getModelSet"));
|
|
}
|
|
|
|
CSimulatorInfo CContextSimulatorProxy::simulatorsWithInitializedModelSet() const
|
|
{
|
|
return m_dBusInterface->callDBusRet<BlackMisc::Simulation::CSimulatorInfo>(QLatin1Literal("simulatorsWithInitializedModelSet"));
|
|
}
|
|
|
|
QStringList CContextSimulatorProxy::getModelSetStrings() const
|
|
{
|
|
return m_dBusInterface->callDBusRet<QStringList>(QLatin1Literal("getModelSetStrings"));
|
|
}
|
|
|
|
QStringList CContextSimulatorProxy::getModelSetCompleterStrings(bool sorted) const
|
|
{
|
|
return m_dBusInterface->callDBusRet<QStringList>(QLatin1Literal("getModelSetCompleterStrings"), sorted);
|
|
}
|
|
|
|
CAircraftModelList CContextSimulatorProxy::getModelSetModelsStartingWith(const QString modelString) const
|
|
{
|
|
return m_dBusInterface->callDBusRet<BlackMisc::Simulation::CAircraftModelList>(QLatin1Literal("getModelSetModelsStartingWith"), modelString);
|
|
}
|
|
|
|
int CContextSimulatorProxy::getModelSetCount() const
|
|
{
|
|
return m_dBusInterface->callDBusRet<int>(QLatin1Literal("getModelSetCount"));
|
|
}
|
|
|
|
BlackMisc::Simulation::CSimulatorPluginInfo CContextSimulatorProxy::getSimulatorPluginInfo() const
|
|
{
|
|
return m_dBusInterface->callDBusRet<BlackMisc::Simulation::CSimulatorPluginInfo>(QLatin1Literal("getSimulatorPluginInfo"));
|
|
}
|
|
|
|
CSimulatorInternals CContextSimulatorProxy::getSimulatorInternals() const
|
|
{
|
|
return m_dBusInterface->callDBusRet<BlackMisc::Simulation::CSimulatorInternals>(QLatin1Literal("getSimulatorInternals"));
|
|
}
|
|
|
|
bool CContextSimulatorProxy::setTimeSynchronization(bool enable, const CTime &offset)
|
|
{
|
|
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("setTimeSynchronization"), enable, offset);
|
|
}
|
|
|
|
bool CContextSimulatorProxy::isTimeSynchronized() const
|
|
{
|
|
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isTimeSynchronized"));
|
|
}
|
|
|
|
CInterpolationAndRenderingSetup CContextSimulatorProxy::getInterpolationAndRenderingSetup() const
|
|
{
|
|
return m_dBusInterface->callDBusRet<CInterpolationAndRenderingSetup>(QLatin1Literal("getInterpolationAndRenderingSetup"));
|
|
}
|
|
|
|
void CContextSimulatorProxy::setInterpolationAndRenderingSetup(const CInterpolationAndRenderingSetup &setup)
|
|
{
|
|
m_dBusInterface->callDBus(QLatin1Literal("setInterpolationAndRenderingSetup"), setup);
|
|
}
|
|
|
|
CTime CContextSimulatorProxy::getTimeSynchronizationOffset() const
|
|
{
|
|
return m_dBusInterface->callDBusRet<BlackMisc::PhysicalQuantities::CTime>(QLatin1Literal("getTimeSynchronizationOffset"));
|
|
}
|
|
|
|
bool CContextSimulatorProxy::startSimulatorPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo)
|
|
{
|
|
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("startSimulatorPlugin"), simulatorInfo);
|
|
}
|
|
|
|
void CContextSimulatorProxy::stopSimulatorPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo)
|
|
{
|
|
m_dBusInterface->callDBus(QLatin1Literal("stopSimulatorPlugin"), simulatorInfo);
|
|
}
|
|
|
|
CPixmap CContextSimulatorProxy::iconForModel(const QString &modelString) const
|
|
{
|
|
return m_dBusInterface->callDBusRet<CPixmap>(QLatin1Literal("iconForModel"), modelString);
|
|
}
|
|
|
|
void CContextSimulatorProxy::highlightAircraft(const CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const CTime &displayTime)
|
|
{
|
|
m_dBusInterface->callDBus(QLatin1Literal("highlightAircraft"), aircraftToHighlight, enableHighlight, displayTime);
|
|
}
|
|
|
|
bool CContextSimulatorProxy::resetToModelMatchingAircraft(const CCallsign &callsign)
|
|
{
|
|
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("resetToModelMatchingAircraft"), callsign, callsign);
|
|
}
|
|
|
|
void CContextSimulatorProxy::setWeatherActivated(bool activated)
|
|
{
|
|
m_dBusInterface->callDBus(QLatin1Literal("setWeatherActivated"), activated);
|
|
}
|
|
|
|
void CContextSimulatorProxy::requestWeatherGrid(const Weather::CWeatherGrid &weatherGrid, const CIdentifier &identifier)
|
|
{
|
|
m_dBusInterface->callDBus(QLatin1Literal("requestWeatherGrid"), weatherGrid, identifier);
|
|
}
|
|
|
|
CStatusMessageList CContextSimulatorProxy::getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const
|
|
{
|
|
return m_dBusInterface->callDBusRet<BlackMisc::CStatusMessageList>(QLatin1Literal("getMatchingMessages"), callsign);
|
|
}
|
|
|
|
bool CContextSimulatorProxy::isMatchingMessagesEnabled() const
|
|
{
|
|
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("isMatchingMessagesEnabled"));
|
|
}
|
|
|
|
void CContextSimulatorProxy::enableMatchingMessages(bool enabled)
|
|
{
|
|
m_dBusInterface->callDBus(QLatin1Literal("enableMatchingMessages"), enabled);
|
|
}
|
|
|
|
bool CContextSimulatorProxy::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
|
|
{
|
|
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("parseCommandLine"), commandLine, originator);
|
|
}
|
|
|
|
CMatchingStatistics CContextSimulatorProxy::getCurrentMatchingStatistics(bool missingOnly) const
|
|
{
|
|
return m_dBusInterface->callDBusRet<CMatchingStatistics>(QLatin1Literal("getCurrentMatchingStatistics"), missingOnly);
|
|
}
|
|
} // namespace
|
|
} // namespace
|