Rise
The Vieneo Province
Loading...
Searching...
No Matches
GPWS.cpp
Go to the documentation of this file.
1#include "Module.h"
3#include "../MathUtilities.h"
4
12
13// MESSAGE MODE
14// 100 “Windshear, Windshear, Windshear” d, j ..................................................7
15// 101 “Pull Up” k .............................................................................1, 2
16// 102 “Terrain, Terrain” ......................................................................2
17// 103 “V1” c ..................................................................................ANN
18// 104 “Engine Fail” c .........................................................................ANN
19// 105 “Terrain, Terrain Pull Up” h, k .........................................................TA
20// 106 “Obstacle, Obstacle Pull Up” c, i, k ....................................................TA
21// 107 “Terrain” ...............................................................................2
22// 108 “Minimums” a, c .........................................................................6
23// 109 “Caution Terrain, Caution Terrain” c, f .................................................TA
24// 110 “Caution Obstacle, Caution Obstacle” c, g ...............................................TA
25// 111 “Too Low Terrain” .......................................................................4, TCF
26// 112 Altitude Callouts c .....................................................................6
27// 113 “Speed Brake, Speed Brake” c ............................................................6
28// 114 “Too Low Gear” ..........................................................................4A
29// 115 “Too Low Flaps” .........................................................................4B
30// 116 “Sink Rate, Sink Rate” ..................................................................1
31// 117 “Don’t Sink, Don’t Sink” ................................................................3
32// 118 “Glideslope” ............................................................................5
33// 119 “Approaching Minimums” b, c .............................................................6
34// 120 “Bank Angle, Bank Angle” c ..............................................................6
35// 121 “Caution Windshear” c, d, e .............................................................7
36// 122 “Autopilot” c ...........................................................................6
37// 123 “Airspeed Low, Airspeed Low” c ..........................................................MON
38// 124 “Flaps, Flaps” c ........................................................................6
39// 125 “Too High, Too High” ....................................................................MON
40// 126 “Too Fast, Too Fast” ....................................................................MON
41// 127 “Flaps(pause) Flaps” or “Flaps, Flaps” ..................................................MON
42// 128 “Unstable, Unstable” ....................................................................MON
43// 129 “Altimeter Setting, Altimeter Setting” ..................................................MON
44// 130 RAAS Advisories .........................................................................RAAS
45// 131 RAAS Distance Remaining Callouts ........................................................RAAS
46
47Gpws::Gpws(Bus* prmBus, Logger* prmLogger, Viewscreen* prmViewscreen) : Module(prmBus), viewscreen(prmViewscreen)
48{
49 logger = prmLogger;
50}
51
52void Gpws::FrameMove(float fElapsed)
53{
54 Rendering::ProfileCpuScope11 timing("GPWS module");
55 Evaluate(fElapsed);
56 const bool popup = bus->GPWS.TerrainDisplayActive() && bus->GPWS.autoRange &&
58 if (popup && !terrainRangeActive)
59 {
61 // Match the discrete kilometer ranges accepted by the map zoom keys.
63 }
65 terrainRangeActive = popup;
66}
67
68void Gpws::Evaluate(float fElapsed)
69{
70 const bool airborne = playerships[0].reference == REF_APNMODE || playerships[0].reference == REF_ACLMODE;
71 const bool powered = !playerships[0].groundvehicle && std::isfinite(ourcockpit.power) && ourcockpit.power >= .5f;
72 if (std::isfinite(fElapsed) && fElapsed > 0) bus->GPWS.testMessageSeconds = (std::max)(0.f,bus->GPWS.testMessageSeconds-fElapsed);
73 ProcessControls(powered,airborne);
74 const auto previousAlert = bus->GPWS.Alert;
75 UpdateTerrainAwareness(fElapsed);
78 if (UpdateSelfTest(fElapsed,powered,airborne)) { reactiveReady = false; windshear.Reset(); return; }
79 if (!TerrainAwareness::DisplayAllowed(playerships[0].isSimulator, playerships[0].groundvehicle, ourcockpit.power))
81 if (!airborne || bus->GPWS.inhibited) bus->GPWS.terrain.ClearThreats();
82 if (!bus->GPWS.terrain.enabled)
83 {
86 }
87 if (playerships[0].groundvehicle || !std::isfinite(ourcockpit.power) || ourcockpit.power < 0.5f)
88 {
91 reactiveReady = false;
92 bus->commandStream.erase(std::remove_if(bus->commandStream.begin(),bus->commandStream.end(),
93 [](const Command& c) { return c.sValue == "GPWSPredictiveWind" || c.sValue == "GPWSReactive" || c.sValue == "GPWSAltitude" || c.sValue == "GPWSTerrain" || c.sValue == "GPWSTestAudio"; }),bus->commandStream.end());
94 return;
95 }
96 if (!std::isfinite(fElapsed) || fElapsed <= 0)
97 {
102 return;
103 }
104
105 // Clouds do not inhibit a radio-altimeter or terrain-awareness instrument.
107 const bool radioValid = !(bus->GPWS.faults&1);
108 const bool motionValid = radioValid && !(bus->GPWS.faults&2);
109 const bool reset = !reactiveReady || reactiveVehicle != playerships[0].vehicleId;
110 const bool liftedOff = !reset && oldReference == REF_ONGROUND && airborne;
111 const bool goAround = !reset && airborne && radioValid && bus->RadioAltitudeKm < .074676f &&
113 if (reset || !airborne || !motionValid)
114 {
119 takeoffSeconds = 61; mode2WasWarning = false; bus->GPWS.mode2Latch = false;
124 bus->commandStream.erase(std::remove_if(bus->commandStream.begin(),bus->commandStream.end(),
125 [](const Command& c) { return c.sValue == "GPWSPredictiveWind" || c.sValue == "GPWSReactive" || c.sValue == "GPWSAltitude" || c.sValue == "GPWSTerrain"; }),bus->commandStream.end());
126 }
127 if (liftedOff || goAround)
128 {
129 takeoffPhase = mode3active = true;
132 if (liftedOff) takeoffSeconds = 0;
134 }
135 reactiveReady = motionValid;
137 oldReference = static_cast<Reference>(playerships[0].reference);
139 if (airborne) takeoffSeconds += fElapsed;
140 secsincelast += fElapsed;
142 terrainVoiceSeconds = (std::min)(terrainVoiceSeconds+fElapsed,60.f);
143 groundclose = motionValid && !reset ? (bus->RadioAltitudeKm-oldRadioAltitudeKm)/fElapsed : 0;
145 const bool landingFlaps = bus->GPWS.flapOverride || ourcockpit.flapSettings.empty() || bus->TrailingEdgeFlapsPosition >= 20.f;
146 const bool landingConfiguration = playerships[0].geardown && landingFlaps;
147 const bool tadAvailable = bus->GPWS.positionValid && bus->GPWS.terrain.enabled && bus->GPWS.terrain.terrainComplete &&
149 const bool ilsValid = std::isfinite(bus->GlideslopeDeviationRadians) &&
152 bool frontCourse = ilsValid;
153 if (bus->WPtargetC >= 0 && size_t(bus->WPtargetC) < bus->waypoint.size())
154 {
155 const auto& runway = bus->waypoint[bus->WPtargetC];
156 frontCourse = ilsValid && runway.ils == 127 && runway.heading >= 0 && runway.heading <= 360 &&
157 std::isfinite(bus->HeadingTrackDegrees) && bus->HeadingTrackDegrees >= 0 &&
158 std::fabs(std::remainder(bus->HeadingTrackDegrees-runway.heading,360.f)) < 90;
159 }
160 const bool centeredIls = frontCourse && std::fabs(bus->GlideslopeDeviationRadians) < RiseMath::ToRadian(.7f) &&
162 bool nearDestination = false;
163 if (tadAvailable && bus->WPtargetC >= 0 && size_t(bus->WPtargetC) < bus->waypoint.size())
164 {
165 const auto& destination = bus->waypoint[bus->WPtargetC];
166 const auto delta = destination.location-playerships[0].position;
167 // p.13, -022 installation: configuration-independent airport vicinity.
168 // Use the selected received runway, not a possibly stale target range.
169 nearDestination = destination.type == 2 && destination.length > 0 &&
170 destination.heading >= 0 && destination.heading <= 360 &&
171 RiseMath::Vec3Length(&delta) <= 18.52f &&
172 std::fabs(playerships[0].mslKm-destination.elevationKm) <= 1.0668f;
173 }
174 const bool mode2b = landingFlaps || centeredIls || takeoffSeconds < 60 || nearDestination;
175
176 float penetration = 0;
177 const float floorPenetration = airborne ? ClearanceFloor() : 0;
178 if (!airborne) bus->GPWS.steepApproach = false;
179 if (airborne && motionValid)
180 {
181 // Instrument biases, not an aerodynamic escape-rate multiplier.
182 const float warningDescent = -bus->VerticalSpeedKms-(bus->GPWS.steepApproach ? .001016f : 0.f);
183 const float captureBias = frontCourse && bus->GlideslopeDeviationRadians > 0
185 const float cautionDescent = -bus->VerticalSpeedKms-(bus->GPWS.steepApproach ? .00254f : captureBias);
186 penetration = cautionDescent/(std::max)(.008f,(bus->RadioAltitudeKm-.009f)*.02306f+.008f);
187 // Mode 1 - Excessive barometric descent rate
188 if (bus->RadioAltitudeKm >= 0.01524f && bus->RadioAltitudeKm <= 0.74676f) // 50' to 2450'
189 {
191 ((warningDescent >= 0.009f && bus->RadioAltitudeKm < 0.082f) ||
192 (bus->RadioAltitudeKm >= 0.082f && warningDescent > ((bus->RadioAltitudeKm - 0.082f) * 0.04367f + 0.009f))))
193 {
195 }
197 (bus->RadioAltitudeKm >= 0.009f && cautionDescent > ((bus->RadioAltitudeKm - 0.009f) * 0.02306f + 0.008f)))
198 {
200 }
201 }
202
203 // Mode 2A - Excessive terrain closure rate (not landing)
204 if (bus->RadioAltitudeKm >= 0.01524f && bus->RadioAltitudeKm <= GpwsBehavior::Mode2Ceiling(bus->IndicatedAirspeedKms,tadAvailable,bus->GPWS.slowAircraft) && !mode2b) // 50' - 2000'
205 {
207 (-groundclose > (bus->RadioAltitudeKm * 0.020997f + 0.011f) ||
208 (-groundclose > 0.019f && bus->RadioAltitudeKm < 0.381f)))
209 {
211 }
213 (-groundclose > (bus->RadioAltitudeKm * 0.020997f + 0.010f) ||
214 (bus->RadioAltitudeKm >= 0.381f && -groundclose > ((bus->RadioAltitudeKm - 0.381f) * 0.144408f + 0.018f))))
215 {
217 }
218 }
219
220 // Mode 2B - Excessive terrain closure rate (landing config)
221 if (bus->RadioAltitudeKm >= 0.06096f && bus->RadioAltitudeKm <= 0.240792f && mode2b) // 200' to 790'
222 {
223 if (!landingConfiguration && bus->GPWS.Alert > Bus::Gpws::GpwsEnum::Mode2b_Pull_Up &&
224 (-groundclose > ((bus->RadioAltitudeKm - 0.061f) / 0.12184f * 0.002538f + 0.01523f) || // front side of pull up envelope
225 (-groundclose > 0.017768f && -groundclose < ((bus->RadioAltitudeKm - 0.061f) / 0.12184f * 0.03046f + 0.017768f)))) // backside of pull up envelope
226 {
228 }
230 (-groundclose > ((bus->RadioAltitudeKm - 0.061f) / 0.18f * 0.002538f + 0.012692f) || // front side of terrain terrain envelope
231 (-groundclose > 0.01523f && -groundclose < ((bus->RadioAltitudeKm - 0.118793f) / 0.12184f * 0.035537f + 0.01523f)))) // backside of terrain terrain envelope
232 {
234 }
235 }
236
238 {
241 }
242 else if (mode2WasWarning)
243 {
246 else if (groundclose >= 0 || mode2b) mode2WasWarning = false;
247 }
248 if (bus->GPWS.mode2Latch)
249 {
250 mode2LatchSeconds += fElapsed;
251 if (mode2LatchSeconds >= 45 || playerships[0].mslKm-mode2LatchAltitude >= .09144f || landingFlaps)
252 bus->GPWS.mode2Latch = false;
253 }
254 if (landingConfiguration && bus->GPWS.Alert == Bus::Gpws::Mode2b_Terrain_Terrain)
256
257 /* Mode 3 provides alerts for significant altitude loss after takeoff or low altitude go-around (less than 245* feet AGL) with gear or flaps not in the landing configuration.
258 * The amount of altitude loss that is permitted before an alert is given is a function of the height of the aircraft above the terrain as shown below.
259 * This protection is available until the EGPWS determines that the aircraft has gained sufficient altitude that it is no longer in the takeoff phase of flight.
260 * Significant altitude loss after takeoff or during a low altitude go-around activates the EGPWS caution lights and the aural message “DON’T SINK, DON’T SINK”.
261 */
262 // Altitude loss must not be confused with rising terrain under a climbing
263 // aircraft. Use geometric height; retain the legacy jet loss envelope.
264 if (bus->RadioAltitudeKm > .4572f) mode3active = takeoffPhase = false;
265 if (mode3active && std::isfinite(playerships[0].mslKm) && playerships[0].mslKm != -1)
266 {
267 mode3altitude = (std::max)(mode3altitude,playerships[0].mslKm);
268 if (!landingConfiguration && bus->VerticalSpeedKms < 0 &&
272 }
273
274 // Mode 4A - Unsafe terrain clearance with the gear UP 50-500'
275 // Cruise/approach phase, including level flight (guide pp.16-19).
276 if (bus->RadioAltitudeKm >= 0.01524f && bus->RadioAltitudeKm <= 0.3048f && !takeoffPhase && !playerships[0].geardown)
277 {
278 // above 190 kts, scaled from 500' to 1000' to 250 kts, capped at 1000' above 250 kts
280 {
282 }
283 // at or below 190 kts and below 500'
285 {
287 }
288 }
289
290 // Mode 4B - Unsafe terrain clearance with the gear DOWN but the flaps are not in the landing configuration 50-200'
291 // Cruise/approach phase, including level flight (guide pp.16-19).
292 if (bus->RadioAltitudeKm >= 0.01524f && bus->RadioAltitudeKm <= 0.3048f && !takeoffPhase && playerships[0].geardown && !landingFlaps)
293 {
294 // above 159 kts, scaled from 245' to 1000' to 250 kts, capped at 1000' above 250 kts
296 {
298 }
299 // at or below 159 kts and below 245'
301 {
303 }
304 }
305
306 // p.20: takeoff/go-around MTC is 75% of the preceding 15 seconds'
307 // radio altitude, never decreasing, capped by the Mode 4A limit.
308 if (takeoffPhase)
309 {
310 const float floor = clearanceHistory.Update(fElapsed,bus->RadioAltitudeKm,
312 if (!landingConfiguration && bus->RadioAltitudeKm <= floor && floor > 0 &&
315 }
316
317 // Receiver validity, not autopilot capture, admits a manual ILS approach.
318 const float gsDots = -RiseMath::ToDegree(bus->GlideslopeDeviationRadians)/.35f;
319 const float gsUpperKm = .1524f+.1524f*(std::clamp)(-bus->VerticalSpeedKms/.00254f,0.f,1.f);
320 const bool gsConfiguration = bus->RadioAltitudeKm < .1524f ||
321 (landingConfiguration && std::fabs(bus->LocalizerDeviationRadians) < RiseMath::ToRadian(.7f));
322 if (frontCourse && !bus->GPWS.mode5cancelled && bus->RadioAltitudeKm >= .01524f &&
323 bus->RadioAltitudeKm < gsUpperKm && gsConfiguration && gsDots >= GpwsBehavior::GlideslopeThreshold(bus->RadioAltitudeKm,false))
324 {
327 if (bus->GPWS.Alert > alert) bus->GPWS.Alert = alert;
328 }
329 else mode5bactive = false;
330
331 // Use the current MSL sample with the same density model as propulsion;
332 // the bus density may still describe the previous frame after relocation.
333 // Keep both p.25 profiles, selected by the actual Autoflyte engagement bit.
334 // Only bank advisories get Rise's thin-air/hypersonic spaceflight exclusion.
335 const float bankDensityRatio = bus->GPWS.positionValid && std::isfinite(playerships[0].mslKm) &&
336 playerships[0].mslKm != -1.f ? std::exp(-std::fabs(playerships[0].mslKm)/ScaleHeightC) : NAN;
337 const bool bankAllowed = bankFlightEnvelope.Allows(bus->RadioAltitudeKm,bankDensityRatio,bus->Mach);
338 if (bus->GPWS.bankCallouts && bankAllowed && bus->RadioAltitudeKm >= .001524f &&
339 std::isfinite(bus->RollAttitudeRadians) &&
344
345 // Mode 6 - Altitudes
346 if (bus->RadioAltitudeKm < oldradioaltitude) // descending only
347 {
348 const float heights[] = {.003048f,.006096f,.009144f,.012192f,.01524f,.03048f,.06096f,.1524f,.3048f};
352 bool selected = false;
353 for (unsigned i = 0; i < 9; ++i)
354 if (oldradioaltitude >= heights[i] && bus->RadioAltitudeKm < heights[i] && !(altitudeCallouts & (1u<<i)))
355 {
356 if (i != 7 || bus->GPWS.fiveHundredMode != 2) altitudeCallouts |= 1u<<i;
357 const bool enabled = (bus->GPWS.calloutMask&(1u<<i)) && (i != 7 ||
358 (bus->GPWS.fiveHundredMode == 0 || (bus->GPWS.fiveHundredMode == 1 && (!frontCourse || std::fabs(gsDots)>2))));
359 if (enabled && !selected && bus->GPWS.Alert > calls[i]) { bus->GPWS.Alert = calls[i]; selected = true; }
360 }
361
362 // Retard
364 (bus->EngineThrustLever[0] > 0.0f || bus->EngineThrustLever[1] > 0.0f || bus->EngineThrustLever[2] > 0.0f) &&
366 {
368 mode6retardArmed = false;
369 }
370 else if (!mode6retardArmed && bus->RadioAltitudeKm > 0.100f)
371 {
372 mode6retardArmed = true;
373 }
374
375 // Minimums, minimums
376 // Decision height is a bus-configurable geometric/radio-height setting.
378 {
380 altitudeCallouts |= 1u<<9;
381 }
382 }
383
384 } // airborne, valid reactive inputs
385 if (airborne && floorValid && (bus->GPWS.calloutMask&(1u<<7)) && bus->GPWS.fiveHundredMode == 2 && !(altitudeCallouts&(1u<<7)) &&
387 {
389 }
391 if (floorPenetration > 0 && bus->GPWS.Alert > Bus::Gpws::TCF_Too_Low_Terrain)
393
394 // I am 30 and empty is 10 and maxgross is 30
405
409 {
412 }
414
415 // Mode 6 Pilot Monitoring
416 if (playerships[0].reference != REF_ONGROUND)
417 {
418 if (!mode6pr && bus->VerticalSpeedKms >= 0.002f)
419 {
421 {
423 mode6pr = true;
424 }
425 }
426 }
427 else
428 {
429 // resets
430 mode6pr = false;
431 bus->GPWS.mode5cancelled = false;
432 }
433
434
435 // Mode 7 reactive windshear: actual encountered wind, no radar dependency.
436 // Rise retains protection throughout low-altitude flight, including hover
437 // and ACL control. This is broader than the reference takeoff/approach phases.
438 const bool windEnabled = airborne && motionValid && !bus->GPWS.inhibited &&
442 const auto windAlert = windshear.Update(bus->WindshearWind,fElapsed,windEnabled);
447
451
453
454
455
456 if (bus->GPWS.terrain.enabled)
457 {
459 const auto& terrain = bus->GPWS.terrain;
460 if (terrain.Alert() == TerrainAwareness::Severity::Warning)
462 else if (terrain.Alert() == TerrainAwareness::Severity::Caution)
463 terrainAlert = terrain.ObstacleAlert() ? Bus::Gpws::TA_Obstacle_Caution : Bus::Gpws::TA_Terrain_Caution;
464 if (terrainAlert != Bus::Gpws::NoAlert &&
465 (bus->GPWS.Alert == Bus::Gpws::NoAlert || bus->GPWS.Alert > terrainAlert))
466 bus->GPWS.Alert = terrainAlert;
467 }
468
474 if (previousAlert != bus->GPWS.Alert && *bus->GPWS.AlertText())
475 {
476 if (bus->GPWS.warningHistory.size() == 32) bus->GPWS.warningHistory.erase(bus->GPWS.warningHistory.begin());
477 bus->GPWS.warningHistory.push_back(bus->GPWS.AlertText());
478 }
480 lastTerrainVoice = Bus::Gpws::NoAlert; // A later encounter gets its identifying phrase again.
481 if (previousAlert != bus->GPWS.Alert)
483 // Only predictive speech expires when the selected alert changes. One-shot
484 // reactive callouts (such as an altitude crossing) must survive until consumed.
485 auto& commands = bus->commandStream;
486 commands.erase(std::remove_if(commands.begin(), commands.end(), [&](const Command& command) {
487 if (command.sValue == "GPWSPredictiveWind") return !bus->GPWS.predictiveWindshear.caution ||
488 bus->GPWS.Alert != Bus::Gpws::Predictive_Windshear_Caution || command.ivalues[1] != playerships[0].vehicleId;
489 if (command.sValue == "GPWSReactive") return !airborne || command.ivalues[0] != bus->GPWS.Alert;
490 return command.sValue == "GPWSTerrain" && (!bus->GPWS.IsTerrainAlert() ||
491 command.ivalues[0] != bus->GPWS.Alert ||
492 unsigned(command.ivalues[1]) != bus->GPWS.terrainRevision);
493 }), commands.end());
494
495 // State churn can invalidate queued speech, but cannot bypass its repeat
496 // interval. A new warning may queue promptly after a caution; VMU still
497 // finishes the current phrase. Keep this in the normal command switch.
498 const bool initialTerrainVoice = lastTerrainVoice != bus->GPWS.Alert;
499 const bool wasTerrainWarning = lastTerrainVoice == Bus::Gpws::TA_Terrain_Warning ||
502 {
505 lastFloorRadio = lastFloorGeo = FLT_MAX;
506 }
507 const float gsMagnitude = -RiseMath::ToDegree(bus->GlideslopeDeviationRadians)/.35f;
508 const float bankMagnitude = std::fabs(RiseMath::ToDegree(bus->RollAttitudeRadians));
509 const auto alert = bus->GPWS.Alert;
510 if (alert == Bus::Gpws::TCF_Too_Low_Terrain) penetration = floorPenetration;
512 penetration = GpwsBehavior::GearFloor(bus->IndicatedAirspeedKms,tadAvailable)/(std::max)(bus->RadioAltitudeKm,.001f);
513 else if (alert == Bus::Gpws::Mode4a_Too_Low_Gear) penetration = .1524f/(std::max)(bus->RadioAltitudeKm,.001f);
514 else if (alert == Bus::Gpws::Mode4b_Too_Low_Flaps) penetration = .074676f/(std::max)(bus->RadioAltitudeKm,.001f);
515 const bool repeatPenetration = !bus->GPWS.auralDeclutter ? secsincelast>=2 :
516 lastDeclutterValue == 0 || penetration >= lastDeclutterValue*1.2f;
517 Command newCommand;
518 switch (bus->GPWS.Alert)
519 {
521 if (!wasTerrainWarning || terrainVoiceSeconds >= 2.0f)
522 {
523 newCommand.name = initialTerrainVoice ? "GPWSTerrainTerrain" : "GPWSPullUp";
524 newCommand.priority = 105;
525 }
526 break;
528 if (!wasTerrainWarning || terrainVoiceSeconds >= 2.0f)
529 {
530 newCommand.name = initialTerrainVoice ? "GPWSObstacleObstacle" : "GPWSPullUp";
531 newCommand.priority = 106;
532 }
533 break;
535 if (terrainVoiceSeconds >= 7.0f)
536 {
537 newCommand.name = "GPWSCautionTerrain";
538 newCommand.priority = 109;
539 }
540 break;
542 if (terrainVoiceSeconds >= 7.0f)
543 {
544 newCommand.name = "GPWSCautionObstacle";
545 newCommand.priority = 110;
546 }
547 break;
549 if (lastDeclutterValue == 0 || gsMagnitude >= lastDeclutterValue*1.2f)
550 {
551 newCommand.name = "GPWSGlideslope"; newCommand.priority = 118;
552 newCommand.fValue = .5f; lastDeclutterValue = gsMagnitude;
553 }
554 break;
556 if (lastDeclutterValue == 0 || secsincelast >= 4.f)
557 {
558 newCommand.name = "GPWSGlideslope"; newCommand.priority = 118; newCommand.ivalues[1] = 2;
559 lastDeclutterValue = gsMagnitude;
560 }
561 break;
565 if (secsincelast >= 2.0f)
566 {
567 newCommand.name = "GPWSPullUp";
568 newCommand.priority = 101;
569 }
570 break;
573 if (secsincelast >= 4.0f)
574 {
575 newCommand.name = "GPWSTerrainTerrain";
576 newCommand.priority = 102;
577 }
578 break;
580 if (lastDeclutterValue == 0 || secsincelast >= 2) { newCommand.name = "GPWSTerrain"; newCommand.priority = 107; lastDeclutterValue = 1; }
581 break;
583 if (!bus->GPWS.auralDeclutter ? secsincelast>=2 : lastFloorRadio == FLT_MAX ||
584 (lastFloorRadio-bus->RadioAltitudeKm >= .2f*(std::max)(std::fabs(lastFloorRadio),.009144f)) ||
585 (lastFloorGeo-lastFloorHeight >= .2f*(std::max)(std::fabs(lastFloorGeo),.009144f)))
586 {
587 newCommand.name = "GPWSTooLowTerrain"; newCommand.priority = 111;
589 }
590 break;
594 if (repeatPenetration)
595 {
596 lastDeclutterValue = penetration;
597 newCommand.name = "GPWSTooLowTerrain";
598 newCommand.priority = 111;
599 }
600 break;
602 if (repeatPenetration)
603 {
604 lastDeclutterValue = penetration;
605 newCommand.name = "GPWSTooLowGear";
606 newCommand.priority = 114;
607 }
608 break;
610 if (repeatPenetration)
611 {
612 lastDeclutterValue = penetration;
613 newCommand.name = "GPWSTooLowFlaps";
614 newCommand.priority = 115;
615 }
616 break;
618 if (repeatPenetration)
619 {
620 lastDeclutterValue = penetration;
621 newCommand.name = "GPWSSinkRate";
622 newCommand.priority = 116;
623 }
624 break;
626 if (lastDeclutterValue == 0 || bankMagnitude >= lastDeclutterValue*1.2f ||
627 (bankAnnouncements >= 3 && bankMagnitude >= lastDeclutterValue && secsincelast >= 2.f))
628 {
629 newCommand.name = "GPWSBankAngle"; newCommand.priority = 120;
630 if (bankAnnouncements < 3) lastDeclutterValue = bankMagnitude;
632 }
633 break;
635 if (secsincelast >= 1.0f)
636 {
637 newCommand.name = "GPWSMode6Retard";
638 }
639 break;
641 newCommand.name = "GPWSMode6Ten";
642 break;
644 newCommand.name = "GPWSMode6Twenty";
645 break;
647 newCommand.name = "GPWSMode6Thirty";
648 break;
650 newCommand.name = "GPWSMode6Forty";
651 break;
653 newCommand.name = "GPWSMode6Fifty";
654 newCommand.ttl = 0.443f;
655 break;
657 newCommand.name = "GPWSMode6OneHundred";
658 break;
660 newCommand.name = "GPWSMode6TwoHundred";
661 break;
663 newCommand.name = "GPWSMode6Minimums";
664 newCommand.priority = 108;
665 break;
667 newCommand.name = "GPWSMode6PositiveRate";
668 break;
670 newCommand.name = "GPWSMode6FiveHundred";
671 break;
673 newCommand.name = "GPWSMode6OneThousand";
674 break;
676 newCommand.name = "GPWSMode6Rotate";
677 break;
679 if ((mode3Announcements < 2 && (mode3Announcements == 0 || secsincelast >= 2)) ||
681 {
682 newCommand.name = "GPWSMode3DontSink"; newCommand.priority = 117;
684 }
685 break;
687 if (secsincelast >= 4.0f)
688 {
689 newCommand.name = "GPWSMode7WindshearWarning";
690 newCommand.priority = 100;
691 }
692 break;
695 { newCommand.name = "GPWSPredictiveWindshear"; newCommand.priority = 121; }
696 break;
698 if (secsincelast >= 4.0f)
699 {
700 newCommand.name = "GPWSMode7WindshearCaution";
701 newCommand.priority = 121;
702 }
703 break;
704 }
705
706 if (!newCommand.name.empty())
707 {
709 {
710 newCommand.sValue = "GPWSPredictiveWind"; newCommand.ivalues[0] = bus->GPWS.Alert;
711 newCommand.ivalues[1] = playerships[0].vehicleId; newCommand.ttl = 2;
712 if (std::none_of(commands.begin(),commands.end(),[](const Command& c) { return c.sValue == "GPWSPredictiveWind"; }))
713 commands.insert(std::find_if(commands.begin(),commands.end(),[&](const Command& c) {
714 return c.priority > newCommand.priority;
715 }),newCommand);
717 }
718 else if (bus->GPWS.IsTerrainAlert())
719 {
720 if (std::any_of(commands.begin(), commands.end(), [](const Command& command) {
721 return command.sValue == "GPWSTerrain";
722 })) return;
723 // Carry the selected alert and its revision so VMU can cancel stale speech.
724 newCommand.sValue = "GPWSTerrain";
725 newCommand.ivalues[0] = bus->GPWS.Alert;
726 newCommand.ivalues[1] = int(bus->GPWS.terrainRevision);
727 newCommand.ttl = 2;
728 const auto position = std::find_if(commands.begin(), commands.end(), [&](const Command& command) {
729 return command.priority > newCommand.priority;
730 });
731 commands.insert(position, newCommand);
733 }
734 else
735 {
737 {
738 newCommand.priority = 112; newCommand.sValue = "GPWSAltitude";
739 newCommand.ttl = 2;
740 // Finish speech already playing; skip superseded queued heights.
741 commands.erase(std::remove_if(commands.begin(),commands.end(),[](const Command& c) {
742 return c.sValue == "GPWSAltitude";
743 }),commands.end());
744 }
745 if (newCommand.priority >= 100 && newCommand.priority <= 121 &&
746 newCommand.priority != 108 && newCommand.priority != 112)
747 {
748 newCommand.sValue = "GPWSReactive"; newCommand.ivalues[0] = bus->GPWS.Alert;
749 newCommand.ttl = 2;
750 }
751 if (std::none_of(commands.begin(),commands.end(),[&](const Command& c) { return c.name == newCommand.name; }))
752 commands.insert(std::find_if(commands.begin(),commands.end(),[&](const Command& c) {
753 return c.priority > newCommand.priority;
754 }),newCommand);
755 }
756 secsincelast = 0.0f;
757 }
758}
SCRIPT_CONTROL SCRIPT_STATE const void int
float Lerp(float val1, float val2, float lerp)
Reference
Definition ServerTypes.h:40
@ REF_ACLMODE
Definition ServerTypes.h:44
@ REF_APNMODE
Definition ServerTypes.h:42
@ REF_ONGROUND
Definition ServerTypes.h:43
Definition Bus.h:20
float Mach
Definition Bus.h:456
float RollAttitudeRadians
Definition Bus.h:48
float MapScaleInnerRingKm
Definition Bus.h:490
float TrailingEdgeFlapsPosition
Definition Bus.h:424
float HeadingTrackDegrees
Definition Bus.h:303
struct Bus::Gpws GPWS
float ComputedTrimTargetDegrees
Definition Bus.h:416
UINT flapSettingTE
Definition Bus.h:67
float LocalizerDeviationRadians
Definition Bus.h:158
float EngineThrustLever[MAX_ENGINES]
Definition Bus.h:357
float GrossWeightLbs() const noexcept
Definition Bus.h:466
float IndicatedAirspeedKms
Definition Bus.h:34
struct Bus::Afcs AFCS
std::vector< Swaypoint > waypoint
Definition Bus.h:500
GpwsWindshear::Sample WindshearWind
Definition Bus.h:309
float ComputedVsKms
Definition Bus.h:37
float RadioAltitudeKm
Definition Bus.h:157
float ComputedVrKms
Definition Bus.h:36
int WPtargetC
Definition Bus.h:499
float GlideslopeDeviationRadians
Definition Bus.h:159
float ComputedVneKms
Definition Bus.h:38
float VerticalSpeedKms
Definition Bus.h:451
std::vector< Command > commandStream
Definition Bus.h:442
Gpws(Bus *prmBus, Logger *prmLogger, Viewscreen *prmViewscreen=nullptr)
Definition GPWS.cpp:47
GpwsWindshear::Detector windshear
Definition Module.h:65
bool mode3active
Definition Module.h:61
void UpdateTerrainAwareness(float seconds)
GpwsBehavior::ClearanceHistory clearanceHistory
Definition Module.h:78
bool floorValid
Definition Module.h:88
void Evaluate(float seconds)
Definition GPWS.cpp:68
float fieldCalloutHeight
Definition Module.h:86
unsigned bankAnnouncements
Definition Module.h:82
void UpdatePredictiveWindshear(float seconds)
float previousFieldHeight
Definition Module.h:86
bool terrainRangeActive
Definition Module.h:56
float ClearanceFloor()
float takeoffSeconds
Definition Module.h:76
float mode2LatchSeconds
Definition Module.h:84
GpwsBehavior::BankFlightEnvelope bankFlightEnvelope
Definition Module.h:79
bool mode6retardArmed
Definition Module.h:71
float previousMapRange
Definition Module.h:57
bool mode6pr
Definition Module.h:70
Viewscreen * viewscreen
Definition Module.h:45
unsigned altitudeCallouts
Definition Module.h:77
int reactiveVehicle
Definition Module.h:75
void ProcessControls(bool powered, bool airborne)
float lastFloorHeight
Definition Module.h:86
float predictiveWindVoiceSeconds
Definition Module.h:68
float terrainVoiceSeconds
Definition Module.h:50
float mode2LatchAltitude
Definition Module.h:84
float lastFloorGeo
Definition Module.h:85
bool mode5bactive
Definition Module.h:69
float secsincelast
Definition Module.h:59
float oldRadioAltitudeKm
Definition Module.h:73
float oldradioaltitude
Definition Module.h:60
bool UpdateSelfTest(float seconds, bool powered, bool airborne)
float lastDeclutterValue
Definition Module.h:81
float previousVerticalKms
Definition Module.h:76
bool takeoffPhase
Definition Module.h:74
Reference oldReference
Definition Module.h:63
bool reactiveReady
Definition Module.h:74
void UpdateFaults()
float lastFloorRadio
Definition Module.h:85
float mode3altitude
Definition Module.h:62
unsigned mode3Announcements
Definition Module.h:87
Bus::Gpws::GpwsEnum lastTerrainVoice
Definition Module.h:51
bool mode2WasWarning
Definition Module.h:88
float oldIndicatedAirspeedKms
Definition Module.h:64
void FrameMove(float fElapsedTime) override
Definition GPWS.cpp:52
Logger * logger
Definition Module.h:44
float groundclose
Definition Module.h:72
Bus::Gpws::GpwsEnum lastDeclutterAlert
Definition Module.h:80
float lastAltitudeLoss
Definition Module.h:86
Alert Update(const Sample &sample, float elapsed, bool enabled)
Bus * bus
Definition Module.h:21
s_network_objects playerships[MAX_SCAN]
Definition globals.cpp:112
Scockpit ourcockpit
Definition globals.cpp:114
#define ScaleHeightC
Definition globals.h:98
float FlapFloor(float speedKms, bool terrainAvailable)
float BankLimit(float radioKm, bool autopilot)
float AltitudeLossLimit(float radioKm)
float GearFloor(float speedKms, bool terrainAvailable)
float Clamp01(float x)
float Mode2Ceiling(float speedKms, bool tad, bool slow)
float GlideslopeThreshold(float radioKm, bool hard)
bool HeightAllowed(float radioKm)
auto ToRadian(T value)
Definition ClientMath.h:13
float Vec3Length(const Vector3 *a)
Definition ClientMath.h:95
auto ToDegree(T value)
Definition ClientMath.h:14
constexpr float HalfPi
Definition ClientMath.h:12
bool DisplayAllowed(bool simulator, bool groundVehicle, float power)
bool AutopilotEngaged
Definition Bus.h:87
bool inhibited
Definition Bus.h:250
bool positionValid
Definition Bus.h:253
unsigned terrainRevision
Definition Bus.h:276
bool TerrainDisplayActive() const
Definition Bus.h:271
bool slowAircraft
Definition Bus.h:254
bool warningLamp
Definition Bus.h:258
bool flapOverride
Definition Bus.h:250
bool auralDeclutter
Definition Bus.h:252
const wchar_t * AlertText() const
Definition Bus.h:277
GpwsEnum
Definition Bus.h:189
@ Mode6_Retard
Definition Bus.h:243
@ Mode6_Twenty
Definition Bus.h:218
@ Mode6_One_Thousand
Definition Bus.h:211
@ Mode4b_Too_Low_Terrain
Definition Bus.h:208
@ Mode6_Fifty
Definition Bus.h:215
@ Mode6_Ten
Definition Bus.h:219
@ TA_Obstacle_Caution
Definition Bus.h:206
@ Mode4a_Too_Low_Gear
Definition Bus.h:221
@ Mode7_Windshear_Caution
Definition Bus.h:229
@ Predictive_Windshear_Caution
Definition Bus.h:230
@ Mode1_Pull_Up
Definition Bus.h:194
@ Mode2b_Terrain_Terrain
Definition Bus.h:198
@ Mode1_Sink_Rate
Definition Bus.h:223
@ Mode6_Minimums_Minimums
Definition Bus.h:204
@ Mode2_Terrain
Definition Bus.h:203
@ Mode4b_Too_Low_Flaps
Definition Bus.h:222
@ NoAlert
Definition Bus.h:190
@ Mode6_Forty
Definition Bus.h:216
@ Mode4c_Too_Low_Terrain
Definition Bus.h:209
@ Mode6_Bank_Angle
Definition Bus.h:228
@ TA_Terrain_Caution
Definition Bus.h:205
@ TCF_Too_Low_Terrain
Definition Bus.h:210
@ Mode6_One_Hundred
Definition Bus.h:214
@ Mode5b_Glideslope
Definition Bus.h:226
@ Mode4a_Too_Low_Terrain
Definition Bus.h:207
@ Mode6_Rotate
Definition Bus.h:245
@ Mode6_Two_Hundred
Definition Bus.h:213
@ Mode7_Windshear_Warning
Definition Bus.h:193
@ Mode2a_Pull_Up
Definition Bus.h:195
@ Mode6_Five_Hundred
Definition Bus.h:212
@ Mode2a_Terrain_Terrain
Definition Bus.h:197
@ Mode5a_Glideslope
Definition Bus.h:225
@ Mode2b_Pull_Up
Definition Bus.h:196
@ TA_Obstacle_Warning
Definition Bus.h:202
@ TA_Terrain_Warning
Definition Bus.h:201
@ Mode3_Dont_Sink
Definition Bus.h:224
@ Reset
Definition Bus.h:247
@ Mode6_Positive_Rate
Definition Bus.h:244
@ Mode6_Thirty
Definition Bus.h:217
bool mode2Latch
Definition Bus.h:258
int fiveHundredMode
Definition Bus.h:257
bool steepApproach
Definition Bus.h:250
unsigned faults
Definition Bus.h:259
bool cautionLamp
Definition Bus.h:258
GpwsPredictiveWindshear::State predictiveWindshear
Definition Bus.h:265
std::vector< std::wstring > warningHistory
Definition Bus.h:263
bool mode5cancelled
Definition Bus.h:249
float decisionHeightKm
Definition Bus.h:255
bool IsTerrainAlert() const
Definition Bus.h:266
enum Bus::Gpws::GpwsEnum Alert
bool bankCallouts
Definition Bus.h:252
bool autoRange
Definition Bus.h:251
unsigned calloutMask
Definition Bus.h:256
float testMessageSeconds
Definition Bus.h:262
TerrainAwareness::State terrain
Definition Bus.h:264
std::string sValue
Definition Command.h:20
float fValue
Definition Command.h:25
unsigned char priority
Definition Command.h:28
int ivalues[2]
Definition Command.h:21
std::string name
Definition Command.h:11
float ttl
Definition Command.h:17
bool Allows(float radioKm, float densityRatio, float mach)
float Update(float dt, float radioKm, float limitKm)
float maxGrossLbs
Definition globals.h:634
float VrEmpty
Definition globals.h:644
float MaxDoorOpenOperatingKms
Definition globals.h:645
float trimTargetEmpty
Definition globals.h:662
float power
Definition globals.h:599
float VneEmpty
Definition globals.h:644
float flapExtent
Definition globals.h:660
std::vector< FlapSetting > flapSettings
Definition globals.h:661
float emptyWeightLbs
Definition globals.h:633
float Vle
Definition globals.h:645
float VneMaxGross
Definition globals.h:644
float gearextent
Definition globals.h:617
bool wheeled
Definition globals.h:596
float VrMaxGross
Definition globals.h:644
float trimTargetMaxGross
Definition globals.h:662
RiseMath::Vector3 position
Definition globals.h:511
unsigned short vehicleId
Definition globals.h:537
float baydoorextent
Definition globals.h:539