swift
Loading...
Searching...
No Matches
contextownaircraftimpl.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_CORE_CONTEXT_CONTEXTOWNAIRCRAFT_IMPL_H
7#define SWIFT_CORE_CONTEXT_CONTEXTOWNAIRCRAFT_IMPL_H
8
9#include <atomic>
10
11#include <QObject>
12#include <QReadWriteLock>
13#include <QString>
14#include <QTimer>
15
16#include "core/actionbind.h"
27#include "misc/icons.h"
28#include "misc/identifiable.h"
29#include "misc/identifier.h"
32#include "misc/network/user.h"
33#include "misc/pq/frequency.h"
34#include "misc/pq/length.h"
35#include "misc/settingscache.h"
40
41// clazy:excludeall=const-signal-or-slot
42
43namespace swift::misc
44{
45 class CDBusServer;
46 namespace aviation
47 {
50 class CAltitude;
51 class CCallsign;
52 class CTransponder;
53 } // namespace aviation
54} // namespace swift::misc
55namespace swift::core
56{
57 class CCoreFacade;
58 namespace context
59 {
63 public IContextOwnAircraft,
66 {
71 friend class swift::core::CCoreFacade;
72 friend class IContextOwnAircraft;
73
74 public:
76 ~CContextOwnAircraft() override = default;
77
78 // IOwnAircraftProvider overrides
82
86
90
94
99
104
108
111 bool updateOwnParts(const swift::misc::aviation::CAircraftParts &parts) override;
112
116
118 QObject *asQObject() override { return this; }
119
120 signals:
124 void ps_changedModel(const swift::misc::simulation::CAircraftModel &model,
125 const swift::misc::CIdentifier &identifier);
126
127 public slots:
130 swift::misc::simulation::CSimulatedAircraft getOwnAircraft() const override;
131
135 getOwnComSystem(swift::misc::aviation::CComSystem::ComUnit unit) const override;
136
139 swift::misc::aviation::CTransponder getOwnTransponder() const override;
140
143 swift::misc::aviation::CAircraftSituation getOwnAircraftSituation() const override;
144
147 bool updateOwnCallsign(const swift::misc::aviation::CCallsign &callsign) override;
148
151 bool updateOwnIcaoCodes(const swift::misc::aviation::CAircraftIcaoCode &aircraftIcaoCode,
152 const swift::misc::aviation::CAirlineIcaoCode &airlineIcaoCode) override;
153
155 bool updateOwnPosition(const swift::misc::geo::CCoordinateGeodetic &position,
156 const swift::misc::aviation::CAltitude &altitude,
157 const swift::misc::aviation::CAltitude &pressureAltitude) override;
158
160 bool updateCockpit(const swift::misc::aviation::CComSystem &com1,
162 const swift::misc::aviation::CTransponder &transponder,
163 const swift::misc::CIdentifier &originator) override;
164
166 bool updateTransponderMode(const swift::misc::aviation::CTransponder::TransponderMode &transponderMode,
167 const swift::misc::CIdentifier &originator) override;
168
170 bool updateSelcal(const swift::misc::aviation::CSelcal &selcal,
171 const swift::misc::CIdentifier &originator) override;
172
174 bool updateActiveComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
176 const swift::misc::CIdentifier &originator) override;
177
179 bool updateStandbyComFrequency(const swift::misc::physical_quantities::CFrequency &frequency,
181 const swift::misc::CIdentifier &originator) override;
182
184 bool updateOwnAircraftPilot(const swift::misc::network::CUser &pilot) override;
185
187 void toggleTransponderMode() override;
188
190 bool setTransponderMode(swift::misc::aviation::CTransponder::TransponderMode mode) override;
191
200 bool parseCommandLine(const QString &commandLine, const swift::misc::CIdentifier &originator) override;
201
203 static void registerHelp()
204 {
205 if (swift::misc::CSimpleCommandParser::registered("swift::core::context::CContextOwnAircraft"))
206 {
207 return;
208 }
210 swift::misc::CSimpleCommandParser::registerCommand({ ".x code|mode", "set XPDR code or mode" });
211 swift::misc::CSimpleCommandParser::registerCommand({ ".selcal code", "set SELCAL code" });
213 swift::misc::CSimpleCommandParser::registerCommand({ ".com1 frequency", "set COM1 frequency" });
214 swift::misc::CSimpleCommandParser::registerCommand({ ".com2 frequency", "set COM2 frequency" });
215 }
216
217 protected:
220
221 private:
223 mutable QReadWriteLock m_lockAircraft;
224
225 CActionBind m_actionToggleXpdr { swift::misc::input::toggleXPDRStateHotkeyAction(),
226 swift::misc::input::toggleXPDRStateHotkeyIcon(), this,
227 &CContextOwnAircraft::actionToggleTransponder };
228 CActionBind m_actionIdent { swift::misc::input::toggleXPDRIdentHotkeyAction(),
229 swift::misc::input::toggleXPDRIdentHotkeyIcon(), this,
230 &CContextOwnAircraft::actionIdent };
231
232 static constexpr qint64 MinHistoryDeltaMs = 1000;
233 static constexpr int MaxHistoryElements = 20;
234 QTimer m_historyTimer;
235 std::atomic_bool m_history { true };
237
239 this
240 };
241
244 void xCtxChangedSimulatorModel(const swift::misc::simulation::CAircraftModel &model,
245 const swift::misc::CIdentifier &identifier);
246
249 void xCtxChangedSimulatorStatus(int status);
250
253 void actionToggleTransponder(bool keydown);
254 void actionIdent(bool keydown);
256
258 void allSwiftWebDataRead();
259
261 void initOwnAircraft();
262
264 void evaluateUpdateHistory();
265
267 bool updateOwnModel(const swift::misc::simulation::CAircraftModel &model,
268 const swift::misc::CIdentifier &identifier);
269
271 static swift::misc::simulation::CAircraftModel
272 reverseLookupModel(const swift::misc::simulation::CAircraftModel &model);
273 };
274 } // namespace context
275} // namespace swift::core
276#endif // SWIFT_CORE_CONTEXT_CONTEXTOWNAIRCRAFT_IMPL_H
CActionBind binds a member function to an action.
Definition actionbind.h:18
ContextMode
How to handle a given context.
The class providing facades (the contexts) for all DBus relevant operations.
Definition corefacade.h:57
Own aircraft context implementation. Central instance of data for.
swift::misc::simulation::CAircraftModel getOwnAircraftModel() const
Own aircraft model.
swift::misc::physical_quantities::CLength getDistanceToOwnAircraft(const swift::misc::geo::ICoordinateGeodetic &position) const
Distance to own aircraft.
swift::misc::geo::CCoordinateGeodetic getOwnAircraftPosition() const
Own aircraft's position.
swift::misc::aviation::CCallsign getOwnCallsign() const
Own aircraft's callsign.
bool updateOwnSituation(const swift::misc::aviation::CAircraftSituation &situation)
Update own situation.
bool updateOwnModel(const swift::misc::simulation::CAircraftModel &model)
Update model.
CContextOwnAircraft(CCoreFacadeConfig::ContextMode, CCoreFacade *runtime)
Constructor, with link to runtime.
bool updateOwnParts(const swift::misc::aviation::CAircraftParts &parts)
Update own parts.
swift::misc::aviation::CAircraftParts getOwnAircraftParts() const
Own aircraft's parts.
bool updateOwnCG(const swift::misc::physical_quantities::CLength &cg)
Update own parts.
Custom DBusServer.
Definition dbusserver.h:34
Base class with a member CIdentifier to be inherited by a class which has an identity in the environm...
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition identifier.h:29
Class template for accessing a specific value in the CSettingsCache.
static void registerCommand(const CommandHtmlHelp &command)
Register a command.
static bool registered(const QString &helpContext)
Help already registered.
Base class for providers.
Definition provider.h:19
Value object for ICAO classification.
Value object encapsulating information of aircraft's parts.
Value object encapsulating information of an aircraft's situation.
Value object for ICAO classification.
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
COM system (aka "radio").
Definition comsystem.h:37
Value object for SELCAL.
Definition selcal.h:31
Geodetic coordinate, a position in 3D space relative to the reference geoid.
Value object encapsulating information of a user.
Definition user.h:28
Physical unit length (length).
Definition length.h:18
Aircraft model (used by another pilot, my models on disk).
Comprehensive information of an aircraft.
Direct threadsafe in memory access to own aircraft.
#define SWIFT_CORE_CONTEXTOWNAIRCRAFT_INTERFACENAME
DBus interface for context.
Backend services of the swift project, like dealing with the network or the simulators.
Definition actionbind.cpp:7
Free functions in swift::misc.
QObject(QObject *parent)
Q_CLASSINFO(Name, Value)
Q_INTERFACES(...)
Q_OBJECTQ_OBJECT
#define SWIFT_CORE_EXPORT
Export a class or function from the library.