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
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(),
76 if (!myself) {
return; }
77 this->initByLastUsedModelSet();
78 m_aircraftMatcher.
setSetup(m_matchingSettings.
get());
93 using namespace std::chrono_literals;
94 m_validator->startUpdating(60s);
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; }
200 return m_simulatorPlugin.second->getSimulatorPluginInfo();
202 return m_simulatorPlugin.first;
208 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return {}; }
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 {}; }
331 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return; }
338 if (!m_validator) {
return false; }
345 if (!m_validator) {
return false; }
357 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return {}; }
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 {}; }
373 return m_simulatorPlugin.second->getInterpolationSetupsPerCallsign();
380 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return {}; }
381 return m_simulatorPlugin.second->getInterpolationSetupPerCallsignOrDefault(callsign);
385 bool ignoreSameAsGlobal)
388 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return false; }
389 return m_simulatorPlugin.second->setInterpolationSetupsPerCallsign(setups, ignoreSameAsGlobal);
401 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return; }
402 m_simulatorPlugin.second->setInterpolationSetupGlobal(setup);
408 if (callsign.
isEmpty()) {
return {}; }
409 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified()) {
return {}; }
410 return m_simulatorPlugin.second->getInterpolationMessages(callsign);
421 if (!m_simulatorPlugin.first.isUnspecified())
428 if (!simulatorPluginInfo.
isValid())
435 Q_ASSERT_X(factory, Q_FUNC_INFO,
"no factory");
440 "Need implementing object");
446 factory->create(simulatorPluginInfo, ownAircraftProvider, renderedAircraftProvider, clientProvider);
447 Q_ASSERT_X(
simulator, Q_FUNC_INFO,
"no simulator driver can be created");
455 SWIFT_VERIFY_X(
false, Q_FUNC_INFO,
"Invalid simulator from plugin");
460 u
"Emulated driver does NOT provide valid simulator, using default '%1', plugin: '%2'")
471 m_modelSetSimulator.
set(simInfo);
473 m_aircraftMatcher.
setModelSet(modelSetModels, simInfo,
true);
480 &CContextSimulator::onAddingRemoteAircraftFailed);
483 &CContextSimulator::onOwnSimulatorModelChanged);
512 &CContextSimulator::relayStatusMessageToSimulator);
515 &CContextSimulator::relayStatusMessageToSimulator);
520 m_initallyAddAircraft =
true;
521 m_wasSimulating =
false;
522 m_matchingMessages.
clear();
523 m_failoverAddingCounts.
clear();
526 const bool connected =
simulator->connectTo();
529 CLogMessage(
this).
error(u
"Simulator plugin connection to simulator '%1' failed")
535 m_simulatorPlugin.first = simulatorPluginInfo;
537 m_simulatorPlugin.second->setInterpolationSetupGlobal(m_renderSettings.
get());
543 if (m_simulatorPlugin.second)
545 CLogMessage(this).info(u
"Simulator plugin loaded: '%1' connected: %2")
546 << simulatorPluginInfo.toQString(true) << boolToYesNo(connected);
549 emit this->simulatorPluginChanged(m_simulatorPlugin.second->getSimulatorPluginInfo());
550 emit this->simulatorChanged(m_simulatorPlugin.second->getSimulatorInfo());
562 Q_ASSERT(m_simulatorPlugin.first.isUnspecified());
571 if (!listener) {
return false; }
573 if (listener->thread() != &m_listenersThread)
575 Q_ASSERT_X(!listener->parent(), Q_FUNC_INFO,
"Objects with parent cannot be moved to thread");
584 listener->setProperty(
"isInitialized",
true);
585 listener->moveToThread(&m_listenersThread);
589 if (!listener->isRunning())
592 Q_ASSERT_X(s, Q_FUNC_INFO,
"cannot invoke method");
599 void CContextSimulator::listenForAllSimulators()
604 Q_ASSERT(!p.isUnspecified());
605 if (p.isValid()) { this->listenForSimulator(p); }
609 void CContextSimulator::unloadSimulatorPlugin()
611 if (!m_simulatorPlugin.first.isUnspecified())
613 ISimulator *
simulator = m_simulatorPlugin.second;
621 m_simulatorPlugin.second =
nullptr;
639 m_wasSimulating =
false;
643 void CContextSimulator::xCtxAddedRemoteAircraftReadyForModelMatching(
const CSimulatedAircraft &remoteAircraft)
649 if (callsign.
isEmpty()) {
return; }
654 MatchingLog whatToLog = m_logMatchingMessages;
656 CStatusMessageList *pMatchingMessages = m_logMatchingMessages > 0 ? &matchingMessages :
nullptr;
658 m_aircraftMatcher.
getClosestMatch(remoteAircraft, whatToLog, pMatchingMessages,
true);
659 Q_ASSERT_X(remoteAircraft.
getCallsign() == aircraftModel.
getCallsign(), Q_FUNC_INFO,
"Mismatching callsigns");
663 const CLength cgSim = m_simulatorPlugin.second->getSimulatorCGPerModelString(aircraftModel.
getModelString());
667 case CSimulatorSettings::CGFromSimulatorOnly: aircraftModel.
setCG(cgSim);
break;
668 case CSimulatorSettings::CGFromSimulatorFirst:
669 if (!cgSim.
isNull()) { aircraftModel.
setCG(cgSim); }
671 case CSimulatorSettings::CGFromDBFirst:
672 if (cgModel.
isNull()) { aircraftModel.
setCG(cgSim); }
679 m_simulatorPlugin.second->overriddenCGorDefault(CLength::null(), aircraftModel.
getModelString());
680 if (!overriddenCG.
isNull()) { aircraftModel.
setCG(overriddenCG); }
689 if (!aircraftAfterModelApplied.
hasCallsign()) {
return; }
700 brokenAircraft.setEnabled(
false);
701 brokenAircraft.setRendered(
false);
702 CCallsign::addLogDetailsToList(
703 pMatchingMessages, callsign,
704 QStringLiteral(
"Cannot add remote aircraft, no model string: '%1'").arg(brokenAircraft.toQString()));
710 m_simulatorPlugin.second->logicallyAddRemoteAircraft(aircraftAfterModelApplied);
711 CCallsign::addLogDetailsToList(
712 pMatchingMessages, callsign,
713 QStringLiteral(
"Logically added remote aircraft: %1").arg(aircraftAfterModelApplied.
toQString()));
715 this->clearMatchingMessages(callsign);
716 this->addMatchingMessages(callsign, matchingMessages);
722 void CContextSimulator::xCtxRemovedRemoteAircraft(
const CCallsign &callsign)
725 m_simulatorPlugin.second->logicallyRemoveRemoteAircraft(callsign);
726 m_failoverAddingCounts.
remove(callsign);
729 void CContextSimulator::onSimulatorStatusChanged(ISimulator::SimulatorStatus status)
736 Q_ASSERT_X(networkContext, Q_FUNC_INFO,
"Need context");
737 Q_ASSERT_X(networkContext->isLocalObject(), Q_FUNC_INFO,
"Need local object");
743 SWIFT_VERIFY_X(!simulatedAircraft.getCallsign().isEmpty(), Q_FUNC_INFO,
"Need callsign");
744 this->xCtxAddedRemoteAircraftReadyForModelMatching(simulatedAircraft);
746 m_initallyAddAircraft =
false;
753 this->unloadSimulatorPlugin();
754 this->restoreSimulatorPlugins();
757 m_wasSimulating =
false;
770 for (
const auto &tm : textMessages)
773 m_simulatorPlugin.second->displayTextMessage(tm);
777 void CContextSimulator::xCtxChangedRemoteAircraftModel(
const CSimulatedAircraft &aircraft,
782 m_simulatorPlugin.second->changeRemoteAircraftModel(aircraft);
785 void CContextSimulator::xCtxChangedOwnAircraftModel(
const CAircraftModel &aircraftModel,
794 void CContextSimulator::xCtxChangedRemoteAircraftEnabled(
const CSimulatedAircraft &aircraft)
797 m_simulatorPlugin.second->changeRemoteAircraftEnabled(aircraft);
800 void CContextSimulator::xCtxNetworkConnectionStatusChanged(
const CConnectionStatus &from,
806 if (to.
isConnected() && this->getIContextNetwork())
809 if (m_simulatorPlugin.second)
811 m_simulatorPlugin.second->setFlightNetworkConnected(
true);
812 m_simulatorPlugin.second->setOwnCallsign(
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);
827 m_simulatorPlugin.second->setOwnCallsign({});
832 void CContextSimulator::onAddingRemoteAircraftFailed(
const CSimulatedAircraft &remoteAircraft,
bool disabled,
841 bool failover = requestFailover;
847 const int trial = m_failoverAddingCounts.
value(cs, 0);
848 if (trial < MaxModelAddedFailoverTrials)
850 m_failoverAddingCounts[cs] = trial + 1;
856 CLogMessage(
this).
warning(u
"Model for '%1' failed adding, tried %2 time(s) to resolve, giving up")
864 void CContextSimulator::xCtxUpdateSimulatorCockpitFromContext(
const CSimulatedAircraft &ownAircraft,
871 m_simulatorPlugin.second->updateOwnSimulatorCockpit(ownAircraft, originator);
874 void CContextSimulator::xCtxUpdateSimulatorSelcalFromContext(
const CSelcal &selcal,
const CIdentifier &originator)
880 m_simulatorPlugin.second->updateOwnSimulatorSelcal(selcal, originator);
883 void CContextSimulator::xCtxNetworkRequestedNewAircraft(
const CCallsign &callsign,
const QString &aircraftIcao,
886 if (m_networkSessionId.
isEmpty()) {
return; }
897 m_simulatorPlugin.second->displayStatusMessage(message);
901 void CContextSimulator::changeEnabledSimulators()
904 const QStringList enabledSimulators = m_enabledSimulators.getThreadLocal();
909 unloadSimulatorPlugin();
912 restoreSimulatorPlugins();
915 void CContextSimulator::restoreSimulatorPlugins()
917 if (!m_simulatorPlugin.first.isUnspecified()) {
return; }
919 this->stopSimulatorListeners();
920 const QStringList enabledSimulators = m_enabledSimulators.getThreadLocal();
931 return m_matchingMessages[callsign];
937 return m_logMatchingMessages;
946 if (m_logMatchingMessages == enabled) {
return; }
947 m_logMatchingMessages = enabled;
975 return m_aircraftMatcher.
getSetup();
980 if (!m_simulatorPlugin.second || !m_simulatorPlugin.second->isConnected()) {
return false; }
984 m_simulatorPlugin.second->setTestMode(
true);
985 added = m_simulatorPlugin.second->logicallyAddRemoteAircraft(aircraft);
989 m_simulatorPlugin.second->logicallyRemoveRemoteAircraft(aircraft.
getCallsign());
990 m_simulatorPlugin.second->setTestMode(
false);
998 if (!m_simulatorPlugin.second || !m_simulatorPlugin.second->isConnected()) {
return false; }
1001 return m_simulatorPlugin.second->testSendSituationAndParts(cs, s, parts);
1006 Q_UNUSED(originator)
1007 if (commandLine.
isEmpty()) {
return false; }
1009 ".plugin",
".drv",
".driver",
1012 parser.
parse(commandLine);
1013 if (!parser.isKnownCommand()) {
return false; }
1014 if (parser.matchesCommand(
"ris"))
1017 const QString p1 = parser.part(1);
1018 if (!parser.hasPart(2)) {
return false; }
1022 else {
return false; }
1027 if (parser.matchesCommand(
"plugin") || parser.matchesCommand(
"drv") || parser.matchesCommand(
"driver"))
1029 if (!m_simulatorPlugin.second) {
return false; }
1030 return m_simulatorPlugin.second->parseCommandLine(commandLine, originator);
1038 return m_simulatorPlugin.second;
1044 if (!m_simulatorPlugin.second) {
return false; }
1045 return m_simulatorPlugin.second->followAircraft(callsign);
1051 if (!m_simulatorPlugin.second) {
return; }
1052 m_simulatorPlugin.second->recalculateAllAircraft();
1058 if (aircraft.
getCallsign() != callsign) {
return false; }
1061 m_simulatorPlugin.second->logicallyRemoveRemoteAircraft(callsign);
1066 this->xCtxAddedRemoteAircraftReadyForModelMatching(aircraft);
1074 if (!m_simulatorPlugin.second || !m_simulatorPlugin.second->isConnected()) {
return false; }
1075 return m_simulatorPlugin.second->requestElevationBySituation(situation);
1086 if (!m_simulatorPlugin.second || !m_simulatorPlugin.second->isConnected()) {
return CElevationPlane::null(); }
1087 return m_simulatorPlugin.second->findClosestElevationWithinRange(reference, range);
1094 if (callsigns.
isEmpty()) {
return 0; }
1101 this->doMatchingAgain(cs);
1105 return callsigns.
size();
1124 resetAircraft.setEnabled(
true);
1125 this->xCtxAddedRemoteAircraftReadyForModelMatching(resetAircraft);
1132 this->stopSimulatorListeners();
1133 this->loadSimulatorPlugin(info);
1136 if (m_logMatchingMessages)
1140 if (!myself) {
return; }
1143 const MatchingLog log = CBuildConfig::isDebugBuild() ? MatchingLogAll : MatchingLogSimplified;
1144 this->enableMatchingMessages(log);
1150 void CContextSimulator::onOwnSimulatorModelChanged(
const CAircraftModel &model)
1153 if (!lookupModel.isLoadedFromDb()) { lookupModel = this->reverseLookupModel(model); }
1157 void CContextSimulator::stopSimulatorListeners()
1165 Q_ASSERT_X(s, Q_FUNC_INFO,
"Cannot invoke stop");
1173 if (callsign.
isEmpty()) {
return; }
1174 if (messages.
isEmpty()) {
return; }
1175 if (!m_logMatchingMessages) {
return; }
1176 if (m_matchingMessages.
contains(callsign))
1181 else { m_matchingMessages.
insert(callsign, messages); }
1184 void CContextSimulator::clearMatchingMessages(
const CCallsign &callsign)
1186 if (callsign.
isEmpty()) {
return; }
1187 m_matchingMessages.
remove(callsign);
1192 bool modified =
false;
1194 CDatabaseUtils::consolidateOwnAircraftModelWithDbData(model,
false, &modified);
1195 return reverseModel;
1198 void CContextSimulator::initByLastUsedModelSet()
1202 CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().synchronizeCache(
simulator);
1204 CLogMessage(
this).
info(u
"Init aircraft matcher with %1 models from set for '%2'")
1205 << 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.
int getModelSetCount() const
Model set count.
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.
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.
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.
bool followAircraft(const swift::misc::aviation::CCallsign &callsign)
Follow aircraft im simulator view.
bool setSimulatorSettings(const swift::misc::simulation::settings::CSimulatorSettings &settings, const swift::misc::simulation::CSimulatorInfo &simulator)
Set settings for give simulator.
swift::misc::CStatusMessageList verifyPrerequisites() const
Verify prerequisites for simulation like an existing model set.
bool resetToModelMatchingAircraft(const swift::misc::aviation::CCallsign &callsign)
Reset model by matching it again.
ISimulator::SimulatorStatus getSimulatorStatus() const
Simulator combined status.
void setInterpolationAndRenderingSetupGlobal(const swift::misc::simulation::CInterpolationAndRenderingSetupGlobal &setup)
Set the global setup.
swift::misc::simulation::CAircraftMatcherSetup getMatchingSetup() const
Get matching setup.
swift::misc::simulation::CAircraftModelList getModelSet() const
Installed models in simulator eco system.
bool isKnownModelInSet(const QString &modelString) const
Known model?
swift::misc::simulation::CInterpolationSetupList getInterpolationAndRenderingSetupsPerCallsign() const
Get all setups per callsign.
swift::misc::simulation::CAircraftModelList getModelSetModelsStartingWith(const QString &modelString) const
Models for model string.
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)
bool startSimulatorPlugin(const swift::misc::simulation::CSimulatorPluginInfo &simulatorInfo)
Load and start specific simulator plugin.
void disableModelsForMatching(const swift::misc::simulation::CAircraftModelList &removedModels, bool incremental)
Remove a model for matching.
swift::misc::simulation::CSimulatorInternals getSimulatorInternals() const
Simulator setup.
swift::misc::CStatusMessageList getMatchingMessages(const swift::misc::aviation::CCallsign &callsign) const
Get mapping messages.
QStringList getModelSetCompleterStrings(bool sorted) const
Model set completer string.
bool triggerModelSetValidation(const swift::misc::simulation::CSimulatorInfo &simulator)
Trigger model set validation.
int removeModelsFromSet(const swift::misc::simulation::CAircraftModelList &removeModels)
Remove models from set.
static void registerHelp()
Register dot commands.
bool testUpdateRemoteAircraft(const swift::misc::aviation::CCallsign &cs, const swift::misc::aviation::CAircraftSituation &situation, const swift::misc::aviation::CAircraftParts &parts)
Test update remote aircraft.
void setModelSetLoaderSimulator(const swift::misc::simulation::CSimulatorInfo &simulator)
Set the model set loader simulator directly.
void recalculateAllAircraft()
Recalculate all aircraft.
swift::misc::simulation::CInterpolationAndRenderingSetupGlobal getInterpolationAndRenderingSetupGlobal() const
The global setup.
bool testRemoteAircraft(const swift::misc::simulation::CSimulatedAircraft &aircraft, bool add)
Test a remote aircraft.
bool doMatchingAgain(const swift::misc::aviation::CCallsign &callsign)
Repeat the matching callsign.
bool requestElevationBySituation(const swift::misc::aviation::CAircraftSituation &situation)
Request elevation, there is no guarantee the requested elevation will be available in the provider.
void restoreDisabledModels()
Restore the models removed with CAircraftMatcher::disableModelForMatching.
swift::misc::simulation::CSimulatorInfo getModelSetLoaderSimulator() const
Get the model set loader simulator directly.
int doMatchingsAgain()
Repeat all matchings.
swift::misc::simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const
Return list of available simulator plugins.
void gracefulShutdown()
Gracefully shut down, e.g. for plugin unloading.
swift::misc::simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const
Simulator info, currently loaded plugin.
swift::misc::simulation::CSimulatorInfo simulatorsWithInitializedModelSet() const
Simulators which have an initialized model set.
swift::misc::CStatusMessageList getInterpolationMessages(const swift::misc::aviation::CCallsign &callsign) const
Interpolation messages.
swift::misc::simulation::settings::CSimulatorSettings getSimulatorSettings() const
Get the current simulator settings.
void setMatchingSetup(const swift::misc::simulation::CAircraftMatcherSetup &setup)
Set matching setup.
int checkListeners()
Check all listeners enabled if simulator is connected.
swift::misc::simulation::CMatchingStatistics getCurrentMatchingStatistics(bool missingOnly) const
Current matching statistics.
bool isValidationInProgress() const
Validation in progress.
QPointer< ISimulator > simulator() const
Access to simulator (i.e. the plugin)
swift::misc::simulation::CInterpolationAndRenderingSetupPerCallsign getInterpolationAndRenderingSetupPerCallsignOrDefault(const swift::misc::aviation::CCallsign &callsign) const
Get the setup for callsign, if not existing the global setup.
int getModelSetCount() const
Number of installed models in simulator eco system.
swift::misc::simulation::MatchingLog isMatchingMessagesEnabled() const
Enabled mapping logging?
void stopSimulatorPlugin(const swift::misc::simulation::CSimulatorPluginInfo &simulatorInfo)
Stop listener or unload the given plugin (if currently loaded)
bool setInterpolationAndRenderingSetupsPerCallsign(const swift::misc::simulation::CInterpolationSetupList &setups, bool ignoreSameAsGlobal)
Set all setups per callsign.
QStringList getModelSetStrings() const
Model strings.
void enableMatchingMessages(swift::misc::simulation::MatchingLog enabled)
Enable mapping logging.
bool isSimulatorPluginAvailable() const
Simulator plugin available?
~CContextSimulator()
Destructor.
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.
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.
bool contains(const Key &key) const const
QMap< Key, T >::iterator insert(QMap< Key, T >::const_iterator pos, const Key &key, const T &value)
QMap< Key, T >::size_type remove(const Key &key)
T value(const Key &key, const T &defaultValue) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
void setObjectName(QAnyStringView name)
bool isEmpty() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
bool isRunning() const const
void start(QThread::Priority priority)
bool wait(QDeadlineTimer deadline)
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.