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., 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_engine.h"
96 void parse_engine( 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 int token_value_convert1, token_value_convert2;
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());
113 switch(engine_map[linetoken2])
115 case simpleSingle_flag:
117 if (check_float(linetoken3))
118 token3 >> token_value;
120 uiuc_warnings_errors(1, *command_line);
122 simpleSingleMaxThrust = token_value;
123 engineParts -> storeCommands (*command_line);
126 case simpleSingleModel_flag:
128 simpleSingleModel = true;
129 /* input the thrust at zero speed */
130 if (check_float(linetoken3))
131 token3 >> token_value;
133 uiuc_warnings_errors(1, *command_line);
135 /* input slope of thrust at speed for which thrust is zero */
136 if (check_float(linetoken4))
137 token4 >> token_value;
139 uiuc_warnings_errors(1, *command_line);
140 dtdv_t0 = token_value;
141 /* input speed at which thrust is zero */
142 if (check_float(linetoken5))
143 token5 >> token_value;
145 uiuc_warnings_errors(1, *command_line);
147 dtdvvt = -dtdv_t0 * v_t0 / t_v0;
148 engineParts -> storeCommands (*command_line);
153 engineParts -> storeCommands (*command_line);
158 engineParts -> storeCommands (*command_line);
161 case Throttle_pct_input_flag:
163 Throttle_pct_input = true;
164 Throttle_pct_input_file = aircraft_directory + linetoken3;
165 token4 >> token_value_convert1;
166 token5 >> token_value_convert2;
167 convert_y = uiuc_convert(token_value_convert1);
168 convert_x = uiuc_convert(token_value_convert2);
169 uiuc_1DdataFileReader(Throttle_pct_input_file,
170 Throttle_pct_input_timeArray,
171 Throttle_pct_input_dTArray,
172 Throttle_pct_input_ntime);
173 token6 >> token_value;
174 Throttle_pct_input_startTime = token_value;
177 case gyroForce_Q_body_flag:
179 /* include gyroscopic forces due to pitch */
180 gyroForce_Q_body = true;
183 case gyroForce_R_body_flag:
185 /* include gyroscopic forces due to yaw */
186 gyroForce_R_body = true;
190 case slipstream_effects_flag:
192 // include slipstream effects
193 b_slipstreamEffects = true;
194 if (!simpleSingleModel)
195 uiuc_warnings_errors(3, *command_line);
200 if (check_float(linetoken3))
201 token3 >> token_value;
203 uiuc_warnings_errors(1, *command_line);
204 propDia = token_value;
207 case eta_q_Cm_q_flag:
209 // include slipstream effects due to Cm_q
210 if (check_float(linetoken3))
211 token3 >> token_value;
213 uiuc_warnings_errors(1, *command_line);
214 eta_q_Cm_q_fac = token_value;
215 if (eta_q_Cm_q_fac == 0.0) {eta_q_Cm_q_fac = 1.0;}
218 case eta_q_Cm_adot_flag:
220 // include slipstream effects due to Cm_adot
221 if (check_float(linetoken3))
222 token3 >> token_value;
224 uiuc_warnings_errors(1, *command_line);
225 eta_q_Cm_adot_fac = token_value;
226 if (eta_q_Cm_adot_fac == 0.0) {eta_q_Cm_adot_fac = 1.0;}
229 case eta_q_Cmfade_flag:
231 // include slipstream effects due to Cmfade
232 if (check_float(linetoken3))
233 token3 >> token_value;
235 uiuc_warnings_errors(1, *command_line);
236 eta_q_Cmfade_fac = token_value;
237 if (eta_q_Cmfade_fac == 0.0) {eta_q_Cmfade_fac = 1.0;}
240 case eta_q_Cm_de_flag:
242 // include slipstream effects due to Cmfade
243 if (check_float(linetoken3))
244 token3 >> token_value;
246 uiuc_warnings_errors(1, *command_line);
247 eta_q_Cm_de_fac = token_value;
248 if (eta_q_Cm_de_fac == 0.0) {eta_q_Cm_de_fac = 1.0;}
251 case eta_q_Cl_beta_flag:
253 // include slipstream effects due to Cl_beta
254 if (check_float(linetoken3))
255 token3 >> token_value;
257 uiuc_warnings_errors(1, *command_line);
258 eta_q_Cl_beta_fac = token_value;
259 if (eta_q_Cl_beta_fac == 0.0) {eta_q_Cl_beta_fac = 1.0;}
262 case eta_q_Cl_p_flag:
264 // include slipstream effects due to Cl_p
265 if (check_float(linetoken3))
266 token3 >> token_value;
268 uiuc_warnings_errors(1, *command_line);
269 eta_q_Cl_p_fac = token_value;
270 if (eta_q_Cl_p_fac == 0.0) {eta_q_Cl_p_fac = 1.0;}
273 case eta_q_Cl_r_flag:
275 // include slipstream effects due to Cl_r
276 if (check_float(linetoken3))
277 token3 >> token_value;
279 uiuc_warnings_errors(1, *command_line);
280 eta_q_Cl_r_fac = token_value;
281 if (eta_q_Cl_r_fac == 0.0) {eta_q_Cl_r_fac = 1.0;}
284 case eta_q_Cl_dr_flag:
286 // include slipstream effects due to Cl_dr
287 if (check_float(linetoken3))
288 token3 >> token_value;
290 uiuc_warnings_errors(1, *command_line);
291 eta_q_Cl_dr_fac = token_value;
292 if (eta_q_Cl_dr_fac == 0.0) {eta_q_Cl_dr_fac = 1.0;}
295 case eta_q_CY_beta_flag:
297 // include slipstream effects due to CY_beta
298 if (check_float(linetoken3))
299 token3 >> token_value;
301 uiuc_warnings_errors(1, *command_line);
302 eta_q_CY_beta_fac = token_value;
303 if (eta_q_CY_beta_fac == 0.0) {eta_q_CY_beta_fac = 1.0;}
306 case eta_q_CY_p_flag:
308 // include slipstream effects due to CY_p
309 if (check_float(linetoken3))
310 token3 >> token_value;
312 uiuc_warnings_errors(1, *command_line);
313 eta_q_CY_p_fac = token_value;
314 if (eta_q_CY_p_fac == 0.0) {eta_q_CY_p_fac = 1.0;}
317 case eta_q_CY_r_flag:
319 // include slipstream effects due to CY_r
320 if (check_float(linetoken3))
321 token3 >> token_value;
323 uiuc_warnings_errors(1, *command_line);
324 eta_q_CY_r_fac = token_value;
325 if (eta_q_CY_r_fac == 0.0) {eta_q_CY_r_fac = 1.0;}
328 case eta_q_CY_dr_flag:
330 // include slipstream effects due to CY_dr
331 if (check_float(linetoken3))
332 token3 >> token_value;
334 uiuc_warnings_errors(1, *command_line);
335 eta_q_CY_dr_fac = token_value;
336 if (eta_q_CY_dr_fac == 0.0) {eta_q_CY_dr_fac = 1.0;}
339 case eta_q_Cn_beta_flag:
341 // include slipstream effects due to Cn_beta
342 if (check_float(linetoken3))
343 token3 >> token_value;
345 uiuc_warnings_errors(1, *command_line);
346 eta_q_Cn_beta_fac = token_value;
347 if (eta_q_Cn_beta_fac == 0.0) {eta_q_Cn_beta_fac = 1.0;}
350 case eta_q_Cn_p_flag:
352 // include slipstream effects due to Cn_p
353 if (check_float(linetoken3))
354 token3 >> token_value;
356 uiuc_warnings_errors(1, *command_line);
357 eta_q_Cn_p_fac = token_value;
358 if (eta_q_Cn_p_fac == 0.0) {eta_q_Cn_p_fac = 1.0;}
361 case eta_q_Cn_r_flag:
363 // include slipstream effects due to Cn_r
364 if (check_float(linetoken3))
365 token3 >> token_value;
367 uiuc_warnings_errors(1, *command_line);
368 eta_q_Cn_r_fac = token_value;
369 if (eta_q_Cn_r_fac == 0.0) {eta_q_Cn_r_fac = 1.0;}
372 case eta_q_Cn_dr_flag:
374 // include slipstream effects due to Cn_dr
375 if (check_float(linetoken3))
376 token3 >> token_value;
378 uiuc_warnings_errors(1, *command_line);
379 eta_q_Cn_dr_fac = token_value;
380 if (eta_q_Cn_dr_fac == 0.0) {eta_q_Cn_dr_fac = 1.0;}
386 if (check_float(linetoken3))
387 token3 >> token_value;
389 uiuc_warnings_errors(1, *command_line);
390 minOmega = token_value;
391 if (check_float(linetoken4))
392 token4 >> token_value;
394 uiuc_warnings_errors(1, *command_line);
395 maxOmega = token_value;
400 if (check_float(linetoken3))
401 token3 >> token_value;
403 uiuc_warnings_errors(1, *command_line);
404 minOmegaRPM = token_value;
405 minOmega = minOmegaRPM * 2.0 * LS_PI / 60;
406 if (check_float(linetoken4))
407 token4 >> token_value;
409 uiuc_warnings_errors(1, *command_line);
410 maxOmegaRPM = token_value;
411 maxOmega = maxOmegaRPM * 2.0 * LS_PI / 60;
414 case polarInertia_flag:
416 if (check_float(linetoken3))
417 token3 >> token_value;
419 uiuc_warnings_errors(1, *command_line);
420 polarInertia = token_value;
425 engineParts -> storeCommands (*command_line);
431 Xp_input_file = aircraft_directory + linetoken3;
432 token4 >> token_value_convert1;
433 token5 >> token_value_convert2;
434 convert_y = uiuc_convert(token_value_convert1);
435 convert_x = uiuc_convert(token_value_convert2);
436 uiuc_1DdataFileReader(Xp_input_file,
440 token6 >> token_value;
441 Xp_input_startTime = token_value;
447 Zp_input_file = aircraft_directory + linetoken3;
448 token4 >> token_value_convert1;
449 token5 >> token_value_convert2;
450 convert_y = uiuc_convert(token_value_convert1);
451 convert_x = uiuc_convert(token_value_convert2);
452 uiuc_1DdataFileReader(Zp_input_file,
456 token6 >> token_value;
457 Zp_input_startTime = token_value;
463 Mp_input_file = aircraft_directory + linetoken3;
464 token4 >> token_value_convert1;
465 token5 >> token_value_convert2;
466 convert_y = uiuc_convert(token_value_convert1);
467 convert_x = uiuc_convert(token_value_convert2);
468 uiuc_1DdataFileReader(Mp_input_file,
472 token6 >> token_value;
473 Mp_input_startTime = token_value;
478 if (ignore_unknown_keywords) {
481 // print error message
482 uiuc_warnings_errors(2, *command_line);