39using namespace swift::config;
42using namespace swift::misc::physical_quantities;
43using namespace swift::misc::aviation;
44using namespace swift::misc::network;
45using namespace swift::misc::simulation;
46using namespace swift::misc::simulation::xplane;
47using namespace swift::misc::geo;
48using namespace swift::misc::weather;
49using namespace swift::misc::simulation;
50using namespace swift::misc::simulation::settings;
51using namespace swift::misc::simulation::data;
52using namespace std::chrono_literals;
54namespace swift::core::context
62 Q_ASSERT_X(sApp, Q_FUNC_INFO,
"Need sApp");
63 MatchingLog logMatchingMessages =
65 m_logMatchingMessages = logMatchingMessages;
66 m_plugins->collectPlugins();
67 this->restoreSimulatorPlugins();
80 this->initByLastUsedModelSet();
81 m_aircraftMatcher.setSetup(m_matchingSettings.get());
82 if (m_aircraftMatcher.getModelSetCount() <= MatchingLogMaxModelSetSize)
96 using namespace std::chrono_literals;
97 m_validator->startUpdating(60s);
102 void CContextSimulator::setValidator(
const CSimulatorInfo &simulator)
128 m_validator->quitAndWait();
129 m_validator->deleteLater();
130 m_validator =
nullptr;
132 this->stopSimulatorListeners();
134 this->unloadSimulatorPlugin();
138 m_listenersThread.quit();
139 m_listenersThread.wait(10 * 1000);
148 return m_plugins->getAvailableSimulatorPlugins();
163 return m_multiSimulatorSettings.getSettings(sim);
173 if (simSettings == settings)
185 return this->listenForSimulator(simulatorInfo);
190 if (!m_simulatorPlugin.first.isUnspecified() && m_simulatorPlugin.first == simulatorInfo)
192 this->unloadSimulatorPlugin();
210 return m_plugins->checkAvailableListeners();
219 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
223 return m_simulatorPlugin.second->getSimulatorStatus();
233 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
239 return m_simulatorPlugin.second->getSimulatorPluginInfo();
241 return m_simulatorPlugin.first;
250 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
254 return m_simulatorPlugin.second->getSimulatorInternals();
279 if (m_simulatorPlugin.second)
281 if (m_simulatorPlugin.second->isConnected())
283 if (m_simulatorPlugin.second->isEmulatedDriver())
288 return m_simulatorPlugin.first.getSimulatorInfo();
291 return m_modelSetSimulator.get();
296 Q_ASSERT_X(
simulator.isSingleSimulator(), Q_FUNC_INFO,
"Need single simulator");
307 m_aircraftMatcher.setModelSet(models,
simulator,
false);
330 u
"No model set so far, you need at least one model set. Hint: You can create a model set in the "
331 u
"mapping tool, or copy an existing set in the launcher."));
397 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
410 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
414 m_aircraftMatcher.disableModelsForMatching(removedModels, incremental);
423 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
427 return m_aircraftMatcher.getDisabledModelsForMatching();
436 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
440 m_aircraftMatcher.restoreDisabledModels();
453 return m_validator->isValidating();
467 simulator.isSingleSimulator() ? m_multiSimulatorSettings.getSimulatorDirectoryOrDefault(
simulator) :
"";
468 return m_validator->triggerValidation(
simulator, simDir);
477 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
491 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
493 return m_renderSettings.get();
495 return m_simulatorPlugin.second->getInterpolationSetupGlobal();
504 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
508 return m_simulatorPlugin.second->getInterpolationSetupsPerCallsign();
518 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
522 return m_simulatorPlugin.second->getInterpolationSetupPerCallsignOrDefault(callsign);
526 bool ignoreSameAsGlobal)
532 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
536 return m_simulatorPlugin.second->setInterpolationSetupsPerCallsign(setups, ignoreSameAsGlobal);
551 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
555 m_simulatorPlugin.second->setInterpolationSetupGlobal(setup);
568 if (!m_simulatorPlugin.second || m_simulatorPlugin.first.isUnspecified())
572 return m_simulatorPlugin.second->getInterpolationMessages(callsign);
583 if (!m_simulatorPlugin.first.isUnspecified())
590 if (!simulatorPluginInfo.
isValid())
597 Q_ASSERT_X(factory, Q_FUNC_INFO,
"no factory");
602 "Need implementing object");
608 factory->
create(simulatorPluginInfo, ownAircraftProvider, renderedAircraftProvider, clientProvider);
609 Q_ASSERT_X(
simulator, Q_FUNC_INFO,
"no simulator driver can be created");
617 SWIFT_VERIFY_X(
false, Q_FUNC_INFO,
"Invalid simulator from plugin");
622 u
"Emulated driver does NOT provide valid simulator, using default '%1', plugin: '%2'")
633 m_modelSetSimulator.set(simInfo);
634 const CAircraftModelList modelSetModels = this->
getModelSet();
635 m_aircraftMatcher.setModelSet(modelSetModels, simInfo,
true);
636 m_aircraftMatcher.setDefaultModel(
simulator->getDefaultModel());
642 &CContextSimulator::onAddingRemoteAircraftFailed);
645 &CContextSimulator::onOwnSimulatorModelChanged);
677 &CContextSimulator::relayStatusMessageToSimulator);
680 &CContextSimulator::relayStatusMessageToSimulator);
685 m_initallyAddAircraft =
true;
686 m_wasSimulating =
false;
687 m_matchingMessages.clear();
688 m_failoverAddingCounts.clear();
691 const bool connected =
simulator->connectTo();
694 CLogMessage(
this).error(u
"Simulator plugin connection to simulator '%1' failed")
700 m_simulatorPlugin.first = simulatorPluginInfo;
702 m_simulatorPlugin.second->setInterpolationSetupGlobal(m_renderSettings.get());
705 QPointer<CContextSimulator> myself(
this);
711 if (m_simulatorPlugin.second)
713 CLogMessage(
this).info(u
"Simulator plugin loaded: '%1' connected: %2")
725 bool CContextSimulator::listenForSimulator(
const CSimulatorPluginInfo &simulatorInfo)
730 Q_ASSERT(m_simulatorPlugin.first.isUnspecified());
732 if (!m_listenersThread.isRunning())
734 m_listenersThread.setObjectName(
"CContextSimulator: Thread for listener " + simulatorInfo.
getIdentifier());
738 ISimulatorListener *listener = m_plugins->createListener(simulatorInfo.
getIdentifier());
744 if (listener->
thread() != &m_listenersThread)
746 Q_ASSERT_X(!listener->
parent(), Q_FUNC_INFO,
"Objects with parent cannot be moved to thread");
752 CLogMessage(
this).error(u
"Unable to use '%1'") << simulatorInfo.
toQString();
763 Q_ASSERT_X(s, Q_FUNC_INFO,
"cannot invoke method");
766 CLogMessage(
this).info(u
"Listening for simulator '%1'") << simulatorInfo.
getIdentifier();
770 void CContextSimulator::listenForAllSimulators()
773 for (
const CSimulatorPluginInfo &p : plugins)
775 Q_ASSERT(!p.isUnspecified());
778 this->listenForSimulator(p);
783 void CContextSimulator::unloadSimulatorPlugin()
785 if (!m_simulatorPlugin.first.isUnspecified())
787 ISimulator *
simulator = m_simulatorPlugin.second;
795 m_simulatorPlugin.second =
nullptr;
796 m_simulatorPlugin.first = CSimulatorPluginInfo();
816 m_wasSimulating =
false;
820 void CContextSimulator::xCtxAddedRemoteAircraftReadyForModelMatching(
const CSimulatedAircraft &remoteAircraft)
827 const CCallsign callsign = remoteAircraft.
getCallsign();
837 MatchingLog whatToLog = m_logMatchingMessages;
838 CStatusMessageList matchingMessages;
839 CStatusMessageList *pMatchingMessages = m_logMatchingMessages > 0 ? &matchingMessages :
nullptr;
840 CAircraftModel aircraftModel =
841 m_aircraftMatcher.getClosestMatch(remoteAircraft, whatToLog, pMatchingMessages,
true);
842 Q_ASSERT_X(remoteAircraft.
getCallsign() == aircraftModel.
getCallsign(), Q_FUNC_INFO,
"Mismatching callsigns");
845 const CLength cgModel = aircraftModel.
getCG();
846 const CLength cgSim = m_simulatorPlugin.second->getSimulatorCGPerModelString(aircraftModel.
getModelString());
850 case CSimulatorSettings::CGFromSimulatorOnly: aircraftModel.
setCG(cgSim);
break;
851 case CSimulatorSettings::CGFromSimulatorFirst:
854 aircraftModel.
setCG(cgSim);
857 case CSimulatorSettings::CGFromDBFirst:
860 aircraftModel.
setCG(cgSim);
867 const CLength overriddenCG =
868 m_simulatorPlugin.second->overriddenCGorDefault(CLength::null(), aircraftModel.
getModelString());
869 if (!overriddenCG.
isNull())
871 aircraftModel.
setCG(overriddenCG);
877 const CSimulatedAircraft aircraftAfterModelApplied =
891 CLogMessage(
this).error(u
"Matching error for '%1', no model string")
894 CSimulatedAircraft brokenAircraft(aircraftAfterModelApplied);
895 brokenAircraft.setEnabled(
false);
896 brokenAircraft.setRendered(
false);
898 pMatchingMessages, callsign,
899 QStringLiteral(
"Cannot add remote aircraft, no model string: '%1'").arg(brokenAircraft.toQString()));
905 m_simulatorPlugin.second->logicallyAddRemoteAircraft(aircraftAfterModelApplied);
907 pMatchingMessages, callsign,
908 QStringLiteral(
"Logically added remote aircraft: %1").arg(aircraftAfterModelApplied.
toQString()));
910 this->clearMatchingMessages(callsign);
911 this->addMatchingMessages(callsign, matchingMessages);
917 void CContextSimulator::xCtxRemovedRemoteAircraft(
const CCallsign &callsign)
923 m_simulatorPlugin.second->logicallyRemoveRemoteAircraft(callsign);
924 m_failoverAddingCounts.remove(callsign);
927 void CContextSimulator::onSimulatorStatusChanged(ISimulator::SimulatorStatus status)
934 Q_ASSERT_X(networkContext, Q_FUNC_INFO,
"Need context");
935 Q_ASSERT_X(networkContext->isLocalObject(), Q_FUNC_INFO,
"Need local object");
938 const CSimulatedAircraftList aircraft = networkContext->getAircraftInRange();
939 for (
const CSimulatedAircraft &simulatedAircraft : aircraft)
941 SWIFT_VERIFY_X(!simulatedAircraft.getCallsign().isEmpty(), Q_FUNC_INFO,
"Need callsign");
942 this->xCtxAddedRemoteAircraftReadyForModelMatching(simulatedAircraft);
944 m_initallyAddAircraft =
false;
951 this->unloadSimulatorPlugin();
952 this->restoreSimulatorPlugins();
958 m_wasSimulating =
false;
964 void CContextSimulator::xCtxTextMessagesReceived(
const network::CTextMessageList &textMessages)
975 const CSimulatorMessagesSettings settings = m_messageSettings.getThreadLocal();
977 for (
const auto &tm : textMessages)
983 m_simulatorPlugin.second->displayTextMessage(tm);
987 void CContextSimulator::xCtxChangedRemoteAircraftModel(
const CSimulatedAircraft &aircraft,
988 const swift::misc::CIdentifier &originator)
998 m_simulatorPlugin.second->changeRemoteAircraftModel(aircraft);
1001 void CContextSimulator::xCtxChangedOwnAircraftModel(
const CAircraftModel &aircraftModel,
1002 const CIdentifier &originator)
1016 void CContextSimulator::xCtxChangedRemoteAircraftEnabled(
const CSimulatedAircraft &aircraft)
1022 m_simulatorPlugin.second->changeRemoteAircraftEnabled(aircraft);
1025 void CContextSimulator::xCtxNetworkConnectionStatusChanged(
const CConnectionStatus &from,
1026 const CConnectionStatus &to)
1031 if (to.
isConnected() && this->getIContextNetwork())
1034 if (m_simulatorPlugin.second)
1036 m_simulatorPlugin.second->setFlightNetworkConnected(
true);
1037 m_simulatorPlugin.second->setOwnCallsign(
1043 m_networkSessionId.clear();
1044 m_aircraftMatcher.clearMatchingStatistics();
1045 m_matchingMessages.clear();
1046 m_failoverAddingCounts.clear();
1048 if (m_simulatorPlugin.second)
1050 m_simulatorPlugin.second->removeAllRemoteAircraft();
1051 m_simulatorPlugin.second->setFlightNetworkConnected(
false);
1052 m_simulatorPlugin.second->setOwnCallsign({});
1057 void CContextSimulator::onAddingRemoteAircraftFailed(
const CSimulatedAircraft &remoteAircraft,
bool disabled,
1058 bool requestFailover,
const CStatusMessage &message)
1066 m_aircraftMatcher.addingRemoteModelFailed(remoteAircraft);
1069 const CCallsign cs = remoteAircraft.
getCallsign();
1075 bool failover = requestFailover;
1076 if (requestFailover)
1078 const CAircraftMatcherSetup setup = m_aircraftMatcher.getSetup();
1081 const int trial = m_failoverAddingCounts.value(cs, 0);
1082 if (trial < MaxModelAddedFailoverTrials)
1084 m_failoverAddingCounts[cs] = trial + 1;
1090 CLogMessage(
this).warning(u
"Model for '%1' failed adding, tried %2 time(s) to resolve, giving up")
1098 void CContextSimulator::xCtxUpdateSimulatorCockpitFromContext(
const CSimulatedAircraft &ownAircraft,
1099 const CIdentifier &originator)
1111 m_simulatorPlugin.second->updateOwnSimulatorCockpit(ownAircraft, originator);
1114 void CContextSimulator::xCtxUpdateSimulatorSelcalFromContext(
const CSelcal &selcal,
const CIdentifier &originator)
1126 m_simulatorPlugin.second->updateOwnSimulatorSelcal(selcal, originator);
1129 void CContextSimulator::xCtxNetworkRequestedNewAircraft(
const CCallsign &callsign,
const QString &aircraftIcao,
1130 const QString &airlineIcao,
const QString &livery)
1132 if (m_networkSessionId.isEmpty())
1136 m_aircraftMatcher.evaluateStatisticsEntry(m_networkSessionId, callsign, aircraftIcao, airlineIcao, livery);
1139 void CContextSimulator::relayStatusMessageToSimulator(
const swift::misc::CStatusMessage &message)
1149 const CSimulatorMessagesSettings simMsg = m_messageSettings.getThreadLocal();
1152 m_simulatorPlugin.second->displayStatusMessage(message);
1156 void CContextSimulator::changeEnabledSimulators()
1158 CSimulatorPluginInfo currentPluginInfo = m_simulatorPlugin.first;
1159 const QStringList enabledSimulators = m_enabledSimulators.getThreadLocal();
1164 unloadSimulatorPlugin();
1167 restoreSimulatorPlugins();
1170 void CContextSimulator::restoreSimulatorPlugins()
1172 if (!m_simulatorPlugin.first.isUnspecified())
1177 this->stopSimulatorListeners();
1178 const QStringList enabledSimulators = m_enabledSimulators.getThreadLocal();
1179 const CSimulatorPluginInfoList allSimulators = m_plugins->getAvailableSimulatorPlugins();
1180 for (
const CSimulatorPluginInfo &s : allSimulators)
1182 if (enabledSimulators.
contains(s.getIdentifier()))
1195 return m_matchingMessages[callsign];
1204 return m_logMatchingMessages;
1213 if (m_logMatchingMessages == enabled)
1217 m_logMatchingMessages = enabled;
1237 m_aircraftMatcher.setSetup(setup);
1248 return m_aircraftMatcher.getSetup();
1253 if (!m_simulatorPlugin.second || !m_simulatorPlugin.second->isConnected())
1260 m_simulatorPlugin.second->setTestMode(
true);
1261 added = m_simulatorPlugin.second->logicallyAddRemoteAircraft(aircraft);
1265 m_simulatorPlugin.second->logicallyRemoveRemoteAircraft(aircraft.
getCallsign());
1266 m_simulatorPlugin.second->setTestMode(
false);
1274 if (!m_simulatorPlugin.second || !m_simulatorPlugin.second->isConnected())
1280 return m_simulatorPlugin.second->testSendSituationAndParts(cs, s, parts);
1285 Q_UNUSED(originator)
1291 ".plugin",
".drv",
".driver",
1294 parser.
parse(commandLine);
1295 if (!parser.isKnownCommand())
1299 if (parser.matchesCommand(
"ris"))
1302 const QString p1 = parser.part(1);
1303 if (!parser.hasPart(2))
1312 else if (p1 ==
"parts")
1324 if (parser.matchesCommand(
"plugin") || parser.matchesCommand(
"drv") || parser.matchesCommand(
"driver"))
1326 if (!m_simulatorPlugin.second)
1330 return m_simulatorPlugin.second->parseCommandLine(commandLine, originator);
1341 return m_simulatorPlugin.second;
1350 if (!m_simulatorPlugin.second)
1354 return m_simulatorPlugin.second->followAircraft(callsign);
1363 if (!m_simulatorPlugin.second)
1367 m_simulatorPlugin.second->recalculateAllAircraft();
1382 m_simulatorPlugin.second->logicallyRemoveRemoteAircraft(callsign);
1386 if (!sApp || sApp->isShuttingDown() || !myself)
1390 this->xCtxAddedRemoteAircraftReadyForModelMatching(aircraft);
1401 if (!m_simulatorPlugin.second || !m_simulatorPlugin.second->isConnected())
1405 return m_simulatorPlugin.second->requestElevationBySituation(situation);
1416 if (!m_simulatorPlugin.second || !m_simulatorPlugin.second->isConnected())
1420 return m_simulatorPlugin.second->findClosestElevationWithinRange(reference, range);
1439 if (!sApp || sApp->isShuttingDown() || !myself)
1447 return callsigns.
size();
1467 if (!sApp || sApp->isShuttingDown() || !myself)
1479 this->xCtxAddedRemoteAircraftReadyForModelMatching(resetAircraft);
1486 this->stopSimulatorListeners();
1487 this->loadSimulatorPlugin(info);
1490 if (m_logMatchingMessages)
1507 void CContextSimulator::onOwnSimulatorModelChanged(
const CAircraftModel &model)
1509 CAircraftModel lookupModel(model);
1510 if (!lookupModel.isLoadedFromDb())
1512 lookupModel = this->reverseLookupModel(model);
1517 void CContextSimulator::stopSimulatorListeners()
1521 ISimulatorListener *listener = m_plugins->getListener(info.
getIdentifier());
1525 Q_ASSERT_X(s, Q_FUNC_INFO,
"Cannot invoke stop");
1531 void CContextSimulator::addMatchingMessages(
const CCallsign &callsign,
const CStatusMessageList &messages)
1541 if (!m_logMatchingMessages)
1545 if (m_matchingMessages.contains(callsign))
1547 CStatusMessageList &msgs = m_matchingMessages[callsign];
1552 m_matchingMessages.insert(callsign, messages);
1556 void CContextSimulator::clearMatchingMessages(
const CCallsign &callsign)
1562 m_matchingMessages.remove(callsign);
1565 CAircraftModel CContextSimulator::reverseLookupModel(
const CAircraftModel &model)
1567 bool modified =
false;
1568 const CAircraftModel reverseModel =
1570 return reverseModel;
1573 void CContextSimulator::initByLastUsedModelSet()
1576 const CSimulatorInfo
simulator(m_modelSetSimulator.get());
1578 const CAircraftModelList models(this->
getModelSet());
1579 CLogMessage(
this).info(u
"Init aircraft matcher with %1 models from set for '%2'")
1580 << models.size() <<
simulator.toQString();
1581 m_aircraftMatcher.setModelSet(models,
simulator,
false);
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
static constexpr bool isDebugBuild()
Debug build?
static bool isLocalDeveloperDebugBuild()
Local build for developers.
void setupChanged()
Setup changed.
int getModelSetCount() const
Model set count.
bool isShuttingDown() const
Is application shutting down?
ContextMode
How to handle a given context.
context::CContextNetwork * getCContextNetwork()
Context for network.
context::CContextOwnAircraft * getCContextOwnAircraft()
Context for own aircraft.
Manages plugins for the simulator context.
ISimulatorFactory * getFactory(const QString &pluginId)
Get simulator factory from the plugin.
Factory pattern class to create instances of ISimulator.
virtual ISimulator * create(const swift::misc::simulation::CSimulatorPluginInfo &info, swift::misc::simulation::IOwnAircraftProvider *ownAircraftProvider, swift::misc::simulation::IRemoteAircraftProvider *remoteAircraftProvider, swift::misc::network::IClientProvider *clientProvider)=0
Create a new instance of a driver.
Interface to a simulator.
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 isRunning() const
Running?
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.
CContextSimulator(CCoreFacadeConfig::ContextMode, CCoreFacade *runtime)
Constructor.
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.
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?
CCoreFacade * getRuntime()
Runtime.
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.
static swift::misc::simulation::CAircraftModel consolidateOwnAircraftModelWithDbData(const swift::misc::simulation::CAircraftModel &model, bool force, bool *modified=nullptr)
Consolidate own (aircraft) model data with DB data.
size_type size() const
Returns number of elements in the collection.
bool isEmpty() const
Synonym for empty.
bool isMyIdentifier(const CIdentifier &otherIdentifier) const
My identifier?
CIdentifiable(const QString &objectName)
Use literal based object name.
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 & debug()
Set the severity to debug.
Derived & error(const char16_t(&format)[N])
Set the severity to error, providing a format string.
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.
static void addLogDetailsToList(CStatusMessageList *log, const CCallsign &callsign, const QString &message, const QStringList &extraCategories={}, CStatusMessage::StatusSeverity s=CStatusMessage::SeverityInfo)
Specialized log for matching / reverse lookup.
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).
static const CElevationPlane & null()
NULL plane.
QString toQString(bool i18n=false) const
Cast as QString.
bool isConnected() const
Query status.
bool isDisconnected() const
Query status.
QString getServerSessionId(bool onlyConnected) const
Identifying a session, if not connected empty.
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.
const aviation::CCallsign & getCallsign() const
Corresponding callsign if applicable.
const physical_quantities::CLength & getCG() const
Get center of gravity.
void setCG(const physical_quantities::CLength &cg)
Get center of gravity.
const QString & getModelString() const
Model key, either queried or loaded from simulator model.
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.
void setCurrentSimulator(const CSimulatorInfo &simulator, const QString &simDirectory, const QStringList &modelDirList)
Corresponding simulator.
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 aviation::CCallsign & getCallsign() const
Get callsign.
bool hasCallsign() const
Callsign not empty, no further checks.
bool setEnabled(bool enabled)
Enabled / disabled.
const simulation::CAircraftModel & getNetworkModel() const
Get network model.
bool resetToNetworkModel()
Reset to the newtork model.
Simple hardcoded info about the corresponding simulator.
static const CSimulatorInfo & p3d()
Const simulator info objects.
bool isSingleSimulator() const
Single simulator selected.
bool isNoSimulator() const
No simulator?
Simulator internals for flight simulators. Those are obtained from a running simulator and represent ...
Describing a simulator plugin.
const CSimulatorInfo & getSimulatorInfo() const
Simulator info object.
bool isUnspecified() const
Unspecified simulator.
const QString & getIdentifier() const
Identifier.
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.
CAircraftModelList getCachedModels(const CSimulatorInfo &simulator) const
Models for simulator.
void synchronizeCache(const CSimulatorInfo &simulator)
Synchronize for given simulator.
CStatusMessage setCachedModels(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Set cached models.
static CCentralMultiSimulatorModelSetCachesProvider & modelCachesInstance()
Central instance.
CSimulatorInfo simulatorsWithInitializedCache() const
Initialized caches for which simulator?
void cacheChanged(const swift::misc::simulation::CSimulatorInfo &simulator)
Cache has been changed.
QStringList getModelDirectoriesOrDefault(const CSimulatorInfo &simulator) const
Model directory or default model path per simulator.
QString getSimulatorDirectoryOrDefault(const CSimulatorInfo &simulator) const
Simulator directory or default model path per simulator.
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)
Classes interacting with the swift database (aka "datastore").
Free functions in swift::misc.
SWIFT_MISC_EXPORT const QString & boolToYesNo(bool v)
Bool to yes/no.
SWIFT_MISC_EXPORT bool stringToBool(const QString &boolString)
Convert string to bool.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
bool moveToThread(QThread *targetThread)
QObject * parent() const const
void setObjectName(QAnyStringView name)
bool setProperty(const char *name, QVariant &&value)
QThread * thread() const const
bool isEmpty() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.