60 if (ptrSet && ptrSet->IsConstant()) {
61 set = ptrSet->GetValue() >= 0.5;
69 if (ptrReset && ptrReset->IsConstant()) {
70 reset = ptrReset->GetValue() >= 0.5;
78 if (ptrVersus && ptrVersus->IsConstant()) {
79 versus = ptrVersus->GetValue();
87 if (ptrBias && ptrBias->IsConstant()) {
88 bias = ptrBias->GetValue();
93 module = element->FindElementValueAsNumber("module");
95 cout <<
"FGLinearActuator::Run " <<
InputNodes[0]->GetNameWithSign()
96 <<
" <module> parameter is forced from " <<
module
97 << " value to 1.0 value" << endl;
104 if (hysteresis < 0) {
105 cout <<
"FGLinearActuator::Run " <<
InputNodes[0]->GetNameWithSign()
106 <<
" <hysteresis> parameter is forced from " << hysteresis
107 <<
" value to 0.0 value" << endl;
115 double denom = 2.00 +
dt*lag;
116 ca =
dt * lag / denom;
117 cb = (2.00 -
dt * lag) / denom;
118 previousLagInput = previousLagOutput = 0.0;
121 cout <<
"FGLinearActuator::Run " <<
InputNodes[0]->GetNameWithSign()
122 <<
" <lag> parameter is forced from "
123 << lag <<
" value to 0.0 value" << endl;
131 if (rate <= 0 || rate > 1.0) {
132 cout <<
"FGLinearActuator::Run " <<
InputNodes[0]->GetNameWithSign()
133 <<
" <rate> parameter is forced from " << rate
134 <<
" value to 0.5 value" << endl;
158 if (ptrSet && !ptrSet->IsConstant()) set = ptrSet->GetValue() >= 0.5;
159 if (ptrReset && !ptrReset->IsConstant()) reset = ptrReset->GetValue() >= 0.5;
170 double inputDelta =
Input - inputMem;
171 if (abs(inputDelta) >= hysteresis) {
172 if (ptrVersus && !ptrVersus->IsConstant()) {
173 versus = ptrVersus->GetValue();
176 }
else if (versus <= -0.5) {
180 if (abs(inputDelta) <= (module * rate)) {
181 if (inputDelta > 0.0) {
183 }
else if (inputDelta < 0.0) {
187 if ((versus == 0) || (versus == direction)) {
189 if (abs(inputDelta) >= (module*rate)) {
195 }
else if ((versus != 0) && (direction != 0) && (versus != direction)) {
196 inputLast += inputDelta;
200 if (ptrBias && !ptrBias->IsConstant()) {
201 bias = ptrBias->GetValue();
203 Output = gain * (bias + inputMem + module*countSpin);
208 Output = ca * (input + previousLagInput) + previousLagOutput * cb;
209 previousLagInput = input;
210 previousLagOutput =
Output;
236void FGLinearActuator::Debug(
int from)
242 cout <<
" INPUT: " <<
InputNodes[0]->GetNameWithSign() << endl;
243 cout <<
" inputMem: " << inputMem << endl;
244 cout <<
" bias: " << bias << endl;
245 cout <<
" module: " << module << endl;
246 cout <<
" hysteresis: " << hysteresis << endl;
247 cout <<
" rate: " << rate << endl;
248 cout <<
" versus: " << versus << endl;
249 cout <<
" direction: " << direction << endl;
250 cout <<
" countSpin: " << countSpin << endl;
251 cout <<
" Lag: " << lag << endl;
252 cout <<
" Gain: " << gain << endl;
253 cout <<
" set: " << set << endl;
254 cout <<
" reset: " << reset << endl;
256 cout <<
" OUTPUT: " << node->GetName() << endl;
260 if (from == 0) cout <<
"Instantiated: FGLinearActuator" << endl;
261 if (from == 1) cout <<
"Destroyed: FGLinearActuator" << endl;
double FindElementValueAsNumber(const std::string &el="")
Searches for the named element and returns the data belonging to it as a number.
std::string FindElementValue(const std::string &el="")
Searches for the named element and returns the string data belonging to it.
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)
FGPropertyManager * PropertyManager
virtual void bind(Element *el)
virtual void SetOutput(void)
std::vector< FGPropertyNode_ptr > OutputNodes
bool Run(void) override
The execution method for this FCS component.
~FGLinearActuator()
Destructor.
FGLinearActuator(FGFCS *fcs, Element *element)
Constructor.
Represents a either a real value or a property value.