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"
65class FGExternalReactions;
66class FGGroundReactions;
187 std::unique_ptr<FGFDMExec> exec;
202 void Run(
void) {exec->Run();}
204 exec->GetPropagate()->SetVState(source_prop->GetVState());
211 FGFDMExec(FGPropertyManager* root =
nullptr, std::shared_ptr<unsigned int> fdmctr =
nullptr);
225 enum eModels { ePropagate=0,
241 eNumStandardModels };
261 bool LoadPlanet(
const SGPath& PlanetPath,
bool useAircraftPath =
true);
278 bool LoadModel(
const SGPath& AircraftPath,
const SGPath& EnginePath,
279 const SGPath& SystemsPath,
const std::string& model,
280 bool addModelToPath =
true);
292 bool LoadModel(
const std::string& model,
bool addModelToPath =
true);
305 bool LoadScript(
const SGPath& Script,
double deltaT=0.0,
306 const SGPath& initfile=SGPath());
315 EnginePath = GetFullPath(path);
327 AircraftPath = GetFullPath(path);
338 SystemsPath = GetFullPath(path);
349 OutputPath = GetFullPath(path);
356 std::shared_ptr<FGAtmosphere> GetAtmosphere(
void)
const;
358 std::shared_ptr<FGAccelerations> GetAccelerations(
void)
const;
360 std::shared_ptr<FGWinds> GetWinds(
void)
const;
362 std::shared_ptr<FGFCS> GetFCS(
void)
const;
364 std::shared_ptr<FGPropulsion> GetPropulsion(
void)
const;
366 std::shared_ptr<FGMassBalance> GetMassBalance(
void)
const;
368 std::shared_ptr<FGAerodynamics> GetAerodynamics(
void)
const;
370 std::shared_ptr<FGInertial> GetInertial(
void)
const;
372 std::shared_ptr<FGGroundReactions> GetGroundReactions(
void)
const;
374 std::shared_ptr<FGExternalReactions> GetExternalReactions(
void)
const;
376 std::shared_ptr<FGBuoyantForces> GetBuoyantForces(
void)
const;
378 std::shared_ptr<FGAircraft> GetAircraft(
void)
const;
380 std::shared_ptr<FGPropagate> GetPropagate(
void)
const;
382 std::shared_ptr<FGAuxiliary> GetAuxiliary(
void)
const;
384 std::shared_ptr<FGInput> GetInput(
void)
const;
386 std::shared_ptr<FGOutput> GetOutput(
void)
const;
388 std::shared_ptr<FGScript>
GetScript(
void)
const {
return Script;}
390 std::shared_ptr<FGInitialCondition>
GetIC(
void)
const {
return IC;}
392 std::shared_ptr<FGTrim> GetTrim(
void);
410 {
return instance->GetNode()->getDoubleValue(property.c_str()); }
416 { instance->GetNode()->setDoubleValue(property.c_str(), value); }
424 std::vector <std::string> EnumerateFDMs(
void);
448 {
return Output->SetDirectivesFile(GetFullPath(fname)); }
460 bool SetOutputFileName(
const int n,
const std::string& fname) {
return Output->SetOutputName(n, fname); }
477 void DoTrim(
int mode);
482 void DoLinearization(
int);
489 void Hold(
void) {holding =
true;}
493 void CheckIncrementalHold(
void);
499 static const int START_NEW_OUTPUT = 0x1;
500 static const int DONT_EXECUTE_RUN_IC = 0x2;
508 void ResetToInitialConditions(
int mode);
532 std::string QueryPropertyCatalog(
const std::string& check,
const std::string& end_of_line=
"\n");
535 void PrintPropertyCatalog(
void);
538 void PrintSimulationConfiguration(
void)
const;
540 std::vector<std::string>& GetPropertyCatalog(
void) {
return PropertyCatalog;}
542 void SetTrimStatus(
bool status){ trim_status = status; }
543 bool GetTrimStatus(
void)
const {
return trim_status; }
544 void SetTrimMode(
int mode){ ta_mode = mode; }
545 int GetTrimMode(
void)
const {
return ta_mode; }
547 std::string GetPropulsionTankReport()
const;
568 double Setsim_time(
double cur_time);
572 void Setdt(
double delta_t) { dT = delta_t; }
596 double IncrTime(
void);
612 void SetHoldDown(
bool hd);
619 FGTemplateFunc_ptr GetTemplateFunc(
const std::string& name) {
620 return TemplateFunctions.count(name) ? TemplateFunctions[name] :
nullptr;
623 void AddTemplateFunc(
const std::string& name, Element* el) {
624 TemplateFunctions[name] = std::make_shared<FGTemplateFunc>(
this, el);
627 auto GetRandomGenerator(
void)
const {
return RandomGenerator; }
629 int SRand(
void)
const {
return RandomSeed; }
640 bool IncrementThenHolding;
641 int TimeStepsUntilHold;
645 std::string modelName;
647 SGPath FullAircraftPath;
651 std::string CFGVersion;
657 FGPropagate* Propagate;
658 FGInertial* Inertial;
659 FGAtmosphere* Atmosphere;
661 FGAuxiliary* Auxiliary;
663 FGPropulsion* Propulsion;
664 FGAerodynamics* Aerodynamics;
665 FGGroundReactions* GroundReactions;
666 FGExternalReactions* ExternalReactions;
667 FGBuoyantForces* BuoyantForces;
668 FGMassBalance* MassBalance;
669 FGAircraft* Aircraft;
670 FGAccelerations* Accelerations;
678 std::shared_ptr<FGInitialCondition> IC;
679 std::shared_ptr<FGScript> Script;
680 std::shared_ptr<FGTrim> Trim;
682 SGPropertyNode_ptr Root;
683 std::shared_ptr<FGPropertyManager> instance;
687 unsigned int RandomSeed;
688 std::shared_ptr<RandomNumberGenerator> RandomGenerator;
692 std::shared_ptr<unsigned int> FDMctr;
694 std::vector <std::string> PropertyCatalog;
695 std::vector <std::shared_ptr<childData>> ChildFDMList;
696 std::vector <std::shared_ptr<FGModel>> Models;
697 std::map<std::string, FGTemplateFunc_ptr> TemplateFunctions;
699 bool ReadFileHeader(Element*);
700 bool ReadChild(Element*);
701 bool ReadPrologue(Element*);
703 void LoadInputs(
unsigned int idx);
704 void LoadPlanetConstants(
void);
705 bool LoadPlanet(Element* el);
706 void LoadModelConstants(
void);
708 bool DeAllocate(
void);
709 void InitializeModels(
void);
710 int GetDisperse(
void)
const {
return disperse;}
711 SGPath GetFullPath(
const SGPath& name) {
712 if (name.isRelative())
713 return RootDir/name.utf8Str();
718 void Debug(
int from);
This class implements a 3 element column vector.
Encapsulates the JSBSim simulation executive.
const SGPath & GetOutputPath(void)
Retrieves the path to the output files.
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.
std::shared_ptr< FGInitialCondition > GetIC(void) const
Returns a pointer to the FGInitialCondition object.
const SGPath & GetRootDir(void) const
Retrieve the Root Directory.
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.
void SetDebugLevel(int level)
Sets the debug level.
const SGPath & GetAircraftPath(void)
Retrieves the aircraft path.
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.
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).
std::shared_ptr< FGScript > GetScript(void) const
Retrieves the script object.
bool SetOutputPath(const SGPath &path)
Set the directory where the output files will be written.
const SGPath & GetFullAircraftPath(void)
Retrieves the full aircraft path name.
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.
const SGPath & GetSystemsPath(void)
Retrieves the systems path.
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.
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.
std::shared_ptr< FGPropertyManager > GetPropertyManager(void) const
Returns a pointer to the property manager object.
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.
void ResumeIntegration(void)
Resumes the simulation by resetting delta T to the correct value.
const std::string & GetModelName(void) const
Returns the model name.
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.
Main namespace for the JSBSim Flight Dynamics Model.
SGPropertyNode_ptr node
The node for the property.
std::string base_string
Name of the property.