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