39 using namespace swift::config;
42 using namespace swift::misc::physical_quantities;
43 using namespace swift::misc::aviation;
44 using namespace swift::misc::network;
45 using namespace swift::misc::simulation;
46 using namespace swift::misc::simulation::xplane;
47 using namespace swift::misc::geo;
48 using namespace swift::misc::weather;
49 using namespace swift::misc::simulation;
50 using namespace swift::misc::simulation::settings;
51 using namespace swift::misc::simulation::data;
52 using namespace std::chrono_literals;
54 namespace swift::core::context
59 this->setObjectName(
"CContextSimulator");
62 Q_ASSERT_X(
sApp, Q_FUNC_INFO,
"Need sApp");
63 MatchingLog logMatchingMessages =
64 CBuildConfig::isLocalDeveloperDebugBuild() ? MatchingLogAll : MatchingLogSimplified;
65 m_logMatchingMessages = logMatchingMessages;
67 this->restoreSimulatorPlugins();
70 connect(&CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance(),
74 const QPointer<CContextSimulator> myself(
this);
76 if (!myself) {
return; }
77 this->initByLastUsedModelSet();
78 m_aircraftMatcher.
setSetup(m_matchingSettings.
get());
90 Qt::QueuedConnection);
92 m_validator->start(QThread::LowestPriority);
93 using namespace std::chrono_literals;
94 m_validator->startUpdating(60s);
121 disconnect(m_validator);
123 m_validator->deleteLater();
124 m_validator =
nullptr;
126 this->stopSimulatorListeners();
128 this->unloadSimulatorPlugin();
132 m_listenersThread.quit();
133 m_listenersThread.wait(10 * 1000);
138 if (!m_plugins) {
return {}; }
145 if (!p.
isValid()) {
return {}; }
153 if (!
simulator.isSingleSimulator()) {
return false; }
155 if (simSettings == settings) {
return false; }
164 return this->listenForSimulator(simulatorInfo);
169 if (!m_simulatorPlugin.first.isUnspecified() && m_simulatorPlugin.first == simulatorInfo)
171 this->unloadSimulatorPlugin();
182 if (!m_plugins) {
return 0; }
190 return m_simulatorPlugin.second->getSimulatorStatus();
197 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return unspecified; }
198 if (m_simulatorPlugin.first.getSimulator().contains(
"emulated", Qt::CaseInsensitive))
200 return m_simulatorPlugin.second->getSimulatorPluginInfo();
202 return m_simulatorPlugin.first;
208 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return CSimulatorInternals(); }
209 return m_simulatorPlugin.second->getSimulatorInternals();
218 CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().synchronizeCache(
simulator);
219 return CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().getCachedModels(
simulator);
225 if (m_simulatorPlugin.second)
227 if (m_simulatorPlugin.second->isConnected())
229 if (m_simulatorPlugin.second->isEmulatedDriver())
234 return m_simulatorPlugin.first.getSimulatorInfo();
237 return m_modelSetSimulator.
get();
242 Q_ASSERT_X(
simulator.isSingleSimulator(), Q_FUNC_INFO,
"Need single simulator");
253 return CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().simulatorsWithInitializedCache();
264 u
"No model set so far, you need at least one model set. Hint: You can create a model set in the "
265 u
"mapping tool, or copy an existing set in the launcher."));
286 if (removeModels.
isEmpty()) {
return 0; }
288 if (!
simulator.isSingleSimulator()) {
return 0; }
290 CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().synchronizeCache(
simulator);
292 CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().getCachedModels(
simulator);
296 CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().setCachedModels(models,
simulator);
310 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return 0; }
317 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return; }
324 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return CAircraftModelList(); }
331 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return; }
338 if (!m_validator) {
return false; }
345 if (!m_validator) {
return false; }
346 const QString simDir =
357 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return CAircraftModelList(); }
365 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return m_renderSettings.
get(); }
366 return m_simulatorPlugin.second->getInterpolationSetupGlobal();
372 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return CInterpolationSetupList(); }
373 return m_simulatorPlugin.second->getInterpolationSetupsPerCallsign();
380 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
384 return m_simulatorPlugin.second->getInterpolationSetupPerCallsignOrDefault(callsign);
388 bool ignoreSameAsGlobal)
391 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return false; }
392 return m_simulatorPlugin.second->setInterpolationSetupsPerCallsign(setups, ignoreSameAsGlobal);
404 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return; }
405 m_simulatorPlugin.second->setInterpolationSetupGlobal(setup);
412 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return CStatusMessageList(); }
413 return m_simulatorPlugin.second->getInterpolationMessages(callsign);
424 if (!m_simulatorPlugin.first.isUnspecified())
431 if (!simulatorPluginInfo.
isValid())
438 Q_ASSERT_X(factory, Q_FUNC_INFO,
"no factory");
443 "Need implementing object");
449 factory->create(simulatorPluginInfo, ownAircraftProvider, renderedAircraftProvider, clientProvider);
450 Q_ASSERT_X(
simulator, Q_FUNC_INFO,
"no simulator driver can be created");
458 SWIFT_VERIFY_X(
false, Q_FUNC_INFO,
"Invalid simulator from plugin");
463 u
"Emulated driver does NOT provide valid simulator, using default '%1', plugin: '%2'")
474 m_modelSetSimulator.
set(simInfo);
476 m_aircraftMatcher.
setModelSet(modelSetModels, simInfo,
true);
483 &CContextSimulator::onAddingRemoteAircraftFailed);
486 &CContextSimulator::onOwnSimulatorModelChanged);
515 &CContextSimulator::relayStatusMessageToSimulator);
518 &CContextSimulator::relayStatusMessageToSimulator);
523 m_initallyAddAircraft =
true;
524 m_wasSimulating =
false;
525 m_matchingMessages.clear();
526 m_failoverAddingCounts.clear();
529 const bool connected =
simulator->connectTo();
532 CLogMessage(
this).
error(u
"Simulator plugin connection to simulator '%1' failed")
538 m_simulatorPlugin.first = simulatorPluginInfo;
540 m_simulatorPlugin.second->setInterpolationSetupGlobal(m_renderSettings.
get());
543 QPointer<CContextSimulator> myself(
this);
546 if (m_simulatorPlugin.second)
548 CLogMessage(this).info(u
"Simulator plugin loaded: '%1' connected: %2")
549 << simulatorPluginInfo.toQString(true) << boolToYesNo(connected);
552 emit this->simulatorPluginChanged(m_simulatorPlugin.second->getSimulatorPluginInfo());
553 emit this->simulatorChanged(m_simulatorPlugin.second->getSimulatorInfo());
565 Q_ASSERT(m_simulatorPlugin.first.isUnspecified());
567 if (!m_listenersThread.isRunning())
569 m_listenersThread.setObjectName(
"CContextSimulator: Thread for listener " + simulatorInfo.
getIdentifier());
570 m_listenersThread.start(QThread::LowPriority);
574 if (!listener) {
return false; }
576 if (listener->thread() != &m_listenersThread)
578 Q_ASSERT_X(!listener->parent(), Q_FUNC_INFO,
"Objects with parent cannot be moved to thread");
581 &CContextSimulator::onSimulatorStarted, Qt::QueuedConnection);
587 listener->setProperty(
"isInitialized",
true);
588 listener->moveToThread(&m_listenersThread);
592 if (!listener->isRunning())
595 Q_ASSERT_X(s, Q_FUNC_INFO,
"cannot invoke method");
602 void CContextSimulator::listenForAllSimulators()
607 Q_ASSERT(!p.isUnspecified());
608 if (p.isValid()) { this->listenForSimulator(p); }
612 void CContextSimulator::unloadSimulatorPlugin()
614 if (!m_simulatorPlugin.first.isUnspecified())
616 ISimulator *
simulator = m_simulatorPlugin.second;
624 m_simulatorPlugin.second =
nullptr;
642 m_wasSimulating =
false;
646 void CContextSimulator::xCtxAddedRemoteAircraftReadyForModelMatching(
const CSimulatedAircraft &remoteAircraft)
652 if (callsign.
isEmpty()) {
return; }
657 MatchingLog whatToLog = m_logMatchingMessages;
659 CStatusMessageList *pMatchingMessages = m_logMatchingMessages > 0 ? &matchingMessages :
nullptr;
661 m_aircraftMatcher.
getClosestMatch(remoteAircraft, whatToLog, pMatchingMessages,
true);
662 Q_ASSERT_X(remoteAircraft.
getCallsign() == aircraftModel.
getCallsign(), Q_FUNC_INFO,
"Mismatching callsigns");
666 const CLength cgSim = m_simulatorPlugin.second->getSimulatorCGPerModelString(aircraftModel.
getModelString());
670 case CSimulatorSettings::CGFromSimulatorOnly: aircraftModel.
setCG(cgSim);
break;
671 case CSimulatorSettings::CGFromSimulatorFirst:
672 if (!cgSim.
isNull()) { aircraftModel.
setCG(cgSim); }
674 case CSimulatorSettings::CGFromDBFirst:
675 if (cgModel.
isNull()) { aircraftModel.
setCG(cgSim); }
682 m_simulatorPlugin.second->overriddenCGorDefault(CLength::null(), aircraftModel.
getModelString());
683 if (!overriddenCG.
isNull()) { aircraftModel.
setCG(overriddenCG); }
692 if (!aircraftAfterModelApplied.
hasCallsign()) {
return; }
703 brokenAircraft.setEnabled(
false);
704 brokenAircraft.setRendered(
false);
705 CCallsign::addLogDetailsToList(
706 pMatchingMessages, callsign,
707 QStringLiteral(
"Cannot add remote aircraft, no model string: '%1'").arg(brokenAircraft.toQString()));
713 m_simulatorPlugin.second->logicallyAddRemoteAircraft(aircraftAfterModelApplied);
714 CCallsign::addLogDetailsToList(
715 pMatchingMessages, callsign,
716 QStringLiteral(
"Logically added remote aircraft: %1").arg(aircraftAfterModelApplied.
toQString()));
718 this->clearMatchingMessages(callsign);
719 this->addMatchingMessages(callsign, matchingMessages);
725 void CContextSimulator::xCtxRemovedRemoteAircraft(
const CCallsign &callsign)
728 m_simulatorPlugin.second->logicallyRemoveRemoteAircraft(callsign);
729 m_failoverAddingCounts.remove(callsign);
732 void CContextSimulator::onSimulatorStatusChanged(ISimulator::SimulatorStatus status)
739 Q_ASSERT_X(networkContext, Q_FUNC_INFO,
"Need context");
740 Q_ASSERT_X(networkContext->isLocalObject(), Q_FUNC_INFO,
"Need local object");
746 SWIFT_VERIFY_X(!simulatedAircraft.getCallsign().isEmpty(), Q_FUNC_INFO,
"Need callsign");
747 this->xCtxAddedRemoteAircraftReadyForModelMatching(simulatedAircraft);
749 m_initallyAddAircraft =
false;
756 this->unloadSimulatorPlugin();
757 this->restoreSimulatorPlugins();
760 m_wasSimulating =
false;
773 for (
const auto &tm : textMessages)
776 m_simulatorPlugin.second->displayTextMessage(tm);
780 void CContextSimulator::xCtxChangedRemoteAircraftModel(
const CSimulatedAircraft &aircraft,
785 m_simulatorPlugin.second->changeRemoteAircraftModel(aircraft);
788 void CContextSimulator::xCtxChangedOwnAircraftModel(
const CAircraftModel &aircraftModel,
797 void CContextSimulator::xCtxChangedRemoteAircraftEnabled(
const CSimulatedAircraft &aircraft)
800 m_simulatorPlugin.second->changeRemoteAircraftEnabled(aircraft);
803 void CContextSimulator::xCtxNetworkConnectionStatusChanged(
const CConnectionStatus &from,
808 if (to.
isConnected() && this->getIContextNetwork())
811 if (m_simulatorPlugin.second)
813 m_simulatorPlugin.second->setFlightNetworkConnected(
true);
818 m_networkSessionId.clear();
820 m_matchingMessages.clear();
821 m_failoverAddingCounts.clear();
823 if (m_simulatorPlugin.second)
825 m_simulatorPlugin.second->removeAllRemoteAircraft();
826 m_simulatorPlugin.second->setFlightNetworkConnected(
false);
831 void CContextSimulator::onAddingRemoteAircraftFailed(
const CSimulatedAircraft &remoteAircraft,
bool disabled,
840 bool failover = requestFailover;
846 const int trial = m_failoverAddingCounts.value(cs, 0);
847 if (trial < MaxModelAddedFailoverTrials)
849 m_failoverAddingCounts[cs] = trial + 1;
855 CLogMessage(
this).
warning(u
"Model for '%1' failed adding, tried %2 time(s) to resolve, giving up")
863 void CContextSimulator::xCtxUpdateSimulatorCockpitFromContext(
const CSimulatedAircraft &ownAircraft,
870 m_simulatorPlugin.second->updateOwnSimulatorCockpit(ownAircraft, originator);
873 void CContextSimulator::xCtxUpdateSimulatorSelcalFromContext(
const CSelcal &selcal,
const CIdentifier &originator)
879 m_simulatorPlugin.second->updateOwnSimulatorSelcal(selcal, originator);
882 void CContextSimulator::xCtxNetworkRequestedNewAircraft(
const CCallsign &callsign,
const QString &aircraftIcao,
883 const QString &airlineIcao,
const QString &livery)
885 if (m_networkSessionId.isEmpty()) {
return; }
896 m_simulatorPlugin.second->displayStatusMessage(message);
900 void CContextSimulator::changeEnabledSimulators()
903 const QStringList enabledSimulators = m_enabledSimulators.getThreadLocal();
908 unloadSimulatorPlugin();
911 restoreSimulatorPlugins();
914 void CContextSimulator::restoreSimulatorPlugins()
916 if (!m_simulatorPlugin.first.isUnspecified()) {
return; }
918 this->stopSimulatorListeners();
919 const QStringList enabledSimulators = m_enabledSimulators.getThreadLocal();
930 return m_matchingMessages[callsign];
936 return m_logMatchingMessages;
945 if (m_logMatchingMessages == enabled) {
return; }
946 m_logMatchingMessages = enabled;
974 return m_aircraftMatcher.
getSetup();
979 if (!m_simulatorPlugin.second || !m_simulatorPlugin.second->isConnected()) {
return false; }
983 m_simulatorPlugin.second->setTestMode(
true);
984 added = m_simulatorPlugin.second->logicallyAddRemoteAircraft(aircraft);
988 m_simulatorPlugin.second->logicallyRemoveRemoteAircraft(aircraft.
getCallsign());
989 m_simulatorPlugin.second->setTestMode(
false);
997 if (!m_simulatorPlugin.second || !m_simulatorPlugin.second->isConnected()) {
return false; }
1000 return m_simulatorPlugin.second->testSendSituationAndParts(cs, s, parts);
1005 Q_UNUSED(originator)
1006 if (commandLine.isEmpty()) {
return false; }
1008 ".plugin",
".drv",
".driver",
1011 parser.
parse(commandLine);
1012 if (!parser.isKnownCommand()) {
return false; }
1013 if (parser.matchesCommand(
"ris"))
1016 const QString p1 = parser.part(1);
1017 if (!parser.hasPart(2)) {
return false; }
1021 else {
return false; }
1026 if (parser.matchesCommand(
"plugin") || parser.matchesCommand(
"drv") || parser.matchesCommand(
"driver"))
1028 if (!m_simulatorPlugin.second) {
return false; }
1029 return m_simulatorPlugin.second->parseCommandLine(commandLine, originator);
1037 return m_simulatorPlugin.second;
1043 if (!m_simulatorPlugin.second) {
return false; }
1044 return m_simulatorPlugin.second->followAircraft(callsign);
1050 if (!m_simulatorPlugin.second) {
return; }
1051 m_simulatorPlugin.second->recalculateAllAircraft();
1057 if (aircraft.
getCallsign() != callsign) {
return false; }
1060 m_simulatorPlugin.second->logicallyRemoveRemoteAircraft(callsign);
1062 QPointer<CContextSimulator> myself(
this);
1065 this->xCtxAddedRemoteAircraftReadyForModelMatching(aircraft);
1073 if (!m_simulatorPlugin.second || !m_simulatorPlugin.second->isConnected()) {
return false; }
1074 return m_simulatorPlugin.second->requestElevationBySituation(situation);
1085 if (!m_simulatorPlugin.second || !m_simulatorPlugin.second->isConnected()) {
return CElevationPlane::null(); }
1086 return m_simulatorPlugin.second->findClosestElevationWithinRange(reference, range);
1093 if (callsigns.
isEmpty()) {
return 0; }
1095 QPointer<CContextSimulator> myself(
this);
1100 this->doMatchingAgain(cs);
1104 return callsigns.
size();
1116 QPointer<CContextSimulator> myself(
this);
1123 resetAircraft.setEnabled(
true);
1124 this->xCtxAddedRemoteAircraftReadyForModelMatching(resetAircraft);
1131 this->stopSimulatorListeners();
1132 this->loadSimulatorPlugin(info);
1135 if (m_logMatchingMessages)
1137 const QPointer<CContextSimulator> myself(
this);
1139 if (!myself) {
return; }
1142 const MatchingLog log = CBuildConfig::isDebugBuild() ? MatchingLogAll : MatchingLogSimplified;
1143 this->enableMatchingMessages(log);
1149 void CContextSimulator::onOwnSimulatorModelChanged(
const CAircraftModel &model)
1152 if (!lookupModel.isLoadedFromDb()) { lookupModel = this->reverseLookupModel(model); }
1156 void CContextSimulator::stopSimulatorListeners()
1164 Q_ASSERT_X(s, Q_FUNC_INFO,
"Cannot invoke stop");
1172 if (callsign.
isEmpty()) {
return; }
1173 if (messages.
isEmpty()) {
return; }
1174 if (!m_logMatchingMessages) {
return; }
1175 if (m_matchingMessages.contains(callsign))
1180 else { m_matchingMessages.insert(callsign, messages); }
1183 void CContextSimulator::clearMatchingMessages(
const CCallsign &callsign)
1185 if (callsign.
isEmpty()) {
return; }
1186 m_matchingMessages.remove(callsign);
1191 bool modified =
false;
1193 CDatabaseUtils::consolidateOwnAircraftModelWithDbData(model,
false, &modified);
1194 return reverseModel;
1197 void CContextSimulator::initByLastUsedModelSet()
1201 CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().synchronizeCache(
simulator);
1203 CLogMessage(
this).
info(u
"Init aircraft matcher with %1 models from set for '%2'")
1204 << models.size() <<
simulator.toQString();
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
void setupChanged()
Setup changed.
void evaluateStatisticsEntry(const QString &sessionId, const swift::misc::aviation::CCallsign &callsign, const QString &aircraftIcao, const QString &airlineIcao, const QString &livery)
Evaluate if a statistics entry makes sense and add it.
void clearMatchingStatistics()
Clear the statistics.
void setDefaultModel(const swift::misc::simulation::CAircraftModel &defaultModel)
Set default model, can be set by driver specific for simulator.
swift::misc::simulation::CAircraftMatcherSetup getSetup() const
Get the setup.
void addingRemoteModelFailed(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft)
Adding a model failed.
virtual int getModelSetCount() const
Model set count.
int setModelSet(const swift::misc::simulation::CAircraftModelList &models, const swift::misc::simulation::CSimulatorInfo &simulator, bool forced)
Set the models we want to use.
const swift::misc::simulation::CMatchingStatistics & getCurrentStatistics() const
The current statistics.
swift::misc::simulation::CAircraftModelList getDisabledModelsForMatching() const
The disabled models for matching.
bool setSetup(const swift::misc::simulation::CAircraftMatcherSetup &setup)
Set the setup.
swift::misc::simulation::CAircraftModel getClosestMatch(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft, swift::misc::simulation::MatchingLog whatToLog, swift::misc::CStatusMessageList *log, bool useMatchingScript) const
Get the closest matching aircraft model from set. Result depends on setup.
void disableModelsForMatching(const swift::misc::simulation::CAircraftModelList &removedModels, bool incremental)
Remove a model for matching.
void restoreDisabledModels()
Restore the models removed with CAircraftMatcher::disableModelForMatching.
bool isShuttingDown() const
Is application shutting down?
ContextMode
How to handle a given context.
The class providing facades (the contexts) for all DBus relevant operations.
context::CContextNetwork * getCContextNetwork()
Context for network.
context::CContextOwnAircraft * getCContextOwnAircraft()
Context for own aircraft.
Manages plugins for the simulator context.
virtual void collectPlugins()
Looks for all available plugins.
swift::misc::simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const
Get all simulator driver plugins.
ISimulatorListener * createListener(const QString &pluginId)
Create simulator listener from the plugin In case one is existing already, it is returned instead....
int checkAvailableListeners()
Check if simulator is connected.
ISimulatorFactory * getFactory(const QString &pluginId)
Get simulator factory from the plugin.
ISimulatorListener * getListener(const QString &pluginId)
Get previously created simulator listener from the plugin Returns nullptr if listener is not yet crea...
void renderRestrictionsChanged(bool restricted, bool enabled, int maxAircraft, const swift::misc::physical_quantities::CLength &maxRenderedDistance)
Render restrictions have been changed.
void physicallyAddingRemoteModelFailed(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft, bool disabled, bool requestFailover, const swift::misc::CStatusMessage &message)
Adding the remote model failed.
void ownAircraftModelChanged(const swift::misc::simulation::CAircraftModel &model)
Emitted when own aircraft model has changed.
void simulatorStatusChanged(swift::core::ISimulator::SimulatorStatus status)
Simulator combined status.
void insufficientFrameRateDetected(bool fatal)
Frame rate has fallen too far below the threshold to maintain consistent sim rate.
void autoPublishDataWritten(const swift::misc::simulation::CSimulatorInfo &simulator)
Auto publish data written for simulator.
void airspaceSnapshotHandled()
An airspace snapshot was handled.
@ Disconnected
not connected, and hence not simulating/paused
@ Simulating
Is the simulator actually simulating?
@ Connected
Is the plugin connected to the simulator?
@ Unspecified
unspecied, needed as default value
void aircraftRenderingChanged(const swift::misc::simulation::CSimulatedAircraft &aircraft)
Aircraft rendering changed.
void driverMessages(const swift::misc::CStatusMessageList &messages)
Relevant simulator messages to be explicitly displayed.
void interpolationAndRenderingSetupChanged()
Interpolation or rendering setup changed.
Interface to a simulator listener.
void simulatorStarted(const swift::misc::simulation::CSimulatorPluginInfo &info)
Emitted when the listener discovers the simulator running.
void start()
Start listening for the simulator to start.
void stop()
Stops listening.
virtual bool followAircraft(const swift::misc::aviation::CCallsign &callsign)
Follow aircraft im simulator view.
virtual bool setSimulatorSettings(const swift::misc::simulation::settings::CSimulatorSettings &settings, const swift::misc::simulation::CSimulatorInfo &simulator)
Set settings for give simulator.
virtual swift::misc::CStatusMessageList verifyPrerequisites() const
Verify prerequisites for simulation like an existing model set.
virtual bool resetToModelMatchingAircraft(const swift::misc::aviation::CCallsign &callsign)
Reset model by matching it again.
virtual ISimulator::SimulatorStatus getSimulatorStatus() const
Simulator combined status.
virtual void setInterpolationAndRenderingSetupGlobal(const swift::misc::simulation::CInterpolationAndRenderingSetupGlobal &setup)
Set the global setup.
virtual swift::misc::simulation::CAircraftMatcherSetup getMatchingSetup() const
Get matching setup.
virtual swift::misc::simulation::CAircraftModelList getModelSet() const
Installed models in simulator eco system.
virtual bool isKnownModelInSet(const QString &modelString) const
Known model?
virtual swift::misc::simulation::CInterpolationSetupList getInterpolationAndRenderingSetupsPerCallsign() const
Get all setups per callsign.
virtual swift::misc::simulation::CAircraftModelList getModelSetModelsStartingWith(const QString &modelString) const
Models for model string.
virtual swift::misc::geo::CElevationPlane findClosestElevationWithinRange(const swift::misc::geo::CCoordinateGeodetic &reference, const swift::misc::physical_quantities::CLength &range) const
Find closest elevation (or return NULL)
virtual bool startSimulatorPlugin(const swift::misc::simulation::CSimulatorPluginInfo &simulatorInfo)
Load and start specific simulator plugin.
virtual void disableModelsForMatching(const swift::misc::simulation::CAircraftModelList &removedModels, bool incremental)
Remove a model for matching.
virtual swift::misc::simulation::CSimulatorInternals getSimulatorInternals() const
Simulator setup.
virtual swift::misc::CStatusMessageList getMatchingMessages(const swift::misc::aviation::CCallsign &callsign) const
Get mapping messages.
virtual QStringList getModelSetCompleterStrings(bool sorted) const
Model set completer string.
virtual bool triggerModelSetValidation(const swift::misc::simulation::CSimulatorInfo &simulator)
Trigger model set validation.
virtual int removeModelsFromSet(const swift::misc::simulation::CAircraftModelList &removeModels)
Remove models from set.
static void registerHelp()
Register dot commands.
virtual bool testUpdateRemoteAircraft(const swift::misc::aviation::CCallsign &cs, const swift::misc::aviation::CAircraftSituation &situation, const swift::misc::aviation::CAircraftParts &parts)
Test update remote aircraft.
virtual void setModelSetLoaderSimulator(const swift::misc::simulation::CSimulatorInfo &simulator)
Set the model set loader simulator directly.
virtual void recalculateAllAircraft()
Recalculate all aircraft.
virtual swift::misc::simulation::CInterpolationAndRenderingSetupGlobal getInterpolationAndRenderingSetupGlobal() const
The global setup.
virtual bool testRemoteAircraft(const swift::misc::simulation::CSimulatedAircraft &aircraft, bool add)
Test a remote aircraft.
virtual bool doMatchingAgain(const swift::misc::aviation::CCallsign &callsign)
Repeat the matching callsign.
virtual bool requestElevationBySituation(const swift::misc::aviation::CAircraftSituation &situation)
Request elevation, there is no guarantee the requested elevation will be available in the provider.
virtual void restoreDisabledModels()
Restore the models removed with CAircraftMatcher::disableModelForMatching.
virtual swift::misc::simulation::CSimulatorInfo getModelSetLoaderSimulator() const
Get the model set loader simulator directly.
virtual int doMatchingsAgain()
Repeat all matchings.
virtual swift::misc::simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const
Return list of available simulator plugins.
void gracefulShutdown()
Gracefully shut down, e.g. for plugin unloading.
virtual swift::misc::simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const
Simulator info, currently loaded plugin.
virtual swift::misc::simulation::CSimulatorInfo simulatorsWithInitializedModelSet() const
Simulators which have an initialized model set.
virtual swift::misc::CStatusMessageList getInterpolationMessages(const swift::misc::aviation::CCallsign &callsign) const
Interpolation messages.
virtual swift::misc::simulation::settings::CSimulatorSettings getSimulatorSettings() const
Get the current simulator settings.
virtual void setMatchingSetup(const swift::misc::simulation::CAircraftMatcherSetup &setup)
Set matching setup.
virtual int checkListeners()
Check all listeners enabled if simulator is connected.
virtual swift::misc::simulation::CMatchingStatistics getCurrentMatchingStatistics(bool missingOnly) const
Current matching statistics.
virtual bool isValidationInProgress() const
Validation in progress.
QPointer< ISimulator > simulator() const
Access to simulator (i.e. the plugin)
virtual swift::misc::simulation::CInterpolationAndRenderingSetupPerCallsign getInterpolationAndRenderingSetupPerCallsignOrDefault(const swift::misc::aviation::CCallsign &callsign) const
Get the setup for callsign, if not existing the global setup.
virtual int getModelSetCount() const
Number of installed models in simulator eco system.
virtual swift::misc::simulation::MatchingLog isMatchingMessagesEnabled() const
Enabled mapping logging?
virtual void stopSimulatorPlugin(const swift::misc::simulation::CSimulatorPluginInfo &simulatorInfo)
Stop listener or unload the given plugin (if currently loaded)
virtual bool setInterpolationAndRenderingSetupsPerCallsign(const swift::misc::simulation::CInterpolationSetupList &setups, bool ignoreSameAsGlobal)
Set all setups per callsign.
virtual QStringList getModelSetStrings() const
Model strings.
virtual void enableMatchingMessages(swift::misc::simulation::MatchingLog enabled)
Enable mapping logging.
bool isSimulatorPluginAvailable() const
Simulator plugin available?
virtual ~CContextSimulator()
Destructor.
virtual swift::misc::simulation::CAircraftModelList getDisabledModelsForMatching() const
The disabled models for matching.
void changedLogOrDebugSettings()
Log or debug values changed.
CCoreFacade * getRuntime()
Runtime.
bool isUsingImplementingObject() const
Using local implementing object?
IContextNetwork * getIContextNetwork()
Context for network.
bool isLocalObject() const
Local or remote object?
const IContextApplication * getIContextApplication() const
Context for application.
IContextOwnAircraft * getIContextOwnAircraft()
Context for own aircraft.
bool isDebugEnabled() const
Debug enabled?
virtual swift::misc::network::CServer getConnectedServer() const =0
Server which is connected, if not connected empty default object.
virtual swift::misc::simulation::CSimulatedAircraft getOwnAircraft() const =0
Get own aircraft.
void renderRestrictionsChanged(bool restricted, bool enabled, int maxAircraft, const swift::misc::physical_quantities::CLength &maxRenderedDistance)
Render restrictions have been changed.
void validatedModelSet(const swift::misc::simulation::CSimulatorInfo &simulator, const swift::misc::simulation::CAircraftModelList &valid, const swift::misc::simulation::CAircraftModelList &invalid, bool stopped, const swift::misc::CStatusMessageList &msgs)
Validated model set.
void addingRemoteModelFailed(const swift::misc::simulation::CSimulatedAircraft &aircraft, bool disabled, bool failover, const swift::misc::CStatusMessage &message)
Adding a remote aircraft failed.
static const QString & InterfaceName()
Service name.
void vitalityLost()
A formerly vital driver is no longer vital/responding.
bool isSimulatorAvailable() const
Simulator avialable (driver available)?
void interpolationAndRenderingSetupChanged()
Setup changed.
void autoPublishDataWritten(const swift::misc::simulation::CSimulatorInfo &simulator)
Auto publish data written for simulator.
void ownAircraftModelChanged(const swift::misc::simulation::CAircraftModel &model)
Emitted when own aircraft model changes.
void simulatorChanged(const swift::misc::simulation::CSimulatorInfo &simulator)
Same as simulatorPluginChanged, only with simulator signature.
void modelSetChanged(const swift::misc::simulation::CSimulatorInfo &simulator)
Model set ready or changed.
void simulatorPluginChanged(const swift::misc::simulation::CSimulatorPluginInfo &info)
Simulator plugin loaded / unloaded (default info)
void modelMatchingCompleted(const swift::misc::simulation::CSimulatedAircraft &aircraft)
A single model has been matched for given aircraft.
void matchingSetupChanged()
Matching setup changed.
void driverMessages(const swift::misc::CStatusMessageList &messages)
Relevant simulator messages to be explicitly displayed.
void simulatorStatusChanged(int status)
Simulator combined status.
void insufficientFrameRateDetected(bool fatal)
Frame rate has fallen too far below the threshold to maintain consistent sim rate.
void simulatorSettingsChanged()
Simulator settings have been changed.
void airspaceSnapshotHandled()
An airspace snapshot was handled.
void aircraftRenderingChanged(const swift::misc::simulation::CSimulatedAircraft &aircraft)
Aircraft rendering changed.
CStatusMessage setAndSave(const T &value, qint64 timestamp=0)
Write and save in the same step. Must be called from the thread in which the owner lives.
const T & getThreadLocal() const
Read the current value.
T get() const
Get a copy of the current value.
size_type size() const
Returns number of elements in the collection.
bool isEmpty() const
Synonym for empty.
void quitAndWait() noexcept final
Calls quit() and blocks until the thread is finished.
CStatusMessage set(const typename Trait::type &value, qint64 timestamp=0)
Write a new value. Must be called from the thread in which the owner lives.
Base class with a member CIdentifier to be inherited by a class which has an identity in the environm...
bool isMyIdentifier(const CIdentifier &otherIdentifier) const
My identifier?
const CIdentifier & identifier() const
Get identifier.
Value object encapsulating information identifying a component of a modular distributed swift process...
const QString & getName() const
Name.
static const QString & contextSlot()
Context slots.
static const QString & cmdLine()
Cmd.line parsing.
void localMessageLogged(const swift::misc::CStatusMessage &message)
Emitted when a message is logged in this process.
static CLogHandler * instance()
Return pointer to the CLogHandler singleton.
void remoteMessageLogged(const swift::misc::CStatusMessage &message)
Emitted when a log message is relayed from a different process.
Class for emitting a log message.
static void preformatted(const CStatusMessage &statusMessage)
Sends a verbatim, preformatted message to the log.
Derived & warning(const char16_t(&format)[N])
Set the severity to warning, providing a format string.
Derived & error(const char16_t(&format)[N])
Set the severity to error, providing a format string.
Derived & debug()
Set the severity to debug.
Derived & info(const char16_t(&format)[N])
Set the severity to info, providing a format string.
size_type size() const
Returns number of elements in the sequence.
void push_back(const T &value)
Appends an element at the end of the sequence.
bool isEmpty() const
Synonym for empty.
Utility methods for simple line parsing used with the command line.
void parse(const QString &commandLine)
Parse.
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
static bool thisIsMainThread()
Is the current thread the application thread?
Value object encapsulating information of aircraft's parts.
Value object encapsulating information of an aircraft's situation.
void setCallsign(const CCallsign &callsign)
Corresponding callsign.
Value object encapsulating information of a callsign.
const QString & asString() const
Get callsign (normalized)
bool isEmpty() const
Is empty?
Value object for a set of callsigns.
QString convertToQString(bool i18n=false) const
Cast as QString.
Plane of same elevation, can be a single point or larger area (e.g. airport)
QString toQString(bool i18n=false) const
Cast as QString.
Value object encapsulating information about a connection status.
bool isConnected() const
Query status.
bool isDisconnected() const
Query status.
QString getServerSessionId(bool onlyConnected) const
Identifying a session, if not connected empty.
Value object encapsulating a list of text messages.
Direct in memory access to client (network client) data.
Physical unit length (length)
bool isNull() const
Is quantity null?
bool doModelAddFailover() const
Failover if model cannot be loaded.
Aircraft model (used by another pilot, my models on disk)
const aviation::CCallsign & getCallsign() const
Corresponding callsign if applicable.
const QString & getModelString() const
Model key, either queried or loaded from simulator model.
const physical_quantities::CLength & getCG() const
Get center of gravity.
void setCG(const physical_quantities::CLength &cg)
Get center of gravity.
Value object encapsulating a list of aircraft models.
QStringList getModelStringList(bool sort=true) const
Model strings.
QStringList toCompleterStrings(bool sorted=true, const CSimulatorInfo &simulator={ CSimulatorInfo::All }) const
Completer strings.
CAircraftModelList findModelsStartingWith(const QString &modelString, Qt::CaseSensitivity sensitivity=Qt::CaseInsensitive) const
Find models starting with.
int removeModelsWithString(const CAircraftModelList &models, Qt::CaseSensitivity sensitivity)
Remove those models with given model strings.
bool containsModelString(const QString &modelString, Qt::CaseSensitivity sensitivity=Qt::CaseInsensitive) const
Contains model string?
Validate model files from the sets and check if the model still exists.
bool isValidating() const
Validation in progress.
void setCurrentSimulator(const CSimulatorInfo &simulator, const QString &simDirectory, const QStringList &modelDirList)
Corresponding simulator.
bool triggerValidation(const CSimulatorInfo &simulator, const QString &simDirectory)
Trigger a validation, returns false if "work in progress".
void validated(const CSimulatorInfo &simulator, const CAircraftModelList &validModels, const CAircraftModelList &invalidModels, bool stopped, const CStatusMessageList &msgs)
Validated for simulator.
bool setEnabledAircraftParts(bool enabled)
Set enabled aircraft parts.
void setSimulatorDebuggingMessages(bool debug)
Debugging messages for simulation.
Value object for interpolator and rendering.
Value object for interpolator and rendering per callsign.
Value object for matching statistics.
CMatchingStatistics findMissingOnly() const
Find entires denoting missing entries only.
aviation::CCallsignSet getAircraftInRangeCallsigns() const
Unique callsigns for aircraft in range.
bool isAircraftInRange(const aviation::CCallsign &callsign) const
Is aircraft in range?
void updateMarkAllAsNotRendered()
Mark all as not rendered.
CSimulatedAircraft getAircraftInRangeForCallsign(const aviation::CCallsign &callsign) const
Aircraft for callsign.
void setRemoteAircraftProvider(IRemoteAircraftProvider *remoteAircraftProvider)
Set remote aircraft provider.
bool updateAircraftModel(const aviation::CCallsign &callsign, const CAircraftModel &model, const CIdentifier &originator)
Change model.
Comprehensive information of an aircraft.
bool hasModelString() const
Has model string?
void setModel(const CAircraftModel &model)
Set model.
const simulation::CAircraftModel & getNetworkModel() const
Get network model.
bool hasCallsign() const
Callsign not empty, no further checks.
const aviation::CCallsign & getCallsign() const
Get callsign.
bool resetToNetworkModel()
Reset to the newtork model.
Value object encapsulating a list of aircraft.
Simple hardcoded info about the corresponding simulator.
bool isSingleSimulator() const
Single simulator selected.
bool isNoSimulator() const
No simulator?
static const CSimulatorInfo & p3d()
Const simulator info objects.
Simulator internals for flight simulators. Those are obtained from a running simulator and represent ...
Describing a simulator plugin.
const QString & getIdentifier() const
Identifier.
const CSimulatorInfo & getSimulatorInfo() const
Simulator info object.
bool isUnspecified() const
Unspecified simulator.
bool isValid() const
Check if the provided plugin metadata is valid. Simulator plugin (driver) has to meet the following r...
Value object encapsulating a list of SimulatorInfo objects.
Direct threadsafe in memory access to own aircraft.
Direct thread safe in memory access to remote aircraft.
CStatusMessage setSettings(const CSimulatorSettings &settings, const CSimulatorInfo &simulator)
Set settings per simulator.
QStringList getModelDirectoriesOrDefault(const CSimulatorInfo &simulator) const
Model directory or default model path per simulator.
CSimulatorSettings getSettings(const CSimulatorInfo &simulator) const
Settings per simulator.
QString getSimulatorDirectoryOrDefault(const CSimulatorInfo &simulator) const
Simulator directory or default model path per simulator.
Settings regarding message handling. Driver independent part, related to network.
bool relayThisTextMessage(const network::CTextMessage &msg, const CSimulatedAircraft &aircraft) const
Relay given text message.
bool relayThisStatusMessage(const CStatusMessage &message) const
Relay this particular message.
Settings for simulator Driver independent parts (such as directories), also used in model loaders.
CGSource getCGSource() const
CG source.
virtual bool parseCommandLine(const QString &commandLine, const swift::misc::CIdentifier &originator)
Parse a given command line.
Classes interacting with the swift database (aka "datastore").
Free functions in swift::misc.
SWIFT_MISC_EXPORT bool stringToBool(const QString &boolString)
Convert string to bool.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.