1 /**********************************************************************
3 FILENAME: uiuc_menu.cpp
5 ----------------------------------------------------------------------
7 DESCRIPTION: reads input file 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: 01/29/2000 initial release
21 02/18/2000 (JS) added 1D data file capability for
22 CL(a) and CD(a) -- calls
24 02/22/2000 (JS) added ice map functions
25 02/29/2000 (JS) added 2D data file capability for
26 CL(a,de), CD(a,de), Cm(a,de), CY(a,da),
27 CY(beta,dr), Cl(a,da), Cl(beta,dr),
28 Cn(a,da), Cn(beta,dr) -- calls
30 02/02/2000 (JS) added record options for 1D and
31 2D interpolated variables
32 03/28/2000 (JS) streamlined conversion factors for
33 file readers -- since they are global
34 variables, it is not necessary to put
35 them in the function calls
36 03/29/2000 (JS) added Cmfa and Weight flags;
37 added misc map; added Dx_cg (etc) to init
39 04/01/2000 (JS) added throttle, longitudinal, lateral,
40 and rudder inputs to record map
41 04/05/2000 (JS) added Altitude to init and record
42 maps; added zero_Long_trim to
44 03/09/2001 (DPM) added support for gear.
45 06/18/2001 (RD) Added Alpha, Beta, U_body,
46 V_body, and W_body to init map. Added
47 aileron_input, rudder_input, pilot_elev_no,
48 pilot_ail_no, and pilot_rud_no to
49 controlSurface map. Added Throttle_pct_input
50 to engine map. Added CZfa to CL map.
51 07/05/2001 (RD) Changed pilot_elev_no = true to pilot_
52 elev_no_check=false. This is to allow pilot
53 to fly aircraft after input files have been
55 08/27/2001 (RD) Added xxx_init_true and xxx_init for
56 P_body, Q_body, R_body, Phi, Theta, Psi,
57 U_body, V_body, and W_body to help in
58 starting the A/C at an initial condition.
59 10/25/2001 (RD) Added new variables needed for the non-
60 linear Twin Otter model at zero flaps
62 11/12/2001 (RD) Added new variables needed for the non-
63 linear Twin Otter model with flaps
64 (Cxfxxf). Removed zero flap variables.
65 Added minmaxfind() which is needed for non-
67 01/11/2002 (AP) Added keywords for bootTime
68 02/13/2002 (RD) Added variables so linear aero model
69 values can be recorded
70 02/18/2002 (RD) Added variables necessary to use the
71 uiuc_3Dinterp_quick() function. Takes
72 advantage of data in a "nice" form (data
73 that are in a rectangular matrix).
74 03/13/2002 (RD) Added aircraft_directory so full path
75 is no longer needed in the aircraft.dat file
76 04/02/2002 (RD) Removed minmaxfind() since it was no
77 longer needed. Added d_2_to_3(),
78 d_1_to_2(), and i_1_to_2() so uiuc_menu()
79 will compile with certain compilers.
80 08/29/2002 (RD) Separated each primary keyword into its
81 own function to speed up compile time
82 08/29/2002 (RD w/ help from CO) Made changes to shorten
83 compile time. [] RD to add more comments here.
84 08/29/2003 (MSS) Adding new keywords for new engine model
85 and slipstream effects on tail.
86 03/02/2003 (RD) Changed Cxfxxf areas so that there is a
87 conversion factor for flap angle
88 03/03/2003 (RD) Added flap_cmd_record
89 03/16/2003 (RD) Added trigger record flags
90 04/02/2003 (RD) Tokens are now equal to 0 when no value
91 is given in the input file
92 04/04/2003 (RD) To speed up compile time on this file,
93 each first level token now goes to its
94 own file uiuc_menu_*.cpp
96 ----------------------------------------------------------------------
98 AUTHOR(S): Bipin Sehgal <bsehgal@uiuc.edu>
99 Jeff Scott http://www.jeffscott.net/
100 Robert Deters <rdeters@uiuc.edu>
101 Michael Selig <m-selig@uiuc.edu>
102 David Megginson <david@megginson.com>
103 Ann Peedikayil <peedikay@uiuc.edu>
104 ----------------------------------------------------------------------
108 ----------------------------------------------------------------------
112 ----------------------------------------------------------------------
116 ----------------------------------------------------------------------
118 CALLED BY: uiuc_wrapper.cpp
120 ----------------------------------------------------------------------
122 CALLS TO: aircraft.dat
123 tabulated data files (if needed)
127 uiuc_menu_controlSurface()
141 ----------------------------------------------------------------------
143 COPYRIGHT: (C) 2000 by Michael Selig
145 This program is free software; you can redistribute it and/or
146 modify it under the terms of the GNU General Public License
147 as published by the Free Software Foundation.
149 This program is distributed in the hope that it will be useful,
150 but WITHOUT ANY WARRANTY; without even the implied warranty of
151 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
152 GNU General Public License for more details.
154 You should have received a copy of the GNU General Public License
155 along with this program; if not, write to the Free Software
156 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
157 USA or view http://www.gnu.org/copyleft/gpl.html.
159 **********************************************************************/
161 #include <simgear/compiler.h>
163 #if defined( __MWERKS__ )
164 // -dw- optimizer chokes (big-time) trying to optimize humongous
165 // loop/switch statements
166 #pragma optimization_level 0
171 #include STL_IOSTREAM
173 #include "uiuc_menu.h"
183 void uiuc_menu( string aircraft_name )
185 string aircraft_directory;
188 int token_value_recordRate;
189 int token_value_convert1, token_value_convert2, token_value_convert3;
202 /* the following default setting should eventually be moved to a default or uiuc_init routine */
204 recordRate = 1; /* record every time step, default */
205 recordStartTime = 0; /* record from beginning of simulation */
207 /* set speed at which dynamic pressure terms will be accounted for,
208 since if velocity is too small, coefficients will go to infinity */
209 dyn_on_speed = 33; /* 20 kts (33 ft/sec), default */
210 dyn_on_speed_zero = 0.5 * dyn_on_speed; /* only used if use_dyn_on_speed_curve1 is used */
211 bootindex = 0; // the index for the bootTime
213 /* Read the file and get the list of commands */
214 airplane = new ParseFile(aircraft_name); /* struct that includes all lines of the input file */
215 command_list = airplane -> getCommands();
216 /* structs to include all parts included in the input file for specific keyword groups */
217 initParts = new ParseFile();
218 geometryParts = new ParseFile();
219 massParts = new ParseFile();
220 engineParts = new ParseFile();
221 aeroDragParts = new ParseFile();
222 aeroLiftParts = new ParseFile();
223 aeroPitchParts = new ParseFile();
224 aeroSideforceParts = new ParseFile();
225 aeroRollParts = new ParseFile();
226 aeroYawParts = new ParseFile();
227 gearParts = new ParseFile();
228 recordParts = new ParseFile();
230 if (command_list.begin() == command_list.end())
232 cerr << "UIUC ERROR: File " << aircraft_name <<" does not exist" << endl;
236 //construct aircraft-directory
237 aircraft_directory = aircraft_name;
238 int index_aircraft_dat = aircraft_directory.find("aircraft.dat");
239 aircraft_directory.erase(index_aircraft_dat,12);
241 for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
243 cout << *command_line << endl;
245 linetoken1 = airplane -> getToken (*command_line, 1);
246 linetoken2 = airplane -> getToken (*command_line, 2);
249 linetoken3 = airplane -> getToken (*command_line, 3);
252 linetoken4 = airplane -> getToken (*command_line, 4);
255 linetoken5 = airplane -> getToken (*command_line, 5);
258 linetoken6 = airplane -> getToken (*command_line, 6);
261 linetoken7 = airplane -> getToken (*command_line, 7);
264 linetoken8 = airplane -> getToken (*command_line, 8);
267 linetoken9 = airplane -> getToken (*command_line, 9);
270 linetoken10 = airplane -> getToken (*command_line, 10);
274 //cout << linetoken1 << endl;
275 //cout << linetoken2 << endl;
276 //cout << linetoken3 << endl;
277 //cout << linetoken4 << endl;
278 //cout << linetoken5 << endl;
279 //cout << linetoken6 << endl;
280 //cout << linetoken7 << endl;
281 //cout << linetoken8 << endl;
282 //cout << linetoken9 << endl;
283 //cout << linetoken10 << endl;
285 //istrstream token3(linetoken3.c_str());
286 //istrstream token4(linetoken4.c_str());
287 //istrstream token5(linetoken5.c_str());
288 //istrstream token6(linetoken6.c_str());
289 //istrstream token7(linetoken7.c_str());
290 //istrstream token8(linetoken8.c_str());
291 //istrstream token9(linetoken9.c_str());
292 //istrstream token10(linetoken10.c_str());
294 switch (Keyword_map[linetoken1])
298 parse_init( linetoken2, linetoken3, linetoken4,
299 linetoken5, linetoken6, linetoken7,
300 linetoken8, linetoken9, linetoken10,
301 aircraft_directory, command_line );
308 parse_geometry( linetoken2, linetoken3, linetoken4,
309 linetoken5, linetoken6, linetoken7,
310 linetoken8, linetoken9, linetoken10,
311 aircraft_directory, command_line );
313 } // end geometry map
316 case controlSurface_flag:
318 parse_controlSurface( linetoken2, linetoken3, linetoken4,
319 linetoken5, linetoken6, linetoken7,
320 linetoken8, linetoken9, linetoken10,
321 aircraft_directory, command_line );
323 } // end controlSurface map
328 parse_mass( linetoken2, linetoken3, linetoken4,
329 linetoken5, linetoken6, linetoken7,
330 linetoken8, linetoken9, linetoken10,
331 aircraft_directory, command_line );
338 parse_engine( linetoken2, linetoken3, linetoken4,
339 linetoken5, linetoken6, linetoken7,
340 linetoken8, linetoken9, linetoken10,
341 aircraft_directory, command_line );
348 parse_CD( linetoken2, linetoken3, linetoken4,
349 linetoken5, linetoken6, linetoken7,
350 linetoken8, linetoken9, linetoken10,
351 aircraft_directory, command_line );
358 parse_CL( linetoken2, linetoken3, linetoken4,
359 linetoken5, linetoken6, linetoken7,
360 linetoken8, linetoken9, linetoken10,
361 aircraft_directory, command_line );
368 parse_Cm( linetoken2, linetoken3, linetoken4,
369 linetoken5, linetoken6, linetoken7,
370 linetoken8, linetoken9, linetoken10,
371 aircraft_directory, command_line );
378 parse_CY( linetoken2, linetoken3, linetoken4,
379 linetoken5, linetoken6, linetoken7,
380 linetoken8, linetoken9, linetoken10,
381 aircraft_directory, command_line );
388 parse_Cl( linetoken2, linetoken3, linetoken4,
389 linetoken5, linetoken6, linetoken7,
390 linetoken8, linetoken9, linetoken10,
391 aircraft_directory, command_line );
398 parse_Cn( linetoken2, linetoken3, linetoken4,
399 linetoken5, linetoken6, linetoken7,
400 linetoken8, linetoken9, linetoken10,
401 aircraft_directory, command_line );
408 parse_gear( linetoken2, linetoken3, linetoken4,
409 linetoken5, linetoken6, linetoken7,
410 linetoken8, linetoken9, linetoken10,
411 aircraft_directory, command_line );
418 parse_ice( linetoken2, linetoken3, linetoken4,
419 linetoken5, linetoken6, linetoken7,
420 linetoken8, linetoken9, linetoken10,
421 aircraft_directory, command_line );
428 parse_fog( linetoken2, linetoken3, linetoken4,
429 linetoken5, linetoken6, linetoken7,
430 linetoken8, linetoken9, linetoken10,
431 aircraft_directory, command_line );
438 static int fout_flag=0;
442 fout.open("uiuc_record.dat");
444 parse_record( linetoken2, linetoken3, linetoken4,
445 linetoken5, linetoken6, linetoken7,
446 linetoken8, linetoken9, linetoken10,
447 aircraft_directory, command_line );
454 parse_misc( linetoken2, linetoken3, linetoken4,
455 linetoken5, linetoken6, linetoken7,
456 linetoken8, linetoken9, linetoken10,
457 aircraft_directory, command_line );
466 if (ignore_unknown_keywords) {
469 // print error message
470 uiuc_warnings_errors(2, *command_line);