54 Input_prev = Input_prev2 = 0.0;
56 ProcessVariableDot =
nullptr;
64 if (pid_type ==
"standard") IsStandard =
true;
75 if (integ_type ==
"rect") {
77 }
else if (integ_type ==
"trap") {
79 }
else if (integ_type ==
"ab2") {
81 }
else if (integ_type ==
"ab3") {
117 if (
Name.find(
"/") == string::npos) {
122 typedef double (
FGPID::*PMF)(void)
const;
123 PropertyManager->Tie(tmp+
"/initial-integrator-value",
this, (PMF)
nullptr,
137 delete ProcessVariableDot;
147 Input_prev = Input_prev2 =
Output = I_out_total = 0.0;
154 double I_out_delta = 0.0;
159 if (ProcessVariableDot) {
160 Dval = ProcessVariableDot->getDoubleValue();
162 Dval = (
Input - Input_prev)/
dt;
171 if (Trigger) test = Trigger->getDoubleValue();
173 if (fabs(test) < 0.000001) {
179 I_out_delta = 0.5 * (
Input + Input_prev);
182 I_out_delta = 1.5*
Input - 0.5*Input_prev;
185 I_out_delta = (23.0*
Input - 16.0*Input_prev + 5.0*Input_prev2) / 12.0;
194 if (test < 0.0) I_out_total = 0.0;
196 I_out_total += Ki->GetValue() *
dt * I_out_delta;
199 Output = Kp->GetValue() * (
Input + I_out_total + Kd->GetValue()*Dval);
201 Output = Kp->GetValue()*
Input + I_out_total + Kd->GetValue()*Dval;
203 Input_prev2 = test < 0.0 ? 0.0:Input_prev;
231void FGPID::Debug(
int from)
237 cout <<
" INPUT: " <<
InputNodes[0]->GetNameWithSign() << endl;
240 cout <<
" OUTPUT: " << node->getNameString() << endl;
244 if (from == 0) cout <<
"Instantiated: FGPID" << endl;
245 if (from == 1) cout <<
"Destroyed: FGPID" << endl;
std::string GetDataLine(unsigned int i=0)
Gets a line of data belonging to an element.
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
Element * FindElement(const std::string &el="")
Searches for a specified element.
FGFCSComponent(FGFCS *fcs, Element *el)
Constructor.
std::vector< FGPropertyValue_ptr > InputNodes
void CheckInputNodes(size_t MinNodes, size_t MaxNodes, Element *el)
virtual void ResetPastStates(void)
FGPropertyManager * PropertyManager
virtual void bind(Element *el)
virtual void SetOutput(void)
std::vector< FGPropertyNode_ptr > OutputNodes
void SetInitialOutput(double val)
void ResetPastStates(void) override
FGPID(FGFCS *fcs, Element *element)
Represents a either a real value or a property value.
std::string mkPropertyName(std::string name, bool lowercase)
Property-ify a name replaces spaces with '-' and, optionally, makes name all lower case.
Represents a property value which can use late binding.