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 SG_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 = "$Header$";
141 static const char *IdHdr = ID_AIRCRAFT;
143 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
147 FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex),
164 AxisIdx["PITCH"] = 4;
167 Coeff = new CoeffArray[6];
171 alphaclmin = alphaclmax = 0;
173 numTanks = numEngines = numSelectedFuelTanks = numSelectedOxiTanks = 0;
177 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180 FGAircraft::~FGAircraft(void) {
183 if (Engine != NULL) {
184 for (i=0; i<numEngines; i++)
188 for (i=0; i<numTanks; i++)
191 for (i=0; i<6; i++) {
192 for (j=0; j<Coeff[i].size(); j++) {
199 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
201 bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string fname) {
204 string aircraftCfgFileName;
207 AircraftPath = aircraft_path;
208 EnginePath = engine_path;
211 aircraftCfgFileName = AircraftPath + "/" + fname + "/" + fname + ".xml";
213 aircraftCfgFileName = AircraftPath + ";" + fname + ";" + fname + ".xml";
216 FGConfigFile AC_cfg(aircraftCfgFileName);
217 if (!AC_cfg.IsOpen()) return false;
219 ReadPrologue(&AC_cfg);
221 while ((AC_cfg.GetNextConfigLine() != "EOF") &&
222 (token = AC_cfg.GetValue()) != "/FDM_CONFIG") {
223 if (token == "METRICS") {
224 cout << " Reading Metrics" << endl;
225 ReadMetrics(&AC_cfg);
226 } else if (token == "AERODYNAMICS") {
227 cout << " Reading Aerodynamics" << endl;
228 ReadAerodynamics(&AC_cfg);
229 } else if (token == "UNDERCARRIAGE") {
230 cout << " Reading Landing Gear" << endl;
231 ReadUndercarriage(&AC_cfg);
232 } else if (token == "PROPULSION") {
233 cout << " Reading Propulsion" << endl;
234 ReadPropulsion(&AC_cfg);
235 } else if (token == "FLIGHT_CONTROL") {
236 cout << " Reading Flight Control" << endl;
237 ReadFlightControls(&AC_cfg);
238 } else if (token == "OUTPUT") {
246 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
248 bool FGAircraft::Run(void) {
249 if (!FGModel::Run()) { // if false then execute this Run()
252 for (int i = 1; i <= 3; i++) vForces(i) = vMoments(i) = 0.0;
261 if (fabs(Position->GetGamma()) < 1.57) {
262 nlf = vFs(eZ)/(Weight*cos(Position->GetGamma()));
265 } else { // skip Run() execution this time
272 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
274 void FGAircraft::MassChange() {
275 static FGColumnVector vXYZtank(3);
277 float IXXt, IYYt, IZZt, IXZt;
279 unsigned int axis_ctr;
281 for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vXYZtank(axis_ctr) = 0.0;
283 // UPDATE TANK CONTENTS
285 // For each engine, cycle through the tanks and draw an equal amount of
286 // fuel (or oxidizer) from each active tank. The needed amount of fuel is
287 // determined by the engine in the FGEngine class. If more fuel is needed
288 // than is available in the tank, then that amount is considered a shortage,
289 // and will be drawn from the next tank. If the engine cannot be fed what it
290 // needs, it will be considered to be starved, and will shut down.
292 float Oshortage, Fshortage;
294 for (unsigned int e=0; e<numEngines; e++) {
295 Fshortage = Oshortage = 0.0;
296 for (t=0; t<numTanks; t++) {
297 switch(Engine[e]->GetType()) {
298 case FGEngine::etRocket:
300 switch(Tank[t]->GetType()) {
302 if (Tank[t]->GetSelected()) {
303 Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
304 numSelectedFuelTanks)*(dt*rate) + Fshortage);
307 case FGTank::ttOXIDIZER:
308 if (Tank[t]->GetSelected()) {
309 Oshortage = Tank[t]->Reduce((Engine[e]->CalcOxidizerNeed()/
310 numSelectedOxiTanks)*(dt*rate) + Oshortage);
316 case FGEngine::etPiston:
317 case FGEngine::etTurboJet:
318 case FGEngine::etTurboProp:
320 if (Tank[t]->GetSelected()) {
321 Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
322 numSelectedFuelTanks)*(dt*rate) + Fshortage);
327 if ((Fshortage <= 0.0) || (Oshortage <= 0.0)) Engine[e]->SetStarved();
328 else Engine[e]->SetStarved(false);
331 Weight = EmptyWeight;
332 for (t=0; t<numTanks; t++)
333 Weight += Tank[t]->GetContents();
335 Mass = Weight / GRAVITY;
336 // Calculate new CG here.
339 for (t=0; t<numTanks; t++) {
340 vXYZtank(eX) += Tank[t]->GetX()*Tank[t]->GetContents();
341 vXYZtank(eY) += Tank[t]->GetY()*Tank[t]->GetContents();
342 vXYZtank(eZ) += Tank[t]->GetZ()*Tank[t]->GetContents();
344 Tw += Tank[t]->GetContents();
347 vXYZcg = (vXYZtank + EmptyWeight*vbaseXYZcg) / (Tw + EmptyWeight);
349 // Calculate new moments of inertia here
351 IXXt = IYYt = IZZt = IXZt = 0.0;
352 for (t=0; t<numTanks; t++) {
353 IXXt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetX() - vXYZcg(eX))/12.0)*Tank[t]->GetContents()/GRAVITY;
354 IYYt += ((Tank[t]->GetY()-vXYZcg(eY))/12.0)*((Tank[t]->GetY() - vXYZcg(eY))/12.0)*Tank[t]->GetContents()/GRAVITY;
355 IZZt += ((Tank[t]->GetZ()-vXYZcg(eZ))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
356 IXZt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
359 Ixx = baseIxx + IXXt;
360 Iyy = baseIyy + IYYt;
361 Izz = baseIzz + IZZt;
362 Ixz = baseIxz + IXZt;
366 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
368 void FGAircraft::FMAero(void) {
369 static FGColumnVector vDXYZcg(3);
370 static FGColumnVector vAeroBodyForces(3);
371 unsigned int axis_ctr,ctr;
373 for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vFs(axis_ctr) = 0.0;
375 for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
376 for (ctr=0; ctr < Coeff[axis_ctr].size(); ctr++) {
377 vFs(axis_ctr+1) += Coeff[axis_ctr][ctr]->TotalValue();
381 vAeroBodyForces = State->GetTs2b(alpha, beta)*vFs;
382 vForces += vAeroBodyForces;
384 // see http://home.earthlink.net/~apeden/jsbsim_moments_due_to_forces.txt
385 // for details on this
386 vDXYZcg(eX) = -(vXYZrp(eX) - vXYZcg(eX))/12.0; //cg and rp values are in inches
387 vDXYZcg(eY) = (vXYZrp(eY) - vXYZcg(eY))/12.0;
388 vDXYZcg(eZ) = -(vXYZrp(eZ) - vXYZcg(eZ))/12.0;
390 vMoments(eL) += vAeroBodyForces(eZ)*vDXYZcg(eY) - vAeroBodyForces(eY)*vDXYZcg(eZ); // rolling moment
391 vMoments(eM) += vAeroBodyForces(eX)*vDXYZcg(eZ) - vAeroBodyForces(eZ)*vDXYZcg(eX); // pitching moment
392 vMoments(eN) += vAeroBodyForces(eY)*vDXYZcg(eX) - vAeroBodyForces(eX)*vDXYZcg(eY); // yawing moment
394 for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
395 for (ctr = 0; ctr < Coeff[axis_ctr+3].size(); ctr++) {
396 vMoments(axis_ctr+1) += Coeff[axis_ctr+3][ctr]->TotalValue();
401 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
403 void FGAircraft::FMGear(void) {
406 vector <FGLGear>::iterator iGear = lGear.begin();
407 while (iGear != lGear.end()) {
408 vForces += iGear->Force();
409 vMoments += iGear->Moment();
417 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
419 void FGAircraft::FMMass(void) {
420 vForces(eX) += -GRAVITY*sin(vEuler(eTht)) * Mass;
421 vForces(eY) += GRAVITY*sin(vEuler(ePhi))*cos(vEuler(eTht)) * Mass;
422 vForces(eZ) += GRAVITY*cos(vEuler(ePhi))*cos(vEuler(eTht)) * Mass;
425 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427 void FGAircraft::FMProp(void) {
428 for (unsigned int i=0;i<numEngines;i++) {
430 // Changes required here for new engine placement parameters (i.e. location and direction)
432 vForces(eX) += Engine[i]->CalcThrust();
437 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
439 void FGAircraft::GetState(void) {
442 alpha = Translation->Getalpha();
443 beta = Translation->Getbeta();
444 vEuler = Rotation->GetEuler();
447 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
449 void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg) {
453 AC_cfg->GetNextConfigLine();
455 while ((token = AC_cfg->GetValue()) != "/METRICS") {
456 *AC_cfg >> parameter;
457 if (parameter == "AC_WINGAREA") {
459 cout << " WingArea: " << WingArea << endl;
460 } else if (parameter == "AC_WINGSPAN") {
462 cout << " WingSpan: " << WingSpan << endl;
463 } else if (parameter == "AC_CHORD") {
465 cout << " Chord: " << cbar << endl;
466 } else if (parameter == "AC_IXX") {
468 cout << " baseIxx: " << baseIxx << endl;
469 } else if (parameter == "AC_IYY") {
471 cout << " baseIyy: " << baseIyy << endl;
472 } else if (parameter == "AC_IZZ") {
474 cout << " baseIzz: " << baseIzz << endl;
475 } else if (parameter == "AC_IXZ") {
477 cout << " baseIxz: " << baseIxz << endl;
478 } else if (parameter == "AC_EMPTYWT") {
479 *AC_cfg >> EmptyWeight;
480 cout << " EmptyWeight: " << EmptyWeight << endl;
481 } else if (parameter == "AC_CGLOC") {
482 *AC_cfg >> vbaseXYZcg(eX) >> vbaseXYZcg(eY) >> vbaseXYZcg(eZ);
483 cout << " CG (x, y, z): " << vbaseXYZcg << endl;
484 } else if (parameter == "AC_EYEPTLOC") {
485 *AC_cfg >> vXYZep(eX) >> vXYZep(eY) >> vXYZep(eZ);
486 cout << " Eyepoint (x, y, z): " << vXYZep << endl;
487 } else if (parameter == "AC_AERORP") {
488 *AC_cfg >> vXYZrp(eX) >> vXYZrp(eY) >> vXYZrp(eZ);
489 cout << " Ref Pt (x, y, z): " << vXYZrp << endl;
490 } else if (parameter == "AC_ALPHALIMITS") {
491 *AC_cfg >> alphaclmin >> alphaclmax;
492 cout << " Maximum Alpha: " << alphaclmax
493 << " Minimum Alpha: " << alphaclmin
499 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
501 void FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg) {
506 AC_cfg->GetNextConfigLine();
508 while ((token = AC_cfg->GetValue()) != "/PROPULSION") {
509 *AC_cfg >> parameter;
511 if (parameter == "AC_ENGINE") {
513 *AC_cfg >> engine_name;
514 Engine[numEngines] = new FGEngine(FDMExec, EnginePath, engine_name, numEngines);
517 } else if (parameter == "AC_TANK") {
519 Tank[numTanks] = new FGTank(AC_cfg);
520 switch(Tank[numTanks]->GetType()) {
522 numSelectedFuelTanks++;
524 case FGTank::ttOXIDIZER:
525 numSelectedOxiTanks++;
533 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
535 void FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg) {
538 FCS->LoadFCS(AC_cfg);
541 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
543 void FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg) {
546 AC_cfg->GetNextConfigLine();
548 while ((token = AC_cfg->GetValue()) != "/AERODYNAMICS") {
549 if (token == "AXIS") {
551 axis = AC_cfg->GetValue("NAME");
552 AC_cfg->GetNextConfigLine();
553 while ((token = AC_cfg->GetValue()) != "/AXIS") {
554 ca.push_back(new FGCoefficient(FDMExec, AC_cfg));
555 DisplayCoeffFactors(ca.back()->Getmultipliers());
557 Coeff[AxisIdx[axis]]=ca;
558 AC_cfg->GetNextConfigLine();
563 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
565 void FGAircraft::ReadUndercarriage(FGConfigFile* AC_cfg) {
568 AC_cfg->GetNextConfigLine();
570 while ((token = AC_cfg->GetValue()) != "/UNDERCARRIAGE") {
571 lGear.push_back(FGLGear(AC_cfg, FDMExec));
575 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
577 void FGAircraft::ReadOutput(FGConfigFile* AC_cfg) {
578 string token, parameter;
582 token = AC_cfg->GetValue("NAME");
583 Output->SetFilename(token);
584 token = AC_cfg->GetValue("TYPE");
585 Output->SetType(token);
586 AC_cfg->GetNextConfigLine();
588 while ((token = AC_cfg->GetValue()) != "/OUTPUT") {
589 *AC_cfg >> parameter;
590 if (parameter == "RATE_IN_HZ") *AC_cfg >> OutRate;
591 if (parameter == "SIMULATION") {
592 *AC_cfg >> parameter;
593 if (parameter == "ON") subsystems += ssSimulation;
595 if (parameter == "AEROSURFACES") {
596 *AC_cfg >> parameter;
597 if (parameter == "ON") subsystems += ssAerosurfaces;
599 if (parameter == "RATES") {
600 *AC_cfg >> parameter;
601 if (parameter == "ON") subsystems += ssRates;
603 if (parameter == "VELOCITIES") {
604 *AC_cfg >> parameter;
605 if (parameter == "ON") subsystems += ssVelocities;
607 if (parameter == "FORCES") {
608 *AC_cfg >> parameter;
609 if (parameter == "ON") subsystems += ssForces;
611 if (parameter == "MOMENTS") {
612 *AC_cfg >> parameter;
613 if (parameter == "ON") subsystems += ssMoments;
615 if (parameter == "ATMOSPHERE") {
616 *AC_cfg >> parameter;
617 if (parameter == "ON") subsystems += ssAtmosphere;
619 if (parameter == "MASSPROPS") {
620 *AC_cfg >> parameter;
621 if (parameter == "ON") subsystems += ssMassProps;
623 if (parameter == "POSITION") {
624 *AC_cfg >> parameter;
625 if (parameter == "ON") subsystems += ssPosition;
627 if (parameter == "COEFFICIENTS") {
628 *AC_cfg >> parameter;
629 if (parameter == "ON") subsystems += ssCoefficients;
631 if (parameter == "GROUND_REACTIONS") {
632 *AC_cfg >> parameter;
633 if (parameter == "ON") subsystems += ssGroundReactions;
635 if (parameter == "FCS") {
636 *AC_cfg >> parameter;
637 if (parameter == "ON") subsystems += ssFCS;
641 Output->SetSubsystems(subsystems);
643 OutRate = OutRate>120?120:(OutRate<0?0:OutRate);
644 Output->SetRate( (int)(0.5 + 1.0/(State->Getdt()*OutRate)) );
647 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
649 void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg) {
650 string token = AC_cfg->GetValue();
652 AircraftName = AC_cfg->GetValue("NAME");
653 cout << "Reading Aircraft Configuration File: " << AircraftName << endl;
654 scratch=AC_cfg->GetValue("VERSION").c_str();
656 CFGVersion = AC_cfg->GetValue("VERSION");
657 cout << " Version: " << CFGVersion << endl;
658 if (CFGVersion != NEEDED_CFG_VERSION) {
659 cout << endl << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
660 " RESULTS WILL BE UNPREDICTABLE !!" << endl;
661 cout << "Current version needed is: " << NEEDED_CFG_VERSION << endl;
662 cout << " You have version: " << CFGVersion << endl << endl;
669 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
671 void FGAircraft::DisplayCoeffFactors(vector <eParam> multipliers) {
672 cout << " Non-Dimensionalized by: ";
674 for (unsigned int i=0; i<multipliers.size();i++)
675 cout << State->paramdef[multipliers[i]];
680 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
682 string FGAircraft::GetCoefficientStrings(void) {
683 string CoeffStrings = "";
684 bool firstime = true;
686 for (unsigned int axis = 0; axis < 6; axis++) {
687 for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
691 CoeffStrings += ", ";
693 CoeffStrings += Coeff[axis][sd]->Getname();
700 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
702 string FGAircraft::GetCoefficientValues(void) {
703 string SDValues = "";
705 bool firstime = true;
707 for (unsigned int axis = 0; axis < 6; axis++) {
708 for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
714 sprintf(buffer, "%9.6f", Coeff[axis][sd]->GetSD());
715 SDValues += string(buffer);
722 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
724 string FGAircraft::GetGroundReactionStrings(void) {
725 string GroundReactionStrings = "";
726 bool firstime = true;
728 for (unsigned int i=0;i<lGear.size();i++) {
729 if (!firstime) GroundReactionStrings += ", ";
730 GroundReactionStrings += (lGear[i].GetName() + "_WOW, ");
731 GroundReactionStrings += (lGear[i].GetName() + "_compressLength, ");
732 GroundReactionStrings += (lGear[i].GetName() + "_compressSpeed, ");
733 GroundReactionStrings += (lGear[i].GetName() + "_Force");
738 return GroundReactionStrings;
741 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
743 string FGAircraft::GetGroundReactionValues(void) {
745 string GroundReactionValues = "";
747 bool firstime = true;
749 for (unsigned int i=0;i<lGear.size();i++) {
750 if (!firstime) GroundReactionValues += ", ";
751 GroundReactionValues += string( lGear[i].GetWOW()?"1":"0" ) + ", ";
752 GroundReactionValues += (string(gcvt(lGear[i].GetCompLen(), 5, buff)) + ", ");
753 GroundReactionValues += (string(gcvt(lGear[i].GetCompVel(), 6, buff)) + ", ");
754 GroundReactionValues += (string(gcvt(lGear[i].GetCompForce(), 10, buff)));
759 return GroundReactionValues;