mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 02:35:33 +08:00
Initial "Auto" option
* Added ContextSimulator::listenForAllSimulators() * Added "auto" option in SettingsSimulatorComponent * Default plugin is UnspecifiedSim, which stands for "auto" option
This commit is contained in:
committed by
Roland Winklmeier
parent
a0033bee02
commit
5b4c2377b6
@@ -171,6 +171,9 @@ namespace BlackCore
|
||||
//! Listen for the specific simulator to start, load plugin automatically
|
||||
virtual void listenForSimulator(const BlackSim::CSimulatorInfo &simulatorInfo) = 0;
|
||||
|
||||
//! Listen for all available simulators
|
||||
virtual void listenForAllSimulators() = 0;
|
||||
|
||||
//! Listen for simulator as set in settings
|
||||
virtual void listenForSimulatorFromSettings() = 0;
|
||||
|
||||
|
||||
@@ -413,10 +413,22 @@ namespace BlackCore
|
||||
|
||||
}
|
||||
|
||||
void CContextSimulator::listenForAllSimulators()
|
||||
{
|
||||
auto plugins = getAvailableSimulatorPlugins();
|
||||
for (const auto &p: plugins)
|
||||
listenForSimulator(p);
|
||||
}
|
||||
|
||||
void CContextSimulator::listenForSimulatorFromSettings()
|
||||
{
|
||||
Q_ASSERT(this->getIContextSettings());
|
||||
listenForSimulator(getIContextSettings()->getSimulatorSettings().getSelectedPlugin());
|
||||
|
||||
auto plugin = getIContextSettings()->getSimulatorSettings().getSelectedPlugin();
|
||||
if (plugin.isUnspecified())
|
||||
listenForAllSimulators();
|
||||
else
|
||||
listenForSimulator(plugin);
|
||||
}
|
||||
|
||||
void CContextSimulator::unloadSimulatorPlugin()
|
||||
@@ -512,30 +524,31 @@ namespace BlackCore
|
||||
void CContextSimulator::settingsChanged(uint type)
|
||||
{
|
||||
Q_ASSERT(this->getIContextSettings());
|
||||
Q_ASSERT(this->m_simulator);
|
||||
if (!this->getIContextSettings()) return;
|
||||
|
||||
auto settingsType = static_cast<IContextSettings::SettingsType>(type);
|
||||
if (settingsType != IContextSettings::SettingsSimulator) return;
|
||||
if (settingsType != IContextSettings::SettingsSimulator)
|
||||
return;
|
||||
|
||||
// plugin
|
||||
CSettingsSimulator settingsSim = this->getIContextSettings()->getSimulatorSettings();
|
||||
CSimulatorInfo plugin = settingsSim.getSelectedPlugin();
|
||||
if (!this->getSimulatorInfo().isSameSimulator(plugin))
|
||||
{
|
||||
if (this->loadSimulatorPlugin(plugin))
|
||||
{
|
||||
CLogMessage(this).info("Plugin loaded: '%1'") << plugin.toQString(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).error("Cannot load driver: '%1'") << plugin.toQString(true);
|
||||
CSimulatorInfo plugin = getIContextSettings()->getSimulatorSettings().getSelectedPlugin();
|
||||
|
||||
// no simulator loaded yet, listen
|
||||
if (!m_simulator) {
|
||||
stopSimulatorListeners();
|
||||
if (plugin.isSameSimulator(CSimulatorInfo::UnspecifiedSim())) {
|
||||
listenForAllSimulators();
|
||||
} else {
|
||||
listenForSimulator(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
// time sync
|
||||
bool timeSync = settingsSim.isTimeSyncEnabled();
|
||||
CTime syncOffset = settingsSim.getSyncTimeOffset();
|
||||
this->m_simulator->setTimeSynchronization(timeSync, syncOffset);
|
||||
else
|
||||
{
|
||||
// time sync
|
||||
bool timeSync = settingsSim.isTimeSyncEnabled();
|
||||
CTime syncOffset = settingsSim.getSyncTimeOffset();
|
||||
m_simulator->setTimeSynchronization(timeSync, syncOffset);
|
||||
}
|
||||
}
|
||||
|
||||
CPixmap CContextSimulator::iconForModel(const QString &modelString) const
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace BlackCore
|
||||
|
||||
//! Lazy-loads the driver, instantiates the factory and returns it.
|
||||
//! \return nullptr if no corresponding driver was found or an error occured during loading it.
|
||||
//! \todo Consider moving to private scope.
|
||||
ISimulatorFactory* getSimulatorFactory(const BlackSim::CSimulatorInfo& simulator);
|
||||
|
||||
public slots:
|
||||
@@ -132,6 +133,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::listenForSimulator()
|
||||
virtual void listenForSimulator(const BlackSim::CSimulatorInfo &simulatorInfo) override;
|
||||
|
||||
//! \copydoc IContextSimulator::listenForAllSimulators()
|
||||
virtual void listenForAllSimulators() override;
|
||||
|
||||
//! \copydoc IContextSimulator::listenForSimulatorFromSettings()
|
||||
virtual void listenForSimulatorFromSettings() override;
|
||||
|
||||
|
||||
@@ -189,6 +189,11 @@ namespace BlackCore
|
||||
m_dBusInterface->callDBus(QLatin1Literal("listenForSimulator"), simulatorInfo);
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::listenForAllSimulators()
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("listenForAllSimulators"));
|
||||
}
|
||||
|
||||
void CContextSimulatorProxy::listenForSimulatorFromSettings()
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("listenForSimulatorFromSettings"));
|
||||
|
||||
@@ -131,6 +131,9 @@ namespace BlackCore
|
||||
//! \copydoc IContextSimulator::listenForSimulator()
|
||||
virtual void listenForSimulator(const BlackSim::CSimulatorInfo &simulatorInfo) override;
|
||||
|
||||
//! \copydoc IContextSimulator::listenForAllSimulators()
|
||||
virtual void listenForAllSimulators() override;
|
||||
|
||||
//! \copydoc IContextSimulator::listenForSimulatorFromSettings()
|
||||
virtual void listenForSimulatorFromSettings() override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user