mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 08:45:36 +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
@@ -144,6 +144,16 @@ namespace BlackCore
|
|||||||
//! Driver will be unloaded
|
//! Driver will be unloaded
|
||||||
virtual void unload() = 0;
|
virtual void unload() = 0;
|
||||||
|
|
||||||
|
//! \addtogroup commandline
|
||||||
|
//! @{
|
||||||
|
//! <pre>
|
||||||
|
//! .drv unload unload driver CSimulatorCommon
|
||||||
|
//! .drv fsuipc on|off enable/disable FSUIPC (if applicable) BlackSimPlugin::FsCommon::CSimulatorFsCommon
|
||||||
|
//! </pre>
|
||||||
|
//! @}
|
||||||
|
//! Parse command line
|
||||||
|
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) = 0;
|
||||||
|
|
||||||
//! Status to string
|
//! Status to string
|
||||||
static QString statusToString(int status);
|
static QString statusToString(int status);
|
||||||
|
|
||||||
|
|||||||
@@ -201,6 +201,12 @@ namespace BlackCore
|
|||||||
this->reverseLookupAndUpdateOwnAircraftModel(model);
|
this->reverseLookupAndUpdateOwnAircraftModel(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSimulatorCommon::parseDetails(const CSimpleCommandParser &parser)
|
||||||
|
{
|
||||||
|
Q_UNUSED(parser);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CSimulatorCommon::reverseLookupAndUpdateOwnAircraftModel(const BlackMisc::Simulation::CAircraftModel &model)
|
void CSimulatorCommon::reverseLookupAndUpdateOwnAircraftModel(const BlackMisc::Simulation::CAircraftModel &model)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Missing sApp");
|
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Missing sApp");
|
||||||
@@ -323,6 +329,25 @@ namespace BlackCore
|
|||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSimulatorCommon::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
|
||||||
|
{
|
||||||
|
if (this->isMyIdentifier(originator)) { return false; }
|
||||||
|
if (commandLine.isEmpty()) { return false; }
|
||||||
|
CSimpleCommandParser parser(
|
||||||
|
{
|
||||||
|
".plugin", ".drv", ".driver"
|
||||||
|
});
|
||||||
|
parser.parse(commandLine);
|
||||||
|
if (!parser.isKnownCommand()) { return false; }
|
||||||
|
|
||||||
|
if (parser.matchesPart(1, "unload"))
|
||||||
|
{
|
||||||
|
this->unload();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return this->parseDetails(parser);
|
||||||
|
}
|
||||||
|
|
||||||
void CSimulatorCommon::ps_oneSecondTimer()
|
void CSimulatorCommon::ps_oneSecondTimer()
|
||||||
{
|
{
|
||||||
blinkHighlightedAircraft();
|
blinkHighlightedAircraft();
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
|
class CSimpleCommandParser;
|
||||||
|
|
||||||
namespace Aviation
|
namespace Aviation
|
||||||
{
|
{
|
||||||
class CAircraftParts;
|
class CAircraftParts;
|
||||||
@@ -69,8 +71,7 @@ namespace BlackCore
|
|||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~CSimulatorCommon();
|
virtual ~CSimulatorCommon();
|
||||||
|
|
||||||
//! \name ISimulator implementations
|
// --------- ISimulator implementations ------------
|
||||||
//! @{
|
|
||||||
virtual BlackMisc::Simulation::CAircraftModel getDefaultModel() const override;
|
virtual BlackMisc::Simulation::CAircraftModel getDefaultModel() const override;
|
||||||
virtual void setInterpolationAndRenderingSetup(const BlackMisc::Simulation::CInterpolationAndRenderingSetup &setup) override;
|
virtual void setInterpolationAndRenderingSetup(const BlackMisc::Simulation::CInterpolationAndRenderingSetup &setup) override;
|
||||||
virtual BlackMisc::Simulation::CInterpolationAndRenderingSetup getInterpolationAndRenderingSetup() const override;
|
virtual BlackMisc::Simulation::CInterpolationAndRenderingSetup getInterpolationAndRenderingSetup() const override;
|
||||||
@@ -80,7 +81,8 @@ namespace BlackCore
|
|||||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||||
virtual void unload() override;
|
virtual void unload() override;
|
||||||
virtual int physicallyRemoveMultipleRemoteAircraft(const BlackMisc::Aviation::CCallsignSet &callsigns) override;
|
virtual int physicallyRemoveMultipleRemoteAircraft(const BlackMisc::Aviation::CCallsignSet &callsigns) override;
|
||||||
//! @}
|
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
|
||||||
|
// --------- ISimulator implementations ------------
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
//! \name Connected with remote aircraft provider signals
|
//! \name Connected with remote aircraft provider signals
|
||||||
@@ -154,6 +156,9 @@ namespace BlackCore
|
|||||||
//! Set own model
|
//! Set own model
|
||||||
void reverseLookupAndUpdateOwnAircraftModel(const QString &modelString);
|
void reverseLookupAndUpdateOwnAircraftModel(const QString &modelString);
|
||||||
|
|
||||||
|
//! Parse driver specific details for ISimulator::parseCommandLine
|
||||||
|
virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser);
|
||||||
|
|
||||||
BlackMisc::Simulation::IInterpolator *m_interpolator = nullptr; //!< interpolator instance
|
BlackMisc::Simulation::IInterpolator *m_interpolator = nullptr; //!< interpolator instance
|
||||||
bool m_pausedSimFreezesInterpolation = false; //!< paused simulator will also pause interpolation (so AI aircraft will hold)
|
bool m_pausedSimFreezesInterpolation = false; //!< paused simulator will also pause interpolation (so AI aircraft will hold)
|
||||||
BlackMisc::Simulation::CAircraftModel m_defaultModel; //!< default model
|
BlackMisc::Simulation::CAircraftModel m_defaultModel; //!< default model
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "simulatorfscommon.h"
|
#include "simulatorfscommon.h"
|
||||||
#include "blackcore/webdataservices.h"
|
#include "blackcore/webdataservices.h"
|
||||||
|
#include "blackmisc/simplecommandparser.h"
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
#include "blackmisc/stringutils.h"
|
#include "blackmisc/stringutils.h"
|
||||||
|
|
||||||
@@ -52,6 +53,17 @@ namespace BlackSimPlugin
|
|||||||
this->m_simulatorInternals = s;
|
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()
|
bool CSimulatorFsCommon::disconnectFrom()
|
||||||
{
|
{
|
||||||
if (this->m_fsuipc) { this->m_fsuipc->disconnect(); }
|
if (this->m_fsuipc) { this->m_fsuipc->disconnect(); }
|
||||||
@@ -67,6 +79,21 @@ namespace BlackSimPlugin
|
|||||||
return !m_fsuipc.isNull() && m_fsuipc->isConnected();
|
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
|
CTime CSimulatorFsCommon::getTimeSynchronizationOffset() const
|
||||||
{
|
{
|
||||||
return m_syncTimeOffset;
|
return m_syncTimeOffset;
|
||||||
|
|||||||
@@ -33,8 +33,10 @@ namespace BlackSimPlugin
|
|||||||
//! FSUIPC connected?
|
//! FSUIPC connected?
|
||||||
bool isFsuipcConnected() const;
|
bool isFsuipcConnected() const;
|
||||||
|
|
||||||
//! \name ISimulator interface implementations
|
//! FSUIPC on/off, correctly disconnecting/connecting
|
||||||
//! @{
|
bool useFsuipc(bool on);
|
||||||
|
|
||||||
|
// ---------------------- ISimulator ------------------
|
||||||
virtual bool disconnectFrom() override;
|
virtual bool disconnectFrom() override;
|
||||||
virtual bool isPaused() const override { return m_simPaused; }
|
virtual bool isPaused() const override { return m_simPaused; }
|
||||||
virtual bool isTimeSynchronized() const override { return m_simTimeSynced; }
|
virtual bool isTimeSynchronized() const override { return m_simTimeSynced; }
|
||||||
@@ -43,7 +45,7 @@ namespace BlackSimPlugin
|
|||||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||||
virtual bool changeRemoteAircraftModel(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) override;
|
virtual bool changeRemoteAircraftModel(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) override;
|
||||||
virtual bool changeRemoteAircraftEnabled(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) override;
|
virtual bool changeRemoteAircraftEnabled(const BlackMisc::Simulation::CSimulatedAircraft &aircraft) override;
|
||||||
//! @}
|
// ---------------------- ISimulator ------------------
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
//! \copydoc BlackCore::CSimulatorCommon::ps_allSwiftDataRead
|
//! \copydoc BlackCore::CSimulatorCommon::ps_allSwiftDataRead
|
||||||
@@ -60,6 +62,9 @@ namespace BlackSimPlugin
|
|||||||
//! Init the internals objects
|
//! Init the internals objects
|
||||||
virtual void initInternalsObject();
|
virtual void initInternalsObject();
|
||||||
|
|
||||||
|
//! \copydoc BlackCore::CSimulatorCommon::parseDetails
|
||||||
|
virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser) override;
|
||||||
|
|
||||||
QString m_simulatorName; //!< name of simulator
|
QString m_simulatorName; //!< name of simulator
|
||||||
QString m_simulatorDetails; //!< describes version etc.
|
QString m_simulatorDetails; //!< describes version etc.
|
||||||
QString m_simulatorVersion; //!< Simulator version
|
QString m_simulatorVersion; //!< Simulator version
|
||||||
|
|||||||
Reference in New Issue
Block a user