1
2#include "../TcasAudio.h"
3
4template<
class Render>
static void CheckTcasDisplayOnMap(
Bus& bus, Render render)
5{
8 const auto baseline = render("tcas-normal-map");
11 const auto symbols = render("tcas-display-check");
12 Check(symbols != baseline, "TCAS test must appear with transponder off");
13 auto previous = symbols;
15 {
17 const auto current = render("tcas-test-" + std::to_string(callout));
18 Check(current != previous, "every TCAS phrase must update the actual navigation display");
19 previous = current;
20 }
22 Check(render("tcas-test-cancelled") == baseline, "TCAS cancellation must restore the original map exactly");
25}
26
27static void CheckTcasMapDeclutter(NativeUiTest11& fixture,
DeviceObject& device,
28 Bus& bus,
Logger& logger,
const std::vector<Font*>& fonts)
29{
30 const auto savedGpws=bus.
GPWS;
31 const auto savedWaypoints=bus.
waypoint;
32 const auto savedMode=bus.
TCAS;
42 MovingMap map(32,32,.468f,.468f,&bus,&logger,&device,fonts);
43 auto draw=[&] {
44 map.FrameMove(1);map.FrameMove(1);
46 NativeUiTest11::HR(fixture.device.BeginScene());
52 map.Render();NativeUiTest11::HR(device.
pSprite->
End());
53 NativeUiTest11::HR(fixture.device.EndScene());fixture.DebugClean();return fixture.Pixels();
54 };
55
56
57 const auto compassOnly=draw();
58 Check(std::any_of(compassOnly.begin(),compassOnly.end(),[](
DWORD p){return p!=0xff000000;}),
59 "TCAS declutter reference must retain the compass and heading cues");
61 {
64 }
66 const auto navigationOnly=draw();
67 Check(navigationOnly!=compassOnly,"reference must contain waypoint symbols, labels, airspace and arena");
69 for(const bool assay : {false,true})
70 {
72 map.FrameMove(16);
74 const auto withoutSurface=draw();
75 Check(assay ? withoutSurface!=navigationOnly : withoutSurface==navigationOnly,
76 "reference must preserve the assay overlay when powered");
78 const auto normal=draw();
79 Check(assay ? normal==withoutSurface : normal!=withoutSurface,
80 "normal surface fill must be visible unless replaced by assay");
82 {
83 if(mode==0)continue;
86 Check(draw()==withoutSurface,
87 "TCAS test, TA and every RA must omit only surface fill, preserving all overlays");
88 }
90 Check(draw()==withoutSurface,"TCAS test over an RA must preserve overlays without surface fill");
92 Check(draw()==withoutSurface,"ending a test cannot restore surface fill during an RA");
94 Check(draw()==normal,"clear of conflict must restore surface fill without changing overlays");
95 }
98 Check(draw()!=navigationOnly,"TCAS declutter must preserve the GPWS warning annunciation");
101 terrain.
enabled=terrain.terrainComplete=terrain.obstaclesComplete=
true;
103 for(int u=0;u<63;++u)for(int v=0;v<63;++v)
104 {
105 auto& cell=terrain.cells[u*63+v];
107 cell.topKm=.1f+float((u+v)%8)*.2f;
108 }
109 const auto relative=draw();
110 Check(relative!=navigationOnly,"GPWS must display relative terrain when a hazard is active");
111 unsigned navigationInk=0;
112 for(size_t i=0;i<navigationOnly.size();++i)
113 if(navigationOnly[i]==0xffffffff && compassOnly[i]!=navigationOnly[i])
114 {
115 ++navigationInk;
116 Check(relative[i]==navigationOnly[i],"GPWS relative terrain must retain navigation glyphs");
117 }
118 Check(navigationInk>30,"GPWS overlay check needs visible navigation glyphs");
120 {
121 if(mode==0)continue;
124 Check(draw()==relative,"TCAS must preserve GPWS relative terrain, peaks and navigation overlays");
125 }
127 Check(draw()==navigationOnly,"clearing GPWS during an RA leaves navigation with no surface fill");
129 Check(draw()!=navigationOnly,"clearing both hazards restores the surface map");
135 std::cout<<"TCAS surface declutter: self-test, TA, all RAs, navigation/assay preservation, restoration and simultaneous GPWS terrain passed\n";
136}
137
138static void CheckTcasDisplayRendering(NativeUiTest11& fixture,
DeviceObject& device,
139 Bus& bus,
Logger& logger,
const std::vector<Font*>& fonts)
140{
141 TCASOverlay overlay(32,32,.468f,.468f,&bus,&logger,&device,fonts);
146 auto begin = [&] {
148 NativeUiTest11::HR(fixture.device.BeginScene());
154 };
155 auto end = [&] {
157 NativeUiTest11::HR(fixture.device.EndScene());
158 fixture.DebugClean(); return fixture.Pixels();
159 };
160 const int cx = 32 +
int(265*.468f), top = 32 +
int(265*.468f) - 84;
161 auto compareText = [&](
const std::vector<DWORD>& actual,
const wchar_t* text,
int atX,
int atY,
DWORD color,
bool centered) {
164 RECT rect = {atX,atY,atX,atY};
165 NativeUiTest11::HR(fonts[1]->pFont->DrawTextW(device.
pSprite,text,-1,&rect,
166 DT_NOCLIP | (centered ? DT_CENTER : 0),color));
167 const auto expected = end(); int solid = 0;
168 for (int py = atY; py < atY+13; ++py) for (int px = cx-64; px < cx+64; ++px)
169 if (expected[size_t(py)*1024+px] == color)
170 {
171 ++solid;
172 Check(actual[size_t(py)*1024+px] == color, "TCAS test text, altitude or trend glyph is missing/obscured");
173 }
174 Check(solid > 0, "TCAS expected text produced no solid glyph pixels");
175 };
176 const wchar_t* instruction[] = {L"TRAFFIC",L"CLIMB",L"DESCEND",L"INCREASE CLIMB",L"INCREASE DESCENT",
177 L"REDUCE CLIMB",L"REDUCE DESCENT",L"CLIMB NOW",L"DESCEND NOW",L"MAINTAIN VERTICAL SPEED",
178 L"ADJUST VERTICAL SPEED",L"MONITOR VERTICAL SPEED",L"CROSSING",L"CLEAR OF CONFLICT",L"TCAS SYSTEM TEST OK"};
180 for (int callout = 0; callout < 15; ++callout)
181 {
183
184 begin(); overlay.Render(); const auto actual = end();
185 compareText(actual,L"TCAS TEST",cx,top+7,0xffffffff,true);
186 compareText(actual,instruction[callout],cx,top+21,
187 callout == 0 ? 0xffffaa00 : callout < 13 ? 0xffff0000 : 0xffffffff,true);
188 compareText(actual,L"05",cx-51,top+54,0xff0088ff,false);
189 compareText(actual,L"01",cx-21,top+74,0xff0088ff,false);
190 compareText(actual,L"02\u2191",cx+9,top+54,0xffffaa00,false);
191 compareText(actual,L"02\u2193",cx+39,top+74,0xffff0000,false);
192 const int offsets[] = {-51,-21,9,39};
193 for (int symbol = 0; symbol < 4; ++symbol)
194 {
195 int ink = 0;
196 for (int py = top+64; py < top+73; ++py)
197 for (int px = cx+offsets[symbol]; px < cx+offsets[symbol]+13; ++px)
198 {
199
200
201 const DWORD pixel = actual[size_t(py)*1024+px];
202 const int r = (pixel >> 16)&255, g = (pixel >> 8)&255, b = pixel&255;
203 ink += symbol < 2 ? b > r+20 && b > g :
204 symbol == 2 ? r > g && g > b+20 : r > g+20 && r > b+20;
205 }
206 Check(ink > 0, "one of the four TCAS test symbols is absent or has the wrong color");
207 }
208 }
210 overlay.FrameMove(.1f); begin(); overlay.Render(); const auto cleared = end();
211 Check(std::all_of(cleared.begin(),cleared.end(),[](
DWORD p) { return p == 0xff000000; }),
212 "cancelled test leaves no symbols or text in the overlay");
214 const auto savedMode = bus.
TCAS;
223 overlay.FrameMove(1); begin(); overlay.Render(); const auto live = end();
224 Check(live != cleared, "live traffic must render outside test mode");
226 overlay.FrameMove(1); begin(); overlay.Render(); end();
228 "test rendering cannot change scanner or advisory state");
230 begin(); overlay.Render();
231 Check(end() == live, "test exit immediately restores the real target depiction");
233 target.active =
false; overlay.FrameMove(1);
235 Check(end() == cleared, "traffic lost during testing must not reappear when testing ends");
239 CheckTcasMapDeclutter(fixture,device,bus,logger,fonts);
240 std::cout << "TCAS display: all phrases, four symbols, altitude/trend glyphs, page entry and cancellation passed\n";
241}
SCRIPT_CONTROL SCRIPT_STATE const void int
SCRIPT_CONTROL SCRIPT_STATE const void DWORD
float MapScaleInnerRingKm
std::vector< Swaypoint > waypoint
RiseMath::Vector3 BattleRoyaleRingCenter
Rendering::RenderSprite * pSprite
HRESULT Begin(DWORD flags)
HRESULT SetTransform(const RiseMath::Matrix *value)
s_network_objects playerships[MAX_SCAN]
LOCALGRID2 gridarray[64][64]
constexpr uint32_t TARGET
constexpr uint32_t STENCILENABLE
constexpr uint32_t SCISSORTESTENABLE
constexpr uint32_t ZENABLE
constexpr DWORD AlphaBlend
constexpr DWORD SortTexture
constexpr DWORD SortBackToFront
Matrix * MatrixIdentity(Matrix *out)
enum Bus::Gpws::GpwsEnum Alert
TerrainAwareness::State terrain
RiseMath::Vector3 location
RiseMath::Vector3 position