]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/FGFCS.cpp
Merge branch 'jmt/units-fix' into maint
[flightgear.git] / src / FDM / JSBSim / models / FGFCS.cpp
index 22ca19d77ee9892333698f3638762840e41cc615..477890295478671424b026873c20664dfeb362fb 100644 (file)
@@ -6,7 +6,7 @@
  Purpose:      Model the flight controls
  Called by:    FDMExec
 
- ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
+ ------------- Copyright (C) 1999  Jon S. Berndt (jon@jsbsim.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
  the terms of the GNU Lesser General Public License as published by the Free Software
@@ -38,23 +38,28 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGFCS.h"
-#include <FGFDMExec.h>
-#include <input_output/FGPropertyManager.h>
+#include "FGFDMExec.h"
+#include "FGGroundReactions.h"
+#include "input_output/FGPropertyManager.h"
 #include <fstream>
 #include <sstream>
 #include <iomanip>
 
-#include <models/flight_control/FGFilter.h>
-#include <models/flight_control/FGDeadBand.h>
-#include <models/flight_control/FGGain.h>
-#include <models/flight_control/FGPID.h>
-#include <models/flight_control/FGSwitch.h>
-#include <models/flight_control/FGSummer.h>
-#include <models/flight_control/FGKinemat.h>
-#include <models/flight_control/FGFCSFunction.h>
-#include <models/flight_control/FGSensor.h>
-#include <models/flight_control/FGActuator.h>
-#include <models/flight_control/FGAccelerometer.h>
+#include "models/flight_control/FGFilter.h"
+#include "models/flight_control/FGDeadBand.h"
+#include "models/flight_control/FGGain.h"
+#include "models/flight_control/FGPID.h"
+#include "models/flight_control/FGSwitch.h"
+#include "models/flight_control/FGSummer.h"
+#include "models/flight_control/FGKinemat.h"
+#include "models/flight_control/FGFCSFunction.h"
+#include "models/flight_control/FGSensor.h"
+#include "models/flight_control/FGActuator.h"
+#include "models/flight_control/FGAccelerometer.h"
+#include "models/flight_control/FGMagnetometer.h"
+#include "models/flight_control/FGGyro.h"
+
+using namespace std;
 
 namespace JSBSim {
 
@@ -193,6 +198,8 @@ bool FGFCS::Run(void)
   if (FGModel::Run()) return true; // fast exit if nothing to do
   if (FDMExec->Holding()) return false;
 
+  RunPreFunctions();
+
   for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
   for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
   for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
@@ -213,6 +220,8 @@ bool FGFCS::Run(void)
   // Execute Flight Control System
   for (i=0; i<FCSComponents.size(); i++) FCSComponents[i]->Run();
 
+  RunPostFunctions();
+
   return false;
 }
 
@@ -519,7 +528,7 @@ bool FGFCS::Load(Element* el, SystemType systype)
 {
   string name, file, fname="", interface_property_string, parent_name;
   vector <FGFCSComponent*> *Components;
-  Element *component_element, *sensor_element;
+  Element *component_element;
   Element *channel_element;
 
   Components=0;
@@ -642,6 +651,10 @@ bool FGFCS::Load(Element* el, SystemType systype)
           Components->push_back(new FGSensor(this, component_element));
         } else if (component_element->GetName() == string("accelerometer")) {
           Components->push_back(new FGAccelerometer(this, component_element));
+        } else if (component_element->GetName() == string("magnetometer")) {
+          Components->push_back(new FGMagnetometer(this, component_element));
+        } else if (component_element->GetName() == string("gyro")) {
+          Components->push_back(new FGGyro(this, component_element));
         } else {
           cerr << "Unknown FCS component: " << component_element->GetName() << endl;
         }
@@ -679,7 +692,7 @@ double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGFCS::FindSystemFullPathname(string system_filename)
+string FGFCS::FindSystemFullPathname(const string& system_filename)
 {
   string fullpath, localpath;
   string systemPath = FDMExec->GetSystemsPath();
@@ -707,7 +720,7 @@ string FGFCS::FindSystemFullPathname(string system_filename)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-ifstream* FGFCS::FindSystemFile(string system_filename)
+ifstream* FGFCS::FindSystemFile(const string& system_filename)
 {
   string fullpath, localpath;
   string systemPath = FDMExec->GetSystemsPath();
@@ -732,7 +745,7 @@ ifstream* FGFCS::FindSystemFile(string system_filename)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGFCS::GetComponentStrings(string delimeter)
+string FGFCS::GetComponentStrings(const string& delimiter)
 {
   unsigned int comp;
   string CompStrings = "";
@@ -741,7 +754,7 @@ string FGFCS::GetComponentStrings(string delimeter)
 
   for (unsigned int i=0; i<Systems.size(); i++) {
     if (firstime) firstime = false;
-    else          CompStrings += delimeter;
+    else          CompStrings += delimiter;
 
     CompStrings += Systems[i]->GetName();
     total_count++;
@@ -750,7 +763,7 @@ string FGFCS::GetComponentStrings(string delimeter)
   for (comp = 0; comp < APComponents.size(); comp++)
   {
     if (firstime) firstime = false;
-    else          CompStrings += delimeter;
+    else          CompStrings += delimiter;
 
     CompStrings += APComponents[comp]->GetName();
     total_count++;
@@ -758,7 +771,7 @@ string FGFCS::GetComponentStrings(string delimeter)
 
   for (comp = 0; comp < FCSComponents.size(); comp++) {
     if (firstime) firstime = false;
-    else          CompStrings += delimeter;
+    else          CompStrings += delimiter;
 
     CompStrings += FCSComponents[comp]->GetName();
     total_count++;
@@ -769,7 +782,7 @@ string FGFCS::GetComponentStrings(string delimeter)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGFCS::GetComponentValues(string delimeter)
+string FGFCS::GetComponentValues(const string& delimiter)
 {
   std::ostringstream buf;
 
@@ -779,7 +792,7 @@ string FGFCS::GetComponentValues(string delimeter)
 
   for (unsigned int i=0; i<Systems.size(); i++) {
     if (firstime) firstime = false;
-    else          buf << delimeter;
+    else          buf << delimiter;
 
     buf << setprecision(9) << Systems[i]->GetOutput();
     total_count++;
@@ -787,7 +800,7 @@ string FGFCS::GetComponentValues(string delimeter)
 
   for (comp = 0; comp < APComponents.size(); comp++) {
     if (firstime) firstime = false;
-    else          buf << delimeter;
+    else          buf << delimiter;
 
     buf << setprecision(9) << APComponents[comp]->GetOutput();
     total_count++;
@@ -795,7 +808,7 @@ string FGFCS::GetComponentValues(string delimeter)
 
   for (comp = 0; comp < FCSComponents.size(); comp++) {
     if (firstime) firstime = false;
-    else          buf << delimeter;
+    else          buf << delimiter;
 
     buf << setprecision(9) << FCSComponents[comp]->GetOutput();
     total_count++;