40 #include "FGKinemat.h"
41 #include "input_output/FGXMLElement.h"
42 #include "models/FGFCS.h"
55 CheckInputNodes(1, 1, element);
60 if (element->
FindElement(
"noscale")) DoScale =
false;
64 while (setting_element) {
67 Detents.push_back(tmpDetent);
68 TransitionTimes.push_back(tmpTime);
72 if (Detents.size() <= 1) {
74 s <<
"Kinematic component " << Name
75 <<
" must have more than 1 setting element";
76 cerr << element->
ReadFrom() << endl << s.str() << endl;
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;
176 void FGKinemat::Debug(
int from)
178 if (debug_lvl <= 0)
return;
182 cout <<
" INPUT: " << InputNodes[0]->GetName() << endl;
183 cout <<
" DETENTS: " << Detents.size() << endl;
184 for (
unsigned int i=0;i<Detents.size();i++) {
185 cout <<
" " << Detents[i] <<
" " << TransitionTimes[i] << endl;
187 for (
auto node: OutputNodes)
188 cout <<
" OUTPUT: " << node->getNameString() << endl;
189 if (!DoScale) cout <<
" NOSCALE" << endl;
192 if (debug_lvl & 2 ) {
193 if (from == 0) cout <<
"Instantiated: FGKinemat" << endl;
194 if (from == 1) cout <<
"Destroyed: FGKinemat" << endl;
196 if (debug_lvl & 4 ) {
198 if (debug_lvl & 8 ) {
200 if (debug_lvl & 16) {
202 if (debug_lvl & 64) {