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., 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_CL.h"
96 void parse_CL( 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, token_value_convert3;
104 int token_value_convert4;
105 double datafile_xArray[100][100], datafile_yArray[100];
106 double datafile_zArray[100][100];
108 int datafile_nxArray[100], datafile_ny;
109 istringstream token3(linetoken3.c_str());
110 istringstream token4(linetoken4.c_str());
111 istringstream token5(linetoken5.c_str());
112 istringstream token6(linetoken6.c_str());
113 istringstream token7(linetoken7.c_str());
114 istringstream token8(linetoken8.c_str());
115 istringstream token9(linetoken9.c_str());
116 istringstream token10(linetoken10.c_str());
118 static bool CZfabetaf_first = true;
119 static bool CZfadef_first = true;
120 static bool CZfaqf_first = true;
122 switch(CL_map[linetoken2])
126 if (check_float(linetoken3))
127 token3 >> token_value;
129 uiuc_warnings_errors(1, *command_line);
133 aeroLiftParts -> storeCommands (*command_line);
138 if (check_float(linetoken3))
139 token3 >> token_value;
141 uiuc_warnings_errors(1, *command_line);
145 aeroLiftParts -> storeCommands (*command_line);
150 if (check_float(linetoken3))
151 token3 >> token_value;
153 uiuc_warnings_errors(1, *command_line);
155 CL_adot = token_value;
156 CL_adot_clean = CL_adot;
157 aeroLiftParts -> storeCommands (*command_line);
162 if (check_float(linetoken3))
163 token3 >> token_value;
165 uiuc_warnings_errors(1, *command_line);
169 aeroLiftParts -> storeCommands (*command_line);
174 if (check_float(linetoken3))
175 token3 >> token_value;
177 uiuc_warnings_errors(1, *command_line);
180 aeroLiftParts -> storeCommands (*command_line);
185 if (check_float(linetoken3))
186 token3 >> token_value;
188 uiuc_warnings_errors(1, *command_line);
192 aeroLiftParts -> storeCommands (*command_line);
197 if (check_float(linetoken3))
198 token3 >> token_value;
200 uiuc_warnings_errors(1, *command_line);
203 aeroLiftParts -> storeCommands (*command_line);
208 if (check_float(linetoken3))
209 token3 >> token_value;
211 uiuc_warnings_errors(1, *command_line);
214 aeroLiftParts -> storeCommands (*command_line);
219 if (check_float(linetoken3))
220 token3 >> token_value;
222 uiuc_warnings_errors(1, *command_line);
225 aeroLiftParts -> storeCommands (*command_line);
230 CLfa = aircraft_directory + linetoken3;
231 token4 >> token_value_convert1;
232 token5 >> token_value_convert2;
233 convert_y = uiuc_convert(token_value_convert1);
234 convert_x = uiuc_convert(token_value_convert2);
235 /* call 1D File Reader with file name (CLfa) and conversion
236 factors; function returns array of alphas (aArray) and
237 corresponding CL values (CLArray) and max number of
238 terms in arrays (nAlpha) */
239 uiuc_1DdataFileReader(CLfa,
243 aeroLiftParts -> storeCommands (*command_line);
248 CLfade = aircraft_directory + linetoken3;
249 token4 >> token_value_convert1;
250 token5 >> token_value_convert2;
251 token6 >> token_value_convert3;
252 convert_z = uiuc_convert(token_value_convert1);
253 convert_x = uiuc_convert(token_value_convert2);
254 convert_y = uiuc_convert(token_value_convert3);
255 /* call 2D File Reader with file name (CLfade) and
256 conversion factors; function returns array of
257 elevator deflections (deArray) and corresponding
258 alpha (aArray) and delta CL (CLArray) values and
259 max number of terms in alpha arrays (nAlphaArray)
260 and deflection array (nde) */
261 uiuc_2DdataFileReader(CLfade,
267 aeroLiftParts -> storeCommands (*command_line);
272 CLfdf = aircraft_directory + linetoken3;
273 token4 >> token_value_convert1;
274 token5 >> token_value_convert2;
275 convert_y = uiuc_convert(token_value_convert1);
276 convert_x = uiuc_convert(token_value_convert2);
277 /* call 1D File Reader with file name (CLfdf) and conversion
278 factors; function returns array of dfs (dfArray) and
279 corresponding CL values (CLArray) and max number of
280 terms in arrays (ndf) */
281 uiuc_1DdataFileReader(CLfdf,
285 aeroLiftParts -> storeCommands (*command_line);
287 // additional variables to streamline flap routine in aerodeflections
289 //int temp_counter = 1;
290 //while (temp_counter <= ndf)
292 // dfArray[temp_counter] = CLfdf_dfArray[temp_counter];
293 // TimeArray[temp_counter] = dfTimefdf_TimeArray[temp_counter];
300 CLfadf = aircraft_directory + linetoken3;
301 token4 >> token_value_convert1;
302 token5 >> token_value_convert2;
303 token6 >> token_value_convert3;
304 convert_z = uiuc_convert(token_value_convert1);
305 convert_x = uiuc_convert(token_value_convert2);
306 convert_y = uiuc_convert(token_value_convert3);
307 /* call 2D File Reader with file name (CLfadf) and
308 conversion factors; function returns array of
309 flap deflections (dfArray) and corresponding
310 alpha (aArray) and delta CL (CLArray) values and
311 max number of terms in alpha arrays (nAlphaArray)
312 and deflection array (ndf) */
313 uiuc_2DdataFileReader(CLfadf,
319 aeroLiftParts -> storeCommands (*command_line);
324 if (check_float(linetoken3))
325 token3 >> token_value;
327 uiuc_warnings_errors(1, *command_line);
331 aeroLiftParts -> storeCommands (*command_line);
336 if (check_float(linetoken3))
337 token3 >> token_value;
339 uiuc_warnings_errors(1, *command_line);
343 aeroLiftParts -> storeCommands (*command_line);
348 if (check_float(linetoken3))
349 token3 >> token_value;
351 uiuc_warnings_errors(1, *command_line);
355 aeroLiftParts -> storeCommands (*command_line);
360 if (check_float(linetoken3))
361 token3 >> token_value;
363 uiuc_warnings_errors(1, *command_line);
367 aeroLiftParts -> storeCommands (*command_line);
372 if (check_float(linetoken3))
373 token3 >> token_value;
375 uiuc_warnings_errors(1, *command_line);
377 CZ_adot = token_value;
378 CZ_adot_clean = CZ_adot;
379 aeroLiftParts -> storeCommands (*command_line);
384 if (check_float(linetoken3))
385 token3 >> token_value;
387 uiuc_warnings_errors(1, *command_line);
391 aeroLiftParts -> storeCommands (*command_line);
396 if (check_float(linetoken3))
397 token3 >> token_value;
399 uiuc_warnings_errors(1, *command_line);
403 aeroLiftParts -> storeCommands (*command_line);
408 if (check_float(linetoken3))
409 token3 >> token_value;
411 uiuc_warnings_errors(1, *command_line);
413 CZ_deb2 = token_value;
414 CZ_deb2_clean = CZ_deb2;
415 aeroLiftParts -> storeCommands (*command_line);
420 if (check_float(linetoken3))
421 token3 >> token_value;
423 uiuc_warnings_errors(1, *command_line);
427 aeroLiftParts -> storeCommands (*command_line);
432 if (check_float(linetoken3))
433 token3 >> token_value;
435 uiuc_warnings_errors(1, *command_line);
437 CZ_adf = token_value;
438 CZ_adf_clean = CZ_adf;
439 aeroLiftParts -> storeCommands (*command_line);
444 CZfa = aircraft_directory + linetoken3;
445 token4 >> token_value_convert1;
446 token5 >> token_value_convert2;
447 convert_y = uiuc_convert(token_value_convert1);
448 convert_x = uiuc_convert(token_value_convert2);
449 /* call 1D File Reader with file name (CZfa) and conversion
450 factors; function returns array of alphas (aArray) and
451 corresponding CZ values (CZArray) and max number of
452 terms in arrays (nAlpha) */
453 uiuc_1DdataFileReader(CZfa,
457 aeroLiftParts -> storeCommands (*command_line);
462 int CZfabetaf_index, i;
463 string CZfabetaf_file;
465 CZfabetaf_file = aircraft_directory + linetoken3;
466 token4 >> CZfabetaf_index;
467 if (CZfabetaf_index < 0 || CZfabetaf_index >= 30)
468 uiuc_warnings_errors(1, *command_line);
469 if (CZfabetaf_index > CZfabetaf_nf)
470 CZfabetaf_nf = CZfabetaf_index;
471 token5 >> flap_value;
472 token6 >> token_value_convert1;
473 token7 >> token_value_convert2;
474 token8 >> token_value_convert3;
475 token9 >> token_value_convert4;
476 token10 >> CZfabetaf_nice;
477 convert_z = uiuc_convert(token_value_convert1);
478 convert_x = uiuc_convert(token_value_convert2);
479 convert_y = uiuc_convert(token_value_convert3);
480 convert_f = uiuc_convert(token_value_convert4);
481 CZfabetaf_fArray[CZfabetaf_index] = flap_value * convert_f;
482 /* call 2D File Reader with file name (CZfabetaf_file) and
483 conversion factors; function returns array of
484 beta (betaArray) and corresponding
485 alpha (aArray) and CZ (CZArray) values and
486 max number of terms in alpha arrays (nAlphaArray)
487 and beta array (nbeta) */
488 uiuc_2DdataFileReader(CZfabetaf_file,
494 d_2_to_3(datafile_xArray, CZfabetaf_aArray, CZfabetaf_index);
495 d_1_to_2(datafile_yArray, CZfabetaf_betaArray, CZfabetaf_index);
496 d_2_to_3(datafile_zArray, CZfabetaf_CZArray, CZfabetaf_index);
497 i_1_to_2(datafile_nxArray, CZfabetaf_nAlphaArray, CZfabetaf_index);
498 CZfabetaf_nbeta[CZfabetaf_index] = datafile_ny;
499 if (CZfabetaf_first==true)
501 if (CZfabetaf_nice == 1)
503 CZfabetaf_na_nice = datafile_nxArray[1];
504 CZfabetaf_nb_nice = datafile_ny;
505 d_1_to_1(datafile_yArray, CZfabetaf_bArray_nice);
506 for (i=1; i<=CZfabetaf_na_nice; i++)
507 CZfabetaf_aArray_nice[i] = datafile_xArray[1][i];
509 aeroLiftParts -> storeCommands (*command_line);
510 CZfabetaf_first=false;
516 int CZfadef_index, i;
519 CZfadef_file = aircraft_directory + linetoken3;
520 token4 >> CZfadef_index;
521 if (CZfadef_index < 0 || CZfadef_index >= 30)
522 uiuc_warnings_errors(1, *command_line);
523 if (CZfadef_index > CZfadef_nf)
524 CZfadef_nf = CZfadef_index;
525 token5 >> flap_value;
526 token6 >> token_value_convert1;
527 token7 >> token_value_convert2;
528 token8 >> token_value_convert3;
529 token9 >> token_value_convert4;
530 token10 >> CZfadef_nice;
531 convert_z = uiuc_convert(token_value_convert1);
532 convert_x = uiuc_convert(token_value_convert2);
533 convert_y = uiuc_convert(token_value_convert3);
534 convert_f = uiuc_convert(token_value_convert4);
535 CZfadef_fArray[CZfadef_index] = flap_value * convert_f;
536 /* call 2D File Reader with file name (CZfadef_file) and
537 conversion factors; function returns array of
538 elevator deflections (deArray) and corresponding
539 alpha (aArray) and delta CZ (CZArray) values and
540 max number of terms in alpha arrays (nAlphaArray)
541 and delfection array (nde) */
542 uiuc_2DdataFileReader(CZfadef_file,
548 d_2_to_3(datafile_xArray, CZfadef_aArray, CZfadef_index);
549 d_1_to_2(datafile_yArray, CZfadef_deArray, CZfadef_index);
550 d_2_to_3(datafile_zArray, CZfadef_CZArray, CZfadef_index);
551 i_1_to_2(datafile_nxArray, CZfadef_nAlphaArray, CZfadef_index);
552 CZfadef_nde[CZfadef_index] = datafile_ny;
553 if (CZfadef_first==true)
555 if (CZfadef_nice == 1)
557 CZfadef_na_nice = datafile_nxArray[1];
558 CZfadef_nde_nice = datafile_ny;
559 d_1_to_1(datafile_yArray, CZfadef_deArray_nice);
560 for (i=1; i<=CZfadef_na_nice; i++)
561 CZfadef_aArray_nice[i] = datafile_xArray[1][i];
563 aeroLiftParts -> storeCommands (*command_line);
573 CZfaqf_file = aircraft_directory + linetoken3;
574 token4 >> CZfaqf_index;
575 if (CZfaqf_index < 0 || CZfaqf_index >= 30)
576 uiuc_warnings_errors(1, *command_line);
577 if (CZfaqf_index > CZfaqf_nf)
578 CZfaqf_nf = CZfaqf_index;
579 token5 >> flap_value;
580 token6 >> token_value_convert1;
581 token7 >> token_value_convert2;
582 token8 >> token_value_convert3;
583 token9 >> token_value_convert4;
584 token10 >> CZfaqf_nice;
585 convert_z = uiuc_convert(token_value_convert1);
586 convert_x = uiuc_convert(token_value_convert2);
587 convert_y = uiuc_convert(token_value_convert3);
588 convert_f = uiuc_convert(token_value_convert4);
589 CZfaqf_fArray[CZfaqf_index] = flap_value * convert_f;
590 /* call 2D File Reader with file name (CZfaqf_file) and
591 conversion factors; function returns array of
592 pitch rate (qArray) and corresponding
593 alpha (aArray) and delta CZ (CZArray) values and
594 max number of terms in alpha arrays (nAlphaArray)
595 and pitch rate array (nq) */
596 uiuc_2DdataFileReader(CZfaqf_file,
602 d_2_to_3(datafile_xArray, CZfaqf_aArray, CZfaqf_index);
603 d_1_to_2(datafile_yArray, CZfaqf_qArray, CZfaqf_index);
604 d_2_to_3(datafile_zArray, CZfaqf_CZArray, CZfaqf_index);
605 i_1_to_2(datafile_nxArray, CZfaqf_nAlphaArray, CZfaqf_index);
606 CZfaqf_nq[CZfaqf_index] = datafile_ny;
607 if (CZfaqf_first==true)
609 if (CZfaqf_nice == 1)
611 CZfaqf_na_nice = datafile_nxArray[1];
612 CZfaqf_nq_nice = datafile_ny;
613 d_1_to_1(datafile_yArray, CZfaqf_qArray_nice);
614 for (i=1; i<=CZfaqf_na_nice; i++)
615 CZfaqf_aArray_nice[i] = datafile_xArray[1][i];
617 aeroLiftParts -> storeCommands (*command_line);
624 if (ignore_unknown_keywords) {
627 // print error message
628 uiuc_warnings_errors(2, *command_line);