Rise
The Vieneo Province
Bus.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include "Logger.h"
5 #include <d3dx9math.h>
6 
7 #include "Command.h"
8 //#include "Nullable.h"
9 //#include "Component.h"
10 #include "Message.h"
11 #include "Viewscreen/globals.h"
12 #include "scanDb.h"
13 
14 #define MAX_ENGINES 3
15 
16 class Bus
17 {
19  //std::vector<std::string> highlightElements;
20 
21 public:
23  _SYSTEMTIME Time;
24 
25  float PressureAltitudeKm = 0.0f; // (2)
26 
27  float IndicatedAirspeedKms = 0.0f; // (3) brought online 5/22/2018
28 
29  // (4) Heading--primary flight crew reference (if selectable, record discrete, true or magnetic);
30  float HeadingTrueDegrees = 0.0f; // (4)
31  float HeadingMagneticDegrees = 0.0f; // used for the assay grid among other things
32 
33  // (5) vertical (11) longitudinal (18) lateral
34  D3DXVECTOR3 NormalAcceleration = D3DXVECTOR3(0, 0, 0); // G
35 
36  float PitchAttitudeRadians = 0.0f; // (6)
37  float RollAttitudeRadians = 0.0f; // (7)
38 
39  // (8) Manual radio transmitter keying, or CVR/DFDR synchronization reference;
40  //std::vector<bool> Transmitting; // one for each of TeamSpeakConfig::pttLocations
41 
42  // (9) Thrust/power of each engine—primary flight crew reference;
44 
45  // (12) Pitch control input;
46  // (13) Lateral control input;
47  // (14) Rudder pedal input;
48  // (15) Primary pitch control surface position;
49  // (16) Primary lateral control surface position;
50  // (17) Primary yaw control surface position;
51 
52  // (19) Pitch trim surface position or parameters of paragraph (a)(82) of this section if currently recorded;
54 
55  // (20) Trailing edge flap or cockpit flap control selection (except when parameters of paragraph (a)(85) of this section apply);
56  UINT flapSettingTE = 0; // in flapSettings vector
57  // (21) Leading edge flap or cockpit flap control selection (except when parameters of paragraph (a)(86) of this section apply);
58  UINT flapSettingLE = 0; // in flapSettings vector
59 
60  // (22) Each Thrust reverser position
62 
63  // (23) Ground spoiler position or speed brake selection (except when parameters of paragraph (a)(87) of this section apply);
64 
65  // (24) Outside or total air temperature;
66  float StaticAirTemperatureCelsius = 0.0f; // brought online 5/22/2018
67  float OutsideAirTemperatureKelvin = 0.0f; // brought online 5/22/2018
68  float TotalAirTemperatureCelsius = 0.0f; // brought online 5/22/2018
69  float AirframeTemperatureCelsius = -1.0f; // brought online 5/22/2018
70 
72  struct Afcs
73  {
74  bool AutopilotEngaged = false; // (10) Autopilot engagement status;
75  bool AutothrottleEngaged = false;
76  //float assistanceLevel = 1.0f; // 1.0f is
78  // full scale VOR is 10 degrees, LOC is 2.5 degrees, G/S is 0.72 degrees
79 
80  enum VerticalModes : int
81  {
84  Pitch = 1, // vs. Flight Path Angle or FPA?
91  } CurrentVerticalMode = VerticalModes::VerticalMode_Off,
92  StandbyVerticalMode = VerticalModes::VerticalMode_Off;
93 
94  enum LateralModes : int
95  {
98  Roll = 1,
99  Heading = 2,
103  } CurrentLateralMode = LateralModes::LateralMode_Off, // (60) Primary Navigation System Reference;
104  StandbyLateralMode = LateralModes::LateralMode_Off;
105 
106  // (48) Selected altitude(when an information source is installed);
107  // (49) Selected speed(when an information source is installed);
108  // (50) Selected mach(when an information source is installed);
109  // (51) Selected vertical speed(when an information source is installed);
110  // (52) Selected heading(when an information source is installed);
111  // (53) Selected flight path(when an information source is installed); // I assume this is course?
112 
113  float DesiredVsiKms = 0.0f;
114  float DesiredHeadingRadians = 0.0f;
115  float DesiredCourseRadians = 0.0f;
116  float DesiredRollRadians = 0.0f; // for command bars
117  float DesiredPitchRadians = 0.0f; // for command bars
118  float DesiredAltitudeKm = 0.0f;
119  float DesiredThrust = 0.0f; // 0-1 for 0-100%
120  float DesiredIasKms = 0.0f;
121 
122  float PitchInput = 0.0f;
123  float RollInput = 0.0f;
124  float YawInput = 0.0f;
125 
126  bool TvmOn = false;
127  float DesiredClosingSpeed = 0.0f;
129 
130  bool DorOn = false;
131 
132  } AFCS;
133 
135  float LocalizerDeviationRadians = 0.0f; // (27) in radians
136  float GlideslopeDeviationRadians = 0.0f; // (28) in radians
137 
140  {
145 
146  } MarkerBeacon = MarkerBeaconTypes::None;
147 
148  bool MasterWarning = false; // (30)
149 
150  bool OnGround = true; // (31)
151 
152  float AngleOfAttackRadians = 0.0f; // (32)
153 
154  // (33) hydraulic pressure LOW each loop
155 
156  float GroundSpeedKms = 0.0f; // (34)
157 
158  // (35) Ground proximity warning system;
159  // @ref https://skybrary.aero/bookshelf/books/3364.pdf
160  struct Gpws
161  {
162  float TerrainClosureRate = 0.0f;
163  float ObstacleClosureRate = 0.0f;
164  enum GpwsEnum : char
165  {
167 
168  // very important! these are in order of highest to lowest priority so we need an upper bound to compare against
175  // @todo V1
176  // @todo Engine Fail
177  // @todo TA terrain, terrain pull up
178  // @todo TA obstacle, obstacle pull up
194  // @todo Speed brake, speed brake
201  // @todo Approaching Minimums
204  // @todo Autopilot
205  // @todo Airspeed Low, Airspeed Low
206  // @todo Flaps, Flaps
207  // @todo Too High, Too High
208  // @todo Too Fast, Too Fast
209  // @todo Flaps (pause Flaps" or "Flaps, Flaps"
210  // @todo Unstable, Unstable"
211  // @todo Altimeter Setting, Altimeter Setting
212  // @todo RAAS advisoryies
213  // @todo RAAS distance remaining callouts
214 
215  // These aren't enumerated in the priority list??
219 
221  } Alert = GpwsEnum::NoAlert;
222  } GPWS;
223 
224  float LandingGearExtended = 0.0f; // (36)
225 
226  float HeadingTrackDegrees = 0.0f; // (37)
227 
228  // (38) Wind speed and direction (when an information source is installed);
229  float WindDirectionDegrees = 0.0f;
230  float WindSpeedMs = 0.0f;
231  float WindUpdraftMs = 0.0f;
232 
233  // (39) Latitude and longitude (when an information source is installed);
234  float LatitudeDeg = 0.0f, LongitudeDeg = 0.0f;
235  float LatitudeRad = 0.0f;
236  VECTOR2SHORT tcp;
237 
238  // (40) Stick shaker/pusher (when an information source is installed);
239  // (41) Windshear (when an information source is installed);
240  // (43) Additional engine parameters (as designed in appendix E of this part);
241 
242  // (44) Traffic alert and collision avoidance system;
243  enum TcasEnum
244  {
247  RA_Climb = 2,
251  } TCAS = TcasEnum::Clear_Of_Conflict;
252  short TCASTargetOrdinal = -1;
253 
254  /*
255  (45) DME 1 and 2 distances; // deprecated
256  (46) Nav 1 and 2 selected frequency; // deprecated
257  (47) Selected barometric setting (when an information source is installed);
258  (54) Selected decision height (when an information source is installed);
259  (55) EFIS display format;
260  (56) Multi-function/engine/alerts display format;
261  */
262 
263  //(42) Throttle/power lever position; what is the difference?
265 
266  //(57) Thrust command (when an information source is installed);
268 
269  //(58) Thrust target (when an information source is installed);
270 
271  //(59) Fuel quantity in CG trim tank (when an information source is installed);
272 
273  //(61) Icing (when an information source is installed);
274  bool IceDetected = false;
275  float IceDetectorMm = 0.0f; // mm accrued... automatically cycles to melt every X seconds ... sensitivity is 0.0254 but triggers CAS at 0.5
276  bool IceDetectorHeat = false;
277 
278  /*
279  (62) Engine warning each engine vibration (when an information source is installed);
280  (63) Engine warning each engine over temp. (when an information source is installed);
281  (64) Engine warning each engine oil pressure low (when an information source is installed);
282  (65) Engine warning each engine over speed (when an information source is installed);
283  (66) Yaw trim surface position;
284  (67) Roll trim surface position;
285  (68) Brake pressure (selected system);
286  */
287 
288  //(69) Brake pedal application (left and right);
289  float LeftBrake = 0.0f, RightBrake = 0.0f;
290 
291  /*
292  (70) Yaw or sideslip angle (when an information source is installed);
293  (71) Engine bleed valve position (when an information source is installed);
294  */
295 
296  bool AntiIce = false; // (72)
297 
298  /*
299  (73) Computed center of gravity (when an information source is installed);
300  (74) AC electrical bus status;
301  (75) DC electrical bus status;
302  (76) APU bleed valve position (when an information source is installed);
303  (77) Hydraulic pressure (each system);
304  */
305 
306  // (78) Loss of cabin pressure;
307  float CabinPressureMb = SeaLevelPressureMb; // @todo needs to be initialized from server?
308 
309  /*
310  (79) Computer failure;
311  (80) Heads-up display (when an information source is installed);
312  (81) Para-visual display (when an information source is installed);
313  */
314 
315  // (82) Cockpit trim control input position—pitch;
316  float PitchTrimScalar = 0.0f; // -1 to +1 for -15 degrees to +15 degrees
317 
318  /*
319  (83) Cockpit trim control input position—roll;
320  (84) Cockpit trim control input position—yaw;
321  */
322 
323  //(85) Trailing edge flap and cockpit flap control position;
324  float TrailingEdgeFlapsPosition = 0.0f; // degrees
325  //(86) Leading edge flap and cockpit flap control position;
326  float LeadingEdgeFlapsPosition = 0.0f; // degrees
327 
328 
329  //(87) Ground spoiler position and speed brake selection;
330  //(88) All cockpit flight control input forces (control wheel, control column, rudder pedal);
331 
332  //(89) Yaw damper status;
333  bool YawDamperStatus = true;
334 
335  //(90) Yaw damper command; and
336  float YawDamperCommand = 0.0f;
337 
338  //(91) Standby rudder valve status.
339 
340 
341 
342  std::vector<Command> commandStream;
343  void AddCommand(Command command, bool onlyOne);
344 
345  std::vector<Message> messages; // CAS
346 
347  // this section is for internal and environmental
348  float TrueAirspeedKms = 0.0f; // brought online 5/22/2018
349  // Surprisingly, VSI wasn't in the list of FDR parameters, probably because it can be deduced from change in altitude over time
350  // more likely it is the vertical acceleration converted to fpm
351  float VerticalSpeedKms = 0.0f;
353  float AirDensityScalar = 1.0f; // sea level default, brought online 5/22/2018
354  float DynamicPressure = 0.0f; // brought online 5/22/2018
355  float LinearVelocityKms = 0.0f; // relative to vieneo, shows 300 m/s on the surface, added 5/22/2018
356  float Mach = 0.0f; // brought online 5/22/2018
357  float SpeedOfSoundKms = 0.0f; // brought online 5/22/2018
358  float LocalTimeHours = 11.0f;
359  float LocalTimeMinutes = 32.0f;
360 
361  float EmptyWeightLbs = 0.0f;
362  float FuelWeightLbs = 0.0f;
363  float FuelFlowKgh = 0.0f;
364  float PayloadWeightLbs = 0.0f;
365  unsigned short CargoBays[MAX_PODSPERSHIP];
366  float GrossWeight() const noexcept // in pounds
367  {
368  // we could actually be below emptyweight if we lose parts ... empty weight will likely be a calculation based on modules
370  }
371 
372  // Identified a need for these in modules
373  double ProgramTime = 0.0; // from DirectX fTime
374  bool FlightFreeze = false;
375  bool MasterCaution = false; // MasterWarning is part of FDR but not MasterCaution
376  bool ProximityAlert = false; // for Floating Man
377 
378  short targetC; // current scanner target
380 
381  float MapScaleInnerRingKm = 25; // if we add more of these they can go in a MfdSettings container
382  bool ComponentRcsRollFail = false;
383  bool ComponentFcsRollFail = false;
384 
385  SAssayGrid assayGrid;
386  float assayQuality = 0.0f;
387  float assayProgressU = 0.0f, assayProgressV = 0.0f;
388 
389  // for Modules like TCAS, GPWS, and FMS
390  int WPtargetC; // current waypoint
391  std::vector<Swaypoint> waypoint;
394  char TimeToNextFix[6];
395 
396  // These are special for a vector-based instrument StreetView
397  std::vector<Snode> nodes;
398  bool turnByTurnDirty = false;
399  unsigned char turnByTurnRoutingType = 0; // 0 is NONE, 1 is complete, 2 is closest approach
402 
403  void FrameMove(float fElapsed);
404 
405  explicit Bus::Bus(Logger* prmLogger);
406 
407  // DEBUGGING
408  float DebugFloat1 = 0.0f;
409  float DebugFloat2 = 0.0f;
410  float DebugFloat3 = 0.0f;
411  float DebugFloat4 = 0.0f;
412  float DebugFloat5 = 0.0f;
413  float DebugFloat6 = 0.0f;
414  float DebugFloat7 = 0.0f;
415  float DebugFloat8 = 0.0f;
416  float DebugFloat9 = 0.0f;
417  D3DXVECTOR3 Debug1Vec3 = centerC;
418  D3DXVECTOR3 Debug2Vec3 = centerC;
419  char DebugString[MAX_PATH];
422 };
float Mach
Definition: Bus.h:356
float LeadingEdgeFlapsPosition
Definition: Bus.h:326
std::vector< Message > messages
Definition: Bus.h:345
float TerrainClosureRate
Definition: Bus.h:162
float PitchTrimScalar
Definition: Bus.h:316
bool AntiIce
Definition: Bus.h:296
#define MAX_ENGINES
Definition: Bus.h:14
double ProgramTime
Definition: Bus.h:373
float LocalTimeMinutes
Definition: Bus.h:359
Definition: Bus.h:141
UINT flapSettingTE
Definition: Bus.h:56
float LatitudeRad
Definition: Bus.h:235
Definition: Bus.h:160
short TCASTargetOrdinal
Definition: Bus.h:252
enum Bus::Gpws::GpwsEnum Alert
float PitchInput
Definition: Bus.h:122
float LandingGearExtended
Definition: Bus.h:224
float DesiredVsiKms
Definition: Bus.h:113
float turnByTurnTotalDistanceMeters
Definition: Bus.h:400
struct Bus::Afcs AFCS
float RightBrake
Definition: Bus.h:289
float HeadingTrueDegrees
Definition: Bus.h:30
float SpeedOfSoundKms
Definition: Bus.h:357
(25) Automatic Flight Control System (AFCS) modes and engagement status, including autothrottle; ...
Definition: Bus.h:72
MarkerBeaconTypes
(29) Marker beacon passage;
Definition: Bus.h:139
std::vector< Command > commandStream
Definition: Bus.h:342
float TvmCurrentClosingSpeed
Definition: Bus.h:128
#define cloudTopsMslC
Definition: globals.h:92
float FuelWeightLbs
Definition: Bus.h:362
float DynamicPressure
Definition: Bus.h:354
Definition: Logger.h:9
float turnByTurnTotalTimeSeconds
Definition: Bus.h:401
float DebugFloat7
Definition: Bus.h:414
enum Bus::Afcs::LateralModes CurrentLateralMode
Definition: Module.h:443
scanDb Scanner
Definition: Bus.h:379
float DesiredThrust
Definition: Bus.h:119
char DebugString[MAX_PATH]
Definition: Bus.h:419
Definition: scanDb.h:53
bool DorOn
Definition: Bus.h:130
float RadioAltitudeKm
Definition: Bus.h:134
float WindDirectionDegrees
Definition: Bus.h:229
float VerticalSpeedKms
Definition: Bus.h:351
float assayProgressU
Definition: Bus.h:387
bool ComponentRcsRollFail
Definition: Bus.h:382
float RollAttitudeRadians
Definition: Bus.h:37
float EmptyWeightLbs
Definition: Bus.h:361
float DebugFloat6
Definition: Bus.h:413
float DesiredCourseRadians
Definition: Bus.h:115
Bus(Logger *prmLogger)
Definition: Bus.cpp:47
float IceDetectorMm
Definition: Bus.h:275
float TargetDistanceKm
Definition: Bus.h:393
float PayloadWeightLbs
Definition: Bus.h:364
void AddCommand(Command command, bool onlyOne)
Definition: Bus.cpp:3
GpwsEnum
Definition: Bus.h:164
float AngleOfAttackRadians
Definition: Bus.h:152
float GlideslopeDeviationRadians
Definition: Bus.h:136
UINT flapSettingLE
Definition: Bus.h:58
float DebugSoundReal
Definition: Bus.h:420
float DesiredRollRadians
Definition: Bus.h:116
float PressureAltitudeKm
Definition: Bus.h:25
float DesiredIasKms
Definition: Bus.h:120
bool ComponentFcsRollFail
Definition: Bus.h:383
float DebugFloat5
Definition: Bus.h:412
D3DXVECTOR3 Debug2Vec3
Definition: Bus.h:418
bool AutothrottleEngaged
Definition: Bus.h:75
TcasEnum
Definition: Bus.h:243
float DebugCeiling
Definition: Bus.h:421
float DebugFloat9
Definition: Bus.h:416
float YawInput
Definition: Bus.h:124
Definition: Bus.h:16
D3DXVECTOR3 NormalAcceleration
Definition: Bus.h:34
float DesiredClosingSpeed
Definition: Bus.h:127
bool IceDetected
Definition: Bus.h:274
bool ThrustReverserCommand[MAX_ENGINES]
Definition: Bus.h:61
float LocalizerDeviationRadians
Definition: Bus.h:135
float HeadingTrackDegrees
Definition: Bus.h:226
float DesiredPitchRadians
Definition: Bus.h:117
#define SeaLevelPressureMb
Definition: globals.h:85
float IndicatedAirspeedKms
Definition: Bus.h:27
float AirDensityScalar
Definition: Bus.h:353
float WindUpdraftMs
Definition: Bus.h:231
float DebugFloat2
Definition: Bus.h:409
float WindSpeedMs
Definition: Bus.h:230
float DebugFloat3
Definition: Bus.h:410
float assayQuality
Definition: Bus.h:386
float LinearVelocityKms
Definition: Bus.h:355
float MapScaleInnerRingKm
Definition: Bus.h:381
bool FlightFreeze
Definition: Bus.h:374
LateralModes
Definition: Bus.h:94
float assayProgressV
Definition: Bus.h:387
enum Bus::MarkerBeaconTypes MarkerBeacon
unsigned char turnByTurnRoutingType
Definition: Bus.h:399
float AirframeTemperatureCelsius
Definition: Bus.h:69
float DebugSoundBear
Definition: Bus.h:420
float DebugSoundFake
Definition: Bus.h:420
float RollInput
Definition: Bus.h:123
float DebugTurbidity
Definition: Bus.h:421
struct Bus::Gpws GPWS
float EngineThrustOutput[MAX_ENGINES]
Definition: Bus.h:43
Definition: Command.h:5
short targetC
Definition: Bus.h:378
bool MasterWarning
Definition: Bus.h:148
float LongitudeDeg
Definition: Bus.h:234
float DebugFloat1
Definition: Bus.h:408
bool OnGround
Definition: Bus.h:150
float EngineThrustCommand[MAX_ENGINES]
Definition: Bus.h:267
enum Bus::Afcs::VerticalModes CurrentVerticalMode
const D3DXVECTOR3 centerC
float TrailingEdgeFlapsPosition
Definition: Bus.h:324
float LatitudeDeg
Definition: Bus.h:234
float GrossWeight() const noexcept
Definition: Bus.h:366
D3DXVECTOR3 Debug1Vec3
Definition: Bus.h:417
enum Bus::Afcs::VerticalModes StandbyVerticalMode
float DesiredAltitudeKm
Definition: Bus.h:118
bool MasterCaution
Definition: Bus.h:375
unsigned short CargoBays[MAX_PODSPERSHIP]
Definition: Bus.h:365
bool turnByTurnDirty
Definition: Bus.h:398
float PitchTrimSurfacePositionDegrees
Definition: Bus.h:53
void FrameMove(float fElapsed)
Definition: Bus.cpp:15
float ObstacleClosureRate
Definition: Bus.h:163
bool TvmOn
Definition: Bus.h:126
float YawDamperCommand
Definition: Bus.h:336
bool YawDamperStatus
Definition: Bus.h:333
float LocalTimeHours
Definition: Bus.h:358
float DebugSoundClose
Definition: Bus.h:420
float DesiredHeadingRadians
Definition: Bus.h:114
float OutsideAirTemperatureKelvin
Definition: Bus.h:67
char TimeToNextFix[6]
Definition: Bus.h:394
float CabinPressureMb
Definition: Bus.h:307
std::vector< Snode > nodes
Definition: Bus.h:397
float GroundSpeedKms
Definition: Bus.h:156
float TotalAirTemperatureCelsius
Definition: Bus.h:68
std::vector< Swaypoint > waypoint
Definition: Bus.h:391
bool AutopilotEngaged
Definition: Bus.h:74
float DebugFloat8
Definition: Bus.h:415
float DebugTurbulence
Definition: Bus.h:421
enum Bus::Afcs::LateralModes StandbyLateralMode
VerticalModes
so I guess we allow them to fly until they get to x degrees off
Definition: Bus.h:80
float LeftBrake
Definition: Bus.h:289
int WPtargetC
Definition: Bus.h:390
VECTOR2SHORT tcp
Definition: Bus.h:236
D3DXVECTOR3 lastWaypointLocation
Definition: Bus.h:392
bool IceDetectorHeat
Definition: Bus.h:276
bool ProximityAlert
Definition: Bus.h:376
float DebugFloat4
Definition: Bus.h:411
_SYSTEMTIME Time
(1) Time (UTC when available, otherwise elapsed time)
Definition: Bus.h:23
SAssayGrid assayGrid
Definition: Bus.h:385
float StaticAirTemperatureCelsius
Definition: Bus.h:66
float FlightPathAngleRadians
Definition: Bus.h:352
float PitchAttitudeRadians
Definition: Bus.h:36
Logger * logger
Definition: Bus.h:18
float FuelFlowKgh
Definition: Bus.h:363
float HeadingMagneticDegrees
Definition: Bus.h:31
float EngineThrustLever[MAX_ENGINES]
Definition: Bus.h:264
float TrueAirspeedKms
Definition: Bus.h:348