Rise
The Vieneo Province
Loading...
Searching...
No Matches
Tests/TcasTests.cpp

Source at documentation-generation time. See Test catalog for fixture associations.

1// Exercise the production TCAS/VMU modules with deterministic sound and logging sinks.
2#include "../Modules/Module.h"
3#include <cstdlib>
4#include <algorithm>
5#include <cmath>
6#include <iostream>
7#include <memory>
8#include <vector>
9
12static std::vector<SOUNDS> played, stopped;
13static float soundDuration = 1.0f;
14static void Check(bool condition, const char* message)
15{
16 if (!condition) { std::cerr << "FAIL: " << message << '\n'; std::exit(1); }
17}
18// This executable replaces Logger.cpp with a recording-free sink. Complete its
19// private storage type so the stub constructor/destructor can own an empty pointer.
20struct Logger::CrashState {};
21Logger::Logger() = default;
22Logger::~Logger() = default;
23void Logger::Log(const char*, Level, int) {}
26{
27 Check(sound_path.size() == SOUND_ENUMERATION, "sound paths remain aligned with sound IDs");
28}
29float Sound::Play(SOUNDS sound, float) { played.push_back(sound); return soundDuration; }
30void Sound::Stop(SOUNDS sound) const { stopped.push_back(sound); }
31
32struct Fixture
33{
34 Logger logger;
35 std::unique_ptr<Bus> bus = std::make_unique<Bus>(&logger);
36 std::unique_ptr<Sound> sound = std::make_unique<Sound>(nullptr);
37 RiseMath::Matrix view;
38 TCAS tcas{bus.get(), &logger, &view};
39 Vmu vmu{bus.get(), &logger, sound.get()};
40 Fixture()
41 {
42 soundDuration = 1.0f;
43 ourcockpit.power = 1.0f;
45 for (auto& ship : playerships) ship = s_network_objects{};
46 playerships[0].logolight = true;
47 playerships[0].transponder = true;
49 bus->RadioAltitudeKm = 1.0f;
50 playerships[0].mslKm = 2.0f;
51 playerships[0].position = RiseMath::Vector3(0, 6373, 0);
53 Step(2.0f); // VMU power-up.
54 played.clear(); stopped.clear(); bus->vmuHold = 0;
55 }
56 void Queue(const char* name, bool test = false, float delay = 0)
57 {
58 Command command; command.name = name; command.bValue = test; command.delay = delay;
59 bus->commandStream.push_back(command);
60 }
61 void Step(float seconds = 0.1f) { tcas.FrameMove(seconds); vmu.FrameMove(seconds); }
62};
63
64static void InhibitsAndResets()
65{
66 Fixture f;
67 f.bus->RadioAltitudeKm = 0.3048f; f.Step();
68 Check(!f.bus->TCASInhibited, "exactly 1,000 feet allows TCAS");
69 f.bus->TCAS = Bus::RA_Climb; f.bus->TCASTargetOrdinal = 9;
70 f.Queue("TCASClimb", false, 5); f.Queue("UnrelatedCommand");
71 f.bus->RadioAltitudeKm = 0.3047f; f.Step();
72 Check(f.bus->TCASInhibited, "below 1,000 feet inhibits TCAS");
73 Check(f.bus->TCAS == Bus::Clear_Of_Conflict && f.bus->TCASTargetOrdinal == -1,
74 "inhibition clears displayed mode and target");
75 Check(f.bus->commandStream.size() == 1 && f.bus->commandStream[0].name == "UnrelatedCommand",
76 "inhibition removes delayed stale speech and preserves unrelated commands");
77 f.bus->RadioAltitudeKm = 1;
78 f.bus->GPWS.Alert = Bus::Gpws::Reset; f.Step();
79 Check(!f.bus->TCASInhibited, "GPWS Reset is not an alert");
80 f.bus->GPWS.Alert = Bus::Gpws::NoAlert; f.Step();
81 Check(!f.bus->TCASInhibited, "GPWS NoAlert allows TCAS");
82 for (int alert = Bus::Gpws::Mode7_Windshear_Warning; alert < Bus::Gpws::Reset; ++alert)
83 {
84 f.bus->GPWS.Alert = static_cast<Bus::Gpws::GpwsEnum>(alert);
85 f.Queue("IncreaseClimb"); f.Step();
86 Check(f.bus->TCASInhibited && played.empty(), "each active GPWS alert suppresses TCAS");
87 }
88}
89
90static void VoicesAndPreemption()
91{
92 Fixture f;
93 for (int i = 0; i < TcasAudio::Count; ++i)
94 {
95 Check(TcasAudio::Find(TcasAudio::Callouts[i].command) == i, "current command mapping");
96 f.Queue(TcasAudio::Callouts[i].dropshipCommand); f.Step(1.1f);
97 Check(played.back() == SOUND_TCASTRAFFIC + i, "Dropship aliases play correct recordings");
98 }
99 Check(TcasAudio::Find("TcasSystemTest") == -1, "test control is not mistaken for speech");
100 f.Queue("TCASClimb"); f.Step(1.1f);
101 f.bus->GPWS.Alert = Bus::Gpws::Mode1_Pull_Up;
102 f.Queue("GPWSPullUp"); f.Step();
103 Check(stopped.empty() && played.back() == SOUND_TCASCLIMB, "GPWS lets the active TCAS phrase finish");
104 f.Step(1);
105 Check(played.back() == SOUND_GPWSPULLUP, "GPWS takes the next voice slot after TCAS finishes");
106 f.bus->GPWS.Alert = Bus::Gpws::NoAlert; f.Queue("TCASDescend"); f.Step(1.1f);
107 f.bus->RadioAltitudeKm = 0; f.Step();
108 Check(stopped.empty() && played.back() == SOUND_TCASDESCEND, "inhibit altitude clears queued TCAS without clipping active speech");
109 f.bus->RadioAltitudeKm = 1; f.bus->vmuHold = 0;
110 Command live; live.name = "TCASClimb"; live.sValue = "TCASLive"; live.ivalues[0] = int(f.bus->TCASRevision);
111 f.bus->commandStream.push_back(live); f.vmu.FrameMove(.1f);
112 const auto count = played.size(); ++f.bus->TCASRevision; f.vmu.FrameMove(.1f);
113 Check(stopped.empty() && played.size() == count, "TCAS advisory revision cannot restart the active recording");
114}
115
116static void CompleteGroundTest()
117{
118 Fixture f;
120 playerships[0].transponder = false; f.bus->RadioAltitudeKm = 0;
121 f.Queue("TcasSystemTest");
122 std::vector<float> times;
123 for (int i = 1; i <= 500; ++i)
124 {
125 const auto before = played.size(); f.Step();
126 if (played.size() > before)
127 {
128 times.push_back(i * 0.1f);
129 Check(f.bus->TCASTestCallout == played.back() - SOUND_TCASTRAFFIC,
130 "display follows the phrase actually started by the VMU");
131 }
132 Check(f.bus->TCAS == Bus::Clear_Of_Conflict && f.bus->TCASTargetOrdinal == -1,
133 "display test never publishes a live advisory or target");
134 if (i > 1 && !f.bus->TCASTestActive) break;
135 }
141 Check(played == std::vector<SOUNDS>(std::begin(expected), std::end(expected)),
142 "ground test speaks all 15 callouts in Dropship order exactly once");
143 Check(times[0] >= 1.99f && times[10] - times[9] >= 2.99f &&
144 times[11] - times[10] >= 2.99f && times[13] - times[12] >= 1.49f,
145 "test preserves initial, maintain, adjust, and crossing pauses");
146 Check(!f.bus->TCASTestActive && f.bus->commandStream.empty(), "test ends without queued residue");
147 Check(f.bus->TCASTestCallout == -1, "completed test clears display state");
148 Check(f.bus->TCAS == Bus::Clear_Of_Conflict && f.bus->TCASTargetOrdinal == -1,
149 "test creates no real traffic threat");
150}
151
152static void CancelAndRestart()
153{
154 Fixture f;
155 f.Queue("TcasSystemTest", false, 5); f.Step(2);
156 Check(!f.bus->TCASTestActive, "delayed test command waits");
157 f.bus->commandStream[0].delay = 0; f.Step(2);
158 Check(f.bus->TCASTestActive && played.back() == SOUND_TCASTRAFFIC, "test starts");
159 f.Queue("TcasSystemTest"); f.Step();
160 Check(!f.bus->TCASTestActive && stopped.back() == SOUND_TCASTRAFFIC, "toggle cancels active speech");
161 Check(f.bus->TCASTestCallout == -1, "toggle clears display");
162 f.Queue("TcasSystemTest"); f.Step(2);
163 Check(played.back() == SOUND_TCASTRAFFIC, "restart begins with Traffic");
164 ourcockpit.power = 0; f.Step();
165 Check(!f.bus->TCASTestActive && f.bus->commandStream.empty(), "power loss cancels test and queue");
166 Check(f.bus->TCASTestCallout == -1, "power loss clears display");
167 ourcockpit.power = 1; f.Step(3);
168 Check(!f.bus->TCASTestActive, "power restoration does not resume stale test");
169 f.Queue("TcasSystemTest"); f.Step(2);
170 f.bus->GPWS.Alert = Bus::Gpws::Mode1_Pull_Up; f.Step();
171 Check(!f.bus->TCASTestActive, "GPWS cancels active test");
172 Check(f.bus->TCASTestCallout == -1, "GPWS clears test display");
173 f.Queue("TcasSystemTest"); f.Step(2);
174 Check(!f.bus->TCASTestActive, "cannot start test during GPWS alert");
175 f.bus->GPWS.Alert = Bus::Gpws::NoAlert;
176 f.Queue("TcasSystemTest"); f.Step(2);
177 f.Queue("VMUTest"); f.Step();
178 Check(!f.bus->TCASTestActive, "normal VMU test cancels TCAS test");
179 Check(f.bus->TCASTestCallout == -1, "VMU test clears TCAS display");
180}
181
182static void DisplayPlaybackAndLifecycle()
183{
184 Fixture f;
185 f.Queue("TcasSystemTest"); f.Step(.1f);
186 Check(f.bus->TCASTestActive && f.bus->TCASTestCallout == -1,
187 "display starts with symbol check before first voice");
188 f.bus->vmuHold = 10;
189 f.Step(3);
190 Check(f.bus->TCASTestCallout == -1 && played.empty(), "busy audio cannot advance display ahead of speech");
191 f.bus->vmuHold = 0;
192 f.tcas.FrameMove(.1f);
193 Check(!f.bus->commandStream.empty() && f.bus->TCASTestCallout == -1,
194 "queueing a test phrase alone does not advance display");
195 f.vmu.FrameMove(.1f);
196 Check(f.bus->TCASTestCallout == 0, "consuming test speech advances display");
197 soundDuration = 4;
198 f.Step(2); f.Step();
199 Check(f.bus->TCASTestCallout == 1, "next phrase updates display");
200 f.Step(2);
201 Check(f.bus->TCASTestCallout == 1, "display holds throughout a long recording");
202 ++playerships[0].vehicleId; f.Step();
203 Check(!f.bus->TCASTestActive && f.bus->TCASTestCallout == -1 && f.bus->commandStream.empty(),
204 "vehicle change cancels display, test sequence and queued speech");
205 f.Step(3);
206 Check(!f.bus->TCASTestActive, "vehicle change cannot replay old test");
207 playerships[0].isSimulator = true;
208 f.Queue("TcasSystemTest"); f.Step(2);
209 Check(f.bus->TCASTestActive && f.bus->TCASTestCallout == 0,
210 "cockpit avionics self-test remains available in simulator");
211 f.Queue("TcasSystemTest"); f.Step();
212 f.Queue("TcasSystemTest"); f.Step();
213 Check(f.bus->TCASTestCallout == -1, "restart clears previous phrase during initial display check");
214 f.Step(2);
215 f.bus->GPWS.testLevel = 1; f.Step();
216 Check(!f.bus->TCASTestActive && f.bus->TCASTestCallout == -1,
217 "GPWS self-test cancels the competing TCAS sound and display test");
218 f.Queue("TcasSystemTest"); f.Step(2);
219 Check(!f.bus->TCASTestActive, "TCAS test cannot cover an active GPWS self-test");
220 f.bus->GPWS.testLevel = 0; f.Step(3);
221 Check(!f.bus->TCASTestActive, "GPWS test completion does not replay cancelled TCAS test");
222}
223
224static constexpr float FT = .0003048f, FPM = FT/60;
225static s_network_objects& Traffic(Fixture& f, int slot, float range, float altitudeFeet, float rateFpm = 0, float closing = .15f)
226{
227 auto& t = playerships[slot];
228 t = s_network_objects{};
229 t.active = t.visible = t.isOnScanner = t.transponder = true;
230 t.reference = REF_ACLMODE; t.type = VehicleType::E10; t.vehicleId = slot;
231 t.mslKm = playerships[0].mslKm + altitudeFeet*FT;
232 t.position = playerships[0].position + RiseMath::Vector3(range, altitudeFeet*FT, 0);
233 t.velocity = RiseMath::Vector3(-closing, rateFpm*FPM, 0);
234 return t;
235}
236static void Fly(Fixture& f, float seconds, float ownFpm = 0, float frame = .1f)
237{
238 f.bus->VerticalSpeedKms = ownFpm*FPM;
239 for (float elapsed = 0; elapsed < seconds-.0001f; )
240 {
241 const float dt = (std::min)(frame, seconds-elapsed);
242 auto& own = playerships[0];
243 own.position.y += ownFpm*FPM*dt; own.mslKm += ownFpm*FPM*dt;
244 for (int i = 1; i < MAX_SCAN; ++i)
245 if (playerships[i].active)
246 {
249 }
250 f.Step(dt); elapsed += dt;
251 }
252}
253static bool Heard(SOUNDS sound) { return std::find(played.begin(), played.end(), sound) != played.end(); }
254static void LiveAdvisoryRegression()
255{
256 Fixture f; Traffic(f, 1, 6, -100);
257 Fly(f, 20);
258 Check(Heard(SOUND_TCASTRAFFIC) && Heard(SOUND_TCASCLIMB), "converging encounter progresses from TA to climb RA");
259 Check(!Heard(SOUND_TCASMONITOR), "climb does not automatically degrade to repeated monitor calls");
260 Check(f.bus->TCAS >= Bus::RA_Climb && f.bus->TCASTargetOrdinal == 1, "live target displayed");
261 f.bus->GPWS.Alert = Bus::Gpws::Mode1_Pull_Up; f.Step();
262 Check(f.bus->TCAS == Bus::Clear_Of_Conflict && f.bus->TCASTargetOrdinal == -1, "GPWS clears actual advisory");
263}
264static void NuisanceAndTracking()
265{
266 { Fixture f; Traffic(f, 1, 3, 2000); Fly(f, 5);
267 Check(played.empty() && f.bus->TCASTargetOrdinal == -1, "vertically separated traffic is not a threat"); }
268 { Fixture f; auto& t = Traffic(f, 1, 3, 0); t.position.z = 3; Fly(f, 5);
269 Check(played.empty(), "large horizontal miss distance suppresses nuisance alerts"); }
270 { Fixture f; Traffic(f, 1, .3f, 0, 0, -.1f); Fly(f, 5);
271 Check(played.empty(), "receding traffic produces no alert"); }
272 { Fixture f; auto& t = Traffic(f, 1, 3, -100); Fly(f, 5);
273 Check(Heard(SOUND_TCASCLIMB), "traffic with transponder on is detected even with logo light off");
274 t.active = false; Fly(f, 2);
275 Check(f.bus->TCASTargetOrdinal == -1 && Heard(SOUND_TCASCLEAR), "lost target clears advisory and target");
276 played.clear(); t.active = true; t.vehicleId = 999; t.mslKm += 2; Fly(f, 3);
277 Check(played.empty(), "reused scanner slot acquires a new track without stale rate"); }
278 { Fixture f; auto& t = Traffic(f, 1, 3, -100, 600); Fly(f, 2.4f, 0, .6f);
279 Check(std::fabs(t.vsi-600*FPM) < 20*FPM && std::fabs(t.closurerate-.15f) < .003f,
280 "rates use actual 1.2-second sample interval"); }
281 { Fixture f; Traffic(f, 1, 3, -100); Fly(f, 4); played.clear(); f.Step(8);
282 Check(f.bus->TCAS == Bus::Clear_Of_Conflict, "loading pause discards stale tracks"); }
283}
284static void LiveReduceAndMaintain()
285{
286 { Fixture f; Traffic(f, 1, 3.5f, 550); Fly(f, 3, 1500);
287 Check(Heard(SOUND_TCASREDUCECLIMB) && f.bus->TCASTargetVerticalSpeedKms == 0,
288 "converging climb reduces to level flight when that provides separation"); }
289 { Fixture f; Traffic(f, 1, 3.5f, -550); Fly(f, 3, -1500);
290 Check(Heard(SOUND_TCASREDUCEDESCENT), "converging descent reduces to level flight"); }
291 { Fixture f; Traffic(f, 1, 3, -80); Fly(f, 3, 1800);
292 Check(Heard(SOUND_TCASMAINTAIN) && f.bus->TCASTargetVerticalSpeedKms >= 1500*FPM,
293 "adequate existing climb gets maintain rate"); }
294 { Fixture f; Traffic(f, 1, 4, -100); Fly(f, 3); Fly(f, 12, 1500);
295 Check(Heard(SOUND_TCASREDUCECLIMB), "RA weakens after achieving separation before CPA"); }
296}
297static void CrossingAndCamera()
298{
299 { Fixture f; Traffic(f, 1, 3, 200, -1200); Fly(f, 4);
300 Check(Heard(SOUND_TCASCLIMB) && Heard(SOUND_TCASCROSSING) && f.bus->TCASCrossing,
301 "crossing climb selected when non-crossing descent cannot provide separation"); }
302 { Fixture f; Traffic(f, 1, 3, -200, 1200); Fly(f, 4);
303 Check(Heard(SOUND_TCASDESCEND) && Heard(SOUND_TCASCROSSING), "mirrored crossing descent"); }
304 { Fixture f; Traffic(f, 1, 3, 100); RiseMath::MatrixRotationX(&f.view, 3.0f); Fly(f, 4);
305 Check(Heard(SOUND_TCASDESCEND) && !Heard(SOUND_TCASCROSSING),
306 "non-crossing sense preferred and camera orientation has no effect"); }
307}
308static void IncreaseReverseAndInhibits()
309{
310 { Fixture f; auto& t = Traffic(f, 1, 4, -30); Fly(f, 3, 1500);
311 Check(Heard(SOUND_TCASMAINTAIN), "maintain-strengthening scenario starts with adequate current climb");
312 t.velocity.y = 1200*FPM; Fly(f, 5, 1500);
313 Check(Heard(SOUND_TCASINCREASECLIMB), "ineffective maintained positive rate can strengthen"); }
314 { Fixture f; auto& t = Traffic(f, 1, 4, -100); Fly(f, 5);
315 Check(Heard(SOUND_TCASCLIMB), "increase scenario begins with climb");
316 t.velocity.y = 1200*FPM; Fly(f, 5, 1500);
317 Check(Heard(SOUND_TCASINCREASECLIMB), "maneuvering intruder strengthens climb to 2500 fpm"); }
318 { Fixture f; auto& t = Traffic(f, 1, 4, 100); Fly(f, 5);
319 t.velocity.y = -1200*FPM; Fly(f, 5, -1500);
320 Check(Heard(SOUND_TCASINCREASEDESCENT), "mirrored increase descent"); }
321 { Fixture f; auto& t = Traffic(f, 1, 4, -100); Fly(f, 5);
322 t.velocity.y = 5000*FPM; Fly(f, 8, 1500);
323 Check(Heard(SOUND_TCASDESCENDNOW), "ineffective climb reverses after intruder crosses above"); }
324 { Fixture f; f.bus->RadioAltitudeKm = 1050*FT; Traffic(f, 1, 1.5f, 50); Fly(f, 5);
325 Check(!Heard(SOUND_TCASDESCEND) && !Heard(SOUND_TCASDESCENDNOW), "descend inhibited below 1100 feet AGL"); }
326 { Fixture f; f.bus->RadioAltitudeKm = 1300*FT; auto& t = Traffic(f, 1, 2, 100); Fly(f, 5);
327 t.velocity.y = -1200*FPM; Fly(f, 5, -1500);
328 Check(!Heard(SOUND_TCASINCREASEDESCENT), "increase descent inhibited below 1450 feet AGL"); }
329}
330static void MultiThreatAndSpeech()
331{
332 { Fixture f; auto& t = Traffic(f, 1, 4, -100); Fly(f, 4); played.clear();
333 t.velocity.z = .05f; Fly(f, 4);
334 Check(f.bus->TCAS == Bus::Traffic_Advisory && Heard(SOUND_TCASCLEAR) && !Heard(SOUND_TCASTRAFFIC),
335 "RA-to-TA downgrade clears once without re-announcing the same traffic"); }
336 { Fixture f; Traffic(f, 1, 3, 100); Traffic(f, 2, 3, -450); Fly(f, 4);
337 Check(f.bus->TCAS >= Bus::RA_Climb, "multiple intruders produce one shared advisory");
338 Check(f.bus->TCASTargetVerticalSpeedKms >= 0, "selection considers lower secondary threat before descending"); }
339 { Fixture f; auto& t = Traffic(f, 1, 3, -100); f.bus->vmuHold = 30; Fly(f, 3);
340 t.active = false; Fly(f, 2);
341 for (const auto& c : f.bus->commandStream)
342 Check(c.name != "TCASClimb" && c.name != "TCASCrossing", "superseded speech is purged while channel is busy"); }
343 { Fixture f; soundDuration = 10; Traffic(f, 1, 3, -100); Fly(f, 3);
344 playerships[1].active = false; Fly(f, 1.1f);
345 Check(stopped.empty() && !Heard(SOUND_TCASCLEAR), "clear-of-conflict waits for the active TCAS phrase");
346 Fly(f, 10);
347 Check(stopped.empty() && Heard(SOUND_TCASCLEAR), "clear-of-conflict plays after the prior phrase finishes"); }
348}
349
350static void PreventiveSlowClosureAndIdentity()
351{
352 { Fixture f; Traffic(f, 1, 3, 550); Fly(f, 8);
353 Check(Heard(SOUND_TCASMONITOR) && std::count(played.begin(), played.end(), SOUND_TCASMONITOR) == 1,
354 "preventive advisory persists without repeated monitor calls"); }
355 { Fixture f; Traffic(f, 1, .2f, -30, 0, 0); Fly(f, 3);
356 Check(f.bus->TCAS >= Bus::RA_Climb, "fixed-distance threshold protects slow/zero closure encounters"); }
357 { Fixture f; playerships[0].vehicleId = 2; Traffic(f, 1, 3, 0); Fly(f, 3);
358 Check(Heard(SOUND_TCASDESCEND), "higher vehicle ID chooses down in an equal-cost encounter"); }
359 { Fixture f; playerships[0].vehicleId = 1; auto& t = Traffic(f, 1, 3, 0); t.vehicleId = 2; Fly(f, 3);
360 Check(Heard(SOUND_TCASCLIMB), "lower vehicle ID chooses complementary up in equal-cost encounter"); }
361 { Fixture f; auto& t = Traffic(f, 1, 4, 100); Fly(f, 5);
362 t.velocity.y = -5000*FPM; Fly(f, 8, -1500);
363 Check(Heard(SOUND_TCASCLIMBNOW), "mirrored ineffective descent reverses to climb now"); }
364 { Fixture f; soundDuration = 10; auto& t = Traffic(f, 1, 3, 200, -1200); Fly(f, 3);
365 Check(Heard(SOUND_TCASCLIMB) && !Heard(SOUND_TCASCROSSING), "crossing suffix waits for maneuver audio");
366 t.active = false; Fly(f, 2);
367 Check(!Heard(SOUND_TCASCROSSING) && !Heard(SOUND_TCASCLEAR) && stopped.empty(), "obsolete crossing is canceled while maneuver phrase finishes");
368 Fly(f, 10);
369 Check(!Heard(SOUND_TCASCROSSING) && Heard(SOUND_TCASCLEAR), "clear replaces the obsolete crossing suffix after maneuver speech"); }
370}
371static void ContinuousPowerWarmup()
372{
373 Fixture f;
374 ourcockpit.power = 0; f.Step(); played.clear();
375 ourcockpit.power = 1; f.Step(1.2f);
376 ourcockpit.power = 0; f.Step();
377 ourcockpit.power = 1; f.Step(1);
378 Check(!Heard(SOUND_AURALUNITOKAY), "interrupted power cannot accumulate VMU warm-up time");
379 f.Step(1);
380 Check(Heard(SOUND_AURALUNITOKAY), "continuous power completes VMU warm-up");
381}
382
383static void FullVmuTestRegression()
384{
385 Fixture f;
386 playerships[0].reference = REF_ONGROUND; f.bus->RadioAltitudeKm = 0;
387 f.Queue("VMUTest");
388 for (int i = 0; i < 200; ++i) f.Step(1);
389 Check(!f.bus->TCASTestActive && f.bus->TCASTestCallout == -1,
390 "full VMU audio test does not create an unrequested TCAS display test");
391 int tcasVoices = 0;
392 for (auto voice : played)
393 if (voice >= SOUND_TCASTRAFFIC && voice <= SOUND_TCASTESTOK) ++tcasVoices;
394 Check(tcasVoices == 15 && stopped.empty(), "full VMU test includes 15 TCAS voices on ground without truncation");
395}
396
397static void PendingTestControls()
398{
399 Fixture f;
400 f.bus->vmuHold = 5;
401 f.Queue("VMUTest"); f.Queue("TcasSystemTest"); f.Step(); f.Step();
402 Check(f.bus->TCASTestActive && f.bus->commandStream.empty(),
403 "new TCAS test supersedes an older unconsumed VMU test");
404 f.Queue("VMUTest"); f.Step();
405 Check(!f.bus->TCASTestActive, "new VMU test cancels TCAS while audio is busy");
406}
407
408static void BusySequence()
409{
410 TcasAudio::TestSequence sequence; sequence.Start();
411 Check(sequence.Update(30, true) == -1, "busy VMU prevents queued test backlog");
412 Check(sequence.Update(0, false) == 0, "first callout waits for VMU");
413 Check(sequence.Update(0, false) == -1, "long frame does not burst remaining callouts");
414 sequence.Cancel();
415 Check(sequence.Update(30, false) == -1, "canceled sequence stays canceled");
416 sequence.Start();
417 for (int i = 0; i < TcasAudio::Count; ++i)
418 Check(sequence.Update(3, false) == i, "silent test still steps through every display phase");
419 sequence.Update(.1f, false);
420 Check(sequence.Active(), "final OK display remains readable without an audio recording");
421 sequence.Update(2, false);
422 Check(!sequence.Active(), "silent test ends after the final display dwell");
423}
424int main()
425{
426 InhibitsAndResets(); VoicesAndPreemption(); CompleteGroundTest(); CancelAndRestart();
427 DisplayPlaybackAndLifecycle();
428 LiveAdvisoryRegression(); NuisanceAndTracking(); LiveReduceAndMaintain(); CrossingAndCamera();
429 IncreaseReverseAndInhibits(); MultiThreatAndSpeech(); PreventiveSlowClosureAndIdentity(); ContinuousPowerWarmup(); FullVmuTestRegression(); PendingTestControls(); BusySequence();
430 std::cout << "PASS: live TCAS encounter selection, increase/reduce/crossing/reversal, tracking, phrase completion, and 15-callout TCAS/VMU regression suite\n";
431}
SCRIPT_CONTROL SCRIPT_STATE const void int
@ E10
Definition ServerTypes.h:63
#define MAX_SCAN
@ REF_ACLMODE
Definition ServerTypes.h:44
@ REF_ONGROUND
Definition ServerTypes.h:43
SOUNDS
Definition Sound.h:23
@ SOUND_TCASDESCENDNOW
Definition Sound.h:82
@ SOUND_TCASTESTOK
Definition Sound.h:88
@ SOUND_TCASADJUST
Definition Sound.h:84
@ SOUND_AURALUNITOKAY
Definition Sound.h:114
@ SOUND_TCASCLEAR
Definition Sound.h:87
@ SOUND_TCASTRAFFIC
Definition Sound.h:74
@ SOUND_TCASREDUCEDESCENT
Definition Sound.h:80
@ SOUND_TCASCLIMB
Definition Sound.h:75
@ SOUND_TCASMONITOR
Definition Sound.h:85
@ SOUND_TCASCLIMBNOW
Definition Sound.h:81
@ SOUND_TCASCROSSING
Definition Sound.h:86
@ SOUND_TCASINCREASECLIMB
Definition Sound.h:77
@ SOUND_TCASREDUCECLIMB
Definition Sound.h:79
@ SOUND_GPWSPULLUP
Definition Sound.h:45
@ SOUND_ENUMERATION
Definition Sound.h:344
@ SOUND_TCASMAINTAIN
Definition Sound.h:83
@ SOUND_TCASDESCEND
Definition Sound.h:76
@ SOUND_TCASINCREASEDESCENT
Definition Sound.h:78
@ Clear_Of_Conflict
Definition Bus.h:323
@ Traffic_Advisory
Definition Bus.h:324
@ RA_Climb
Definition Bus.h:325
Bus(Logger *prmLogger)
Definition Bus.cpp:55
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition Logger.cpp:283
Logger()
Definition Logger.cpp:392
~Logger()
Definition Logger.cpp:448
void Stop(SOUNDS soundEnum) const
Definition Sound.cpp:3397
std::vector< std::string > sound_path
Definition Sound.h:397
float Play(SOUNDS soundEnum, float volume=1.0f)
Definition Sound.cpp:802
Sound(GameClass *gameptr)
Definition Sound.cpp:69
void FrameMove(float fElapsedTime) override
Definition TCAS.cpp:156
bool Active() const
Definition TcasAudio.h:65
int Update(float seconds, bool busy)
Definition TcasAudio.h:70
void FrameMove(float fElapsedTime) override
Definition VMU.cpp:5
s_network_objects playerships[MAX_SCAN]
Definition globals.cpp:112
Scockpit ourcockpit
Definition globals.cpp:114
Matrix * MatrixRotationX(Matrix *out, float value)
Definition ClientMath.h:126
Matrix * MatrixIdentity(Matrix *out)
Definition ClientMath.h:115
int Find(const char *command)
Definition TcasAudio.h:38
constexpr int Count
Definition TcasAudio.h:36
constexpr Callout Callouts[]
Definition TcasAudio.h:19
GpwsEnum
Definition Bus.h:189
@ Mode1_Pull_Up
Definition Bus.h:194
@ NoAlert
Definition Bus.h:190
@ Mode7_Windshear_Warning
Definition Bus.h:193
@ Reset
Definition Bus.h:247
std::string sValue
Definition Command.h:20
bool bValue
Definition Command.h:22
int ivalues[2]
Definition Command.h:21
std::string name
Definition Command.h:11
float delay
Definition Command.h:8
short texturelib
Definition globals.h:602
float power
Definition globals.h:599
RiseMath::Vector3 position
Definition globals.h:511
unsigned short vehicleId
Definition globals.h:537
RiseMath::Vector3 velocity
Definition globals.h:500