mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #207, added SimulatorInfo to context
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/context_runtime.h"
|
||||
#include "blackmisc/avaircraft.h"
|
||||
#include "blacksim/simulatorinfo.h"
|
||||
#include <QObject>
|
||||
|
||||
namespace BlackCore
|
||||
@@ -53,6 +54,9 @@ namespace BlackCore
|
||||
//! Get user aircraft value object
|
||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const = 0;
|
||||
|
||||
//! Simulator info
|
||||
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const = 0;
|
||||
|
||||
protected:
|
||||
//! \brief Constructor
|
||||
IContextSimulator(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}
|
||||
|
||||
@@ -41,6 +41,13 @@ namespace BlackCore
|
||||
return m_ownAircraft;
|
||||
}
|
||||
|
||||
BlackSim::CSimulatorInfo CContextSimulator::getSimulatorInfo() const
|
||||
{
|
||||
if (this->getRuntime()->isSlotLogForSimulatorEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
|
||||
if (!m_simulator) return BlackSim::CSimulatorInfo::UnspecifiedSim();
|
||||
return m_simulator->getSimulatorInfo();
|
||||
}
|
||||
|
||||
void CContextSimulator::updateOwnAircraft()
|
||||
{
|
||||
m_ownAircraft = m_simulator->getOwnAircraft();
|
||||
@@ -72,11 +79,12 @@ namespace BlackCore
|
||||
QObject *plugin = loader.instance();
|
||||
if (plugin)
|
||||
{
|
||||
ISimulatorFactory *factory = qobject_cast<ISimulatorFactory*>(plugin);
|
||||
if(factory)
|
||||
ISimulatorFactory *factory = qobject_cast<ISimulatorFactory *>(plugin);
|
||||
if (factory)
|
||||
{
|
||||
m_simulator = factory->create(this);
|
||||
connect(m_simulator, SIGNAL(connectionChanged(bool)), this, SLOT(setConnectionStatus(bool)));
|
||||
qDebug() << "Simulator plugin:" << m_simulator->getSimulatorInfo().toQString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::getOwnAircraft()
|
||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorInfo()
|
||||
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override;
|
||||
|
||||
protected:
|
||||
//! \brief Constructor
|
||||
CContextSimulator(CRuntimeConfig::ContextMode, CRuntime *runtime);
|
||||
|
||||
@@ -16,7 +16,6 @@ using namespace BlackMisc::Geo;
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
// Constructor for DBus
|
||||
CContextSimulatorProxy::CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextSimulator(mode, runtime), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||
@@ -25,7 +24,6 @@ namespace BlackCore
|
||||
this->relaySignals(serviceName, connection);
|
||||
}
|
||||
|
||||
// Workaround for signals, not working without, but why?
|
||||
void CContextSimulatorProxy::relaySignals(const QString &/*serviceName*/, QDBusConnection &/*connection*/)
|
||||
{ }
|
||||
|
||||
@@ -39,4 +37,9 @@ namespace BlackCore
|
||||
return m_dBusInterface->callDBusRet<BlackMisc::Aviation::CAircraft>(QLatin1Literal("getOwnAircraft"));
|
||||
}
|
||||
|
||||
BlackSim::CSimulatorInfo CContextSimulatorProxy::getSimulatorInfo() const
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<BlackSim::CSimulatorInfo>(QLatin1Literal("getSimulatorInfo"));
|
||||
}
|
||||
|
||||
} // namespace BlackCore
|
||||
|
||||
@@ -40,6 +40,9 @@ namespace BlackCore
|
||||
|
||||
//! \copydoc IContextSimulator::getOwnAircraft()
|
||||
virtual BlackMisc::Aviation::CAircraft getOwnAircraft() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorInfo
|
||||
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override;
|
||||
};
|
||||
|
||||
} // namespace BlackCore
|
||||
|
||||
Reference in New Issue
Block a user