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