]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_menu_init.cpp
Harald JOHNSEN:
[flightgear.git] / src / FDM / UIUCModel / uiuc_menu_init.cpp
1 /**********************************************************************
2                                                                        
3  FILENAME:     uiuc_menu_init.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                08/20/2003   (RD) removed old_flap_routine
25
26 ----------------------------------------------------------------------
27
28  AUTHOR(S):    Robert Deters      <rdeters@uiuc.edu>
29                Michael Selig      <m-selig@uiuc.edu>
30
31 ----------------------------------------------------------------------
32
33  VARIABLES:
34
35 ----------------------------------------------------------------------
36
37  INPUTS:       n/a
38
39 ----------------------------------------------------------------------
40
41  OUTPUTS:      n/a
42
43 ----------------------------------------------------------------------
44
45  CALLED BY:    uiuc_menu()
46
47 ----------------------------------------------------------------------
48
49  CALLS TO:     check_float() if needed
50                d_2_to_3() if needed
51                d_1_to_2() if needed
52                i_1_to_2() if needed
53                d_1_to_1() if needed
54
55  ----------------------------------------------------------------------
56
57  COPYRIGHT:    (C) 2003 by Michael Selig
58
59  This program is free software; you can redistribute it and/or
60  modify it under the terms of the GNU General Public License
61  as published by the Free Software Foundation.
62
63  This program is distributed in the hope that it will be useful,
64  but WITHOUT ANY WARRANTY; without even the implied warranty of
65  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
66  GNU General Public License for more details.
67
68  You should have received a copy of the GNU General Public License
69  along with this program; if not, write to the Free Software
70  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
71  USA or view http://www.gnu.org/copyleft/gpl.html.
72
73 **********************************************************************/
74
75 #include <simgear/compiler.h>
76
77 #if defined( __MWERKS__ )
78 // -dw- optimizer chokes (big-time) trying to optimize humongous
79 // loop/switch statements
80 #pragma optimization_level 0
81 #endif
82
83 #include <cstdlib>
84 #include <string>
85 #include STL_IOSTREAM
86
87 #include "uiuc_menu_init.h"
88
89 SG_USING_STD(cerr);
90 SG_USING_STD(cout);
91 SG_USING_STD(endl);
92
93 #ifndef _MSC_VER
94 SG_USING_STD(exit);
95 #endif
96
97 void parse_init( const string& linetoken2, const string& linetoken3,
98                  const string& linetoken4, const string& linetoken5, 
99                  const string& linetoken6, const string& linetoken7, 
100                  const string& linetoken8, const string& linetoken9,
101                  const string& linetoken10, const string& aircraft_directory,
102                  LIST command_line ) {
103     double token_value;
104     istringstream token3(linetoken3.c_str());
105     istringstream token4(linetoken4.c_str());
106     istringstream token5(linetoken5.c_str());
107     istringstream token6(linetoken6.c_str());
108     istringstream token7(linetoken7.c_str());
109     istringstream token8(linetoken8.c_str());
110     istringstream token9(linetoken9.c_str());
111     istringstream token10(linetoken10.c_str());
112     int token_value_recordRate;
113
114     switch(init_map[linetoken2])
115       {
116       case Dx_pilot_flag:
117         {
118           if (check_float(linetoken3))
119             token3 >> token_value;
120           else
121             uiuc_warnings_errors(1, *command_line);
122           
123           Dx_pilot = token_value;
124           initParts -> storeCommands (*command_line);
125           break;
126         }
127       case Dy_pilot_flag:
128         {
129           if (check_float(linetoken3))
130             token3 >> token_value;
131           else
132             uiuc_warnings_errors(1, *command_line);
133           
134           Dy_pilot = token_value;
135           initParts -> storeCommands (*command_line);
136           break;
137         }
138       case Dz_pilot_flag:
139         {
140           if (check_float(linetoken3))
141             token3 >> token_value;
142           else
143             uiuc_warnings_errors(1, *command_line);
144           
145           Dz_pilot = token_value;
146           initParts -> storeCommands (*command_line);
147           break;
148         }
149       case Dx_cg_flag:
150         {
151           if (check_float(linetoken3))
152             token3 >> token_value;
153           else
154             uiuc_warnings_errors(1, *command_line);
155           
156           Dx_cg = token_value;
157           initParts -> storeCommands (*command_line);
158           break;
159         }
160       case Dy_cg_flag:
161         {
162           if (check_float(linetoken3))
163             token3 >> token_value;
164           else
165             uiuc_warnings_errors(1, *command_line);
166           
167           Dy_cg = token_value;
168           initParts -> storeCommands (*command_line);
169           break;
170         }
171       case Dz_cg_flag:
172         {
173           if (check_float(linetoken3))
174             token3 >> token_value;
175           else
176             uiuc_warnings_errors(1, *command_line);
177           
178           Dz_cg = token_value;
179           initParts -> storeCommands (*command_line);
180           break;
181         }
182       case Altitude_flag:
183         {
184           if (check_float(linetoken3))
185             token3 >> token_value;
186           else
187             uiuc_warnings_errors(1, *command_line);
188           
189           Altitude = token_value;
190           initParts -> storeCommands (*command_line);
191           break;
192         }
193       case V_north_flag:
194         {
195           if (check_float(linetoken3)) 
196             token3 >> token_value;
197           else
198             uiuc_warnings_errors(1, *command_line);
199           
200           V_north = token_value;
201           initParts -> storeCommands (*command_line);
202           break;
203         }
204       case V_east_flag:
205         {
206           initParts -> storeCommands (*command_line);
207           if (check_float(linetoken3))
208             token3 >> token_value;
209           else
210             uiuc_warnings_errors(1, *command_line);
211           
212           V_east = token_value;
213           break;
214         }
215       case V_down_flag:
216         {
217           if (check_float(linetoken3))
218             token3 >> token_value;
219           else
220             uiuc_warnings_errors(1, *command_line);
221           
222           V_down = token_value;
223           initParts -> storeCommands (*command_line);
224           break;
225         }
226       case P_body_flag:
227         {
228           if (check_float(linetoken3))
229             token3 >> token_value;
230           else
231             uiuc_warnings_errors(1, *command_line);
232           
233           P_body_init_true = true;
234           P_body_init = token_value;
235           initParts -> storeCommands (*command_line);
236           break;
237         }
238       case Q_body_flag:
239         {
240           if (check_float(linetoken3))
241             token3 >> token_value;
242           else
243             uiuc_warnings_errors(1, *command_line);
244           
245           Q_body_init_true = true;
246           Q_body_init = token_value;
247           initParts -> storeCommands (*command_line);
248           break;
249         }
250       case R_body_flag:
251         {
252           if (check_float(linetoken3))
253             token3 >> token_value;
254           else
255             uiuc_warnings_errors(1, *command_line);
256           
257           R_body_init_true = true;
258           R_body_init = token_value;
259           initParts -> storeCommands (*command_line);
260           break;
261         }
262       case Phi_flag:
263         {
264           if (check_float(linetoken3))
265             token3 >> token_value;
266           else
267             uiuc_warnings_errors(1, *command_line);
268           
269           Phi_init_true = true;
270           Phi_init = token_value;
271           initParts -> storeCommands (*command_line);
272           break;
273         }
274       case Theta_flag:
275         {
276           if (check_float(linetoken3))
277             token3 >> token_value;
278           else
279             uiuc_warnings_errors(1, *command_line);
280           
281           Theta_init_true = true;
282           Theta_init = token_value;
283           initParts -> storeCommands (*command_line);
284           break;
285         }
286       case Psi_flag:
287         {
288           if (check_float(linetoken3))
289             token3 >> token_value;
290           else
291             uiuc_warnings_errors(1, *command_line);
292           
293           Psi_init_true = true;
294           Psi_init = token_value;
295           initParts -> storeCommands (*command_line);
296           break;
297         }
298       case Long_trim_flag:
299         {
300           if (check_float(linetoken3))
301             token3 >> token_value;
302           else
303             uiuc_warnings_errors(1, *command_line);
304           
305           Long_trim = token_value;
306           initParts -> storeCommands (*command_line);
307           break;
308         }
309       case recordRate_flag:
310         {
311           //can't use check_float since variable is integer
312           token3 >> token_value_recordRate;
313           recordRate = 120 / token_value_recordRate;
314           break;
315         }
316       case recordStartTime_flag:
317         {
318           if (check_float(linetoken3))
319             token3 >> token_value;
320           else
321             uiuc_warnings_errors(1, *command_line);
322           
323           recordStartTime = token_value;
324           break;
325         }
326       case use_V_rel_wind_2U_flag:
327         {
328           use_V_rel_wind_2U = true;
329           break;
330         }
331       case nondim_rate_V_rel_wind_flag:
332         {
333           nondim_rate_V_rel_wind = true;
334           break;
335         }
336       case use_abs_U_body_2U_flag:
337         {
338           use_abs_U_body_2U = true;
339           break;
340         }
341       case dyn_on_speed_flag:
342         {
343           if (check_float(linetoken3))
344             token3 >> token_value;
345           else
346             uiuc_warnings_errors(1, *command_line);
347           
348           dyn_on_speed = token_value;
349           break;
350         }
351       case dyn_on_speed_zero_flag:
352         {
353           if (check_float(linetoken3))
354             token3 >> token_value;
355           else
356             uiuc_warnings_errors(1, *command_line);
357           
358           dyn_on_speed_zero = token_value;
359           break;
360         }
361       case use_dyn_on_speed_curve1_flag:
362         {
363           use_dyn_on_speed_curve1 = true;
364           break;
365         }
366       case use_Alpha_dot_on_speed_flag:
367         {
368           use_Alpha_dot_on_speed = true;
369           if (check_float(linetoken3))
370             token3 >> token_value;
371           else
372             uiuc_warnings_errors(1, *command_line);
373           Alpha_dot_on_speed = token_value;
374           break;
375         }
376       case use_gamma_horiz_on_speed_flag:
377         {
378           use_gamma_horiz_on_speed = true;
379           if (check_float(linetoken3))
380             token3 >> token_value;
381           else
382             uiuc_warnings_errors(1, *command_line);
383           gamma_horiz_on_speed = token_value;
384           break;
385         }
386       case downwashMode_flag:
387         {
388           b_downwashMode = true;
389           token3 >> downwashMode;
390           if (downwashMode==100)
391             ;
392           // compute downwash using downwashCoef, do nothing here
393           else
394             uiuc_warnings_errors(4, *command_line); 
395           break;
396         }
397       case downwashCoef_flag:
398         {
399           if (check_float(linetoken3))
400             token3 >> token_value;
401           else
402             uiuc_warnings_errors(1, *command_line);
403           downwashCoef = token_value;
404           break;
405         }
406       case Alpha_flag:
407         {
408           if (check_float(linetoken3))
409             token3 >> token_value;
410           else
411             uiuc_warnings_errors(1, *command_line);
412           
413           Alpha_init_true = true;
414           Alpha_init = token_value;
415           break;
416         }
417       case Beta_flag:
418         {
419           if (check_float(linetoken3))
420             token3 >> token_value;
421           else
422             uiuc_warnings_errors(1, *command_line);
423           
424           Beta_init_true = true;
425           Beta_init = token_value;
426           break;
427         }
428       case U_body_flag:
429         {
430           if (check_float(linetoken3))
431             token3 >> token_value;
432           else
433             uiuc_warnings_errors(1, *command_line);
434           
435           U_body_init_true = true;
436           U_body_init = token_value;
437           break;
438         }
439       case V_body_flag:
440         {
441           if (check_float(linetoken3))
442             token3 >> token_value;
443           else
444             uiuc_warnings_errors(1, *command_line);
445           
446           V_body_init_true = true;
447           V_body_init = token_value;
448           break;
449         }
450       case W_body_flag:
451         {
452           if (check_float(linetoken3))
453             token3 >> token_value;
454           else
455             uiuc_warnings_errors(1, *command_line);
456           
457           W_body_init_true = true;
458           W_body_init = token_value;
459           break;
460         }
461       case ignore_unknown_keywords_flag:
462         {
463           ignore_unknown_keywords=true;
464           break;
465         }
466       case trim_case_2_flag:
467         {
468           trim_case_2 = true;
469           break;
470         }
471       case use_uiuc_network_flag:
472         {
473           use_uiuc_network = true;
474           server_IP = linetoken3;
475           token4 >> port_num;
476           break;
477         }
478       case icing_demo_flag:
479         {
480           icing_demo = true;
481           break;
482         }
483       case outside_control_flag:
484         {
485           outside_control = true;
486           break;
487         }
488       default:
489         {
490           if (ignore_unknown_keywords){
491             // do nothing
492           } else {
493             // print error message
494             uiuc_warnings_errors(2, *command_line);
495           }
496           break;
497         }
498       };
499 }