1 /**********************************************************************
3 FILENAME: uiuc_menu_controlSurface.cpp
5 ----------------------------------------------------------------------
7 DESCRIPTION: reads input data for specified aircraft and creates
8 approporiate data storage space
10 ----------------------------------------------------------------------
14 ----------------------------------------------------------------------
16 REFERENCES: based on "menu reader" format of Michael Selig
18 ----------------------------------------------------------------------
20 HISTORY: 04/04/2003 initial release
22 ----------------------------------------------------------------------
24 AUTHOR(S): Robert Deters <rdeters@uiuc.edu>
25 Michael Selig <m-selig@uiuc.edu>
27 ----------------------------------------------------------------------
31 ----------------------------------------------------------------------
35 ----------------------------------------------------------------------
39 ----------------------------------------------------------------------
41 CALLED BY: uiuc_menu()
43 ----------------------------------------------------------------------
45 CALLS TO: check_float() if needed
51 ----------------------------------------------------------------------
53 COPYRIGHT: (C) 2003 by Michael Selig
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.
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.
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.
69 **********************************************************************/
71 #include <simgear/compiler.h>
73 #if defined( __MWERKS__ )
74 // -dw- optimizer chokes (big-time) trying to optimize humongous
75 // loop/switch statements
76 #pragma optimization_level 0
83 #include "uiuc_menu_controlSurface.h"
93 void parse_controlSurface( 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,
98 const string& aircraft_directory,
101 int token_value_convert1, token_value_convert2;
102 istrstream token3(linetoken3.c_str());
103 istrstream token4(linetoken4.c_str());
104 istrstream token5(linetoken5.c_str());
105 istrstream token6(linetoken6.c_str());
106 istrstream token7(linetoken7.c_str());
107 istrstream token8(linetoken8.c_str());
108 istrstream token9(linetoken9.c_str());
109 istrstream token10(linetoken10.c_str());
111 switch(controlSurface_map[linetoken2])
115 if (check_float(linetoken3))
116 token3 >> token_value;
118 uiuc_warnings_errors(1, *command_line);
122 if (check_float(linetoken4))
123 token4 >> token_value;
125 uiuc_warnings_errors(1, *command_line);
132 if (check_float(linetoken3))
133 token3 >> token_value;
135 uiuc_warnings_errors(1, *command_line);
139 if (check_float(linetoken4))
140 token4 >> token_value;
142 uiuc_warnings_errors(1, *command_line);
149 if (check_float(linetoken3))
150 token3 >> token_value;
152 uiuc_warnings_errors(1, *command_line);
156 if (check_float(linetoken4))
157 token4 >> token_value;
159 uiuc_warnings_errors(1, *command_line);
164 case set_Long_trim_flag:
166 if (check_float(linetoken3))
167 token3 >> token_value;
169 uiuc_warnings_errors(1, *command_line);
171 set_Long_trim = true;
172 elevator_tab = token_value;
175 case set_Long_trim_deg_flag:
177 if (check_float(linetoken3))
178 token3 >> token_value;
180 uiuc_warnings_errors(1, *command_line);
182 set_Long_trim = true;
183 elevator_tab = token_value * DEG_TO_RAD;
186 case zero_Long_trim_flag:
188 zero_Long_trim = true;
191 case elevator_step_flag:
193 // set step input flag
194 elevator_step = true;
196 // read in step angle in degrees and convert
197 if (check_float(linetoken3))
198 token3 >> token_value;
200 uiuc_warnings_errors(1, *command_line);
202 elevator_step_angle = token_value * DEG_TO_RAD;
204 // read in step start time
205 if (check_float(linetoken4))
206 token4 >> token_value;
208 uiuc_warnings_errors(1, *command_line);
210 elevator_step_startTime = token_value;
213 case elevator_singlet_flag:
215 // set singlet input flag
216 elevator_singlet = true;
218 // read in singlet angle in degrees and convert
219 if (check_float(linetoken3))
220 token3 >> token_value;
222 uiuc_warnings_errors(1, *command_line);
224 elevator_singlet_angle = token_value * DEG_TO_RAD;
226 // read in singlet start time
227 if (check_float(linetoken4))
228 token4 >> token_value;
230 uiuc_warnings_errors(1, *command_line);
232 elevator_singlet_startTime = token_value;
234 // read in singlet duration
235 if (check_float(linetoken5))
236 token5 >> token_value;
238 uiuc_warnings_errors(1, *command_line);
240 elevator_singlet_duration = token_value;
243 case elevator_doublet_flag:
245 // set doublet input flag
246 elevator_doublet = true;
248 // read in doublet angle in degrees and convert
249 if (check_float(linetoken3))
250 token3 >> token_value;
252 uiuc_warnings_errors(1, *command_line);
254 elevator_doublet_angle = token_value * DEG_TO_RAD;
256 // read in doublet start time
257 if (check_float(linetoken4))
258 token4 >> token_value;
260 uiuc_warnings_errors(1, *command_line);
262 elevator_doublet_startTime = token_value;
264 // read in doublet duration
265 if (check_float(linetoken5))
266 token5 >> token_value;
268 uiuc_warnings_errors(1, *command_line);
270 elevator_doublet_duration = token_value;
273 case elevator_input_flag:
275 elevator_input = true;
276 elevator_input_file = aircraft_directory + linetoken3;
277 token4 >> token_value_convert1;
278 token5 >> token_value_convert2;
279 convert_y = uiuc_convert(token_value_convert1);
280 convert_x = uiuc_convert(token_value_convert2);
281 uiuc_1DdataFileReader(elevator_input_file,
282 elevator_input_timeArray,
283 elevator_input_deArray,
284 elevator_input_ntime);
285 token6 >> token_value;
286 elevator_input_startTime = token_value;
289 case aileron_input_flag:
291 aileron_input = true;
292 aileron_input_file = aircraft_directory + linetoken3;
293 token4 >> token_value_convert1;
294 token5 >> token_value_convert2;
295 convert_y = uiuc_convert(token_value_convert1);
296 convert_x = uiuc_convert(token_value_convert2);
297 uiuc_1DdataFileReader(aileron_input_file,
298 aileron_input_timeArray,
299 aileron_input_daArray,
300 aileron_input_ntime);
301 token6 >> token_value;
302 aileron_input_startTime = token_value;
305 case rudder_input_flag:
308 rudder_input_file = aircraft_directory + linetoken3;
309 token4 >> token_value_convert1;
310 token5 >> token_value_convert2;
311 convert_y = uiuc_convert(token_value_convert1);
312 convert_x = uiuc_convert(token_value_convert2);
313 uiuc_1DdataFileReader(rudder_input_file,
314 rudder_input_timeArray,
315 rudder_input_drArray,
317 token6 >> token_value;
318 rudder_input_startTime = token_value;
321 case flap_pos_input_flag:
323 flap_pos_input = true;
324 flap_pos_input_file = aircraft_directory + linetoken3;
325 token4 >> token_value_convert1;
326 token5 >> token_value_convert2;
327 convert_y = uiuc_convert(token_value_convert1);
328 convert_x = uiuc_convert(token_value_convert2);
329 uiuc_1DdataFileReader(flap_pos_input_file,
330 flap_pos_input_timeArray,
331 flap_pos_input_dfArray,
332 flap_pos_input_ntime);
333 token6 >> token_value;
334 flap_pos_input_startTime = token_value;
337 case pilot_elev_no_flag:
339 pilot_elev_no_check = true;
342 case pilot_ail_no_flag:
344 pilot_ail_no_check = true;
347 case pilot_rud_no_flag:
349 pilot_rud_no_check = true;
354 if (check_float(linetoken3))
355 token3 >> token_value;
357 uiuc_warnings_errors(1, *command_line);
360 flap_max = token_value;
365 if (check_float(linetoken3))
366 token3 >> token_value;
368 uiuc_warnings_errors(1, *command_line);
371 flap_rate = token_value;
374 case spoiler_max_flag:
376 if (check_float(linetoken3))
377 token3 >> token_value;
379 uiuc_warnings_errors(1, *command_line);
382 spoiler_max = token_value;
385 case spoiler_rate_flag:
387 if (check_float(linetoken3))
388 token3 >> token_value;
390 uiuc_warnings_errors(1, *command_line);
393 spoiler_rate = token_value;
396 case aileron_sas_KP_flag:
398 if (check_float(linetoken3))
399 token3 >> token_value;
401 uiuc_warnings_errors(1, *command_line);
403 aileron_sas_KP = token_value;
406 case aileron_sas_max_flag:
408 if (check_float(linetoken3))
409 token3 >> token_value;
411 uiuc_warnings_errors(1, *command_line);
412 aileron_sas_max = token_value;
413 use_aileron_sas_max = true;
416 case aileron_stick_gain_flag:
418 if (check_float(linetoken3))
419 token3 >> token_value;
421 uiuc_warnings_errors(1, *command_line);
422 aileron_stick_gain = token_value;
423 use_aileron_stick_gain = true;
426 case elevator_sas_KQ_flag:
428 if (check_float(linetoken3))
429 token3 >> token_value;
431 uiuc_warnings_errors(1, *command_line);
432 elevator_sas_KQ = token_value;
435 case elevator_sas_max_flag:
437 if (check_float(linetoken3))
438 token3 >> token_value;
440 uiuc_warnings_errors(1, *command_line);
441 elevator_sas_max = token_value;
442 use_elevator_sas_max = true;
445 case elevator_sas_min_flag:
447 if (check_float(linetoken3))
448 token3 >> token_value;
450 uiuc_warnings_errors(1, *command_line);
451 elevator_sas_min = token_value;
452 use_elevator_sas_min = true;
455 case elevator_stick_gain_flag:
457 if (check_float(linetoken3))
458 token3 >> token_value;
460 uiuc_warnings_errors(1, *command_line);
461 elevator_stick_gain = token_value;
462 use_elevator_stick_gain = true;
465 case rudder_sas_KR_flag:
467 if (check_float(linetoken3))
468 token3 >> token_value;
470 uiuc_warnings_errors(1, *command_line);
471 rudder_sas_KR = token_value;
474 case rudder_sas_max_flag:
476 if (check_float(linetoken3))
477 token3 >> token_value;
479 uiuc_warnings_errors(1, *command_line);
480 rudder_sas_max = token_value;
481 use_rudder_sas_max = true;
484 case rudder_stick_gain_flag:
486 if (check_float(linetoken3))
487 token3 >> token_value;
489 uiuc_warnings_errors(1, *command_line);
490 rudder_stick_gain = token_value;
491 use_rudder_stick_gain = true;
494 case use_aileron_sas_type1_flag:
496 use_aileron_sas_type1 = true;
499 case use_elevator_sas_type1_flag:
501 use_elevator_sas_type1 = true;
504 case use_rudder_sas_type1_flag:
506 use_rudder_sas_type1 = true;
511 if (ignore_unknown_keywords) {
514 // print error message
515 uiuc_warnings_errors(2, *command_line);