Marine systems simulation
CSrcBase.h
1#ifndef C_SRC_BASE_H
2#define C_SRC_BASE_H
3
19#include "sfh/timers/Timer.h"
20
21#include <SimObject.h>
22
23class CSrcBase : public SimObject
24{
25 public:
27 CSrcBase(std::string sSimObjectName, ISimObjectCreator* pCreator);
28
30 virtual ~CSrcBase();
31
33 virtual void OdeFcn(const double dT, const double* const adX, double* const adXDot, const bool bIsMajorTimeStep){};
34
35#ifdef FH_VISUALIZATION
37 virtual void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator) { }
38
40 virtual void RenderUpdate(const double T, const double* const X) { }
41#endif
42
43 protected:
45 void ReadParameter(std::string sTag, double* adVals, double dDefault, ISimObjectCreator* pCreator);
46
48 bool ReadTwinParameters(std::string sTagA, double dDefaultA, std::string sTagB, double dDefaultB, double* adVals, ISimObjectCreator* pCreator);
49
51 virtual void CalcOutput(const double dT, const double* const adX) = 0;
52
54 virtual const double* Signal(const double dT, const double* const adX);
55
57 virtual const double* SignalDot(const double dT, const double* const adX);
58
59 double* m_adOutSignal;
62 sfh::timers::Timer m_OutputTimer;
63};
64
65
66#endif
Definition: CSrcBase.h:24
CSrcBase(std::string sSimObjectName, ISimObjectCreator *pCreator)
The constructor.
virtual const double * SignalDot(const double dT, const double *const adX)
The derivative of the output signal.
virtual void OdeFcn(const double dT, const double *const adX, double *const adXDot, const bool bIsMajorTimeStep)
Calculates the state derivatives.
Definition: CSrcBase.h:33
sfh::timers::Timer m_OutputTimer
Timer to ensure that signals are updated only once per timestep.
Definition: CSrcBase.h:62
virtual void CalcOutput(const double dT, const double *const adX)=0
Calculations of the output signals.
void ReadParameter(std::string sTag, double *adVals, double dDefault, ISimObjectCreator *pCreator)
Utility function to read a parameter.
virtual ~CSrcBase()
The destructor.
double * m_adOutSignal
The output signal.
Definition: CSrcBase.h:59
int m_iPortWidth
The width of the output port.
Definition: CSrcBase.h:61
bool ReadTwinParameters(std::string sTagA, double dDefaultA, std::string sTagB, double dDefaultB, double *adVals, ISimObjectCreator *pCreator)
Utility function to read a parameter with two possible representations or units.
virtual const double * Signal(const double dT, const double *const adX)
The output signal.
double * m_adOutSignalDot
The derivative of the output signal.
Definition: CSrcBase.h:60