Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
TcasAudio.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstring>
4
5
// Dropship TCAS test order, including its longer pauses after maintain/adjust.
6
// Keep this order aligned with SOUND_TCASTRAFFIC through SOUND_TCASTESTOK.
7
namespace
TcasAudio
8
{
9
struct
Callout
10
{
11
const
char
*
command
;
12
const
char
*
dropshipCommand
;
13
const
char
*
file
;
14
float
intervalAfter
;
15
const
wchar_t
*
testInstruction
;
16
const
wchar_t
*
testDetail
;
17
};
18
19
inline
constexpr
Callout
Callouts
[] = {
20
{
"TCASTraffic"
,
"TrafficTraffic"
,
nullptr
, 2.0f, L
"TRAFFIC"
, L
""
},
21
{
"TCASClimb"
,
"ClimbClimb"
,
nullptr
, 2.0f, L
"CLIMB"
, L
"+1500 FPM"
},
22
{
"TCASDescend"
,
"DescendDescend"
,
nullptr
, 2.0f, L
"DESCEND"
, L
"-1500 FPM"
},
23
{
"TCASIncreaseClimb"
,
"IncreaseClimb"
,
"IncreaseClimb.wav"
, 2.0f, L
"INCREASE CLIMB"
, L
"+2500 FPM"
},
24
{
"TCASIncreaseDescent"
,
"IncreaseDescent"
,
"IncreaseDescent.wav"
, 2.0f, L
"INCREASE DESCENT"
, L
"-2500 FPM"
},
25
{
"TCASReduceClimb"
,
"ReduceClimb"
,
"ReduceClimb.wav"
, 2.0f, L
"REDUCE CLIMB"
, L
"LEVEL OFF / 0 FPM"
},
26
{
"TCASReduceDescent"
,
"ReduceDescent"
,
"ReduceDescent.wav"
, 2.0f, L
"REDUCE DESCENT"
, L
"LEVEL OFF / 0 FPM"
},
27
{
"TCASClimbNow"
,
"ClimbClimbNow"
,
"ClimbClimbNow.wav"
, 2.0f, L
"CLIMB NOW"
, L
"+1500 FPM"
},
28
{
"TCASDescendNow"
,
"DescendDescendNow"
,
"DescendDescendNow.wav"
, 2.0f, L
"DESCEND NOW"
, L
"-1500 FPM"
},
29
{
"TCASMaintain"
,
"MaintainVerticalSpeedMaintain"
,
"MaintainVerticalSpeedMaintain.wav"
, 3.0f, L
"MAINTAIN VERTICAL SPEED"
, L
"+1500 FPM"
},
30
{
"TCASAdjust"
,
"AdjustVerticalSpeedAdjust"
,
"AdjustVerticalSpeedAdjust.wav"
, 3.0f, L
"ADJUST VERTICAL SPEED"
, L
"LEVEL OFF / 0 FPM"
},
31
{
"TCASMonitor"
,
"MonitorVerticalSpeed"
,
nullptr
, 2.0f, L
"MONITOR VERTICAL SPEED"
, L
"DO NOT DESCEND / 0 FPM"
},
32
{
"TCASCrossing"
,
"Crossing"
,
"Crossing.wav"
, 1.5f, L
"CROSSING"
, L
"CLIMB / +1500 FPM"
},
33
{
"TCASClear"
,
"ClearOfConflict"
,
nullptr
, 2.0f, L
"CLEAR OF CONFLICT"
, L
""
},
34
{
"TCASTestOK"
,
"TcasSystemTestOk"
,
"TcasSystemTestOk.wav"
, 2.0f, L
"TCAS SYSTEM TEST OK"
, L
""
}
35
};
36
inline
constexpr
int
Count
=
sizeof
(
Callouts
) /
sizeof
(
Callouts
[0]);
37
38
inline
int
Find
(
const
char
* command)
39
{
40
for
(
int
i = 0; i <
Count
; ++i)
41
if
(std::strcmp(command,
Callouts
[i].command) == 0 ||
42
std::strcmp(command,
Callouts
[i].dropshipCommand) == 0)
43
return
i;
44
return
-1;
45
}
46
47
inline
bool
AltitudeInhibited
(
float
radioAltitudeKm)
48
{
49
return
radioAltitudeKm < 0.3048f;
// 1,000 feet AGL
50
}
51
52
inline
bool
ShouldPlay
(
bool
testCallout,
bool
testActive,
bool
liveInhibited,
53
bool
powered,
bool
gpwsAlert)
54
{
55
return
powered && !gpwsAlert &&
56
(testCallout ? testActive : !testActive && !liveInhibited);
57
}
58
59
class
TestSequence
60
{
61
int
next
= -1;
62
float
elapsed
= 0.0f;
63
float
interval
= 2.0f;
64
public
:
65
bool
Active
()
const
{
return
next
>= 0; }
66
void
Cancel
() {
next
= -1;
elapsed
= 0.0f; }
67
void
Start
() {
next
= 0;
elapsed
= 0.0f;
interval
= 2.0f; }
68
// busy includes both the VMU's playing sound and an unconsumed test command.
69
// Wait for the final callout to finish before ending the test.
70
int
Update
(
float
seconds,
bool
busy)
71
{
72
if
(!
Active
())
return
-1;
73
elapsed
+= seconds;
74
if
(busy)
return
-1;
75
// Keep the final display result readable even if that cockpit has no recording.
76
if
(
next
==
Count
) {
if
(
elapsed
>=
interval
)
Cancel
();
return
-1; }
77
if
(
elapsed
<
interval
)
return
-1;
78
const
int
result =
next
++;
79
elapsed
= 0.0f;
80
interval
=
Callouts
[result].
intervalAfter
;
81
return
result;
82
}
83
};
84
}
TcasAudio::TestSequence
Definition
TcasAudio.h:60
TcasAudio::TestSequence::next
int next
Definition
TcasAudio.h:61
TcasAudio::TestSequence::elapsed
float elapsed
Definition
TcasAudio.h:62
TcasAudio::TestSequence::Active
bool Active() const
Definition
TcasAudio.h:65
TcasAudio::TestSequence::interval
float interval
Definition
TcasAudio.h:63
TcasAudio::TestSequence::Start
void Start()
Definition
TcasAudio.h:67
TcasAudio::TestSequence::Update
int Update(float seconds, bool busy)
Definition
TcasAudio.h:70
TcasAudio::TestSequence::Cancel
void Cancel()
Definition
TcasAudio.h:66
TcasAudio
Definition
TcasAudio.h:8
TcasAudio::Find
int Find(const char *command)
Definition
TcasAudio.h:38
TcasAudio::ShouldPlay
bool ShouldPlay(bool testCallout, bool testActive, bool liveInhibited, bool powered, bool gpwsAlert)
Definition
TcasAudio.h:52
TcasAudio::Count
constexpr int Count
Definition
TcasAudio.h:36
TcasAudio::AltitudeInhibited
bool AltitudeInhibited(float radioAltitudeKm)
Definition
TcasAudio.h:47
TcasAudio::Callouts
constexpr Callout Callouts[]
Definition
TcasAudio.h:19
TcasAudio::Callout
Definition
TcasAudio.h:10
TcasAudio::Callout::intervalAfter
float intervalAfter
Definition
TcasAudio.h:14
TcasAudio::Callout::file
const char * file
Definition
TcasAudio.h:13
TcasAudio::Callout::testDetail
const wchar_t * testDetail
Definition
TcasAudio.h:16
TcasAudio::Callout::testInstruction
const wchar_t * testInstruction
Definition
TcasAudio.h:15
TcasAudio::Callout::command
const char * command
Definition
TcasAudio.h:11
TcasAudio::Callout::dropshipCommand
const char * dropshipCommand
Definition
TcasAudio.h:12
TcasAudio.h
Generated on
for Rise by
1.18.0