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 "test_debug.hpp"
24 #include "harness_wind.hpp"
25 #include "harness_task.hpp"
26 #include "harness_flight.hpp"
27 #include "Contest/Solvers/ContestDijkstra.hpp"
35 AutopilotParameters autopilot_parms
;
37 int terrain_height
= 1;
38 std::string replay_file
= "test/data/0asljd01.igc";
39 std::string task_file
= "";
41 #ifdef INSTRUMENT_TASK
43 long count_intersections
;
44 extern unsigned n_queries
;
45 extern unsigned count_distbearing
;
48 #ifdef INSTRUMENT_ZERO
49 extern unsigned long zero_skipped
;
50 extern unsigned long zero_total
;
53 void PrintDistanceCounts() {
55 printf("# Instrumentation\n");
56 #ifdef INSTRUMENT_TASK
57 printf("# dist+bearing calcs/c %d\n",count_distbearing
/n_samples
);
58 printf("# mc calcs/c %d\n",(int)(count_mc
/n_samples
));
60 printf("# intersection tests/q %d\n",(unsigned)(count_intersections
/n_queries
));
61 printf("# (total queries %d)\n\n",n_queries
);
64 printf("# (total cycles %d)\n#\n",n_samples
);
65 #ifdef INSTRUMENT_ZERO
67 printf("# ZeroFinder total %ld\n",zero_total
);
68 printf("# ZeroFinder %%skipped %d\n",(int)(100*zero_skipped
/zero_total
));
73 #ifdef INSTRUMENT_TASK
74 count_intersections
= 0;
76 count_distbearing
= 0;
79 #ifdef INSTRUMENT_ZERO
85 void PrintQueries(unsigned n
, std::ostream
&fout
) {
86 #ifdef INSTRUMENT_TASK
88 fout
<< n
<< " " << count_intersections
/n_queries
<< "\n";
90 count_intersections
= 0;
98 * @param time time of simulation
100 * @return character received by keyboard
105 puts("# [enter to continue]");
112 ParseArgs(int argc
, char** argv
)
114 // initialise random number generator once per test program
118 static struct option long_options
[] =
120 /* These options set a flag. */
121 {"verbose", optional_argument
, 0, 'v'},
122 {"interactive", optional_argument
, 0, 'i'},
123 {"startalt", required_argument
, 0, 'a'},
124 {"bearingnoise", required_argument
, 0, 'n'},
125 {"outputskip", required_argument
, 0, 's'},
126 {"targetnoise", required_argument
, 0, 't'},
127 {"turnspeed", required_argument
, 0, 'r'},
128 {"igc", required_argument
, 0, 'f'},
129 {"task", required_argument
, 0, 'x'},
132 /* getopt_long stores the option index here. */
133 int option_index
= 0;
135 int c
= getopt_long (argc
, argv
, "s:v:i:n:t:r:a:f:x:",
136 long_options
, &option_index
);
137 /* Detect the end of the options. */
143 /* If this option set a flag, do nothing else now. */
144 if (long_options
[option_index
].flag
!= 0)
146 printf ("option %s", long_options
[option_index
].name
);
148 printf (" with arg %s", optarg
);
152 replay_file
= optarg
;
158 autopilot_parms
.start_alt
= (fixed
)atof(optarg
);
161 output_skip
= atoi(optarg
);
165 verbose
= atoi(optarg
);
171 autopilot_parms
.bearing_noise
= (fixed
)atof(optarg
);
174 autopilot_parms
.target_noise
= (fixed
)atof(optarg
);
177 autopilot_parms
.turn_speed
= (fixed
)atof(optarg
);
181 interactive
= atoi(optarg
);
187 /* getopt_long already printed an error message. */
189 for (unsigned i
=0; i
+1< sizeof(long_options
)/sizeof(option
); i
++) {
190 switch (long_options
[i
].has_arg
) {
192 printf(" --%s %c\n", long_options
[i
].name
,
193 long_options
[i
].val
);
196 printf(" --%s -%c value\n", long_options
[i
].name
,
197 long_options
[i
].val
);
200 printf(" --%s -%c [value]\n", long_options
[i
].name
,
201 long_options
[i
].val
);
212 if (interactive
&& !verbose
) {
219 const char* GetTestName(const char* in
, int task_num
, int wind_num
)
221 static char buffer
[80];
222 sprintf(buffer
,"%s (task %s, wind %s)", in
, task_name(task_num
), wind_name(wind_num
));