]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_menu_init.cpp
- rename fgcommand "set-mouse" to "set-cursor"
[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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
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_init.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_init( 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     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());
111     int token_value_recordRate;
112
113     switch(init_map[linetoken2])
114       {
115       case Dx_pilot_flag:
116         {
117           if (check_float(linetoken3))
118             token3 >> token_value;
119           else
120             uiuc_warnings_errors(1, *command_line);
121           
122           Dx_pilot = token_value;
123           initParts -> storeCommands (*command_line);
124           break;
125         }
126       case Dy_pilot_flag:
127         {
128           if (check_float(linetoken3))
129             token3 >> token_value;
130           else
131             uiuc_warnings_errors(1, *command_line);
132           
133           Dy_pilot = token_value;
134           initParts -> storeCommands (*command_line);
135           break;
136         }
137       case Dz_pilot_flag:
138         {
139           if (check_float(linetoken3))
140             token3 >> token_value;
141           else
142             uiuc_warnings_errors(1, *command_line);
143           
144           Dz_pilot = token_value;
145           initParts -> storeCommands (*command_line);
146           break;
147         }
148       case Dx_cg_flag:
149         {
150           if (check_float(linetoken3))
151             token3 >> token_value;
152           else
153             uiuc_warnings_errors(1, *command_line);
154           
155           Dx_cg = token_value;
156           initParts -> storeCommands (*command_line);
157           break;
158         }
159       case Dy_cg_flag:
160         {
161           if (check_float(linetoken3))
162             token3 >> token_value;
163           else
164             uiuc_warnings_errors(1, *command_line);
165           
166           Dy_cg = token_value;
167           initParts -> storeCommands (*command_line);
168           break;
169         }
170       case Dz_cg_flag:
171         {
172           if (check_float(linetoken3))
173             token3 >> token_value;
174           else
175             uiuc_warnings_errors(1, *command_line);
176           
177           Dz_cg = token_value;
178           initParts -> storeCommands (*command_line);
179           break;
180         }
181       case Altitude_flag:
182         {
183           if (check_float(linetoken3))
184             token3 >> token_value;
185           else
186             uiuc_warnings_errors(1, *command_line);
187           
188           Altitude = token_value;
189           initParts -> storeCommands (*command_line);
190           break;
191         }
192       case V_north_flag:
193         {
194           if (check_float(linetoken3)) 
195             token3 >> token_value;
196           else
197             uiuc_warnings_errors(1, *command_line);
198           
199           V_north = token_value;
200           initParts -> storeCommands (*command_line);
201           break;
202         }
203       case V_east_flag:
204         {
205           initParts -> storeCommands (*command_line);
206           if (check_float(linetoken3))
207             token3 >> token_value;
208           else
209             uiuc_warnings_errors(1, *command_line);
210           
211           V_east = token_value;
212           break;
213         }
214       case V_down_flag:
215         {
216           if (check_float(linetoken3))
217             token3 >> token_value;
218           else
219             uiuc_warnings_errors(1, *command_line);
220           
221           V_down = token_value;
222           initParts -> storeCommands (*command_line);
223           break;
224         }
225       case P_body_flag:
226         {
227           if (check_float(linetoken3))
228             token3 >> token_value;
229           else
230             uiuc_warnings_errors(1, *command_line);
231           
232           P_body_init_true = true;
233           P_body_init = token_value;
234           initParts -> storeCommands (*command_line);
235           break;
236         }
237       case Q_body_flag:
238         {
239           if (check_float(linetoken3))
240             token3 >> token_value;
241           else
242             uiuc_warnings_errors(1, *command_line);
243           
244           Q_body_init_true = true;
245           Q_body_init = token_value;
246           initParts -> storeCommands (*command_line);
247           break;
248         }
249       case R_body_flag:
250         {
251           if (check_float(linetoken3))
252             token3 >> token_value;
253           else
254             uiuc_warnings_errors(1, *command_line);
255           
256           R_body_init_true = true;
257           R_body_init = token_value;
258           initParts -> storeCommands (*command_line);
259           break;
260         }
261       case Phi_flag:
262         {
263           if (check_float(linetoken3))
264             token3 >> token_value;
265           else
266             uiuc_warnings_errors(1, *command_line);
267           
268           Phi_init_true = true;
269           Phi_init = token_value;
270           initParts -> storeCommands (*command_line);
271           break;
272         }
273       case Theta_flag:
274         {
275           if (check_float(linetoken3))
276             token3 >> token_value;
277           else
278             uiuc_warnings_errors(1, *command_line);
279           
280           Theta_init_true = true;
281           Theta_init = token_value;
282           initParts -> storeCommands (*command_line);
283           break;
284         }
285       case Psi_flag:
286         {
287           if (check_float(linetoken3))
288             token3 >> token_value;
289           else
290             uiuc_warnings_errors(1, *command_line);
291           
292           Psi_init_true = true;
293           Psi_init = token_value;
294           initParts -> storeCommands (*command_line);
295           break;
296         }
297       case Long_trim_flag:
298         {
299           if (check_float(linetoken3))
300             token3 >> token_value;
301           else
302             uiuc_warnings_errors(1, *command_line);
303           
304           Long_trim = token_value;
305           initParts -> storeCommands (*command_line);
306           break;
307         }
308       case recordRate_flag:
309         {
310           //can't use check_float since variable is integer
311           token3 >> token_value_recordRate;
312           recordRate = 120 / token_value_recordRate;
313           break;
314         }
315       case recordStartTime_flag:
316         {
317           if (check_float(linetoken3))
318             token3 >> token_value;
319           else
320             uiuc_warnings_errors(1, *command_line);
321           
322           recordStartTime = token_value;
323           break;
324         }
325       case use_V_rel_wind_2U_flag:
326         {
327           use_V_rel_wind_2U = true;
328           break;
329         }
330       case nondim_rate_V_rel_wind_flag:
331         {
332           nondim_rate_V_rel_wind = true;
333           break;
334         }
335       case use_abs_U_body_2U_flag:
336         {
337           use_abs_U_body_2U = true;
338           break;
339         }
340       case dyn_on_speed_flag:
341         {
342           if (check_float(linetoken3))
343             token3 >> token_value;
344           else
345             uiuc_warnings_errors(1, *command_line);
346           
347           dyn_on_speed = token_value;
348           break;
349         }
350       case dyn_on_speed_zero_flag:
351         {
352           if (check_float(linetoken3))
353             token3 >> token_value;
354           else
355             uiuc_warnings_errors(1, *command_line);
356           
357           dyn_on_speed_zero = token_value;
358           break;
359         }
360       case use_dyn_on_speed_curve1_flag:
361         {
362           use_dyn_on_speed_curve1 = true;
363           break;
364         }
365       case use_Alpha_dot_on_speed_flag:
366         {
367           use_Alpha_dot_on_speed = true;
368           if (check_float(linetoken3))
369             token3 >> token_value;
370           else
371             uiuc_warnings_errors(1, *command_line);
372           Alpha_dot_on_speed = token_value;
373           break;
374         }
375       case use_gamma_horiz_on_speed_flag:
376         {
377           use_gamma_horiz_on_speed = true;
378           if (check_float(linetoken3))
379             token3 >> token_value;
380           else
381             uiuc_warnings_errors(1, *command_line);
382           gamma_horiz_on_speed = token_value;
383           break;
384         }
385       case downwashMode_flag:
386         {
387           b_downwashMode = true;
388           token3 >> downwashMode;
389           if (downwashMode==100)
390             ;
391           // compute downwash using downwashCoef, do nothing here
392           else
393             uiuc_warnings_errors(4, *command_line); 
394           break;
395         }
396       case downwashCoef_flag:
397         {
398           if (check_float(linetoken3))
399             token3 >> token_value;
400           else
401             uiuc_warnings_errors(1, *command_line);
402           downwashCoef = token_value;
403           break;
404         }
405       case Alpha_flag:
406         {
407           if (check_float(linetoken3))
408             token3 >> token_value;
409           else
410             uiuc_warnings_errors(1, *command_line);
411           
412           Alpha_init_true = true;
413           Alpha_init = token_value;
414           break;
415         }
416       case Beta_flag:
417         {
418           if (check_float(linetoken3))
419             token3 >> token_value;
420           else
421             uiuc_warnings_errors(1, *command_line);
422           
423           Beta_init_true = true;
424           Beta_init = token_value;
425           break;
426         }
427       case U_body_flag:
428         {
429           if (check_float(linetoken3))
430             token3 >> token_value;
431           else
432             uiuc_warnings_errors(1, *command_line);
433           
434           U_body_init_true = true;
435           U_body_init = token_value;
436           break;
437         }
438       case V_body_flag:
439         {
440           if (check_float(linetoken3))
441             token3 >> token_value;
442           else
443             uiuc_warnings_errors(1, *command_line);
444           
445           V_body_init_true = true;
446           V_body_init = token_value;
447           break;
448         }
449       case W_body_flag:
450         {
451           if (check_float(linetoken3))
452             token3 >> token_value;
453           else
454             uiuc_warnings_errors(1, *command_line);
455           
456           W_body_init_true = true;
457           W_body_init = token_value;
458           break;
459         }
460       case ignore_unknown_keywords_flag:
461         {
462           ignore_unknown_keywords=true;
463           break;
464         }
465       case trim_case_2_flag:
466         {
467           trim_case_2 = true;
468           break;
469         }
470       case use_uiuc_network_flag:
471         {
472           use_uiuc_network = true;
473           server_IP = linetoken3;
474           token4 >> port_num;
475           break;
476         }
477       case icing_demo_flag:
478         {
479           icing_demo = true;
480           break;
481         }
482       case outside_control_flag:
483         {
484           outside_control = true;
485           break;
486         }
487       default:
488         {
489           if (ignore_unknown_keywords){
490             // do nothing
491           } else {
492             // print error message
493             uiuc_warnings_errors(2, *command_line);
494           }
495           break;
496         }
497       };
498 }