37 #ifndef FGFDMEXEC_HEADER_H
38 #define FGFDMEXEC_HEADER_H
46 #include "models/FGPropagate.h"
47 #include "models/FGOutput.h"
48 #include "math/FGTemplateFunc.h"
61 class FGAccelerations;
64 class FGBuoyantForces;
65 class FGExternalReactions;
66 class FGGroundReactions;
186 std::unique_ptr<FGFDMExec> exec;
201 void Run(
void) {exec->Run();}
203 exec->GetPropagate()->SetVState(source_prop->GetVState());
224 enum eModels { ePropagate=0,
240 eNumStandardModels };
260 bool LoadPlanet(
const SGPath& PlanetPath,
bool useAircraftPath =
true);
277 bool LoadModel(
const SGPath& AircraftPath,
const SGPath& EnginePath,
278 const SGPath& SystemsPath,
const std::string& model,
279 bool addModelToPath =
true);
291 bool LoadModel(
const std::string& model,
bool addModelToPath =
true);
304 bool LoadScript(
const SGPath& Script,
double deltaT=0.0,
305 const SGPath& initfile=SGPath());
314 EnginePath = GetFullPath(path);
326 AircraftPath = GetFullPath(path);
337 SystemsPath = GetFullPath(path);
348 OutputPath = GetFullPath(path);
355 std::shared_ptr<FGAtmosphere> GetAtmosphere(
void)
const;
357 std::shared_ptr<FGAccelerations> GetAccelerations(
void)
const;
359 std::shared_ptr<FGWinds> GetWinds(
void)
const;
361 std::shared_ptr<FGFCS> GetFCS(
void)
const;
363 std::shared_ptr<FGPropulsion> GetPropulsion(
void)
const;
365 std::shared_ptr<FGMassBalance> GetMassBalance(
void)
const;
367 std::shared_ptr<FGAerodynamics> GetAerodynamics(
void)
const;
369 std::shared_ptr<FGInertial> GetInertial(
void)
const;
371 std::shared_ptr<FGGroundReactions> GetGroundReactions(
void)
const;
373 std::shared_ptr<FGExternalReactions> GetExternalReactions(
void)
const;
375 std::shared_ptr<FGBuoyantForces> GetBuoyantForces(
void)
const;
377 std::shared_ptr<FGAircraft> GetAircraft(
void)
const;
379 std::shared_ptr<FGPropagate> GetPropagate(
void)
const;
381 std::shared_ptr<FGAuxiliary> GetAuxiliary(
void)
const;
383 std::shared_ptr<FGInput> GetInput(
void)
const;
385 std::shared_ptr<FGOutput> GetOutput(
void)
const;
387 std::shared_ptr<FGScript>
GetScript(
void)
const {
return Script;}
389 std::shared_ptr<FGInitialCondition>
GetIC(
void)
const {
return IC;}
391 std::shared_ptr<FGTrim> GetTrim(
void);
409 {
return instance->GetNode()->GetDouble(property); }
415 { instance->GetNode()->SetDouble(property, value); }
423 std::vector <std::string> EnumerateFDMs(
void);
447 {
return Output->SetDirectivesFile(GetFullPath(fname)); }
459 bool SetOutputFileName(
const int n,
const std::string& fname) {
return Output->SetOutputName(n, fname); }
476 void DoTrim(
int mode);
483 void Hold(
void) {holding =
true;}
487 void CheckIncrementalHold(
void);
493 static const int START_NEW_OUTPUT = 0x1;
494 static const int DONT_EXECUTE_RUN_IC = 0x2;
502 void ResetToInitialConditions(
int mode);
526 std::string QueryPropertyCatalog(
const std::string& check,
const std::string& end_of_line=
"\n");
529 void PrintPropertyCatalog(
void);
532 void PrintSimulationConfiguration(
void)
const;
534 std::vector<std::string>& GetPropertyCatalog(
void) {
return PropertyCatalog;}
536 void SetTrimStatus(
bool status){ trim_status = status; }
537 bool GetTrimStatus(
void)
const {
return trim_status; }
538 void SetTrimMode(
int mode){ ta_mode = mode; }
539 int GetTrimMode(
void)
const {
return ta_mode; }
541 std::string GetPropulsionTankReport()
const;
562 double Setsim_time(
double cur_time);
566 void Setdt(
double delta_t) { dT = delta_t; }
590 double IncrTime(
void);
606 void SetHoldDown(
bool hd);
613 FGTemplateFunc_ptr GetTemplateFunc(
const std::string& name) {
614 return TemplateFunctions.count(name) ? TemplateFunctions[name] :
nullptr;
617 void AddTemplateFunc(
const std::string& name, Element* el) {
618 TemplateFunctions[name] = std::make_shared<FGTemplateFunc>(
this, el);
621 auto GetRandomGenerator(
void)
const {
return RandomGenerator; }
627 unsigned short Terminate;
632 bool IncrementThenHolding;
633 int TimeStepsUntilHold;
637 std::string modelName;
639 SGPath FullAircraftPath;
643 std::string CFGVersion;
649 FGPropagate* Propagate;
650 FGInertial* Inertial;
651 FGAtmosphere* Atmosphere;
653 FGAuxiliary* Auxiliary;
655 FGPropulsion* Propulsion;
656 FGAerodynamics* Aerodynamics;
657 FGGroundReactions* GroundReactions;
658 FGExternalReactions* ExternalReactions;
659 FGBuoyantForces* BuoyantForces;
660 FGMassBalance* MassBalance;
661 FGAircraft* Aircraft;
662 FGAccelerations* Accelerations;
670 std::shared_ptr<FGInitialCondition> IC;
671 std::shared_ptr<FGScript> Script;
672 std::shared_ptr<FGTrim> Trim;
674 FGPropertyNode_ptr Root;
675 std::shared_ptr<FGPropertyManager> instance;
679 unsigned int RandomSeed;
680 std::shared_ptr<RandomNumberGenerator> RandomGenerator;
684 std::shared_ptr<unsigned int> FDMctr;
686 std::vector <std::string> PropertyCatalog;
687 std::vector <std::shared_ptr<childData>> ChildFDMList;
688 std::vector <std::shared_ptr<FGModel>> Models;
689 std::map<std::string, FGTemplateFunc_ptr> TemplateFunctions;
691 bool ReadFileHeader(Element*);
692 bool ReadChild(Element*);
693 bool ReadPrologue(Element*);
695 int SRand(
void)
const {
return RandomSeed;}
696 void LoadInputs(
unsigned int idx);
697 void LoadPlanetConstants(
void);
698 bool LoadPlanet(Element* el);
699 void LoadModelConstants(
void);
701 bool DeAllocate(
void);
702 void InitializeModels(
void);
703 int GetDisperse(
void)
const {
return disperse;}
704 SGPath GetFullPath(
const SGPath& name) {
705 if (name.isRelative())
706 return RootDir/name.utf8Str();
711 void Debug(
int from);
This class implements a 3 element column vector.
Encapsulates the JSBSim simulation executive.
std::shared_ptr< FGInitialCondition > GetIC(void) const
Returns a pointer to the FGInitialCondition object.
bool GetHoldDown(void) const
Gets the value of the property forces/hold-down.
void EnableOutput(void)
Enables data logging to all outputs.
void SetPropertyValue(const std::string &property, double value)
Sets a property value.
const SGPath & GetEnginePath(void)
Retrieves the engine path.
const SGPath & GetAircraftPath(void)
Retrieves the aircraft path.
void ForceOutput(int idx=0)
Forces the specified output object to print its items once.
bool SetSystemsPath(const SGPath &path)
Set the path to the systems config file directories.
bool SetOutputFileName(const int n, const std::string &fname)
Sets (or overrides) the output filename.
const SGPath & GetFullAircraftPath(void)
Retrieves the full aircraft path name.
void SetDebugLevel(int level)
Sets the debug level.
double GetPropertyValue(const std::string &property)
Retrieves the value of a property.
bool SetEnginePath(const SGPath &path)
Set the path to the engine config file directories.
const SGPath & GetSystemsPath(void)
Retrieves the systems path.
int GetDebugLevel(void) const
Retrieves the current debug level setting.
void SetLoggingRate(double rate)
Sets the logging rate in Hz for all output objects (if any).
const SGPath & GetRootDir(void) const
Retrieve the Root Directory.
bool SetOutputPath(const SGPath &path)
Set the directory where the output files will be written.
void EnableIncrementThenHold(int Timesteps)
Turn on hold after increment.
void SetRootDir(const SGPath &rootDir)
Set the root directory that is used to obtain absolute paths from relative paths.
std::string GetOutputFileName(int n) const
Retrieves the current output filename.
double GetDeltaT(void) const
Returns the simulation delta T.
size_t GetFDMCount(void) const
Gets the number of child FDMs.
unsigned int GetFrame(void) const
Retrieves the current frame count.
void Resume(void)
Resumes execution from a "Hold".
void DisableOutput(void)
Disables data logging to all outputs.
bool IntegrationSuspended(void) const
Returns the simulation suspension state.
bool SetOutputDirectives(const SGPath &fname)
Sets the output (logging) mechanism for this run.
void Unbind(void)
Unbind all tied JSBSim properties.
void SetChild(bool ch)
Marks this instance of the Exec object as a "child" object.
double GetSimTime(void) const
Returns the cumulative simulation time in seconds.
const std::string & GetModelName(void) const
Returns the model name.
void Setdt(double delta_t)
Sets the integration time step for the simulation executive.
void SuspendIntegration(void)
Suspends the simulation and sets the delta T to zero.
const SGPath & GetOutputPath(void)
Retrieves the path to the output files.
void Hold(void)
Pauses execution by preventing time from incrementing.
bool SetAircraftPath(const SGPath &path)
Set the path to the aircraft config file directories.
auto GetChildFDM(int i) const
Gets a particular child FDM.
std::shared_ptr< FGPropertyManager > GetPropertyManager(void) const
Returns a pointer to the property manager object.
std::shared_ptr< FGScript > GetScript(void) const
Retrieves the script object.
void ResumeIntegration(void)
Resumes the simulation by resetting delta T to the correct value.
bool Holding(void)
Returns true if the simulation is Holding (i.e. simulation time is not moving).
Initializes the simulation run.
Models the EOM and integration/propagation of state.
FGPropertyNode_ptr node
The node for the property.
std::string base_string
Name of the property.