]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/flight_control/FGSwitch.cpp
sync with JSB JSBSim CVS
[flightgear.git] / src / FDM / JSBSim / models / flight_control / FGSwitch.cpp
index 63d9e9bbcd54ed1a07a8ecbfbbcf5c95823f0181..45b0a9921a9941335290d9ceaa831fe4cc127066 100644 (file)
@@ -62,10 +62,14 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGSwitch.h"
+#include <iostream>
+#include <cstdlib>
+
+using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGSwitch.cpp,v 1.22 2011/06/17 12:12:19 jberndt Exp $";
 static const char *IdHdr = ID_SWITCH;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -98,10 +102,6 @@ FGSwitch::FGSwitch(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
       }
       for (unsigned int i=0; i<test_element->GetNumDataLines(); i++) {
         string input_data = test_element->GetDataLine(i);
-        while (input_data[0] <= 32) {
-          input_data = input_data.erase(0,1);
-          if (input_data.size() <= 1) break;
-        }
         if (input_data.size() <= 1) {
           // Make sure there are no bad data lines that consist solely of whitespace
           cerr << fgred << "  Bad data line in switch component: " << Name << reset << endl;
@@ -119,8 +119,11 @@ FGSwitch::FGSwitch(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
       tests.push_back(current_test);
     }
 
-    if (test_element->GetName() != "output"
-        && test_element->GetName() != "description") { // this is not an output element
+    string el_name = test_element->GetName();
+    if (   el_name != "output"
+        && el_name != "description"
+        && el_name != "delay" )
+    {
       value = test_element->GetAttributeValue("value");
       if (value.empty()) {
         cerr << "No VALUE supplied for switch component: " << Name << endl;
@@ -135,7 +138,13 @@ FGSwitch::FGSwitch(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
           } else {
             current_test->sign = 1.0;
           }
-          current_test->OutputProp = PropertyManager->GetNode(value);
+          FGPropertyManager *node = PropertyManager->GetNode(value, false);
+          if (node) {
+            current_test->OutputProp = new FGPropertyValue(node);
+          } else {
+            current_test->OutputProp = new FGPropertyValue(value,
+                                                           PropertyManager);
+          }
         }
       }
     }
@@ -151,6 +160,7 @@ FGSwitch::~FGSwitch()
 {
   for (unsigned int i=0; i<tests.size(); i++) {
     for (unsigned int j=0; j<tests[i]->conditions.size(); j++) delete tests[i]->conditions[j];
+    delete tests[i]->OutputProp;
     delete tests[i];
   }
 
@@ -189,6 +199,7 @@ bool FGSwitch::Run(void )
   
   if (!pass) Output = default_output;
 
+  if (delay != 0) Delay();
   Clip();
   if (IsOutput) SetOutput();
 
@@ -265,7 +276,10 @@ void FGSwitch::Debug(int from)
         }
         cout << endl;
       }
-      if (IsOutput) cout << "      OUTPUT: " << OutputNode->getName() << endl;
+      if (IsOutput) {
+        for (unsigned int i=0; i<OutputNodes.size(); i++)
+          cout << "      OUTPUT: " << OutputNodes[i]->getName() << endl;
+      }
     }
   }
   if (debug_lvl & 2 ) { // Instantiation/Destruction notification