]> 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 11deb848a87f8d6d48efd96ff8e51a56fb6c41f5..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);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -185,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();
@@ -226,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;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -272,7 +279,7 @@ void FGCoefficient::DisplayCoeffFactors(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGCoefficient::GetCoefficientValues(void)
+string FGCoefficient::GetSDstring(void)
 {
   char buffer[10];
   string value;
@@ -284,23 +291,24 @@ string FGCoefficient::GetCoefficientValues(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGCoefficient::bind(FGPropertyManager *parent) {
+void FGCoefficient::bind(FGPropertyManager *parent)
+{
   string mult;
   unsigned i;
   
   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) 
+  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);
   
@@ -317,12 +325,14 @@ void FGCoefficient::bind(FGPropertyManager *parent) {
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-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