Debian Codegraph @

src/Network/Swift/service.h

raw symbols SCIP
1 /*
2 * Service module for swift<->FG connection
3 * SPDX-FileCopyrightText: (C) 2019-2022 swift Project Community / Contributors (https://swift-project.org/)
4 * SPDX-FileCopyrightText: (C) 2019-2022 Lars Toenning <[email protected]>
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8 #pragma once
9
10
11 #include "dbusobject.h"
12 #include <Main/fg_props.hxx>
13 #include <chrono>
14 #include <simgear/compiler.h>
15 #include <simgear/debug/logstream.hxx>
16 #include <simgear/io/raw_socket.hxx>
17 #include <simgear/misc/stdint.hxx>
18 #include <simgear/props/props.hxx>
19 #include <simgear/structure/commands.hxx>
20 #include <simgear/structure/event_mgr.hxx>
21 #include <simgear/structure/subsystem_mgr.hxx>
22 #include <simgear/timing/timestamp.hxx>
23 #include <string>
24
25
26 namespace flightgear::swift {
27
28 /*!
29 * FGSwiftBus service object which is accessible through DBus
30 */
31 class CService : public CDBusObject
32 {
33 public:
34 //! Constructor
35 CService();
36
37 //! DBus interface name
38 static const std::string& InterfaceName();
39
40 //! DBus object path
41 static const std::string& ObjectPath();
42
43 //! Getting flightgear version
44 static int getVersionNumber();
45
46 ////! Add a text message to the on-screen display, with RGB components in the range [0,1]
47 void addTextMessage(const std::string& text);
48
49 ////! Get full path to current aircraft model
50 std::string getAircraftModelPath() const;
51
52 ////! Get base filename of current aircraft model
53 std::string getAircraftModelFilename() const;
54
55 ////! Get canonical swift model string of current aircraft model
56 std::string getAircraftModelString() const;
57
58 ////! Get name of current aircraft model
59 std::string getAircraftName() const;
60
61 ////! Get path to current aircraft livery
62 std::string getAircraftLivery() const;
63
64 //! Get the ICAO code of the current aircraft model
65 std::string getAircraftIcaoCode() const;
66
67 ////! Get the description of the current aircraft model
68 std::string getAircraftDescription() const;
69
70 //! True if sim is paused
71 bool isPaused() const;
72
73 //! Get aircraft latitude in degrees
74 double getLatitude() const;
75
76 //! Get aircraft longitude in degrees
77 double getLongitude() const;
78
79 //! Get aircraft altitude in feet
80 double getAltitudeMSL() const;
81
82 //! Get aircraft height in feet
83 double getHeightAGL() const;
84
85 //! Get aircraft groundspeed in knots
86 double getGroundSpeed() const;
87
88 //! Get aircraft pitch in degrees above horizon
89 double getPitch() const;
90
91 //! Get aircraft roll in degrees
92 double getRoll() const;
93
94 //! Get aircraft true heading in degrees
95 double getTrueHeading() const;
96
97 //! Get whether all wheels are on the ground
98 bool getAllWheelsOnGround() const;
99
100 //! Get the current COM1 active frequency in kHz
101 int getCom1Active() const;
102
103 //! Get the current COM1 standby frequency in kHz
104 int getCom1Standby() const;
105
106 //! Get the current COM2 active frequency in kHz
107 int getCom2Active() const;
108
109 //! Get the current COM2 standby frequency in kHz
110 int getCom2Standby() const;
111
112 //! Get the current transponder code in decimal
113 int getTransponderCode() const;
114
115 //! Get the current transponder mode (depends on the aircraft, 0-2 usually mean standby, >2 active)
116 int getTransponderMode() const;
117
118 //! Get whether we are currently squawking ident
119 bool getTransponderIdent() const;
120
121 //! Get whether beacon lights are on
122 bool getBeaconLightsOn() const;
123
124 //! Get whether landing lights are on
125 bool getLandingLightsOn() const;
126
127 //! Get whether nav lights are on
128 bool getNavLightsOn() const;
129
130 //! Get whether strobe lights are on
131 bool getStrobeLightsOn() const;
132
133 //! Get whether taxi lights are on
134 bool getTaxiLightsOn() const;
135
136 //! Get pressure altitude in ft
137 double getPressAlt() const;
138
139 //! Set the current COM1 active frequency in kHz
140 void setCom1Active(int freq);
141
142 //! Set the current COM1 standby frequency in kHz
143 void setCom1Standby(int freq);
144
145 //! Set the current COM2 active frequency in kHz
146 void setCom2Active(int freq);
147
148 //! Set the current COM2 standby frequency in kHz
149 void setCom2Standby(int freq);
150
151 ////! Set the current transponder code in decimal
152 void setTransponderCode(int code);
153
154 ////! Set the current transponder mode (depends on the aircraft, 0 and 1 usually mean standby, >1 active)
155 void setTransponderMode(int mode);
156
157 //! Get flaps deploy ratio, where 0.0 is flaps fully retracted, and 1.0 is flaps fully extended.
158 double getFlapsDeployRatio() const;
159
160 //! Get gear deploy ratio, where 0 is up and 1 is down
161 double getGearDeployRatio() const;
162
163 //! Get the number of engines of current aircraft
164 int getNumberOfEngines() const;
165
166 //! Get the N1 speed as percent of max (per engine)
167 std::vector<double> getEngineN1Percentage() const;
168
169 //! Get the ratio how much the speedbrakes surfaces are extended (0.0 is fully retracted, and 1.0 is fully extended)
170 double getSpeedBrakeRatio() const;
171
172 //! Get ground elevation at aircraft current position
173 double getGroundElevation() const;
174
175 //! Get x velocity in m/s
176 double getVelocityX() const;
177
178 //! Get y velocity in m/s
179 double getVelocityY() const;
180
181 //! Get z velocity in m/s
182 double getVelocityZ() const;
183
184 //! Get roll rate in rad/sec
185 double getRollRate() const;
186
187 //! Get pitch rate in rad/sec
188 double getPitchRate() const;
189
190 //! Get yaw rate in rad/sec
191 double getYawRate() const;
192
193 double getCom1Volume() const;
194 double getCom2Volume() const;
195
196 //! Perform generic processing
197 int process();
198
199 protected:
200 DBusHandlerResult dbusMessageHandler(const CDBusMessage& message) override;
201
202 private:
203 SGPropertyNode_ptr m_textMessageNode;
204 SGPropertyNode_ptr m_aircraftModelPathNode;
205 //SGPropertyNode_ptr aircraftLiveryNode;
206 //SGPropertyNode_ptr aircraftIcaoCodeNode;
207 SGPropertyNode_ptr m_aircraftDescriptionNode;
208 SGPropertyNode_ptr m_isPausedNode;
209 SGPropertyNode_ptr m_latitudeNode;
210 SGPropertyNode_ptr m_longitudeNode;
211 SGPropertyNode_ptr m_altitudeMSLNode;
212 SGPropertyNode_ptr m_heightAGLNode;
213 SGPropertyNode_ptr m_groundSpeedNode;
214 SGPropertyNode_ptr m_pitchNode;
215 SGPropertyNode_ptr m_rollNode;
216 SGPropertyNode_ptr m_trueHeadingNode;
217 SGPropertyNode_ptr m_wheelsOnGroundNode;
218 SGPropertyNode_ptr m_com1ActiveNode;
219 SGPropertyNode_ptr m_com1StandbyNode;
220 SGPropertyNode_ptr m_com2ActiveNode;
221 SGPropertyNode_ptr m_com2StandbyNode;
222 SGPropertyNode_ptr m_transponderCodeNode;
223 SGPropertyNode_ptr m_transponderModeNode;
224 SGPropertyNode_ptr m_transponderIdentNode;
225 SGPropertyNode_ptr m_beaconLightsNode;
226 SGPropertyNode_ptr m_landingLightsNode;
227 SGPropertyNode_ptr m_navLightsNode;
228 SGPropertyNode_ptr m_strobeLightsNode;
229 SGPropertyNode_ptr m_taxiLightsNode;
230 SGPropertyNode_ptr m_altimeterServiceableNode;
231 SGPropertyNode_ptr m_pressAltitudeFtNode;
232 SGPropertyNode_ptr m_flapsDeployRatioNode;
233 SGPropertyNode_ptr m_gearDeployRatioNode;
234 SGPropertyNode_ptr m_speedBrakeDeployRatioNode;
235 SGPropertyNode_ptr m_groundElevationNode;
236 //SGPropertyNode_ptr numberEnginesNode;
237 //SGPropertyNode_ptr engineN1PercentageNode;
238 SGPropertyNode_ptr m_aircraftNameNode;
239 SGPropertyNode_ptr m_velocityXNode;
240 SGPropertyNode_ptr m_velocityYNode;
241 SGPropertyNode_ptr m_velocityZNode;
242 SGPropertyNode_ptr m_rollRateNode;
243 SGPropertyNode_ptr m_pichRateNode;
244 SGPropertyNode_ptr m_yawRateNode;
245 SGPropertyNode_ptr m_com1VolumeNode;
246 SGPropertyNode_ptr m_com2VolumeNode;
247 };
248 } // namespace flightgear::swift