1 /**********************************************************************
3 FILENAME: uiuc_menu_init.cpp
5 ----------------------------------------------------------------------
7 DESCRIPTION: reads input data for specified aircraft and creates
8 approporiate data storage space
10 ----------------------------------------------------------------------
14 ----------------------------------------------------------------------
16 REFERENCES: based on "menu reader" format of Michael Selig
18 ----------------------------------------------------------------------
20 HISTORY: 04/04/2003 initial release
21 06/30/2003 (RD) replaced istrstream with istringstream
22 to get rid of the annoying warning about
23 using the strstream header
25 ----------------------------------------------------------------------
27 AUTHOR(S): Robert Deters <rdeters@uiuc.edu>
28 Michael Selig <m-selig@uiuc.edu>
30 ----------------------------------------------------------------------
34 ----------------------------------------------------------------------
38 ----------------------------------------------------------------------
42 ----------------------------------------------------------------------
44 CALLED BY: uiuc_menu()
46 ----------------------------------------------------------------------
48 CALLS TO: check_float() if needed
54 ----------------------------------------------------------------------
56 COPYRIGHT: (C) 2003 by Michael Selig
58 This program is free software; you can redistribute it and/or
59 modify it under the terms of the GNU General Public License
60 as published by the Free Software Foundation.
62 This program is distributed in the hope that it will be useful,
63 but WITHOUT ANY WARRANTY; without even the implied warranty of
64 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
65 GNU General Public License for more details.
67 You should have received a copy of the GNU General Public License
68 along with this program; if not, write to the Free Software
69 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
70 USA or view http://www.gnu.org/copyleft/gpl.html.
72 **********************************************************************/
74 #include <simgear/compiler.h>
76 #if defined( __MWERKS__ )
77 // -dw- optimizer chokes (big-time) trying to optimize humongous
78 // loop/switch statements
79 #pragma optimization_level 0
86 #include "uiuc_menu_init.h"
96 void parse_init( const string& linetoken2, const string& linetoken3,
97 const string& linetoken4, const string& linetoken5,
98 const string& linetoken6, const string& linetoken7,
99 const string& linetoken8, const string& linetoken9,
100 const string& linetoken10, const string& aircraft_directory,
101 LIST command_line ) {
103 istringstream token3(linetoken3.c_str());
104 istringstream token4(linetoken4.c_str());
105 istringstream token5(linetoken5.c_str());
106 istringstream token6(linetoken6.c_str());
107 istringstream token7(linetoken7.c_str());
108 istringstream token8(linetoken8.c_str());
109 istringstream token9(linetoken9.c_str());
110 istringstream token10(linetoken10.c_str());
111 int token_value_recordRate;
113 switch(init_map[linetoken2])
117 if (check_float(linetoken3))
118 token3 >> token_value;
120 uiuc_warnings_errors(1, *command_line);
122 Dx_pilot = token_value;
123 initParts -> storeCommands (*command_line);
128 if (check_float(linetoken3))
129 token3 >> token_value;
131 uiuc_warnings_errors(1, *command_line);
133 Dy_pilot = token_value;
134 initParts -> storeCommands (*command_line);
139 if (check_float(linetoken3))
140 token3 >> token_value;
142 uiuc_warnings_errors(1, *command_line);
144 Dz_pilot = token_value;
145 initParts -> storeCommands (*command_line);
150 if (check_float(linetoken3))
151 token3 >> token_value;
153 uiuc_warnings_errors(1, *command_line);
156 initParts -> storeCommands (*command_line);
161 if (check_float(linetoken3))
162 token3 >> token_value;
164 uiuc_warnings_errors(1, *command_line);
167 initParts -> storeCommands (*command_line);
172 if (check_float(linetoken3))
173 token3 >> token_value;
175 uiuc_warnings_errors(1, *command_line);
178 initParts -> storeCommands (*command_line);
183 if (check_float(linetoken3))
184 token3 >> token_value;
186 uiuc_warnings_errors(1, *command_line);
188 Altitude = token_value;
189 initParts -> storeCommands (*command_line);
194 if (check_float(linetoken3))
195 token3 >> token_value;
197 uiuc_warnings_errors(1, *command_line);
199 V_north = token_value;
200 initParts -> storeCommands (*command_line);
205 initParts -> storeCommands (*command_line);
206 if (check_float(linetoken3))
207 token3 >> token_value;
209 uiuc_warnings_errors(1, *command_line);
211 V_east = token_value;
216 if (check_float(linetoken3))
217 token3 >> token_value;
219 uiuc_warnings_errors(1, *command_line);
221 V_down = token_value;
222 initParts -> storeCommands (*command_line);
227 if (check_float(linetoken3))
228 token3 >> token_value;
230 uiuc_warnings_errors(1, *command_line);
232 P_body_init_true = true;
233 P_body_init = token_value;
234 initParts -> storeCommands (*command_line);
239 if (check_float(linetoken3))
240 token3 >> token_value;
242 uiuc_warnings_errors(1, *command_line);
244 Q_body_init_true = true;
245 Q_body_init = token_value;
246 initParts -> storeCommands (*command_line);
251 if (check_float(linetoken3))
252 token3 >> token_value;
254 uiuc_warnings_errors(1, *command_line);
256 R_body_init_true = true;
257 R_body_init = token_value;
258 initParts -> storeCommands (*command_line);
263 if (check_float(linetoken3))
264 token3 >> token_value;
266 uiuc_warnings_errors(1, *command_line);
268 Phi_init_true = true;
269 Phi_init = token_value;
270 initParts -> storeCommands (*command_line);
275 if (check_float(linetoken3))
276 token3 >> token_value;
278 uiuc_warnings_errors(1, *command_line);
280 Theta_init_true = true;
281 Theta_init = token_value;
282 initParts -> storeCommands (*command_line);
287 if (check_float(linetoken3))
288 token3 >> token_value;
290 uiuc_warnings_errors(1, *command_line);
292 Psi_init_true = true;
293 Psi_init = token_value;
294 initParts -> storeCommands (*command_line);
299 if (check_float(linetoken3))
300 token3 >> token_value;
302 uiuc_warnings_errors(1, *command_line);
304 Long_trim = token_value;
305 initParts -> storeCommands (*command_line);
308 case recordRate_flag:
310 //can't use check_float since variable is integer
311 token3 >> token_value_recordRate;
312 recordRate = 120 / token_value_recordRate;
315 case recordStartTime_flag:
317 if (check_float(linetoken3))
318 token3 >> token_value;
320 uiuc_warnings_errors(1, *command_line);
322 recordStartTime = token_value;
325 case use_V_rel_wind_2U_flag:
327 use_V_rel_wind_2U = true;
330 case nondim_rate_V_rel_wind_flag:
332 nondim_rate_V_rel_wind = true;
335 case use_abs_U_body_2U_flag:
337 use_abs_U_body_2U = true;
340 case dyn_on_speed_flag:
342 if (check_float(linetoken3))
343 token3 >> token_value;
345 uiuc_warnings_errors(1, *command_line);
347 dyn_on_speed = token_value;
350 case dyn_on_speed_zero_flag:
352 if (check_float(linetoken3))
353 token3 >> token_value;
355 uiuc_warnings_errors(1, *command_line);
357 dyn_on_speed_zero = token_value;
360 case use_dyn_on_speed_curve1_flag:
362 use_dyn_on_speed_curve1 = true;
365 case use_Alpha_dot_on_speed_flag:
367 use_Alpha_dot_on_speed = true;
368 if (check_float(linetoken3))
369 token3 >> token_value;
371 uiuc_warnings_errors(1, *command_line);
372 Alpha_dot_on_speed = token_value;
375 case use_gamma_horiz_on_speed_flag:
377 use_gamma_horiz_on_speed = true;
378 if (check_float(linetoken3))
379 token3 >> token_value;
381 uiuc_warnings_errors(1, *command_line);
382 gamma_horiz_on_speed = token_value;
385 case downwashMode_flag:
387 b_downwashMode = true;
388 token3 >> downwashMode;
389 if (downwashMode==100)
391 // compute downwash using downwashCoef, do nothing here
393 uiuc_warnings_errors(4, *command_line);
396 case downwashCoef_flag:
398 if (check_float(linetoken3))
399 token3 >> token_value;
401 uiuc_warnings_errors(1, *command_line);
402 downwashCoef = token_value;
407 if (check_float(linetoken3))
408 token3 >> token_value;
410 uiuc_warnings_errors(1, *command_line);
412 Alpha_init_true = true;
413 Alpha_init = token_value;
418 if (check_float(linetoken3))
419 token3 >> token_value;
421 uiuc_warnings_errors(1, *command_line);
423 Beta_init_true = true;
424 Beta_init = token_value;
429 if (check_float(linetoken3))
430 token3 >> token_value;
432 uiuc_warnings_errors(1, *command_line);
434 U_body_init_true = true;
435 U_body_init = token_value;
440 if (check_float(linetoken3))
441 token3 >> token_value;
443 uiuc_warnings_errors(1, *command_line);
445 V_body_init_true = true;
446 V_body_init = token_value;
451 if (check_float(linetoken3))
452 token3 >> token_value;
454 uiuc_warnings_errors(1, *command_line);
456 W_body_init_true = true;
457 W_body_init = token_value;
460 case ignore_unknown_keywords_flag:
462 ignore_unknown_keywords=true;
465 case trim_case_2_flag:
470 case use_uiuc_network_flag:
472 use_uiuc_network = true;
473 server_IP = linetoken3;
477 case old_flap_routine_flag:
479 old_flap_routine = true;
482 case icing_demo_flag:
487 case outside_control_flag:
489 outside_control = true;
494 if (ignore_unknown_keywords){
497 // print error message
498 uiuc_warnings_errors(2, *command_line);