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;
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()->getDoubleValue(property.c_str()); }
415 { instance->GetNode()->setDoubleValue(property.c_str(), 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);
481 void DoLinearization(
int);
488 void Hold(
void) {holding =
true;}
492 void CheckIncrementalHold(
void);
498 static const int START_NEW_OUTPUT = 0x1;
499 static const int DONT_EXECUTE_RUN_IC = 0x2;
507 void ResetToInitialConditions(
int mode);
531 std::string QueryPropertyCatalog(
const std::string& check,
const std::string& end_of_line=
"\n");
534 void PrintPropertyCatalog(
void);
537 void PrintSimulationConfiguration(
void)
const;
539 std::vector<std::string>& GetPropertyCatalog(
void) {
return PropertyCatalog;}
541 void SetTrimStatus(
bool status){ trim_status = status; }
542 bool GetTrimStatus(
void)
const {
return trim_status; }
543 void SetTrimMode(
int mode){ ta_mode = mode; }
544 int GetTrimMode(
void)
const {
return ta_mode; }
546 std::string GetPropulsionTankReport()
const;
567 double Setsim_time(
double cur_time);
571 void Setdt(
double delta_t) { dT = delta_t; }
595 double IncrTime(
void);
611 void SetHoldDown(
bool hd);
618 FGTemplateFunc_ptr GetTemplateFunc(
const std::string& name) {
619 return TemplateFunctions.count(name) ? TemplateFunctions[name] :
nullptr;
622 void AddTemplateFunc(
const std::string& name, Element* el) {
623 TemplateFunctions[name] = std::make_shared<FGTemplateFunc>(
this, el);
626 auto GetRandomGenerator(
void)
const {
return RandomGenerator; }
628 int SRand(
void)
const {
return RandomSeed; }
639 bool IncrementThenHolding;
640 int TimeStepsUntilHold;
644 std::string modelName;
646 SGPath FullAircraftPath;
650 std::string CFGVersion;
656 FGPropagate* Propagate;
657 FGInertial* Inertial;
658 FGAtmosphere* Atmosphere;
660 FGAuxiliary* Auxiliary;
662 FGPropulsion* Propulsion;
663 FGAerodynamics* Aerodynamics;
664 FGGroundReactions* GroundReactions;
665 FGExternalReactions* ExternalReactions;
666 FGBuoyantForces* BuoyantForces;
667 FGMassBalance* MassBalance;
668 FGAircraft* Aircraft;
669 FGAccelerations* Accelerations;
677 std::shared_ptr<FGInitialCondition> IC;
678 std::shared_ptr<FGScript> Script;
679 std::shared_ptr<FGTrim> Trim;
681 SGPropertyNode_ptr Root;
682 std::shared_ptr<FGPropertyManager> instance;
686 unsigned int RandomSeed;
687 std::shared_ptr<RandomNumberGenerator> RandomGenerator;
691 std::shared_ptr<unsigned int> FDMctr;
693 std::vector <std::string> PropertyCatalog;
694 std::vector <std::shared_ptr<childData>> ChildFDMList;
695 std::vector <std::shared_ptr<FGModel>> Models;
696 std::map<std::string, FGTemplateFunc_ptr> TemplateFunctions;
698 bool ReadFileHeader(Element*);
699 bool ReadChild(Element*);
700 bool ReadPrologue(Element*);
702 void LoadInputs(
unsigned int idx);
703 void LoadPlanetConstants(
void);
704 bool LoadPlanet(Element* el);
705 void LoadModelConstants(
void);
707 bool DeAllocate(
void);
708 void InitializeModels(
void);
709 int GetDisperse(
void)
const {
return disperse;}
710 SGPath GetFullPath(
const SGPath& name) {
711 if (name.isRelative())
712 return RootDir/name.utf8Str();
717 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.
Class wrapper for property handling.
SGPropertyNode_ptr node
The node for the property.
std::string base_string
Name of the property.