mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 15:45:42 +08:00
refs #289, method bodys for time sync as preparation
simulator can send messages to contexts
This commit is contained in:
@@ -88,6 +88,10 @@ namespace BlackCore
|
||||
//! Aircraft model
|
||||
virtual BlackMisc::Network::CAircraftModel getOwnAircraftModel() const = 0;
|
||||
|
||||
//! Set time synchronization between simulator and user's computer time
|
||||
//! \remarks not all drivers implement this, e.g. if it is an intrinsic simulator feature
|
||||
virtual void setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime offset) = 0;
|
||||
|
||||
//! Load specific simulator plugin
|
||||
virtual bool loadSimulatorPlugin(const BlackSim::CSimulatorInfo &simulatorInfo) = 0;
|
||||
|
||||
|
||||
@@ -105,6 +105,11 @@ namespace BlackCore
|
||||
|
||||
return this->m_simulator->getAirportsInRange();
|
||||
}
|
||||
|
||||
void CContextSimulator::setTimeSynchronization(bool enable, CTime offset)
|
||||
{
|
||||
if (!m_simulator) return;
|
||||
this->setTimeSynchronization(enable, offset);
|
||||
}
|
||||
|
||||
bool CContextSimulator::loadSimulatorPlugin(const CSimulatorInfo &simulatorInfo)
|
||||
@@ -145,6 +150,16 @@ namespace BlackCore
|
||||
|
||||
connect(m_simulator, SIGNAL(statusChanged(ISimulator::Status)), this, SLOT(setConnectionStatus(ISimulator::Status)));
|
||||
connect(m_simulator, &ISimulator::aircraftModelChanged, this, &IContextSimulator::ownAircraftModelChanged);
|
||||
if (this->getIContextApplication() && this->getIContextApplication()->usingLocalObjects())
|
||||
{
|
||||
// relay status messages
|
||||
connect(m_simulator, &ISimulator::sendStatusMessage, this->getIContextApplication(), &IContextApplication::sendStatusMessage);
|
||||
connect(m_simulator, &ISimulator::sendStatusMessages, this->getIContextApplication(), &IContextApplication::sendStatusMessages);
|
||||
}
|
||||
else
|
||||
{
|
||||
qFatal("No application context ot application context not local");
|
||||
}
|
||||
asyncConnectTo(); // try to connect
|
||||
|
||||
QString m = QString("Simulator plugin loaded: '%1'").arg(this->m_simulator->getSimulatorInfo().toQString(true));
|
||||
|
||||
@@ -62,6 +62,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::getAirportsInRange()
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::setTimeSynchronization
|
||||
virtual void setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime offset) override;
|
||||
|
||||
//! \copydoc IContextSimulator::loadSimulatorPlugin()
|
||||
virtual bool loadSimulatorPlugin(const BlackSim::CSimulatorInfo &simulatorInfo) override;
|
||||
|
||||
|
||||
@@ -73,6 +73,11 @@ namespace BlackCore
|
||||
return m_dBusInterface->callDBusRet<BlackSim::CSimulatorInfo>(QLatin1Literal("getSimulatorInfo"));
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::setTimeSynchronization(bool enable, CTime offset)
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("setTimeSynchronization"), enable, offset);
|
||||
}
|
||||
|
||||
bool CContextSimulatorProxy::loadSimulatorPlugin(const BlackSim::CSimulatorInfo &simulatorInfo)
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("loadSimulatorPlugin"), simulatorInfo);
|
||||
|
||||
@@ -63,6 +63,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::getSimulatorInfo
|
||||
virtual BlackSim::CSimulatorInfo getSimulatorInfo() const override;
|
||||
|
||||
//! \copydoc IContextSimulator::setTimeSynchronization
|
||||
virtual void setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime offset) override;
|
||||
|
||||
//! \copydoc IContextSimulator::loadSimulatorPlugin
|
||||
virtual bool loadSimulatorPlugin(const BlackSim::CSimulatorInfo &simulatorInfo) override;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#define BLACKCORE_SIMULATOR_H
|
||||
|
||||
#include "blacksim/simulatorinfo.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/avaircraft.h"
|
||||
#include "blackmisc/avairportlist.h"
|
||||
#include "blackmisc/nwaircraftmodel.h"
|
||||
@@ -88,6 +88,9 @@ namespace BlackCore
|
||||
//! Airports in range
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const = 0;
|
||||
|
||||
//! Set time synchronization between simulator and user's computer time
|
||||
//! \remarks not all drivers implement this, e.g. if it is an intrinsic simulator feature
|
||||
virtual void setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime offset) = 0;
|
||||
|
||||
signals:
|
||||
//! Emitted when the connection status has changed
|
||||
@@ -101,6 +104,12 @@ namespace BlackCore
|
||||
|
||||
//! Simulator stopped;
|
||||
void simulatorStopped();
|
||||
|
||||
//! Send a message to be displayed (from simulator to contexts)
|
||||
void sendStatusMessage(const BlackMisc::CStatusMessage &message);
|
||||
|
||||
//! Send messages to be displayed (from simulator to contexts)
|
||||
void sendStatusMessages(const BlackMisc::CStatusMessageList &messages);
|
||||
};
|
||||
|
||||
//! Factory pattern class to create instances of ISimulator
|
||||
|
||||
@@ -286,6 +286,9 @@ namespace BlackSimPlugin
|
||||
|
||||
void CSimulatorFsx::setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime offset)
|
||||
{
|
||||
Q_UNUSED(enable);
|
||||
Q_UNUSED(offset);
|
||||
}
|
||||
|
||||
void CSimulatorFsx::onSimRunning()
|
||||
{
|
||||
|
||||
@@ -129,6 +129,8 @@ namespace BlackSimPlugin
|
||||
//! \copydoc ISimulator::getAirportsInRange
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
|
||||
//! \copydoc ISimulator::setTimeSynchronization
|
||||
virtual void setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime offset) override;
|
||||
|
||||
//! \brief Called when sim has started
|
||||
void onSimRunning();
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <QDBusServiceWatcher>
|
||||
#include <QTimer>
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
@@ -209,6 +211,15 @@ namespace BlackSimPlugin
|
||||
return airports;
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime offset)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
emit this->displayStatusMessage(CStatusMessage::getWarningMessage("Use time synchronization of XP itself", CStatusMessage::TypeSimulator));
|
||||
}
|
||||
Q_UNUSED(offset);
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::updateOwnSimulatorCockpit(const BlackMisc::Aviation::CAircraft &aircraft)
|
||||
{
|
||||
if (! isConnected()) { return false; }
|
||||
|
||||
@@ -77,6 +77,9 @@ namespace BlackSimPlugin
|
||||
//! Airports in range
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
|
||||
//! \copydoc ISimulator::setTimeSynchronization
|
||||
virtual void setTimeSynchronization(bool enable, BlackMisc::PhysicalQuantities::CTime offset) override;
|
||||
|
||||
private slots:
|
||||
void serviceRegistered(const QString &serviceName);
|
||||
void serviceUnregistered();
|
||||
|
||||
Reference in New Issue
Block a user