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
22 ----------------------------------------------------------------------
24 AUTHOR(S): Robert Deters <rdeters@uiuc.edu>
25 Michael Selig <m-selig@uiuc.edu>
27 ----------------------------------------------------------------------
31 ----------------------------------------------------------------------
35 ----------------------------------------------------------------------
39 ----------------------------------------------------------------------
41 CALLED BY: uiuc_menu()
43 ----------------------------------------------------------------------
45 CALLS TO: check_float() if needed
51 ----------------------------------------------------------------------
53 COPYRIGHT: (C) 2003 by Michael Selig
55 This program is free software; you can redistribute it and/or
56 modify it under the terms of the GNU General Public License
57 as published by the Free Software Foundation.
59 This program is distributed in the hope that it will be useful,
60 but WITHOUT ANY WARRANTY; without even the implied warranty of
61 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
62 GNU General Public License for more details.
64 You should have received a copy of the GNU General Public License
65 along with this program; if not, write to the Free Software
66 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
67 USA or view http://www.gnu.org/copyleft/gpl.html.
69 **********************************************************************/
71 #include <simgear/compiler.h>
73 #if defined( __MWERKS__ )
74 // -dw- optimizer chokes (big-time) trying to optimize humongous
75 // loop/switch statements
76 #pragma optimization_level 0
83 #include "uiuc_menu_init.h"
93 void parse_init( const string& linetoken2, const string& linetoken3,
94 const string& linetoken4, const string& linetoken5,
95 const string& linetoken6, const string& linetoken7,
96 const string& linetoken8, const string& linetoken9,
97 const string& linetoken10, const string& aircraft_directory,
100 istrstream token3(linetoken3.c_str());
101 istrstream token4(linetoken4.c_str());
102 istrstream token5(linetoken5.c_str());
103 istrstream token6(linetoken6.c_str());
104 istrstream token7(linetoken7.c_str());
105 istrstream token8(linetoken8.c_str());
106 istrstream token9(linetoken9.c_str());
107 istrstream token10(linetoken10.c_str());
108 int token_value_recordRate;
110 switch(init_map[linetoken2])
114 if (check_float(linetoken3))
115 token3 >> token_value;
117 uiuc_warnings_errors(1, *command_line);
119 Dx_pilot = token_value;
120 initParts -> storeCommands (*command_line);
125 if (check_float(linetoken3))
126 token3 >> token_value;
128 uiuc_warnings_errors(1, *command_line);
130 Dy_pilot = token_value;
131 initParts -> storeCommands (*command_line);
136 if (check_float(linetoken3))
137 token3 >> token_value;
139 uiuc_warnings_errors(1, *command_line);
141 Dz_pilot = token_value;
142 initParts -> storeCommands (*command_line);
147 if (check_float(linetoken3))
148 token3 >> token_value;
150 uiuc_warnings_errors(1, *command_line);
153 initParts -> storeCommands (*command_line);
158 if (check_float(linetoken3))
159 token3 >> token_value;
161 uiuc_warnings_errors(1, *command_line);
164 initParts -> storeCommands (*command_line);
169 if (check_float(linetoken3))
170 token3 >> token_value;
172 uiuc_warnings_errors(1, *command_line);
175 initParts -> storeCommands (*command_line);
180 if (check_float(linetoken3))
181 token3 >> token_value;
183 uiuc_warnings_errors(1, *command_line);
185 Altitude = token_value;
186 initParts -> storeCommands (*command_line);
191 if (check_float(linetoken3))
192 token3 >> token_value;
194 uiuc_warnings_errors(1, *command_line);
196 V_north = token_value;
197 initParts -> storeCommands (*command_line);
202 initParts -> storeCommands (*command_line);
203 if (check_float(linetoken3))
204 token3 >> token_value;
206 uiuc_warnings_errors(1, *command_line);
208 V_east = token_value;
213 if (check_float(linetoken3))
214 token3 >> token_value;
216 uiuc_warnings_errors(1, *command_line);
218 V_down = token_value;
219 initParts -> storeCommands (*command_line);
224 if (check_float(linetoken3))
225 token3 >> token_value;
227 uiuc_warnings_errors(1, *command_line);
229 P_body_init_true = true;
230 P_body_init = token_value;
231 initParts -> storeCommands (*command_line);
236 if (check_float(linetoken3))
237 token3 >> token_value;
239 uiuc_warnings_errors(1, *command_line);
241 Q_body_init_true = true;
242 Q_body_init = token_value;
243 initParts -> storeCommands (*command_line);
248 if (check_float(linetoken3))
249 token3 >> token_value;
251 uiuc_warnings_errors(1, *command_line);
253 R_body_init_true = true;
254 R_body_init = token_value;
255 initParts -> storeCommands (*command_line);
260 if (check_float(linetoken3))
261 token3 >> token_value;
263 uiuc_warnings_errors(1, *command_line);
265 Phi_init_true = true;
266 Phi_init = token_value;
267 initParts -> storeCommands (*command_line);
272 if (check_float(linetoken3))
273 token3 >> token_value;
275 uiuc_warnings_errors(1, *command_line);
277 Theta_init_true = true;
278 Theta_init = token_value;
279 initParts -> storeCommands (*command_line);
284 if (check_float(linetoken3))
285 token3 >> token_value;
287 uiuc_warnings_errors(1, *command_line);
289 Psi_init_true = true;
290 Psi_init = token_value;
291 initParts -> storeCommands (*command_line);
296 if (check_float(linetoken3))
297 token3 >> token_value;
299 uiuc_warnings_errors(1, *command_line);
301 Long_trim = token_value;
302 initParts -> storeCommands (*command_line);
305 case recordRate_flag:
307 //can't use check_float since variable is integer
308 token3 >> token_value_recordRate;
309 recordRate = 120 / token_value_recordRate;
312 case recordStartTime_flag:
314 if (check_float(linetoken3))
315 token3 >> token_value;
317 uiuc_warnings_errors(1, *command_line);
319 recordStartTime = token_value;
322 case use_V_rel_wind_2U_flag:
324 use_V_rel_wind_2U = true;
327 case nondim_rate_V_rel_wind_flag:
329 nondim_rate_V_rel_wind = true;
332 case use_abs_U_body_2U_flag:
334 use_abs_U_body_2U = true;
337 case dyn_on_speed_flag:
339 if (check_float(linetoken3))
340 token3 >> token_value;
342 uiuc_warnings_errors(1, *command_line);
344 dyn_on_speed = token_value;
347 case dyn_on_speed_zero_flag:
349 if (check_float(linetoken3))
350 token3 >> token_value;
352 uiuc_warnings_errors(1, *command_line);
354 dyn_on_speed_zero = token_value;
357 case use_dyn_on_speed_curve1_flag:
359 use_dyn_on_speed_curve1 = true;
362 case use_Alpha_dot_on_speed_flag:
364 use_Alpha_dot_on_speed = true;
365 if (check_float(linetoken3))
366 token3 >> token_value;
368 uiuc_warnings_errors(1, *command_line);
369 Alpha_dot_on_speed = token_value;
372 case use_gamma_horiz_on_speed_flag:
374 use_gamma_horiz_on_speed = true;
375 if (check_float(linetoken3))
376 token3 >> token_value;
378 uiuc_warnings_errors(1, *command_line);
379 gamma_horiz_on_speed = token_value;
382 case downwashMode_flag:
384 b_downwashMode = true;
385 token3 >> downwashMode;
386 if (downwashMode==100)
388 // compute downwash using downwashCoef, do nothing here
390 uiuc_warnings_errors(4, *command_line);
393 case downwashCoef_flag:
395 if (check_float(linetoken3))
396 token3 >> token_value;
398 uiuc_warnings_errors(1, *command_line);
399 downwashCoef = token_value;
404 if (check_float(linetoken3))
405 token3 >> token_value;
407 uiuc_warnings_errors(1, *command_line);
409 Alpha_init_true = true;
410 Alpha_init = token_value;
415 if (check_float(linetoken3))
416 token3 >> token_value;
418 uiuc_warnings_errors(1, *command_line);
420 Beta_init_true = true;
421 Beta_init = token_value;
426 if (check_float(linetoken3))
427 token3 >> token_value;
429 uiuc_warnings_errors(1, *command_line);
431 U_body_init_true = true;
432 U_body_init = token_value;
437 if (check_float(linetoken3))
438 token3 >> token_value;
440 uiuc_warnings_errors(1, *command_line);
442 V_body_init_true = true;
443 V_body_init = token_value;
448 if (check_float(linetoken3))
449 token3 >> token_value;
451 uiuc_warnings_errors(1, *command_line);
453 W_body_init_true = true;
454 W_body_init = token_value;
457 case ignore_unknown_keywords_flag:
459 ignore_unknown_keywords=true;
462 case trim_case_2_flag:
467 case use_uiuc_network_flag:
469 use_uiuc_network = true;
470 server_IP = linetoken3;
474 case old_flap_routine_flag:
476 old_flap_routine = true;
479 case icing_demo_flag:
484 case outside_control_flag:
486 outside_control = true;
491 if (ignore_unknown_keywords){
494 // print error message
495 uiuc_warnings_errors(2, *command_line);