]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGFactorGroup.cpp
Updated to match changes in radiostack.[ch]xx
[flightgear.git] / src / FDM / JSBSim / FGFactorGroup.cpp
index f46a472cc2e00094b5e1db690c1f88ae8c80c5fe..9d96439eacb57bac824d5a36e3756d83607f465c 100644 (file)
@@ -51,13 +51,15 @@ INCLUDES
 #include "FGFDMExec.h"
 
 #ifndef FGFS
-#  include <iomanip>
+#  if defined(sgi) && !defined(__GNUC__)
+#    include <iomanip.h>
+#  else
+#    include <iomanip>
+#  endif
 #else
 #  include STL_IOMANIP
 #endif
 
-extern short debug_lvl;
-
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_FACTORGROUP;
 
@@ -65,39 +67,41 @@ static const char *IdHdr = ID_FACTORGROUP;
 CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-FGFactorGroup::FGFactorGroup( FGFDMExec* fdmex ) : FGCoefficient( fdmex) {
-  FDMExec=fdmex;
+FGFactorGroup::FGFactorGroup( FGFDMExec* fdmex ) : FGCoefficient( fdmex)
+{
+  FDMExec = fdmex;
+  totalValue = 0;
+  Debug(0);
 }  
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
                           
-FGFactorGroup::~FGFactorGroup() {
-    int i;
-    for (i=0; i<sum.size(); i++) {
-      delete sum[i];
-    }
+FGFactorGroup::~FGFactorGroup()
+{
+  for (unsigned int i=0; i<sum.size(); i++) delete sum[i];
+
+  Debug(1);
 }
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-bool FGFactorGroup::Load(FGConfigFile *AC_cfg) {
+bool FGFactorGroup::Load(FGConfigFile *AC_cfg)
+{
   string token;
   
-  if(AC_cfg) {
+  if (AC_cfg) {
     name = AC_cfg->GetValue("NAME");
     AC_cfg->GetNextConfigLine();
     *AC_cfg >> description;
     token = AC_cfg->GetValue();
-    iftoken == "FACTOR") {
+    if (token == "FACTOR") {
       FGCoefficient::Load(AC_cfg);
-      //if (debug_lvl > 0) DisplayCoeffFactors(ca.back()->Getmultipliers());
     } 
     token = AC_cfg->GetValue();  
-    while ( token != "/GROUP" ) {
-          sum.push_back( new FGCoefficient(FDMExec) );
-          sum.back()->Load(AC_cfg);
-          //if (debug_lvl > 0) DisplayCoeffFactors(ca.back()->Getmultipliers());
-          token = AC_cfg->GetValue(); 
+    while (token != string("/GROUP") ) {
+      sum.push_back( new FGCoefficient(FDMExec) );
+      sum.back()->Load(AC_cfg);
+      token = AC_cfg->GetValue(); 
     }
     AC_cfg->GetNextConfigLine();
     return true;
@@ -108,53 +112,91 @@ bool FGFactorGroup::Load(FGConfigFile *AC_cfg) {
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-float FGFactorGroup::TotalValue(void) {
-  int i;
-  float totalsum=0;
-  SDtotal=0.0;
-  for(i=0;i<sum.size();i++) {
-     totalsum+=sum[i]->TotalValue();
+double FGFactorGroup::TotalValue(void)
+{
+  unsigned int i;
+  SDtotal = 0.0;
+  totalValue = 0.0;
+  for (i=0; i<sum.size(); i++) {
+     totalValue += sum[i]->TotalValue();
      SDtotal += sum[i]->GetSD();
   }
-  totalsum *= FGCoefficient::TotalValue();
+  totalValue *= FGCoefficient::TotalValue();
   SDtotal *= FGCoefficient::GetSD();
-  cout << "FGCoefficient::GetSD(): " << FGCoefficient::GetSD() << endl;
-  cout << "FGFactorGroup::SDtotal: " << SDtotal << endl;
-  return totalsum;
-}        
+  Debug(2);
+  return totalValue;
+}
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-string FGFactorGroup::GetCoefficientStrings(void) {
-  int i;
-  string CoeffStrings;
-  
-  CoeffStrings += name;
-  CoeffStrings += ", ";
-  CoeffStrings += FGCoefficient::Getname();
-  for(i=0;i<sum.size();i++) {
-    CoeffStrings += ", ";
-    CoeffStrings += sum[i]->Getname();
-  }
-  return CoeffStrings;    
+void FGFactorGroup::bind(FGPropertyManager* parent)
+{
+  unsigned i;
+  node=parent->GetNode(name,true);
+  node->SetString("description",description);
+  FGCoefficient::bind(node);
+  for (i=0; i < sum.size(); i++) { 
+    sum[i]->bind(node);
+  } 
+  node=(FGPropertyManager*)node->getParent();                                         
+
 }
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+  
+void FGFactorGroup::unbind(void)
+{
+  unsigned i;
+  FGCoefficient::unbind();
+  for (i=0; i < sum.size(); i++) { 
+    sum[i]->unbind();
+  } 
+}
 
-string FGFactorGroup::GetCoefficientValues(void) {
-    int i;
-    char buffer[10];
-    string values;
-    
-    snprintf(buffer,10,"%9.6f",SDtotal);
-    values += string(buffer);
-    values += ", ";
-    snprintf(buffer,10,"%9.6f",FGCoefficient::GetSD() );
-    values += string(buffer);
-    values += ", ";
-    for(i=0;i<sum.size();i++) {
-       values += sum[i]->GetCoefficientValues();
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+//    The bitmasked value choices are as follows:
+//    unset: In this case (the default) JSBSim would only print
+//       out the normally expected messages, essentially echoing
+//       the config files as they are read. If the environment
+//       variable is not set, debug_lvl is set to 1 internally
+//    0: This requests JSBSim not to output any messages
+//       whatsoever.
+//    1: This value explicity requests the normal JSBSim
+//       startup messages
+//    2: This value asks for a message to be printed out when
+//       a class is instantiated
+//    4: When this value is set, a message is displayed when a
+//       FGModel object executes its Run() method
+//    8: When this value is set, various runtime state variables
+//       are printed out periodically
+//    16: When set various parameters are sanity checked and
+//       a message is printed out when they go out of bounds
+
+void FGFactorGroup::Debug(int from)
+{
+  if (debug_lvl <= 0) return;
+
+  if (debug_lvl & 1) { // Standard console startup message output
+  }
+  if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+    if (from == 0) cout << "Instantiated: FGFactorGroup" << endl;
+    if (from == 1) cout << "Destroyed:    FGFactorGroup" << endl;
+  }
+  if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+  }
+  if (debug_lvl & 8 ) { // Runtime state variables
+    if (from == 2) {
+      cout << "FGCoefficient::GetSD(): " << FGCoefficient::GetSD() << endl;
+      cout << "FGFactorGroup::SDtotal: " << SDtotal << endl;
     }
-    return values;
-}       
-       
+  }
+  if (debug_lvl & 16) { // Sanity checking
+  }
+  if (debug_lvl & 64) {
+    if (from == 0) { // Constructor
+      cout << IdSrc << endl;
+      cout << IdHdr << endl;
+    }
+  }
+}
+