3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "harness_flight.hpp"
24 #include "harness_wind.hpp"
27 test_effective_mc(int test_num
, int n_wind
)
29 // tests functionality of effective mc calculations
31 double ce0
, ce1
, ce2
, ce3
, ce4
, ce5
, ce6
;
33 autopilot_parms
.SetIdeal();
35 TestFlightResult result
= test_flight(test_num
, n_wind
);
36 ce0
= result
.calc_effective_mc
;
39 autopilot_parms
.SetRealistic();
40 result
= test_flight(test_num
, n_wind
);
41 ce1
= result
.calc_effective_mc
;
42 // effective mc of this should be lower than nominal
43 if (ce0
<= ce1
|| verbose
)
44 printf("# calc effective mc %g\n", result
.calc_effective_mc
);
46 ok(ce0
> ce1
, GetTestName("emc wandering", test_num
, n_wind
), 0);
49 autopilot_parms
.SetIdeal();
50 result
= test_flight(test_num
, n_wind
, 0.8);
51 ce2
= result
.calc_effective_mc
;
52 // effective mc of this should be lower than nominal
53 if (ce0
<= ce2
|| verbose
)
54 printf("# calc effective mc %g\n", result
.calc_effective_mc
);
56 ok(ce0
> ce2
, GetTestName("emc speed slow", test_num
, n_wind
), 0);
59 autopilot_parms
.SetIdeal();
60 result
= test_flight(test_num
, n_wind
, 1.2);
61 ce3
= result
.calc_effective_mc
;
62 // effective mc of this should be lower than nominal
63 if (ce0
<= ce3
|| verbose
)
64 printf("# calc effective mc %g\n", result
.calc_effective_mc
);
66 ok(ce0
> ce3
, GetTestName("emc speed fast", test_num
, n_wind
), 0);
68 // higher than expected cruise sink
69 autopilot_parms
.sink_factor
= fixed(1.2);
70 result
= test_flight(test_num
, n_wind
);
71 ce4
= result
.calc_effective_mc
;
72 if (ce0
<= ce4
|| verbose
)
73 printf("# calc effective mc %g\n", result
.calc_effective_mc
);
75 ok(ce0
> ce4
, GetTestName("emc high sink", test_num
, n_wind
), 0);
76 // effective mc of this should be lower than nominal
77 autopilot_parms
.sink_factor
= fixed(1.0);
79 // slower than expected climb
80 autopilot_parms
.climb_factor
= fixed(0.8);
81 result
= test_flight(test_num
, n_wind
);
82 ce5
= result
.calc_effective_mc
;
83 if (ce0
<= ce5
|| verbose
)
84 printf("# calc effective mc %g\n", result
.calc_effective_mc
);
86 ok(ce0
> ce5
, GetTestName("emc slow climb", test_num
, n_wind
), 0);
87 // effective mc of this should be lower than nominal
88 autopilot_parms
.climb_factor
= fixed(1.0);
90 // lower than expected cruise sink;
91 autopilot_parms
.sink_factor
= fixed(0.8);
92 result
= test_flight(test_num
, n_wind
);
93 ce6
= result
.calc_effective_mc
;
94 if (ce0
>= ce6
|| verbose
)
95 printf("# calc effective mc %g\n", result
.calc_effective_mc
);
97 ok(ce0
< ce6
, GetTestName("emc low sink", test_num
, n_wind
), 0);
98 // effective mc of this should be greater than nominal
99 autopilot_parms
.sink_factor
= fixed(1.0);
101 bool retval
= (ce0
> ce1
) &&
108 if (verbose
|| !retval
) {
109 printf("# emc nominal %g\n", ce0
);
110 printf("# emc wandering %g\n", ce1
);
111 printf("# emc speed slow %g\n", ce2
);
112 printf("# emc speed fast %g\n", ce3
);
113 printf("# emc high sink %g\n", ce4
);
114 printf("# emc slow climb %g\n", ce5
);
115 printf("# emc low sink %g\n", ce6
);
121 main(int argc
, char** argv
)
124 autopilot_parms
.SetIdeal();
126 if (!ParseArgs(argc
, argv
)) {
132 // tests whether effective mc is calculated correctly
133 unsigned j
= rand() % NUM_WIND
;
134 test_effective_mc(3, j
);
136 return exit_status();