JSBSim Flight Dynamics Model 1.3.0 (09 Apr 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGStateSpace::Component Class Referenceabstract

Detailed Description

Definition at line 43 of file FGStateSpace.h.

+ Inheritance diagram for FGStateSpace::Component:
+ Collaboration diagram for FGStateSpace::Component:

Public Member Functions

 Component (const std::string &name, const std::string &unit)
 
virtual double get () const =0
 
virtual double getDeriv () const
 
const std::string & getName () const
 
const std::string & getUnit () const
 
virtual void set (double val)=0
 
void setFdm (FGFDMExec *fdm)
 
void setStateSpace (FGStateSpace *stateSpace)
 

Protected Attributes

FGFDMExecm_fdm
 
std::string m_name
 
FGStateSpacem_stateSpace
 
std::string m_unit
 

Constructor & Destructor Documentation

◆ Component()

Component ( const std::string &  name,
const std::string &  unit 
)
inline

Definition at line 50 of file FGStateSpace.h.

50 :
51 m_stateSpace(), m_fdm(), m_name(name), m_unit(unit) {};

◆ ~Component()

virtual ~Component ( )
inlinevirtual

Definition at line 52 of file FGStateSpace.h.

52{};

Member Function Documentation

◆ getDeriv()

virtual double getDeriv ( ) const
inlinevirtual

Definition at line 55 of file FGStateSpace.h.

56 {
57 // by default should calculate using finite difference approx
58 std::vector<double> x0 = m_stateSpace->x.get();
59 double f0 = get();
60 double dt0 = m_fdm->GetDeltaT();
61 double time0 = m_fdm->GetSimTime();
62 m_fdm->Setdt(1./120.);
63 m_fdm->DisableOutput();
64 m_fdm->Run();
65 double f1 = get();
66 m_stateSpace->x.set(x0);
67 if (m_fdm->GetDebugLevel() > 1)
68 {
69 FGLogging log(LogLevel::DEBUG);
70 log << std::scientific
71 << "name: " << m_name
72 << "\nf1: " << f0
73 << "\nf2: " << f1
74 << "\ndt: " << m_fdm->GetDeltaT()
75 << "\tdf/dt: " << (f1-f0)/m_fdm->GetDeltaT()
76 << std::fixed << "\n";
77 }
78 double deriv = (f1-f0)/m_fdm->GetDeltaT();
79 m_fdm->Setdt(dt0); // restore original value
80 m_fdm->Setsim_time(time0);
81 m_fdm->EnableOutput();
82 return deriv;
83 }
void EnableOutput(void)
Enables data logging to all outputs.
Definition FGFDMExec.h:487
int GetDebugLevel(void) const
Retrieves the current debug level setting.
Definition FGFDMExec.h:602
double GetDeltaT(void) const
Returns the simulation delta T.
Definition FGFDMExec.h:553
double Setsim_time(double cur_time)
Sets the current sim time.
bool Run(void)
This function executes each scheduled model in succession.
void DisableOutput(void)
Disables data logging to all outputs.
Definition FGFDMExec.h:485
double GetSimTime(void) const
Returns the cumulative simulation time in seconds.
Definition FGFDMExec.h:550
void Setdt(double delta_t)
Sets the integration time step for the simulation executive.
Definition FGFDMExec.h:572

◆ getName()

const std::string & getName ( ) const
inline

Definition at line 92 of file FGStateSpace.h.

93 {
94 return m_name;
95 }

◆ getUnit()

const std::string & getUnit ( ) const
inline

Definition at line 96 of file FGStateSpace.h.

97 {
98 return m_unit;
99 }

◆ setFdm()

void setFdm ( FGFDMExec fdm)
inline

Definition at line 88 of file FGStateSpace.h.

89 {
90 m_fdm = fdm;
91 }

◆ setStateSpace()

void setStateSpace ( FGStateSpace stateSpace)
inline

Definition at line 84 of file FGStateSpace.h.

85 {
86 m_stateSpace = stateSpace;
87 }

Member Data Documentation

◆ m_fdm

FGFDMExec* m_fdm
protected

Definition at line 47 of file FGStateSpace.h.

◆ m_name

std::string m_name
protected

Definition at line 48 of file FGStateSpace.h.

◆ m_stateSpace

FGStateSpace* m_stateSpace
protected

Definition at line 46 of file FGStateSpace.h.

◆ m_unit

std::string m_unit
protected

Definition at line 48 of file FGStateSpace.h.


The documentation for this class was generated from the following file: