1 /**********************************************************************
3 FILENAME: uiuc_menu_CL.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_CL.h"
95 void parse_CL( 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, token_value_convert3;
103 int token_value_convert4;
104 double datafile_xArray[100][100], datafile_yArray[100];
105 double datafile_zArray[100][100];
107 int datafile_nxArray[100], datafile_ny;
108 istringstream token3(linetoken3.c_str());
109 istringstream token4(linetoken4.c_str());
110 istringstream token5(linetoken5.c_str());
111 istringstream token6(linetoken6.c_str());
112 istringstream token7(linetoken7.c_str());
113 istringstream token8(linetoken8.c_str());
114 istringstream token9(linetoken9.c_str());
115 istringstream token10(linetoken10.c_str());
117 static bool CZfabetaf_first = true;
118 static bool CZfadef_first = true;
119 static bool CZfaqf_first = true;
121 switch(CL_map[linetoken2])
125 if (check_float(linetoken3))
126 token3 >> token_value;
128 uiuc_warnings_errors(1, *command_line);
132 aeroLiftParts -> storeCommands (*command_line);
137 if (check_float(linetoken3))
138 token3 >> token_value;
140 uiuc_warnings_errors(1, *command_line);
144 aeroLiftParts -> storeCommands (*command_line);
149 if (check_float(linetoken3))
150 token3 >> token_value;
152 uiuc_warnings_errors(1, *command_line);
154 CL_adot = token_value;
155 CL_adot_clean = CL_adot;
156 aeroLiftParts -> storeCommands (*command_line);
161 if (check_float(linetoken3))
162 token3 >> token_value;
164 uiuc_warnings_errors(1, *command_line);
168 aeroLiftParts -> storeCommands (*command_line);
173 if (check_float(linetoken3))
174 token3 >> token_value;
176 uiuc_warnings_errors(1, *command_line);
179 aeroLiftParts -> storeCommands (*command_line);
184 if (check_float(linetoken3))
185 token3 >> token_value;
187 uiuc_warnings_errors(1, *command_line);
191 aeroLiftParts -> storeCommands (*command_line);
196 if (check_float(linetoken3))
197 token3 >> token_value;
199 uiuc_warnings_errors(1, *command_line);
202 aeroLiftParts -> storeCommands (*command_line);
207 if (check_float(linetoken3))
208 token3 >> token_value;
210 uiuc_warnings_errors(1, *command_line);
213 aeroLiftParts -> storeCommands (*command_line);
218 if (check_float(linetoken3))
219 token3 >> token_value;
221 uiuc_warnings_errors(1, *command_line);
224 aeroLiftParts -> storeCommands (*command_line);
229 CLfa = aircraft_directory + linetoken3;
230 token4 >> token_value_convert1;
231 token5 >> token_value_convert2;
232 convert_y = uiuc_convert(token_value_convert1);
233 convert_x = uiuc_convert(token_value_convert2);
234 /* call 1D File Reader with file name (CLfa) and conversion
235 factors; function returns array of alphas (aArray) and
236 corresponding CL values (CLArray) and max number of
237 terms in arrays (nAlpha) */
238 uiuc_1DdataFileReader(CLfa,
242 aeroLiftParts -> storeCommands (*command_line);
247 CLfade = aircraft_directory + linetoken3;
248 token4 >> token_value_convert1;
249 token5 >> token_value_convert2;
250 token6 >> token_value_convert3;
251 convert_z = uiuc_convert(token_value_convert1);
252 convert_x = uiuc_convert(token_value_convert2);
253 convert_y = uiuc_convert(token_value_convert3);
254 /* call 2D File Reader with file name (CLfade) and
255 conversion factors; function returns array of
256 elevator deflections (deArray) and corresponding
257 alpha (aArray) and delta CL (CLArray) values and
258 max number of terms in alpha arrays (nAlphaArray)
259 and deflection array (nde) */
260 uiuc_2DdataFileReader(CLfade,
266 aeroLiftParts -> storeCommands (*command_line);
271 CLfdf = aircraft_directory + linetoken3;
272 token4 >> token_value_convert1;
273 token5 >> token_value_convert2;
274 convert_y = uiuc_convert(token_value_convert1);
275 convert_x = uiuc_convert(token_value_convert2);
276 /* call 1D File Reader with file name (CLfdf) and conversion
277 factors; function returns array of dfs (dfArray) and
278 corresponding CL values (CLArray) and max number of
279 terms in arrays (ndf) */
280 uiuc_1DdataFileReader(CLfdf,
284 aeroLiftParts -> storeCommands (*command_line);
286 // additional variables to streamline flap routine in aerodeflections
288 //int temp_counter = 1;
289 //while (temp_counter <= ndf)
291 // dfArray[temp_counter] = CLfdf_dfArray[temp_counter];
292 // TimeArray[temp_counter] = dfTimefdf_TimeArray[temp_counter];
299 CLfadf = aircraft_directory + linetoken3;
300 token4 >> token_value_convert1;
301 token5 >> token_value_convert2;
302 token6 >> token_value_convert3;
303 convert_z = uiuc_convert(token_value_convert1);
304 convert_x = uiuc_convert(token_value_convert2);
305 convert_y = uiuc_convert(token_value_convert3);
306 /* call 2D File Reader with file name (CLfadf) and
307 conversion factors; function returns array of
308 flap deflections (dfArray) and corresponding
309 alpha (aArray) and delta CL (CLArray) values and
310 max number of terms in alpha arrays (nAlphaArray)
311 and deflection array (ndf) */
312 uiuc_2DdataFileReader(CLfadf,
318 aeroLiftParts -> storeCommands (*command_line);
323 if (check_float(linetoken3))
324 token3 >> token_value;
326 uiuc_warnings_errors(1, *command_line);
330 aeroLiftParts -> storeCommands (*command_line);
335 if (check_float(linetoken3))
336 token3 >> token_value;
338 uiuc_warnings_errors(1, *command_line);
342 aeroLiftParts -> storeCommands (*command_line);
347 if (check_float(linetoken3))
348 token3 >> token_value;
350 uiuc_warnings_errors(1, *command_line);
354 aeroLiftParts -> storeCommands (*command_line);
359 if (check_float(linetoken3))
360 token3 >> token_value;
362 uiuc_warnings_errors(1, *command_line);
366 aeroLiftParts -> storeCommands (*command_line);
371 if (check_float(linetoken3))
372 token3 >> token_value;
374 uiuc_warnings_errors(1, *command_line);
376 CZ_adot = token_value;
377 CZ_adot_clean = CZ_adot;
378 aeroLiftParts -> storeCommands (*command_line);
383 if (check_float(linetoken3))
384 token3 >> token_value;
386 uiuc_warnings_errors(1, *command_line);
390 aeroLiftParts -> storeCommands (*command_line);
395 if (check_float(linetoken3))
396 token3 >> token_value;
398 uiuc_warnings_errors(1, *command_line);
402 aeroLiftParts -> storeCommands (*command_line);
407 if (check_float(linetoken3))
408 token3 >> token_value;
410 uiuc_warnings_errors(1, *command_line);
412 CZ_deb2 = token_value;
413 CZ_deb2_clean = CZ_deb2;
414 aeroLiftParts -> storeCommands (*command_line);
419 if (check_float(linetoken3))
420 token3 >> token_value;
422 uiuc_warnings_errors(1, *command_line);
426 aeroLiftParts -> storeCommands (*command_line);
431 if (check_float(linetoken3))
432 token3 >> token_value;
434 uiuc_warnings_errors(1, *command_line);
436 CZ_adf = token_value;
437 CZ_adf_clean = CZ_adf;
438 aeroLiftParts -> storeCommands (*command_line);
443 CZfa = aircraft_directory + linetoken3;
444 token4 >> token_value_convert1;
445 token5 >> token_value_convert2;
446 convert_y = uiuc_convert(token_value_convert1);
447 convert_x = uiuc_convert(token_value_convert2);
448 /* call 1D File Reader with file name (CZfa) and conversion
449 factors; function returns array of alphas (aArray) and
450 corresponding CZ values (CZArray) and max number of
451 terms in arrays (nAlpha) */
452 uiuc_1DdataFileReader(CZfa,
456 aeroLiftParts -> storeCommands (*command_line);
461 int CZfabetaf_index, i;
462 string CZfabetaf_file;
464 CZfabetaf_file = aircraft_directory + linetoken3;
465 token4 >> CZfabetaf_index;
466 if (CZfabetaf_index < 0 || CZfabetaf_index >= 30)
467 uiuc_warnings_errors(1, *command_line);
468 if (CZfabetaf_index > CZfabetaf_nf)
469 CZfabetaf_nf = CZfabetaf_index;
470 token5 >> flap_value;
471 token6 >> token_value_convert1;
472 token7 >> token_value_convert2;
473 token8 >> token_value_convert3;
474 token9 >> token_value_convert4;
475 token10 >> CZfabetaf_nice;
476 convert_z = uiuc_convert(token_value_convert1);
477 convert_x = uiuc_convert(token_value_convert2);
478 convert_y = uiuc_convert(token_value_convert3);
479 convert_f = uiuc_convert(token_value_convert4);
480 CZfabetaf_fArray[CZfabetaf_index] = flap_value * convert_f;
481 /* call 2D File Reader with file name (CZfabetaf_file) and
482 conversion factors; function returns array of
483 beta (betaArray) and corresponding
484 alpha (aArray) and CZ (CZArray) values and
485 max number of terms in alpha arrays (nAlphaArray)
486 and beta array (nbeta) */
487 uiuc_2DdataFileReader(CZfabetaf_file,
493 d_2_to_3(datafile_xArray, CZfabetaf_aArray, CZfabetaf_index);
494 d_1_to_2(datafile_yArray, CZfabetaf_betaArray, CZfabetaf_index);
495 d_2_to_3(datafile_zArray, CZfabetaf_CZArray, CZfabetaf_index);
496 i_1_to_2(datafile_nxArray, CZfabetaf_nAlphaArray, CZfabetaf_index);
497 CZfabetaf_nbeta[CZfabetaf_index] = datafile_ny;
498 if (CZfabetaf_first==true)
500 if (CZfabetaf_nice == 1)
502 CZfabetaf_na_nice = datafile_nxArray[1];
503 CZfabetaf_nb_nice = datafile_ny;
504 d_1_to_1(datafile_yArray, CZfabetaf_bArray_nice);
505 for (i=1; i<=CZfabetaf_na_nice; i++)
506 CZfabetaf_aArray_nice[i] = datafile_xArray[1][i];
508 aeroLiftParts -> storeCommands (*command_line);
509 CZfabetaf_first=false;
515 int CZfadef_index, i;
518 CZfadef_file = aircraft_directory + linetoken3;
519 token4 >> CZfadef_index;
520 if (CZfadef_index < 0 || CZfadef_index >= 30)
521 uiuc_warnings_errors(1, *command_line);
522 if (CZfadef_index > CZfadef_nf)
523 CZfadef_nf = CZfadef_index;
524 token5 >> flap_value;
525 token6 >> token_value_convert1;
526 token7 >> token_value_convert2;
527 token8 >> token_value_convert3;
528 token9 >> token_value_convert4;
529 token10 >> CZfadef_nice;
530 convert_z = uiuc_convert(token_value_convert1);
531 convert_x = uiuc_convert(token_value_convert2);
532 convert_y = uiuc_convert(token_value_convert3);
533 convert_f = uiuc_convert(token_value_convert4);
534 CZfadef_fArray[CZfadef_index] = flap_value * convert_f;
535 /* call 2D File Reader with file name (CZfadef_file) and
536 conversion factors; function returns array of
537 elevator deflections (deArray) and corresponding
538 alpha (aArray) and delta CZ (CZArray) values and
539 max number of terms in alpha arrays (nAlphaArray)
540 and delfection array (nde) */
541 uiuc_2DdataFileReader(CZfadef_file,
547 d_2_to_3(datafile_xArray, CZfadef_aArray, CZfadef_index);
548 d_1_to_2(datafile_yArray, CZfadef_deArray, CZfadef_index);
549 d_2_to_3(datafile_zArray, CZfadef_CZArray, CZfadef_index);
550 i_1_to_2(datafile_nxArray, CZfadef_nAlphaArray, CZfadef_index);
551 CZfadef_nde[CZfadef_index] = datafile_ny;
552 if (CZfadef_first==true)
554 if (CZfadef_nice == 1)
556 CZfadef_na_nice = datafile_nxArray[1];
557 CZfadef_nde_nice = datafile_ny;
558 d_1_to_1(datafile_yArray, CZfadef_deArray_nice);
559 for (i=1; i<=CZfadef_na_nice; i++)
560 CZfadef_aArray_nice[i] = datafile_xArray[1][i];
562 aeroLiftParts -> storeCommands (*command_line);
572 CZfaqf_file = aircraft_directory + linetoken3;
573 token4 >> CZfaqf_index;
574 if (CZfaqf_index < 0 || CZfaqf_index >= 30)
575 uiuc_warnings_errors(1, *command_line);
576 if (CZfaqf_index > CZfaqf_nf)
577 CZfaqf_nf = CZfaqf_index;
578 token5 >> flap_value;
579 token6 >> token_value_convert1;
580 token7 >> token_value_convert2;
581 token8 >> token_value_convert3;
582 token9 >> token_value_convert4;
583 token10 >> CZfaqf_nice;
584 convert_z = uiuc_convert(token_value_convert1);
585 convert_x = uiuc_convert(token_value_convert2);
586 convert_y = uiuc_convert(token_value_convert3);
587 convert_f = uiuc_convert(token_value_convert4);
588 CZfaqf_fArray[CZfaqf_index] = flap_value * convert_f;
589 /* call 2D File Reader with file name (CZfaqf_file) and
590 conversion factors; function returns array of
591 pitch rate (qArray) and corresponding
592 alpha (aArray) and delta CZ (CZArray) values and
593 max number of terms in alpha arrays (nAlphaArray)
594 and pitch rate array (nq) */
595 uiuc_2DdataFileReader(CZfaqf_file,
601 d_2_to_3(datafile_xArray, CZfaqf_aArray, CZfaqf_index);
602 d_1_to_2(datafile_yArray, CZfaqf_qArray, CZfaqf_index);
603 d_2_to_3(datafile_zArray, CZfaqf_CZArray, CZfaqf_index);
604 i_1_to_2(datafile_nxArray, CZfaqf_nAlphaArray, CZfaqf_index);
605 CZfaqf_nq[CZfaqf_index] = datafile_ny;
606 if (CZfaqf_first==true)
608 if (CZfaqf_nice == 1)
610 CZfaqf_na_nice = datafile_nxArray[1];
611 CZfaqf_nq_nice = datafile_ny;
612 d_1_to_1(datafile_yArray, CZfaqf_qArray_nice);
613 for (i=1; i<=CZfaqf_na_nice; i++)
614 CZfaqf_aArray_nice[i] = datafile_xArray[1][i];
616 aeroLiftParts -> storeCommands (*command_line);
623 if (ignore_unknown_keywords) {
626 // print error message
627 uiuc_warnings_errors(2, *command_line);