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
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
71 **********************************************************************/
73 #include <simgear/compiler.h>
75 #if defined( __MWERKS__ )
76 // -dw- optimizer chokes (big-time) trying to optimize humongous
77 // loop/switch statements
78 #pragma optimization_level 0
85 #include "uiuc_menu_engine.h"
95 void parse_engine( const string& linetoken2, const string& linetoken3,
96 const string& linetoken4, const string& linetoken5,
97 const string& linetoken6, const string& linetoken7,
98 const string& linetoken8, const string& linetoken9,
99 const string& linetoken10,const string& aircraft_directory,
100 LIST command_line ) {
102 int token_value_convert1, token_value_convert2;
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());
112 switch(engine_map[linetoken2])
114 case simpleSingle_flag:
116 if (check_float(linetoken3))
117 token3 >> token_value;
119 uiuc_warnings_errors(1, *command_line);
121 simpleSingleMaxThrust = token_value;
122 engineParts -> storeCommands (*command_line);
125 case simpleSingleModel_flag:
127 simpleSingleModel = true;
128 /* input the thrust at zero speed */
129 if (check_float(linetoken3))
130 token3 >> token_value;
132 uiuc_warnings_errors(1, *command_line);
134 /* input slope of thrust at speed for which thrust is zero */
135 if (check_float(linetoken4))
136 token4 >> token_value;
138 uiuc_warnings_errors(1, *command_line);
139 dtdv_t0 = token_value;
140 /* input speed at which thrust is zero */
141 if (check_float(linetoken5))
142 token5 >> token_value;
144 uiuc_warnings_errors(1, *command_line);
146 dtdvvt = -dtdv_t0 * v_t0 / t_v0;
147 engineParts -> storeCommands (*command_line);
152 engineParts -> storeCommands (*command_line);
157 engineParts -> storeCommands (*command_line);
160 case Throttle_pct_input_flag:
162 Throttle_pct_input = true;
163 Throttle_pct_input_file = aircraft_directory + linetoken3;
164 token4 >> token_value_convert1;
165 token5 >> token_value_convert2;
166 convert_y = uiuc_convert(token_value_convert1);
167 convert_x = uiuc_convert(token_value_convert2);
168 uiuc_1DdataFileReader(Throttle_pct_input_file,
169 Throttle_pct_input_timeArray,
170 Throttle_pct_input_dTArray,
171 Throttle_pct_input_ntime);
172 token6 >> token_value;
173 Throttle_pct_input_startTime = token_value;
176 case gyroForce_Q_body_flag:
178 /* include gyroscopic forces due to pitch */
179 gyroForce_Q_body = true;
182 case gyroForce_R_body_flag:
184 /* include gyroscopic forces due to yaw */
185 gyroForce_R_body = true;
189 case slipstream_effects_flag:
191 // include slipstream effects
192 b_slipstreamEffects = true;
193 if (!simpleSingleModel)
194 uiuc_warnings_errors(3, *command_line);
199 if (check_float(linetoken3))
200 token3 >> token_value;
202 uiuc_warnings_errors(1, *command_line);
203 propDia = token_value;
206 case eta_q_Cm_q_flag:
208 // include slipstream effects due to Cm_q
209 if (check_float(linetoken3))
210 token3 >> token_value;
212 uiuc_warnings_errors(1, *command_line);
213 eta_q_Cm_q_fac = token_value;
214 if (eta_q_Cm_q_fac == 0.0) {eta_q_Cm_q_fac = 1.0;}
217 case eta_q_Cm_adot_flag:
219 // include slipstream effects due to Cm_adot
220 if (check_float(linetoken3))
221 token3 >> token_value;
223 uiuc_warnings_errors(1, *command_line);
224 eta_q_Cm_adot_fac = token_value;
225 if (eta_q_Cm_adot_fac == 0.0) {eta_q_Cm_adot_fac = 1.0;}
228 case eta_q_Cmfade_flag:
230 // include slipstream effects due to Cmfade
231 if (check_float(linetoken3))
232 token3 >> token_value;
234 uiuc_warnings_errors(1, *command_line);
235 eta_q_Cmfade_fac = token_value;
236 if (eta_q_Cmfade_fac == 0.0) {eta_q_Cmfade_fac = 1.0;}
239 case eta_q_Cm_de_flag:
241 // include slipstream effects due to Cmfade
242 if (check_float(linetoken3))
243 token3 >> token_value;
245 uiuc_warnings_errors(1, *command_line);
246 eta_q_Cm_de_fac = token_value;
247 if (eta_q_Cm_de_fac == 0.0) {eta_q_Cm_de_fac = 1.0;}
250 case eta_q_Cl_beta_flag:
252 // include slipstream effects due to Cl_beta
253 if (check_float(linetoken3))
254 token3 >> token_value;
256 uiuc_warnings_errors(1, *command_line);
257 eta_q_Cl_beta_fac = token_value;
258 if (eta_q_Cl_beta_fac == 0.0) {eta_q_Cl_beta_fac = 1.0;}
261 case eta_q_Cl_p_flag:
263 // include slipstream effects due to Cl_p
264 if (check_float(linetoken3))
265 token3 >> token_value;
267 uiuc_warnings_errors(1, *command_line);
268 eta_q_Cl_p_fac = token_value;
269 if (eta_q_Cl_p_fac == 0.0) {eta_q_Cl_p_fac = 1.0;}
272 case eta_q_Cl_r_flag:
274 // include slipstream effects due to Cl_r
275 if (check_float(linetoken3))
276 token3 >> token_value;
278 uiuc_warnings_errors(1, *command_line);
279 eta_q_Cl_r_fac = token_value;
280 if (eta_q_Cl_r_fac == 0.0) {eta_q_Cl_r_fac = 1.0;}
283 case eta_q_Cl_dr_flag:
285 // include slipstream effects due to Cl_dr
286 if (check_float(linetoken3))
287 token3 >> token_value;
289 uiuc_warnings_errors(1, *command_line);
290 eta_q_Cl_dr_fac = token_value;
291 if (eta_q_Cl_dr_fac == 0.0) {eta_q_Cl_dr_fac = 1.0;}
294 case eta_q_CY_beta_flag:
296 // include slipstream effects due to CY_beta
297 if (check_float(linetoken3))
298 token3 >> token_value;
300 uiuc_warnings_errors(1, *command_line);
301 eta_q_CY_beta_fac = token_value;
302 if (eta_q_CY_beta_fac == 0.0) {eta_q_CY_beta_fac = 1.0;}
305 case eta_q_CY_p_flag:
307 // include slipstream effects due to CY_p
308 if (check_float(linetoken3))
309 token3 >> token_value;
311 uiuc_warnings_errors(1, *command_line);
312 eta_q_CY_p_fac = token_value;
313 if (eta_q_CY_p_fac == 0.0) {eta_q_CY_p_fac = 1.0;}
316 case eta_q_CY_r_flag:
318 // include slipstream effects due to CY_r
319 if (check_float(linetoken3))
320 token3 >> token_value;
322 uiuc_warnings_errors(1, *command_line);
323 eta_q_CY_r_fac = token_value;
324 if (eta_q_CY_r_fac == 0.0) {eta_q_CY_r_fac = 1.0;}
327 case eta_q_CY_dr_flag:
329 // include slipstream effects due to CY_dr
330 if (check_float(linetoken3))
331 token3 >> token_value;
333 uiuc_warnings_errors(1, *command_line);
334 eta_q_CY_dr_fac = token_value;
335 if (eta_q_CY_dr_fac == 0.0) {eta_q_CY_dr_fac = 1.0;}
338 case eta_q_Cn_beta_flag:
340 // include slipstream effects due to Cn_beta
341 if (check_float(linetoken3))
342 token3 >> token_value;
344 uiuc_warnings_errors(1, *command_line);
345 eta_q_Cn_beta_fac = token_value;
346 if (eta_q_Cn_beta_fac == 0.0) {eta_q_Cn_beta_fac = 1.0;}
349 case eta_q_Cn_p_flag:
351 // include slipstream effects due to Cn_p
352 if (check_float(linetoken3))
353 token3 >> token_value;
355 uiuc_warnings_errors(1, *command_line);
356 eta_q_Cn_p_fac = token_value;
357 if (eta_q_Cn_p_fac == 0.0) {eta_q_Cn_p_fac = 1.0;}
360 case eta_q_Cn_r_flag:
362 // include slipstream effects due to Cn_r
363 if (check_float(linetoken3))
364 token3 >> token_value;
366 uiuc_warnings_errors(1, *command_line);
367 eta_q_Cn_r_fac = token_value;
368 if (eta_q_Cn_r_fac == 0.0) {eta_q_Cn_r_fac = 1.0;}
371 case eta_q_Cn_dr_flag:
373 // include slipstream effects due to Cn_dr
374 if (check_float(linetoken3))
375 token3 >> token_value;
377 uiuc_warnings_errors(1, *command_line);
378 eta_q_Cn_dr_fac = token_value;
379 if (eta_q_Cn_dr_fac == 0.0) {eta_q_Cn_dr_fac = 1.0;}
385 if (check_float(linetoken3))
386 token3 >> token_value;
388 uiuc_warnings_errors(1, *command_line);
389 minOmega = token_value;
390 if (check_float(linetoken4))
391 token4 >> token_value;
393 uiuc_warnings_errors(1, *command_line);
394 maxOmega = token_value;
399 if (check_float(linetoken3))
400 token3 >> token_value;
402 uiuc_warnings_errors(1, *command_line);
403 minOmegaRPM = token_value;
404 minOmega = minOmegaRPM * 2.0 * LS_PI / 60;
405 if (check_float(linetoken4))
406 token4 >> token_value;
408 uiuc_warnings_errors(1, *command_line);
409 maxOmegaRPM = token_value;
410 maxOmega = maxOmegaRPM * 2.0 * LS_PI / 60;
413 case polarInertia_flag:
415 if (check_float(linetoken3))
416 token3 >> token_value;
418 uiuc_warnings_errors(1, *command_line);
419 polarInertia = token_value;
424 engineParts -> storeCommands (*command_line);
430 Xp_input_file = aircraft_directory + linetoken3;
431 token4 >> token_value_convert1;
432 token5 >> token_value_convert2;
433 convert_y = uiuc_convert(token_value_convert1);
434 convert_x = uiuc_convert(token_value_convert2);
435 uiuc_1DdataFileReader(Xp_input_file,
439 token6 >> token_value;
440 Xp_input_startTime = token_value;
446 Zp_input_file = aircraft_directory + linetoken3;
447 token4 >> token_value_convert1;
448 token5 >> token_value_convert2;
449 convert_y = uiuc_convert(token_value_convert1);
450 convert_x = uiuc_convert(token_value_convert2);
451 uiuc_1DdataFileReader(Zp_input_file,
455 token6 >> token_value;
456 Zp_input_startTime = token_value;
462 Mp_input_file = aircraft_directory + linetoken3;
463 token4 >> token_value_convert1;
464 token5 >> token_value_convert2;
465 convert_y = uiuc_convert(token_value_convert1);
466 convert_x = uiuc_convert(token_value_convert2);
467 uiuc_1DdataFileReader(Mp_input_file,
471 token6 >> token_value;
472 Mp_input_startTime = token_value;
477 if (ignore_unknown_keywords) {
480 // print error message
481 uiuc_warnings_errors(2, *command_line);