mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Ref T275, move simulator info into env. provider
This commit is contained in:
@@ -153,7 +153,7 @@ namespace BlackMisc
|
||||
|
||||
CSimulatorPluginInfo ISimulationEnvironmentProvider::getSimulatorPluginInfo() const
|
||||
{
|
||||
QReadLocker l(&m_lockModel);
|
||||
QReadLocker l(&m_lockSimInfo);
|
||||
return m_simulatorPluginInfo;
|
||||
}
|
||||
|
||||
@@ -207,9 +207,37 @@ namespace BlackMisc
|
||||
|
||||
void ISimulationEnvironmentProvider::setNewPluginInfo(const CSimulatorPluginInfo &info, const CAircraftModel &defaultModel)
|
||||
{
|
||||
QWriteLocker l(&m_lockModel);
|
||||
m_simulatorPluginInfo = info;
|
||||
m_defaultModel = defaultModel;
|
||||
{
|
||||
QWriteLocker l1(&m_lockSimInfo);
|
||||
m_simulatorPluginInfo = info;
|
||||
}
|
||||
this->setDefaultModel(defaultModel);
|
||||
}
|
||||
|
||||
void ISimulationEnvironmentProvider::setSimulatorDetails(const QString &name, const QString &details, const QString &version)
|
||||
{
|
||||
QWriteLocker l(&m_lockSimInfo);
|
||||
m_simulatorName = name;
|
||||
m_simulatorDetails = details;
|
||||
m_simulatorVersion = version;
|
||||
}
|
||||
|
||||
QString ISimulationEnvironmentProvider::getSimulatorName() const
|
||||
{
|
||||
QReadLocker l(&m_lockSimInfo);
|
||||
return m_simulatorName;
|
||||
}
|
||||
|
||||
QString ISimulationEnvironmentProvider::getSimulatorVersion() const
|
||||
{
|
||||
QReadLocker l(&m_lockSimInfo);
|
||||
return m_simulatorVersion;
|
||||
}
|
||||
|
||||
QString ISimulationEnvironmentProvider::getSimulatorDetails() const
|
||||
{
|
||||
QReadLocker l(&m_lockSimInfo);
|
||||
return m_simulatorDetails;
|
||||
}
|
||||
|
||||
void ISimulationEnvironmentProvider::setDefaultModel(const CAircraftModel &defaultModel)
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace BlackMisc
|
||||
namespace Simulation
|
||||
{
|
||||
//! Direct in memory access to elevation data
|
||||
//! \remark we are interested in elevations of airports
|
||||
//! \remark we are interested in elevations at airports mostly
|
||||
class BLACKMISC_EXPORT ISimulationEnvironmentProvider : public IProvider
|
||||
{
|
||||
public:
|
||||
@@ -101,6 +101,22 @@ namespace BlackMisc
|
||||
//! \threadsafe
|
||||
void setNewPluginInfo(const CSimulatorPluginInfo &info, const CAircraftModel &defaultModel);
|
||||
|
||||
//! Set version and simulator details from running simulator
|
||||
//! \threadsafe
|
||||
void setSimulatorDetails(const QString &name, const QString &details, const QString &version);
|
||||
|
||||
//! Simulator name as set from the running simulator
|
||||
//! \threadsafe
|
||||
QString getSimulatorName() const;
|
||||
|
||||
//! Simulator version as set from the running simulator
|
||||
//! \threadsafe
|
||||
QString getSimulatorVersion() const;
|
||||
|
||||
//! Simulator details as set from the running simulator
|
||||
//! \threadsafe
|
||||
QString getSimulatorDetails() const;
|
||||
|
||||
//! Default model
|
||||
//! \threadsafe
|
||||
void setDefaultModel(const CAircraftModel &defaultModel);
|
||||
@@ -145,16 +161,20 @@ namespace BlackMisc
|
||||
static PhysicalQuantities::CLength minRange(const PhysicalQuantities::CLength &range);
|
||||
|
||||
private:
|
||||
int m_maxElevations = 100; //!< How many elevations we keep
|
||||
CAircraftModel m_defaultModel; //!< default model
|
||||
CSimulatorPluginInfo m_simulatorPluginInfo; //!< info object
|
||||
QString m_simulatorName; //!< name of simulator
|
||||
QString m_simulatorDetails; //!< describes version etc.
|
||||
QString m_simulatorVersion; //!< Simulator version
|
||||
CAircraftModel m_defaultModel; //!< default model
|
||||
int m_maxElevations = 100; //!< How many elevations we keep
|
||||
Geo::CCoordinateGeodeticList m_elvCoordinates;
|
||||
QMap<Aviation::CCallsign, PhysicalQuantities::CLength> m_cgs; //! CGs
|
||||
mutable int m_elvFound = 0; //!< statistics only
|
||||
mutable int m_elvMissed = 0; //!< statistics only
|
||||
mutable QReadWriteLock m_lockElvCoordinates; //!< lock m_coordinates
|
||||
mutable QReadWriteLock m_lockCG; //!< lock CGs
|
||||
mutable QReadWriteLock m_lockModel; //!< lock models
|
||||
mutable QReadWriteLock m_lockCG; //!< lock CGs
|
||||
mutable QReadWriteLock m_lockModel; //!< lock models
|
||||
mutable QReadWriteLock m_lockSimInfo; //!< lock plugin info
|
||||
};
|
||||
|
||||
//! Class which can be directly used to access an \sa ISimulationEnvironmentProvider object
|
||||
|
||||
@@ -46,8 +46,8 @@ namespace BlackSimPlugin
|
||||
void CSimulatorFsCommon::initSimulatorInternals()
|
||||
{
|
||||
CSimulatorInternals s;
|
||||
s.setSimulatorName(m_simulatorName);
|
||||
s.setSimulatorVersion(m_simulatorVersion);
|
||||
s.setSimulatorName(this->getSimulatorName());
|
||||
s.setSimulatorVersion(this->getSimulatorVersion());
|
||||
s.setValue("fscommon/fsuipc", boolToOnOff(m_useFsuipc));
|
||||
if (m_fsuipc)
|
||||
{
|
||||
|
||||
@@ -76,9 +76,6 @@ namespace BlackSimPlugin
|
||||
//! Register help
|
||||
static void registerHelp();
|
||||
|
||||
QString m_simulatorName; //!< name of simulator
|
||||
QString m_simulatorDetails; //!< describes version etc.
|
||||
QString m_simulatorVersion; //!< Simulator version
|
||||
std::unique_ptr<CFsuipc> m_fsuipc; //!< FSUIPC
|
||||
bool m_useFsuipc = true; //!< use FSUIPC
|
||||
bool m_simPaused = false; //!< Simulator paused?
|
||||
|
||||
@@ -412,7 +412,7 @@ namespace BlackSimPlugin
|
||||
void CSimulatorFsxCommon::onSimStopped()
|
||||
{
|
||||
// stopping events in FSX: Load menu, weather and season
|
||||
CLogMessage(this).info("Simulator stopped: %1") << m_simulatorDetails;
|
||||
CLogMessage(this).info("Simulator stopped: %1") << this->getSimulatorDetails();
|
||||
const SimulatorStatus oldStatus = this->getSimulatorStatus();
|
||||
m_simSimulating = false;
|
||||
m_simulatingChangedTs = QDateTime::currentMSecsSinceEpoch();
|
||||
@@ -433,7 +433,7 @@ namespace BlackSimPlugin
|
||||
|
||||
void CSimulatorFsxCommon::onSimExit()
|
||||
{
|
||||
CLogMessage(this).info("Simulator exit: %1") << m_simulatorDetails;
|
||||
CLogMessage(this).info("Simulator exit: %1") << this->getSimulatorDetails();
|
||||
|
||||
// reset complete state, we are going down
|
||||
m_simulatingChangedTs = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
@@ -45,11 +45,13 @@ namespace BlackSimPlugin
|
||||
case SIMCONNECT_RECV_ID_OPEN:
|
||||
{
|
||||
SIMCONNECT_RECV_OPEN *event = (SIMCONNECT_RECV_OPEN *)pData;
|
||||
simulatorFsxP3D->m_simulatorVersion = QString("%1.%2.%3.%4").arg(event->dwApplicationVersionMajor).arg(event->dwApplicationVersionMinor).arg(event->dwApplicationBuildMajor).arg(event->dwApplicationBuildMinor);
|
||||
simulatorFsxP3D->m_simConnectVersion = QString("%1.%2.%3.%4").arg(event->dwSimConnectVersionMajor).arg(event->dwSimConnectVersionMinor).arg(event->dwSimConnectBuildMajor).arg(event->dwSimConnectBuildMinor);
|
||||
simulatorFsxP3D->m_simulatorName = CSimulatorFsxCommon::fsxCharToQString(event->szApplicationName);
|
||||
simulatorFsxP3D->m_simulatorDetails = QString("Name: '%1' Version: %2 SimConnect: %3").arg(simulatorFsxP3D->m_simulatorName, simulatorFsxP3D->m_simulatorVersion, simulatorFsxP3D->m_simConnectVersion);
|
||||
CLogMessage(static_cast<CSimulatorFsxCommon *>(nullptr)).info("Connected to %1: '%2'") << simulatorFsxP3D->getSimulatorPluginInfo().getIdentifier() << simulatorFsxP3D->m_simulatorDetails;
|
||||
const QString simConnectVersion = QString("%1.%2.%3.%4").arg(event->dwSimConnectVersionMajor).arg(event->dwSimConnectVersionMinor).arg(event->dwSimConnectBuildMajor).arg(event->dwSimConnectBuildMinor);
|
||||
const QString version = QString("%1.%2.%3.%4").arg(event->dwApplicationVersionMajor).arg(event->dwApplicationVersionMinor).arg(event->dwApplicationBuildMajor).arg(event->dwApplicationBuildMinor);
|
||||
const QString name = CSimulatorFsxCommon::fsxCharToQString(event->szApplicationName);
|
||||
const QString details = QString("Name: '%1' Version: %2 SimConnect: %3").arg(name, version, simConnectVersion);
|
||||
simulatorFsxP3D->setSimulatorDetails(name, details, version);
|
||||
simulatorFsxP3D->m_simConnectVersion = simConnectVersion;
|
||||
CLogMessage(static_cast<CSimulatorFsxCommon *>(nullptr)).info("Connected to %1: '%2'") << simulatorFsxP3D->getSimulatorPluginInfo().getIdentifier() << details;
|
||||
simulatorFsxP3D->setSimConnected();
|
||||
break; // SIMCONNECT_RECV_ID_OPEN
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user