]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_menu_CL.cpp
Make yasim accept the launchbar and hook properties. They are not tied to anything...
[flightgear.git] / src / FDM / UIUCModel / uiuc_menu_CL.cpp
1 /**********************************************************************
2                                                                        
3  FILENAME:     uiuc_menu_CL.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  reads input data for specified aircraft and creates 
8                approporiate data storage space
9
10 ----------------------------------------------------------------------
11
12  STATUS:       alpha version
13
14 ----------------------------------------------------------------------
15
16  REFERENCES:   based on "menu reader" format of Michael Selig
17
18 ----------------------------------------------------------------------
19
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
24
25 ----------------------------------------------------------------------
26
27  AUTHOR(S):    Robert Deters      <rdeters@uiuc.edu>
28                Michael Selig      <m-selig@uiuc.edu>
29
30 ----------------------------------------------------------------------
31
32  VARIABLES:
33
34 ----------------------------------------------------------------------
35
36  INPUTS:       n/a
37
38 ----------------------------------------------------------------------
39
40  OUTPUTS:      n/a
41
42 ----------------------------------------------------------------------
43
44  CALLED BY:    uiuc_menu()
45
46 ----------------------------------------------------------------------
47
48  CALLS TO:     check_float() if needed
49                d_2_to_3() if needed
50                d_1_to_2() if needed
51                i_1_to_2() if needed
52                d_1_to_1() if needed
53
54  ----------------------------------------------------------------------
55
56  COPYRIGHT:    (C) 2003 by Michael Selig
57
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.
61
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.
66
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.
71
72 **********************************************************************/
73
74 #include <simgear/compiler.h>
75
76 #if defined( __MWERKS__ )
77 // -dw- optimizer chokes (big-time) trying to optimize humongous
78 // loop/switch statements
79 #pragma optimization_level 0
80 #endif
81
82 #include <cstdlib>
83 #include <string>
84 #include STL_IOSTREAM
85
86 #include "uiuc_menu_CL.h"
87
88 SG_USING_STD(cerr);
89 SG_USING_STD(cout);
90 SG_USING_STD(endl);
91
92 #ifndef _MSC_VER
93 SG_USING_STD(exit);
94 #endif
95
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 ) {
102     double token_value;
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];
107     double convert_f;
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());
117
118     static bool CZfabetaf_first = true;
119     static bool CZfadef_first = true;
120     static bool CZfaqf_first = true;
121
122     switch(CL_map[linetoken2])
123       {
124       case CLo_flag:
125         {
126           if (check_float(linetoken3))
127             token3 >> token_value;
128           else
129             uiuc_warnings_errors(1, *command_line);
130           
131           CLo = token_value;
132           CLo_clean = CLo;
133           aeroLiftParts -> storeCommands (*command_line);
134           break;
135         }
136       case CL_a_flag:
137         {
138           if (check_float(linetoken3))
139             token3 >> token_value;
140           else
141             uiuc_warnings_errors(1, *command_line);
142           
143           CL_a = token_value;
144           CL_a_clean = CL_a;
145           aeroLiftParts -> storeCommands (*command_line);
146           break;
147         }
148       case CL_adot_flag:
149         {
150           if (check_float(linetoken3))
151             token3 >> token_value;
152           else
153             uiuc_warnings_errors(1, *command_line);
154           
155           CL_adot = token_value;
156           CL_adot_clean = CL_adot;
157           aeroLiftParts -> storeCommands (*command_line);
158           break;
159         }
160       case CL_q_flag:
161         {
162           if (check_float(linetoken3))
163             token3 >> token_value;
164           else
165             uiuc_warnings_errors(1, *command_line);
166           
167           CL_q = token_value;
168           CL_q_clean = CL_q;
169           aeroLiftParts -> storeCommands (*command_line);
170           break;
171         }
172       case CL_ih_flag:
173         {
174           if (check_float(linetoken3))
175             token3 >> token_value;
176           else
177             uiuc_warnings_errors(1, *command_line);
178           
179           CL_ih = token_value;
180           aeroLiftParts -> storeCommands (*command_line);
181           break;
182         }
183       case CL_de_flag:
184         {
185           if (check_float(linetoken3))
186             token3 >> token_value;
187           else
188             uiuc_warnings_errors(1, *command_line);
189           
190           CL_de = token_value;
191           CL_de_clean = CL_de;
192           aeroLiftParts -> storeCommands (*command_line);
193           break;
194         }
195       case CL_df_flag:
196         {
197           if (check_float(linetoken3))
198             token3 >> token_value;
199           else
200             uiuc_warnings_errors(1, *command_line);
201           
202           CL_df = token_value;
203           aeroLiftParts -> storeCommands (*command_line);
204           break;
205         }
206       case CL_ds_flag:
207         {
208           if (check_float(linetoken3))
209             token3 >> token_value;
210           else
211             uiuc_warnings_errors(1, *command_line);
212           
213           CL_ds = token_value;
214           aeroLiftParts -> storeCommands (*command_line);
215           break;
216         }
217       case CL_dg_flag:
218         {
219           if (check_float(linetoken3))
220             token3 >> token_value;
221           else
222             uiuc_warnings_errors(1, *command_line);
223           
224           CL_dg = token_value;
225           aeroLiftParts -> storeCommands (*command_line);
226           break;
227         }
228       case CLfa_flag:
229         {
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,
240                                 CLfa_aArray,
241                                 CLfa_CLArray,
242                                 CLfa_nAlpha);
243           aeroLiftParts -> storeCommands (*command_line);
244           break;
245         }
246       case CLfade_flag:
247         {
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,
262                                 CLfade_aArray,
263                                 CLfade_deArray,
264                                 CLfade_CLArray,
265                                 CLfade_nAlphaArray,
266                                 CLfade_nde);
267           aeroLiftParts -> storeCommands (*command_line);
268           break;
269         }
270       case CLfdf_flag:
271         {
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,
282                                 CLfdf_dfArray,
283                                 CLfdf_CLArray,
284                                 CLfdf_ndf);
285           aeroLiftParts -> storeCommands (*command_line);
286           
287           // additional variables to streamline flap routine in aerodeflections
288           //ndf = CLfdf_ndf;
289           //int temp_counter = 1;
290           //while (temp_counter <= ndf)
291           //  {
292           //    dfArray[temp_counter] = CLfdf_dfArray[temp_counter];
293           //    TimeArray[temp_counter] = dfTimefdf_TimeArray[temp_counter];
294           //    temp_counter++;
295           //  }
296           break;
297         }
298       case CLfadf_flag:
299         {
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,
314                                 CLfadf_aArray,
315                                 CLfadf_dfArray,
316                                 CLfadf_CLArray,
317                                 CLfadf_nAlphaArray,
318                                 CLfadf_ndf);
319           aeroLiftParts -> storeCommands (*command_line);
320           break;
321         }
322       case CZo_flag:
323         {
324           if (check_float(linetoken3))
325             token3 >> token_value;
326           else
327             uiuc_warnings_errors(1, *command_line);
328           
329           CZo = token_value;
330           CZo_clean = CZo;
331           aeroLiftParts -> storeCommands (*command_line);
332           break;
333         }
334       case CZ_a_flag:
335         {
336           if (check_float(linetoken3))
337             token3 >> token_value;
338           else
339             uiuc_warnings_errors(1, *command_line);
340           
341           CZ_a = token_value;
342           CZ_a_clean = CZ_a;
343           aeroLiftParts -> storeCommands (*command_line);
344           break;
345         }
346       case CZ_a2_flag:
347         {
348           if (check_float(linetoken3))
349             token3 >> token_value;
350           else
351             uiuc_warnings_errors(1, *command_line);
352           
353           CZ_a2 = token_value;
354           CZ_a2_clean = CZ_a2;
355           aeroLiftParts -> storeCommands (*command_line);
356           break;
357         }
358       case CZ_a3_flag:
359         {
360           if (check_float(linetoken3))
361             token3 >> token_value;
362           else
363             uiuc_warnings_errors(1, *command_line);
364           
365           CZ_a3 = token_value;
366           CZ_a3_clean = CZ_a3;
367           aeroLiftParts -> storeCommands (*command_line);
368           break;
369         }
370       case CZ_adot_flag:
371         {
372           if (check_float(linetoken3))
373             token3 >> token_value;
374           else
375             uiuc_warnings_errors(1, *command_line);
376           
377           CZ_adot = token_value;
378           CZ_adot_clean = CZ_adot;
379           aeroLiftParts -> storeCommands (*command_line);
380           break;
381         }
382       case CZ_q_flag:
383         {
384           if (check_float(linetoken3))
385             token3 >> token_value;
386           else
387             uiuc_warnings_errors(1, *command_line);
388           
389           CZ_q = token_value;
390           CZ_q_clean = CZ_q;
391           aeroLiftParts -> storeCommands (*command_line);
392           break;
393         }
394       case CZ_de_flag:
395         {
396           if (check_float(linetoken3))
397             token3 >> token_value;
398           else
399             uiuc_warnings_errors(1, *command_line);
400           
401           CZ_de = token_value;
402           CZ_de_clean = CZ_de;
403           aeroLiftParts -> storeCommands (*command_line);
404           break;
405         }
406       case CZ_deb2_flag:
407         {
408           if (check_float(linetoken3))
409             token3 >> token_value;
410           else
411             uiuc_warnings_errors(1, *command_line);
412           
413           CZ_deb2 = token_value;
414           CZ_deb2_clean = CZ_deb2;
415           aeroLiftParts -> storeCommands (*command_line);
416           break;
417         }
418       case CZ_df_flag:
419         {
420           if (check_float(linetoken3))
421             token3 >> token_value;
422           else
423             uiuc_warnings_errors(1, *command_line);
424           
425           CZ_df = token_value;
426           CZ_df_clean = CZ_df;
427           aeroLiftParts -> storeCommands (*command_line);
428           break;
429         }
430       case CZ_adf_flag:
431         {
432           if (check_float(linetoken3))
433             token3 >> token_value;
434           else
435             uiuc_warnings_errors(1, *command_line);
436           
437           CZ_adf = token_value;
438           CZ_adf_clean = CZ_adf;
439           aeroLiftParts -> storeCommands (*command_line);
440           break;
441         }
442       case CZfa_flag:
443         {
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,
454                                 CZfa_aArray,
455                                 CZfa_CZArray,
456                                 CZfa_nAlpha);
457           aeroLiftParts -> storeCommands (*command_line);
458           break;
459         }
460       case CZfabetaf_flag:
461         {
462           int CZfabetaf_index, i;
463           string CZfabetaf_file;
464           double flap_value;
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,
489                                 datafile_xArray,
490                                 datafile_yArray,
491                                 datafile_zArray,
492                                 datafile_nxArray,
493                                 datafile_ny);
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)
500             {
501               if (CZfabetaf_nice == 1)
502                 {
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];
508                 }
509               aeroLiftParts -> storeCommands (*command_line);
510               CZfabetaf_first=false;
511             }
512           break;
513         }
514       case CZfadef_flag:
515         {
516           int CZfadef_index, i;
517           string CZfadef_file;
518           double flap_value;
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,
543                                 datafile_xArray,
544                                 datafile_yArray,
545                                 datafile_zArray,
546                                 datafile_nxArray,
547                                 datafile_ny);
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)
554             {
555               if (CZfadef_nice == 1)
556                 {
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];
562                 }
563               aeroLiftParts -> storeCommands (*command_line);
564               CZfadef_first=false;
565             }
566           break;
567         }
568       case CZfaqf_flag:
569         {
570           int CZfaqf_index, i;
571           string CZfaqf_file;
572           double flap_value;
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,
597                                 datafile_xArray,
598                                 datafile_yArray,
599                                 datafile_zArray,
600                                 datafile_nxArray,
601                                 datafile_ny);
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)
608             {
609               if (CZfaqf_nice == 1)
610                 {
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];
616                 }
617               aeroLiftParts -> storeCommands (*command_line);
618               CZfaqf_first=false;
619             }
620           break;
621         }
622       default:
623         {
624           if (ignore_unknown_keywords) {
625             // do nothing
626           } else {
627             // print error message
628             uiuc_warnings_errors(2, *command_line);
629           }
630           break;
631         }
632       };
633 }