mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 05:45:35 +08:00
Ref T292, Ref T285 replaced model set loader in context
This commit is contained in:
@@ -51,6 +51,7 @@ using namespace BlackMisc::Simulation::XPlane;
|
|||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackMisc::Simulation::Settings;
|
using namespace BlackMisc::Simulation::Settings;
|
||||||
|
using namespace BlackMisc::Simulation::Data;
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
@@ -71,10 +72,7 @@ namespace BlackCore
|
|||||||
this->restoreSimulatorPlugins();
|
this->restoreSimulatorPlugins();
|
||||||
|
|
||||||
connect(&m_weatherManager, &CWeatherManager::weatherGridReceived, this, &CContextSimulator::weatherGridReceived);
|
connect(&m_weatherManager, &CWeatherManager::weatherGridReceived, this, &CContextSimulator::weatherGridReceived);
|
||||||
connect(&m_modelSetLoader, &CAircraftModelSetLoader::cacheChanged, this, &CContextSimulator::modelSetChanged);
|
connect(&CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance(), &CCentralMultiSimulatorModelSetCachesProvider::cacheChanged, this, &CContextSimulator::modelSetChanged);
|
||||||
|
|
||||||
// seems to be redundant, as changed simulator will cause changed cache
|
|
||||||
// connect(&m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CDigestSignal::modelSetChanged);
|
|
||||||
|
|
||||||
// deferred init of last model set, if no other data are set in meantime
|
// deferred init of last model set, if no other data are set in meantime
|
||||||
const QPointer<CContextSimulator> myself(this);
|
const QPointer<CContextSimulator> myself(this);
|
||||||
@@ -172,13 +170,14 @@ namespace BlackCore
|
|||||||
CAircraftModelList CContextSimulator::getModelSet() const
|
CAircraftModelList CContextSimulator::getModelSet() const
|
||||||
{
|
{
|
||||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||||
return m_aircraftMatcher.getModelSet();
|
const CSimulatorInfo simulator = m_modelSetSimulator.get();
|
||||||
|
return CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().getCachedModels(simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSimulatorInfo CContextSimulator::getModelSetLoaderSimulator() const
|
CSimulatorInfo CContextSimulator::getModelSetLoaderSimulator() const
|
||||||
{
|
{
|
||||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||||
return m_modelSetLoader.getSimulator();
|
return m_modelSetSimulator.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CContextSimulator::setModelSetLoaderSimulator(const CSimulatorInfo &simulator)
|
void CContextSimulator::setModelSetLoaderSimulator(const CSimulatorInfo &simulator)
|
||||||
@@ -186,14 +185,15 @@ namespace BlackCore
|
|||||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||||
if (this->isSimulatorAvailable()) { return; }
|
if (this->isSimulatorAvailable()) { return; }
|
||||||
m_modelSetLoader.setSimulator(simulator);
|
m_modelSetSimulator.set(simulator);
|
||||||
m_aircraftMatcher.setModelSet(m_modelSetLoader.getAircraftModels(), simulator);
|
const CAircraftModelList models = this->getModelSet();
|
||||||
|
m_aircraftMatcher.setModelSet(models, simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSimulatorInfo CContextSimulator::simulatorsWithInitializedModelSet() const
|
CSimulatorInfo CContextSimulator::simulatorsWithInitializedModelSet() const
|
||||||
{
|
{
|
||||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||||
return m_modelSetLoader.simulatorsWithInitializedModelSet();
|
return CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().simulatorsWithInitializedCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
CStatusMessageList CContextSimulator::verifyPrerequisites() const
|
CStatusMessageList CContextSimulator::verifyPrerequisites() const
|
||||||
@@ -368,8 +368,10 @@ namespace BlackCore
|
|||||||
// use simulator info from ISimulator as it can access the emulated driver settings
|
// use simulator info from ISimulator as it can access the emulated driver settings
|
||||||
const CSimulatorInfo simInfo = simulator->getSimulatorInfo();
|
const CSimulatorInfo simInfo = simulator->getSimulatorInfo();
|
||||||
Q_ASSERT_X(simInfo.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
Q_ASSERT_X(simInfo.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||||
m_modelSetLoader.setSimulator(simInfo);
|
|
||||||
m_aircraftMatcher.setModelSet(m_modelSetLoader.getAircraftModels(), simInfo);
|
m_modelSetSimulator.set(simInfo);
|
||||||
|
const CAircraftModelList modelSetModels = this->getModelSet();
|
||||||
|
m_aircraftMatcher.setModelSet(modelSetModels, simInfo);
|
||||||
m_aircraftMatcher.setDefaultModel(simulator->getDefaultModel());
|
m_aircraftMatcher.setDefaultModel(simulator->getDefaultModel());
|
||||||
|
|
||||||
bool c = connect(simulator, &ISimulator::simulatorStatusChanged, this, &CContextSimulator::onSimulatorStatusChanged);
|
bool c = connect(simulator, &ISimulator::simulatorStatusChanged, this, &CContextSimulator::onSimulatorStatusChanged);
|
||||||
@@ -713,10 +715,10 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
if (m_simulatorPlugin.first.isUnspecified()) { return CPixmap(); }
|
if (m_simulatorPlugin.first.isUnspecified()) { return CPixmap(); }
|
||||||
Q_ASSERT_X(m_simulatorPlugin.second, Q_FUNC_INFO, "Missing simulator");
|
Q_ASSERT_X(m_simulatorPlugin.second, Q_FUNC_INFO, "Missing simulator");
|
||||||
const CAircraftModel model(m_modelSetLoader.getModelForModelString(modelString));
|
|
||||||
|
|
||||||
// load from file
|
// load from file
|
||||||
CStatusMessage msg;
|
CStatusMessage msg;
|
||||||
|
const CAircraftModel model(this->getModelSet().findFirstByModelStringOrDefault(modelString));
|
||||||
const CPixmap pm(model.loadIcon(msg));
|
const CPixmap pm(model.loadIcon(msg));
|
||||||
if (!msg.isEmpty()) { CLogMessage::preformatted(msg);}
|
if (!msg.isEmpty()) { CLogMessage::preformatted(msg);}
|
||||||
return pm;
|
return pm;
|
||||||
@@ -874,18 +876,11 @@ namespace BlackCore
|
|||||||
void CContextSimulator::initByLastUsedModelSet()
|
void CContextSimulator::initByLastUsedModelSet()
|
||||||
{
|
{
|
||||||
// no models in matcher, but in cache, we can set them as default
|
// no models in matcher, but in cache, we can set them as default
|
||||||
const CSimulatorInfo sim(m_modelSetLoader.getSimulator());
|
const CSimulatorInfo simulator(m_modelSetSimulator.get());
|
||||||
if (!m_aircraftMatcher.hasModels() && m_modelSetLoader.getAircraftModelsCount() > 0)
|
CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().synchronizeCache(simulator);
|
||||||
{
|
const CAircraftModelList models(this->getModelSet());
|
||||||
const CAircraftModelList models(m_modelSetLoader.getAircraftModels());
|
CLogMessage(this).info("Init aircraft matcher with %1 models from set for '%2'") << models.size() << simulator.toQString();
|
||||||
CLogMessage(this).info("Init aircraft matcher with %1 models from set for '%2'") << models.size() << sim.toQString();
|
m_aircraftMatcher.setModelSet(models, simulator);
|
||||||
m_aircraftMatcher.setModelSet(models, sim);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CLogMessage(this).info("Start loading of model set for '%1'") << sim.toQString();
|
|
||||||
m_modelSetLoader.admitCache(); // when ready chache change signal
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -20,9 +20,9 @@
|
|||||||
#include "blackcore/blackcoreexport.h"
|
#include "blackcore/blackcoreexport.h"
|
||||||
#include "blackcore/weathermanager.h"
|
#include "blackcore/weathermanager.h"
|
||||||
#include "blackcore/network.h"
|
#include "blackcore/network.h"
|
||||||
|
#include "blackmisc/simulation/data/modelcaches.h"
|
||||||
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
||||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||||
#include "blackmisc/simulation/aircraftmodelsetloader.h"
|
|
||||||
#include "blackmisc/simulation/interpolationsetuplist.h"
|
#include "blackmisc/simulation/interpolationsetuplist.h"
|
||||||
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
||||||
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
||||||
@@ -34,7 +34,6 @@
|
|||||||
#include "blackmisc/identifier.h"
|
#include "blackmisc/identifier.h"
|
||||||
#include "blackmisc/pixmap.h"
|
#include "blackmisc/pixmap.h"
|
||||||
#include "blackmisc/settingscache.h"
|
#include "blackmisc/settingscache.h"
|
||||||
|
|
||||||
#include "blackmisc/worker.h"
|
#include "blackmisc/worker.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -243,17 +242,17 @@ namespace BlackCore
|
|||||||
BlackMisc::CRegularThread m_listenersThread; //!< waiting for plugin
|
BlackMisc::CRegularThread m_listenersThread; //!< waiting for plugin
|
||||||
CWeatherManager m_weatherManager { this };
|
CWeatherManager m_weatherManager { this };
|
||||||
CAircraftMatcher m_aircraftMatcher; //!< Model matcher
|
CAircraftMatcher m_aircraftMatcher; //!< Model matcher
|
||||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { this }; //!< load model set from caches
|
|
||||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::CStatusMessageList> m_matchingMessages;
|
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::CStatusMessageList> m_matchingMessages;
|
||||||
bool m_initallyAddAircrafts = false;
|
bool m_initallyAddAircrafts = false;
|
||||||
bool m_enableMatchingMessages = true;
|
bool m_enableMatchingMessages = true;
|
||||||
bool m_isWeatherActivated = false;
|
bool m_isWeatherActivated = false;
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
|
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelection> m_modelSetSimulator { this }; //!< current simulator (used with radio buttons)
|
||||||
BlackMisc::Simulation::Settings::CMultiSimulatorSettings m_simulatorSettings { this }; //!< for directories of XPlane
|
BlackMisc::Simulation::Settings::CMultiSimulatorSettings m_simulatorSettings { this }; //!< for directories of XPlane
|
||||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TSimulatorMessages> m_messageSettings { this }; //!< settings for messages
|
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TSimulatorMessages> m_messageSettings { this }; //!< settings for messages
|
||||||
BlackMisc::CSettingReadOnly<Application::TEnabledSimulators> m_enabledSimulators { this, &CContextSimulator::changeEnabledSimulators };
|
BlackMisc::CSettingReadOnly<Application::TEnabledSimulators> m_enabledSimulators { this, &CContextSimulator::changeEnabledSimulators };
|
||||||
QString m_networkSessionId; //! Network session of CServer::getServerSessionId, if not connected empty
|
QString m_networkSessionId; //!< Network session of CServer::getServerSessionId, if not connected empty
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user