]> git.mxchange.org Git - flightgear.git/blobdiff - JSBsim/FGCoefficient.cpp
Latest changes from Jon, plus ...
[flightgear.git] / JSBsim / FGCoefficient.cpp
index da5bfbe33624ba8fb747dd7ffe563827bc0ee60d..89c1ca1ef25ed4b05cd6274f405c2617dee633cb 100644 (file)
@@ -99,10 +99,6 @@ seen to be equal, and there are the same number of values for each altitude.
 
 See the header file FGCoefficient.h for the values of the identifiers.
 
-ARGUMENTS
---------------------------------------------------------------------------------
-
-
 HISTORY
 --------------------------------------------------------------------------------
 12/28/98   JSB   Created
@@ -111,29 +107,56 @@ HISTORY
 INCLUDES
 *******************************************************************************/
 
-class FGCoefficient;
-#include <stdio.h>
-#include <stdlib.h>
+#include "FGCoefficient.h"
+#include "FGAtmosphere.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
 #include "FGFCS.h"
 #include "FGAircraft.h"
-#include "FGCoefficient.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
 
 /*******************************************************************************
 ************************************ CODE **************************************
 *******************************************************************************/
 
-FGCoefficient::FGCoefficient(void)
+FGCoefficient::FGCoefficient(FGFDMExec* fdex)
 {
+  FDMExec     = fdex;
+  State       = FDMExec->GetState();
+  Atmosphere  = FDMExec->GetAtmosphere();
+  FCS         = FDMExec->GetFCS();
+  Aircraft    = FDMExec->GetAircraft();
+  Translation = FDMExec->GetTranslation();
+  Rotation    = FDMExec->GetRotation();
+  Position    = FDMExec->GetPosition();
+  Auxiliary   = FDMExec->GetAuxiliary();
+  Output      = FDMExec->GetOutput();
+
   rows = columns = 0;
 }
 
 
-FGCoefficient::FGCoefficient(char* fname)
+FGCoefficient::FGCoefficient(FGFDMExec* fdex, string fname)
 {
   int r, c;
   float ftrashcan;
 
-  ifstream coeffDefFile(fname);
+  FDMExec     = fdex;
+  State       = FDMExec->GetState();
+  Atmosphere  = FDMExec->GetAtmosphere();
+  FCS         = FDMExec->GetFCS();
+  Aircraft    = FDMExec->GetAircraft();
+  Translation = FDMExec->GetTranslation();
+  Rotation    = FDMExec->GetRotation();
+  Position    = FDMExec->GetPosition();
+  Auxiliary   = FDMExec->GetAuxiliary();
+  Output      = FDMExec->GetOutput();
+
+  ifstream coeffDefFile(fname.c_str());
 
   if (coeffDefFile) {
     if (!coeffDefFile.fail()) {
@@ -141,21 +164,21 @@ FGCoefficient::FGCoefficient(char* fname)
       coeffDefFile >> description;
       coeffDefFile >> method;
 
-      if (strcmp(method,"EQUATION") == 0) type = 4;
-      else if (strcmp(method,"TABLE") == 0) type = 3;
-      else if (strcmp(method,"VECTOR") == 0) type = 2;
-      else if (strcmp(method,"VALUE") == 0) type = 1;
-      else type = 0;
+      if      (method == "EQUATION") type = EQUATION;
+      else if (method == "TABLE")    type = TABLE;
+      else if (method == "VECTOR")   type = VECTOR;
+      else if (method == "VALUE")    type = VALUE;
+      else                           type = UNKNOWN;
 
-      if (type == 2 || type == 3) {
+      if (type == VECTOR || type == TABLE) {
         coeffDefFile >> rows;
-        if (type == 3) {
+        if (type == TABLE) {
           coeffDefFile >> columns;
         }
         coeffDefFile >> LookupR;
       }
 
-      if (type == 3) {
+      if (type == TABLE) {
         coeffDefFile >> LookupC;
       }
 
@@ -228,10 +251,10 @@ FGCoefficient::FGCoefficient(char* fname)
       }
 
       switch(type) {
-      case 1:
+      case VALUE:
         coeffDefFile >> StaticValue;
         break;
-      case 2:
+      case VECTOR:
         Allocate(rows,2);
 
         for (r=1;r<=rows;r++) {
@@ -239,7 +262,7 @@ FGCoefficient::FGCoefficient(char* fname)
           coeffDefFile >> Table3D[r][1];
         }
         break;
-      case 3:
+      case TABLE:
         Allocate(rows, columns);
 
         for (c=1;c<=columns;c++) {
@@ -260,16 +283,38 @@ FGCoefficient::FGCoefficient(char* fname)
 }
 
 
-FGCoefficient::FGCoefficient(int r, int c)
+FGCoefficient::FGCoefficient(FGFDMExec* fdex, int r, int c)
 {
+  FDMExec     = fdex;
+  State       = FDMExec->GetState();
+  Atmosphere  = FDMExec->GetAtmosphere();
+  FCS         = FDMExec->GetFCS();
+  Aircraft    = FDMExec->GetAircraft();
+  Translation = FDMExec->GetTranslation();
+  Rotation    = FDMExec->GetRotation();
+  Position    = FDMExec->GetPosition();
+  Auxiliary   = FDMExec->GetAuxiliary();
+  Output      = FDMExec->GetOutput();
+
   rows = r;
   columns = c;
   Allocate(r,c);
 }
 
 
-FGCoefficient::FGCoefficient(int n)
+FGCoefficient::FGCoefficient(FGFDMExec* fdex, int n)
 {
+  FDMExec     = fdex;
+  State       = FDMExec->GetState();
+  Atmosphere  = FDMExec->GetAtmosphere();
+  FCS         = FDMExec->GetFCS();
+  Aircraft    = FDMExec->GetAircraft();
+  Translation = FDMExec->GetTranslation();
+  Rotation    = FDMExec->GetRotation();
+  Position    = FDMExec->GetPosition();
+  Auxiliary   = FDMExec->GetAuxiliary();
+  Output      = FDMExec->GetOutput();
+
   rows = n;
   columns = 0;
   Allocate(n);
@@ -384,19 +429,19 @@ float FGCoefficient::GetCoeffVal(int val_idx)
   case FG_CBAR:
     return Aircraft->Getcbar();
   case FG_ALPHA:
-    return State->Getalpha();
+    return Translation->Getalpha();
   case FG_ALPHADOT:
     return State->Getadot();
   case FG_BETA:
-    return State->Getbeta();
+    return Translation->Getbeta();
   case FG_BETADOT:
     return State->Getbdot();
   case FG_PITCHRATE:
-    return State->GetQ();
+    return Rotation->GetQ();
   case FG_ROLLRATE:
-    return State->GetP();
+    return Rotation->GetP();
   case FG_YAWRATE:
-    return State->GetR();
+    return Rotation->GetR();
   case FG_ELEVATOR:
     return FCS->GetDe();
   case FG_AILERON: