+FGJSBsim::FGJSBsim( double dt )
+ : FGInterface(dt)
+{
+ bool result;
+
+ fdmex=new FGFDMExec;
+
+ State = fdmex->GetState();
+ Atmosphere = fdmex->GetAtmosphere();
+ FCS = fdmex->GetFCS();
+ MassBalance = fdmex->GetMassBalance();
+ Propulsion = fdmex->GetPropulsion();
+ Aircraft = fdmex->GetAircraft();
+ Translation = fdmex->GetTranslation();
+ Rotation = fdmex->GetRotation();
+ Position = fdmex->GetPosition();
+ Auxiliary = fdmex->GetAuxiliary();
+ Aerodynamics = fdmex->GetAerodynamics();
+
+ Atmosphere->UseInternal();
+
+ fgic=new FGInitialCondition(fdmex);
+ needTrim=true;
+
+ SGPath aircraft_path( globals->get_fg_root() );
+ aircraft_path.append( "Aircraft" );
+
+ SGPath engine_path( globals->get_fg_root() );
+ engine_path.append( "Engine" );
+ set_delta_t( dt );
+ State->Setdt( dt );
+
+ result = fdmex->LoadModel( aircraft_path.str(),
+ engine_path.str(),
+ fgGetString("/sim/aircraft") );
+
+
+ if (result) {
+ SG_LOG( SG_FLIGHT, SG_INFO, " loaded aircraft.");
+ } else {
+ SG_LOG( SG_FLIGHT, SG_INFO,
+ " aircraft does not exist (you may have mis-typed the name).");
+ throw(-1);
+ }
+
+ int Neng = Propulsion->GetNumEngines();
+ SG_LOG(SG_FLIGHT,SG_INFO, "Neng: " << Neng );
+
+ for(int i=0;i<Neng;i++) {
+ add_engine( FGEngInterface() );
+ }
+
+ fgSetDouble("/fdm/trim/pitch-trim", FCS->GetPitchTrimCmd());
+ fgSetDouble("/fdm/trim/throttle", FCS->GetThrottleCmd(0));
+ fgSetDouble("/fdm/trim/aileron", FCS->GetDaCmd());
+ fgSetDouble("/fdm/trim/rudder", FCS->GetDrCmd());
+
+ startup_trim = fgGetNode("/sim/startup/trim", true);
+
+ trimmed = fgGetNode("/fdm/trim/trimmed", true);
+ trimmed->setBoolValue(false);
+
+ pitch_trim = fgGetNode("/fdm/trim/pitch-trim", true );
+ throttle_trim = fgGetNode("/fdm/trim/throttle", true );
+ aileron_trim = fgGetNode("/fdm/trim/aileron", true );
+ rudder_trim = fgGetNode("/fdm/trim/rudder", true );
+}
+
+/******************************************************************************/
+FGJSBsim::~FGJSBsim(void) {
+ if (fdmex != NULL) {
+ delete fdmex; fdmex=NULL;
+ delete fgic; fgic=NULL;
+ }
+}
+
+/******************************************************************************/
+