From: curt Date: Mon, 24 Apr 2000 23:49:37 +0000 (+0000) Subject: Added new section of JSBsim. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c7cac5893fc8c53f4d395eb00fae10f682e874e2;p=flightgear.git Added new section of JSBsim. --- diff --git a/src/FDM/JSBSim/filtersjb/FGDeadBand.cpp b/src/FDM/JSBSim/filtersjb/FGDeadBand.cpp new file mode 100644 index 000000000..16be66794 --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGDeadBand.cpp @@ -0,0 +1,85 @@ + +/******************************************************************************* + + Module: FGDeadBand.cpp + Author: + Date started: + + ------------- Copyright (C) 2000 ------------- + + 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 +-------------------------------------------------------------------------------- + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +INCLUDES +*******************************************************************************/ + +#include "FGDeadBand.h" + +/******************************************************************************* +************************************ CODE ************************************** +*******************************************************************************/ + +// ***************************************************************************** +// Function: Run +// Purpose: +// Parameters: void +// Comments: + +FGDeadBand::FGDeadBand(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), + AC_cfg(AC_cfg) +{ + Type = AC_cfg->GetValue("TYPE"); + Name = AC_cfg->GetValue("NAME"); + AC_cfg->GetNextConfigLine(); + string token; + + while ((token = AC_cfg->GetValue()) != "/COMPONENT") { + *AC_cfg >> token; + if (token == "ID") { + *AC_cfg >> ID; + } else if (token == "INPUT") { + *AC_cfg >> InputIdx; + } else { + *AC_cfg >> token; + } + } +} + +// ***************************************************************************** +// Function: Run +// Purpose: +// Parameters: void +// Comments: + +bool FGDeadBand::Run(void ) +{ + FGFCSComponent::Run(); // call the base class for initialization of Input + + return true; +} + diff --git a/src/FDM/JSBSim/filtersjb/FGDeadBand.h b/src/FDM/JSBSim/filtersjb/FGDeadBand.h new file mode 100644 index 000000000..d3faf0317 --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGDeadBand.h @@ -0,0 +1,69 @@ + +/******************************************************************************* + + Header: FGDeadBand.h + Author: + Date started: + + ------------- Copyright (C) ------------- + + 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. + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +SENTRY +*******************************************************************************/ + +#ifndef FGDEADBAND_H +#define FGDEADBAND_H + +/******************************************************************************* +INCLUDES +*******************************************************************************/ + +#include "FGFCSComponent.h" +#include "../FGConfigFile.h" + +/******************************************************************************* +DEFINES +*******************************************************************************/ + +class FGFCS; + +/******************************************************************************* +CLASS DECLARATION +*******************************************************************************/ + +class FGDeadBand : public FGFCSComponent +{ + FGConfigFile* AC_cfg; + +public: + FGDeadBand(FGFCS* fcs, FGConfigFile* AC_cfg); + ~ FGDeadBand ( ) { } //Destructor + + bool Run (void ) ; +}; + +#endif diff --git a/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp b/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp new file mode 100644 index 000000000..ac59cdca3 --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp @@ -0,0 +1,87 @@ + +/******************************************************************************* + + Module: FGFCSComponent.cpp + Author: + Date started: + + ------------- Copyright (C) 2000 ------------- + + 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 +-------------------------------------------------------------------------------- + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +INCLUDES +*******************************************************************************/ + +#include "FGFCSComponent.h" + +/******************************************************************************* +************************************ CODE ************************************** +*******************************************************************************/ + +// ***************************************************************************** +// Function: Constructor +// Purpose: +// Parameters: void +// Comments: + +FGFCSComponent::FGFCSComponent(FGFCS* _fcs) : fcs(_fcs) +{ + Type = ""; + ID = 0; + Input = 0.0; + InputIdx = 0; + Output = 0.0; + sOutputIdx = ""; + OutputIdx = 0; + IsOutput = false; +} + + +void FGFCSComponent::SetOutput(void) +{ + fcs->GetState()->SetParameter(OutputIdx, Output); +} + + +bool FGFCSComponent::Run(void) +{ + switch(InputType) { + case itPilotAC: + Input = fcs->GetState()->GetParameter(InputIdx); + break; + case itFCS: + Input = fcs->GetComponentOutput(InputIdx); + break; + case itAP: + // implement autopilot input mechanism + break; + } + + return true; +} diff --git a/src/FDM/JSBSim/filtersjb/FGFCSComponent.h b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h new file mode 100644 index 000000000..65a3fa4e4 --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h @@ -0,0 +1,95 @@ + +/******************************************************************************* + + Header: FGFCSComponent.h + Author: + Date started: + + ------------- Copyright (C) ------------- + + 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. + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +SENTRY +*******************************************************************************/ + +#ifndef FGFCSCOMPONENT_H +#define FGFCSCOMPONENT_H + +/******************************************************************************* +INCLUDES +*******************************************************************************/ + +#ifdef FGFS +# include +# include STL_STRING + FG_USING_STD(string); +#else +# include +#endif + +/******************************************************************************* +DEFINES +*******************************************************************************/ + +class FGFCS; + +using namespace std; + +/******************************************************************************* +CLASS DECLARATION +*******************************************************************************/ + +class FGFCSComponent +{ +private: + +protected: + FGFCS* fcs; + string Type; + string Name; + enum {itPilotAC, itFCS, itAP} InputType; // Pilot/Aircraft, FCS, Autopilot inputs + int ID; + int InputIdx; + float Input; + string sOutputIdx; + int OutputIdx; + float Output; + bool IsOutput; + +public: + FGFCSComponent(FGFCS*); + ~FGFCSComponent ( ) { } //Destructor + + virtual bool Run (void); + virtual void SetOutput(void); + inline float GetOutput (void) {return Output;} + inline string GetName(void) {return Name;} +}; + +#include + +#endif + diff --git a/src/FDM/JSBSim/filtersjb/FGFilter.cpp b/src/FDM/JSBSim/filtersjb/FGFilter.cpp new file mode 100644 index 000000000..71170efe1 --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGFilter.cpp @@ -0,0 +1,151 @@ +/******************************************************************************* + + Module: FGFilter.cpp + Author: + Date started: + + ------------- Copyright (C) 2000 ------------- + + 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 +-------------------------------------------------------------------------------- + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +INCLUDES +*******************************************************************************/ + +#include "FGFilter.h" + +/******************************************************************************* +************************************ CODE ************************************** +*******************************************************************************/ + +// ***************************************************************************** +// Function: constructor +// Purpose: +// Parameters: void +// Comments: + +FGFilter::FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), + AC_cfg(AC_cfg) +{ + string token; + + Type = AC_cfg->GetValue("TYPE"); + Name = AC_cfg->GetValue("NAME"); + AC_cfg->GetNextConfigLine(); + + C1 = C2 = C3 = C4 = C5 = C6 = 0.0; + + if (Type == "LAG_FILTER") FilterType = eLag ; + else if (Type == "RECT_LAG_FILTER") FilterType = eRectLag ; + else if (Type == "LEAD_LAG_FILTER") FilterType = eLeadLag ; + else if (Type == "SECOND_ORDER_FILTER") FilterType = eOrder2 ; + else if (Type == "WASHOUT_FILTER") FilterType = eWashout ; + else if (Type == "INTEGRATOR") FilterType = eIntegrator ; + else FilterType = eUnknown ; + + while ((token = AC_cfg->GetValue()) != "/COMPONENT") { + *AC_cfg >> token; + if (token == "ID") { + *AC_cfg >> ID; + } else if (token == "INPUT") { + token = AC_cfg->GetValue("INPUT"); + if (token.find("FG_") != token.npos) { + *AC_cfg >> token; + InputIdx = fcs->GetState()->GetParameterIndex(token); + InputType = itPilotAC; + } else { + *AC_cfg >> InputIdx; + InputType = itFCS; + } + } else if (token == "C1") { + *AC_cfg >> C1; + } else if (token == "C2") { + *AC_cfg >> C2; + } else if (token == "C3") { + *AC_cfg >> C3; + } else if (token == "C4") { + *AC_cfg >> C4; + } else if (token == "C5") { + *AC_cfg >> C5; + } else if (token == "C6") { + *AC_cfg >> C6; + } + } + + switch (FilterType) { + case eLag: + ca = dt*C1 / (2.00 + dt*C1); + cb = (2.00 - dt*C1) / (2.00 + dt*C1); + break; + case eRectLag: + break; + case eLeadLag: + break; + case eOrder2: + break; + case eWashout: + break; + case eIntegrator: + break; + } + +} + +// ***************************************************************************** +// Function: Run +// Purpose: +// Parameters: void +// Comments: + +bool FGFilter::Run(void) +{ + FGFCSComponent::Run(); // call the base class for initialization of Input + + switch (FilterType) { + case eLag: + break; + case eRectLag: + break; + case eLeadLag: + break; + case eOrder2: + break; + case eWashout: + break; + case eIntegrator: + break; + } + + PreviousOutput2 = PreviousOutput1; + PreviousOutput1 = Output; + PreviousInput2 = PreviousInput1; + PreviousInput1 = Input; + + return true; +} + diff --git a/src/FDM/JSBSim/filtersjb/FGFilter.h b/src/FDM/JSBSim/filtersjb/FGFilter.h new file mode 100644 index 000000000..38391469e --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGFilter.h @@ -0,0 +1,84 @@ +/******************************************************************************* + + Header: FGFilter.h + Author: + Date started: + + ------------- Copyright (C) ------------- + + 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. + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +SENTRY +*******************************************************************************/ + +#ifndef FGFILTER_H +#define FGFILTER_H + +/******************************************************************************* +INCLUDES +*******************************************************************************/ + +#include "FGFCSComponent.h" +#include "../FGConfigFile.h" + +/******************************************************************************* +DEFINES +*******************************************************************************/ + +/******************************************************************************* +CLASS DECLARATION +*******************************************************************************/ + +class FGFilter : public FGFCSComponent +{ + float dt; + float ca; + float cb; + float cc; + float cd; + float C1; + float C2; + float C3; + float C4; + float C5; + float C6; + float PreviousInput1; + float PreviousInput2; + float PreviousOutput1; + float PreviousOutput2; + FGConfigFile* AC_cfg; + +protected: + enum {eLag, eRectLag, eLeadLag, eOrder2, eWashout, eIntegrator, eUnknown} FilterType; + +public: + FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg); + ~FGFilter ( ) { } //Destructor + + bool Run (void); +}; + +#endif diff --git a/src/FDM/JSBSim/filtersjb/FGGain.cpp b/src/FDM/JSBSim/filtersjb/FGGain.cpp new file mode 100644 index 000000000..129900649 --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGGain.cpp @@ -0,0 +1,144 @@ +/******************************************************************************* + + Module: FGGain.cpp + Author: + Date started: + + ------------- Copyright (C) 2000 ------------- + + 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 +-------------------------------------------------------------------------------- + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +INCLUDES +*******************************************************************************/ + +#include "FGGain.h" + +/******************************************************************************* +************************************ CODE ************************************** +*******************************************************************************/ + +// ***************************************************************************** +// Function: Constructor +// Purpose: Builds a Gain-type of FCS component. +// Parameters: void +// Comments: Types are PURE_GAIN, SCHEDULED_GAIN, and AEROSURFACE_SCALE + +FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), + AC_cfg(AC_cfg) +{ + string token; + + lookup = NULL; + Schedule.clear(); + Gain = 1.000; + Min = Max = 0; + ScheduledBy = 0; + + Type = AC_cfg->GetValue("TYPE"); + Name = AC_cfg->GetValue("NAME"); + AC_cfg->GetNextConfigLine(); + + while ((token = AC_cfg->GetValue()) != "/COMPONENT") { + *AC_cfg >> token; + if (token == "ID") { + *AC_cfg >> ID; + } else if (token == "INPUT") { + token = AC_cfg->GetValue("INPUT"); + if (token.find("FG_") != token.npos) { + *AC_cfg >> token; + InputIdx = fcs->GetState()->GetParameterIndex(token); + InputType = itPilotAC; + } else { + *AC_cfg >> InputIdx; + InputType = itFCS; + } + } else if (token == "GAIN") { + *AC_cfg >> Gain; + } else if (token == "MIN") { + *AC_cfg >> Min; + } else if (token == "MAX") { + *AC_cfg >> Max; + } else if (token == "SCHEDULED_BY") { + *AC_cfg >> ScheduledBy; + } else { + AC_cfg->ResetLineIndexToZero(); + lookup = new float[2]; + *AC_cfg >> lookup[0] >> lookup[1]; + Schedule.push_back(lookup); + } + } +} + +// ***************************************************************************** +// Function: Run +// Purpose: +// Parameters: void +// Comments: + +bool FGGain::Run(void ) +{ + float SchedGain = 1.0; + + FGFCSComponent::Run(); // call the base class for initialization of Input + + if (Type == "PURE_GAIN") { + + Output = Gain * Input; + + } else if (Type == "SCHEDULED_GAIN") { + + float LookupVal = fcs->GetState()->GetParameter(ScheduledBy); + unsigned int last = Schedule.size()-1; + float lowVal = Schedule[0][0], hiVal = Schedule[last][0]; + float factor = 1.0; + + if (LookupVal <= lowVal) Output = Gain * Schedule[0][1]; + else if (LookupVal >= hiVal) Output = Gain * Schedule[last][1]; + else { + for (unsigned int ctr = 1; ctr < last; ctr++) { + if (LookupVal < Schedule[ctr][0]) { + hiVal = Schedule[ctr][0]; + lowVal = Schedule[ctr-1][0]; + factor = (LookupVal - lowVal) / (hiVal - lowVal); + SchedGain = Schedule[ctr-1][1] + factor*(Schedule[ctr][1] - Schedule[ctr-1][1]); + Output = Gain * SchedGain * Input; + break; + } + } + } + + } else if (Type == "AEROSURFACE_SCALE") { + + if (Output >= 0.0) Output = Input * Max; + else Output = Input * (-Min); + } + + return true; +} + diff --git a/src/FDM/JSBSim/filtersjb/FGGain.h b/src/FDM/JSBSim/filtersjb/FGGain.h new file mode 100644 index 000000000..60c9f334b --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGGain.h @@ -0,0 +1,88 @@ + +/******************************************************************************* + + Header: FGGain.h + Author: + Date started: + + ------------- Copyright (C) ------------- + + 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. + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +SENTRY +*******************************************************************************/ + +#ifndef FGGAIN_H +#define FGGAIN_H + +/******************************************************************************* +INCLUDES +*******************************************************************************/ + +#ifdef FGFS +# include +# include STL_STRING + FG_USING_STD(string); +# ifdef FG_HAVE_STD_INCLUDES +# include +# else +# include +# endif +#else +# include +# include +#endif + +#include "FGFCSComponent.h" +#include "../FGConfigFile.h" + +/******************************************************************************* +DEFINES +*******************************************************************************/ + +class FGFCS; + +/******************************************************************************* +CLASS DECLARATION +*******************************************************************************/ + +class FGGain : public FGFCSComponent +{ + FGConfigFile* AC_cfg; + float Gain; + float* lookup; + vector< float* > Schedule; + float Min, Max; + int ScheduledBy; + +public: + FGGain(FGFCS* fcs, FGConfigFile* AC_cfg); + ~FGGain ( ) { } //Destructor + + bool Run (void); +}; + +#endif diff --git a/src/FDM/JSBSim/filtersjb/FGGradient.cpp b/src/FDM/JSBSim/filtersjb/FGGradient.cpp new file mode 100644 index 000000000..f58ffbc5c --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGGradient.cpp @@ -0,0 +1,73 @@ + +/******************************************************************************* + + Module: FGGradient.cpp + Author: + Date started: + + ------------- Copyright (C) 2000 ------------- + + 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 +-------------------------------------------------------------------------------- + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +INCLUDES +*******************************************************************************/ + +#include "FGGradient.h" + +/******************************************************************************* +************************************ CODE ************************************** +*******************************************************************************/ + +// ***************************************************************************** +// Function: Run +// Purpose: +// Parameters: void +// Comments: + +FGGradient::FGGradient(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), + AC_cfg(AC_cfg) +{ + Type = AC_cfg->GetValue("TYPE"); + Name = AC_cfg->GetValue("NAME"); + +} + +// ***************************************************************************** +// Function: Run +// Purpose: +// Parameters: void +// Comments: + +bool FGGradient::Run(void ) +{ + FGFCSComponent::Run(); // call the base class for initialization of Input + + return true; +} + diff --git a/src/FDM/JSBSim/filtersjb/FGGradient.h b/src/FDM/JSBSim/filtersjb/FGGradient.h new file mode 100644 index 000000000..7433c36e3 --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGGradient.h @@ -0,0 +1,69 @@ + +/******************************************************************************* + + Header: FGGradient.h + Author: + Date started: + + ------------- Copyright (C) ------------- + + 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. + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +SENTRY +*******************************************************************************/ + +#ifndef FGGRADIENT_H +#define FGGRADIENT_H + +/******************************************************************************* +INCLUDES +*******************************************************************************/ + +#include "FGFCSComponent.h" +#include "../FGConfigFile.h" + +/******************************************************************************* +DEFINES +*******************************************************************************/ + +class FGFCS; + +/******************************************************************************* +CLASS DECLARATION +*******************************************************************************/ + +class FGGradient : public FGFCSComponent +{ + FGConfigFile* AC_cfg; + +public: + FGGradient(FGFCS* fcs, FGConfigFile* AC_cfg); + ~ FGGradient ( ) { } //Destructor + + bool Run (void ) ; +}; + +#endif diff --git a/src/FDM/JSBSim/filtersjb/FGSummer.cpp b/src/FDM/JSBSim/filtersjb/FGSummer.cpp new file mode 100644 index 000000000..4f7c4bce1 --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGSummer.cpp @@ -0,0 +1,119 @@ + +/******************************************************************************* + + Module: FGSummer.cpp + Author: + Date started: + + ------------- Copyright (C) 2000 ------------- + + 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 +-------------------------------------------------------------------------------- + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +INCLUDES +*******************************************************************************/ + +#include "FGSummer.h" + +/******************************************************************************* +************************************ CODE ************************************** +*******************************************************************************/ + +// ***************************************************************************** +// Function: Constructor +// Purpose: +// Parameters: void +// Comments: + +FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), + AC_cfg(AC_cfg) +{ + string token; + int tmpInputIndex; + + InputIndices.clear(); + InputTypes.clear(); + + Type = AC_cfg->GetValue("TYPE"); + Name = AC_cfg->GetValue("NAME"); + AC_cfg->GetNextConfigLine(); + + while ((token = AC_cfg->GetValue()) != "/COMPONENT") { + *AC_cfg >> token; + if (token == "ID") { + *AC_cfg >> ID; + } else if (token == "INPUT") { + token = AC_cfg->GetValue("INPUT"); + if (token.find("FG_") != token.npos) { + *AC_cfg >> token; + tmpInputIndex = fcs->GetState()->GetParameterIndex(token); + InputIndices.push_back(tmpInputIndex); + InputTypes.push_back(itPilotAC); + } else { + *AC_cfg >> tmpInputIndex; + InputIndices.push_back(tmpInputIndex); + InputTypes.push_back(itFCS); + } + } else if (token == "OUTPUT") { + IsOutput = true; + *AC_cfg >> sOutputIdx; + OutputIdx = fcs->GetState()->GetParameterIndex(sOutputIdx); + } + } +} + +// ***************************************************************************** +// Function: Run +// Purpose: +// Parameters: void +// Comments: + +bool FGSummer::Run(void ) +{ + unsigned int idx; + + // The Summer takes several inputs, so do not call the base class Run() + // FGFCSComponent::Run(); + + Output = 0.0; + for (idx=0; idxGetState()->GetParameter(InputIndices[idx]); + break; + case itFCS: + Output += fcs->GetComponentOutput(InputIndices[idx]); + break; + } + } + + if (IsOutput) SetOutput(); + + return true; +} + diff --git a/src/FDM/JSBSim/filtersjb/FGSummer.h b/src/FDM/JSBSim/filtersjb/FGSummer.h new file mode 100644 index 000000000..7d1ecc4fd --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGSummer.h @@ -0,0 +1,83 @@ + +/******************************************************************************* + + Header: FGSummer.h + Author: + Date started: + + ------------- Copyright (C) ------------- + + 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. + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +SENTRY +*******************************************************************************/ + +#ifndef FGSUMMER_H +#define FGSUMMER_H + +/******************************************************************************* +INCLUDES +*******************************************************************************/ + +#ifdef FGFS +# include +# include STL_STRING + FG_USING_STD(string); +# ifdef FG_HAVE_STD_INCLUDES +# include +# else +# include +# endif +#else +# include +# include +#endif + +#include "FGFCSComponent.h" +#include "../FGConfigFile.h" + +/******************************************************************************* +DEFINES +*******************************************************************************/ + +/******************************************************************************* +CLASS DECLARATION +*******************************************************************************/ + +class FGSummer : public FGFCSComponent +{ + FGConfigFile* AC_cfg; + vector InputIndices; + vector InputTypes; + +public: + FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg); + ~FGSummer ( ) { } //Destructor + + bool Run (void ); +}; + +#endif diff --git a/src/FDM/JSBSim/filtersjb/FGSwitch.cpp b/src/FDM/JSBSim/filtersjb/FGSwitch.cpp new file mode 100644 index 000000000..8de5203d1 --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGSwitch.cpp @@ -0,0 +1,72 @@ + +/******************************************************************************* + + Module: FGSwitch.cpp + Author: + Date started: + + ------------- Copyright (C) 2000 ------------- + + 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 +-------------------------------------------------------------------------------- + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +INCLUDES +*******************************************************************************/ + +#include "FGSwitch.h" + +/******************************************************************************* +************************************ CODE ************************************** +*******************************************************************************/ + +// ***************************************************************************** +// Function: constructor +// Purpose: +// Parameters: void +// Comments: + +FGSwitch::FGSwitch(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), + AC_cfg(AC_cfg) +{ + Type = AC_cfg->GetValue("TYPE"); + Name = AC_cfg->GetValue("NAME"); +} + +// ***************************************************************************** +// Function: Run +// Purpose: +// Parameters: void +// Comments: + +bool FGSwitch::Run(void ) +{ + FGFCSComponent::Run(); // call the base class for initialization of Input + + return true; +} + diff --git a/src/FDM/JSBSim/filtersjb/FGSwitch.h b/src/FDM/JSBSim/filtersjb/FGSwitch.h new file mode 100644 index 000000000..3e95a9e71 --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/FGSwitch.h @@ -0,0 +1,68 @@ + +/******************************************************************************* + + Header: FGSwitch.h + Author: + Date started: + + ------------- Copyright (C) ------------- + + 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. + +HISTORY +-------------------------------------------------------------------------------- + +******************************************************************************** +COMMENTS, REFERENCES, and NOTES +******************************************************************************** + +******************************************************************************** +SENTRY +*******************************************************************************/ + +#ifndef FGSWITCH_H +#define FGSWITCH_H + +/******************************************************************************* +INCLUDES +*******************************************************************************/ + +#include "FGFCSComponent.h" +#include "../FGConfigFile.h" + +/******************************************************************************* +DEFINES +*******************************************************************************/ + +/******************************************************************************* +CLASS DECLARATION +*******************************************************************************/ + +class FGSwitch : public FGFCSComponent +{ + FGFCS* fcs; + FGConfigFile* AC_cfg; + +public: + FGSwitch(FGFCS* fcs, FGConfigFile* AC_cfg); + ~ FGSwitch ( ) { } //Destructor + + bool Run (void ) ; +}; + +#endif diff --git a/src/FDM/JSBSim/filtersjb/Makefile.am b/src/FDM/JSBSim/filtersjb/Makefile.am new file mode 100644 index 000000000..9b3a651fd --- /dev/null +++ b/src/FDM/JSBSim/filtersjb/Makefile.am @@ -0,0 +1,16 @@ +EXTRA_DIST = Makefile.solo + +noinst_LIBRARIES = libfiltersjb.a + +libfiltersjb_a_SOURCES = \ + FGDeadBand.cpp FGDeadBand.h \ + FGFCSComponent.cpp FGFCSComponent.h \ + FGFilter.cpp FGFilter.h \ + FGGain.cpp FGGain.h \ + FGGradient.cpp FGGradient.h \ + FGSummer.cpp FGSummer.h \ + FGSwitch.cpp FGSwitch.h + +INCLUDES += -I$(top_builddir)/src + +DEFS += -DFGFS