]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGFDMExec.cpp
Use tiedPropertyLists instead of manually matched tie/untie calls.
[flightgear.git] / src / FDM / JSBSim / FGFDMExec.cpp
index 8d29a688f2eb487acfbfc241018e7d9fab7aee03..d5c81f8217d5a6f7b3e8b33f30e9fb49f7facac9 100644 (file)
@@ -70,7 +70,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.114 2011/09/11 11:36:04 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.120 2011/11/10 12:06:13 jberndt Exp $";
 static const char *IdHdr = ID_FDMEXEC;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -82,10 +82,9 @@ CLASS IMPLEMENTATION
 
 FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), FDMctr(fdmctr)
 {
-
   Frame           = 0;
   Error           = 0;
-  GroundCallback  = 0;
+  SetGroundCallback(new FGDefaultGroundCallback());
   IC              = 0;
   Trim            = 0;
   Script          = 0;
@@ -210,7 +209,7 @@ bool FGFDMExec::Allocate(void)
   Models[ePropulsion]        = new FGPropulsion(this);
   Models[eAerodynamics]      = new FGAerodynamics (this);
 
-  GroundCallback  = new FGGroundCallback(((FGInertial*)Models[eInertial])->GetRefRadius());
+  GetGroundCallback()->SetSeaLevelRadius(((FGInertial*)Models[eInertial])->GetRefRadius());
 
   Models[eGroundReactions]   = new FGGroundReactions(this);
   Models[eExternalReactions] = new FGExternalReactions(this);
@@ -266,8 +265,6 @@ bool FGFDMExec::DeAllocate(void)
   delete IC;
   delete Trim;
 
-  delete GroundCallback;
-
   Error       = 0;
 
   modelLoaded = false;
@@ -303,11 +300,11 @@ bool FGFDMExec::Run(void)
     firstPass = false;
   }
 
+  IncrTime();
+
   // returns true if success, false if complete
   if (Script != 0 && !IntegrationSuspended()) success = Script->RunScript();
 
-  IncrTime();
-
   for (unsigned int i = 0; i < Models.size(); i++) {
     LoadInputs(i);
     Models[i]->Run(holding);
@@ -563,9 +560,7 @@ void FGFDMExec::Initialize(FGInitialCondition *FGIC)
   Propagate->InitializeDerivatives();
   LoadInputs(eAtmosphere);
   Atmosphere->Run(false);
-  Winds->SetWindNED( FGIC->GetWindNFpsIC(),
-                          FGIC->GetWindEFpsIC(),
-                          FGIC->GetWindDFpsIC() );
+  Winds->SetWindNED(FGIC->GetWindNEDFpsIC());
   Auxiliary->Run(false);
 }
 
@@ -617,14 +612,6 @@ string FGFDMExec::GetOutputFileName(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGFDMExec::SetGroundCallback(FGGroundCallback* p)
-{
-  delete GroundCallback;
-  GroundCallback = p;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
 vector <string> FGFDMExec::EnumerateFDMs(void)
 {
   vector <string> FDMList;
@@ -1138,7 +1125,7 @@ void FGFDMExec::ForceOutput(int idx)
 {
   if (idx >= (int)0 && idx < (int)Outputs.size()) Outputs[idx]->Print();
 }
-       
+
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 bool FGFDMExec::SetOutputDirectives(const string& fname)
@@ -1152,11 +1139,14 @@ bool FGFDMExec::SetOutputDirectives(const string& fname)
   result = Output->Load(0);
 
   if (result) {
+    Output->Run(holding);
     Outputs.push_back(Output);
     typedef double (FGOutput::*iOPMF)(void) const;
     string outputProp = CreateIndexedPropertyName("simulation/output",Outputs.size()-1);
     instance->Tie(outputProp+"/log_rate_hz", Output, (iOPMF)0, &FGOutput::SetRate, false);
   }
+  else
+    delete Output;
 
   return result;
 }