1 /**********************************************************************
3 FILENAME: uiuc_menu_engine.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_engine.h"
93 void parse_engine( 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 int token_value_convert1, token_value_convert2;
101 istrstream token3(linetoken3.c_str());
102 istrstream token4(linetoken4.c_str());
103 istrstream token5(linetoken5.c_str());
104 istrstream token6(linetoken6.c_str());
105 istrstream token7(linetoken7.c_str());
106 istrstream token8(linetoken8.c_str());
107 istrstream token9(linetoken9.c_str());
108 istrstream token10(linetoken10.c_str());
110 switch(engine_map[linetoken2])
112 case simpleSingle_flag:
114 if (check_float(linetoken3))
115 token3 >> token_value;
117 uiuc_warnings_errors(1, *command_line);
119 simpleSingleMaxThrust = token_value;
120 engineParts -> storeCommands (*command_line);
123 case simpleSingleModel_flag:
125 simpleSingleModel = true;
126 /* input the thrust at zero speed */
127 if (check_float(linetoken3))
128 token3 >> token_value;
130 uiuc_warnings_errors(1, *command_line);
132 /* input slope of thrust at speed for which thrust is zero */
133 if (check_float(linetoken4))
134 token4 >> token_value;
136 uiuc_warnings_errors(1, *command_line);
137 dtdv_t0 = token_value;
138 /* input speed at which thrust is zero */
139 if (check_float(linetoken5))
140 token5 >> token_value;
142 uiuc_warnings_errors(1, *command_line);
144 dtdvvt = -dtdv_t0 * v_t0 / t_v0;
145 engineParts -> storeCommands (*command_line);
150 engineParts -> storeCommands (*command_line);
155 engineParts -> storeCommands (*command_line);
158 case Throttle_pct_input_flag:
160 Throttle_pct_input = true;
161 Throttle_pct_input_file = aircraft_directory + linetoken3;
162 token4 >> token_value_convert1;
163 token5 >> token_value_convert2;
164 convert_y = uiuc_convert(token_value_convert1);
165 convert_x = uiuc_convert(token_value_convert2);
166 uiuc_1DdataFileReader(Throttle_pct_input_file,
167 Throttle_pct_input_timeArray,
168 Throttle_pct_input_dTArray,
169 Throttle_pct_input_ntime);
170 token6 >> token_value;
171 Throttle_pct_input_startTime = token_value;
174 case gyroForce_Q_body_flag:
176 /* include gyroscopic forces due to pitch */
177 gyroForce_Q_body = true;
180 case gyroForce_R_body_flag:
182 /* include gyroscopic forces due to yaw */
183 gyroForce_R_body = true;
187 case slipstream_effects_flag:
189 // include slipstream effects
190 b_slipstreamEffects = true;
191 if (!simpleSingleModel)
192 uiuc_warnings_errors(3, *command_line);
197 if (check_float(linetoken3))
198 token3 >> token_value;
200 uiuc_warnings_errors(1, *command_line);
201 propDia = token_value;
204 case eta_q_Cm_q_flag:
206 // include slipstream effects due to Cm_q
207 if (check_float(linetoken3))
208 token3 >> token_value;
210 uiuc_warnings_errors(1, *command_line);
211 eta_q_Cm_q_fac = token_value;
212 if (eta_q_Cm_q_fac == 0.0) {eta_q_Cm_q_fac = 1.0;}
215 case eta_q_Cm_adot_flag:
217 // include slipstream effects due to Cm_adot
218 if (check_float(linetoken3))
219 token3 >> token_value;
221 uiuc_warnings_errors(1, *command_line);
222 eta_q_Cm_adot_fac = token_value;
223 if (eta_q_Cm_adot_fac == 0.0) {eta_q_Cm_adot_fac = 1.0;}
226 case eta_q_Cmfade_flag:
228 // include slipstream effects due to Cmfade
229 if (check_float(linetoken3))
230 token3 >> token_value;
232 uiuc_warnings_errors(1, *command_line);
233 eta_q_Cmfade_fac = token_value;
234 if (eta_q_Cmfade_fac == 0.0) {eta_q_Cmfade_fac = 1.0;}
237 case eta_q_Cm_de_flag:
239 // include slipstream effects due to Cmfade
240 if (check_float(linetoken3))
241 token3 >> token_value;
243 uiuc_warnings_errors(1, *command_line);
244 eta_q_Cm_de_fac = token_value;
245 if (eta_q_Cm_de_fac == 0.0) {eta_q_Cm_de_fac = 1.0;}
248 case eta_q_Cl_beta_flag:
250 // include slipstream effects due to Cl_beta
251 if (check_float(linetoken3))
252 token3 >> token_value;
254 uiuc_warnings_errors(1, *command_line);
255 eta_q_Cl_beta_fac = token_value;
256 if (eta_q_Cl_beta_fac == 0.0) {eta_q_Cl_beta_fac = 1.0;}
259 case eta_q_Cl_p_flag:
261 // include slipstream effects due to Cl_p
262 if (check_float(linetoken3))
263 token3 >> token_value;
265 uiuc_warnings_errors(1, *command_line);
266 eta_q_Cl_p_fac = token_value;
267 if (eta_q_Cl_p_fac == 0.0) {eta_q_Cl_p_fac = 1.0;}
270 case eta_q_Cl_r_flag:
272 // include slipstream effects due to Cl_r
273 if (check_float(linetoken3))
274 token3 >> token_value;
276 uiuc_warnings_errors(1, *command_line);
277 eta_q_Cl_r_fac = token_value;
278 if (eta_q_Cl_r_fac == 0.0) {eta_q_Cl_r_fac = 1.0;}
281 case eta_q_Cl_dr_flag:
283 // include slipstream effects due to Cl_dr
284 if (check_float(linetoken3))
285 token3 >> token_value;
287 uiuc_warnings_errors(1, *command_line);
288 eta_q_Cl_dr_fac = token_value;
289 if (eta_q_Cl_dr_fac == 0.0) {eta_q_Cl_dr_fac = 1.0;}
292 case eta_q_CY_beta_flag:
294 // include slipstream effects due to CY_beta
295 if (check_float(linetoken3))
296 token3 >> token_value;
298 uiuc_warnings_errors(1, *command_line);
299 eta_q_CY_beta_fac = token_value;
300 if (eta_q_CY_beta_fac == 0.0) {eta_q_CY_beta_fac = 1.0;}
303 case eta_q_CY_p_flag:
305 // include slipstream effects due to CY_p
306 if (check_float(linetoken3))
307 token3 >> token_value;
309 uiuc_warnings_errors(1, *command_line);
310 eta_q_CY_p_fac = token_value;
311 if (eta_q_CY_p_fac == 0.0) {eta_q_CY_p_fac = 1.0;}
314 case eta_q_CY_r_flag:
316 // include slipstream effects due to CY_r
317 if (check_float(linetoken3))
318 token3 >> token_value;
320 uiuc_warnings_errors(1, *command_line);
321 eta_q_CY_r_fac = token_value;
322 if (eta_q_CY_r_fac == 0.0) {eta_q_CY_r_fac = 1.0;}
325 case eta_q_CY_dr_flag:
327 // include slipstream effects due to CY_dr
328 if (check_float(linetoken3))
329 token3 >> token_value;
331 uiuc_warnings_errors(1, *command_line);
332 eta_q_CY_dr_fac = token_value;
333 if (eta_q_CY_dr_fac == 0.0) {eta_q_CY_dr_fac = 1.0;}
336 case eta_q_Cn_beta_flag:
338 // include slipstream effects due to Cn_beta
339 if (check_float(linetoken3))
340 token3 >> token_value;
342 uiuc_warnings_errors(1, *command_line);
343 eta_q_Cn_beta_fac = token_value;
344 if (eta_q_Cn_beta_fac == 0.0) {eta_q_Cn_beta_fac = 1.0;}
347 case eta_q_Cn_p_flag:
349 // include slipstream effects due to Cn_p
350 if (check_float(linetoken3))
351 token3 >> token_value;
353 uiuc_warnings_errors(1, *command_line);
354 eta_q_Cn_p_fac = token_value;
355 if (eta_q_Cn_p_fac == 0.0) {eta_q_Cn_p_fac = 1.0;}
358 case eta_q_Cn_r_flag:
360 // include slipstream effects due to Cn_r
361 if (check_float(linetoken3))
362 token3 >> token_value;
364 uiuc_warnings_errors(1, *command_line);
365 eta_q_Cn_r_fac = token_value;
366 if (eta_q_Cn_r_fac == 0.0) {eta_q_Cn_r_fac = 1.0;}
369 case eta_q_Cn_dr_flag:
371 // include slipstream effects due to Cn_dr
372 if (check_float(linetoken3))
373 token3 >> token_value;
375 uiuc_warnings_errors(1, *command_line);
376 eta_q_Cn_dr_fac = token_value;
377 if (eta_q_Cn_dr_fac == 0.0) {eta_q_Cn_dr_fac = 1.0;}
383 if (check_float(linetoken3))
384 token3 >> token_value;
386 uiuc_warnings_errors(1, *command_line);
387 minOmega = token_value;
388 if (check_float(linetoken4))
389 token4 >> token_value;
391 uiuc_warnings_errors(1, *command_line);
392 maxOmega = token_value;
397 if (check_float(linetoken3))
398 token3 >> token_value;
400 uiuc_warnings_errors(1, *command_line);
401 minOmegaRPM = token_value;
402 minOmega = minOmegaRPM * 2.0 * LS_PI / 60;
403 if (check_float(linetoken4))
404 token4 >> token_value;
406 uiuc_warnings_errors(1, *command_line);
407 maxOmegaRPM = token_value;
408 maxOmega = maxOmegaRPM * 2.0 * LS_PI / 60;
411 case polarInertia_flag:
413 if (check_float(linetoken3))
414 token3 >> token_value;
416 uiuc_warnings_errors(1, *command_line);
417 polarInertia = token_value;
422 engineParts -> storeCommands (*command_line);
428 Xp_input_file = aircraft_directory + linetoken3;
429 token4 >> token_value_convert1;
430 token5 >> token_value_convert2;
431 convert_y = uiuc_convert(token_value_convert1);
432 convert_x = uiuc_convert(token_value_convert2);
433 uiuc_1DdataFileReader(Xp_input_file,
437 token6 >> token_value;
438 Xp_input_startTime = token_value;
444 Zp_input_file = aircraft_directory + linetoken3;
445 token4 >> token_value_convert1;
446 token5 >> token_value_convert2;
447 convert_y = uiuc_convert(token_value_convert1);
448 convert_x = uiuc_convert(token_value_convert2);
449 uiuc_1DdataFileReader(Zp_input_file,
453 token6 >> token_value;
454 Zp_input_startTime = token_value;
460 Mp_input_file = aircraft_directory + linetoken3;
461 token4 >> token_value_convert1;
462 token5 >> token_value_convert2;
463 convert_y = uiuc_convert(token_value_convert1);
464 convert_x = uiuc_convert(token_value_convert2);
465 uiuc_1DdataFileReader(Mp_input_file,
469 token6 >> token_value;
470 Mp_input_startTime = token_value;
475 if (ignore_unknown_keywords) {
478 // print error message
479 uiuc_warnings_errors(2, *command_line);