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>
80 #include "uiuc_menu_engine.h"
90 void parse_engine( const string& linetoken2, const string& linetoken3,
91 const string& linetoken4, const string& linetoken5,
92 const string& linetoken6, const string& linetoken7,
93 const string& linetoken8, const string& linetoken9,
94 const string& linetoken10,const string& aircraft_directory,
97 int token_value_convert1, token_value_convert2;
98 istringstream token3(linetoken3.c_str());
99 istringstream token4(linetoken4.c_str());
100 istringstream token5(linetoken5.c_str());
101 istringstream token6(linetoken6.c_str());
102 istringstream token7(linetoken7.c_str());
103 istringstream token8(linetoken8.c_str());
104 istringstream token9(linetoken9.c_str());
105 istringstream token10(linetoken10.c_str());
107 switch(engine_map[linetoken2])
109 case simpleSingle_flag:
111 if (check_float(linetoken3))
112 token3 >> token_value;
114 uiuc_warnings_errors(1, *command_line);
116 simpleSingleMaxThrust = token_value;
117 engineParts -> storeCommands (*command_line);
120 case simpleSingleModel_flag:
122 simpleSingleModel = true;
123 /* input the thrust at zero speed */
124 if (check_float(linetoken3))
125 token3 >> token_value;
127 uiuc_warnings_errors(1, *command_line);
129 /* input slope of thrust at speed for which thrust is zero */
130 if (check_float(linetoken4))
131 token4 >> token_value;
133 uiuc_warnings_errors(1, *command_line);
134 dtdv_t0 = token_value;
135 /* input speed at which thrust is zero */
136 if (check_float(linetoken5))
137 token5 >> token_value;
139 uiuc_warnings_errors(1, *command_line);
141 dtdvvt = -dtdv_t0 * v_t0 / t_v0;
142 engineParts -> storeCommands (*command_line);
147 engineParts -> storeCommands (*command_line);
152 engineParts -> storeCommands (*command_line);
155 case Throttle_pct_input_flag:
157 Throttle_pct_input = true;
158 Throttle_pct_input_file = aircraft_directory + linetoken3;
159 token4 >> token_value_convert1;
160 token5 >> token_value_convert2;
161 convert_y = uiuc_convert(token_value_convert1);
162 convert_x = uiuc_convert(token_value_convert2);
163 uiuc_1DdataFileReader(Throttle_pct_input_file,
164 Throttle_pct_input_timeArray,
165 Throttle_pct_input_dTArray,
166 Throttle_pct_input_ntime);
167 token6 >> token_value;
168 Throttle_pct_input_startTime = token_value;
171 case gyroForce_Q_body_flag:
173 /* include gyroscopic forces due to pitch */
174 gyroForce_Q_body = true;
177 case gyroForce_R_body_flag:
179 /* include gyroscopic forces due to yaw */
180 gyroForce_R_body = true;
184 case slipstream_effects_flag:
186 // include slipstream effects
187 b_slipstreamEffects = true;
188 if (!simpleSingleModel)
189 uiuc_warnings_errors(3, *command_line);
194 if (check_float(linetoken3))
195 token3 >> token_value;
197 uiuc_warnings_errors(1, *command_line);
198 propDia = token_value;
201 case eta_q_Cm_q_flag:
203 // include slipstream effects due to Cm_q
204 if (check_float(linetoken3))
205 token3 >> token_value;
207 uiuc_warnings_errors(1, *command_line);
208 eta_q_Cm_q_fac = token_value;
209 if (eta_q_Cm_q_fac == 0.0) {eta_q_Cm_q_fac = 1.0;}
212 case eta_q_Cm_adot_flag:
214 // include slipstream effects due to Cm_adot
215 if (check_float(linetoken3))
216 token3 >> token_value;
218 uiuc_warnings_errors(1, *command_line);
219 eta_q_Cm_adot_fac = token_value;
220 if (eta_q_Cm_adot_fac == 0.0) {eta_q_Cm_adot_fac = 1.0;}
223 case eta_q_Cmfade_flag:
225 // include slipstream effects due to Cmfade
226 if (check_float(linetoken3))
227 token3 >> token_value;
229 uiuc_warnings_errors(1, *command_line);
230 eta_q_Cmfade_fac = token_value;
231 if (eta_q_Cmfade_fac == 0.0) {eta_q_Cmfade_fac = 1.0;}
234 case eta_q_Cm_de_flag:
236 // include slipstream effects due to Cmfade
237 if (check_float(linetoken3))
238 token3 >> token_value;
240 uiuc_warnings_errors(1, *command_line);
241 eta_q_Cm_de_fac = token_value;
242 if (eta_q_Cm_de_fac == 0.0) {eta_q_Cm_de_fac = 1.0;}
245 case eta_q_Cl_beta_flag:
247 // include slipstream effects due to Cl_beta
248 if (check_float(linetoken3))
249 token3 >> token_value;
251 uiuc_warnings_errors(1, *command_line);
252 eta_q_Cl_beta_fac = token_value;
253 if (eta_q_Cl_beta_fac == 0.0) {eta_q_Cl_beta_fac = 1.0;}
256 case eta_q_Cl_p_flag:
258 // include slipstream effects due to Cl_p
259 if (check_float(linetoken3))
260 token3 >> token_value;
262 uiuc_warnings_errors(1, *command_line);
263 eta_q_Cl_p_fac = token_value;
264 if (eta_q_Cl_p_fac == 0.0) {eta_q_Cl_p_fac = 1.0;}
267 case eta_q_Cl_r_flag:
269 // include slipstream effects due to Cl_r
270 if (check_float(linetoken3))
271 token3 >> token_value;
273 uiuc_warnings_errors(1, *command_line);
274 eta_q_Cl_r_fac = token_value;
275 if (eta_q_Cl_r_fac == 0.0) {eta_q_Cl_r_fac = 1.0;}
278 case eta_q_Cl_dr_flag:
280 // include slipstream effects due to Cl_dr
281 if (check_float(linetoken3))
282 token3 >> token_value;
284 uiuc_warnings_errors(1, *command_line);
285 eta_q_Cl_dr_fac = token_value;
286 if (eta_q_Cl_dr_fac == 0.0) {eta_q_Cl_dr_fac = 1.0;}
289 case eta_q_CY_beta_flag:
291 // include slipstream effects due to CY_beta
292 if (check_float(linetoken3))
293 token3 >> token_value;
295 uiuc_warnings_errors(1, *command_line);
296 eta_q_CY_beta_fac = token_value;
297 if (eta_q_CY_beta_fac == 0.0) {eta_q_CY_beta_fac = 1.0;}
300 case eta_q_CY_p_flag:
302 // include slipstream effects due to CY_p
303 if (check_float(linetoken3))
304 token3 >> token_value;
306 uiuc_warnings_errors(1, *command_line);
307 eta_q_CY_p_fac = token_value;
308 if (eta_q_CY_p_fac == 0.0) {eta_q_CY_p_fac = 1.0;}
311 case eta_q_CY_r_flag:
313 // include slipstream effects due to CY_r
314 if (check_float(linetoken3))
315 token3 >> token_value;
317 uiuc_warnings_errors(1, *command_line);
318 eta_q_CY_r_fac = token_value;
319 if (eta_q_CY_r_fac == 0.0) {eta_q_CY_r_fac = 1.0;}
322 case eta_q_CY_dr_flag:
324 // include slipstream effects due to CY_dr
325 if (check_float(linetoken3))
326 token3 >> token_value;
328 uiuc_warnings_errors(1, *command_line);
329 eta_q_CY_dr_fac = token_value;
330 if (eta_q_CY_dr_fac == 0.0) {eta_q_CY_dr_fac = 1.0;}
333 case eta_q_Cn_beta_flag:
335 // include slipstream effects due to Cn_beta
336 if (check_float(linetoken3))
337 token3 >> token_value;
339 uiuc_warnings_errors(1, *command_line);
340 eta_q_Cn_beta_fac = token_value;
341 if (eta_q_Cn_beta_fac == 0.0) {eta_q_Cn_beta_fac = 1.0;}
344 case eta_q_Cn_p_flag:
346 // include slipstream effects due to Cn_p
347 if (check_float(linetoken3))
348 token3 >> token_value;
350 uiuc_warnings_errors(1, *command_line);
351 eta_q_Cn_p_fac = token_value;
352 if (eta_q_Cn_p_fac == 0.0) {eta_q_Cn_p_fac = 1.0;}
355 case eta_q_Cn_r_flag:
357 // include slipstream effects due to Cn_r
358 if (check_float(linetoken3))
359 token3 >> token_value;
361 uiuc_warnings_errors(1, *command_line);
362 eta_q_Cn_r_fac = token_value;
363 if (eta_q_Cn_r_fac == 0.0) {eta_q_Cn_r_fac = 1.0;}
366 case eta_q_Cn_dr_flag:
368 // include slipstream effects due to Cn_dr
369 if (check_float(linetoken3))
370 token3 >> token_value;
372 uiuc_warnings_errors(1, *command_line);
373 eta_q_Cn_dr_fac = token_value;
374 if (eta_q_Cn_dr_fac == 0.0) {eta_q_Cn_dr_fac = 1.0;}
380 if (check_float(linetoken3))
381 token3 >> token_value;
383 uiuc_warnings_errors(1, *command_line);
384 minOmega = token_value;
385 if (check_float(linetoken4))
386 token4 >> token_value;
388 uiuc_warnings_errors(1, *command_line);
389 maxOmega = token_value;
394 if (check_float(linetoken3))
395 token3 >> token_value;
397 uiuc_warnings_errors(1, *command_line);
398 minOmegaRPM = token_value;
399 minOmega = minOmegaRPM * 2.0 * LS_PI / 60;
400 if (check_float(linetoken4))
401 token4 >> token_value;
403 uiuc_warnings_errors(1, *command_line);
404 maxOmegaRPM = token_value;
405 maxOmega = maxOmegaRPM * 2.0 * LS_PI / 60;
408 case polarInertia_flag:
410 if (check_float(linetoken3))
411 token3 >> token_value;
413 uiuc_warnings_errors(1, *command_line);
414 polarInertia = token_value;
419 engineParts -> storeCommands (*command_line);
425 Xp_input_file = aircraft_directory + linetoken3;
426 token4 >> token_value_convert1;
427 token5 >> token_value_convert2;
428 convert_y = uiuc_convert(token_value_convert1);
429 convert_x = uiuc_convert(token_value_convert2);
430 uiuc_1DdataFileReader(Xp_input_file,
434 token6 >> token_value;
435 Xp_input_startTime = token_value;
441 Zp_input_file = aircraft_directory + linetoken3;
442 token4 >> token_value_convert1;
443 token5 >> token_value_convert2;
444 convert_y = uiuc_convert(token_value_convert1);
445 convert_x = uiuc_convert(token_value_convert2);
446 uiuc_1DdataFileReader(Zp_input_file,
450 token6 >> token_value;
451 Zp_input_startTime = token_value;
457 Mp_input_file = aircraft_directory + linetoken3;
458 token4 >> token_value_convert1;
459 token5 >> token_value_convert2;
460 convert_y = uiuc_convert(token_value_convert1);
461 convert_x = uiuc_convert(token_value_convert2);
462 uiuc_1DdataFileReader(Mp_input_file,
466 token6 >> token_value;
467 Mp_input_startTime = token_value;
472 if (ignore_unknown_keywords) {
475 // print error message
476 uiuc_warnings_errors(2, *command_line);