FlightGear next
service.h
Go to the documentation of this file.
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 <dev@ltoenning.de>
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
26namespace flightgear::swift {
27
31class CService : public CDBusObject
32{
33public:
35 CService();
36
38 static const std::string& InterfaceName();
39
41 static const std::string& ObjectPath();
42
44 static int getVersionNumber();
45
47 void addTextMessage(const std::string& text);
48
50 std::string getAircraftModelPath() const;
51
53 std::string getAircraftModelFilename() const;
54
56 std::string getAircraftModelString() const;
57
59 std::string getAircraftName() const;
60
62 std::string getAircraftLivery() const;
63
65 std::string getAircraftIcaoCode() const;
66
68 std::string getAircraftDescription() const;
69
71 bool isPaused() const;
72
74 double getLatitude() const;
75
77 double getLongitude() const;
78
80 double getAltitudeMSL() const;
81
83 double getHeightAGL() const;
84
86 double getGroundSpeed() const;
87
89 double getPitch() const;
90
92 double getRoll() const;
93
95 double getTrueHeading() const;
96
98 bool getAllWheelsOnGround() const;
99
101 int getCom1Active() const;
102
104 int getCom1Standby() const;
105
107 int getCom2Active() const;
108
110 int getCom2Standby() const;
111
113 int getTransponderCode() const;
114
116 int getTransponderMode() const;
117
119 bool getTransponderIdent() const;
120
122 bool getBeaconLightsOn() const;
123
125 bool getLandingLightsOn() const;
126
128 bool getNavLightsOn() const;
129
131 bool getStrobeLightsOn() const;
132
134 bool getTaxiLightsOn() const;
135
137 double getPressAlt() const;
138
140 void setCom1Active(int freq);
141
143 void setCom1Standby(int freq);
144
146 void setCom2Active(int freq);
147
149 void setCom2Standby(int freq);
150
152 void setTransponderCode(int code);
153
155 void setTransponderMode(int mode);
156
158 double getFlapsDeployRatio() const;
159
161 double getGearDeployRatio() const;
162
164 int getNumberOfEngines() const;
165
167 std::vector<double> getEngineN1Percentage() const;
168
170 double getSpeedBrakeRatio() const;
171
173 double getGroundElevation() const;
174
176 double getVelocityX() const;
177
179 double getVelocityY() const;
180
182 double getVelocityZ() const;
183
185 double getRollRate() const;
186
188 double getPitchRate() const;
189
191 double getYawRate() const;
192
193 double getCom1Volume() const;
194 double getCom2Volume() const;
195
197 int process();
198
199protected:
200 DBusHandlerResult dbusMessageHandler(const CDBusMessage& message) override;
201
202private:
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
CDBusObject()=default
Constructor.
std::string getAircraftIcaoCode() const
Get the ICAO code of the current aircraft model.
Definition service.cpp:101
std::string getAircraftLivery() const
Definition service.cpp:96
void setCom1Standby(int freq)
Set the current COM1 standby frequency in kHz.
Definition service.cpp:236
double getHeightAGL() const
Get aircraft height in feet.
Definition service.cpp:131
double getFlapsDeployRatio() const
Get flaps deploy ratio, where 0.0 is flaps fully retracted, and 1.0 is flaps fully extended.
Definition service.cpp:261
void setCom2Active(int freq)
Set the current COM2 active frequency in kHz.
Definition service.cpp:241
void setCom2Standby(int freq)
Set the current COM2 standby frequency in kHz.
Definition service.cpp:246
double getPressAlt() const
Get pressure altitude in ft.
Definition service.cpp:222
double getVelocityX() const
Get x velocity in m/s.
Definition service.cpp:318
double getAltitudeMSL() const
Get aircraft altitude in feet.
Definition service.cpp:126
void setTransponderCode(int code)
Definition service.cpp:251
bool getBeaconLightsOn() const
Get whether beacon lights are on.
Definition service.cpp:196
double getGroundSpeed() const
Get aircraft groundspeed in knots.
Definition service.cpp:136
void setTransponderMode(int mode)
Definition service.cpp:256
double getGroundElevation() const
Get ground elevation at aircraft current position.
Definition service.cpp:294
bool getStrobeLightsOn() const
Get whether strobe lights are on.
Definition service.cpp:212
double getPitch() const
Get aircraft pitch in degrees above horizon.
Definition service.cpp:141
bool getLandingLightsOn() const
Get whether landing lights are on.
Definition service.cpp:201
static const std::string & ObjectPath()
DBus object path.
Definition service.cpp:74
double getVelocityY() const
Get y velocity in m/s.
Definition service.cpp:323
DBusHandlerResult dbusMessageHandler(const CDBusMessage &message) override
DBus message handler.
Definition service.cpp:360
bool getTaxiLightsOn() const
Get whether taxi lights are on.
Definition service.cpp:217
std::string getAircraftModelFilename() const
Definition service.cpp:299
std::string getAircraftDescription() const
Definition service.cpp:106
std::string getAircraftModelPath() const
Definition service.cpp:91
void setCom1Active(int freq)
Set the current COM1 active frequency in kHz.
Definition service.cpp:231
int process()
Perform generic processing.
Definition service.cpp:627
int getTransponderMode() const
Get the current transponder mode (depends on the aircraft, 0-2 usually mean standby,...
Definition service.cpp:186
double getSpeedBrakeRatio() const
Get the ratio how much the speedbrakes surfaces are extended (0.0 is fully retracted,...
Definition service.cpp:289
int getCom2Active() const
Get the current COM2 active frequency in kHz.
Definition service.cpp:171
double getRollRate() const
Get roll rate in rad/sec.
Definition service.cpp:333
double getPitchRate() const
Get pitch rate in rad/sec.
Definition service.cpp:337
int getCom2Standby() const
Get the current COM2 standby frequency in kHz.
Definition service.cpp:176
int getTransponderCode() const
Get the current transponder code in decimal.
Definition service.cpp:181
static int getVersionNumber()
Getting flightgear version.
Definition service.cpp:80
std::vector< double > getEngineN1Percentage() const
Get the N1 speed as percent of max (per engine)
Definition service.cpp:277
double getTrueHeading() const
Get aircraft true heading in degrees.
Definition service.cpp:151
double getLatitude() const
Get aircraft latitude in degrees.
Definition service.cpp:116
double getVelocityZ() const
Get z velocity in m/s.
Definition service.cpp:328
std::string getAircraftModelString() const
Definition service.cpp:306
bool getAllWheelsOnGround() const
Get whether all wheels are on the ground.
Definition service.cpp:156
double getGearDeployRatio() const
Get gear deploy ratio, where 0 is up and 1 is down.
Definition service.cpp:266
bool isPaused() const
True if sim is paused.
Definition service.cpp:111
double getLongitude() const
Get aircraft longitude in degrees.
Definition service.cpp:121
double getYawRate() const
Get yaw rate in rad/sec.
Definition service.cpp:342
int getNumberOfEngines() const
Get the number of engines of current aircraft.
Definition service.cpp:271
int getCom1Active() const
Get the current COM1 active frequency in kHz.
Definition service.cpp:161
bool getNavLightsOn() const
Get whether nav lights are on.
Definition service.cpp:206
bool getTransponderIdent() const
Get whether we are currently squawking ident.
Definition service.cpp:191
double getCom2Volume() const
Definition service.cpp:352
double getRoll() const
Get aircraft roll in degrees.
Definition service.cpp:146
void addTextMessage(const std::string &text)
Definition service.cpp:85
int getCom1Standby() const
Get the current COM1 standby frequency in kHz.
Definition service.cpp:166
std::string getAircraftName() const
Definition service.cpp:313
static const std::string & InterfaceName()
DBus interface name.
Definition service.cpp:69
double getCom1Volume() const
Definition service.cpp:347