84 current_test =
new Test;
87 current_test->Default =
true;
89 for (
unsigned int i=0;
i<
delay-1;
i++) {
93 tests.push_back(current_test);
97 while (test_element) {
98 current_test =
new Test;
102 tests.push_back(current_test);
113 for (
auto test: tests) {
114 delete test->condition;
126 double default_output=0.0;
135 for (
auto test: tests) {
137 default_output = test->OutputValue->GetValue();
139 pass = test->condition->Evaluate();
143 Output = test->OutputValue->GetValue();
148 if (!pass)
Output = default_output;
159void FGSwitch::VerifyProperties(
void)
161 for (
auto test: tests) {
162 if (!test->Default) {
163 test->condition->Evaluate();
165 test->OutputValue->GetValue();
188void FGSwitch::Debug(
int from)
195 for (
auto test: tests) {
197 cout <<
" Switch default value is: " << test->GetOutputName();
199 cout <<
" Switch takes test " <<
i <<
" value (" << test->GetOutputName() <<
")" << endl;
201 test->condition->PrintCondition(
" ");
207 cout <<
" OUTPUT: " << node->getNameString() << endl;
211 if (from == 0) cout <<
"Instantiated: FGSwitch" << endl;
212 if (from == 1) cout <<
"Destroyed: FGSwitch" << endl;
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
Element * FindElement(const std::string &el="")
Searches for a specified element.
Element * FindNextElement(const std::string &el="")
Searches for the next element as specified.
Encapsulates a condition, which is used in parts of JSBSim including switches.
FGFCSComponent(FGFCS *fcs, Element *el)
Constructor.
std::vector< double > output_array
FGPropertyManager * PropertyManager
virtual void bind(Element *el)
virtual void SetOutput(void)
std::vector< FGPropertyNode_ptr > OutputNodes
FGSwitch(FGFCS *fcs, Element *element)
Constructor.
bool Run(void) override
Executes the switch logic.
static double atof(const string &str)
bool is_number(const std::string &str)