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
22 ----------------------------------------------------------------------
24 AUTHOR(S): Robert Deters <rdeters@uiuc.edu>
25 Michael Selig <m-selig@uiuc.edu>
27 ----------------------------------------------------------------------
31 ----------------------------------------------------------------------
35 ----------------------------------------------------------------------
39 ----------------------------------------------------------------------
41 CALLED BY: uiuc_menu()
43 ----------------------------------------------------------------------
45 CALLS TO: check_float() if needed
51 ----------------------------------------------------------------------
53 COPYRIGHT: (C) 2003 by Michael Selig
55 This program is free software; you can redistribute it and/or
56 modify it under the terms of the GNU General Public License
57 as published by the Free Software Foundation.
59 This program is distributed in the hope that it will be useful,
60 but WITHOUT ANY WARRANTY; without even the implied warranty of
61 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
62 GNU General Public License for more details.
64 You should have received a copy of the GNU General Public License
65 along with this program; if not, write to the Free Software
66 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
67 USA or view http://www.gnu.org/copyleft/gpl.html.
69 **********************************************************************/
71 #include <simgear/compiler.h>
73 #if defined( __MWERKS__ )
74 // -dw- optimizer chokes (big-time) trying to optimize humongous
75 // loop/switch statements
76 #pragma optimization_level 0
83 #include "uiuc_menu_CL.h"
93 void parse_CL( const string& linetoken2, const string& linetoken3,
94 const string& linetoken4, const string& linetoken5,
95 const string& linetoken6, const string& linetoken7,
96 const string& linetoken8, const string& linetoken9,
97 const string& linetoken10, const string& aircraft_directory,
100 int token_value_convert1, token_value_convert2, token_value_convert3;
101 int token_value_convert4;
102 double datafile_xArray[100][100], datafile_yArray[100];
103 double datafile_zArray[100][100];
105 int datafile_nxArray[100], datafile_ny;
106 istrstream token3(linetoken3.c_str());
107 istrstream token4(linetoken4.c_str());
108 istrstream token5(linetoken5.c_str());
109 istrstream token6(linetoken6.c_str());
110 istrstream token7(linetoken7.c_str());
111 istrstream token8(linetoken8.c_str());
112 istrstream token9(linetoken9.c_str());
113 istrstream token10(linetoken10.c_str());
115 static bool CZfabetaf_first = true;
116 static bool CZfadef_first = true;
117 static bool CZfaqf_first = true;
119 switch(CL_map[linetoken2])
123 if (check_float(linetoken3))
124 token3 >> token_value;
126 uiuc_warnings_errors(1, *command_line);
130 aeroLiftParts -> storeCommands (*command_line);
135 if (check_float(linetoken3))
136 token3 >> token_value;
138 uiuc_warnings_errors(1, *command_line);
142 aeroLiftParts -> storeCommands (*command_line);
147 if (check_float(linetoken3))
148 token3 >> token_value;
150 uiuc_warnings_errors(1, *command_line);
152 CL_adot = token_value;
153 CL_adot_clean = CL_adot;
154 aeroLiftParts -> storeCommands (*command_line);
159 if (check_float(linetoken3))
160 token3 >> token_value;
162 uiuc_warnings_errors(1, *command_line);
166 aeroLiftParts -> storeCommands (*command_line);
171 if (check_float(linetoken3))
172 token3 >> token_value;
174 uiuc_warnings_errors(1, *command_line);
177 aeroLiftParts -> storeCommands (*command_line);
182 if (check_float(linetoken3))
183 token3 >> token_value;
185 uiuc_warnings_errors(1, *command_line);
189 aeroLiftParts -> storeCommands (*command_line);
194 if (check_float(linetoken3))
195 token3 >> token_value;
197 uiuc_warnings_errors(1, *command_line);
200 aeroLiftParts -> storeCommands (*command_line);
205 if (check_float(linetoken3))
206 token3 >> token_value;
208 uiuc_warnings_errors(1, *command_line);
211 aeroLiftParts -> storeCommands (*command_line);
216 if (check_float(linetoken3))
217 token3 >> token_value;
219 uiuc_warnings_errors(1, *command_line);
222 aeroLiftParts -> storeCommands (*command_line);
227 CLfa = aircraft_directory + linetoken3;
228 token4 >> token_value_convert1;
229 token5 >> token_value_convert2;
230 convert_y = uiuc_convert(token_value_convert1);
231 convert_x = uiuc_convert(token_value_convert2);
232 /* call 1D File Reader with file name (CLfa) and conversion
233 factors; function returns array of alphas (aArray) and
234 corresponding CL values (CLArray) and max number of
235 terms in arrays (nAlpha) */
236 uiuc_1DdataFileReader(CLfa,
240 aeroLiftParts -> storeCommands (*command_line);
245 CLfade = aircraft_directory + linetoken3;
246 token4 >> token_value_convert1;
247 token5 >> token_value_convert2;
248 token6 >> token_value_convert3;
249 convert_z = uiuc_convert(token_value_convert1);
250 convert_x = uiuc_convert(token_value_convert2);
251 convert_y = uiuc_convert(token_value_convert3);
252 /* call 2D File Reader with file name (CLfade) and
253 conversion factors; function returns array of
254 elevator deflections (deArray) and corresponding
255 alpha (aArray) and delta CL (CLArray) values and
256 max number of terms in alpha arrays (nAlphaArray)
257 and deflection array (nde) */
258 uiuc_2DdataFileReader(CLfade,
264 aeroLiftParts -> storeCommands (*command_line);
269 CLfdf = aircraft_directory + linetoken3;
270 token4 >> token_value_convert1;
271 token5 >> token_value_convert2;
272 convert_y = uiuc_convert(token_value_convert1);
273 convert_x = uiuc_convert(token_value_convert2);
274 /* call 1D File Reader with file name (CLfdf) and conversion
275 factors; function returns array of dfs (dfArray) and
276 corresponding CL values (CLArray) and max number of
277 terms in arrays (ndf) */
278 uiuc_1DdataFileReader(CLfdf,
282 aeroLiftParts -> storeCommands (*command_line);
284 // additional variables to streamline flap routine in aerodeflections
286 int temp_counter = 1;
287 while (temp_counter <= ndf)
289 dfArray[temp_counter] = CLfdf_dfArray[temp_counter];
290 TimeArray[temp_counter] = dfTimefdf_TimeArray[temp_counter];
297 CLfadf = aircraft_directory + linetoken3;
298 token4 >> token_value_convert1;
299 token5 >> token_value_convert2;
300 token6 >> token_value_convert3;
301 convert_z = uiuc_convert(token_value_convert1);
302 convert_x = uiuc_convert(token_value_convert2);
303 convert_y = uiuc_convert(token_value_convert3);
304 /* call 2D File Reader with file name (CLfadf) and
305 conversion factors; function returns array of
306 flap deflections (dfArray) and corresponding
307 alpha (aArray) and delta CL (CLArray) values and
308 max number of terms in alpha arrays (nAlphaArray)
309 and deflection array (ndf) */
310 uiuc_2DdataFileReader(CLfadf,
316 aeroLiftParts -> storeCommands (*command_line);
321 if (check_float(linetoken3))
322 token3 >> token_value;
324 uiuc_warnings_errors(1, *command_line);
328 aeroLiftParts -> storeCommands (*command_line);
333 if (check_float(linetoken3))
334 token3 >> token_value;
336 uiuc_warnings_errors(1, *command_line);
340 aeroLiftParts -> storeCommands (*command_line);
345 if (check_float(linetoken3))
346 token3 >> token_value;
348 uiuc_warnings_errors(1, *command_line);
352 aeroLiftParts -> storeCommands (*command_line);
357 if (check_float(linetoken3))
358 token3 >> token_value;
360 uiuc_warnings_errors(1, *command_line);
364 aeroLiftParts -> storeCommands (*command_line);
369 if (check_float(linetoken3))
370 token3 >> token_value;
372 uiuc_warnings_errors(1, *command_line);
374 CZ_adot = token_value;
375 CZ_adot_clean = CZ_adot;
376 aeroLiftParts -> storeCommands (*command_line);
381 if (check_float(linetoken3))
382 token3 >> token_value;
384 uiuc_warnings_errors(1, *command_line);
388 aeroLiftParts -> storeCommands (*command_line);
393 if (check_float(linetoken3))
394 token3 >> token_value;
396 uiuc_warnings_errors(1, *command_line);
400 aeroLiftParts -> storeCommands (*command_line);
405 if (check_float(linetoken3))
406 token3 >> token_value;
408 uiuc_warnings_errors(1, *command_line);
410 CZ_deb2 = token_value;
411 CZ_deb2_clean = CZ_deb2;
412 aeroLiftParts -> storeCommands (*command_line);
417 if (check_float(linetoken3))
418 token3 >> token_value;
420 uiuc_warnings_errors(1, *command_line);
424 aeroLiftParts -> storeCommands (*command_line);
429 if (check_float(linetoken3))
430 token3 >> token_value;
432 uiuc_warnings_errors(1, *command_line);
434 CZ_adf = token_value;
435 CZ_adf_clean = CZ_adf;
436 aeroLiftParts -> storeCommands (*command_line);
441 CZfa = 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 /* call 1D File Reader with file name (CZfa) and conversion
447 factors; function returns array of alphas (aArray) and
448 corresponding CZ values (CZArray) and max number of
449 terms in arrays (nAlpha) */
450 uiuc_1DdataFileReader(CZfa,
454 aeroLiftParts -> storeCommands (*command_line);
459 int CZfabetaf_index, i;
460 string CZfabetaf_file;
462 CZfabetaf_file = aircraft_directory + linetoken3;
463 token4 >> CZfabetaf_index;
464 if (CZfabetaf_index < 0 || CZfabetaf_index >= 30)
465 uiuc_warnings_errors(1, *command_line);
466 if (CZfabetaf_index > CZfabetaf_nf)
467 CZfabetaf_nf = CZfabetaf_index;
468 token5 >> flap_value;
469 token6 >> token_value_convert1;
470 token7 >> token_value_convert2;
471 token8 >> token_value_convert3;
472 token9 >> token_value_convert4;
473 token10 >> CZfabetaf_nice;
474 convert_z = uiuc_convert(token_value_convert1);
475 convert_x = uiuc_convert(token_value_convert2);
476 convert_y = uiuc_convert(token_value_convert3);
477 convert_f = uiuc_convert(token_value_convert4);
478 CZfabetaf_fArray[CZfabetaf_index] = flap_value * convert_f;
479 /* call 2D File Reader with file name (CZfabetaf_file) and
480 conversion factors; function returns array of
481 beta (betaArray) and corresponding
482 alpha (aArray) and CZ (CZArray) values and
483 max number of terms in alpha arrays (nAlphaArray)
484 and beta array (nbeta) */
485 uiuc_2DdataFileReader(CZfabetaf_file,
491 d_2_to_3(datafile_xArray, CZfabetaf_aArray, CZfabetaf_index);
492 d_1_to_2(datafile_yArray, CZfabetaf_betaArray, CZfabetaf_index);
493 d_2_to_3(datafile_zArray, CZfabetaf_CZArray, CZfabetaf_index);
494 i_1_to_2(datafile_nxArray, CZfabetaf_nAlphaArray, CZfabetaf_index);
495 CZfabetaf_nbeta[CZfabetaf_index] = datafile_ny;
496 if (CZfabetaf_first==true)
498 if (CZfabetaf_nice == 1)
500 CZfabetaf_na_nice = datafile_nxArray[1];
501 CZfabetaf_nb_nice = datafile_ny;
502 d_1_to_1(datafile_yArray, CZfabetaf_bArray_nice);
503 for (i=1; i<=CZfabetaf_na_nice; i++)
504 CZfabetaf_aArray_nice[i] = datafile_xArray[1][i];
506 aeroLiftParts -> storeCommands (*command_line);
507 CZfabetaf_first=false;
513 int CZfadef_index, i;
516 CZfadef_file = aircraft_directory + linetoken3;
517 token4 >> CZfadef_index;
518 if (CZfadef_index < 0 || CZfadef_index >= 30)
519 uiuc_warnings_errors(1, *command_line);
520 if (CZfadef_index > CZfadef_nf)
521 CZfadef_nf = CZfadef_index;
522 token5 >> flap_value;
523 token6 >> token_value_convert1;
524 token7 >> token_value_convert2;
525 token8 >> token_value_convert3;
526 token9 >> token_value_convert4;
527 token10 >> CZfadef_nice;
528 convert_z = uiuc_convert(token_value_convert1);
529 convert_x = uiuc_convert(token_value_convert2);
530 convert_y = uiuc_convert(token_value_convert3);
531 convert_f = uiuc_convert(token_value_convert4);
532 CZfadef_fArray[CZfadef_index] = flap_value * convert_f;
533 /* call 2D File Reader with file name (CZfadef_file) and
534 conversion factors; function returns array of
535 elevator deflections (deArray) and corresponding
536 alpha (aArray) and delta CZ (CZArray) values and
537 max number of terms in alpha arrays (nAlphaArray)
538 and delfection array (nde) */
539 uiuc_2DdataFileReader(CZfadef_file,
545 d_2_to_3(datafile_xArray, CZfadef_aArray, CZfadef_index);
546 d_1_to_2(datafile_yArray, CZfadef_deArray, CZfadef_index);
547 d_2_to_3(datafile_zArray, CZfadef_CZArray, CZfadef_index);
548 i_1_to_2(datafile_nxArray, CZfadef_nAlphaArray, CZfadef_index);
549 CZfadef_nde[CZfadef_index] = datafile_ny;
550 if (CZfadef_first==true)
552 if (CZfadef_nice == 1)
554 CZfadef_na_nice = datafile_nxArray[1];
555 CZfadef_nde_nice = datafile_ny;
556 d_1_to_1(datafile_yArray, CZfadef_deArray_nice);
557 for (i=1; i<=CZfadef_na_nice; i++)
558 CZfadef_aArray_nice[i] = datafile_xArray[1][i];
560 aeroLiftParts -> storeCommands (*command_line);
570 CZfaqf_file = aircraft_directory + linetoken3;
571 token4 >> CZfaqf_index;
572 if (CZfaqf_index < 0 || CZfaqf_index >= 30)
573 uiuc_warnings_errors(1, *command_line);
574 if (CZfaqf_index > CZfaqf_nf)
575 CZfaqf_nf = CZfaqf_index;
576 token5 >> flap_value;
577 token6 >> token_value_convert1;
578 token7 >> token_value_convert2;
579 token8 >> token_value_convert3;
580 token9 >> token_value_convert4;
581 token10 >> CZfaqf_nice;
582 convert_z = uiuc_convert(token_value_convert1);
583 convert_x = uiuc_convert(token_value_convert2);
584 convert_y = uiuc_convert(token_value_convert3);
585 convert_f = uiuc_convert(token_value_convert4);
586 CZfaqf_fArray[CZfaqf_index] = flap_value * convert_f;
587 /* call 2D File Reader with file name (CZfaqf_file) and
588 conversion factors; function returns array of
589 pitch rate (qArray) and corresponding
590 alpha (aArray) and delta CZ (CZArray) values and
591 max number of terms in alpha arrays (nAlphaArray)
592 and pitch rate array (nq) */
593 uiuc_2DdataFileReader(CZfaqf_file,
599 d_2_to_3(datafile_xArray, CZfaqf_aArray, CZfaqf_index);
600 d_1_to_2(datafile_yArray, CZfaqf_qArray, CZfaqf_index);
601 d_2_to_3(datafile_zArray, CZfaqf_CZArray, CZfaqf_index);
602 i_1_to_2(datafile_nxArray, CZfaqf_nAlphaArray, CZfaqf_index);
603 CZfaqf_nq[CZfaqf_index] = datafile_ny;
604 if (CZfaqf_first==true)
606 if (CZfaqf_nice == 1)
608 CZfaqf_na_nice = datafile_nxArray[1];
609 CZfaqf_nq_nice = datafile_ny;
610 d_1_to_1(datafile_yArray, CZfaqf_qArray_nice);
611 for (i=1; i<=CZfaqf_na_nice; i++)
612 CZfaqf_aArray_nice[i] = datafile_xArray[1][i];
614 aeroLiftParts -> storeCommands (*command_line);
621 if (ignore_unknown_keywords) {
624 // print error message
625 uiuc_warnings_errors(2, *command_line);