41#include "input_output/FGXMLElement.h"
42#include "models/FGFCS.h"
43#include "input_output/FGLog.h"
56 CheckInputNodes(1, 1, element);
61 if (element->
FindElement(
"noscale")) DoScale =
false;
65 while (setting_element) {
68 Detents.push_back(tmpDetent);
69 TransitionTimes.push_back(tmpTime);
73 if (Detents.size() <= 1) {
75 err <<
"\nKinematic component " << Name
76 <<
" must have more than 1 setting element\n";
80 bind(element, fcs->GetPropertyManager().get());
98 Input = InputNodes[0]->getDoubleValue();
100 if (DoScale) Input *= Detents.back();
102 if (!OutputNodes.empty())
103 Output = OutputNodes[0]->getDoubleValue();
105 Input =
Constrain(Detents.front(), Input, Detents.back());
107 if (fcs->GetTrimStatus())
117 for (ind = 1; (Input < Output) ? Detents[ind] < Output : Detents[ind] <= Output ; ++ind)
118 if (ind >= Detents.size())
123 if (TransitionTimes[ind] <= 0.0) {
128 double Rate = (Detents[ind] - Detents[ind-1])/TransitionTimes[ind];
130 double ThisInput =
Constrain(Detents[ind-1], Input, Detents[ind]);
132 double ThisDt = fabs((ThisInput-Output)/Rate);
138 Output += ThisDt*Rate;
140 Output -= ThisDt*Rate;
176void FGKinemat::Debug(
int from)
178 if (debug_lvl <= 0)
return;
183 log <<
" INPUT: " << InputNodes[0]->GetName() <<
"\n";
184 log <<
" DETENTS: " << Detents.size() << fixed << setprecision(4) <<
"\n";
185 for (
unsigned int i=0;i<Detents.size();i++) {
186 log <<
" " << Detents[i] <<
" " << TransitionTimes[i] <<
"\n";
188 for (
auto node: OutputNodes)
189 log <<
" OUTPUT: " << node->getNameString() <<
"\n";
190 if (!DoScale) log <<
" NOSCALE\n";
193 if (debug_lvl & 2 ) {
194 FGLogging log(LogLevel::DEBUG);
195 if (from == 0) log <<
"Instantiated: FGKinemat\n";
196 if (from == 1) log <<
"Destroyed: FGKinemat\n";
198 if (debug_lvl & 4 ) {
200 if (debug_lvl & 8 ) {
202 if (debug_lvl & 16) {
204 if (debug_lvl & 64) {
Element * FindElement(const std::string &el="")
Searches for a specified element.
Element * FindNextElement(const std::string &el="")
Searches for the next element as specified.
double FindElementValueAsNumber(const std::string &el="")
Searches for the named element and returns the data belonging to it as a number.
Base class for JSBSim Flight Control System Components.
Encapsulates the Flight Control System (FCS) functionality.
static bool EqualToRoundoff(double a, double b)
Finite precision comparison.
static constexpr double Constrain(double min, double value, double max)
Constrain a value between a minimum and a maximum value.
bool Run(void) override
Run method, overrides FGModel::Run().
FGKinemat(FGFCS *fcs, Element *element)
Constructor.
Main namespace for the JSBSim Flight Dynamics Model.