#include <FGFDMExec.h> #include <sg_path.hxx> using namespace std;
int main(int argc, char **argv) { JSBSim::FGFDMExec FDMExec; bool result = true; FDMExec.LoadScript(SGPath::fromUtf8(argv[1])); while (result) result = FDMExec.Run(); }
// First build the inertial model since some other models are relying on // the inertial model and the ground callback to build themselves. // Note that this does not affect the order in which the models will be // executed later. Models[eInertial] = new FGInertial(this);
// See the eModels enum specification in the header file. The order of the // enums specifies the order of execution. The Models[] vector is the primary // storage array for the list of models. Models[ePropagate] = new FGPropagate(this); Models[eInput] = new FGInput(this); Models[eAtmosphere] = new FGStandardAtmosphere(this); ...
// Assign the Model shortcuts for internal executive use only. Propagate = (FGPropagate*)Models[ePropagate]; Inertial = (FGInertial*)Models[eInertial]; Atmosphere = (FGAtmosphere*)Models[eAtmosphere]; ...
// Initialize models for (unsigned int i = 0; i < Models.size(); i++) { // The Input/Output models must not be initialized prior to IC loading if (i == eInput || i == eOutput) continue;
void FGFDMExec::LoadInputs(unsigned int idx) { switch(idx) { case ePropagate: Propagate->in.vPQRidot = Accelerations->GetPQRidot(); Propagate->in.vUVWidot = Accelerations->GetUVWidot(); Propagate->in.DeltaT = dT; break; case eInput: break; case eInertial: Inertial->in.Position = Propagate->GetLocation(); break; case eAtmosphere: Atmosphere->in.altitudeASL = Propagate->GetAltitudeASL(); break; case eWinds: Winds->in.AltitudeASL = Propagate->GetAltitudeASL(); Winds->in.DistanceAGL = Propagate->GetDistanceAGL(); ... break; case eAuxiliary: Auxiliary->in.Pressure = Atmosphere->GetPressure(); Auxiliary->in.Density = Atmosphere->GetDensity(); ... break; case eSystems: // Dynamic inputs come into the components that FCS manages through properties break; case ePropulsion: Propulsion->in.Pressure = Atmosphere->GetPressure(); ...
break; case eAerodynamics: Aerodynamics->in.Alpha = Auxiliary->Getalpha(); ... break; case eGroundReactions: // There are no external inputs to this model. GroundReactions->in.Vground = Auxiliary->GetVground(); ... break; case eExternalReactions: // There are no external inputs to this model. break; case eBuoyantForces: BuoyantForces->in.Density = Atmosphere->GetDensity(); ... break; case eMassBalance: MassBalance->in.GasInertia = BuoyantForces->GetGasMassInertia(); MassBalance->in.GasMass = BuoyantForces->GetGasMass(); ... break; case eAircraft: Aircraft->in.AeroForce = Aerodynamics->GetForces(); Aircraft->in.PropForce = Propulsion->GetForces(); ... break; case eAccelerations: Accelerations->in.J = MassBalance->GetJ(); Accelerations->in.Jinv = MassBalance->GetJinv(); ... break; default: break; } }