mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
Ref T515, added background validation in simulator context
* added signals * added validator
This commit is contained in:
committed by
Mat Sutcliffe
parent
0bcd47b277
commit
cea6611656
@@ -94,7 +94,10 @@ namespace BlackCore
|
||||
//! Simulator plugin loaded / unloaded (default info)
|
||||
void simulatorPluginChanged(const BlackMisc::Simulation::CSimulatorPluginInfo &info);
|
||||
|
||||
//! A formerly vital driver is no loner vital
|
||||
//! Same as simulatorPluginChanged, only with simulator signature
|
||||
void simulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! A formerly vital driver is no longer vital/responding
|
||||
void vitalityLost();
|
||||
|
||||
//! Render restrictions have been changed
|
||||
@@ -133,6 +136,11 @@ namespace BlackCore
|
||||
//! Request a console message (whatever the console maybe)
|
||||
void requestUiConsoleMessage(const QString &driverMessage, bool clear);
|
||||
|
||||
//! Validate model set
|
||||
void validatedModelSet(const BlackMisc::Simulation::CSimulatorInfo &simulator,
|
||||
const BlackMisc::Simulation::CAircraftModelList &valid, const BlackMisc::Simulation::CAircraftModelList &invalid,
|
||||
bool stopped, const BlackMisc::CStatusMessageList &msgs);
|
||||
|
||||
public slots:
|
||||
//! Simulator info, currently loaded plugin
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const = 0;
|
||||
|
||||
@@ -90,6 +90,15 @@ namespace BlackCore
|
||||
this->enableMatchingMessages(true);
|
||||
}
|
||||
});
|
||||
|
||||
// Validation
|
||||
m_validator = new CBackgroundValidation(this);
|
||||
m_validator->setCurrentSimulator(this->getSimulatorPluginInfo().getSimulator());
|
||||
connect(this, &CContextSimulator::simulatorChanged, m_validator, &CBackgroundValidation::setCurrentSimulator);
|
||||
connect(m_validator, &CBackgroundValidation::validated, this, &CContextSimulator::validatedModelSet, Qt::QueuedConnection);
|
||||
|
||||
m_validator->start(QThread::LowestPriority);
|
||||
m_validator->startUpdating(60);
|
||||
}
|
||||
|
||||
CContextSimulator *CContextSimulator::registerWithDBus(CDBusServer *server)
|
||||
@@ -106,6 +115,11 @@ namespace BlackCore
|
||||
|
||||
void CContextSimulator::gracefulShutdown()
|
||||
{
|
||||
if (m_validator)
|
||||
{
|
||||
disconnect(m_validator);
|
||||
m_validator->abandonAndWait();
|
||||
}
|
||||
this->disconnect();
|
||||
this->unloadSimulatorPlugin();
|
||||
}
|
||||
@@ -343,8 +357,8 @@ namespace BlackCore
|
||||
|
||||
bool CContextSimulator::loadSimulatorPlugin(const CSimulatorPluginInfo &simulatorPluginInfo)
|
||||
{
|
||||
Q_ASSERT(getIContextApplication());
|
||||
Q_ASSERT(getIContextApplication()->isUsingImplementingObject());
|
||||
Q_ASSERT(this->getIContextApplication());
|
||||
Q_ASSERT(this->getIContextApplication()->isUsingImplementingObject());
|
||||
Q_ASSERT(!simulatorPluginInfo.isUnspecified());
|
||||
Q_ASSERT(CThreadUtils::isCurrentThreadApplicationThread()); // only run in main thread
|
||||
|
||||
@@ -437,7 +451,12 @@ namespace BlackCore
|
||||
QTimer::singleShot(0, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
emit this->simulatorPluginChanged(simulatorPluginInfo);
|
||||
if (m_simulatorPlugin.second)
|
||||
{
|
||||
// use the real driver as this will also work eith emulated driver
|
||||
emit this->simulatorPluginChanged(m_simulatorPlugin.second->getSimulatorPluginInfo());
|
||||
emit this->simulatorChanged(m_simulatorPlugin.second->getSimulatorInfo());
|
||||
}
|
||||
});
|
||||
|
||||
CLogMessage(this).info(u"Simulator plugin loaded: '%1' connected: %2")
|
||||
@@ -527,6 +546,7 @@ namespace BlackCore
|
||||
simulator->unload();
|
||||
simulator->deleteLater();
|
||||
emit this->simulatorPluginChanged(CSimulatorPluginInfo());
|
||||
emit this->simulatorChanged(CSimulatorInfo());
|
||||
}
|
||||
|
||||
if (m_wasSimulating) { emit this->vitalityLost(); }
|
||||
@@ -564,8 +584,8 @@ namespace BlackCore
|
||||
CSimulatedAircraft brokenAircraft(aircraftAfterModelApplied);
|
||||
brokenAircraft.setEnabled(false);
|
||||
brokenAircraft.setRendered(false);
|
||||
emit this->aircraftRenderingChanged(brokenAircraft);
|
||||
CMatchingUtils::addLogDetailsToList(pMatchingMessages, callsign, QStringLiteral("Cannot add remote aircraft, no model string: '%1'").arg(brokenAircraft.toQString()));
|
||||
emit this->aircraftRenderingChanged(brokenAircraft);
|
||||
return;
|
||||
}
|
||||
m_simulatorPlugin.second->logicallyAddRemoteAircraft(aircraftAfterModelApplied);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "blackmisc/simulation/settings/modelmatchersettings.h"
|
||||
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
||||
#include "blackmisc/simulation/settings/interpolationrenderingsetupsettings.h"
|
||||
#include "blackmisc/simulation/backgroundvalidation.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/interpolationsetuplist.h"
|
||||
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
||||
@@ -262,6 +263,7 @@ namespace BlackCore
|
||||
bool m_isWeatherActivated = false;
|
||||
|
||||
QString m_networkSessionId; //!< Network session of CServer::getServerSessionId, if not connected empty (for statistics, ..)
|
||||
BlackMisc::Simulation::CBackgroundValidation *m_validator = nullptr;
|
||||
|
||||
// settings
|
||||
BlackMisc::CSettingReadOnly<Application::TEnabledSimulators> m_enabledSimulators { this, &CContextSimulator::changeEnabledSimulators };
|
||||
|
||||
@@ -71,6 +71,9 @@ namespace BlackCore
|
||||
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||
"simulatorPluginChanged", this, SIGNAL(simulatorPluginChanged(BlackMisc::Simulation::CSimulatorPluginInfo)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||
"simulatorChanged", this, SIGNAL(simulatorChanged(BlackMisc::Simulation::CSimulatorInfo)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||
"vitalityLost", this, SIGNAL(vitalityLost()));
|
||||
Q_ASSERT(s);
|
||||
@@ -90,6 +93,9 @@ namespace BlackCore
|
||||
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||
"requestUiConsoleMessage", this, SIGNAL(requestUiConsoleMessage(QString, bool)));
|
||||
Q_ASSERT(s);
|
||||
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||
"validatedModelSet", this, SIGNAL(validatedModelSet(BlackMisc::Simulation::CSimulatorInfo, BlackMisc::Simulation::CAircraftModelList, BlackMisc::Simulation::CAircraftModelList, bool, BlackMisc::CStatusMessageList)));
|
||||
Q_ASSERT(s);
|
||||
Q_UNUSED(s);
|
||||
this->relayBaseClassSignals(serviceName, connection, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName());
|
||||
}
|
||||
@@ -323,5 +329,6 @@ namespace BlackCore
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<CStatusMessageList>(QLatin1String("copyFsxTerrainProbe"), simulator);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user