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
24 08/20/2003 (RD) removed old_flap_routine
26 ----------------------------------------------------------------------
28 AUTHOR(S): Robert Deters <rdeters@uiuc.edu>
29 Michael Selig <m-selig@uiuc.edu>
31 ----------------------------------------------------------------------
35 ----------------------------------------------------------------------
39 ----------------------------------------------------------------------
43 ----------------------------------------------------------------------
45 CALLED BY: uiuc_menu()
47 ----------------------------------------------------------------------
49 CALLS TO: check_float() if needed
55 ----------------------------------------------------------------------
57 COPYRIGHT: (C) 2003 by Michael Selig
59 This program is free software; you can redistribute it and/or
60 modify it under the terms of the GNU General Public License
61 as published by the Free Software Foundation.
63 This program is distributed in the hope that it will be useful,
64 but WITHOUT ANY WARRANTY; without even the implied warranty of
65 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66 GNU General Public License for more details.
68 You should have received a copy of the GNU General Public License
69 along with this program; if not, write to the Free Software
70 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
71 USA or view http://www.gnu.org/copyleft/gpl.html.
73 **********************************************************************/
75 #include <simgear/compiler.h>
77 #if defined( __MWERKS__ )
78 // -dw- optimizer chokes (big-time) trying to optimize humongous
79 // loop/switch statements
80 #pragma optimization_level 0
87 #include "uiuc_menu_init.h"
97 void parse_init( const string& linetoken2, const string& linetoken3,
98 const string& linetoken4, const string& linetoken5,
99 const string& linetoken6, const string& linetoken7,
100 const string& linetoken8, const string& linetoken9,
101 const string& linetoken10, const string& aircraft_directory,
102 LIST command_line ) {
104 istringstream token3(linetoken3.c_str());
105 istringstream token4(linetoken4.c_str());
106 istringstream token5(linetoken5.c_str());
107 istringstream token6(linetoken6.c_str());
108 istringstream token7(linetoken7.c_str());
109 istringstream token8(linetoken8.c_str());
110 istringstream token9(linetoken9.c_str());
111 istringstream token10(linetoken10.c_str());
112 int token_value_recordRate;
114 switch(init_map[linetoken2])
118 if (check_float(linetoken3))
119 token3 >> token_value;
121 uiuc_warnings_errors(1, *command_line);
123 Dx_pilot = token_value;
124 initParts -> storeCommands (*command_line);
129 if (check_float(linetoken3))
130 token3 >> token_value;
132 uiuc_warnings_errors(1, *command_line);
134 Dy_pilot = token_value;
135 initParts -> storeCommands (*command_line);
140 if (check_float(linetoken3))
141 token3 >> token_value;
143 uiuc_warnings_errors(1, *command_line);
145 Dz_pilot = token_value;
146 initParts -> storeCommands (*command_line);
151 if (check_float(linetoken3))
152 token3 >> token_value;
154 uiuc_warnings_errors(1, *command_line);
157 initParts -> storeCommands (*command_line);
162 if (check_float(linetoken3))
163 token3 >> token_value;
165 uiuc_warnings_errors(1, *command_line);
168 initParts -> storeCommands (*command_line);
173 if (check_float(linetoken3))
174 token3 >> token_value;
176 uiuc_warnings_errors(1, *command_line);
179 initParts -> storeCommands (*command_line);
184 if (check_float(linetoken3))
185 token3 >> token_value;
187 uiuc_warnings_errors(1, *command_line);
189 Altitude = token_value;
190 initParts -> storeCommands (*command_line);
195 if (check_float(linetoken3))
196 token3 >> token_value;
198 uiuc_warnings_errors(1, *command_line);
200 V_north = token_value;
201 initParts -> storeCommands (*command_line);
206 initParts -> storeCommands (*command_line);
207 if (check_float(linetoken3))
208 token3 >> token_value;
210 uiuc_warnings_errors(1, *command_line);
212 V_east = token_value;
217 if (check_float(linetoken3))
218 token3 >> token_value;
220 uiuc_warnings_errors(1, *command_line);
222 V_down = token_value;
223 initParts -> storeCommands (*command_line);
228 if (check_float(linetoken3))
229 token3 >> token_value;
231 uiuc_warnings_errors(1, *command_line);
233 P_body_init_true = true;
234 P_body_init = token_value;
235 initParts -> storeCommands (*command_line);
240 if (check_float(linetoken3))
241 token3 >> token_value;
243 uiuc_warnings_errors(1, *command_line);
245 Q_body_init_true = true;
246 Q_body_init = token_value;
247 initParts -> storeCommands (*command_line);
252 if (check_float(linetoken3))
253 token3 >> token_value;
255 uiuc_warnings_errors(1, *command_line);
257 R_body_init_true = true;
258 R_body_init = token_value;
259 initParts -> storeCommands (*command_line);
264 if (check_float(linetoken3))
265 token3 >> token_value;
267 uiuc_warnings_errors(1, *command_line);
269 Phi_init_true = true;
270 Phi_init = token_value;
271 initParts -> storeCommands (*command_line);
276 if (check_float(linetoken3))
277 token3 >> token_value;
279 uiuc_warnings_errors(1, *command_line);
281 Theta_init_true = true;
282 Theta_init = token_value;
283 initParts -> storeCommands (*command_line);
288 if (check_float(linetoken3))
289 token3 >> token_value;
291 uiuc_warnings_errors(1, *command_line);
293 Psi_init_true = true;
294 Psi_init = token_value;
295 initParts -> storeCommands (*command_line);
300 if (check_float(linetoken3))
301 token3 >> token_value;
303 uiuc_warnings_errors(1, *command_line);
305 Long_trim = token_value;
306 initParts -> storeCommands (*command_line);
309 case recordRate_flag:
311 //can't use check_float since variable is integer
312 token3 >> token_value_recordRate;
313 recordRate = 120 / token_value_recordRate;
316 case recordStartTime_flag:
318 if (check_float(linetoken3))
319 token3 >> token_value;
321 uiuc_warnings_errors(1, *command_line);
323 recordStartTime = token_value;
326 case use_V_rel_wind_2U_flag:
328 use_V_rel_wind_2U = true;
331 case nondim_rate_V_rel_wind_flag:
333 nondim_rate_V_rel_wind = true;
336 case use_abs_U_body_2U_flag:
338 use_abs_U_body_2U = true;
341 case dyn_on_speed_flag:
343 if (check_float(linetoken3))
344 token3 >> token_value;
346 uiuc_warnings_errors(1, *command_line);
348 dyn_on_speed = token_value;
351 case dyn_on_speed_zero_flag:
353 if (check_float(linetoken3))
354 token3 >> token_value;
356 uiuc_warnings_errors(1, *command_line);
358 dyn_on_speed_zero = token_value;
361 case use_dyn_on_speed_curve1_flag:
363 use_dyn_on_speed_curve1 = true;
366 case use_Alpha_dot_on_speed_flag:
368 use_Alpha_dot_on_speed = true;
369 if (check_float(linetoken3))
370 token3 >> token_value;
372 uiuc_warnings_errors(1, *command_line);
373 Alpha_dot_on_speed = token_value;
376 case use_gamma_horiz_on_speed_flag:
378 use_gamma_horiz_on_speed = true;
379 if (check_float(linetoken3))
380 token3 >> token_value;
382 uiuc_warnings_errors(1, *command_line);
383 gamma_horiz_on_speed = token_value;
386 case downwashMode_flag:
388 b_downwashMode = true;
389 token3 >> downwashMode;
390 if (downwashMode==100)
392 // compute downwash using downwashCoef, do nothing here
394 uiuc_warnings_errors(4, *command_line);
397 case downwashCoef_flag:
399 if (check_float(linetoken3))
400 token3 >> token_value;
402 uiuc_warnings_errors(1, *command_line);
403 downwashCoef = token_value;
408 if (check_float(linetoken3))
409 token3 >> token_value;
411 uiuc_warnings_errors(1, *command_line);
413 Alpha_init_true = true;
414 Alpha_init = token_value;
419 if (check_float(linetoken3))
420 token3 >> token_value;
422 uiuc_warnings_errors(1, *command_line);
424 Beta_init_true = true;
425 Beta_init = token_value;
430 if (check_float(linetoken3))
431 token3 >> token_value;
433 uiuc_warnings_errors(1, *command_line);
435 U_body_init_true = true;
436 U_body_init = token_value;
441 if (check_float(linetoken3))
442 token3 >> token_value;
444 uiuc_warnings_errors(1, *command_line);
446 V_body_init_true = true;
447 V_body_init = token_value;
452 if (check_float(linetoken3))
453 token3 >> token_value;
455 uiuc_warnings_errors(1, *command_line);
457 W_body_init_true = true;
458 W_body_init = token_value;
461 case ignore_unknown_keywords_flag:
463 ignore_unknown_keywords=true;
466 case trim_case_2_flag:
471 case use_uiuc_network_flag:
473 use_uiuc_network = true;
474 server_IP = linetoken3;
478 case icing_demo_flag:
483 case outside_control_flag:
485 outside_control = true;
490 if (ignore_unknown_keywords){
493 // print error message
494 uiuc_warnings_errors(2, *command_line);