]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_menu_gear.cpp
Units bug.
[flightgear.git] / src / FDM / UIUCModel / uiuc_menu_gear.cpp
1 /**********************************************************************
2                                                                        
3  FILENAME:     uiuc_menu_gear.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_gear.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_gear( 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
112     switch(gear_map[linetoken2])
113       {
114       case Dx_gear_flag:
115         {
116           int index;
117           token3 >> index;
118           if (index < 0 || index >= 16)
119             uiuc_warnings_errors(1, *command_line);
120           if (check_float(linetoken4))
121             token4 >> token_value;
122           else
123             uiuc_warnings_errors(1, *command_line);
124           D_gear_v[index][0] = token_value;
125           gear_model[index] = true;
126           break;
127         }
128       case Dy_gear_flag:
129         {
130           int index;
131           token3 >> index;
132           if (index < 0 || index >= 16)
133             uiuc_warnings_errors(1, *command_line);
134           if (check_float(linetoken4))
135             token4 >> token_value;
136           else
137             uiuc_warnings_errors(1, *command_line);
138           D_gear_v[index][1] = token_value;
139           gear_model[index] = true;
140           break;
141         }
142       case Dz_gear_flag:
143         {
144           int index;
145           token3 >> index;
146           if (index < 0 || index >= 16)
147             uiuc_warnings_errors(1, *command_line);
148           if (check_float(linetoken4))
149             token4 >> token_value;
150           else
151             uiuc_warnings_errors(1, *command_line);
152           D_gear_v[index][2] = token_value;
153           gear_model[index] = true;
154           break;
155         }
156       case cgear_flag:
157         {
158           int index;
159           token3 >> index;
160           if (index < 0 || index >= 16)
161             uiuc_warnings_errors(1, *command_line);
162           if (check_float(linetoken4))
163             token4 >> token_value;
164           else
165             uiuc_warnings_errors(1, *command_line);
166           cgear[index] = token_value;
167           gear_model[index] = true;
168           break;
169         }
170       case kgear_flag:
171         {
172           int index;
173           token3 >> index;
174           if (index < 0 || index >= 16)
175             uiuc_warnings_errors(1, *command_line);
176           if (check_float(linetoken4))
177             token4 >> token_value;
178           else
179             uiuc_warnings_errors(1, *command_line);
180           kgear[index] = token_value;
181           gear_model[index] = true;
182           break;
183         }
184       case muGear_flag:
185         {
186           int index;
187           token3 >> index;
188           if (index < 0 || index >= 16)
189             uiuc_warnings_errors(1, *command_line);
190           if (check_float(linetoken4))
191             token4 >> token_value;
192           else
193             uiuc_warnings_errors(1, *command_line);
194           muGear[index] = token_value;
195           gear_model[index] = true;
196           break;
197         }
198       case strutLength_flag:
199         {
200           int index;
201           token3 >> index;
202           if (index < 0 || index >= 16)
203             uiuc_warnings_errors(1, *command_line);
204           if (check_float(linetoken4))
205             token4 >> token_value;
206           else
207             uiuc_warnings_errors(1, *command_line);
208           strutLength[index] = token_value;
209           gear_model[index] = true;
210           break;
211         }
212       case gear_max_flag:
213         {
214           if (check_float(linetoken3))
215             token3 >> token_value;
216           else
217             uiuc_warnings_errors(1, *command_line);
218           
219           use_gear = true;
220           gear_max = token_value;
221           break;
222         }
223       case gear_rate_flag:
224         {
225           if (check_float(linetoken3))
226             token3 >> token_value;
227           else
228             uiuc_warnings_errors(1, *command_line);
229           
230           use_gear = true;
231           gear_rate = token_value;
232           break;
233         }
234       default:
235         {
236           if (ignore_unknown_keywords) {
237             // do nothing
238           } else {
239             // print error message
240             uiuc_warnings_errors(2, *command_line);
241           }
242           break;
243         }
244       };
245 }