mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
refs #848, parse command line in simulator
* added default implementation * sims can override parseDetails for specific cmd lines * enable/disable FSUIPC in fscommon part * added useFsuipc(bool on)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
15020b2d5f
commit
c609c555b4
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "simulatorfscommon.h"
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
|
||||
@@ -52,6 +53,17 @@ namespace BlackSimPlugin
|
||||
this->m_simulatorInternals = s;
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::parseDetails(const CSimpleCommandParser &parser)
|
||||
{
|
||||
if (parser.matchesPart(1, "fsuipc") && parser.hasPart(2))
|
||||
{
|
||||
const bool on = parser.toBool(2);
|
||||
const bool s = useFsuipc(on);
|
||||
return s;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::disconnectFrom()
|
||||
{
|
||||
if (this->m_fsuipc) { this->m_fsuipc->disconnect(); }
|
||||
@@ -67,6 +79,21 @@ namespace BlackSimPlugin
|
||||
return !m_fsuipc.isNull() && m_fsuipc->isConnected();
|
||||
}
|
||||
|
||||
bool CSimulatorFsCommon::useFsuipc(bool on)
|
||||
{
|
||||
if (!m_fsuipc) { return false; } // no FSUIPC available
|
||||
m_useFsuipc = on;
|
||||
if (on)
|
||||
{
|
||||
m_useFsuipc = m_fsuipc->connect();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fsuipc->disconnect();
|
||||
}
|
||||
return m_useFsuipc;
|
||||
}
|
||||
|
||||
CTime CSimulatorFsCommon::getTimeSynchronizationOffset() const
|
||||
{
|
||||
return m_syncTimeOffset;
|
||||
|
||||
@@ -33,8 +33,10 @@ namespace BlackSimPlugin
|
||||
//! FSUIPC connected?
|
||||
bool isFsuipcConnected() const;
|
||||
|
||||
//! \name ISimulator interface implementations
|
||||
//! @{
|
||||
//! FSUIPC on/off, correctly disconnecting/connecting
|
||||
bool useFsuipc(bool on);
|
||||
|
||||
// ---------------------- ISimulator ------------------
|
||||
virtual bool disconnectFrom() override;
|
||||
virtual bool isPaused() const override { return m_simPaused; }
|
||||
virtual bool isTimeSynchronized() const override { return m_simTimeSynced; }
|
||||
@@ -43,7 +45,7 @@ namespace BlackSimPlugin
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
virtual bool changeRemoteAircraftModel(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) override;
|
||||
virtual bool changeRemoteAircraftEnabled(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) override;
|
||||
//! @}
|
||||
// ---------------------- ISimulator ------------------
|
||||
|
||||
protected slots:
|
||||
//! \copydoc BlackCore::CSimulatorCommon::ps_allSwiftDataRead
|
||||
@@ -60,6 +62,9 @@ namespace BlackSimPlugin
|
||||
//! Init the internals objects
|
||||
virtual void initInternalsObject();
|
||||
|
||||
//! \copydoc BlackCore::CSimulatorCommon::parseDetails
|
||||
virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser) override;
|
||||
|
||||
QString m_simulatorName; //!< name of simulator
|
||||
QString m_simulatorDetails; //!< describes version etc.
|
||||
QString m_simulatorVersion; //!< Simulator version
|
||||
|
||||
Reference in New Issue
Block a user