Debian Codegraph @

src/FDM/UIUCModel/uiuc_menu_Cm.cpp

raw symbols SCIP
1 /**********************************************************************
2
3 FILENAME: uiuc_menu_Cm.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_Cm.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_Cm( 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 int token_value_convert1, token_value_convert2, token_value_convert3;
100 int token_value_convert4;
101 double datafile_xArray[100][100], datafile_yArray[100];
102 double datafile_zArray[100][100];
103 double convert_f;
104 int datafile_nxArray[100], datafile_ny;
105 istringstream token3(linetoken3.c_str());
106 istringstream token4(linetoken4.c_str());
107 istringstream token5(linetoken5.c_str());
108 istringstream token6(linetoken6.c_str());
109 istringstream token7(linetoken7.c_str());
110 istringstream token8(linetoken8.c_str());
111 istringstream token9(linetoken9.c_str());
112 istringstream token10(linetoken10.c_str());
113
114 static bool Cmfabetaf_first = true;
115 static bool Cmfadef_first = true;
116 static bool Cmfaqf_first = true;
117
118 switch(Cm_map[linetoken2])
119 {
120 case Cmo_flag:
121 {
122 if (check_float(linetoken3))
123 token3 >> token_value;
124 else
125 uiuc_warnings_errors(1, *command_line);
126
127 Cmo = token_value;
128 Cmo_clean = Cmo;
129 aeroPitchParts -> storeCommands (*command_line);
130 break;
131 }
132 case Cm_a_flag:
133 {
134 if (check_float(linetoken3))
135 token3 >> token_value;
136 else
137 uiuc_warnings_errors(1, *command_line);
138
139 Cm_a = token_value;
140 Cm_a_clean = Cm_a;
141 aeroPitchParts -> storeCommands (*command_line);
142 break;
143 }
144 case Cm_a2_flag:
145 {
146 if (check_float(linetoken3))
147 token3 >> token_value;
148 else
149 uiuc_warnings_errors(1, *command_line);
150
151 Cm_a2 = token_value;
152 Cm_a2_clean = Cm_a2;
153 aeroPitchParts -> storeCommands (*command_line);
154 break;
155 }
156 case Cm_adot_flag:
157 {
158 if (check_float(linetoken3))
159 token3 >> token_value;
160 else
161 uiuc_warnings_errors(1, *command_line);
162
163 Cm_adot = token_value;
164 Cm_adot_clean = Cm_adot;
165 aeroPitchParts -> storeCommands (*command_line);
166 break;
167 }
168 case Cm_q_flag:
169 {
170 if (check_float(linetoken3))
171 token3 >> token_value;
172 else
173 uiuc_warnings_errors(1, *command_line);
174
175 Cm_q = token_value;
176 Cm_q_clean = Cm_q;
177 aeroPitchParts -> storeCommands (*command_line);
178 break;
179 }
180 case Cm_ih_flag:
181 {
182 if (check_float(linetoken3))
183 token3 >> token_value;
184 else
185 uiuc_warnings_errors(1, *command_line);
186
187 Cm_ih = token_value;
188 aeroPitchParts -> storeCommands (*command_line);
189 break;
190 }
191 case Cm_de_flag:
192 {
193 if (check_float(linetoken3))
194 token3 >> token_value;
195 else
196 uiuc_warnings_errors(1, *command_line);
197
198 Cm_de = token_value;
199 Cm_de_clean = Cm_de;
200 aeroPitchParts -> storeCommands (*command_line);
201 break;
202 }
203 case Cm_b2_flag:
204 {
205 if (check_float(linetoken3))
206 token3 >> token_value;
207 else
208 uiuc_warnings_errors(1, *command_line);
209
210 Cm_b2 = token_value;
211 Cm_b2_clean = Cm_b2;
212 aeroPitchParts -> storeCommands (*command_line);
213 break;
214 }
215 case Cm_r_flag:
216 {
217 if (check_float(linetoken3))
218 token3 >> token_value;
219 else
220 uiuc_warnings_errors(1, *command_line);
221
222 Cm_r = token_value;
223 Cm_r_clean = Cm_r;
224 aeroPitchParts -> storeCommands (*command_line);
225 break;
226 }
227 case Cm_df_flag:
228 {
229 if (check_float(linetoken3))
230 token3 >> token_value;
231 else
232 uiuc_warnings_errors(1, *command_line);
233
234 Cm_df = token_value;
235 Cm_df_clean = Cm_df;
236 aeroPitchParts -> storeCommands (*command_line);
237 break;
238 }
239 case Cm_ds_flag:
240 {
241 if (check_float(linetoken3))
242 token3 >> token_value;
243 else
244 uiuc_warnings_errors(1, *command_line);
245
246 Cm_ds = token_value;
247 aeroPitchParts -> storeCommands (*command_line);
248 break;
249 }
250 case Cm_dg_flag:
251 {
252 if (check_float(linetoken3))
253 token3 >> token_value;
254 else
255 uiuc_warnings_errors(1, *command_line);
256
257 Cm_dg = token_value;
258 aeroPitchParts -> storeCommands (*command_line);
259 break;
260 }
261 case Cmfa_flag:
262 {
263 Cmfa = aircraft_directory + linetoken3;
264 token4 >> token_value_convert1;
265 token5 >> token_value_convert2;
266 convert_y = uiuc_convert(token_value_convert1);
267 convert_x = uiuc_convert(token_value_convert2);
268 /* call 1D File Reader with file name (Cmfa) and conversion
269 factors; function returns array of alphas (aArray) and
270 corresponding Cm values (CmArray) and max number of
271 terms in arrays (nAlpha) */
272 uiuc_1DdataFileReader(Cmfa,
273 Cmfa_aArray,
274 Cmfa_CmArray,
275 Cmfa_nAlpha);
276 aeroPitchParts -> storeCommands (*command_line);
277 break;
278 }
279 case Cmfade_flag:
280 {
281 Cmfade = aircraft_directory + linetoken3;
282 token4 >> token_value_convert1;
283 token5 >> token_value_convert2;
284 token6 >> token_value_convert3;
285 convert_z = uiuc_convert(token_value_convert1);
286 convert_x = uiuc_convert(token_value_convert2);
287 convert_y = uiuc_convert(token_value_convert3);
288 /* call 2D File Reader with file name (Cmfade) and
289 conversion factors; function returns array of
290 elevator deflections (deArray) and corresponding
291 alpha (aArray) and delta Cm (CmArray) values and
292 max number of terms in alpha arrays (nAlphaArray)
293 and deflection array (nde) */
294 uiuc_2DdataFileReader(Cmfade,
295 Cmfade_aArray,
296 Cmfade_deArray,
297 Cmfade_CmArray,
298 Cmfade_nAlphaArray,
299 Cmfade_nde);
300 aeroPitchParts -> storeCommands (*command_line);
301 break;
302 }
303 case Cmfdf_flag:
304 {
305 Cmfdf = aircraft_directory + linetoken3;
306 token4 >> token_value_convert1;
307 token5 >> token_value_convert2;
308 convert_y = uiuc_convert(token_value_convert1);
309 convert_x = uiuc_convert(token_value_convert2);
310 /* call 1D File Reader with file name (Cmfdf) and conversion
311 factors; function returns array of dfs (dfArray) and
312 corresponding Cm values (CmArray) and max number of
313 terms in arrays (ndf) */
314 uiuc_1DdataFileReader(Cmfdf,
315 Cmfdf_dfArray,
316 Cmfdf_CmArray,
317 Cmfdf_ndf);
318 aeroPitchParts -> storeCommands (*command_line);
319 break;
320 }
321 case Cmfadf_flag:
322 {
323 Cmfadf = aircraft_directory + linetoken3;
324 token4 >> token_value_convert1;
325 token5 >> token_value_convert2;
326 token6 >> token_value_convert3;
327 convert_z = uiuc_convert(token_value_convert1);
328 convert_x = uiuc_convert(token_value_convert2);
329 convert_y = uiuc_convert(token_value_convert3);
330 /* call 2D File Reader with file name (Cmfadf) and
331 conversion factors; function returns array of
332 flap deflections (dfArray) and corresponding
333 alpha (aArray) and delta Cm (CmArray) values and
334 max number of terms in alpha arrays (nAlphaArray)
335 and deflection array (ndf) */
336 uiuc_2DdataFileReader(Cmfadf,
337 Cmfadf_aArray,
338 Cmfadf_dfArray,
339 Cmfadf_CmArray,
340 Cmfadf_nAlphaArray,
341 Cmfadf_ndf);
342 aeroPitchParts -> storeCommands (*command_line);
343 break;
344 }
345 case Cmfabetaf_flag:
346 {
347 int Cmfabetaf_index, i;
348 string Cmfabetaf_file;
349 double flap_value;
350 Cmfabetaf_file = aircraft_directory + linetoken3;
351 token4 >> Cmfabetaf_index;
352 if (Cmfabetaf_index < 0 || Cmfabetaf_index >= 30)
353 uiuc_warnings_errors(1, *command_line);
354 if (Cmfabetaf_index > Cmfabetaf_nf)
355 Cmfabetaf_nf = Cmfabetaf_index;
356 token5 >> flap_value;
357 token6 >> token_value_convert1;
358 token7 >> token_value_convert2;
359 token8 >> token_value_convert3;
360 token9 >> token_value_convert4;
361 token10 >> Cmfabetaf_nice;
362 convert_z = uiuc_convert(token_value_convert1);
363 convert_x = uiuc_convert(token_value_convert2);
364 convert_y = uiuc_convert(token_value_convert3);
365 convert_f = uiuc_convert(token_value_convert4);
366 Cmfabetaf_fArray[Cmfabetaf_index] = flap_value * convert_f;
367 /* call 2D File Reader with file name (Cmfabetaf_file) and
368 conversion factors; function returns array of
369 elevator deflections (deArray) and corresponding
370 alpha (aArray) and delta CZ (CZArray) values and
371 max number of terms in alpha arrays (nAlphaArray)
372 and delfection array (nde) */
373 uiuc_2DdataFileReader(Cmfabetaf_file,
374 datafile_xArray,
375 datafile_yArray,
376 datafile_zArray,
377 datafile_nxArray,
378 datafile_ny);
379 d_2_to_3(datafile_xArray, Cmfabetaf_aArray, Cmfabetaf_index);
380 d_1_to_2(datafile_yArray, Cmfabetaf_betaArray, Cmfabetaf_index);
381 d_2_to_3(datafile_zArray, Cmfabetaf_CmArray, Cmfabetaf_index);
382 i_1_to_2(datafile_nxArray, Cmfabetaf_nAlphaArray, Cmfabetaf_index);
383 Cmfabetaf_nbeta[Cmfabetaf_index] = datafile_ny;
384 if (Cmfabetaf_first==true)
385 {
386 if (Cmfabetaf_nice == 1)
387 {
388 Cmfabetaf_na_nice = datafile_nxArray[1];
389 Cmfabetaf_nb_nice = datafile_ny;
390 d_1_to_1(datafile_yArray, Cmfabetaf_bArray_nice);
391 for (i=1; i<=Cmfabetaf_na_nice; i++)
392 Cmfabetaf_aArray_nice[i] = datafile_xArray[1][i];
393 }
394 aeroPitchParts -> storeCommands (*command_line);
395 Cmfabetaf_first=false;
396 }
397 break;
398 }
399 case Cmfadef_flag:
400 {
401 int Cmfadef_index, i;
402 string Cmfadef_file;
403 double flap_value;
404 Cmfadef_file = aircraft_directory + linetoken3;
405 token4 >> Cmfadef_index;
406 if (Cmfadef_index < 0 || Cmfadef_index >= 30)
407 uiuc_warnings_errors(1, *command_line);
408 if (Cmfadef_index > Cmfadef_nf)
409 Cmfadef_nf = Cmfadef_index;
410 token5 >> flap_value;
411 token6 >> token_value_convert1;
412 token7 >> token_value_convert2;
413 token8 >> token_value_convert3;
414 token9 >> token_value_convert4;
415 token10 >> Cmfadef_nice;
416 convert_z = uiuc_convert(token_value_convert1);
417 convert_x = uiuc_convert(token_value_convert2);
418 convert_y = uiuc_convert(token_value_convert3);
419 convert_f = uiuc_convert(token_value_convert4);
420 Cmfadef_fArray[Cmfadef_index] = flap_value * convert_f;
421 /* call 2D File Reader with file name (Cmfadef_file) and
422 conversion factors; function returns array of
423 elevator deflections (deArray) and corresponding
424 alpha (aArray) and delta CZ (CZArray) values and
425 max number of terms in alpha arrays (nAlphaArray)
426 and delfection array (nde) */
427 uiuc_2DdataFileReader(Cmfadef_file,
428 datafile_xArray,
429 datafile_yArray,
430 datafile_zArray,
431 datafile_nxArray,
432 datafile_ny);
433 d_2_to_3(datafile_xArray, Cmfadef_aArray, Cmfadef_index);
434 d_1_to_2(datafile_yArray, Cmfadef_deArray, Cmfadef_index);
435 d_2_to_3(datafile_zArray, Cmfadef_CmArray, Cmfadef_index);
436 i_1_to_2(datafile_nxArray, Cmfadef_nAlphaArray, Cmfadef_index);
437 Cmfadef_nde[Cmfadef_index] = datafile_ny;
438 if (Cmfadef_first==true)
439 {
440 if (Cmfadef_nice == 1)
441 {
442 Cmfadef_na_nice = datafile_nxArray[1];
443 Cmfadef_nde_nice = datafile_ny;
444 d_1_to_1(datafile_yArray, Cmfadef_deArray_nice);
445 for (i=1; i<=Cmfadef_na_nice; i++)
446 Cmfadef_aArray_nice[i] = datafile_xArray[1][i];
447 }
448 aeroPitchParts -> storeCommands (*command_line);
449 Cmfadef_first=false;
450 }
451 break;
452 }
453 case Cmfaqf_flag:
454 {
455 int Cmfaqf_index, i;
456 string Cmfaqf_file;
457 double flap_value;
458 Cmfaqf_file = aircraft_directory + linetoken3;
459 token4 >> Cmfaqf_index;
460 if (Cmfaqf_index < 0 || Cmfaqf_index >= 30)
461 uiuc_warnings_errors(1, *command_line);
462 if (Cmfaqf_index > Cmfaqf_nf)
463 Cmfaqf_nf = Cmfaqf_index;
464 token5 >> flap_value;
465 token6 >> token_value_convert1;
466 token7 >> token_value_convert2;
467 token8 >> token_value_convert3;
468 token9 >> token_value_convert4;
469 token10 >> Cmfaqf_nice;
470 convert_z = uiuc_convert(token_value_convert1);
471 convert_x = uiuc_convert(token_value_convert2);
472 convert_y = uiuc_convert(token_value_convert3);
473 convert_f = uiuc_convert(token_value_convert4);
474 Cmfaqf_fArray[Cmfaqf_index] = flap_value * convert_f;
475 /* call 2D File Reader with file name (Cmfaqf_file) and
476 conversion factors; function returns array of
477 elevator deflections (deArray) and corresponding
478 alpha (aArray) and delta CZ (CZArray) values and
479 max number of terms in alpha arrays (nAlphaArray)
480 and delfection array (nde) */
481 uiuc_2DdataFileReader(Cmfaqf_file,
482 datafile_xArray,
483 datafile_yArray,
484 datafile_zArray,
485 datafile_nxArray,
486 datafile_ny);
487 d_2_to_3(datafile_xArray, Cmfaqf_aArray, Cmfaqf_index);
488 d_1_to_2(datafile_yArray, Cmfaqf_qArray, Cmfaqf_index);
489 d_2_to_3(datafile_zArray, Cmfaqf_CmArray, Cmfaqf_index);
490 i_1_to_2(datafile_nxArray, Cmfaqf_nAlphaArray, Cmfaqf_index);
491 Cmfaqf_nq[Cmfaqf_index] = datafile_ny;
492 if (Cmfaqf_first==true)
493 {
494 if (Cmfaqf_nice == 1)
495 {
496 Cmfaqf_na_nice = datafile_nxArray[1];
497 Cmfaqf_nq_nice = datafile_ny;
498 d_1_to_1(datafile_yArray, Cmfaqf_qArray_nice);
499 for (i=1; i<=Cmfaqf_na_nice; i++)
500 Cmfaqf_aArray_nice[i] = datafile_xArray[1][i];
501 }
502 aeroPitchParts -> storeCommands (*command_line);
503 Cmfaqf_first=false;
504 }
505 break;
506 }
507 default:
508 {
509 if (ignore_unknown_keywords) {
510 // do nothing
511 } else {
512 // print error message
513 uiuc_warnings_errors(2, *command_line);
514 }
515 break;
516 }
517 };
518 }