]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGCoefficient.cpp
Updated to match changes in radiostack.[ch]xx
[flightgear.git] / src / FDM / JSBSim / FGCoefficient.cpp
index c752213815e5921c3299e27ddace56f4a21c173f..801571f4f3ef1a73c126d8b01463a092ae132a6c 100644 (file)
@@ -68,21 +68,31 @@ CLASS IMPLEMENTATION
 
 FGCoefficient::FGCoefficient( FGFDMExec* fdex )
 {
-
   FDMExec = fdex;
   State   = FDMExec->GetState();
   Table   = 0;
   
   PropertyManager = FDMExec->GetPropertyManager();
   
-  bias=0;
-  gain=1;
-  
+  Table = (FGTable*)0L;
   LookupR = LookupC = 0;
-  
-  totalValue = 0;
-
-  if (debug_lvl & 2) cout << "Instantiated: FGCoefficient" << endl;
+  numInstances = 0;
+  rows = columns = 0;
+
+  StaticValue  = 0.0;
+  totalValue   = 0.0;
+  bias = 0.0;
+  gain = 1.0;
+
+  filename.erase();
+  description.erase();
+  name.erase();
+  method.erase();
+  multparms.erase();
+  multparmsRow.erase();
+  multparmsCol.erase();
+
+  Debug(0);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -90,7 +100,7 @@ FGCoefficient::FGCoefficient( FGFDMExec* fdex )
 FGCoefficient::~FGCoefficient()
 {
   if (Table) delete Table;
-  if (debug_lvl & 2) cout << "Destroyed:    FGCoefficient" << endl;
+  Debug(1);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -122,13 +132,13 @@ bool FGCoefficient::Load(FGConfigFile *AC_cfg)
       }
 
       *AC_cfg >> multparmsRow;
-      prop = State->GetPropertyName( State->GetParameterIndex(multparmsRow) );
+      prop = State->GetPropertyName( multparmsRow );
       LookupR = PropertyManager->GetNode( prop );
     }
 
     if (type == TABLE) {
       *AC_cfg >> multparmsCol;
-      prop = State->GetPropertyName( State->GetParameterIndex(multparmsCol) );
+      prop = State->GetPropertyName( multparmsCol );
 
       LookupC = PropertyManager->GetNode( prop );
     }
@@ -147,13 +157,12 @@ bool FGCoefficient::Load(FGConfigFile *AC_cfg)
       while (n < end && n >= 0) {
         n -= start;
         mult = multparms.substr(start,n);
-        prop= State->GetPropertyName( State->GetParameterIndex(mult) );
+        prop= State->GetPropertyName( mult );
         multipliers.push_back( PropertyManager->GetNode(prop) );
         start += n+1;
         n = multparms.find("|",start);
       }
-      prop=State->GetPropertyName( 
-            State->GetParameterIndex( multparms.substr(start,n) ) );
+      prop=State->GetPropertyName( multparms.substr(start,n) );
       mult = multparms.substr(start,n);
       multipliers.push_back( PropertyManager->GetNode(prop) );
       // End of non-dimensionalizing parameter read-in
@@ -186,7 +195,6 @@ double FGCoefficient::Value(double rVal, double cVal)
   unsigned int midx;
 
   SD = Value = gain*Table->GetValue(rVal, cVal) + bias;
-  
 
   for (midx=0; midx < multipliers.size(); midx++) {
       Value *= multipliers[midx]->getDoubleValue();
@@ -227,31 +235,29 @@ double FGCoefficient::Value(void)
 double FGCoefficient::TotalValue(void)
 {
   switch(type) {
-  case 0:
-    totalValue=-1;
-    return totalValue;
-  case 1:
-    totalValue=Value();
-    return totalValue;
-  case 2:
-    totalValue=Value( LookupR->getDoubleValue() );
-    return totalValue;
-  case 3:
-    totalValue=Value( LookupR->getDoubleValue(),
-                        LookupC->getDoubleValue() );
-    return totalValue;
-  case 4:
-    totalValue=0.0;
-    return totalValue;
-  }
-  return totalValue;
-}
 
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+  case UNKNOWN:
+    totalValue = -1;
+    break;
 
-void FGCoefficient::DumpSD(void)
-{
-  cout << "   " << name << ": " << SD << endl;
+  case VALUE:
+    totalValue = Value();
+    break;
+
+  case VECTOR:
+    totalValue = Value( LookupR->getDoubleValue() );
+    break;
+
+  case TABLE:
+    totalValue = Value( LookupR->getDoubleValue(),
+                      LookupC->getDoubleValue() );
+    break;
+
+  case EQUATION:
+    totalValue = 0.0;
+    break;
+  }
+  return totalValue;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -273,7 +279,7 @@ void FGCoefficient::DisplayCoeffFactors(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGCoefficient::GetCoefficientValues(void)
+string FGCoefficient::GetSDstring(void)
 {
   char buffer[10];
   string value;
@@ -285,20 +291,24 @@ string FGCoefficient::GetCoefficientValues(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGCoefficient::bind(FGPropertyManager *node) {
+void FGCoefficient::bind(FGPropertyManager *parent)
+{
   string mult;
   unsigned i;
   
-  FGCoefficient::node=node;
+  node=parent->GetNode(name,true);
   
   node->SetString("description",description);
-  if(LookupR) node->SetString("row-parm",LookupR->getName() );
-  if(LookupC) node->SetString("column-parm",LookupC->getName() );
+  if (LookupR) node->SetString("row-parm",LookupR->getName() );
+  if (LookupC) node->SetString("column-parm",LookupC->getName() );
   
   mult="";
+  if (multipliers.size() == 0) 
+    mult="none";
+    
   for (i=0; i<multipliers.size(); i++) {
       mult += multipliers[i]->getName();
-      if( i < multipliers.size()-1 ) mult += "|"; 
+      if ( i < multipliers.size()-1 ) mult += " "; 
   }
   node->SetString("multipliers",mult);
   
@@ -315,12 +325,14 @@ void FGCoefficient::bind(FGPropertyManager *node) {
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGCoefficient::unbind(void) {
+void FGCoefficient::unbind(void)
+{
   node->Untie("SD-norm");
   node->Untie("value-lbs"); 
   node->Untie("bias");  
   node->Untie("gain");
-}  
+}
+  
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 //    The bitmasked value choices are as follows:
 //    unset: In this case (the default) JSBSim would only print