AnimatLab  2
Test
Gain.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 namespace AnimatSim
10 {
11 
20  namespace Gains
21  {
35  class ANIMAT_PORT Gain : public AnimatBase
36  {
37  protected:
40 
43 
46 
49 
52 
63  bool InLimits(float fltInput)
64  {
65  if( m_bUseLimits && ( (fltInput < m_fltLowerLimit) || (fltInput > m_fltUpperLimit) ) )
66  return false;
67  else
68  return true;
69  }
70 
81  float CalculateLimitOutput(float fltInput)
82  {
83  if(fltInput < m_fltLowerLimit)
84  return m_fltLowerOutput;
85 
86  if(fltInput > m_fltUpperLimit)
87  return m_fltUpperOutput;
88 
89  return 0;
90  }
91 
92  public:
93  Gain();
94  virtual ~Gain();
95 
96  static Gain *CastToDerived(AnimatBase *lpBase) {return static_cast<Gain*>(lpBase);}
97 
98  bool UseLimits();
99  void UseLimits(bool bVal);
100 
101  float LowerLimit();
102  void LowerLimit(float fltVal);
103 
104  float UpperLimit();
105  void UpperLimit(float fltVal);
106 
107  float LowerOutput();
108  void LowerOutput(float fltVal);
109 
110  float UpperOutput();
111  void UpperOutput(float fltVal);
112 
113  virtual void Copy(CStdSerialize *lpSource);
114 
129  virtual float CalculateGain(float fltInput) = 0;
130 
131  virtual bool SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError = true);
132  virtual void QueryProperties(CStdPtrArray<TypeProperty> &aryProperties);
133  virtual void Load(CStdXml &oXml);
134  };
135 
136  Gain ANIMAT_PORT *LoadGain(Simulator *lpSim, std::string strName, CStdXml &oXml);
137 
138  } //Gains
139 } //AnimatSim
Root namespace for the base simulation library for AnimatLab.
float m_fltUpperLimit
The upper limit value that is checked if UseLimits is true.
Definition: Gain.h:48
The Gain base class.
Definition: Gain.h:35
bool InLimits(float fltInput)
Tells whether the input value is within the defined limit ranges.
Definition: Gain.h:63
float m_fltLowerLimit
The lower limit value that is checked if UseLimits is true.
Definition: Gain.h:42
Animat base class.
Definition: AnimatBase.h:36
float CalculateLimitOutput(float fltInput)
Calculates the output when the input is outside of the limit ranges.
Definition: Gain.h:81
float m_fltLowerOutput
The lower limit output that is used if UseLimits is true and the input is below the lower limit...
Definition: Gain.h:45
float m_fltUpperOutput
The upper limit output that is used if UseLimits is true and the input is above the upper limit...
Definition: Gain.h:51
bool m_bUseLimits
Determines whether or not the gain uses upper and lower limits during its calculations.
Definition: Gain.h:39
Gain * LoadGain(Simulator *lpSim, std::string strName, CStdXml &oXml)
Loads a gain object.
Definition: Gain.cpp:287