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>
80 #include "uiuc_menu_CL.h"
90 void parse_CL( 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, token_value_convert3;
98 int token_value_convert4;
99 double datafile_xArray[100][100], datafile_yArray[100];
100 double datafile_zArray[100][100];
102 int datafile_nxArray[100], datafile_ny;
103 istringstream token3(linetoken3.c_str());
104 istringstream token4(linetoken4.c_str());
105 istringstream token5(linetoken5.c_str());
106 istringstream token6(linetoken6.c_str());
107 istringstream token7(linetoken7.c_str());
108 istringstream token8(linetoken8.c_str());
109 istringstream token9(linetoken9.c_str());
110 istringstream token10(linetoken10.c_str());
112 static bool CZfabetaf_first = true;
113 static bool CZfadef_first = true;
114 static bool CZfaqf_first = true;
116 switch(CL_map[linetoken2])
120 if (check_float(linetoken3))
121 token3 >> token_value;
123 uiuc_warnings_errors(1, *command_line);
127 aeroLiftParts -> storeCommands (*command_line);
132 if (check_float(linetoken3))
133 token3 >> token_value;
135 uiuc_warnings_errors(1, *command_line);
139 aeroLiftParts -> storeCommands (*command_line);
144 if (check_float(linetoken3))
145 token3 >> token_value;
147 uiuc_warnings_errors(1, *command_line);
149 CL_adot = token_value;
150 CL_adot_clean = CL_adot;
151 aeroLiftParts -> storeCommands (*command_line);
156 if (check_float(linetoken3))
157 token3 >> token_value;
159 uiuc_warnings_errors(1, *command_line);
163 aeroLiftParts -> storeCommands (*command_line);
168 if (check_float(linetoken3))
169 token3 >> token_value;
171 uiuc_warnings_errors(1, *command_line);
174 aeroLiftParts -> storeCommands (*command_line);
179 if (check_float(linetoken3))
180 token3 >> token_value;
182 uiuc_warnings_errors(1, *command_line);
186 aeroLiftParts -> storeCommands (*command_line);
191 if (check_float(linetoken3))
192 token3 >> token_value;
194 uiuc_warnings_errors(1, *command_line);
197 aeroLiftParts -> storeCommands (*command_line);
202 if (check_float(linetoken3))
203 token3 >> token_value;
205 uiuc_warnings_errors(1, *command_line);
208 aeroLiftParts -> storeCommands (*command_line);
213 if (check_float(linetoken3))
214 token3 >> token_value;
216 uiuc_warnings_errors(1, *command_line);
219 aeroLiftParts -> storeCommands (*command_line);
224 CLfa = aircraft_directory + linetoken3;
225 token4 >> token_value_convert1;
226 token5 >> token_value_convert2;
227 convert_y = uiuc_convert(token_value_convert1);
228 convert_x = uiuc_convert(token_value_convert2);
229 /* call 1D File Reader with file name (CLfa) and conversion
230 factors; function returns array of alphas (aArray) and
231 corresponding CL values (CLArray) and max number of
232 terms in arrays (nAlpha) */
233 uiuc_1DdataFileReader(CLfa,
237 aeroLiftParts -> storeCommands (*command_line);
242 CLfade = aircraft_directory + linetoken3;
243 token4 >> token_value_convert1;
244 token5 >> token_value_convert2;
245 token6 >> token_value_convert3;
246 convert_z = uiuc_convert(token_value_convert1);
247 convert_x = uiuc_convert(token_value_convert2);
248 convert_y = uiuc_convert(token_value_convert3);
249 /* call 2D File Reader with file name (CLfade) and
250 conversion factors; function returns array of
251 elevator deflections (deArray) and corresponding
252 alpha (aArray) and delta CL (CLArray) values and
253 max number of terms in alpha arrays (nAlphaArray)
254 and deflection array (nde) */
255 uiuc_2DdataFileReader(CLfade,
261 aeroLiftParts -> storeCommands (*command_line);
266 CLfdf = aircraft_directory + linetoken3;
267 token4 >> token_value_convert1;
268 token5 >> token_value_convert2;
269 convert_y = uiuc_convert(token_value_convert1);
270 convert_x = uiuc_convert(token_value_convert2);
271 /* call 1D File Reader with file name (CLfdf) and conversion
272 factors; function returns array of dfs (dfArray) and
273 corresponding CL values (CLArray) and max number of
274 terms in arrays (ndf) */
275 uiuc_1DdataFileReader(CLfdf,
279 aeroLiftParts -> storeCommands (*command_line);
281 // additional variables to streamline flap routine in aerodeflections
283 //int temp_counter = 1;
284 //while (temp_counter <= ndf)
286 // dfArray[temp_counter] = CLfdf_dfArray[temp_counter];
287 // TimeArray[temp_counter] = dfTimefdf_TimeArray[temp_counter];
294 CLfadf = aircraft_directory + linetoken3;
295 token4 >> token_value_convert1;
296 token5 >> token_value_convert2;
297 token6 >> token_value_convert3;
298 convert_z = uiuc_convert(token_value_convert1);
299 convert_x = uiuc_convert(token_value_convert2);
300 convert_y = uiuc_convert(token_value_convert3);
301 /* call 2D File Reader with file name (CLfadf) and
302 conversion factors; function returns array of
303 flap deflections (dfArray) and corresponding
304 alpha (aArray) and delta CL (CLArray) values and
305 max number of terms in alpha arrays (nAlphaArray)
306 and deflection array (ndf) */
307 uiuc_2DdataFileReader(CLfadf,
313 aeroLiftParts -> storeCommands (*command_line);
318 if (check_float(linetoken3))
319 token3 >> token_value;
321 uiuc_warnings_errors(1, *command_line);
325 aeroLiftParts -> storeCommands (*command_line);
330 if (check_float(linetoken3))
331 token3 >> token_value;
333 uiuc_warnings_errors(1, *command_line);
337 aeroLiftParts -> storeCommands (*command_line);
342 if (check_float(linetoken3))
343 token3 >> token_value;
345 uiuc_warnings_errors(1, *command_line);
349 aeroLiftParts -> storeCommands (*command_line);
354 if (check_float(linetoken3))
355 token3 >> token_value;
357 uiuc_warnings_errors(1, *command_line);
361 aeroLiftParts -> storeCommands (*command_line);
366 if (check_float(linetoken3))
367 token3 >> token_value;
369 uiuc_warnings_errors(1, *command_line);
371 CZ_adot = token_value;
372 CZ_adot_clean = CZ_adot;
373 aeroLiftParts -> storeCommands (*command_line);
378 if (check_float(linetoken3))
379 token3 >> token_value;
381 uiuc_warnings_errors(1, *command_line);
385 aeroLiftParts -> storeCommands (*command_line);
390 if (check_float(linetoken3))
391 token3 >> token_value;
393 uiuc_warnings_errors(1, *command_line);
397 aeroLiftParts -> storeCommands (*command_line);
402 if (check_float(linetoken3))
403 token3 >> token_value;
405 uiuc_warnings_errors(1, *command_line);
407 CZ_deb2 = token_value;
408 CZ_deb2_clean = CZ_deb2;
409 aeroLiftParts -> storeCommands (*command_line);
414 if (check_float(linetoken3))
415 token3 >> token_value;
417 uiuc_warnings_errors(1, *command_line);
421 aeroLiftParts -> storeCommands (*command_line);
426 if (check_float(linetoken3))
427 token3 >> token_value;
429 uiuc_warnings_errors(1, *command_line);
431 CZ_adf = token_value;
432 CZ_adf_clean = CZ_adf;
433 aeroLiftParts -> storeCommands (*command_line);
438 CZfa = aircraft_directory + linetoken3;
439 token4 >> token_value_convert1;
440 token5 >> token_value_convert2;
441 convert_y = uiuc_convert(token_value_convert1);
442 convert_x = uiuc_convert(token_value_convert2);
443 /* call 1D File Reader with file name (CZfa) and conversion
444 factors; function returns array of alphas (aArray) and
445 corresponding CZ values (CZArray) and max number of
446 terms in arrays (nAlpha) */
447 uiuc_1DdataFileReader(CZfa,
451 aeroLiftParts -> storeCommands (*command_line);
456 int CZfabetaf_index, i;
457 string CZfabetaf_file;
459 CZfabetaf_file = aircraft_directory + linetoken3;
460 token4 >> CZfabetaf_index;
461 if (CZfabetaf_index < 0 || CZfabetaf_index >= 30)
462 uiuc_warnings_errors(1, *command_line);
463 if (CZfabetaf_index > CZfabetaf_nf)
464 CZfabetaf_nf = CZfabetaf_index;
465 token5 >> flap_value;
466 token6 >> token_value_convert1;
467 token7 >> token_value_convert2;
468 token8 >> token_value_convert3;
469 token9 >> token_value_convert4;
470 token10 >> CZfabetaf_nice;
471 convert_z = uiuc_convert(token_value_convert1);
472 convert_x = uiuc_convert(token_value_convert2);
473 convert_y = uiuc_convert(token_value_convert3);
474 convert_f = uiuc_convert(token_value_convert4);
475 CZfabetaf_fArray[CZfabetaf_index] = flap_value * convert_f;
476 /* call 2D File Reader with file name (CZfabetaf_file) and
477 conversion factors; function returns array of
478 beta (betaArray) and corresponding
479 alpha (aArray) and CZ (CZArray) values and
480 max number of terms in alpha arrays (nAlphaArray)
481 and beta array (nbeta) */
482 uiuc_2DdataFileReader(CZfabetaf_file,
488 d_2_to_3(datafile_xArray, CZfabetaf_aArray, CZfabetaf_index);
489 d_1_to_2(datafile_yArray, CZfabetaf_betaArray, CZfabetaf_index);
490 d_2_to_3(datafile_zArray, CZfabetaf_CZArray, CZfabetaf_index);
491 i_1_to_2(datafile_nxArray, CZfabetaf_nAlphaArray, CZfabetaf_index);
492 CZfabetaf_nbeta[CZfabetaf_index] = datafile_ny;
493 if (CZfabetaf_first==true)
495 if (CZfabetaf_nice == 1)
497 CZfabetaf_na_nice = datafile_nxArray[1];
498 CZfabetaf_nb_nice = datafile_ny;
499 d_1_to_1(datafile_yArray, CZfabetaf_bArray_nice);
500 for (i=1; i<=CZfabetaf_na_nice; i++)
501 CZfabetaf_aArray_nice[i] = datafile_xArray[1][i];
503 aeroLiftParts -> storeCommands (*command_line);
504 CZfabetaf_first=false;
510 int CZfadef_index, i;
513 CZfadef_file = aircraft_directory + linetoken3;
514 token4 >> CZfadef_index;
515 if (CZfadef_index < 0 || CZfadef_index >= 30)
516 uiuc_warnings_errors(1, *command_line);
517 if (CZfadef_index > CZfadef_nf)
518 CZfadef_nf = CZfadef_index;
519 token5 >> flap_value;
520 token6 >> token_value_convert1;
521 token7 >> token_value_convert2;
522 token8 >> token_value_convert3;
523 token9 >> token_value_convert4;
524 token10 >> CZfadef_nice;
525 convert_z = uiuc_convert(token_value_convert1);
526 convert_x = uiuc_convert(token_value_convert2);
527 convert_y = uiuc_convert(token_value_convert3);
528 convert_f = uiuc_convert(token_value_convert4);
529 CZfadef_fArray[CZfadef_index] = flap_value * convert_f;
530 /* call 2D File Reader with file name (CZfadef_file) and
531 conversion factors; function returns array of
532 elevator deflections (deArray) and corresponding
533 alpha (aArray) and delta CZ (CZArray) values and
534 max number of terms in alpha arrays (nAlphaArray)
535 and delfection array (nde) */
536 uiuc_2DdataFileReader(CZfadef_file,
542 d_2_to_3(datafile_xArray, CZfadef_aArray, CZfadef_index);
543 d_1_to_2(datafile_yArray, CZfadef_deArray, CZfadef_index);
544 d_2_to_3(datafile_zArray, CZfadef_CZArray, CZfadef_index);
545 i_1_to_2(datafile_nxArray, CZfadef_nAlphaArray, CZfadef_index);
546 CZfadef_nde[CZfadef_index] = datafile_ny;
547 if (CZfadef_first==true)
549 if (CZfadef_nice == 1)
551 CZfadef_na_nice = datafile_nxArray[1];
552 CZfadef_nde_nice = datafile_ny;
553 d_1_to_1(datafile_yArray, CZfadef_deArray_nice);
554 for (i=1; i<=CZfadef_na_nice; i++)
555 CZfadef_aArray_nice[i] = datafile_xArray[1][i];
557 aeroLiftParts -> storeCommands (*command_line);
567 CZfaqf_file = aircraft_directory + linetoken3;
568 token4 >> CZfaqf_index;
569 if (CZfaqf_index < 0 || CZfaqf_index >= 30)
570 uiuc_warnings_errors(1, *command_line);
571 if (CZfaqf_index > CZfaqf_nf)
572 CZfaqf_nf = CZfaqf_index;
573 token5 >> flap_value;
574 token6 >> token_value_convert1;
575 token7 >> token_value_convert2;
576 token8 >> token_value_convert3;
577 token9 >> token_value_convert4;
578 token10 >> CZfaqf_nice;
579 convert_z = uiuc_convert(token_value_convert1);
580 convert_x = uiuc_convert(token_value_convert2);
581 convert_y = uiuc_convert(token_value_convert3);
582 convert_f = uiuc_convert(token_value_convert4);
583 CZfaqf_fArray[CZfaqf_index] = flap_value * convert_f;
584 /* call 2D File Reader with file name (CZfaqf_file) and
585 conversion factors; function returns array of
586 pitch rate (qArray) and corresponding
587 alpha (aArray) and delta CZ (CZArray) values and
588 max number of terms in alpha arrays (nAlphaArray)
589 and pitch rate array (nq) */
590 uiuc_2DdataFileReader(CZfaqf_file,
596 d_2_to_3(datafile_xArray, CZfaqf_aArray, CZfaqf_index);
597 d_1_to_2(datafile_yArray, CZfaqf_qArray, CZfaqf_index);
598 d_2_to_3(datafile_zArray, CZfaqf_CZArray, CZfaqf_index);
599 i_1_to_2(datafile_nxArray, CZfaqf_nAlphaArray, CZfaqf_index);
600 CZfaqf_nq[CZfaqf_index] = datafile_ny;
601 if (CZfaqf_first==true)
603 if (CZfaqf_nice == 1)
605 CZfaqf_na_nice = datafile_nxArray[1];
606 CZfaqf_nq_nice = datafile_ny;
607 d_1_to_1(datafile_yArray, CZfaqf_qArray_nice);
608 for (i=1; i<=CZfaqf_na_nice; i++)
609 CZfaqf_aArray_nice[i] = datafile_xArray[1][i];
611 aeroLiftParts -> storeCommands (*command_line);
618 if (ignore_unknown_keywords) {
621 // print error message
622 uiuc_warnings_errors(2, *command_line);