Avionics
Dropship Simulator
Bus.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Command.h"
4 #include "Nullable.h"
5 #include "Component.h"
6 #include "Message.h"
7 #include "Waypoint.h"
8 
10 #define enginesC 2
11 
12 class Bus
13 {
14 private:
16  std::vector<std::string> highlightElements;
17 
18 public:
19  bool isComparitor = false;
20  std::vector<Command> commandStream;
21 
22 #pragma region CAS
23  std::vector<Message> messages;
24  //bool MessageFlashState = false; /// @TODO could be moved to alert message stack renderer?
25 #pragma endregion
26 
29  D3DXVECTOR3 PlatformAcceleration = D3DXVECTOR3(-999, -999, -999); // astm 2291 compliance
30  double PlatformBackRightBellow = 0.0; // 0-10VDC
31  double PlatformBackLeftBellow = 0.0; // 0-10VDC
32  double PlatformFrontRightBellow = 0.0; // 0-10VDC
33  double PlatformFrontLeftBellow = 0.0; // 0-10VDC
35  float frameRate = 0.0f;
36  //double AvionicsBlowerMotor; // 0-10VDC
37 
39  _SYSTEMTIME Time; // (1) /// @TODO NEEDS TO BE INITIALIZED HERE?
40  float PressureAltitude = 0.0f; // (2)
42  float IndicatedAirspeed = 0.0f; // kms
44  float HeadingTrue = D3DXToRadian(240.0f); // in radians, initially 240
45  float HeadingTrack = D3DXToRadian(240.0f); // in radians, initially 240
47  D3DXVECTOR3 NormalAcceleration = D3DXVECTOR3(0, 0, 0); // G
49  float PitchAttitude = 0.0f; // radians
51  float RollAttitude = 0.0f; // radians
53  std::vector<bool> Transmitting; // one for each of TeamSpeakConfig::pttLocations
55  float EngineThrustOutput[enginesC]; // pounds /// @TODO NEEDS TO BE INITIALIZED HERE?
56 
57  float PitchControl = 0.0f, RollControl = 0.0f, YawControl = 0.0f; // (12-14) aggregated by FCS based on priority, etc... -1 to +1
58 
59  float DiscreetSurfacePostion[4]; // (15)
60  float RollControlSurfacePosition = 0.0f; // (16)
61  float YawControlSurfacePosition = 0.0f; // (17)
63  float PitchTrimSurfacePosition = 0.0f; // unused
65  float TrailingEdgeFlapsPosition = 0.0f; // unused
67  float LeadingEdgeFlapsPosition = 0.0f; // unused
68 
71 
73  float SpoilerPosition = 0.0f;
75  float OATorTAT = 2.0f; // defaulting it for engine tests
76 
78  struct Afcs
79  {
80  bool AutopilotEngaged = false; // (10) Autopilot engagement status;
81  bool AutothrottleEngaged = false;
82  float assistanceLevel = 1.0f; // 1.0f is
84  // full scale VOR is 10 degrees, LOC is 2.5 degrees, G/S is 0.72 degrees
85 
86  enum VerticalModes : int
87  {
90  Pitch = 1, // vs. Flight Path Angle or FPA?
94  Altitude = 5,
96  }
97  CurrentVerticalMode = VerticalModes::VerticalMode_Off,
98  StandbyVerticalMode = VerticalModes::VerticalMode_Off;
99 
100  enum LateralModes : int
101  {
104  Roll = 1,
105  Heading = 2,
108  }
109  CurrentLateralMode = LateralModes::LateralMode_Off, // (60) Primary Navigation System Reference;
110  StandbyLateralMode = LateralModes::LateralMode_Off;
111 
112  // (48) Selected altitude(when an information source is installed);
113  // (49) Selected speed(when an information source is installed);
114  // (50) Selected mach(when an information source is installed);
115  // (51) Selected vertical speed(when an information source is installed);
116  // (52) Selected heading(when an information source is installed);
117  // (53) Selected flight path(when an information source is installed); // I assume this is course?
118 
119  float DesiredVsi = 0.0f; // kms because VerticalSpeed is kms... but we will display it as m/s
120  float DesiredHeading = 0.0f; // radians
121  float DesiredCourse = 0.0f; // radians
122  float DesiredRoll = 0.0f; // for command bars in radians
123  float DesiredPitch = 0.0f; // for command bars in radians
124  float DesiredAltitude = 0.0f; // km
125  float DesiredThrust = 0.0f; // 0-1 for 0-100%
126 
127  float PitchInput = 0.0f;
128  float RollInput = 0.0f;
129  float YawInput = 0.0f;
130  }
131  AFCS;
132 
133 
134  float RadioAltitude = 0.0f; // (26) in km
135  float LocalizerDeviation = 0.0f; // (27) in radians
136  float GlideslopeDeviation = 0.0f; // (28) in radians
137 
140  {
145  }
147 
148  bool MasterWarning = false; // (30)
149  bool OnGround = true; // (31)
150  float AngleOfAttack = 0.0f; // (32) radians
151 
153 
154  float GroundSpeed = 0.0f; // (34)
155 
157  enum GpwsEnum : char
158  {
159  NoAlert = 0,
168  Mode2_Terrain = 8, // given until the terrain clearance stops decreasing
170  Mode3_Dont_Sink = 28, // was never implemented
176  Mode4c_Too_Low_Terrain = 14, // was never implemented
190  Mode6_Ten = 16,
195  Reset = 127
196  }
197  GPWS = GpwsEnum::NoAlert;
198 
199  bool LandingGearExtended = true; // (36)
200 
201  //(37) Drift angle (when an information source is installed);
202  //(38) Wind speed and direction (when an information source is installed);
203  //(39) Latitude and longitude (when an information source is installed);
204  float Latitude = 0.0f, Longitude = 0.0f;
205  //(40) Stick shaker/pusher (when an information source is installed);
206  //(41) Windshear (when an information source is installed);
207  //(43) Additional engine parameters (as designed in appendix E of this part);
208 
210  enum TcasEnum
211  {
217  }
218  TCAS = TcasEnum::Clear_Of_Conflict;
219 
220  /*
221  (45) DME 1 and 2 distances; // deprecated
222  (46) Nav 1 and 2 selected frequency; // deprecated
223  (47) Selected barometric setting (when an information source is installed);
224  (54) Selected decision height (when an information source is installed);
225  (55) EFIS display format;
226  (56) Multi-function/engine/alerts display format;
227  */
228 
230  //(42) Throttle/power lever position; what is the difference?
232 
233  /*
234  (58) Thrust target (when an information source is installed);
235  (59) Fuel quantity in CG trim tank (when an information source is installed);
236  (61) Icing (when an information source is installed);
237  (62) Engine warning each engine vibration (when an information source is installed);
238  (63) Engine warning each engine over temp. (when an information source is installed);
239  (64) Engine warning each engine oil pressure low (when an information source is installed);
240  (65) Engine warning each engine over speed (when an information source is installed);
241  (66) Yaw trim surface position;
242  (67) Roll trim surface position;
243  (68) Brake pressure (selected system);
244  (69) Brake pedal application (left and right);
245  (70) Yaw or sideslip angle (when an information source is installed);
246  (71) Engine bleed valve position (when an information source is installed);
247  (72) De-icing or anti-icing system selection (when an information source is installed);
248  (73) Computed center of gravity (when an information source is installed);
249  (74) AC electrical bus status;
250  (75) DC electrical bus status;
251  (76) APU bleed valve position (when an information source is installed);
252  (77) Hydraulic pressure (each system);
253  (78) Loss of cabin pressure;
254  (79) Computer failure;
255  (80) Heads-up display (when an information source is installed);
256  (81) Para-visual display (when an information source is installed);
257  */
258  // (82) Cockpit trim control input position—pitch;
259  float PitchTrim = 0.26f;
260  /*
261  (83) Cockpit trim control input position—roll;
262  (84) Cockpit trim control input position—yaw;
263  (85) Trailing edge flap and cockpit flap control position;
264  (86) Leading edge flap and cockpit flap control position;
265  (87) Ground spoiler position and speed brake selection;
266  (88) All cockpit flight control input forces (control wheel, control column, rudder pedal);
267  (89) Yaw damper status;
268  (90) Yaw damper command; and
269  (91) Standby rudder valve status.
270  */
271 
274  float VerticalSpeed = 0.0f; // kms
275  float FlightPathAngle = 0.0f; // radians
276  float AirDensity = 0.002377f; // this is SLP on Earth... what do we need for Venus scale height? 15.9 km vs Earth 8.5 km
278  float EmptyWeight = 40256.4f;
279  float FuelWeight = 10000.0f;
280  float PayloadWeight = 0.0f;
281  float GrossWeight() const // in pounds
282  {
285  }
286 
287 
289  double ProgramTime = 0.0; // from DirectX fTime
290  bool FlightFreeze = true;
291 
292  float ScenarioTimer = 0.0f;
293  std::string receiptNumber = "ABC123";
294  float ScenarioScore = 0.0f;
295 
296  float DisplayFps = 0.0f;
297 
300  bool IsDim(std::string elementName)
301  {
302  if (highlightElements.size() == 0) // not active
303  return false;
304 
305  if (elementName.empty()) // don't bother looking, he won't be in there
306  return true;
307 
308  for (UINT i = 0; i < highlightElements.size(); i++)
309  {
310  if (highlightElements.at(i) == elementName)
311  return false;
312  }
313 
314  return true;
315  }
316  bool IsVisible(std::string elementName)
317  {
318  if (highlightElements.size() == 0) // not active
319  return false;
320 
321  if (elementName.empty()) // don't bother looking, he won't be in there
322  return false;
323 
324  for (UINT i = 0; i < highlightElements.size(); i++)
325  {
326  if (highlightElements.at(i) == elementName)
327  return true;
328  }
329 
330  return false;
331  }
332  void AddHighlight(std::string elementName)
333  {
334  highlightElements.push_back(elementName);
335  }
336  void RemoveHighlight(std::string elementName)
337  {
338  for (UINT i = 0; i < highlightElements.size(); i++)
339  {
340  if (highlightElements.at(i) == elementName)
341  highlightElements.erase(highlightElements.begin() + i);
342  }
343  }
344  void ClearHelp()
345  {
346  highlightElements.clear();
347  }
351  // 29557.7 horizontally(I had to add 1000 feet lol)
352  // 1545 vertically (9L SFB ILS)
353  // so 8.7 plus .3km for the displaced touchdown is 9.0 km from touchdown
354  // we need to have vehicles
355  // any vehicle can have an ID,
356 
357 
358  // really just the easiest thing to do, we don't need lat/long much
359  D3DXVECTOR3 Location = D3DXVECTOR3(-57.0f / 180.0f * 19012.290420994710720528225226931f, 7.5f / 90.0f * 9506.1452104973553602641126134654f + 0.015f, -35.0f - 0.028f);
360 
362  float TerrainClosureRate = 0.0f;
363  float ObstacleClosureRate = 0.0f;
364 
366  std::vector<Vehicle> vehicles;
367  std::vector<Waypoint> waypoints;
368 
369 
371  std::vector<Systems::Component*> components;
372  Systems::Component* GetComponent(std::string guidStr);
373 
375  __declspec(deprecated) Nullable<float> GetComponentStateFloat(std::string guidStr);
376 
377  float* GetComponentCurrentStatePtr(std::string guidStr);
378  float* GetComponentSetStatePtr(std::string guidStr);
379  Systems::Fault* GetComponentFaultStatePtr(std::string guidStr);
380 
381  void FrameMove(float fElapsed, double fTime);
382  void AppendCommands(std::vector<Command>* commands);
383  bool IsCommandOnStack(std::string commandName);
384 
385  explicit Bus::Bus(Logger* prmLogger);
386 };
GpwsEnum
(35) Ground proximity warning system;
Definition: Bus.h:157
std::vector< std::string > highlightElements
Definition: Bus.h:16
float LeadingEdgeFlapsPosition
(21) Leading edge flap or cockpit flap control selection (except when parameters of paragraph (a)(86)...
Definition: Bus.h:67
float EngineThrustCommand[enginesC]
(57) Thrust command (when an information source is installed);
Definition: Bus.h:231
double PlatformFrontRightBellow
Definition: Bus.h:32
float EngineThrustOutput[enginesC]
(9) Thrust/power of each engine—primary flight crew reference;
Definition: Bus.h:55
bool IsVisible(std::string elementName)
Definition: Bus.h:316
std::vector< Message > messages
Definition: Bus.h:23
Unsafe terrain clearance with gear not down AND DECENDING.
Definition: Bus.h:172
float occupantPitchControlAuthority
Definition: Bus.h:298
double ProgramTime
Identified a need for these in modules.
Definition: Bus.h:289
float PressureAltitude
Definition: Bus.h:40
void ClearHelp()
Definition: Bus.h:344
float PitchInput
Definition: Bus.h:127
float occupantRollControlAuthority
Definition: Bus.h:299
(25) Automatic Flight Control System (AFCS) modes and engagement status, including autothrottle; ...
Definition: Bus.h:78
std::vector< Command > commandStream
Definition: Bus.h:20
float YawControl
Definition: Bus.h:57
float FuelWeight
pounds, dynamic later based on module weight calculation (stuff can get blown off) ...
Definition: Bus.h:279
double PlatformFrontLeftBellow
Definition: Bus.h:33
Definition: Logger.h:5
Systems::Fault * GetComponentFaultStatePtr(std::string guidStr)
Definition: Bus.cpp:141
Advisory callouts.
Definition: Bus.h:181
float RollControl
Definition: Bus.h:57
float Latitude
Definition: Bus.h:204
float DesiredThrust
Definition: Bus.h:125
enum Bus::GpwsEnum GPWS
Altitude Loss After TakeOff.
Definition: Bus.h:170
std::vector< Vehicle > vehicles
for TCAS, GPWS, FMS
Definition: Bus.h:366
enum Bus::Afcs::LateralModes CurrentLateralMode
Systems::Component * GetComponent(std::string guidStr)
Definition: Bus.cpp:77
Excessive barometric descent rate.
Definition: Bus.h:161
float RollControlSurfacePosition
Definition: Bus.h:60
std::vector< Waypoint > waypoints
Definition: Bus.h:367
Bus(Logger *prmLogger)
Definition: Bus.cpp:35
void AppendCommands(std::vector< Command > *commands)
Definition: Bus.cpp:41
float GroundSpeed
(33) hydraulic pressure LOW each loop
Definition: Bus.h:154
float EmptyWeight
needs to be configurable XML
Definition: Bus.h:278
float IndicatedAirspeed
(3) Indicated Airspeed in km per second?
Definition: Bus.h:42
Excessive deviation below glideslope.
Definition: Bus.h:178
float assistanceLevel
Definition: Bus.h:82
float DesiredAltitude
Definition: Bus.h:124
float PitchAttitude
(6) Pitch attitude;
Definition: Bus.h:49
float PitchControl
Definition: Bus.h:57
float DesiredHeading
Definition: Bus.h:120
float Longitude
Definition: Bus.h:204
float HeadingTrue
(4) Heading–primary flight crew reference (if selectable, record discrete, true or magnetic); ...
Definition: Bus.h:44
float PitchTrim
Definition: Bus.h:259
float AirDensity
Definition: Bus.h:276
std::vector< bool > Transmitting
(8) Manual radio transmitter keying, or CVR/DFDR synchronization reference;
Definition: Bus.h:53
float DesiredPitch
Definition: Bus.h:123
bool AutothrottleEngaged
Definition: Bus.h:81
TcasEnum
(44) Traffic alert and collision avoidance system;
Definition: Bus.h:210
float YawInput
Definition: Bus.h:129
Definition: Bus.h:12
D3DXVECTOR3 NormalAcceleration
(5) vertical (11) longitudinal (18) lateral
Definition: Bus.h:47
float PitchTrimSurfacePosition
(19) Pitch trim surface position or parameters of paragraph (a)(82) of this section if currently reco...
Definition: Bus.h:63
float OATorTAT
(24) Outside or total air temperature;
Definition: Bus.h:75
float RollAttitude
(7) Roll attitude;
Definition: Bus.h:51
float GrossWeight() const
pounds
Definition: Bus.h:281
bool ThrustReverser[enginesC]
(22) Each Thrust reverser position
Definition: Bus.h:70
float DesiredRoll
Definition: Bus.h:122
float HeadingTrack
Definition: Bus.h:45
float TerrainClosureRate
so we can get data into GPWS?
Definition: Bus.h:362
float DiscreetSurfacePostion[4]
Definition: Bus.h:59
#define enginesC
Data Bus.
Definition: Bus.h:10
float PayloadWeight
pounds, dynamic later as we burn fuel
Definition: Bus.h:280
void FrameMove(float fElapsed, double fTime)
Definition: Bus.cpp:3
float FlightPathAngle
Definition: Bus.h:275
bool FlightFreeze
Definition: Bus.h:290
LateralModes
Definition: Bus.h:100
bool LandingGearExtended
Definition: Bus.h:199
float RollInput
Definition: Bus.h:128
bool MasterWarning
Definition: Bus.h:148
enum Bus::TcasEnum TCAS
float RadioAltitude
Definition: Bus.h:134
float DisplayFps
Definition: Bus.h:296
bool OnGround
Definition: Bus.h:149
float AngleOfAttack
Definition: Bus.h:150
double PlatformBackLeftBellow
Definition: Bus.h:31
float TrailingEdgeFlapsPosition
(20) Trailing edge flap or cockpit flap control selection (except when parameters of paragraph (a)(85...
Definition: Bus.h:65
struct Bus::Afcs AFCS
MarkerBeacons
(29) Marker beacon passage;
Definition: Bus.h:139
enum Bus::Afcs::VerticalModes StandbyVerticalMode
float frameRate
Definition: Bus.h:35
std::string receiptNumber
Definition: Bus.h:293
float VerticalSpeed
Definition: Bus.h:274
float YawControlSurfacePosition
Definition: Bus.h:61
float DesiredVsi
Definition: Bus.h:119
int PlatformMotionSequencer
Definition: Bus.h:34
enum Bus::Afcs::VerticalModes CurrentVerticalMode
std::vector< Systems::Component * > components
SYSTEMS SUPPORT.
Definition: Bus.h:371
float DesiredCourse
Definition: Bus.h:121
float * GetComponentSetStatePtr(std::string guidStr)
Definition: Bus.cpp:109
D3DXVECTOR3 PlatformAcceleration
Definition: Bus.h:29
bool isComparitor
Definition: Bus.h:19
bool IsDim(std::string elementName)
Definition: Bus.h:300
bool AutopilotEngaged
Definition: Bus.h:80
bool IsCommandOnStack(std::string commandName)
Definition: Bus.cpp:67
void AddHighlight(std::string elementName)
Definition: Bus.h:332
enum Bus::MarkerBeacons MarkerBeacon
enum Bus::Afcs::LateralModes StandbyLateralMode
VerticalModes
so I guess we allow them to fly until they get to x degrees off
Definition: Bus.h:86
float ScenarioScore
Definition: Bus.h:294
Excessive terrain closure rate.
Definition: Bus.h:164
float ScenarioTimer
Definition: Bus.h:292
double PlatformBackRightBellow
Definition: Bus.h:30
float ObstacleClosureRate
Definition: Bus.h:363
float SpoilerPosition
NEEDS TO BE INITIALIZED HERE?
Definition: Bus.h:73
void RemoveHighlight(std::string elementName)
Definition: Bus.h:336
_SYSTEMTIME Time
this section is required flight data (FDR)
Definition: Bus.h:39
Definition: Bus.h:141
Logger * logger
Definition: Bus.h:15
float LocalizerDeviation
Definition: Bus.h:135
D3DXVECTOR3 Location
Definition: Bus.h:359
float GlideslopeDeviation
Definition: Bus.h:136