swift
Loading...
Searching...
No Matches
simulatoremulated.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
4#include "simulatoremulated.h"
5
6#include <QApplication>
7#include <QPointer>
8#include <QTimer>
9
11#include "gui/guiapplication.h"
13#include "misc/math/mathutils.h"
15
16using namespace swift::gui;
17using namespace swift::misc;
18using namespace swift::misc::aviation;
19using namespace swift::misc::physical_quantities;
20using namespace swift::misc::geo;
21using namespace swift::misc::network;
22using namespace swift::misc::math;
23using namespace swift::misc::simulation;
24using namespace swift::misc::simulation::settings;
25using namespace swift::core;
26using namespace swift::core::context;
27
28namespace swift::simplugin::emulated
29{
31 IRemoteAircraftProvider *remoteAircraftProvider,
32 IClientProvider *clientProvider, QObject *parent)
33 : CSimulatorPluginCommon(info, ownAircraftProvider, remoteAircraftProvider, clientProvider, parent)
34 {
35 Q_ASSERT_X(sApp && sApp->getIContextSimulator(), Q_FUNC_INFO, "Need context");
36
38 this->onSettingsChanged(); // init from settings
39
40 m_myAircraft = this->getOwnAircraft(); // sync with provider
42
43 connect(qApp, &QApplication::aboutToQuit, this, &CSimulatorEmulated::closeMonitor);
44 connect(sGui, &CGuiApplication::aboutToShutdown, this, &CSimulatorEmulated::closeMonitor, Qt::QueuedConnection);
45 connect(&m_interpolatorFetchTimer, &QTimer::timeout, this, &CSimulatorEmulated::updateRemoteAircraft);
46
47 // connect own signals for monitoring
48 this->connectOwnSignals();
49 }
50
52 {
53 if (m_monitorWidget)
54 {
55 // if the widget still exists, close and delete it
56 m_monitorWidget->close();
57 m_monitorWidget->deleteLater();
58 m_monitorWidget.clear();
59 }
60 }
61
63 {
64 const QPointer<CSimulatorEmulated> myself(this);
65 QTimer::singleShot(1000, this, [=, this] {
66 if (myself.isNull() || !sGui || sGui->isShuttingDown())
67 {
68 return;
69 }
71 m_monitorWidget->show();
73 });
74
75 if (canLog())
76 {
77 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
78 }
79 return true;
80 }
81
83 {
84 if (canLog())
85 {
86 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
87 }
88 m_renderedAircraft.clear();
89 return CSimulatorPluginCommon::disconnectFrom();
90 }
91
93 {
94 if (canLog())
95 {
96 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
97 }
98 CSimulatorPluginCommon::unload();
99 }
100
102 {
103 if (canLog())
104 {
105 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, remoteAircraft.toQString());
106 }
107 return ISimulator::logicallyAddRemoteAircraft(remoteAircraft);
108 }
109
111 {
112 if (canLog())
113 {
114 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, callsign.toQString());
115 }
117 }
118
120 {
121 if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, callsigns.toQString());
123 }
124
126 {
127 if (canLog())
128 {
129 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, aircraft.toQString());
130 }
132 }
133
135 {
136 if (canLog())
137 {
138 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, aircraft.toQString());
139 }
141 }
142
144 const CIdentifier &originator)
145 {
146 if (canLog())
147 {
148 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, aircraft.toQString(), originator.toQString());
149 }
150 if (originator == identifier())
151 {
152 return false;
153 } // myself
154
155 CSimulatedAircraft a = aircraft;
156
157 // only use the frequencies, not active transmit/receive
158 CComSystem com1 = m_myAircraft.getCom1System();
159 CComSystem com2 = m_myAircraft.getCom2System();
164 a.setCom1System(com1);
165 a.setCom2System(com2);
166
167 m_myAircraft.setCockpit(a);
168 emit this->internalAircraftChanged();
169 return true;
170 }
171
173 {
174 if (canLog())
175 {
176 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, selcal.toQString(), originator.toQString());
177 }
178 if (originator == identifier())
179 {
180 return false;
181 } // myself
182 if (m_myAircraft.getSelcal() == selcal)
183 {
184 return false;
185 }
186 m_myAircraft.setSelcal(selcal);
187 emit this->internalAircraftChanged();
188 return true;
189 }
190
192 {
193 if (!canDisplay())
194 {
195 return;
196 }
197 if (canLog())
198 {
199 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, message.toQString());
200 }
201 m_monitorWidget->displayStatusMessage(message);
202 }
203
205 {
206 if (!canDisplay())
207 {
208 return;
209 }
210 if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, message.toQString());
211 m_monitorWidget->displayTextMessage(message);
212 }
213
215 {
216 if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, callsign.toQString());
217 return m_renderedAircraft.containsCallsign(callsign);
218 }
219
221 {
222 if (canLog())
223 {
224 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
225 }
226 return m_renderedAircraft.getCallsigns();
227 }
228
230 {
231 if (canLog())
232 {
233 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
234 }
235 if (!m_interpolators.contains(callsign))
236 {
237 return {};
238 }
240 this->getInterpolationSetupPerCallsignOrDefault(callsign); // threadsafe copy
241 return m_interpolators[callsign]->getInterpolationMessages(setup.getInterpolatorMode());
242 }
243
245 const CAircraftParts &parts)
246 {
247 if (!m_renderedAircraft.containsCallsign(callsign))
248 {
249 return false;
250 }
251 m_renderedAircraft.setAircraftSituation(callsign, situation);
252 m_renderedAircraft.setAircraftPartsSynchronized(callsign, parts);
253 return true;
254 }
255
257 {
258 const bool hasRequested = CSimulatorPluginCommon::requestElevation(reference, callsign);
259 if (hasRequested || !m_enablePseudoElevation)
260 {
261 return hasRequested;
262 }
263
264 // For TESTING purposes ONLY
265 // we could not request elevation, so we provide a random value or set value
267 if (m_pseudoElevation.isNull())
268 {
269 const double elvRnd = CMathUtils::randomDouble(1000);
270 const CAltitude alt(elvRnd, CLengthUnit::ft());
271 elv.setGeodeticHeight(alt);
272 }
273 else
274 {
276 }
277
278 QPointer<CSimulatorEmulated> myself(this);
279 QTimer::singleShot(444, this, [=, this] {
280 if (!myself)
281 {
282 return;
283 }
284
285 // updates in providers and emits signal
287 });
288
289 emit this->requestedElevation(callsign);
290 return true;
291 }
292
293 bool CSimulatorEmulated::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
294 {
295 if (canLog())
296 {
297 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, commandLine, originator.toQString());
298 }
299 return CSimulatorPluginCommon::parseCommandLine(commandLine, originator);
300 }
301
302 // cppcheck-suppress duplInheritedMember
304 {
305 if (CSimpleCommandParser::registered("swift::simplugin::emulated::CSimulatorEmulated"))
306 {
307 return;
308 }
309 CSimpleCommandParser::registerCommand({ ".drv", "alias: .driver .plugin" });
310 CSimpleCommandParser::registerCommand({ ".drv show", "show emulated driver window" });
311 CSimpleCommandParser::registerCommand({ ".drv hide", "hide emulated driver window" });
312 }
313
314 void CSimulatorEmulated::setCombinedStatus(bool connected, bool simulating, bool paused)
315 {
316 m_connected = connected;
317 m_simulating = simulating;
318 m_paused = paused;
320 }
321
323 {
324 return m_pluginSettings.get().getEmulatedSimulator();
325 }
326
328 {
329 bool changed = false;
330 if (aircraft.getCom1System() != m_myAircraft.getCom1System())
331 {
332 changed = true;
333 }
334 if (aircraft.getCom2System() != m_myAircraft.getCom2System())
335 {
336 changed = true;
337 }
338 if (aircraft.getTransponder() != m_myAircraft.getTransponder())
339 {
340 changed = true;
341 }
342 if (aircraft.getSelcal() != m_myAircraft.getSelcal())
343 {
344 changed = true;
345 }
346
347 if (!changed)
348 {
349 return false;
350 }
351 m_myAircraft.setCockpit(aircraft);
352 return this->updateCockpit(aircraft, this->identifier());
353 }
354
356 {
357 if (m_myAircraft.getComSystem(unit) == comSystem)
358 {
359 return false;
360 }
361 m_myAircraft.setComSystem(comSystem, unit);
362 const bool c = this->updateCockpit(m_myAircraft, this->identifier());
363 if (c)
364 {
365 emit this->internalAircraftChanged();
366 }
367 return c;
368 }
369
371 {
372 if (m_myAircraft.getSelcal() == selcal)
373 {
374 return false;
375 }
376 m_myAircraft.setSelcal(selcal);
377 return this->updateSelcal(selcal, identifier());
378 }
379
381 {
382 if (m_myAircraft.getSituation() == situation)
383 {
384 return false;
385 }
386 m_myAircraft.setSituation(situation);
387
388 return this->updateOwnSituationAndGroundElevation(situation);
389 }
390
392 {
393 if (m_myAircraft.getParts() == parts)
394 {
395 return false;
396 }
397 m_myAircraft.setParts(parts);
398 return this->updateOwnParts(parts);
399 }
400
402 {
403 if (timeMs < 1)
404 {
405 m_interpolatorFetchTimer.stop();
406 }
407 else
408 {
409 m_interpolatorFetchTimer.start(timeMs);
410 }
411 return m_interpolatorFetchTimer.isActive();
412 }
413
414 bool CSimulatorEmulated::isInterpolatorFetching() const { return m_interpolatorFetchTimer.isActive(); }
415
417 {
418 if (canLog())
419 {
420 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
421 }
422 return m_connected;
423 }
424
426 {
427 if (canLog())
428 {
429 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
430 }
431 return m_paused;
432 }
433
435 {
436 if (canLog())
437 {
438 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
439 }
440 return m_simulating;
441 }
442
444 {
445 if (canLog())
446 {
447 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, remoteAircraft.toQString());
448 }
449 CSimulatedAircraft aircraft(remoteAircraft);
450 aircraft.setRendered(true);
451 const CCallsign cs = aircraft.getCallsign();
452 m_interpolators.insert(
454
455 this->logAddingAircraftModel(aircraft);
456 m_renderedAircraft.push_back(aircraft); // my simulator list
457 this->updateAircraftRendered(cs, true); // in provider
458 emit this->aircraftRenderingChanged(aircraft);
459
460 // debugging/logging (just here for debugging purposes)
461 const CAircraftModel networkModel = remoteAircraft.getNetworkModel();
462 const CAircraftModel currentModel = remoteAircraft.getModel();
463 Q_UNUSED(networkModel)
464 Q_UNUSED(currentModel)
465
466 return true;
467 }
468
470 {
471 if (canLog())
472 {
473 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, callsign.toQString());
474 }
475 m_interpolators.remove(callsign);
476 const int c = m_renderedAircraft.removeByCallsign(callsign);
477 this->updateAircraftRendered(callsign, false); // in provider
478 CSimulatorPluginCommon::physicallyRemoveRemoteAircraft(callsign);
479 return c > 0;
480 }
481
483 {
484 if (canLog())
485 {
486 m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
487 }
489 }
490
492 {
493 if (m_monitorWidget && parser.isKnownCommand())
494 {
495 if (parser.matchesPart(1, "show"))
496 {
497 m_monitorWidget->show();
498 return true;
499 }
500 if (parser.matchesPart(1, "hide"))
501 {
502 m_monitorWidget->hide();
503 return true;
504 }
505 }
506 return CSimulatorPluginCommon::parseDetails(parser);
507 }
508
509 void CSimulatorEmulated::setObjectName(const CSimulatorInfo &info)
510 {
511 QObject::setObjectName("Emulated driver for " + info.toQString());
512 m_interpolatorFetchTimer.setObjectName(this->objectName() + ":interpolatorFetchTimer");
513 }
514
515 bool CSimulatorEmulated::canLog() const { return this->canDisplay() && m_log; }
516
517 bool CSimulatorEmulated::canDisplay() const { return sApp && !sApp->isShuttingDown() && m_monitorWidget; }
518
519 void CSimulatorEmulated::closeMonitor()
520 {
521 if (m_monitorWidget)
522 {
523 m_monitorWidget->close();
524 }
525 }
526
527 void CSimulatorEmulated::onSettingsChanged()
528 {
529 if (!sApp || sApp->isShuttingDown())
530 {
531 return;
532 }
533 const CSwiftPluginSettings settings(m_pluginSettings.get());
534 m_log = settings.isLoggingFunctionCalls();
535
536 CSimulatorInfo simulator = settings.getEmulatedSimulator();
537 if (!simulator.isSingleSimulator())
538 {
539 // this will always be the same
541 }
542 Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
543
544 const CSimulatorPluginInfoList plugins = sApp->getIContextSimulator()->getAvailableSimulatorPlugins();
545 const CSimulatorPluginInfo plugin = plugins.findBySimulator(simulator);
546
547 if (plugin.isValid())
548 {
549 // ? restart driver, disconnect/reconnect
550 this->setNewPluginInfo(plugin, m_multiSettings.getSettings(simulator), settings.getDefaultModel());
551 }
552 else
553 {
554 // not all drivers are installed, like FS9/FSX on x64
555 CLogMessage(this).validationError(u"No valid plugin in emulated driver for '%1'") << simulator.toQString();
556 const QString sn = simulator.toQString(true);
557 const CSimulatorPluginInfo fakedPlugin =
558 CSimulatorPluginInfo(CSimulatorPluginInfo::identifierFromSimulatorInfo(simulator), sn, sn,
559 QStringLiteral("Emulated, but uninstalled '%1'").arg(sn), false);
560 this->setNewPluginInfo(fakedPlugin, m_multiSettings.getSettings(simulator), settings.getDefaultModel());
561 }
562
563 // update provider, own name, title
564 this->updateOwnModel(settings.getOwnModel());
565 this->setObjectName(simulator);
566 m_interpolationLogger.setObjectName("Logger (emulated driver): " + simulator.toQString());
567
568 if (m_monitorWidget)
569 {
570 m_monitorWidget->updateWindowTitleAndUiValues(simulator);
571 }
572 }
573
574 void CSimulatorEmulated::connectOwnSignals()
575 {
577 m_connectionGuard.append(connect(
579 [=, this](SimulatorStatus status) {
580 if (!m_monitorWidget) return;
581 m_monitorWidget->appendSendingCall("simulatorStatusChanged",
583 },
585
586 m_connectionGuard.append(connect(
588 [=, this](const CAircraftModel &model) {
589 if (!m_monitorWidget) return;
590 m_monitorWidget->appendSendingCall("ownAircraftModelChanged", model.toQString());
591 },
593
594 m_connectionGuard.append(connect(
596 [=, this](bool restricted, bool enabled, int maxAircraft, const CLength &maxRenderedDistance) {
597 if (!m_monitorWidget) return;
598 static const QString params("restricted: %1 enabled: %2 max aircraft: %3");
599 m_monitorWidget->appendSendingCall(
600 "renderRestrictionsChanged",
601 params.arg(boolToYesNo(restricted), boolToYesNo(enabled)).arg(maxAircraft),
602 maxRenderedDistance.valueRoundedWithUnit(CLengthUnit::m(), 1));
603 },
605
606 m_connectionGuard.append(connect(
608 [=, this]() {
609 if (!m_monitorWidget) return;
610 m_monitorWidget->appendSendingCall("interpolationAndRenderingSetupChanged");
611 },
613
614 m_connectionGuard.append(connect(
616 [=, this](const CSimulatedAircraft &aircraft) {
617 if (!m_monitorWidget) return;
618 m_monitorWidget->appendSendingCall("aircraftRenderingChanged", aircraft.toQString());
619 },
621
622 m_connectionGuard.append(connect(
624 [=, this](const CSimulatedAircraft &aircraft) {
625 if (!m_monitorWidget) return;
626 m_monitorWidget->appendSendingCall("physicallyAddingRemoteModelFailed", aircraft.toQString());
627 },
629
630 m_connectionGuard.append(connect(
632 [=, this] {
633 if (!m_monitorWidget) return;
634 m_monitorWidget->appendSendingCall("airspaceSnapshotHandled");
635 },
637 }
638
639 void CSimulatorEmulated::updateRemoteAircraft()
640 {
641 const qint64 now = QDateTime::currentMSecsSinceEpoch();
642 const bool updateAllAircraft = this->isUpdateAllRemoteAircraft(now);
643 uint32_t aircraftNumber = 0;
644
645 for (const CSimulatedAircraft &aircraft : m_renderedAircraft)
646 {
647 const CCallsign callsign = aircraft.getCallsign();
648 if (!m_interpolators.contains(callsign))
649 {
650 continue;
651 }
652 const CInterpolationAndRenderingSetupPerCallsign setup =
653 this->getInterpolationSetupConsolidated(callsign, updateAllAircraft);
654 CInterpolatorMulti *im = m_interpolators[callsign];
655 Q_ASSERT_X(im, Q_FUNC_INFO, "interpolator missing");
656 const CInterpolationResult result = im->getInterpolation(now, setup, aircraftNumber++);
657 const CAircraftSituation s = result;
658 const CAircraftParts p = result;
659 m_countInterpolatedParts++;
660 m_countInterpolatedSituations++;
661 Q_UNUSED(s)
662 Q_UNUSED(p)
663 }
664
666 }
667
670
672 {
673 if (this->isShuttingDown())
674 {
675 return;
676 }
677 const QPointer<CSimulatorEmulatedListener> myself(this);
678 QTimer::singleShot(2000, this, [=, this] {
679 if (!myself)
680 {
681 return;
682 }
683 Q_ASSERT_X(this->getPluginInfo().isValid(), Q_FUNC_INFO, "Invalid plugin");
684 emit this->simulatorStarted(this->getPluginInfo());
685 });
686 }
687
689
691} // namespace swift::simplugin::emulated
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
void aboutToShutdown()
About to shutdown.
bool isShuttingDown() const
Is application shutting down?
const context::IContextSimulator * getIContextSimulator() const
Direct access to contexts if a CCoreFacade has been initialized.
static QString statusToString(SimulatorStatus status)
Status to string.
virtual void callbackReceivedRequestedElevation(const swift::misc::geo::CElevationPlane &plane, const swift::misc::aviation::CCallsign &callsign, bool isWater)
A requested elevation has been received.
swift::misc::simulation::settings::CMultiSimulatorSettings m_multiSettings
simulator settings for all simulators
Definition simulator.h:600
swift::misc::aviation::CAltitude m_pseudoElevation
pseudo elevation for testing purposes
Definition simulator.h:578
void renderRestrictionsChanged(bool restricted, bool enabled, int maxAircraft, const swift::misc::physical_quantities::CLength &maxRenderedDistance)
Render restrictions have been changed.
bool updateOwnSituationAndGroundElevation(const swift::misc::aviation::CAircraftSituation &situation)
Update own aircraft position and if suitable use it to update ground elevation.
bool isUpdateAllRemoteAircraft(qint64 currentTimestamp=-1) const
Do update all remote aircraft?
virtual bool logicallyRemoveRemoteAircraft(const swift::misc::aviation::CCallsign &callsign)
Logically remove remote aircraft from simulator. Depending on max. aircraft, enabled status etc....
Definition simulator.cpp:67
void requestedElevation(const swift::misc::aviation::CCallsign &callsign)
Requested elevation, call pending.
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 finishUpdateRemoteAircraftAndSetStatistics(qint64 startTime, bool limited=false)
Update stats and flags.
void emitSimulatorCombinedStatus(SimulatorStatus oldStatus=Unspecified)
Emit the combined status.
void airspaceSnapshotHandled()
An airspace snapshot was handled.
virtual int physicallyRemoveAllRemoteAircraft()
Remove all remote aircraft and their data via ISimulator::clearAllRemoteAircraftData.
void logAddingAircraftModel(const swift::misc::simulation::CSimulatedAircraft &aircraft) const
Unified qeeing aircraft message.
swift::misc::simulation::CInterpolationAndRenderingSetupPerCallsign getInterpolationSetupConsolidated(const swift::misc::aviation::CCallsign &callsign, bool forceFullUpdate) const
Consolidate setup with other data like from swift::misc::simulation::IRemoteAircraftProvider.
swift::misc::simulation::CInterpolationLogger m_interpolationLogger
log.interpolation
Definition simulator.h:582
void aircraftRenderingChanged(const swift::misc::simulation::CSimulatedAircraft &aircraft)
Aircraft rendering changed.
virtual int physicallyRemoveMultipleRemoteAircraft(const swift::misc::aviation::CCallsignSet &callsigns)
Remove remote aircraft from simulator.
virtual bool logicallyAddRemoteAircraft(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft)
Logically add a new aircraft. Depending on max. aircraft, enabled status etc. it will physically adde...
Definition simulator.cpp:81
void interpolationAndRenderingSetupChanged()
Interpolation or rendering setup changed.
virtual bool changeRemoteAircraftEnabled(const swift::misc::simulation::CSimulatedAircraft &aircraft)
Aircraft got enabled / disabled.
bool m_enablePseudoElevation
return faked elevations (testing)
Definition simulator.h:560
void simulatorStarted(const swift::misc::simulation::CSimulatorPluginInfo &info)
Emitted when the listener discovers the simulator running.
const swift::misc::simulation::CSimulatorPluginInfo & getPluginInfo() const
Corresponding info.
Definition simulator.h:641
ISimulatorListener(const swift::misc::simulation::CSimulatorPluginInfo &info)
Constructor.
virtual bool isShuttingDown() const
Overall (swift) application shutting down.
virtual swift::misc::simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const =0
Return list of available simulator plugins.
static void modalWindowToFront()
Bring any modal dialog to front.
static QWidget * mainApplicationWidget()
Main application window widget.
const CIdentifier & identifier() const
Get identifier.
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition identifier.h:29
Utility methods for simple line parsing used with the command line.
static void registerCommand(const CommandHtmlHelp &command)
Register a command.
bool matchesPart(int index, const QString &toMatch, Qt::CaseSensitivity cs=Qt::CaseInsensitive) const
Matches given part.
bool isKnownCommand() const
Known command?
static bool registered(const QString &helpContext)
Help already registered.
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
Value object encapsulating information of aircraft's parts.
Value object encapsulating information of an aircraft's situation.
Altitude as used in aviation, can be AGL or MSL altitude.
Definition altitude.h:52
Value object encapsulating information of a callsign.
Definition callsign.h:30
Value object for a set of callsigns.
Definition callsignset.h:26
COM system (aka "radio").
Definition comsystem.h:37
static CComSystem getCom1System(double activeFrequencyMHz, double standbyFrequencyMHz=-1)
COM1 unit.
Definition comsystem.cpp:70
void setFrequencyStandby(const physical_quantities::CFrequency &frequency)
Set active frequency.
Definition comsystem.cpp:48
void setFrequencyActive(const physical_quantities::CFrequency &frequency)
Set active frequency.
Definition comsystem.cpp:37
static CComSystem getCom2System(double activeFrequencyMHz, double standbyFrequencyMHz=-1)
COM2 unit.
Definition comsystem.cpp:84
swift::misc::physical_quantities::CFrequency getFrequencyStandby() const
Standby frequency.
Definition modulator.cpp:36
swift::misc::physical_quantities::CFrequency getFrequencyActive() const
Active frequency.
Definition modulator.cpp:30
Value object for SELCAL.
Definition selcal.h:31
void setGeodeticHeight(const aviation::CAltitude &height)
Set height (ellipsoidal or geodetic height).
Plane of same elevation, can be a single point or larger area (e.g. airport).
static const physical_quantities::CLength & singlePointRadius()
Radius for single point.
Geodetic coordinate, a position in 3D space relative to the reference geoid.
static double randomDouble(double max=1)
Random double 0-max.
Definition mathutils.cpp:83
QString toQString(bool i18n=false) const
Cast as QString.
Definition mixinstring.h:74
Value object encapsulating information of a text message.
Definition textmessage.h:31
Direct in memory access to client (network client) data.
static CLengthUnit m()
Meter m.
Definition units.h:140
static CLengthUnit ft()
Foot ft.
Definition units.h:157
QString valueRoundedWithUnit(const MU &unit, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
Value to QString with the given unit, e.g. "5.00m".
Aircraft model (used by another pilot, my models on disk).
Value object for interpolator and rendering per callsign.
CInterpolationResult getInterpolation(qint64 currentTimeSinceEpoch, const CInterpolationAndRenderingSetupPerCallsign &setup, uint32_t aircraftNumber)
Get interpolated situation.
CInterpolatorMulti which can be used with QMap/QHash.
bool updateOwnParts(const aviation::CAircraftParts &parts)
Update own parts.
bool updateOwnModel(const swift::misc::simulation::CAircraftModel &model)
Update model.
bool updateCockpit(const swift::misc::simulation::CSimulatedAircraft &aircraft, const swift::misc::CIdentifier &originator)
Update cockpit, but only send signals when applicable.
bool updateSelcal(const aviation::CSelcal &selcal, const swift::misc::CIdentifier &originator)
Update cockpit, but only send signals when applicable.
CSimulatedAircraft getOwnAircraft() const
Own aircraft.
IRemoteAircraftProvider * getRemoteAircraftProvider() const
Get the aircraft provider.
bool updateAircraftRendered(const aviation::CCallsign &callsign, bool rendered)
Set aircraft rendered.
Comprehensive information of an aircraft.
const aviation::CSelcal getSelcal() const
SELCAL.
const aviation::CComSystem & getCom2System() const
Get COM2 system.
const aviation::CComSystem & getCom1System() const
Get COM1 system.
const aviation::CCallsign & getCallsign() const
Get callsign.
void setCom1System(const aviation::CComSystem &comSystem)
Set COM1 system.
const aviation::CTransponder & getTransponder() const
Get transponder.
void setCom2System(const aviation::CComSystem &comSystem)
Set COM2 system.
const simulation::CAircraftModel & getModel() const
Get model (model used for mapping).
const simulation::CAircraftModel & getNetworkModel() const
Get network model.
Simple hardcoded info about the corresponding simulator.
bool isSingleSimulator() const
Single simulator selected.
static const CSimulatorInfo & guessDefaultSimulator()
Guess a default simulator based on installation.
static const QString & identifierFromSimulatorInfo(const CSimulatorInfo &)
Simulator info to plugin indentifier, empty string if not single simulator.
bool isValid() const
Check if the provided plugin metadata is valid. Simulator plugin (driver) has to meet the following r...
CSimulatorPluginInfo findBySimulator(const swift::misc::simulation::CSimulatorInfo &simulator) const
Find by simulator.
CInterpolationAndRenderingSetupPerCallsign getInterpolationSetupPerCallsignOrDefault(const aviation::CCallsign &callsign) const
Get the setup for callsign, if not existing the global setup.
Direct threadsafe in memory access to own aircraft.
Direct thread safe in memory access to remote aircraft.
void setNewPluginInfo(const CSimulatorPluginInfo &info, const settings::CSimulatorSettings &settings, const CAircraftModel &defaultModel)
New plugin info and default model.
CSimulatorPluginCommon(const swift::misc::simulation::CSimulatorPluginInfo &info, swift::misc::simulation::IOwnAircraftProvider *ownAircraftProvider, swift::misc::simulation::IRemoteAircraftProvider *renderedAircraftProvider, swift::misc::network::IClientProvider *clientProvider, QObject *parent=nullptr)
Constructor.
bool updateOwnSimulatorSelcal(const swift::misc::aviation::CSelcal &selcal, const swift::misc::CIdentifier &originator)
Update own aircraft cockpit (usually from context).
bool isInterpolatorFetching() const
Is fetching from interpolator.
bool testSendSituationAndParts(const swift::misc::aviation::CCallsign &callsign, const swift::misc::aviation::CAircraftSituation &situation, const swift::misc::aviation::CAircraftParts &parts)
Send situation/parts for testing.
bool changeRemoteAircraftModel(const swift::misc::simulation::CSimulatedAircraft &aircraft)
Change remote aircraft per property.
swift::misc::simulation::CSimulatorInfo getEmulatedSimulator() const
The emulated simulated simulator.
bool disconnectFrom()
Disconnect from simulator.
bool physicallyAddRemoteAircraft(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft)
Add new remote aircraft physically to the simulator.
void internalAircraftChanged()
Internal aircraft changed.
swift::misc::aviation::CCallsignSet physicallyRenderedAircraft() const
Physically rendered (displayed in simulator) This shall only return aircraft handled in the simulator...
CSimulatorEmulated(const swift::misc::simulation::CSimulatorPluginInfo &info, swift::misc::simulation::IOwnAircraftProvider *ownAircraftProvider, swift::misc::simulation::IRemoteAircraftProvider *remoteAircraftProvider, swift::misc::network::IClientProvider *clientProvider, QObject *parent=nullptr)
Constructor, parameters as in.
bool updateOwnSimulatorCockpit(const swift::misc::simulation::CSimulatedAircraft &aircraft, const swift::misc::CIdentifier &originator)
Update own aircraft cockpit (usually from context).
swift::misc::CStatusMessageList getInterpolationMessages(const swift::misc::aviation::CCallsign &callsign) const
Interpolation messages for callsign.
bool logicallyRemoveRemoteAircraft(const swift::misc::aviation::CCallsign &callsign)
Logically remove remote aircraft from simulator. Depending on max. aircraft, enabled status etc....
bool requestElevation(const swift::misc::geo::ICoordinateGeodetic &reference, const swift::misc::aviation::CCallsign &callsign)
Request elevation, there is no guarantee the requested elevation will be available in the provider.
bool changeInternalSituation(const swift::misc::aviation::CAircraftSituation &situation)
Simulator internal change of situation.
friend class CSimulatorEmulatedMonitorDialog
the monitor widget represents the simulator and needs access to internals (i.e.
void displayTextMessage(const swift::misc::network::CTextMessage &message) const
Display a text message.
bool changeInternalCom(const swift::misc::simulation::CSimulatedAircraft &aircraft)
Simulator internal change of COM values.
bool setInterpolatorFetchTime(int timeMs)
Interpolator fetch time, <=0 stops.
bool parseDetails(const swift::misc::CSimpleCommandParser &parser)
Parsed in derived classes.
bool changeInternalParts(const swift::misc::aviation::CAircraftParts &parts)
Simulator internal change of parts.
int physicallyRemoveMultipleRemoteAircraft(const swift::misc::aviation::CCallsignSet &callsigns)
Remove remote aircraft from simulator.
bool changeInternalSelcal(const swift::misc::aviation::CSelcal &selcal)
Simulator internal change of SELCAL.
bool changeRemoteAircraftEnabled(const swift::misc::simulation::CSimulatedAircraft &aircraft)
Aircraft got enabled / disabled.
bool logicallyAddRemoteAircraft(const swift::misc::simulation::CSimulatedAircraft &remoteAircraft)
Logically add a new aircraft. Depending on max. aircraft, enabled status etc. it will physically adde...
bool physicallyRemoveRemoteAircraft(const swift::misc::aviation::CCallsign &callsign)
Remove remote aircraft from simulator.
bool isConnected() const
Are we connected to the simulator?
bool isPhysicallyRenderedAircraft(const swift::misc::aviation::CCallsign &callsign) const
Is the aircraft rendered (displayed in simulator)? This shall only return true if the aircraft is rea...
void displayStatusMessage(const swift::misc::CStatusMessage &message) const
Display a status message in the simulator.
void setCombinedStatus(bool connected, bool simulating, bool paused)
UI setter.
int physicallyRemoveAllRemoteAircraft()
Remove all remote aircraft and their data via ISimulator::clearAllRemoteAircraftData.
void startImpl()
Plugin specific implementation to start listener.
CSimulatorEmulatedListener(const swift::misc::simulation::CSimulatorPluginInfo &info)
Constructor.
void checkImpl()
Plugin specific implementation to stop listener.
void stopImpl()
Plugin specific implementation to stop listener.
bool parseCommandLine(const QString &commandLine, const swift::misc::CIdentifier &originator)
Backend services of the swift project, like dealing with the network or the simulators.
Definition actionbind.cpp:7
GUI related classes.
Free functions in swift::misc.
SWIFT_MISC_EXPORT const QString & boolToYesNo(bool v)
Bool to yes/no.
qint64 currentMSecsSinceEpoch()
QObject(QObject *parent)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
void setObjectName(QAnyStringView name)
bool isNull() const const
QueuedConnection
void timeout()