]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAircraft.cpp
Oct. 10, 2000 sync with JSBSim master repository.
[flightgear.git] / src / FDM / JSBSim / FGAircraft.cpp
1 /*******************************************************************************
2  
3  Module:       FGAircraft.cpp
4  Author:       Jon S. Berndt
5  Date started: 12/12/98                                   
6  Purpose:      Encapsulates an aircraft
7  Called by:    FGFDMExec
8  
9  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
10  
11  This program is free software; you can redistribute it and/or modify it under
12  the terms of the GNU General Public License as published by the Free Software
13  Foundation; either version 2 of the License, or (at your option) any later
14  version.
15  
16  This program is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
19  details.
20  
21  You should have received a copy of the GNU General Public License along with
22  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23  Place - Suite 330, Boston, MA  02111-1307, USA.
24  
25  Further information about the GNU General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27  
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 Models the aircraft reactions and forces. This class is instantiated by the
31 FGFDMExec class and scheduled as an FDM entry. LoadAircraft() is supplied with a
32 name of a valid, registered aircraft, and the data file is parsed.
33  
34 HISTORY
35 --------------------------------------------------------------------------------
36 12/12/98   JSB   Created
37 04/03/99   JSB   Changed Aero() method to correct body axis force calculation
38                  from wind vector. Fix provided by Tony Peden.
39 05/03/99   JSB   Changed (for the better?) the way configurations are read in.
40 9/17/99     TP   Combined force and moment functions. Added aero reference 
41                  point to config file. Added calculations for moments due to 
42                  difference in cg and aero reference point
43  
44 ********************************************************************************
45 COMMENTS, REFERENCES,  and NOTES
46 ********************************************************************************
47 [1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
48       Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
49       School, January 1994
50 [2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
51       JSC 12960, July 1977
52 [3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
53       NASA-Ames", NASA CR-2497, January 1975
54 [4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
55       Wiley & Sons, 1979 ISBN 0-471-03032-5
56 [5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
57       1982 ISBN 0-471-08936-2
58  
59 The aerodynamic coefficients used in this model are:
60  
61 Longitudinal
62   CL0 - Reference lift at zero alpha
63   CD0 - Reference drag at zero alpha
64   CDM - Drag due to Mach
65   CLa - Lift curve slope (w.r.t. alpha)
66   CDa - Drag curve slope (w.r.t. alpha)
67   CLq - Lift due to pitch rate
68   CLM - Lift due to Mach
69   CLadt - Lift due to alpha rate
70  
71   Cmadt - Pitching Moment due to alpha rate
72   Cm0 - Reference Pitching moment at zero alpha
73   Cma - Pitching moment slope (w.r.t. alpha)
74   Cmq - Pitch damping (pitch moment due to pitch rate)
75   CmM - Pitch Moment due to Mach
76  
77 Lateral
78   Cyb - Side force due to sideslip
79   Cyr - Side force due to yaw rate
80  
81   Clb - Dihedral effect (roll moment due to sideslip)
82   Clp - Roll damping (roll moment due to roll rate)
83   Clr - Roll moment due to yaw rate
84   Cnb - Weathercocking stability (yaw moment due to sideslip)
85   Cnp - Rudder adverse yaw (yaw moment due to roll rate)
86   Cnr - Yaw damping (yaw moment due to yaw rate)
87  
88 Control
89   CLDe - Lift due to elevator
90   CDDe - Drag due to elevator
91   CyDr - Side force due to rudder
92   CyDa - Side force due to aileron
93  
94   CmDe - Pitch moment due to elevator
95   ClDa - Roll moment due to aileron
96   ClDr - Roll moment due to rudder
97   CnDr - Yaw moment due to rudder
98   CnDa - Yaw moment due to aileron
99  
100 ********************************************************************************
101 INCLUDES
102 *******************************************************************************/
103
104 #include <sys/stat.h>
105 #include <sys/types.h>
106
107 #ifdef FGFS
108 #  ifndef __BORLANDC__
109 #    include <simgear/compiler.h>
110 #  endif
111 #  ifdef FG_HAVE_STD_INCLUDES
112 #    include <cmath>
113 #  else
114 #    include <math.h>
115 #  endif
116 #else
117 #  include <cmath>
118 #endif
119
120 #include "FGAircraft.h"
121 #include "FGTranslation.h"
122 #include "FGRotation.h"
123 #include "FGAtmosphere.h"
124 #include "FGState.h"
125 #include "FGFDMExec.h"
126 #include "FGFCS.h"
127 #include "FGPosition.h"
128 #include "FGAuxiliary.h"
129 #include "FGOutput.h"
130
131 /*******************************************************************************
132 ************************************ CODE **************************************
133 *******************************************************************************/
134
135 FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex),
136     vMoments(3),
137     vForces(3),
138     vFs(3),
139     vXYZrp(3),
140     vbaseXYZcg(3),
141     vXYZcg(3),
142     vXYZep(3),
143     vEuler(3)
144     
145 {
146   Name = "FGAircraft";
147
148   AxisIdx["DRAG"]  = 0;
149   AxisIdx["SIDE"]  = 1;
150   AxisIdx["LIFT"]  = 2;
151   AxisIdx["ROLL"]  = 3;
152   AxisIdx["PITCH"] = 4;
153   AxisIdx["YAW"]   = 5;
154   
155   Coeff = new CoeffArray[6];
156
157   GearUp = false;
158   
159   alphaclmin = alphaclmax = 0;
160
161   numTanks = numEngines = numSelectedFuelTanks = numSelectedOxiTanks = 0;
162 }
163
164
165 /******************************************************************************/
166
167
168 FGAircraft::~FGAircraft(void) { 
169   unsigned int i,j;
170
171   if (Engine != NULL) {
172     for (i=0; i<numEngines; i++)
173       delete Engine[i];
174   }    
175   if (Tank != NULL) {
176     for (i=0; i<numTanks; i++)
177       delete Tank[i];
178   }    
179   for (i=0; i<6; i++) {
180     for (j=0; j<Coeff[i].size(); j++) {
181       delete Coeff[i][j];
182     }
183   }
184   delete[] Coeff;
185 }
186
187 /******************************************************************************/
188
189 bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string fname) {
190   string path;
191   string filename;
192   string aircraftCfgFileName;
193   string token;
194
195   AircraftPath = aircraft_path;
196   EnginePath = engine_path;
197
198 # ifndef macintosh
199   aircraftCfgFileName = AircraftPath + "/" + fname + "/" + fname + ".xml";
200 # else  
201   aircraftCfgFileName = AircraftPath + ";" + fname + ";" + fname + ".xml";
202 # endif
203
204   FGConfigFile AC_cfg(aircraftCfgFileName);
205   if (!AC_cfg.IsOpen()) return false;
206
207   ReadPrologue(&AC_cfg);
208
209   while ((AC_cfg.GetNextConfigLine() != "EOF") &&
210          (token = AC_cfg.GetValue()) != "/FDM_CONFIG") {
211     if (token == "METRICS") {
212       cout << "  Reading Metrics" << endl;
213       ReadMetrics(&AC_cfg);
214     } else if (token == "AERODYNAMICS") {
215       cout << "  Reading Aerodynamics" << endl;
216       ReadAerodynamics(&AC_cfg);
217     } else if (token == "UNDERCARRIAGE") {
218       cout << "  Reading Landing Gear" << endl;
219       ReadUndercarriage(&AC_cfg);
220     } else if (token == "PROPULSION") {
221       cout << "  Reading Propulsion" << endl;
222       ReadPropulsion(&AC_cfg);
223     } else if (token == "FLIGHT_CONTROL") {
224       cout << "  Reading Flight Control" << endl;
225       ReadFlightControls(&AC_cfg);
226     } else if (token == "OUTPUT") {
227       ReadOutput(&AC_cfg);
228     }
229   }
230
231   return true;
232 }
233
234 /******************************************************************************/
235
236 bool FGAircraft::Run(void) {
237   if (!FGModel::Run()) {                 // if false then execute this Run()
238     GetState();
239
240     for (int i = 1; i <= 3; i++)  vForces(i) = vMoments(i) = 0.0;
241
242     MassChange();
243     FMProp();
244     FMAero();
245     FMGear();
246     FMMass();
247
248     nlf = 0;
249     if (fabs(Position->GetGamma()) < 1.57) {
250         nlf = vFs(eZ)/(Weight*cos(Position->GetGamma()));
251     }    
252         
253   } else {                               // skip Run() execution this time
254   }
255
256
257   return false;
258 }
259
260 /******************************************************************************/
261
262 void FGAircraft::MassChange() {
263   static FGColumnVector vXYZtank(3);
264   float Tw;
265   float IXXt, IYYt, IZZt, IXZt;
266   unsigned int t;
267   unsigned int axis_ctr;
268
269   for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vXYZtank(axis_ctr) = 0.0;
270
271   // UPDATE TANK CONTENTS
272   //
273   // For each engine, cycle through the tanks and draw an equal amount of
274   // fuel (or oxidizer) from each active tank. The needed amount of fuel is
275   // determined by the engine in the FGEngine class. If more fuel is needed
276   // than is available in the tank, then that amount is considered a shortage,
277   // and will be drawn from the next tank. If the engine cannot be fed what it
278   // needs, it will be considered to be starved, and will shut down.
279
280   float Oshortage, Fshortage;
281
282   for (unsigned int e=0; e<numEngines; e++) {
283     Fshortage = Oshortage = 0.0;
284     for (t=0; t<numTanks; t++) {
285       switch(Engine[e]->GetType()) {
286       case FGEngine::etRocket:
287
288         switch(Tank[t]->GetType()) {
289         case FGTank::ttFUEL:
290           if (Tank[t]->GetSelected()) {
291             Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
292                                          numSelectedFuelTanks)*(dt*rate) + Fshortage);
293           }
294           break;
295         case FGTank::ttOXIDIZER:
296           if (Tank[t]->GetSelected()) {
297             Oshortage = Tank[t]->Reduce((Engine[e]->CalcOxidizerNeed()/
298                                          numSelectedOxiTanks)*(dt*rate) + Oshortage);
299           }
300           break;
301         }
302         break;
303
304       case FGEngine::etPiston:
305       case FGEngine::etTurboJet:
306       case FGEngine::etTurboProp:
307
308         if (Tank[t]->GetSelected()) {
309           Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
310                                        numSelectedFuelTanks)*(dt*rate) + Fshortage);
311         }
312         break;
313       }
314     }
315     if ((Fshortage <= 0.0) || (Oshortage <= 0.0)) Engine[e]->SetStarved();
316     else Engine[e]->SetStarved(false);
317   }
318
319   Weight = EmptyWeight;
320   for (t=0; t<numTanks; t++)
321     Weight += Tank[t]->GetContents();
322
323   Mass = Weight / GRAVITY;
324   // Calculate new CG here.
325
326   Tw = 0;
327   for (t=0; t<numTanks; t++) {
328     vXYZtank(eX) += Tank[t]->GetX()*Tank[t]->GetContents();
329     vXYZtank(eY) += Tank[t]->GetY()*Tank[t]->GetContents();
330     vXYZtank(eZ) += Tank[t]->GetZ()*Tank[t]->GetContents();
331
332     Tw += Tank[t]->GetContents();
333   }
334
335   vXYZcg = (vXYZtank + EmptyWeight*vbaseXYZcg) / (Tw + EmptyWeight);
336
337   // Calculate new moments of inertia here
338
339   IXXt = IYYt = IZZt = IXZt = 0.0;
340   for (t=0; t<numTanks; t++) {
341     IXXt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetX() - vXYZcg(eX))/12.0)*Tank[t]->GetContents()/GRAVITY;
342     IYYt += ((Tank[t]->GetY()-vXYZcg(eY))/12.0)*((Tank[t]->GetY() - vXYZcg(eY))/12.0)*Tank[t]->GetContents()/GRAVITY;
343     IZZt += ((Tank[t]->GetZ()-vXYZcg(eZ))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
344     IXZt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
345   }
346
347   Ixx = baseIxx + IXXt;
348   Iyy = baseIyy + IYYt;
349   Izz = baseIzz + IZZt;
350   Ixz = baseIxz + IXZt;
351
352 }
353
354 /******************************************************************************/
355
356 void FGAircraft::FMAero(void) {
357   static FGColumnVector vDXYZcg(3);
358   static FGColumnVector vAeroBodyForces(3);
359   unsigned int axis_ctr,ctr;
360
361   for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vFs(axis_ctr) = 0.0;
362
363   for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
364     for (ctr=0; ctr < Coeff[axis_ctr].size(); ctr++) {
365       vFs(axis_ctr+1) += Coeff[axis_ctr][ctr]->TotalValue();
366     }
367   }
368
369   vAeroBodyForces = State->GetTs2b(alpha, beta)*vFs;
370   vForces += vAeroBodyForces;
371
372   // The d*cg distances below, given in inches, are the distances FROM the c.g.
373   // TO the reference point. Since the c.g. and ref point are given in inches in
374   // the structural system (X positive rearwards) and the body coordinate system
375   // is given with X positive out the nose, the dxcg and dzcg values are
376   // *rotated* 180 degrees about the Y axis.
377
378   vDXYZcg(eX) = -(vXYZrp(eX) - vXYZcg(eX))/12.0;  //cg and rp values are in inches
379   vDXYZcg(eY) =  (vXYZrp(eY) - vXYZcg(eY))/12.0;
380   vDXYZcg(eZ) = -(vXYZrp(eZ) - vXYZcg(eZ))/12.0;
381
382   vMoments(eL) += vAeroBodyForces(eZ)*vDXYZcg(eY) - vAeroBodyForces(eY)*vDXYZcg(eZ); // rolling moment
383   vMoments(eM) += vAeroBodyForces(eX)*vDXYZcg(eZ) - vAeroBodyForces(eZ)*vDXYZcg(eX); // pitching moment
384   vMoments(eN) += vAeroBodyForces(eY)*vDXYZcg(eX) - vAeroBodyForces(eX)*vDXYZcg(eY); // yawing moment
385   
386   for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
387     for (ctr = 0; ctr < Coeff[axis_ctr+3].size(); ctr++) {
388       vMoments(axis_ctr+1) += Coeff[axis_ctr+3][ctr]->TotalValue();
389     }
390   }
391 }
392
393 /******************************************************************************/
394
395 void FGAircraft::FMGear(void) {
396
397   if ( !GearUp ) {
398     vector <FGLGear>::iterator iGear = lGear.begin();
399     while (iGear != lGear.end()) {
400       vForces  += iGear->Force();
401       vMoments += iGear->Moment();
402       iGear++;
403     }
404   } else {
405     // Crash Routine
406   }
407 }
408
409 /******************************************************************************/
410
411 void FGAircraft::FMMass(void) {
412   vForces(eX) += -GRAVITY*sin(vEuler(eTht)) * Mass;
413   vForces(eY) +=  GRAVITY*sin(vEuler(ePhi))*cos(vEuler(eTht)) * Mass;
414   vForces(eZ) +=  GRAVITY*cos(vEuler(ePhi))*cos(vEuler(eTht)) * Mass;
415 }
416
417 /******************************************************************************/
418
419 void FGAircraft::FMProp(void) {
420   for (unsigned int i=0;i<numEngines;i++) {
421
422     // Changes required here for new engine placement parameters (i.e. location and direction)
423
424     vForces(eX) += Engine[i]->CalcThrust();
425   }
426   
427 }
428
429 /******************************************************************************/
430
431 void FGAircraft::GetState(void) {
432   dt = State->Getdt();
433
434   alpha = Translation->Getalpha();
435   beta = Translation->Getbeta();
436   vEuler = Rotation->GetEuler();
437 }
438
439 /******************************************************************************/
440
441 void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg) {
442   string token = "";
443   string parameter;
444
445   AC_cfg->GetNextConfigLine();
446
447   while ((token = AC_cfg->GetValue()) != "/METRICS") {
448     *AC_cfg >> parameter;
449     if (parameter == "AC_WINGAREA") {
450         *AC_cfg >> WingArea;
451         cout << "    WingArea: " << WingArea  << endl; 
452     } else if (parameter == "AC_WINGSPAN") {
453         *AC_cfg >> WingSpan;
454         cout << "    WingSpan: " << WingSpan  << endl;
455     } else if (parameter == "AC_CHORD") {
456         *AC_cfg >> cbar;
457         cout << "    Chord: " << cbar << endl;
458     } else if (parameter == "AC_IXX") {
459         *AC_cfg >> baseIxx;
460         cout << "    baseIxx: " << baseIxx << endl;
461     } else if (parameter == "AC_IYY") {
462         *AC_cfg >> baseIyy;
463         cout << "    baseIyy: " << baseIyy << endl;
464     } else if (parameter == "AC_IZZ") { 
465         *AC_cfg >> baseIzz;
466         cout << "    baseIzz: " << baseIzz << endl;
467     } else if (parameter == "AC_IXZ") { 
468         *AC_cfg >> baseIxz;
469         cout << "    baseIxz: " << baseIxz  << endl;
470     } else if (parameter == "AC_EMPTYWT") {
471         *AC_cfg >> EmptyWeight;
472         cout << "    EmptyWeight: " << EmptyWeight  << endl;
473     } else if (parameter == "AC_CGLOC") {
474         *AC_cfg >> vbaseXYZcg(eX) >> vbaseXYZcg(eY) >> vbaseXYZcg(eZ);
475         cout << "    CG (x, y, z): " << vbaseXYZcg << endl;
476     } else if (parameter == "AC_EYEPTLOC") {
477         *AC_cfg >> vXYZep(eX) >> vXYZep(eY) >> vXYZep(eZ);
478         cout << "    Eyepoint (x, y, z): " << vXYZep << endl;
479     } else if (parameter == "AC_AERORP") {
480         *AC_cfg >> vXYZrp(eX) >> vXYZrp(eY) >> vXYZrp(eZ);
481         cout << "    Ref Pt (x, y, z): " << vXYZrp << endl;
482     } else if (parameter == "AC_ALPHALIMITS") {
483         *AC_cfg >> alphaclmin >> alphaclmax;
484         cout << "    Maximum Alpha: " << alphaclmax
485              << "    Minimum Alpha: " << alphaclmin 
486              << endl;
487     }         
488   }
489 }
490
491 /******************************************************************************/
492
493 void FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg) {
494   string token;
495   string engine_name;
496   string parameter;
497
498   AC_cfg->GetNextConfigLine();
499
500   while ((token = AC_cfg->GetValue()) != "/PROPULSION") {
501     *AC_cfg >> parameter;
502
503     if (parameter == "AC_ENGINE") {
504
505       *AC_cfg >> engine_name;
506       Engine[numEngines] = new FGEngine(FDMExec, EnginePath, engine_name, numEngines);
507       numEngines++;
508
509     } else if (parameter == "AC_TANK") {
510
511       Tank[numTanks] = new FGTank(AC_cfg);
512       switch(Tank[numTanks]->GetType()) {
513       case FGTank::ttFUEL:
514         numSelectedFuelTanks++;
515         break;
516       case FGTank::ttOXIDIZER:
517         numSelectedOxiTanks++;
518         break;
519       }
520       numTanks++;
521     }
522   }
523 }
524
525 /******************************************************************************/
526
527 void FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg) {
528   string token;
529
530   FCS->LoadFCS(AC_cfg);
531 }
532
533 /******************************************************************************/
534
535 void FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg) {
536   string token, axis;
537
538   AC_cfg->GetNextConfigLine();
539   
540   while ((token = AC_cfg->GetValue()) != "/AERODYNAMICS") {
541     if (token == "AXIS") {
542       CoeffArray ca;
543       axis = AC_cfg->GetValue("NAME");
544       AC_cfg->GetNextConfigLine();
545       while ((token = AC_cfg->GetValue()) != "/AXIS") {
546         ca.push_back(new FGCoefficient(FDMExec, AC_cfg));
547         DisplayCoeffFactors(ca.back()->Getmultipliers());
548       }
549       Coeff[AxisIdx[axis]]=ca;
550       AC_cfg->GetNextConfigLine();
551     }
552   }
553 }
554
555 /******************************************************************************/
556
557 void FGAircraft::ReadUndercarriage(FGConfigFile* AC_cfg) {
558   string token;
559
560   AC_cfg->GetNextConfigLine();
561
562   while ((token = AC_cfg->GetValue()) != "/UNDERCARRIAGE") {
563     lGear.push_back(FGLGear(AC_cfg, FDMExec));
564   }
565 }
566
567 /******************************************************************************/
568
569 void FGAircraft::ReadOutput(FGConfigFile* AC_cfg) {
570   string token, parameter;
571   int OutRate = 0;
572   int subsystems = 0;
573
574   token = AC_cfg->GetValue("NAME");
575   Output->SetFilename(token);
576   token = AC_cfg->GetValue("TYPE");
577   Output->SetType(token);
578   AC_cfg->GetNextConfigLine();
579
580   while ((token = AC_cfg->GetValue()) != "/OUTPUT") {
581     *AC_cfg >> parameter;
582     if (parameter == "RATE_IN_HZ") *AC_cfg >> OutRate;
583     if (parameter == "SIMULATION") {
584       *AC_cfg >> parameter;
585       if (parameter == "ON") subsystems += ssSimulation;
586     }
587     if (parameter == "AEROSURFACES") {
588       *AC_cfg >> parameter;
589       if (parameter == "ON") subsystems += ssAerosurfaces;
590     }
591     if (parameter == "RATES") {
592       *AC_cfg >> parameter;
593       if (parameter == "ON") subsystems += ssRates;
594     }
595     if (parameter == "VELOCITIES") {
596       *AC_cfg >> parameter;
597       if (parameter == "ON") subsystems += ssVelocities;
598     }
599     if (parameter == "FORCES") {
600       *AC_cfg >> parameter;
601       if (parameter == "ON") subsystems += ssForces;
602     }
603     if (parameter == "MOMENTS") {
604       *AC_cfg >> parameter;
605       if (parameter == "ON") subsystems += ssMoments;
606     }
607     if (parameter == "ATMOSPHERE") {
608       *AC_cfg >> parameter;
609       if (parameter == "ON") subsystems += ssAtmosphere;
610     }
611     if (parameter == "MASSPROPS") {
612       *AC_cfg >> parameter;
613       if (parameter == "ON") subsystems += ssMassProps;
614     }
615     if (parameter == "POSITION") {
616       *AC_cfg >> parameter;
617       if (parameter == "ON") subsystems += ssPosition;
618     }
619     if (parameter == "COEFFICIENTS") {
620       *AC_cfg >> parameter;
621       if (parameter == "ON") subsystems += ssCoefficients;
622     }
623     if (parameter == "GROUND_REACTIONS") {
624       *AC_cfg >> parameter;
625       if (parameter == "ON") subsystems += ssGroundReactions;
626     }
627   }
628
629   Output->SetSubsystems(subsystems);
630
631   OutRate = OutRate>120?120:(OutRate<0?0:OutRate);
632   Output->SetRate( (int)(0.5 + 1.0/(State->Getdt()*OutRate)) );
633 }
634
635 /******************************************************************************/
636
637 void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg) {
638   string token = AC_cfg->GetValue();
639   string scratch;
640   AircraftName = AC_cfg->GetValue("NAME");
641   cout << "Reading Aircraft Configuration File: " << AircraftName << endl;
642   scratch=AC_cfg->GetValue("VERSION").c_str();
643
644   CFGVersion = AC_cfg->GetValue("VERSION");
645   cout << "                            Version: " << CFGVersion << endl;
646   if (CFGVersion != NEEDED_CFG_VERSION) {
647     cout << endl << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
648     " RESULTS WILL BE UNPREDICTABLE !!" << endl;
649     cout << "Current version needed is: " << NEEDED_CFG_VERSION << endl;
650     cout << "         You have version: " << CFGVersion << endl << endl;
651     //exit(-1);
652   }
653
654
655 }
656
657 /******************************************************************************/
658
659 void FGAircraft::DisplayCoeffFactors(vector <eParam> multipliers) {
660   cout << "   Non-Dimensionalized by: ";
661
662   for (unsigned int i=0; i<multipliers.size();i++)
663     cout << State->paramdef[multipliers[i]];
664
665   cout << endl;
666 }
667
668 /******************************************************************************/
669
670 string FGAircraft::GetCoefficientStrings(void) {
671   string CoeffStrings = "";
672   bool firstime = true;
673
674   for (unsigned int axis = 0; axis < 6; axis++) {
675     for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
676       if (firstime) {
677         firstime = false;
678       } else {
679         CoeffStrings += ", ";
680       }
681       CoeffStrings += Coeff[axis][sd]->Getname();
682     }
683   }
684
685   return CoeffStrings;
686 }
687
688 /******************************************************************************/
689
690 string FGAircraft::GetCoefficientValues(void) {
691   string SDValues = "";
692   char buffer[10];
693   bool firstime = true;
694
695   for (unsigned int axis = 0; axis < 6; axis++) {
696     for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
697       if (firstime) {
698         firstime = false;
699       } else {
700         SDValues += ", ";
701       }
702       sprintf(buffer, "%9.6f", Coeff[axis][sd]->GetSD());
703       SDValues += string(buffer);
704     }
705   }
706
707   return SDValues;
708   ;
709 }
710
711 /******************************************************************************/
712
713 string FGAircraft::GetGroundReactionStrings(void) {
714   string GroundReactionStrings = "";
715   bool firstime = true;
716
717   for (unsigned int i=0;i<lGear.size();i++) {
718     if (!firstime) GroundReactionStrings += ", ";
719     GroundReactionStrings += (lGear[i].GetName() + "_WOW, ");
720     GroundReactionStrings += (lGear[i].GetName() + "_compressLength, ");
721     GroundReactionStrings += (lGear[i].GetName() + "_compressSpeed, ");
722     GroundReactionStrings += (lGear[i].GetName() + "_Force");
723
724     firstime = false;
725   }
726
727   return GroundReactionStrings;
728 }
729
730 /******************************************************************************/
731
732 string FGAircraft::GetGroundReactionValues(void) {
733   char buff[20];
734   string GroundReactionValues = "";
735
736   bool firstime = true;
737
738   for (unsigned int i=0;i<lGear.size();i++) {
739     if (!firstime) GroundReactionValues += ", ";
740     GroundReactionValues += string( lGear[i].GetWOW()?"1":"0" ) + ", ";
741     GroundReactionValues += (string(gcvt(lGear[i].GetCompLen(),    5, buff)) + ", ");
742     GroundReactionValues += (string(gcvt(lGear[i].GetCompVel(),    6, buff)) + ", ");
743     GroundReactionValues += (string(gcvt(lGear[i].GetCompForce(), 10, buff)));
744
745     firstime = false;
746   }
747
748   return GroundReactionValues;
749 }
750