-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
- \r
- Module: FGFCS.cpp\r
- Author: Jon Berndt\r
- Date started: 12/12/98\r
- Purpose: Model the flight controls\r
- Called by: FDMExec\r
- \r
- ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------\r
- \r
- This program is free software; you can redistribute it and/or modify it under\r
- the terms of the GNU General Public License as published by the Free Software\r
- Foundation; either version 2 of the License, or (at your option) any later\r
- version.\r
- \r
- This program is distributed in the hope that it will be useful, but WITHOUT\r
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\r
- details.\r
- \r
- You should have received a copy of the GNU General Public License along with\r
- this program; if not, write to the Free Software Foundation, Inc., 59 Temple\r
- Place - Suite 330, Boston, MA 02111-1307, USA.\r
- \r
- Further information about the GNU General Public License can also be found on\r
- the world wide web at http://www.gnu.org.\r
- \r
-FUNCTIONAL DESCRIPTION\r
---------------------------------------------------------------------------------\r
-This class models the flight controls for a specific airplane\r
- \r
-HISTORY\r
---------------------------------------------------------------------------------\r
-12/12/98 JSB Created\r
- \r
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-INCLUDES\r
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
-\r
-#include "FGDefs.h"\r
-\r
-#include "FGFCS.h"\r
-#include "FGState.h"\r
-#include "FGFDMExec.h"\r
-#include "FGAtmosphere.h"\r
-#include "FGAircraft.h"\r
-#include "FGTranslation.h"\r
-#include "FGRotation.h"\r
-#include "FGPosition.h"\r
-#include "FGAuxiliary.h"\r
-#include "FGOutput.h"\r
-\r
-#include "filtersjb/FGFilter.h"\r
-#include "filtersjb/FGDeadBand.h"\r
-#include "filtersjb/FGGain.h"\r
-#include "filtersjb/FGGradient.h"\r
-#include "filtersjb/FGSwitch.h"\r
-#include "filtersjb/FGSummer.h"\r
-#include "filtersjb/FGFlaps.h"\r
-\r
-static const char *IdSrc = "$Id$";\r
-static const char *IdHdr = ID_FCS;\r
-\r
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-CLASS IMPLEMENTATION\r
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/\r
-\r
-FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)\r
-{\r
- Name = "FGFCS";\r
-\r
- DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = PTrimCmd = 0.0;\r
- DaPos = DePos = DrPos = DfPos = DsbPos = DspPos = 0.0;\r
- LeftBrake = RightBrake = CenterBrake = 0.0;\r
-\r
- if (debug_lvl & 2) cout << "Instantiated: " << Name << endl;\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-FGFCS::~FGFCS()\r
-{\r
- ThrottleCmd.clear();\r
- ThrottlePos.clear();\r
- MixtureCmd.clear();\r
- MixturePos.clear();\r
-\r
- unsigned int i;\r
-\r
- for(i=0;i<Components.size();i++) delete Components[i];\r
- if (debug_lvl & 2) cout << "Destroyed: FGFCS" << endl;\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-bool FGFCS::Run(void)\r
-{\r
- unsigned int i;\r
-\r
- if (!FGModel::Run()) {\r
- for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];\r
- for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];\r
- for (i=0; i<Components.size(); i++) Components[i]->Run();\r
- } else {\r
- }\r
-\r
- return false;\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-void FGFCS::SetThrottleCmd(int engineNum, float setting)\r
-{\r
- unsigned int ctr;\r
-\r
- if ((int)ThrottleCmd.size() > engineNum) {\r
- if (engineNum < 0) {\r
- for (ctr=0;ctr<=ThrottleCmd.size();ctr++) ThrottleCmd[ctr] = setting;\r
- } else {\r
- ThrottleCmd[engineNum] = setting;\r
- }\r
- } else {\r
- cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()\r
- << " engines exist, but attempted throttle command is for engine "\r
- << engineNum << endl;\r
- }\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-void FGFCS::SetThrottlePos(int engineNum, float setting)\r
-{\r
- unsigned int ctr;\r
-\r
- if ((int)ThrottlePos.size() > engineNum) {\r
- if (engineNum < 0) {\r
- for (ctr=0;ctr<=ThrottlePos.size();ctr++) ThrottlePos[ctr] = setting;\r
- } else {\r
- ThrottlePos[engineNum] = setting;\r
- }\r
- } else {\r
- cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()\r
- << " engines exist, but attempted throttle position setting is for engine "\r
- << engineNum << endl;\r
- }\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-float FGFCS::GetThrottleCmd(int engineNum)\r
-{\r
- if ((int)ThrottleCmd.size() > engineNum) {\r
- if (engineNum < 0) {\r
- cerr << "Cannot get throttle value for ALL engines" << endl;\r
- } else {\r
- return ThrottleCmd[engineNum];\r
- }\r
- } else {\r
- cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()\r
- << " engines exist, but throttle setting for engine " << engineNum\r
- << " is selected" << endl;\r
- }\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-float FGFCS::GetThrottlePos(int engineNum)\r
-{\r
- if ((int)ThrottlePos.size() > engineNum) {\r
- if (engineNum < 0) {\r
- cerr << "Cannot get throttle value for ALL engines" << endl;\r
- } else {\r
- return ThrottlePos[engineNum];\r
- }\r
- } else {\r
- cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()\r
- << " engines exist, but attempted throttle position setting is for engine "\r
- << engineNum << endl;\r
- }\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-void FGFCS::SetMixtureCmd(int engineNum, float setting)\r
-{\r
- unsigned int ctr;\r
-\r
- if (engineNum < 0) {\r
- for (ctr=0;ctr<MixtureCmd.size();ctr++) MixtureCmd[ctr] = setting;\r
- } else {\r
- MixtureCmd[engineNum] = setting;\r
- }\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-void FGFCS::SetMixturePos(int engineNum, float setting)\r
-{\r
- unsigned int ctr;\r
-\r
- if (engineNum < 0) {\r
- for (ctr=0;ctr<=MixtureCmd.size();ctr++) MixturePos[ctr] = MixtureCmd[ctr];\r
- } else {\r
- MixturePos[engineNum] = setting;\r
- }\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-bool FGFCS::Load(FGConfigFile* AC_cfg)\r
-{\r
- string token;\r
-\r
- Name = Name + ":" + AC_cfg->GetValue("NAME");\r
- if (debug_lvl > 0) cout << " Control System Name: " << Name << endl;\r
- AC_cfg->GetNextConfigLine();\r
- while ((token = AC_cfg->GetValue()) != "/FLIGHT_CONTROL") {\r
- if (token == "COMPONENT") {\r
- token = AC_cfg->GetValue("TYPE");\r
- if (debug_lvl > 0) cout << " Loading Component \""\r
- << AC_cfg->GetValue("NAME")\r
- << "\" of type: " << token << endl;\r
- if ((token == "LAG_FILTER") ||\r
- (token == "LEAD_LAG_FILTER") ||\r
- (token == "SECOND_ORDER_FILTER") ||\r
- (token == "WASHOUT_FILTER") ||\r
- (token == "INTEGRATOR") ) {\r
- Components.push_back(new FGFilter(this, AC_cfg));\r
- } else if ((token == "PURE_GAIN") ||\r
- (token == "SCHEDULED_GAIN") ||\r
- (token == "AEROSURFACE_SCALE") ) {\r
-\r
- Components.push_back(new FGGain(this, AC_cfg));\r
-\r
- } else if (token == "SUMMER") {\r
- Components.push_back(new FGSummer(this, AC_cfg));\r
- } else if (token == "DEADBAND") {\r
- Components.push_back(new FGDeadBand(this, AC_cfg));\r
- } else if (token == "GRADIENT") {\r
- Components.push_back(new FGGradient(this, AC_cfg));\r
- } else if (token == "SWITCH") {\r
- Components.push_back(new FGSwitch(this, AC_cfg));\r
- } else if (token == "FLAPS") {\r
- Components.push_back(new FGFlaps(this, AC_cfg));\r
- } else {\r
- cerr << "Unknown token [" << token << "] in FCS portion of config file" << endl;\r
- return false;\r
- }\r
- AC_cfg->GetNextConfigLine();\r
- }\r
- }\r
- return true;\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-float FGFCS::GetComponentOutput(eParam idx) {\r
- return Components[idx]->GetOutput();\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-string FGFCS::GetComponentName(int idx) {\r
- return Components[idx]->GetName();\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-float FGFCS::GetBrake(FGLGear::BrakeGroup bg) {\r
- switch (bg) {\r
- case FGLGear::bgLeft:\r
- return LeftBrake;\r
- case FGLGear::bgRight:\r
- return RightBrake;\r
- case FGLGear::bgCenter:\r
- return CenterBrake;\r
- default:\r
- cerr << "GetBrake asked to return a bogus brake value" << endl;\r
- }\r
- return 0.0;\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-string FGFCS::GetComponentStrings(void)\r
-{\r
- unsigned int comp;\r
-\r
- string CompStrings = "";\r
- bool firstime = true;\r
-\r
- for (comp = 0; comp < Components.size(); comp++) {\r
- if (firstime) firstime = false;\r
- else CompStrings += ", ";\r
-\r
- CompStrings += Components[comp]->GetName();\r
- }\r
-\r
- return CompStrings;\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-string FGFCS::GetComponentValues(void)\r
-{\r
- unsigned int comp;\r
-\r
- string CompValues = "";\r
- char buffer[10];\r
- bool firstime = true;\r
-\r
- for (comp = 0; comp < Components.size(); comp++) {\r
- if (firstime) firstime = false;\r
- else CompValues += ", ";\r
-\r
- sprintf(buffer, "%9.6f", Components[comp]->GetOutput());\r
- CompValues += string(buffer);\r
- }\r
-\r
- return CompValues;\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-void FGFCS::AddThrottle(void)\r
-{\r
- ThrottleCmd.push_back(0.0);\r
- ThrottlePos.push_back(0.0);\r
- MixtureCmd.push_back(0.0); // assume throttle and mixture are coupled\r
- MixturePos.push_back(0.0);\r
-}\r
-\r
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
-\r
-void FGFCS::Debug(void)\r
-{\r
- //TODO: Add your source code here\r
-}\r
-\r
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Module: FGFCS.cpp
+ Author: Jon Berndt
+ Date started: 12/12/98
+ Purpose: Model the flight controls
+ Called by: FDMExec
+
+ ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ details.
+
+ You should have received a copy of the GNU General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ Further information about the GNU General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+This class models the flight controls for a specific airplane
+
+HISTORY
+--------------------------------------------------------------------------------
+12/12/98 JSB Created
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include "FGFCS.h"
+#include "FGState.h"
+#include "FGFDMExec.h"
+#include "FGAtmosphere.h"
+#include "FGAircraft.h"
+#include "FGTranslation.h"
+#include "FGRotation.h"
+#include "FGPosition.h"
+#include "FGAuxiliary.h"
+#include "FGOutput.h"
+
+#include "filtersjb/FGFilter.h"
+#include "filtersjb/FGDeadBand.h"
+#include "filtersjb/FGGain.h"
+#include "filtersjb/FGGradient.h"
+#include "filtersjb/FGSwitch.h"
+#include "filtersjb/FGSummer.h"
+#include "filtersjb/FGKinemat.h"
+
+static const char *IdSrc = "$Id$";
+static const char *IdHdr = ID_FCS;
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
+{
+ Name = "FGFCS";
+
+ DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = 0.0;
+ PTrimCmd = YTrimCmd = RTrimCmd = 0.0;
+ DaPos = DePos = DrPos = DfPos = DsbPos = DspPos = 0.0;
+ GearCmd = GearPos = 1; // default to gear down
+ LeftBrake = RightBrake = CenterBrake = 0.0;
+
+ Debug(0);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGFCS::~FGFCS()
+{
+ ThrottleCmd.clear();
+ ThrottlePos.clear();
+ MixtureCmd.clear();
+ MixturePos.clear();
+ PropAdvanceCmd.clear();
+ PropAdvance.clear();
+
+ unsigned int i;
+
+ for (i=0;i<Components.size();i++) delete Components[i];
+ Debug(1);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGFCS::Run(void)
+{
+ unsigned int i;
+
+ if (!FGModel::Run()) {
+ 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];
+ for (i=0; i<Components.size(); i++) Components[i]->Run();
+ } else {
+ }
+
+ return false;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGFCS::SetThrottleCmd(int engineNum, double setting)
+{
+ unsigned int ctr;
+
+ if (engineNum < (int)ThrottlePos.size()) {
+ if (engineNum < 0) {
+ for (ctr=0;ctr<ThrottleCmd.size();ctr++) ThrottleCmd[ctr] = setting;
+ } else {
+ ThrottleCmd[engineNum] = setting;
+ }
+ } else {
+ cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
+ << " engines exist, but attempted throttle command is for engine "
+ << engineNum << endl;
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGFCS::SetThrottlePos(int engineNum, double setting)
+{
+ unsigned int ctr;
+
+ if (engineNum < (int)ThrottlePos.size()) {
+ if (engineNum < 0) {
+ for (ctr=0;ctr<ThrottlePos.size();ctr++) ThrottlePos[ctr] = setting;
+ } else {
+ ThrottlePos[engineNum] = setting;
+ }
+ } else {
+ cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
+ << " engines exist, but attempted throttle position setting is for engine "
+ << engineNum << endl;
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+double FGFCS::GetThrottleCmd(int engineNum)
+{
+ if (engineNum < (int)ThrottlePos.size()) {
+ if (engineNum < 0) {
+ cerr << "Cannot get throttle value for ALL engines" << endl;
+ } else {
+ return ThrottleCmd[engineNum];
+ }
+ } else {
+ cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
+ << " engines exist, but throttle setting for engine " << engineNum
+ << " is selected" << endl;
+ }
+ return 0.0;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+double FGFCS::GetThrottlePos(int engineNum)
+{
+ if (engineNum < (int)ThrottlePos.size()) {
+ if (engineNum < 0) {
+ cerr << "Cannot get throttle value for ALL engines" << endl;
+ } else {
+ return ThrottlePos[engineNum];
+ }
+ } else {
+ cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
+ << " engines exist, but attempted throttle position setting is for engine "
+ << engineNum << endl;
+ }
+ return 0.0;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGFCS::SetMixtureCmd(int engineNum, double setting)
+{
+ unsigned int ctr;
+
+ if (engineNum < (int)ThrottlePos.size()) {
+ if (engineNum < 0) {
+ for (ctr=0;ctr<MixtureCmd.size();ctr++) MixtureCmd[ctr] = setting;
+ } else {
+ MixtureCmd[engineNum] = setting;
+ }
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGFCS::SetMixturePos(int engineNum, double setting)
+{
+ unsigned int ctr;
+
+ if (engineNum < (int)ThrottlePos.size()) {
+ if (engineNum < 0) {
+ for (ctr=0;ctr<=MixtureCmd.size();ctr++) MixturePos[ctr] = MixtureCmd[ctr];
+ } else {
+ MixturePos[engineNum] = setting;
+ }
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGFCS::SetPropAdvanceCmd(int engineNum, double setting)
+{
+ unsigned int ctr;
+
+ if (engineNum < (int)ThrottlePos.size()) {
+ if (engineNum < 0) {
+ for (ctr=0;ctr<PropAdvanceCmd.size();ctr++) PropAdvanceCmd[ctr] = setting;
+ } else {
+ PropAdvanceCmd[engineNum] = setting;
+ }
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGFCS::SetPropAdvance(int engineNum, double setting)
+{
+ unsigned int ctr;
+
+ if (engineNum < (int)ThrottlePos.size()) {
+ if (engineNum < 0) {
+ for (ctr=0;ctr<=PropAdvanceCmd.size();ctr++) PropAdvance[ctr] = PropAdvanceCmd[ctr];
+ } else {
+ PropAdvance[engineNum] = setting;
+ }
+ }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGFCS::Load(FGConfigFile* AC_cfg)
+{
+ string token;
+
+ Name = Name + ":" + AC_cfg->GetValue("NAME");
+ if (debug_lvl > 0) cout << " Control System Name: " << Name << endl;
+ AC_cfg->GetNextConfigLine();
+ while ((token = AC_cfg->GetValue()) != string("/FLIGHT_CONTROL")) {
+ if (token == "COMPONENT") {
+ token = AC_cfg->GetValue("TYPE");
+ if (debug_lvl > 0) cout << endl << " Loading Component \""
+ << AC_cfg->GetValue("NAME")
+ << "\" of type: " << token << endl;
+ if ((token == "LAG_FILTER") ||
+ (token == "LEAD_LAG_FILTER") ||
+ (token == "SECOND_ORDER_FILTER") ||
+ (token == "WASHOUT_FILTER") ||
+ (token == "INTEGRATOR") ) {
+ Components.push_back(new FGFilter(this, AC_cfg));
+ } else if ((token == "PURE_GAIN") ||
+ (token == "SCHEDULED_GAIN") ||
+ (token == "AEROSURFACE_SCALE") ) {
+
+ Components.push_back(new FGGain(this, AC_cfg));
+
+ } else if (token == "SUMMER") {
+ Components.push_back(new FGSummer(this, AC_cfg));
+ } else if (token == "DEADBAND") {
+ Components.push_back(new FGDeadBand(this, AC_cfg));
+ } else if (token == "GRADIENT") {
+ Components.push_back(new FGGradient(this, AC_cfg));
+ } else if (token == "SWITCH") {
+ Components.push_back(new FGSwitch(this, AC_cfg));
+ } else if (token == "KINEMAT") {
+ Components.push_back(new FGKinemat(this, AC_cfg));
+ } else {
+ cerr << "Unknown token [" << token << "] in FCS portion of config file" << endl;
+ return false;
+ }
+ AC_cfg->GetNextConfigLine();
+ }
+ }
+ return true;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+double FGFCS::GetComponentOutput(eParam idx) {
+ return Components[idx]->GetOutput();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGFCS::GetComponentName(int idx) {
+ return Components[idx]->GetName();
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+double FGFCS::GetBrake(FGLGear::BrakeGroup bg)
+{
+ switch (bg) {
+ case FGLGear::bgLeft:
+ return LeftBrake;
+ case FGLGear::bgRight:
+ return RightBrake;
+ case FGLGear::bgCenter:
+ return CenterBrake;
+ default:
+ cerr << "GetBrake asked to return a bogus brake value" << endl;
+ }
+ return 0.0;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGFCS::GetComponentStrings(void)
+{
+ unsigned int comp;
+ string CompStrings = "";
+ bool firstime = true;
+
+ for (comp = 0; comp < Components.size(); comp++) {
+ if (firstime) firstime = false;
+ else CompStrings += ", ";
+
+ CompStrings += Components[comp]->GetName();
+ }
+
+ return CompStrings;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGFCS::GetComponentValues(void)
+{
+ unsigned int comp;
+ string CompValues = "";
+ char buffer[10];
+ bool firstime = true;
+
+ for (comp = 0; comp < Components.size(); comp++) {
+ if (firstime) firstime = false;
+ else CompValues += ", ";
+
+ sprintf(buffer, "%9.6f", Components[comp]->GetOutput());
+ CompValues += string(buffer);
+ }
+
+ return CompValues;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGFCS::AddThrottle(void)
+{
+ ThrottleCmd.push_back(0.0);
+ ThrottlePos.push_back(0.0);
+ MixtureCmd.push_back(0.0); // assume throttle and mixture are coupled
+ MixturePos.push_back(0.0);
+ PropAdvanceCmd.push_back(0.0); // assume throttle and prop pitch are coupled
+ PropAdvance.push_back(0.0);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// 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 FGFCS::Debug(int from)
+{
+ if (debug_lvl <= 0) return;
+
+ if (debug_lvl & 1) { // Standard console startup message output
+ if (from == 0) { // Constructor
+
+ }
+ }
+ if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+ if (from == 0) cout << "Instantiated: FGFCS" << endl;
+ if (from == 1) cout << "Destroyed: FGFCS" << endl;
+ }
+ if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+ }
+ if (debug_lvl & 8 ) { // Runtime state variables
+ }
+ if (debug_lvl & 16) { // Sanity checking
+ }
+ if (debug_lvl & 64) {
+ if (from == 0) { // Constructor
+ cout << IdSrc << endl;
+ cout << IdHdr << endl;
+ }
+ }
+}
+