1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 Purpose: Encapsulates an aircraft
9 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
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
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
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.
25 Further information about the GNU General Public License can also be found on
26 the world wide web at http://www.gnu.org.
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.
35 --------------------------------------------------------------------------------
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
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 COMMENTS, REFERENCES, and NOTES
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 [1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
49 Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
51 [2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
53 [3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
54 NASA-Ames", NASA CR-2497, January 1975
55 [4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
56 Wiley & Sons, 1979 ISBN 0-471-03032-5
57 [5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
58 1982 ISBN 0-471-08936-2
60 The aerodynamic coefficients used in this model are:
63 CL0 - Reference lift at zero alpha
64 CD0 - Reference drag at zero alpha
65 CDM - Drag due to Mach
66 CLa - Lift curve slope (w.r.t. alpha)
67 CDa - Drag curve slope (w.r.t. alpha)
68 CLq - Lift due to pitch rate
69 CLM - Lift due to Mach
70 CLadt - Lift due to alpha rate
72 Cmadt - Pitching Moment due to alpha rate
73 Cm0 - Reference Pitching moment at zero alpha
74 Cma - Pitching moment slope (w.r.t. alpha)
75 Cmq - Pitch damping (pitch moment due to pitch rate)
76 CmM - Pitch Moment due to Mach
79 Cyb - Side force due to sideslip
80 Cyr - Side force due to yaw rate
82 Clb - Dihedral effect (roll moment due to sideslip)
83 Clp - Roll damping (roll moment due to roll rate)
84 Clr - Roll moment due to yaw rate
85 Cnb - Weathercocking stability (yaw moment due to sideslip)
86 Cnp - Rudder adverse yaw (yaw moment due to roll rate)
87 Cnr - Yaw damping (yaw moment due to yaw rate)
90 CLDe - Lift due to elevator
91 CDDe - Drag due to elevator
92 CyDr - Side force due to rudder
93 CyDa - Side force due to aileron
95 CmDe - Pitch moment due to elevator
96 ClDa - Roll moment due to aileron
97 ClDr - Roll moment due to rudder
98 CnDr - Yaw moment due to rudder
99 CnDa - Yaw moment due to aileron
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
105 #include <sys/stat.h>
106 #include <sys/types.h>
109 # ifndef __BORLANDC__
110 # include <simgear/compiler.h>
112 # ifdef FG_HAVE_STD_INCLUDES
121 #include "FGAircraft.h"
122 #include "FGTranslation.h"
123 #include "FGRotation.h"
124 #include "FGAtmosphere.h"
126 #include "FGFDMExec.h"
128 #include "FGPosition.h"
129 #include "FGAuxiliary.h"
130 #include "FGOutput.h"
132 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
136 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
140 static const char *IdSrc = "$Id$";
141 static const char *IdHdr = ID_AIRCRAFT;
143 extern char highint[5];
144 extern char halfint[5];
145 extern char normint[6];
146 extern char reset[5];
147 extern char underon[5];
148 extern char underoff[6];
149 extern char fgblue[6];
150 extern char fgcyan[6];
151 extern char fgred[6];
152 extern char fggreen[6];
153 extern char fgdef[6];
155 extern short debug_lvl;
157 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
161 FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex),
178 AxisIdx["PITCH"] = 4;
181 Coeff = new CoeffArray[6];
185 alphaclmin = alphaclmax = 0;
187 if (debug_lvl & 2) cout << "Instantiated: " << Name << endl;
191 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
194 FGAircraft::~FGAircraft() {
196 for (i=0; i<6; i++) {
197 for (j=0; j<Coeff[i].size(); j++) {
203 if (debug_lvl & 2) cout << "Destroyed: FGAircraft" << endl;
206 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
208 bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string fname) {
211 string aircraftCfgFileName;
214 AircraftPath = aircraft_path;
215 EnginePath = engine_path;
218 aircraftCfgFileName = AircraftPath + "/" + fname + "/" + fname + ".xml";
220 aircraftCfgFileName = AircraftPath + ";" + fname + ";" + fname + ".xml";
223 FGConfigFile AC_cfg(aircraftCfgFileName);
224 if (!AC_cfg.IsOpen()) return false;
226 ReadPrologue(&AC_cfg);
228 while ((AC_cfg.GetNextConfigLine() != string("EOF")) &&
229 (token = AC_cfg.GetValue()) != string("/FDM_CONFIG")) {
230 if (token == "METRICS") {
231 cout << fgcyan << "\n Reading Metrics" << fgdef << endl;
232 ReadMetrics(&AC_cfg);
233 } else if (token == "AERODYNAMICS") {
234 cout << fgcyan << "\n Reading Aerodynamics" << fgdef << endl;
235 ReadAerodynamics(&AC_cfg);
236 } else if (token == "UNDERCARRIAGE") {
237 cout << fgcyan << "\n Reading Landing Gear" << fgdef << endl;
238 ReadUndercarriage(&AC_cfg);
239 } else if (token == "PROPULSION") {
240 cout << fgcyan << "\n Reading Propulsion" << fgdef << endl;
241 ReadPropulsion(&AC_cfg);
242 } else if (token == "FLIGHT_CONTROL") {
243 cout << fgcyan << "\n Reading Flight Control" << fgdef << endl;
244 ReadFlightControls(&AC_cfg);
245 } else if (token == "OUTPUT") {
246 cout << fgcyan << "\n Reading Output directives" << fgdef << endl;
254 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256 bool FGAircraft::Run(void) {
257 if (!FGModel::Run()) { // if false then execute this Run()
260 for (int i = 1; i <= 3; i++) vForces(i) = vMoments(i) = 0.0;
269 if (fabs(Position->GetGamma()) < 1.57) {
270 nlf = vFs(eZ)/(Weight*cos(Position->GetGamma()));
273 } else { // skip Run() execution this time
280 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282 void FGAircraft::MassChange() {
283 static FGColumnVector vXYZtank(3);
285 float IXXt, IYYt, IZZt, IXZt;
287 // unsigned int axis_ctr;
289 for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vXYZtank(axis_ctr) = 0.0;
291 // UPDATE TANK CONTENTS
293 // For each engine, cycle through the tanks and draw an equal amount of
294 // fuel (or oxidizer) from each active tank. The needed amount of fuel is
295 // determined by the engine in the FGEngine class. If more fuel is needed
296 // than is available in the tank, then that amount is considered a shortage,
297 // and will be drawn from the next tank. If the engine cannot be fed what it
298 // needs, it will be considered to be starved, and will shut down.
300 float Oshortage, Fshortage;
302 for (unsigned int e=0; e<numEngines; e++) {
303 Fshortage = Oshortage = 0.0;
304 for (t=0; t<numTanks; t++) {
305 switch(Engine[e]->GetType()) {
306 case FGEngine::etRocket:
308 switch(Tank[t]->GetType()) {
310 if (Tank[t]->GetSelected()) {
311 Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
312 numSelectedFuelTanks)*(dt*rate) + Fshortage);
315 case FGTank::ttOXIDIZER:
316 if (Tank[t]->GetSelected()) {
317 Oshortage = Tank[t]->Reduce((Engine[e]->CalcOxidizerNeed()/
318 numSelectedOxiTanks)*(dt*rate) + Oshortage);
324 case FGEngine::etPiston:
325 case FGEngine::etTurboJet:
326 case FGEngine::etTurboProp:
328 if (Tank[t]->GetSelected()) {
329 Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
330 numSelectedFuelTanks)*(dt*rate) + Fshortage);
335 if ((Fshortage <= 0.0) || (Oshortage <= 0.0)) Engine[e]->SetStarved();
336 else Engine[e]->SetStarved(false);
339 Weight = EmptyWeight;
340 // for (t=0; t<numTanks; t++)
341 // Weight += Tank[t]->GetContents();
343 Mass = Weight / GRAVITY;
344 // Calculate new CG here.
347 // for (t=0; t<numTanks; t++) {
348 // vXYZtank(eX) += Tank[t]->GetX()*Tank[t]->GetContents();
349 // vXYZtank(eY) += Tank[t]->GetY()*Tank[t]->GetContents();
350 // vXYZtank(eZ) += Tank[t]->GetZ()*Tank[t]->GetContents();
352 // Tw += Tank[t]->GetContents();
355 vXYZcg = (vXYZtank + EmptyWeight*vbaseXYZcg) / (Tw + EmptyWeight);
357 // Calculate new moments of inertia here
359 IXXt = IYYt = IZZt = IXZt = 0.0;
360 // for (t=0; t<numTanks; t++) {
361 // IXXt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetX() - vXYZcg(eX))/12.0)*Tank[t]->GetContents()/GRAVITY;
362 // IYYt += ((Tank[t]->GetY()-vXYZcg(eY))/12.0)*((Tank[t]->GetY() - vXYZcg(eY))/12.0)*Tank[t]->GetContents()/GRAVITY;
363 // IZZt += ((Tank[t]->GetZ()-vXYZcg(eZ))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
364 // IXZt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
367 Ixx = baseIxx + IXXt;
368 Iyy = baseIyy + IYYt;
369 Izz = baseIzz + IZZt;
370 Ixz = baseIxz + IXZt;
374 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
376 void FGAircraft::FMAero(void) {
377 static FGColumnVector vDXYZcg(3);
378 static FGColumnVector vAeroBodyForces(3);
379 unsigned int axis_ctr,ctr;
381 for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vFs(axis_ctr) = 0.0;
383 for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
384 for (ctr=0; ctr < Coeff[axis_ctr].size(); ctr++) {
385 vFs(axis_ctr+1) += Coeff[axis_ctr][ctr]->TotalValue();
389 vAeroBodyForces = State->GetTs2b(alpha, beta)*vFs;
390 vForces += vAeroBodyForces;
392 // see http://home.earthlink.net/~apeden/jsbsim_moments_due_to_forces.txt
393 // for details on this
394 vDXYZcg(eX) = -(vXYZrp(eX) - vXYZcg(eX))/12.0; //cg and rp values are in inches
395 vDXYZcg(eY) = (vXYZrp(eY) - vXYZcg(eY))/12.0;
396 vDXYZcg(eZ) = -(vXYZrp(eZ) - vXYZcg(eZ))/12.0;
398 vMoments(eL) += vAeroBodyForces(eZ)*vDXYZcg(eY) - vAeroBodyForces(eY)*vDXYZcg(eZ); // rolling moment
399 vMoments(eM) += vAeroBodyForces(eX)*vDXYZcg(eZ) - vAeroBodyForces(eZ)*vDXYZcg(eX); // pitching moment
400 vMoments(eN) += vAeroBodyForces(eY)*vDXYZcg(eX) - vAeroBodyForces(eX)*vDXYZcg(eY); // yawing moment
402 for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
403 for (ctr = 0; ctr < Coeff[axis_ctr+3].size(); ctr++) {
404 vMoments(axis_ctr+1) += Coeff[axis_ctr+3][ctr]->TotalValue();
409 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
411 void FGAircraft::FMGear(void) {
414 vector <FGLGear>::iterator iGear = lGear.begin();
415 while (iGear != lGear.end()) {
416 vForces += iGear->Force();
417 vMoments += iGear->Moment();
425 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427 void FGAircraft::FMMass(void) {
428 vForces(eX) += -GRAVITY*sin(vEuler(eTht)) * Mass;
429 vForces(eY) += GRAVITY*sin(vEuler(ePhi))*cos(vEuler(eTht)) * Mass;
430 vForces(eZ) += GRAVITY*cos(vEuler(ePhi))*cos(vEuler(eTht)) * Mass;
433 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
435 void FGAircraft::FMProp(void) {
436 vForces += Propulsion->GetForces();
437 vMoments += Propulsion->GetMoments();
440 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
442 void FGAircraft::GetState(void) {
445 alpha = Translation->Getalpha();
446 beta = Translation->Getbeta();
447 vEuler = Rotation->GetEuler();
450 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
452 void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg) {
456 AC_cfg->GetNextConfigLine();
458 while ((token = AC_cfg->GetValue()) != string("/METRICS")) {
459 *AC_cfg >> parameter;
460 if (parameter == string("AC_WINGAREA")) {
462 cout << " WingArea: " << WingArea << endl;
463 } else if (parameter == "AC_WINGSPAN") {
465 cout << " WingSpan: " << WingSpan << endl;
466 } else if (parameter == "AC_CHORD") {
468 cout << " Chord: " << cbar << endl;
469 } else if (parameter == "AC_IXX") {
471 cout << " baseIxx: " << baseIxx << endl;
472 } else if (parameter == "AC_IYY") {
474 cout << " baseIyy: " << baseIyy << endl;
475 } else if (parameter == "AC_IZZ") {
477 cout << " baseIzz: " << baseIzz << endl;
478 } else if (parameter == "AC_IXZ") {
480 cout << " baseIxz: " << baseIxz << endl;
481 } else if (parameter == "AC_EMPTYWT") {
482 *AC_cfg >> EmptyWeight;
483 cout << " EmptyWeight: " << EmptyWeight << endl;
484 } else if (parameter == "AC_CGLOC") {
485 *AC_cfg >> vbaseXYZcg(eX) >> vbaseXYZcg(eY) >> vbaseXYZcg(eZ);
486 cout << " CG (x, y, z): " << vbaseXYZcg << endl;
487 } else if (parameter == "AC_EYEPTLOC") {
488 *AC_cfg >> vXYZep(eX) >> vXYZep(eY) >> vXYZep(eZ);
489 cout << " Eyepoint (x, y, z): " << vXYZep << endl;
490 } else if (parameter == "AC_AERORP") {
491 *AC_cfg >> vXYZrp(eX) >> vXYZrp(eY) >> vXYZrp(eZ);
492 cout << " Ref Pt (x, y, z): " << vXYZrp << endl;
493 } else if (parameter == "AC_ALPHALIMITS") {
494 *AC_cfg >> alphaclmin >> alphaclmax;
495 cout << " Maximum Alpha: " << alphaclmax
496 << " Minimum Alpha: " << alphaclmin
502 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
504 void FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg) {
505 if (!Propulsion->LoadPropulsion(AC_cfg)) {
506 cerr << "Propulsion not successfully loaded" << endl;
510 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
512 void FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg) {
513 if (!FCS->LoadFCS(AC_cfg)) {
514 cerr << "Flight Controls not successfully loaded" << endl;
518 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
520 void FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg) {
523 AC_cfg->GetNextConfigLine();
525 while ((token = AC_cfg->GetValue()) != string("/AERODYNAMICS")) {
526 if (token == "AXIS") {
528 axis = AC_cfg->GetValue("NAME");
529 AC_cfg->GetNextConfigLine();
530 while ((token = AC_cfg->GetValue()) != string("/AXIS")) {
531 ca.push_back(new FGCoefficient(FDMExec, AC_cfg));
532 DisplayCoeffFactors(ca.back()->Getmultipliers());
534 Coeff[AxisIdx[axis]]=ca;
535 AC_cfg->GetNextConfigLine();
540 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
542 void FGAircraft::ReadUndercarriage(FGConfigFile* AC_cfg) {
545 AC_cfg->GetNextConfigLine();
547 while ((token = AC_cfg->GetValue()) != string("/UNDERCARRIAGE")) {
548 lGear.push_back(FGLGear(AC_cfg, FDMExec));
552 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
554 void FGAircraft::ReadOutput(FGConfigFile* AC_cfg) {
555 string token, parameter;
559 token = AC_cfg->GetValue("NAME");
560 Output->SetFilename(token);
561 token = AC_cfg->GetValue("TYPE");
562 Output->SetType(token);
563 AC_cfg->GetNextConfigLine();
565 while ((token = AC_cfg->GetValue()) != string("/OUTPUT")) {
566 *AC_cfg >> parameter;
567 if (parameter == "RATE_IN_HZ") *AC_cfg >> OutRate;
568 if (parameter == "SIMULATION") {
569 *AC_cfg >> parameter;
570 if (parameter == "ON") subsystems += ssSimulation;
572 if (parameter == "AEROSURFACES") {
573 *AC_cfg >> parameter;
574 if (parameter == "ON") subsystems += ssAerosurfaces;
576 if (parameter == "RATES") {
577 *AC_cfg >> parameter;
578 if (parameter == "ON") subsystems += ssRates;
580 if (parameter == "VELOCITIES") {
581 *AC_cfg >> parameter;
582 if (parameter == "ON") subsystems += ssVelocities;
584 if (parameter == "FORCES") {
585 *AC_cfg >> parameter;
586 if (parameter == "ON") subsystems += ssForces;
588 if (parameter == "MOMENTS") {
589 *AC_cfg >> parameter;
590 if (parameter == "ON") subsystems += ssMoments;
592 if (parameter == "ATMOSPHERE") {
593 *AC_cfg >> parameter;
594 if (parameter == "ON") subsystems += ssAtmosphere;
596 if (parameter == "MASSPROPS") {
597 *AC_cfg >> parameter;
598 if (parameter == "ON") subsystems += ssMassProps;
600 if (parameter == "POSITION") {
601 *AC_cfg >> parameter;
602 if (parameter == "ON") subsystems += ssPosition;
604 if (parameter == "COEFFICIENTS") {
605 *AC_cfg >> parameter;
606 if (parameter == "ON") subsystems += ssCoefficients;
608 if (parameter == "GROUND_REACTIONS") {
609 *AC_cfg >> parameter;
610 if (parameter == "ON") subsystems += ssGroundReactions;
612 if (parameter == "FCS") {
613 *AC_cfg >> parameter;
614 if (parameter == "ON") subsystems += ssFCS;
618 Output->SetSubsystems(subsystems);
620 OutRate = OutRate>120?120:(OutRate<0?0:OutRate);
621 Output->SetRate( (int)(0.5 + 1.0/(State->Getdt()*OutRate)) );
624 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
626 void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg) {
627 string token = AC_cfg->GetValue();
629 AircraftName = AC_cfg->GetValue("NAME");
630 cout << underon << "Reading Aircraft Configuration File" << underoff << ": "
631 << highint << AircraftName << normint << endl;
632 scratch = AC_cfg->GetValue("VERSION").c_str();
634 CFGVersion = AC_cfg->GetValue("VERSION");
635 cout << " Version: " << highint << CFGVersion
637 if (CFGVersion != string(NEEDED_CFG_VERSION)) {
638 cout << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
639 " RESULTS WILL BE UNPREDICTABLE !!" << endl;
640 cout << "Current version needed is: " << NEEDED_CFG_VERSION << endl;
641 cout << " You have version: " << CFGVersion << endl << fgdef << endl;
648 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
650 void FGAircraft::DisplayCoeffFactors(vector <eParam> multipliers) {
651 cout << " Non-Dimensionalized by: ";
653 for (unsigned int i=0; i<multipliers.size();i++)
654 cout << State->paramdef[multipliers[i]];
659 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
661 string FGAircraft::GetCoefficientStrings(void) {
662 string CoeffStrings = "";
663 bool firstime = true;
665 for (unsigned int axis = 0; axis < 6; axis++) {
666 for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
670 CoeffStrings += ", ";
672 CoeffStrings += Coeff[axis][sd]->Getname();
679 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
681 string FGAircraft::GetCoefficientValues(void) {
682 string SDValues = "";
684 bool firstime = true;
686 for (unsigned int axis = 0; axis < 6; axis++) {
687 for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
693 sprintf(buffer, "%9.6f", Coeff[axis][sd]->GetSD());
694 SDValues += string(buffer);
701 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
703 string FGAircraft::GetGroundReactionStrings(void) {
704 string GroundReactionStrings = "";
705 bool firstime = true;
707 for (unsigned int i=0;i<lGear.size();i++) {
708 if (!firstime) GroundReactionStrings += ", ";
709 GroundReactionStrings += (lGear[i].GetName() + "_WOW, ");
710 GroundReactionStrings += (lGear[i].GetName() + "_compressLength, ");
711 GroundReactionStrings += (lGear[i].GetName() + "_compressSpeed, ");
712 GroundReactionStrings += (lGear[i].GetName() + "_Force");
717 return GroundReactionStrings;
720 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
722 string FGAircraft::GetGroundReactionValues(void) {
724 string GroundReactionValues = "";
726 bool firstime = true;
728 for (unsigned int i=0;i<lGear.size();i++) {
729 if (!firstime) GroundReactionValues += ", ";
730 GroundReactionValues += string( lGear[i].GetWOW()?"1":"0" ) + ", ";
731 GroundReactionValues += (string(gcvt(lGear[i].GetCompLen(), 5, buff)) + ", ");
732 GroundReactionValues += (string(gcvt(lGear[i].GetCompVel(), 6, buff)) + ", ");
733 GroundReactionValues += (string(gcvt(lGear[i].GetCompForce(), 10, buff)));
738 return GroundReactionValues;
741 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
743 void FGAircraft::Debug(void)
745 //TODO: Add your source code here