Debian Codegraph @

src/FDM/UIUCModel/uiuc_menu_gear.cpp

raw symbols SCIP
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 <[email protected]>
28 Michael Selig <[email protected]>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
70
71 **********************************************************************/
72
73 #include <simgear/compiler.h>
74
75
76 #include <cstdlib>
77 #include <string>
78 #include <iostream>
79
80 #include "uiuc_menu_gear.h"
81
82 using std::string;
83 using std::istringstream;
84 using std::cerr;
85 using std::cout;
86 using std::endl;
87
88 #ifndef _MSC_VER
89 using std::exit;
90 #endif
91
92 void parse_gear( const string& linetoken2, const string& linetoken3,
93 const string& linetoken4, const string& linetoken5,
94 const string& linetoken6, const string& linetoken7,
95 const string& linetoken8, const string& linetoken9,
96 const string& linetoken10, const string& aircraft_directory,
97 LIST command_line ) {
98 double token_value;
99 istringstream token3(linetoken3.c_str());
100 istringstream token4(linetoken4.c_str());
101 istringstream token5(linetoken5.c_str());
102 istringstream token6(linetoken6.c_str());
103 istringstream token7(linetoken7.c_str());
104 istringstream token8(linetoken8.c_str());
105 istringstream token9(linetoken9.c_str());
106 istringstream token10(linetoken10.c_str());
107
108 switch(gear_map[linetoken2])
109 {
110 case Dx_gear_flag:
111 {
112 int index;
113 token3 >> index;
114 if (index < 0 || index >= 16)
115 uiuc_warnings_errors(1, *command_line);
116 if (check_float(linetoken4))
117 token4 >> token_value;
118 else
119 uiuc_warnings_errors(1, *command_line);
120 D_gear_v[index][0] = token_value;
121 gear_model[index] = true;
122 break;
123 }
124 case Dy_gear_flag:
125 {
126 int index;
127 token3 >> index;
128 if (index < 0 || index >= 16)
129 uiuc_warnings_errors(1, *command_line);
130 if (check_float(linetoken4))
131 token4 >> token_value;
132 else
133 uiuc_warnings_errors(1, *command_line);
134 D_gear_v[index][1] = token_value;
135 gear_model[index] = true;
136 break;
137 }
138 case Dz_gear_flag:
139 {
140 int index;
141 token3 >> index;
142 if (index < 0 || index >= 16)
143 uiuc_warnings_errors(1, *command_line);
144 if (check_float(linetoken4))
145 token4 >> token_value;
146 else
147 uiuc_warnings_errors(1, *command_line);
148 D_gear_v[index][2] = token_value;
149 gear_model[index] = true;
150 break;
151 }
152 case cgear_flag:
153 {
154 int index;
155 token3 >> index;
156 if (index < 0 || index >= 16)
157 uiuc_warnings_errors(1, *command_line);
158 if (check_float(linetoken4))
159 token4 >> token_value;
160 else
161 uiuc_warnings_errors(1, *command_line);
162 cgear[index] = token_value;
163 gear_model[index] = true;
164 break;
165 }
166 case kgear_flag:
167 {
168 int index;
169 token3 >> index;
170 if (index < 0 || index >= 16)
171 uiuc_warnings_errors(1, *command_line);
172 if (check_float(linetoken4))
173 token4 >> token_value;
174 else
175 uiuc_warnings_errors(1, *command_line);
176 kgear[index] = token_value;
177 gear_model[index] = true;
178 break;
179 }
180 case muGear_flag:
181 {
182 int index;
183 token3 >> index;
184 if (index < 0 || index >= 16)
185 uiuc_warnings_errors(1, *command_line);
186 if (check_float(linetoken4))
187 token4 >> token_value;
188 else
189 uiuc_warnings_errors(1, *command_line);
190 muGear[index] = token_value;
191 gear_model[index] = true;
192 break;
193 }
194 case strutLength_flag:
195 {
196 int index;
197 token3 >> index;
198 if (index < 0 || index >= 16)
199 uiuc_warnings_errors(1, *command_line);
200 if (check_float(linetoken4))
201 token4 >> token_value;
202 else
203 uiuc_warnings_errors(1, *command_line);
204 strutLength[index] = token_value;
205 gear_model[index] = true;
206 break;
207 }
208 case gear_max_flag:
209 {
210 if (check_float(linetoken3))
211 token3 >> token_value;
212 else
213 uiuc_warnings_errors(1, *command_line);
214
215 use_gear = true;
216 gear_max = token_value;
217 break;
218 }
219 case gear_rate_flag:
220 {
221 if (check_float(linetoken3))
222 token3 >> token_value;
223 else
224 uiuc_warnings_errors(1, *command_line);
225
226 use_gear = true;
227 gear_rate = token_value;
228 break;
229 }
230 default:
231 {
232 if (ignore_unknown_keywords) {
233 // do nothing
234 } else {
235 // print error message
236 uiuc_warnings_errors(2, *command_line);
237 }
238 break;
239 }
240 };
241 }