From 5fcabc9982fabfe80060b7ccf52fb0d8ad9e3310 Mon Sep 17 00:00:00 2001 From: tony Date: Sat, 6 Apr 2002 16:03:16 +0000 Subject: [PATCH] Converted FCS to use property tree internally, documentation updates. --- src/FDM/JSBSim/FGAerodynamics.h | 17 +- src/FDM/JSBSim/FGAircraft.cpp | 23 +- src/FDM/JSBSim/FGAircraft.h | 5 +- src/FDM/JSBSim/FGAtmosphere.cpp | 5 +- src/FDM/JSBSim/FGAtmosphere.h | 4 + src/FDM/JSBSim/FGAuxiliary.h | 5 +- src/FDM/JSBSim/FGCoefficient.cpp | 9 +- src/FDM/JSBSim/FGCoefficient.h | 5 +- src/FDM/JSBSim/FGConfigFile.h | 5 +- src/FDM/JSBSim/FGFCS.cpp | 67 +- src/FDM/JSBSim/FGFCS.h | 20 +- src/FDM/JSBSim/FGFactorGroup.h | 5 +- src/FDM/JSBSim/FGInitialCondition.h | 4 + src/FDM/JSBSim/FGLGear.h | 4 + src/FDM/JSBSim/FGNozzle.h | 6 +- src/FDM/JSBSim/FGPiston.h | 4 + src/FDM/JSBSim/FGPosition.h | 4 + src/FDM/JSBSim/FGPropeller.h | 4 + src/FDM/JSBSim/FGPropertyManager.h | 9 + src/FDM/JSBSim/FGPropulsion.cpp | 1 + src/FDM/JSBSim/FGPropulsion.h | 9 +- src/FDM/JSBSim/FGRocket.h | 4 + src/FDM/JSBSim/FGScript.cpp | 42 +- src/FDM/JSBSim/FGScript.h | 9 +- src/FDM/JSBSim/FGState.cpp | 688 +++----------------- src/FDM/JSBSim/FGState.h | 61 +- src/FDM/JSBSim/FGTable.h | 4 + src/FDM/JSBSim/FGTrim.h | 6 +- src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp | 16 +- src/FDM/JSBSim/filtersjb/FGFCSComponent.h | 11 +- src/FDM/JSBSim/filtersjb/FGFilter.cpp | 14 +- src/FDM/JSBSim/filtersjb/FGFilter.h | 4 + src/FDM/JSBSim/filtersjb/FGGain.cpp | 32 +- src/FDM/JSBSim/filtersjb/FGGain.h | 3 +- src/FDM/JSBSim/filtersjb/FGKinemat.cpp | 29 +- src/FDM/JSBSim/filtersjb/FGSummer.cpp | 52 +- src/FDM/JSBSim/filtersjb/FGSummer.h | 13 +- 37 files changed, 417 insertions(+), 786 deletions(-) diff --git a/src/FDM/JSBSim/FGAerodynamics.h b/src/FDM/JSBSim/FGAerodynamics.h index 924d82460..0fa843abf 100644 --- a/src/FDM/JSBSim/FGAerodynamics.h +++ b/src/FDM/JSBSim/FGAerodynamics.h @@ -85,7 +85,10 @@ CLASS DOCUMENTATION as ground effect and maximum lift curve tailoff are handled. @author Jon S. Berndt @version $Id$ - @see - + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -112,17 +115,17 @@ public: /** Gets the total aerodynamic force vector. @return a force vector reference. */ FGColumnVector3& GetForces(void) {return vForces;} - inline double GetForces(int n) const {return vForces(n);} + double GetForces(int n) const {return vForces(n);} /** Gets the total aerodynamic moment vector. @return a moment vector reference. */ FGColumnVector3& GetMoments(void) {return vMoments;} - inline double GetMoments(int n) const {return vMoments(n);} + double GetMoments(int n) const {return vMoments(n);} - inline FGColumnVector3& GetvLastFs(void) { return vLastFs; } - inline double GetvLastFs(int axis) const { return vLastFs(axis); } - inline FGColumnVector3& GetvFs(void) { return vFs; } - inline double GetvFs(int axis) const { return vFs(axis); } + FGColumnVector3& GetvLastFs(void) { return vLastFs; } + double GetvLastFs(int axis) const { return vLastFs(axis); } + FGColumnVector3& GetvFs(void) { return vFs; } + double GetvFs(int axis) const { return vFs(axis); } inline double GetLoD(void) const { return lod; } inline double GetClSquared(void) const { return clsq; } diff --git a/src/FDM/JSBSim/FGAircraft.cpp b/src/FDM/JSBSim/FGAircraft.cpp index f273d4889..37f2efeb4 100644 --- a/src/FDM/JSBSim/FGAircraft.cpp +++ b/src/FDM/JSBSim/FGAircraft.cpp @@ -102,12 +102,15 @@ CLASS IMPLEMENTATION FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex) { Name = "FGAircraft"; - alphaclmin = alphaclmax = 0; - HTailArea = VTailArea = HTailArm = VTailArm = 0.0; - lbarh = lbarv = vbarh = vbarv = 0.0; - WingIncidence=0; - impending_stall = 0; - bi2vel=ci2vel=alphaw=0; + WingIncidence = 0.0; + impending_stall = 0.0; + alphaclmin = alphaclmax = 0.0; + HTailArea = VTailArea = 0.0; + HTailArm = VTailArm = 0.0; + lbarh = lbarv = 0.0; + vbarh = vbarv = 0.0; + bi2vel = ci2vel = 0.0; + alphaw = 0.0; bind(); @@ -147,8 +150,8 @@ bool FGAircraft::Run(void) vNwcg = State->GetTb2s() * vNcg; vNwcg(3) = -1*vNwcg(3) + 1; - twovel=2*Translation->GetVt(); - if(twovel > 0) { + twovel = 2*Translation->GetVt(); + if (twovel > 0) { bi2vel = WingSpan / twovel; ci2vel = cbar / twovel; } @@ -372,8 +375,8 @@ void FGAircraft::unbind(void) PropertyManager->Untie("metrics/eyepoint-x-ft"); PropertyManager->Untie("metrics/eyepoint-y-ft"); PropertyManager->Untie("metrics/eyepoint-z-ft"); - PropertyManager->Untie("metrics/alpha-max-rad"); - PropertyManager->Untie("metrics/alpha-min-rad"); + PropertyManager->Untie("metrics/alpha-max-deg"); + PropertyManager->Untie("metrics/alpha-min-deg"); PropertyManager->Untie("aero/bi2vel"); PropertyManager->Untie("aero/ci2vel"); PropertyManager->Untie("aero/alpha-wing-rad"); diff --git a/src/FDM/JSBSim/FGAircraft.h b/src/FDM/JSBSim/FGAircraft.h index 1a4870c43..8438aba13 100644 --- a/src/FDM/JSBSim/FGAircraft.h +++ b/src/FDM/JSBSim/FGAircraft.h @@ -99,6 +99,10 @@ CLASS DOCUMENTATION Wiley & Sons, 1979 ISBN 0-471-03032-5
  • Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons, 1982 ISBN 0-471-08936-2
  • + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -167,7 +171,6 @@ public: double GetCI2Vel(void) const { return ci2vel; } double GetAlphaW(void) const { return alphaw; } - float GetNlf(void); inline FGColumnVector3& GetNwcg(void) { return vNwcg; } diff --git a/src/FDM/JSBSim/FGAtmosphere.cpp b/src/FDM/JSBSim/FGAtmosphere.cpp index 814c92c7d..c8dea78b7 100644 --- a/src/FDM/JSBSim/FGAtmosphere.cpp +++ b/src/FDM/JSBSim/FGAtmosphere.cpp @@ -72,8 +72,9 @@ CLASS IMPLEMENTATION FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex) { Name = "FGAtmosphere"; - lastIndex=0; - h = 0; + lastIndex = 0; + h = 0.0; + psiw = 0.0; htab[0]=0; htab[1]=36089.239; htab[2]=65616.798; diff --git a/src/FDM/JSBSim/FGAtmosphere.h b/src/FDM/JSBSim/FGAtmosphere.h index 7cc30a5fa..f4c6fcf44 100644 --- a/src/FDM/JSBSim/FGAtmosphere.h +++ b/src/FDM/JSBSim/FGAtmosphere.h @@ -71,6 +71,10 @@ CLASS DOCUMENTATION /** Models the standard atmosphere. @author Tony Peden, Jon Berndt @version $Id$ + @see + Header File + @see + Source File */ /****************************************************************************** diff --git a/src/FDM/JSBSim/FGAuxiliary.h b/src/FDM/JSBSim/FGAuxiliary.h index 3fed37c1f..9210156c6 100644 --- a/src/FDM/JSBSim/FGAuxiliary.h +++ b/src/FDM/JSBSim/FGAuxiliary.h @@ -65,7 +65,10 @@ CLASS DOCUMENTATION /** Encapsulates various uncategorized scheduled functions. @author Tony Peden, Jon Berndt @version $Id$ - @see - + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGCoefficient.cpp b/src/FDM/JSBSim/FGCoefficient.cpp index 7714e7eaf..11deb848a 100644 --- a/src/FDM/JSBSim/FGCoefficient.cpp +++ b/src/FDM/JSBSim/FGCoefficient.cpp @@ -122,13 +122,13 @@ bool FGCoefficient::Load(FGConfigFile *AC_cfg) } *AC_cfg >> multparmsRow; - prop = State->GetPropertyName( State->GetParameterIndex(multparmsRow) ); + prop = State->GetPropertyName( multparmsRow ); LookupR = PropertyManager->GetNode( prop ); } if (type == TABLE) { *AC_cfg >> multparmsCol; - prop = State->GetPropertyName( State->GetParameterIndex(multparmsCol) ); + prop = State->GetPropertyName( multparmsCol ); LookupC = PropertyManager->GetNode( prop ); } @@ -147,13 +147,12 @@ bool FGCoefficient::Load(FGConfigFile *AC_cfg) while (n < end && n >= 0) { n -= start; mult = multparms.substr(start,n); - prop= State->GetPropertyName( State->GetParameterIndex(mult) ); + prop= State->GetPropertyName( mult ); multipliers.push_back( PropertyManager->GetNode(prop) ); start += n+1; n = multparms.find("|",start); } - prop=State->GetPropertyName( - State->GetParameterIndex( multparms.substr(start,n) ) ); + prop=State->GetPropertyName( multparms.substr(start,n) ); mult = multparms.substr(start,n); multipliers.push_back( PropertyManager->GetNode(prop) ); // End of non-dimensionalizing parameter read-in diff --git a/src/FDM/JSBSim/FGCoefficient.h b/src/FDM/JSBSim/FGCoefficient.h index ca262c8fe..0ddbeb696 100644 --- a/src/FDM/JSBSim/FGCoefficient.h +++ b/src/FDM/JSBSim/FGCoefficient.h @@ -89,7 +89,10 @@ CLASS DOCUMENTATION is called and the coefficient value is calculated. @author Jon S. Berndt @version $Id$ - @see - + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGConfigFile.h b/src/FDM/JSBSim/FGConfigFile.h index d4144b561..e1b7e55c0 100644 --- a/src/FDM/JSBSim/FGConfigFile.h +++ b/src/FDM/JSBSim/FGConfigFile.h @@ -96,7 +96,10 @@ CLASS DOCUMENTATION JSBSim config files are in XML format. @author Jon S. Berndt @version $Id$ - @see - + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGFCS.cpp b/src/FDM/JSBSim/FGFCS.cpp index adcf66554..58a683c60 100644 --- a/src/FDM/JSBSim/FGFCS.cpp +++ b/src/FDM/JSBSim/FGFCS.cpp @@ -162,7 +162,7 @@ void FGFCS::SetThrottlePos(int engineNum, double setting) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -double FGFCS::GetThrottleCmd(int engineNum) +double FGFCS::GetThrottleCmd(int engineNum) const { if (engineNum < (int)ThrottlePos.size()) { if (engineNum < 0) { @@ -180,7 +180,7 @@ double FGFCS::GetThrottleCmd(int engineNum) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -double FGFCS::GetThrottlePos(int engineNum) +double FGFCS::GetThrottlePos(int engineNum) const { if (engineNum < (int)ThrottlePos.size()) { if (engineNum < 0) { @@ -306,36 +306,40 @@ bool FGFCS::Load(FGConfigFile* AC_cfg) } } //collect information for normalizing control surfaces - + string nodeName; for(i=0;iGetType() == "AEROSURFACE_SCALE" - || Components[i]->GetType() == "KINEMAT" ) { - if( Components[i]->GetOutputIdx() == FG_ELEVATOR_POS ) { + if( (Components[i]->GetType() == "AEROSURFACE_SCALE" + || Components[i]->GetType() == "KINEMAT") + && Components[i]->GetOutputNode() ) { + nodeName= Components[i]->GetOutputNode()->GetName(); + if( nodeName == "elevator-pos-rad" ) { ToNormalize[iDe]=i; - } else if ( Components[i]->GetOutputIdx() == FG_LEFT_AILERON_POS - || Components[i]->GetOutputIdx() == FG_AILERON_POS ) { + } else if ( nodeName == "left-aileron-pos-rad" + || nodeName == "aileron-pos-rad" ) { ToNormalize[iDaL]=i; - } else if ( Components[i]->GetOutputIdx() == FG_RIGHT_AILERON_POS ) { + } else if ( nodeName == "right-aileron-pos-rad" ) { ToNormalize[iDaR]=i; - } else if ( Components[i]->GetOutputIdx() == FG_RUDDER_POS ) { + } else if ( nodeName == "rudder-pos-rad" ) { ToNormalize[iDr]=i; - } else if ( Components[i]->GetOutputIdx() == FG_SPDBRAKE_POS ) { + } else if ( nodeName == "speedbrake-pos-rad" ) { ToNormalize[iDsb]=i; - } else if ( Components[i]->GetOutputIdx() == FG_SPOILERS_POS ) { + } else if ( nodeName == "spoiler-pos-rad" ) { ToNormalize[iDsp]=i; - } else if ( Components[i]->GetOutputIdx() == FG_FLAPS_POS ) { + } else if ( nodeName == "flaps-pos-deg" ) { ToNormalize[iDf]=i; } } } + bindModel(); + return true; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -double FGFCS::GetComponentOutput(eParam idx) { +double FGFCS::GetComponentOutput(int idx) { return Components[idx]->GetOutput(); } @@ -594,7 +598,42 @@ void FGFCS::bind(void){ &FGFCS::SetGearPos, true); } +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +void FGFCS::bindModel(void){ + unsigned i; + for(i=0;iTie("fcs/throttle-cmd-norm",this,i, + &FGFCS::GetThrottleCmd, + &FGFCS::SetThrottleCmd, + true ); + PropertyManager->Tie("fcs/throttle-pos-norm",this,i, + &FGFCS::GetThrottlePos, + &FGFCS::SetThrottlePos, + true ); + if( MixtureCmd.size() > i ) { + PropertyManager->Tie("fcs/mixture-cmd-norm",this,i, + &FGFCS::GetMixtureCmd, + &FGFCS::SetMixtureCmd, + true ); + PropertyManager->Tie("fcs/mixture-pos-norm",this,i, + &FGFCS::GetMixturePos, + &FGFCS::SetMixturePos, + true ); + } + if( PropAdvanceCmd.size() > i ) { + PropertyManager->Tie("fcs/advance-cmd-norm",this,i, + &FGFCS::GetPropAdvanceCmd, + &FGFCS::SetPropAdvanceCmd, + true ); + PropertyManager->Tie("fcs/advance-pos-norm",this,i, + &FGFCS::GetPropAdvance, + &FGFCS::SetPropAdvance, + true ); + } + } +} + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void FGFCS::unbind(void){ diff --git a/src/FDM/JSBSim/FGFCS.h b/src/FDM/JSBSim/FGFCS.h index 7734fe48a..fa0a8baf1 100644 --- a/src/FDM/JSBSim/FGFCS.h +++ b/src/FDM/JSBSim/FGFCS.h @@ -65,10 +65,8 @@ DEFINITIONS FORWARD DECLARATIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -typedef enum { iDe=0, iDaL, iDaR, iDr, iDsb, iDsp, iDf } FcIdx; -int const NNorm=7; -typedef enum { ofRad=0, ofNorm, ofMag } OutputForm; -int const NForms=3; +typedef enum { iDe=0, iDaL, iDaR, iDr, iDsb, iDsp, iDf, NNorm } FcIdx; +typedef enum { ofRad=0, ofNorm, ofMag , NForms} OutputForm; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs] @@ -152,6 +150,10 @@ CLASS DOCUMENTATION @see FGGradient @see FGFilter @see FGDeadBand + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -200,7 +202,7 @@ public: /** Gets the throttle command. @param engine engine ID number @return throttle command in percent ( 0 - 100) for the given engine */ - double GetThrottleCmd(int engine); + double GetThrottleCmd(int engine) const; /** Gets the mixture command. @param engine engine ID number @@ -272,7 +274,7 @@ public: /** Gets the throttle position. @param engine engine ID number @return throttle position for the given engine in percent ( 0 - 100)*/ - double GetThrottlePos(int engine); + double GetThrottlePos(int engine) const; /** Gets the mixture position. @param engine engine ID number @@ -297,7 +299,7 @@ public: /** Retrieves a components output value @param idx the index of the component (the component ID) @return output value from the component */ - double GetComponentOutput(eParam idx); + double GetComponentOutput(int idx); /** Retrieves the component name @param idx the index of the component (the component ID) @@ -456,9 +458,11 @@ public: void AddThrottle(void); + FGPropertyManager* GetPropertyManager(void) { return PropertyManager; } + void bind(void); + void bindModel(void); void unbind(void); - private: double DaCmd, DeCmd, DrCmd, DfCmd, DsbCmd, DspCmd; diff --git a/src/FDM/JSBSim/FGFactorGroup.h b/src/FDM/JSBSim/FGFactorGroup.h index 296f2a0fb..2b4b7ae43 100644 --- a/src/FDM/JSBSim/FGFactorGroup.h +++ b/src/FDM/JSBSim/FGFactorGroup.h @@ -85,7 +85,10 @@ CLASS DOCUMENTATION /** This class encapsulates the functionality needed to manage a factor group i.e. factor*(coeff1 + coeff2 + coeff3) @author Tony Peden - @see - + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGInitialCondition.h b/src/FDM/JSBSim/FGInitialCondition.h index 042cdedac..a68bd0063 100644 --- a/src/FDM/JSBSim/FGInitialCondition.h +++ b/src/FDM/JSBSim/FGInitialCondition.h @@ -126,6 +126,10 @@ CLASS DOCUMENTATION considered equivalent to setting gamma. @author Anthony K. Peden @version $Id$ + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGLGear.h b/src/FDM/JSBSim/FGLGear.h index 84520b5e7..f9e22797b 100644 --- a/src/FDM/JSBSim/FGLGear.h +++ b/src/FDM/JSBSim/FGLGear.h @@ -169,6 +169,10 @@ CLASS DOCUMENTATION Wiley & Sons, 1979 ISBN 0-471-03032-5 @see W. A. Ragsdale, "A Generic Landing Gear Dynamics Model for LASRS++", AIAA-2000-4303 + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGNozzle.h b/src/FDM/JSBSim/FGNozzle.h index c0b0b9b56..08906083c 100644 --- a/src/FDM/JSBSim/FGNozzle.h +++ b/src/FDM/JSBSim/FGNozzle.h @@ -59,7 +59,11 @@ CLASS DOCUMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ /** Models a rocket nozzle. - */ + @see + Header File + @see + Source File +*/ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CLASS DECLARATION diff --git a/src/FDM/JSBSim/FGPiston.h b/src/FDM/JSBSim/FGPiston.h index 02fa16892..a6841faab 100644 --- a/src/FDM/JSBSim/FGPiston.h +++ b/src/FDM/JSBSim/FGPiston.h @@ -70,6 +70,10 @@ DOCUMENTATION @author Dave Luff (engine operational code) @author David Megginson (porting and additional code) @version $Id$ + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGPosition.h b/src/FDM/JSBSim/FGPosition.h index 00b95c24a..0fd024354 100644 --- a/src/FDM/JSBSim/FGPosition.h +++ b/src/FDM/JSBSim/FGPosition.h @@ -64,6 +64,10 @@ DOCUMENTATION /** Models the lateral and longitudinal translational EOM. @author Jon S. Berndt @version $Id$ + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGPropeller.h b/src/FDM/JSBSim/FGPropeller.h index 14fe39bdd..f6ed849af 100644 --- a/src/FDM/JSBSim/FGPropeller.h +++ b/src/FDM/JSBSim/FGPropeller.h @@ -81,6 +81,10 @@ CLASS DOCUMENTATION @see FGEngine @see FGThruster @see FGTable + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGPropertyManager.h b/src/FDM/JSBSim/FGPropertyManager.h index a3051196a..cad5dc5ff 100644 --- a/src/FDM/JSBSim/FGPropertyManager.h +++ b/src/FDM/JSBSim/FGPropertyManager.h @@ -61,6 +61,8 @@ CLASS DOCUMENTATION @author David Megginson, Tony Peden @see Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -113,6 +115,13 @@ class FGPropertyManager:public SGPropertyNode { return (GetNode(path, false) != 0); } + /** + * Get the name of a node + */ + inline string + GetName( void ) { + return string( getName() ); + } /** * Get a bool value for a property. diff --git a/src/FDM/JSBSim/FGPropulsion.cpp b/src/FDM/JSBSim/FGPropulsion.cpp index 645ff44db..39f278a96 100644 --- a/src/FDM/JSBSim/FGPropulsion.cpp +++ b/src/FDM/JSBSim/FGPropulsion.cpp @@ -69,6 +69,7 @@ FGPropulsion::FGPropulsion(FGFDMExec* exec) : FGModel(exec) numSelectedFuelTanks = numSelectedOxiTanks = 0; numTanks = numEngines = numThrusters = 0; numOxiTanks = numFuelTanks = 0; + dt = 0.0; bind(); Debug(0); } diff --git a/src/FDM/JSBSim/FGPropulsion.h b/src/FDM/JSBSim/FGPropulsion.h index 08f6efd2b..430481178 100644 --- a/src/FDM/JSBSim/FGPropulsion.h +++ b/src/FDM/JSBSim/FGPropulsion.h @@ -90,15 +90,22 @@ CLASS DOCUMENTATION @see FGEngine @see FGTank @see FGThruster + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CLASS DECLARATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -class FGPropulsion : public FGModel { +class FGPropulsion : public FGModel +{ public: + /// Constructor FGPropulsion(FGFDMExec*); + /// Destructor ~FGPropulsion(); /** Executes the propulsion model. diff --git a/src/FDM/JSBSim/FGRocket.h b/src/FDM/JSBSim/FGRocket.h index dd54ae2a0..58142fb49 100644 --- a/src/FDM/JSBSim/FGRocket.h +++ b/src/FDM/JSBSim/FGRocket.h @@ -94,6 +94,10 @@ CLASS DOCUMENTATION @see FGEngine @see FGPropulsion @see FGTank + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGScript.cpp b/src/FDM/JSBSim/FGScript.cpp index 25e1dc685..796f2c338 100644 --- a/src/FDM/JSBSim/FGScript.cpp +++ b/src/FDM/JSBSim/FGScript.cpp @@ -73,6 +73,7 @@ CLASS IMPLEMENTATION FGScript::FGScript(FGFDMExec* fgex) : FDMExec(fgex) { State = FDMExec->GetState(); + PropertyManager=FDMExec->GetPropertyManager(); Debug(0); } @@ -91,6 +92,7 @@ bool FGScript::LoadScript(string script) string token=""; string aircraft=""; string initialize=""; + string prop_name; bool result = false; double dt = 0.0; struct condition *newCondition; @@ -113,6 +115,11 @@ bool FGScript::LoadScript(string script) if (token == "use") { if ((token = Script.GetValue("aircraft")) != string("")) { aircraft = token; + result = FDMExec->LoadModel("aircraft", "engine", aircraft); + if (!result) { + cerr << "Aircraft file " << aircraft << " was not found" << endl; + exit(-1); + } if (debug_lvl > 0) cout << " Use aircraft: " << token << endl; } else if ((token = Script.GetValue("initialize")) != string("")) { initialize = token; @@ -136,11 +143,13 @@ bool FGScript::LoadScript(string script) newCondition = new struct condition(); while (token != string("/when")) { if (token == "parameter") { - newCondition->TestParam.push_back(State->GetParameterIndex(Script.GetValue("name"))); + prop_name = State->GetPropertyName( Script.GetValue("name") ); + newCondition->TestParam.push_back( PropertyManager->GetNode(prop_name) ); newCondition->TestValue.push_back(strtod(Script.GetValue("value").c_str(), NULL)); newCondition->Comparison.push_back(Script.GetValue("comparison")); } else if (token == "set") { - newCondition->SetParam.push_back(State->GetParameterIndex(Script.GetValue("name"))); + prop_name = State->GetPropertyName( Script.GetValue("name") ); + newCondition->SetParam.push_back( PropertyManager->GetNode(prop_name) ); newCondition->SetValue.push_back(strtod(Script.GetValue("value").c_str(), NULL)); newCondition->Triggered.push_back(false); newCondition->OriginalValue.push_back(0.0); @@ -194,11 +203,6 @@ bool FGScript::LoadScript(string script) Debug(4); - result = FDMExec->LoadModel("aircraft", "engine", aircraft); - if (!result) { - cerr << "Aircraft file " << aircraft << " was not found" << endl; - exit(-1); - } FGInitialCondition IC(FDMExec); if ( ! IC.Load("aircraft", aircraft, initialize)) { @@ -228,17 +232,17 @@ bool FGScript::RunScript(void) // to true for (i=0; iTestValue.size(); i++) { if (iC->Comparison[i] == "lt") - truth = State->GetParameter(iC->TestParam[i]) < iC->TestValue[i]; + truth = iC->TestParam[i]->getDoubleValue() < iC->TestValue[i]; else if (iC->Comparison[i] == "le") - truth = State->GetParameter(iC->TestParam[i]) <= iC->TestValue[i]; + truth = iC->TestParam[i]->getDoubleValue() <= iC->TestValue[i]; else if (iC->Comparison[i] == "eq") - truth = State->GetParameter(iC->TestParam[i]) == iC->TestValue[i]; + truth = iC->TestParam[i]->getDoubleValue() == iC->TestValue[i]; else if (iC->Comparison[i] == "ge") - truth = State->GetParameter(iC->TestParam[i]) >= iC->TestValue[i]; + truth = iC->TestParam[i]->getDoubleValue() >= iC->TestValue[i]; else if (iC->Comparison[i] == "gt") - truth = State->GetParameter(iC->TestParam[i]) > iC->TestValue[i]; + truth = iC->TestParam[i]->getDoubleValue() > iC->TestValue[i]; else if (iC->Comparison[i] == "ne") - truth = State->GetParameter(iC->TestParam[i]) != iC->TestValue[i]; + truth = iC->TestParam[i]->getDoubleValue() != iC->TestValue[i]; else cerr << "Bad comparison" << endl; @@ -253,7 +257,7 @@ bool FGScript::RunScript(void) if (WholeTruth) { for (i=0; iSetValue.size(); i++) { if ( ! iC->Triggered[i]) { - iC->OriginalValue[i] = State->GetParameter(iC->SetParam[i]); + iC->OriginalValue[i] = iC->SetParam[i]->getDoubleValue(); switch (iC->Type[i]) { case FG_VALUE: iC->newValue[i] = iC->SetValue[i]; @@ -289,7 +293,7 @@ bool FGScript::RunScript(void) cerr << "Invalid Action specified" << endl; break; } - State->SetParameter(iC->SetParam[i], newSetValue); + iC->SetParam[i]->setDoubleValue(newSetValue); } } iC++; @@ -338,15 +342,15 @@ void FGScript::Debug(int from) for (i=0; iTestValue.size(); i++) { if (i>0) cout << " and" << endl << " "; - cout << "(" << State->GetParameterName(iterConditions->TestParam[i]) - << iterConditions->Comparison[i] << " " + cout << "(" << iterConditions->TestParam[i]->GetName() + << " " << iterConditions->Comparison[i] << " " << iterConditions->TestValue[i] << ")"; } cout << ") then {"; for (i=0; iSetValue.size(); i++) { - cout << endl << " set" << State->GetParameterName(iterConditions->SetParam[i]) - << "to " << iterConditions->SetValue[i]; + cout << endl << " set " << iterConditions->SetParam[i]->GetName() + << " to " << iterConditions->SetValue[i]; switch (iterConditions->Type[i]) { case FG_VALUE: diff --git a/src/FDM/JSBSim/FGScript.h b/src/FDM/JSBSim/FGScript.h index d1ccc88a6..0aa7d5d2c 100644 --- a/src/FDM/JSBSim/FGScript.h +++ b/src/FDM/JSBSim/FGScript.h @@ -63,6 +63,10 @@ CLASS DOCUMENTATION /** Encapsulates the JSBSim scripting capability. @author Jon S. Berndt @version $Id$ + @see + Header File + @see + Source File

    Scripting support provided via FGScript.

    @@ -163,8 +167,8 @@ private: }; struct condition { - vector TestParam; - vector SetParam; + vector TestParam; + vector SetParam; vector TestValue; vector SetValue; vector Comparison; @@ -191,6 +195,7 @@ private: FGFDMExec* FDMExec; FGState* State; + FGPropertyManager* PropertyManager; void Debug(int from); }; diff --git a/src/FDM/JSBSim/FGState.cpp b/src/FDM/JSBSim/FGState.cpp index a3a230450..3359a8549 100644 --- a/src/FDM/JSBSim/FGState.cpp +++ b/src/FDM/JSBSim/FGState.cpp @@ -47,8 +47,7 @@ INCLUDES # endif #endif -#if defined(_MSC_VER)||defined(__BORLANDCPP__) -#pragma message("\n\nRedefining snprintf\n") +#ifdef _WIN32 #define snprintf _snprintf #endif @@ -61,7 +60,8 @@ static const char *IdHdr = ID_STATE; MACROS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#define RegisterVariable(ID,DEF) coeffdef[#ID] = ID; paramdef[ID] = DEF +//#define RegisterVariable(ID,DEF) coeffdef[#ID] = ID; paramdef[ID] = DEF +#define RegisterVariable(ID,DEF) coeffdef[#ID] = ID; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CLASS IMPLEMENTATION @@ -96,84 +96,7 @@ FGState::FGState(FGFDMExec* fdex) PropertyManager = FDMExec->GetPropertyManager(); InitPropertyMaps(); - - RegisterVariable(FG_TIME, " time " ); - RegisterVariable(FG_QBAR, " qbar " ); - RegisterVariable(FG_WINGAREA, " wing_area " ); - RegisterVariable(FG_WINGSPAN, " wingspan " ); - RegisterVariable(FG_CBAR, " cbar " ); - RegisterVariable(FG_ALPHA, " alpha " ); - RegisterVariable(FG_ALPHADOT, " alphadot " ); - RegisterVariable(FG_BETA, " beta " ); - RegisterVariable(FG_ABETA, " |beta| " ); - RegisterVariable(FG_BETADOT, " betadot " ); - RegisterVariable(FG_PHI, " roll_angle " ); - RegisterVariable(FG_THT, " pitch_angle " ); - RegisterVariable(FG_PSI, " heading_angle " ); - RegisterVariable(FG_PITCHRATE, " pitch_rate " ); - RegisterVariable(FG_ROLLRATE, " roll_rate " ); - RegisterVariable(FG_YAWRATE, " yaw_rate " ); - RegisterVariable(FG_AEROQ, " aero_pitch_rate " ); - RegisterVariable(FG_AEROP, " aero_roll_rate " ); - RegisterVariable(FG_AEROR, " aero_yaw_rate " ); - RegisterVariable(FG_CL_SQRD, " Clift_sqrd " ); - RegisterVariable(FG_MACH, " mach " ); - RegisterVariable(FG_ALTITUDE, " altitude " ); - RegisterVariable(FG_BI2VEL, " BI2Vel " ); - RegisterVariable(FG_CI2VEL, " CI2Vel " ); - RegisterVariable(FG_ELEVATOR_POS, " elevator_pos " ); - RegisterVariable(FG_AELEVATOR_POS, " |elevator_pos| " ); - RegisterVariable(FG_NELEVATOR_POS, " elevator_pos_n " ); - RegisterVariable(FG_AILERON_POS, " aileron_pos " ); - RegisterVariable(FG_AAILERON_POS, " |aileron_pos| " ); - RegisterVariable(FG_NAILERON_POS, " aileron_pos_n " ); - RegisterVariable(FG_LEFT_AILERON_POS, " left_aileron_pos " ); - RegisterVariable(FG_ALEFT_AILERON_POS, " |left_aileron_pos| " ); - RegisterVariable(FG_NLEFT_AILERON_POS, " left_aileron_pos_n " ); - RegisterVariable(FG_RIGHT_AILERON_POS, " right_aileron_pos " ); - RegisterVariable(FG_ARIGHT_AILERON_POS, " |right_aileron_pos| " ); - RegisterVariable(FG_NRIGHT_AILERON_POS, " right_aileron_pos_n " ); - RegisterVariable(FG_RUDDER_POS, " rudder_pos " ); - RegisterVariable(FG_ARUDDER_POS, " |rudder_pos| " ); - RegisterVariable(FG_NRUDDER_POS, " rudder_pos_n " ); - RegisterVariable(FG_SPDBRAKE_POS, " speedbrake_pos " ); - RegisterVariable(FG_NSPDBRAKE_POS, " speedbrake_pos_n " ); - RegisterVariable(FG_SPOILERS_POS, " spoiler_pos " ); - RegisterVariable(FG_NSPOILERS_POS, " spoiler_pos_n " ); - RegisterVariable(FG_FLAPS_POS, " flaps_pos " ); - RegisterVariable(FG_NFLAPS_POS, " flaps_pos_n " ); - RegisterVariable(FG_GEAR_POS, " gear_pos " ); - RegisterVariable(FG_ELEVATOR_CMD, " elevator_cmd " ); - RegisterVariable(FG_AILERON_CMD, " aileron_cmd " ); - RegisterVariable(FG_RUDDER_CMD, " rudder_cmd " ); - RegisterVariable(FG_SPDBRAKE_CMD, " speedbrake_cmd " ); - RegisterVariable(FG_SPOILERS_CMD, " spoiler_cmd " ); - RegisterVariable(FG_FLAPS_CMD, " flaps_cmd " ); - RegisterVariable(FG_THROTTLE_CMD, " throttle_cmd " ); - RegisterVariable(FG_GEAR_CMD, " gear_cmd " ); - RegisterVariable(FG_THROTTLE_POS, " throttle_pos " ); - RegisterVariable(FG_MIXTURE_CMD, " mixture_cmd " ); - RegisterVariable(FG_MIXTURE_POS, " mixture_pos " ); - RegisterVariable(FG_MAGNETO_CMD, " magneto_cmd " ); - RegisterVariable(FG_STARTER_CMD, " starter_cmd " ); - RegisterVariable(FG_ACTIVE_ENGINE, " active_engine " ); - RegisterVariable(FG_HOVERB, " height/span " ); - RegisterVariable(FG_PITCH_TRIM_CMD, " pitch_trim_cmd " ); - RegisterVariable(FG_YAW_TRIM_CMD, " yaw_trim_cmd " ); - RegisterVariable(FG_ROLL_TRIM_CMD, " roll_trim_cmd " ); - RegisterVariable(FG_LEFT_BRAKE_CMD, " left_brake_cmd " ); - RegisterVariable(FG_RIGHT_BRAKE_CMD, " right_brake_cmd " ); - RegisterVariable(FG_CENTER_BRAKE_CMD, " center_brake_cmd " ); - RegisterVariable(FG_ALPHAH, " h-tail alpha " ); - RegisterVariable(FG_ALPHAW, " wing alpha " ); - RegisterVariable(FG_LBARH, " h-tail arm " ); - RegisterVariable(FG_LBARV, " v-tail arm " ); - RegisterVariable(FG_HTAILAREA, " h-tail area " ); - RegisterVariable(FG_VTAILAREA, " v-tail area " ); - RegisterVariable(FG_VBARH, " h-tail volume " ); - RegisterVariable(FG_VBARV, " v-tail volume " ); - RegisterVariable(FG_SET_LOGGING, " data_logging " ); - + bind(); Debug(0); @@ -187,354 +110,6 @@ FGState::~FGState() Debug(1); } -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -double FGState::GetParameter(eParam val_idx) { - double scratch; - - switch(val_idx) { - case FG_TIME: - return sim_time; - case FG_QBAR: - return Translation->Getqbar(); - case FG_WINGAREA: - return Aircraft->GetWingArea(); - case FG_WINGSPAN: - return Aircraft->GetWingSpan(); - case FG_CBAR: - return Aircraft->Getcbar(); - case FG_LBARH: - return Aircraft->Getlbarh(); - case FG_LBARV: - return Aircraft->Getvbarh(); - case FG_HTAILAREA: - return Aircraft->GetHTailArea(); - case FG_VTAILAREA: - return Aircraft->GetVTailArea(); - case FG_VBARH: - return Aircraft->Getvbarh(); - case FG_VBARV: - return Aircraft->Getvbarv(); - case FG_ALPHA: - return Translation->Getalpha(); - case FG_ALPHAW: - return Translation->Getalpha() + Aircraft->GetWingIncidence(); - case FG_ALPHADOT: - return Translation->Getadot(); - case FG_BETA: - return Translation->Getbeta(); - case FG_ABETA: - return fabs(Translation->Getbeta()); - case FG_BETADOT: - return Translation->Getbdot(); - case FG_PHI: - return Rotation->Getphi(); - case FG_THT: - return Rotation->Gettht(); - case FG_PSI: - return Rotation->Getpsi(); - case FG_PITCHRATE: - return Rotation->GetPQR(eQ); - case FG_ROLLRATE: - return Rotation->GetPQR(eP); - case FG_YAWRATE: - return Rotation->GetPQR(eR); - case FG_AEROP: - return Rotation->GetAeroPQR(eP); - case FG_AEROQ: - return Rotation->GetAeroPQR(eQ); - case FG_AEROR: - return Rotation->GetAeroPQR(eR); - case FG_CL_SQRD: - if (Translation->Getqbar() > 0.00) - scratch = Aerodynamics->GetvLastFs(eLift)/(Aircraft->GetWingArea()*Translation->Getqbar()); - else - scratch = 0.0; - return scratch*scratch; - case FG_ELEVATOR_POS: - return FCS->GetDePos(); - case FG_AELEVATOR_POS: - return fabs(FCS->GetDePos()); - case FG_NELEVATOR_POS: - return FCS->GetDePos(ofNorm); - case FG_AILERON_POS: - return FCS->GetDaLPos(); - case FG_AAILERON_POS: - return fabs(FCS->GetDaLPos()); - case FG_NAILERON_POS: - return FCS->GetDaLPos(ofNorm); - case FG_LEFT_AILERON_POS: - return FCS->GetDaLPos(); - case FG_ALEFT_AILERON_POS: - return FCS->GetDaLPos(ofMag); - case FG_NLEFT_AILERON_POS: - return FCS->GetDaLPos(ofNorm); - case FG_RIGHT_AILERON_POS: - return FCS->GetDaRPos(); - case FG_ARIGHT_AILERON_POS: - return FCS->GetDaRPos(ofMag); - case FG_NRIGHT_AILERON_POS: - return FCS->GetDaRPos(ofNorm); - case FG_RUDDER_POS: - return FCS->GetDrPos(); - case FG_ARUDDER_POS: - return FCS->GetDrPos(ofMag); - case FG_NRUDDER_POS: - return FCS->GetDrPos(ofNorm); - case FG_SPDBRAKE_POS: - return FCS->GetDsbPos(); - case FG_NSPDBRAKE_POS: - return FCS->GetDsbPos(ofNorm); - case FG_SPOILERS_POS: - return FCS->GetDspPos(); - case FG_NSPOILERS_POS: - return FCS->GetDspPos(ofNorm); - case FG_FLAPS_POS: - return FCS->GetDfPos(); - case FG_NFLAPS_POS: - return FCS->GetDfPos(ofNorm); - case FG_ELEVATOR_CMD: - return FCS->GetDeCmd(); - case FG_AILERON_CMD: - return FCS->GetDaCmd(); - case FG_RUDDER_CMD: - return FCS->GetDrCmd(); - case FG_SPDBRAKE_CMD: - return FCS->GetDsbCmd(); - case FG_SPOILERS_CMD: - return FCS->GetDspCmd(); - case FG_FLAPS_CMD: - return FCS->GetDfCmd(); - case FG_MACH: - return Translation->GetMach(); - case FG_ALTITUDE: - return Position->Geth(); - case FG_BI2VEL: - if(Translation->GetVt() > 0) - return Aircraft->GetWingSpan()/(2.0 * Translation->GetVt()); - else - return 0; - case FG_CI2VEL: - if(Translation->GetVt() > 0) - return Aircraft->Getcbar()/(2.0 * Translation->GetVt()); - else - return 0; - case FG_THROTTLE_CMD: - if (ActiveEngine < 0) return FCS->GetThrottleCmd(0); - else return FCS->GetThrottleCmd(ActiveEngine); - case FG_THROTTLE_POS: - if (ActiveEngine < 0) return FCS->GetThrottlePos(0); - else return FCS->GetThrottlePos(ActiveEngine); - case FG_MAGNETO_CMD: - if (ActiveEngine < 0) return Propulsion->GetEngine(0)->GetMagnetos(); - else return Propulsion->GetEngine(ActiveEngine)->GetMagnetos(); - case FG_STARTER_CMD: - if (ActiveEngine < 0) { - if (Propulsion->GetEngine(0)->GetStarter()) return 1.0; - else return 0.0; - } else { - if (Propulsion->GetEngine(ActiveEngine)->GetStarter()) return 1.0; - else return 0.0; - } - case FG_MIXTURE_CMD: - if (ActiveEngine < 0) return FCS->GetMixtureCmd(0); - else return FCS->GetMixtureCmd(ActiveEngine); - case FG_MIXTURE_POS: - if (ActiveEngine < 0) return FCS->GetMixturePos(0); - else return FCS->GetMixturePos(ActiveEngine); - case FG_HOVERB: - return Position->GetHOverBMAC(); - case FG_PITCH_TRIM_CMD: - return FCS->GetPitchTrimCmd(); - case FG_YAW_TRIM_CMD: - return FCS->GetYawTrimCmd(); - case FG_ROLL_TRIM_CMD: - return FCS->GetRollTrimCmd(); - case FG_GEAR_CMD: - return FCS->GetGearCmd(); - case FG_GEAR_POS: - return FCS->GetGearPos(); - default: - cerr << "FGState::GetParameter() - No handler for parameter " << paramdef[val_idx] << endl; - return 0.0; - } - return 0; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -double FGState::GetParameter(string val_string) { - return GetParameter(coeffdef[val_string]); -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -eParam FGState::GetParameterIndex(string val_string) -{ - return coeffdef[val_string]; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGState::SetParameter(eParam val_idx, double val) -{ - unsigned i; - - switch(val_idx) { - case FG_ELEVATOR_POS: - FCS->SetDePos(ofRad,val); - break; - case FG_NELEVATOR_POS: - FCS->SetDePos(ofNorm,val); - break; - case FG_AILERON_POS: - FCS->SetDaLPos(ofRad,val); - break; - case FG_NAILERON_POS: - FCS->SetDaLPos(ofNorm,val); - break; - case FG_LEFT_AILERON_POS: - FCS->SetDaLPos(ofRad,val); - break; - case FG_NLEFT_AILERON_POS: - FCS->SetDaLPos(ofNorm,val); - break; - case FG_RIGHT_AILERON_POS: - FCS->SetDaRPos(ofRad,val); - break; - case FG_NRIGHT_AILERON_POS: - FCS->SetDaRPos(ofNorm,val); - break; - case FG_RUDDER_POS: - FCS->SetDrPos(ofRad,val); - break; - case FG_NRUDDER_POS: - FCS->SetDrPos(ofNorm,val); - break; - case FG_SPDBRAKE_POS: - FCS->SetDsbPos(ofRad,val); - break; - case FG_NSPDBRAKE_POS: - FCS->SetDsbPos(ofNorm,val); - break; - case FG_SPOILERS_POS: - FCS->SetDspPos(ofRad,val); - break; - case FG_NSPOILERS_POS: - FCS->SetDspPos(ofNorm,val); - break; - case FG_FLAPS_POS: - FCS->SetDfPos(ofRad,val); - break; - case FG_NFLAPS_POS: - FCS->SetDfPos(ofNorm,val); - break; - case FG_THROTTLE_POS: - if (ActiveEngine == -1) { - for (i=0; iGetNumEngines(); i++) { - FCS->SetThrottlePos(i,val); - } - } else { - FCS->SetThrottlePos(ActiveEngine,val); - } - break; - case FG_MIXTURE_POS: - if (ActiveEngine == -1) { - for (i=0; iGetNumEngines(); i++) { - FCS->SetMixturePos(i,val); - } - } else { - FCS->SetMixturePos(ActiveEngine,val); - } - break; - - case FG_ELEVATOR_CMD: - FCS->SetDeCmd(val); - break; - case FG_AILERON_CMD: - FCS->SetDaCmd(val); - break; - case FG_RUDDER_CMD: - FCS->SetDrCmd(val); - break; - case FG_SPDBRAKE_CMD: - FCS->SetDsbCmd(val); - break; - case FG_SPOILERS_CMD: - FCS->SetDspCmd(val); - break; - case FG_FLAPS_CMD: - FCS->SetDfCmd(val); - break; - case FG_THROTTLE_CMD: - if (ActiveEngine == -1) { - for (i=0; iGetNumEngines(); i++) { - FCS->SetThrottleCmd(i,val); - } - } else { - FCS->SetThrottleCmd(ActiveEngine,val); - } - break; - case FG_MIXTURE_CMD: - if (ActiveEngine == -1) { - for (i=0; iGetNumEngines(); i++) { - FCS->SetMixtureCmd(i,val); - } - } else { - FCS->SetMixtureCmd(ActiveEngine,val); - } - break; - case FG_MAGNETO_CMD: - if (ActiveEngine == -1) { - for (i=0; iGetNumEngines(); i++) { - Propulsion->GetEngine(i)->SetMagnetos((int)val); - } - } else { - Propulsion->GetEngine(ActiveEngine)->SetMagnetos((int)val); - } - break; - case FG_STARTER_CMD: - if (ActiveEngine == -1) { - for (i=0; iGetNumEngines(); i++) { - if (val < 0.001) - Propulsion->GetEngine(i)->SetStarter(false); - else if (val >= 0.001) - Propulsion->GetEngine(i)->SetStarter(true); - } - } else { - Propulsion->GetEngine(ActiveEngine)->SetStarter(true); - } - break; - case FG_ACTIVE_ENGINE: - ActiveEngine = (int)val; - break; - - case FG_LEFT_BRAKE_CMD: - FCS->SetLBrake(val); - break; - case FG_CENTER_BRAKE_CMD: - FCS->SetCBrake(val); - break; - case FG_RIGHT_BRAKE_CMD: - FCS->SetRBrake(val); - break; - case FG_GEAR_CMD: - FCS->SetGearCmd(val); - break; - case FG_GEAR_POS: - FCS->SetGearPos(val); - break; - case FG_SET_LOGGING: - if (val < -0.01) Output->Disable(); - else if (val > 0.01) Output->Enable(); - else Output->Toggle(); - break; - - default: - cerr << "Parameter '" << val_idx << "' (" << paramdef[val_idx] << ") not handled" << endl; - } -} - //*************************************************************************** // // Reset: Assume all angles READ FROM FILE IN DEGREES !! @@ -688,29 +263,6 @@ void FGState::Initialize(FGInitialCondition *FGIC) { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -bool FGState::StoreData(string fname) { - ofstream datafile(fname.c_str()); - - if (datafile) { - datafile << Translation->GetUVW(eU); - datafile << Translation->GetUVW(eV); - datafile << Translation->GetUVW(eW); - datafile << Position->GetLatitude(); - datafile << Position->GetLongitude(); - datafile << Rotation->GetEuler(ePhi); - datafile << Rotation->GetEuler(eTht); - datafile << Rotation->GetEuler(ePsi); - datafile << Position->Geth(); - datafile.close(); - return true; - } else { - cerr << "Could not open dump file " << fname << endl; - return false; - } -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - void FGState::InitMatrices(double phi, double tht, double psi) { double thtd2, psid2, phid2; double Sthtd2, Spsid2, Sphid2; @@ -889,14 +441,14 @@ void FGState::ReportState(void) cout << out; snprintf(out,80, " Speed: %4.0f KCAS Mach: %5.2f\n", FDMExec->GetAuxiliary()->GetVcalibratedKTS(), - GetParameter(FG_MACH) ); + Translation->GetMach() ); cout << out; snprintf(out,80, " Altitude: %7.0f ft. AGL Altitude: %7.0f ft.\n", Position->Geth(), Position->GetDistanceAGL() ); cout << out; snprintf(out,80, " Angle of Attack: %6.2f deg Pitch Angle: %6.2f deg\n", - GetParameter(FG_ALPHA)*radtodeg, + Translation->Getalpha()*radtodeg, Rotation->Gettht()*radtodeg ); cout << out; snprintf(out,80, " Flight Path Angle: %6.2f deg Climb Rate: %5.0f ft/min\n", @@ -905,11 +457,11 @@ void FGState::ReportState(void) cout << out; snprintf(out,80, " Normal Load Factor: %4.2f g's Pitch Rate: %5.2f deg/s\n", Aircraft->GetNlf(), - GetParameter(FG_PITCHRATE)*radtodeg ); + Rotation->GetPQR(2)*radtodeg ); cout << out; snprintf(out,80, " Heading: %3.0f deg true Sideslip: %5.2f deg Yaw Rate: %5.2f deg/s\n", Rotation->Getpsi()*radtodeg, - GetParameter(FG_BETA)*radtodeg, + Translation->Getbeta()*radtodeg, Rotation->GetPQR(3)*radtodeg ); cout << out; snprintf(out,80, " Bank Angle: %5.2f deg Roll Rate: %5.2f deg/s\n", @@ -917,9 +469,9 @@ void FGState::ReportState(void) Rotation->GetPQR(1)*radtodeg ); cout << out; snprintf(out,80, " Elevator: %5.2f deg Left Aileron: %5.2f deg Rudder: %5.2f deg\n", - GetParameter(FG_ELEVATOR_POS)*radtodeg, - GetParameter(FG_AILERON_POS)*radtodeg, - GetParameter(FG_RUDDER_POS)*radtodeg ); + FCS->GetDePos(ofRad)*radtodeg, + FCS->GetDaLPos(ofRad)*radtodeg, + FCS->GetDrPos(ofRad)*radtodeg ); cout << out; snprintf(out,80, " Throttle: %5.2f%c\n", FCS->GetThrottlePos(0)*100,'%' ); @@ -940,149 +492,83 @@ void FGState::ReportState(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void FGState::InitPropertyMaps(void) { - ParamToProp[ FG_TIME ]="sim-time-sec"; - ParamToProp[ FG_QBAR ]="aero/qbar-psf"; - ParamToProp[ FG_WINGAREA ]="metrics/Sw-sqft"; - ParamToProp[ FG_WINGSPAN ]="metrics/bw-ft"; - ParamToProp[ FG_CBAR ]="metrics/cbarw-ft"; - ParamToProp[ FG_ALPHA ]="aero/alpha-rad"; - ParamToProp[ FG_ALPHADOT ]="aero/alphadot-rad_sec"; - ParamToProp[ FG_BETA ]="aero/beta-rad"; - ParamToProp[ FG_ABETA ]="aero/mag-beta-rad"; - ParamToProp[ FG_BETADOT ]="aero/betadot-rad_sec"; - ParamToProp[ FG_PHI ]="attitude/phi-rad"; - ParamToProp[ FG_THT ]="attitude/theta-rad"; - ParamToProp[ FG_PSI ]="attitude/psi-true-rad"; - ParamToProp[ FG_PITCHRATE ]="velocities/q-rad_sec"; - ParamToProp[ FG_ROLLRATE ]="velocities/p-rad_sec"; - ParamToProp[ FG_YAWRATE ]="velocities/r-rad_sec"; - ParamToProp[ FG_AEROP ]="velocities/p-aero-rad_sec"; - ParamToProp[ FG_AEROQ ]="velocities/q-aero-rad_sec"; - ParamToProp[ FG_AEROR ]="velocities/r-aero-rad_sec"; - ParamToProp[ FG_CL_SQRD ]="aero/cl-squared-norm"; - ParamToProp[ FG_MACH ]="velocities/mach-norm"; - ParamToProp[ FG_ALTITUDE ]="position/h-sl-ft"; - ParamToProp[ FG_BI2VEL ]="aero/bi2vel"; - ParamToProp[ FG_CI2VEL ]="aero/ci2vel"; - ParamToProp[ FG_ELEVATOR_POS ]="fcs/elevator-pos-rad"; - ParamToProp[ FG_AELEVATOR_POS ]="fcs/mag-elevator-pos-rad"; - ParamToProp[ FG_NELEVATOR_POS ]="fcs/elevator-pos-norm"; - ParamToProp[ FG_AILERON_POS ]="fcs/left-aileron-pos-rad"; - ParamToProp[ FG_AAILERON_POS ]="fcs/mag-aileron-pos-rad"; - ParamToProp[ FG_NAILERON_POS ]="fcs/left-aileron-pos-norm"; - ParamToProp[ FG_LEFT_AILERON_POS ]="fcs/left-aileron-pos-rad"; - ParamToProp[ FG_ALEFT_AILERON_POS ]="fcs/mag-left-aileron-pos-rad"; - ParamToProp[ FG_NLEFT_AILERON_POS ]="fcs/left-aileron-pos-norm"; - ParamToProp[ FG_RIGHT_AILERON_POS ]="fcs/right-aileron-pos-rad"; - ParamToProp[ FG_ARIGHT_AILERON_POS ]="fcs/mag-aileron-pos-rad"; - ParamToProp[ FG_NRIGHT_AILERON_POS ]="fcs/right-aileron-pos-norm"; - ParamToProp[ FG_RUDDER_POS ]="fcs/rudder-pos-rad"; - ParamToProp[ FG_ARUDDER_POS ]="fcs/mag-rudder-pos-rad"; - ParamToProp[ FG_NRUDDER_POS ]="fcs/rudder-pos-norm"; - ParamToProp[ FG_SPDBRAKE_POS ]="fcs/speedbrake-pos-rad"; - ParamToProp[ FG_NSPDBRAKE_POS ]="fcs/speedbrake-pos-norm"; - ParamToProp[ FG_SPOILERS_POS ]="fcs/spoiler-pos-rad"; - ParamToProp[ FG_NSPOILERS_POS ]="fcs/spoiler-pos-norm"; - ParamToProp[ FG_FLAPS_POS ]="fcs/flap-pos-deg"; - ParamToProp[ FG_NFLAPS_POS ]="fcs/flap-pos-norm"; - ParamToProp[ FG_ELEVATOR_CMD ]="fcs/elevator-cmd-norm"; - ParamToProp[ FG_AILERON_CMD ]="fcs/aileron-cmd-norm"; - ParamToProp[ FG_RUDDER_CMD ]="fcs/rudder-cmd-norm"; - ParamToProp[ FG_SPDBRAKE_CMD ]="fcs/speedbrake-cmd-norm"; - ParamToProp[ FG_SPOILERS_CMD ]="fcs/spoiler-cmd-norm"; - ParamToProp[ FG_FLAPS_CMD ]="fcs/flap-cmd-norm"; - ParamToProp[ FG_THROTTLE_CMD ]="zero"; - ParamToProp[ FG_THROTTLE_POS ]="zero"; - ParamToProp[ FG_MIXTURE_CMD ]="zero"; - ParamToProp[ FG_MIXTURE_POS ]="zero"; - ParamToProp[ FG_MAGNETO_CMD ]="zero"; - ParamToProp[ FG_STARTER_CMD ]="zero"; - ParamToProp[ FG_ACTIVE_ENGINE ]="zero"; - ParamToProp[ FG_HOVERB ]="aero/h_b-mac-ft"; - ParamToProp[ FG_PITCH_TRIM_CMD ]="fcs/pitch-trim-cmd-norm"; - ParamToProp[ FG_YAW_TRIM_CMD ]="fcs/yaw-trim-cmd-norm"; - ParamToProp[ FG_ROLL_TRIM_CMD ]="fcs/roll-trim-cmd-norm"; - ParamToProp[ FG_LEFT_BRAKE_CMD ]="zero"; - ParamToProp[ FG_CENTER_BRAKE_CMD ]="zero"; - ParamToProp[ FG_RIGHT_BRAKE_CMD ]="zero"; - ParamToProp[ FG_SET_LOGGING ]="zero"; - ParamToProp[ FG_ALPHAH ]="aero/alpha-rad"; - ParamToProp[ FG_ALPHAW ]="aero/alpha-wing-rad"; - ParamToProp[ FG_LBARH ]="metrics/lh-norm"; - ParamToProp[ FG_LBARV ]="metrics/lv-norm"; - ParamToProp[ FG_HTAILAREA ]="metrics/Sh-sqft"; - ParamToProp[ FG_VTAILAREA ]="metrics/Sv-sqft"; - ParamToProp[ FG_VBARH ]="metrics/vbarh-norm"; - ParamToProp[ FG_VBARV ]="metrics/vbarv-norm"; - ParamToProp[ FG_GEAR_CMD ]="gear/gear-cmd-norm"; - ParamToProp[ FG_GEAR_POS ]="gear/gear-pos-norm"; + ParamNameToProp[ "FG_TIME" ]="sim-time-sec"; + ParamNameToProp[ "FG_QBAR" ]="aero/qbar-psf"; + ParamNameToProp[ "FG_WINGAREA" ]="metrics/Sw-sqft"; + ParamNameToProp[ "FG_WINGSPAN" ]="metrics/bw-ft"; + ParamNameToProp[ "FG_CBAR" ]="metrics/cbarw-ft"; + ParamNameToProp[ "FG_ALPHA" ]="aero/alpha-rad"; + ParamNameToProp[ "FG_ALPHADOT" ]="aero/alphadot-rad_sec"; + ParamNameToProp[ "FG_BETA" ]="aero/beta-rad"; + ParamNameToProp[ "FG_ABETA" ]="aero/mag-beta-rad"; + ParamNameToProp[ "FG_BETADOT" ]="aero/betadot-rad_sec"; + ParamNameToProp[ "FG_PHI" ]="attitude/phi-rad"; + ParamNameToProp[ "FG_THT" ]="attitude/theta-rad"; + ParamNameToProp[ "FG_PSI" ]="attitude/psi-true-rad"; + ParamNameToProp[ "FG_PITCHRATE" ]="velocities/q-rad_sec"; + ParamNameToProp[ "FG_ROLLRATE" ]="velocities/p-rad_sec"; + ParamNameToProp[ "FG_YAWRATE" ]="velocities/r-rad_sec"; + ParamNameToProp[ "FG_AEROP" ]="velocities/p-aero-rad_sec"; + ParamNameToProp[ "FG_AEROQ" ]="velocities/q-aero-rad_sec"; + ParamNameToProp[ "FG_AEROR" ]="velocities/r-aero-rad_sec"; + ParamNameToProp[ "FG_CL_SQRD" ]="aero/cl-squared-norm"; + ParamNameToProp[ "FG_MACH" ]="velocities/mach-norm"; + ParamNameToProp[ "FG_ALTITUDE" ]="position/h-sl-ft"; + ParamNameToProp[ "FG_BI2VEL" ]="aero/bi2vel"; + ParamNameToProp[ "FG_CI2VEL" ]="aero/ci2vel"; + ParamNameToProp[ "FG_ELEVATOR_POS" ]="fcs/elevator-pos-rad"; + ParamNameToProp[ "FG_AELEVATOR_POS" ]="fcs/mag-elevator-pos-rad"; + ParamNameToProp[ "FG_NELEVATOR_POS" ]="fcs/elevator-pos-norm"; + ParamNameToProp[ "FG_AILERON_POS" ]="fcs/left-aileron-pos-rad"; + ParamNameToProp[ "FG_AAILERON_POS" ]="fcs/mag-aileron-pos-rad"; + ParamNameToProp[ "FG_NAILERON_POS" ]="fcs/left-aileron-pos-norm"; + ParamNameToProp[ "FG_LEFT_AILERON_POS" ]="fcs/left-aileron-pos-rad"; + ParamNameToProp[ "FG_ALEFT_AILERON_POS" ]="fcs/mag-left-aileron-pos-rad"; + ParamNameToProp[ "FG_NLEFT_AILERON_POS" ]="fcs/left-aileron-pos-norm"; + ParamNameToProp[ "FG_RIGHT_AILERON_POS" ]="fcs/right-aileron-pos-rad"; + ParamNameToProp[ "FG_ARIGHT_AILERON_POS" ]="fcs/mag-aileron-pos-rad"; + ParamNameToProp[ "FG_NRIGHT_AILERON_POS" ]="fcs/right-aileron-pos-norm"; + ParamNameToProp[ "FG_RUDDER_POS" ]="fcs/rudder-pos-rad"; + ParamNameToProp[ "FG_ARUDDER_POS" ]="fcs/mag-rudder-pos-rad"; + ParamNameToProp[ "FG_NRUDDER_POS" ]="fcs/rudder-pos-norm"; + ParamNameToProp[ "FG_SPDBRAKE_POS" ]="fcs/speedbrake-pos-rad"; + ParamNameToProp[ "FG_NSPDBRAKE_POS" ]="fcs/speedbrake-pos-norm"; + ParamNameToProp[ "FG_SPOILERS_POS" ]="fcs/spoiler-pos-rad"; + ParamNameToProp[ "FG_NSPOILERS_POS" ]="fcs/spoiler-pos-norm"; + ParamNameToProp[ "FG_FLAPS_POS" ]="fcs/flap-pos-deg"; + ParamNameToProp[ "FG_NFLAPS_POS" ]="fcs/flap-pos-norm"; + ParamNameToProp[ "FG_ELEVATOR_CMD" ]="fcs/elevator-cmd-norm"; + ParamNameToProp[ "FG_AILERON_CMD" ]="fcs/aileron-cmd-norm"; + ParamNameToProp[ "FG_RUDDER_CMD" ]="fcs/rudder-cmd-norm"; + ParamNameToProp[ "FG_SPDBRAKE_CMD" ]="fcs/speedbrake-cmd-norm"; + ParamNameToProp[ "FG_SPOILERS_CMD" ]="fcs/spoiler-cmd-norm"; + ParamNameToProp[ "FG_FLAPS_CMD" ]="fcs/flap-cmd-norm"; + ParamNameToProp[ "FG_THROTTLE_CMD" ]="fcs/throttle-cmd-norm"; + ParamNameToProp[ "FG_THROTTLE_POS" ]="fcs/throttle-pos-norm"; + ParamNameToProp[ "FG_MIXTURE_CMD" ]="fcs/mixture-cmd-norm"; + ParamNameToProp[ "FG_MIXTURE_POS" ]="fcs/mixture-pos-norm"; + ParamNameToProp[ "FG_MAGNETO_CMD" ]="zero"; + ParamNameToProp[ "FG_STARTER_CMD" ]="zero"; + ParamNameToProp[ "FG_ACTIVE_ENGINE" ]="zero"; + ParamNameToProp[ "FG_HOVERB" ]="aero/h_b-mac-ft"; + ParamNameToProp[ "FG_PITCH_TRIM_CMD" ]="fcs/pitch-trim-cmd-norm"; + ParamNameToProp[ "FG_YAW_TRIM_CMD" ]="fcs/yaw-trim-cmd-norm"; + ParamNameToProp[ "FG_ROLL_TRIM_CMD" ]="fcs/roll-trim-cmd-norm"; + ParamNameToProp[ "FG_LEFT_BRAKE_CMD" ]="zero"; + ParamNameToProp[ "FG_CENTER_BRAKE_CMD" ]="zero"; + ParamNameToProp[ "FG_RIGHT_BRAKE_CMD" ]="zero"; + ParamNameToProp[ "FG_SET_LOGGING" ]="zero"; + ParamNameToProp[ "FG_ALPHAH" ]="aero/alpha-rad"; + ParamNameToProp[ "FG_ALPHAW" ]="aero/alpha-wing-rad"; + ParamNameToProp[ "FG_LBARH" ]="metrics/lh-norm"; + ParamNameToProp[ "FG_LBARV" ]="metrics/lv-norm"; + ParamNameToProp[ "FG_HTAILAREA" ]="metrics/Sh-sqft"; + ParamNameToProp[ "FG_VTAILAREA" ]="metrics/Sv-sqft"; + ParamNameToProp[ "FG_VBARH" ]="metrics/vbarh-norm"; + ParamNameToProp[ "FG_VBARV" ]="metrics/vbarv-norm"; + ParamNameToProp[ "FG_GEAR_CMD" ]="gear/gear-cmd-norm"; + ParamNameToProp[ "FG_GEAR_POS" ]="gear/gear-pos-norm"; - PropToParam[ "sim-time-sec" ] = FG_TIME; - PropToParam[ "aero/qbar-psf" ] = FG_QBAR; - PropToParam[ "metrics/Sw-sqft" ] = FG_WINGAREA; - PropToParam[ "metrics/bw-ft" ] = FG_WINGSPAN; - PropToParam[ "metrics/cbarw-ft" ] = FG_CBAR; - PropToParam[ "aero/alpha-rad" ] = FG_ALPHA; - PropToParam[ "aero/alphadot-rad_sec" ] = FG_ALPHADOT; - PropToParam[ "aero/beta-rad" ] = FG_BETA; - PropToParam[ "aero/mag-beta-rad" ] = FG_ABETA; - PropToParam[ "aero/betadot-rad_sec" ] = FG_BETADOT; - PropToParam[ "attitude/phi-rad" ] = FG_PHI; - PropToParam[ "attitude/theta-rad" ] = FG_THT; - PropToParam[ "attitude/psi-true-rad" ] = FG_PSI; - PropToParam[ "velocities/q-rad_sec" ] = FG_PITCHRATE; - PropToParam[ "velocities/p-rad_sec" ] = FG_ROLLRATE; - PropToParam[ "velocities/r-rad_sec" ] = FG_YAWRATE; - PropToParam[ "velocities/p-aero-rad_sec" ] = FG_AEROP; - PropToParam[ "velocities/q-aero-rad_sec" ] = FG_AEROQ; - PropToParam[ "velocities/r-aero-rad_sec" ] = FG_AEROR; - PropToParam[ "aero/cl-squared-norm" ] = FG_CL_SQRD; - PropToParam[ "velocities/mach-norm" ] = FG_MACH; - PropToParam[ "position/h-sl-ft" ] = FG_ALTITUDE; - PropToParam[ "aero/bi2vel" ] = FG_BI2VEL; - PropToParam[ "aero/ci2vel" ] = FG_CI2VEL; - PropToParam[ "fcs/elevator-pos-rad" ] = FG_ELEVATOR_POS; - PropToParam[ "fcs/mag-elevator-pos-rad" ] = FG_AELEVATOR_POS; - PropToParam[ "fcs/elevator-pos-norm" ] = FG_NELEVATOR_POS; - PropToParam[ "fcs/left-aileron-pos-rad" ] = FG_AILERON_POS; - PropToParam[ "fcs/mag-aileron-pos-rad" ] = FG_AAILERON_POS; - PropToParam[ "fcs/left-aileron-pos-norm" ] = FG_NAILERON_POS; - PropToParam[ "fcs/left-aileron-pos-rad" ] = FG_LEFT_AILERON_POS; - PropToParam[ "fcs/mag-left-aileron-pos-rad" ] = FG_ALEFT_AILERON_POS; - PropToParam[ "fcs/left-aileron-pos-norm" ] = FG_NLEFT_AILERON_POS; - PropToParam[ "fcs/right-aileron-pos-rad" ] = FG_RIGHT_AILERON_POS; - PropToParam[ "fcs/mag-aileron-pos-rad" ] = FG_ARIGHT_AILERON_POS; - PropToParam[ "fcs/right-aileron-pos-norm" ] = FG_NRIGHT_AILERON_POS; - PropToParam[ "fcs/rudder-pos-rad" ] = FG_RUDDER_POS; - PropToParam[ "fcs/mag-rudder-pos-rad" ] = FG_ARUDDER_POS; - PropToParam[ "fcs/rudder-pos-norm" ] = FG_NRUDDER_POS; - PropToParam[ "fcs/speedbrake-pos-rad" ] = FG_SPDBRAKE_POS; - PropToParam[ "fcs/speedbrake-pos-norm" ] = FG_NSPDBRAKE_POS; - PropToParam[ "fcs/spoiler-pos-rad" ] = FG_SPOILERS_POS; - PropToParam[ "fcs/spoiler-pos-norm" ] = FG_NSPOILERS_POS; - PropToParam[ "fcs/flap-pos-deg" ] = FG_FLAPS_POS; - PropToParam[ "fcs/flap-pos-norm" ] = FG_NFLAPS_POS; - PropToParam[ "fcs/elevator-cmd-norm" ] = FG_ELEVATOR_CMD; - PropToParam[ "fcs/aileron-cmd-norm" ] = FG_AILERON_CMD; - PropToParam[ "fcs/rudder-cmd-norm" ] = FG_RUDDER_CMD; - PropToParam[ "fcs/speedbrake-cmd-norm" ] = FG_SPDBRAKE_CMD; - PropToParam[ "fcs/spoiler-cmd-norm" ] = FG_SPOILERS_CMD; - PropToParam[ "fcs/flap-cmd-norm" ] = FG_FLAPS_CMD; - PropToParam[ "aero/h_b-mac-ft" ] = FG_HOVERB; - PropToParam[ "fcs/pitch-trim-cmd-norm" ] = FG_PITCH_TRIM_CMD; - PropToParam[ "fcs/yaw-trim-cmd-norm" ] = FG_YAW_TRIM_CMD; - PropToParam[ "fcs/roll-trim-cmd-norm" ] = FG_ROLL_TRIM_CMD; - PropToParam[ "aero/alpha-rad" ] = FG_ALPHAH; - PropToParam[ "aero/alpha-wing-rad" ] = FG_ALPHAW; - PropToParam[ "metrics/lh-norm" ] = FG_LBARH; - PropToParam[ "metrics/lv-norm" ] = FG_LBARV; - PropToParam[ "metrics/Sh-sqft" ] = FG_HTAILAREA; - PropToParam[ "metrics/Sv-sqft" ] = FG_VTAILAREA; - PropToParam[ "metrics/vbarh-norm" ] = FG_VBARH; - PropToParam[ "metrics/vbarv-norm" ] = FG_VBARV; - PropToParam[ "gear/gear-cmd-norm" ] = FG_GEAR_CMD; - PropToParam[ "gear/gear-pos-norm" ] = FG_GEAR_POS; - } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGState.h b/src/FDM/JSBSim/FGState.h index ea6ab9d9a..5d7b70dcd 100644 --- a/src/FDM/JSBSim/FGState.h +++ b/src/FDM/JSBSim/FGState.h @@ -95,6 +95,10 @@ CLASS DOCUMENTATION /** Encapsulates the calculation of aircraft state. @author Jon S. Berndt @version $Id$ + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -166,12 +170,6 @@ public: */ void Initialize(FGInitialCondition *FGIC); - /** Stores state data in the supplied file name. - @param filename the file to store the data in. - @return true if successful. - */ - bool StoreData(string filename); - /// returns the speed of sound in feet per second. inline double Geta(void) { return a; } @@ -185,38 +183,11 @@ public: /// Resumes the simulation by resetting delta T to the correct value. inline void Resume(void) {dt = saved_dt;} - /** Retrieves a parameter. - The parameters that can be retrieved are enumerated in FGJSBBase.h. - @param val_idx one of the enumerated JSBSim parameters. - @return the value of the parameter. - */ - double GetParameter(eParam val_idx); - - /** Retrieves a parameter. - The parameters that can be retrieved are enumerated in FGJSBBase.h. - @param val_string a string representing one of the enumerated JSBSim parameters, - i.e. "FG_QBAR". - @return the value of the parameter. - */ - double GetParameter(string val_string); - - /** Retrieves the JSBSim parameter enumerated item given the text string. - @param val_string the parameter string, i.e. "FG_QBAR". - @return the JSBSim parameter index (an enumerated type) for the supplied string. - */ - eParam GetParameterIndex(string val_string); - /** Sets the speed of sound. @param speed the speed of sound in feet per second. */ inline void Seta(double speed) { a = speed; } - /** Gets the name of the parameter given the index. - @param val_idx one of the enumerated JSBSim parameters. - @return the name of the parameter pointed to by the index. - */ - string GetParameterName(eParam val_idx) {return paramdef[val_idx];} - /** Sets the current sim time. @param cur_time the current time @return the current time. @@ -231,12 +202,6 @@ public: */ inline void Setdt(double delta_t) { dt = delta_t; } - /** Sets the JSBSim parameter to the supplied value. - @param prm the JSBSim parameter to set, i.e. FG_RUDDER_POS. - @param val the value to give the parameter. - */ - void SetParameter(eParam prm, double val); - /** Increments the simulation time. @return the new simulation time. */ @@ -309,8 +274,9 @@ public: */ void ReportState(void); - inline string GetPropertyName(eParam prm) { return ParamToProp[prm]; } - inline eParam GetParam(string property) { return PropToParam[property]; } + inline string GetPropertyName(string prm) { return ParamNameToProp[prm]; } + //inline string GetPropertyName(eParam prm) { return ParamIdxToProp[prm]; } + //inline eParam GetParam(string property) { return PropToParam[property]; } void bind(); void unbind(); @@ -347,14 +313,19 @@ private: FGPropulsion* Propulsion; FGPropertyManager* PropertyManager; - typedef map CoeffMap; + /* typedef map CoeffMap; CoeffMap coeffdef; typedef map ParamMap; - ParamMap paramdef; + //ParamMap paramdef; */ + - ParamMap ParamToProp; - CoeffMap PropToParam; + typedef map ParamNameMap; + ParamNameMap ParamNameToProp; + + typedef map ParamIdxMap; + ParamIdxMap ParamIdxToProp; + //CoeffMap PropToParam; int ActiveEngine; diff --git a/src/FDM/JSBSim/FGTable.h b/src/FDM/JSBSim/FGTable.h index 6d5b55b2d..9325a6021 100644 --- a/src/FDM/JSBSim/FGTable.h +++ b/src/FDM/JSBSim/FGTable.h @@ -65,6 +65,10 @@ CLASS DOCUMENTATION @version $Id$ @see FGCoefficient @see FGPropeller + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGTrim.h b/src/FDM/JSBSim/FGTrim.h index 4c5221ff3..105da8aff 100644 --- a/src/FDM/JSBSim/FGTrim.h +++ b/src/FDM/JSBSim/FGTrim.h @@ -76,7 +76,7 @@ typedef enum { tLongitudinal, tFull, tGround, tPullup, tCustom, tNone, tTurn } TrimMode; -#ifdef _MSC_VER +#ifdef _WIN32 #define snprintf _snprintf #endif @@ -140,6 +140,10 @@ CLASS DOCUMENTATION fgt->ReportState(); @author Tony Peden @version $Id$ + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp b/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp index eb578e682..6130c1b62 100644 --- a/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp +++ b/src/FDM/JSBSim/filtersjb/FGFCSComponent.cpp @@ -51,12 +51,11 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs) : fcs(_fcs) Type = ""; ID = 0; Input = 0.0; - InputIdx = FG_UNDEF; + InputNode = 0; Output = 0.0; - sOutputIdx = ""; - OutputIdx = FG_UNDEF; + OutputNode = 0; IsOutput = false; - + PropertyManager=fcs->GetPropertyManager(); Debug(0); } @@ -71,7 +70,7 @@ FGFCSComponent::~FGFCSComponent() void FGFCSComponent::SetOutput(void) { - fcs->GetState()->SetParameter(OutputIdx, Output); + OutputNode->setDoubleValue(Output); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -80,14 +79,15 @@ bool FGFCSComponent::Run(void) { switch(InputType) { case itPilotAC: - Input = fcs->GetState()->GetParameter(InputIdx); + Input = InputNode->getDoubleValue(); break; case itFCS: - Input = fcs->GetComponentOutput(InputIdx); - break; + Input = fcs->GetComponentOutput(InputIdx); case itAP: // implement autopilot input mechanism break; + case itBias: + break; } return true; diff --git a/src/FDM/JSBSim/filtersjb/FGFCSComponent.h b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h index 6c8c51984..599716c05 100644 --- a/src/FDM/JSBSim/filtersjb/FGFCSComponent.h +++ b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h @@ -43,6 +43,8 @@ INCLUDES #include #include "../FGJSBBase.h" +#include "../FGPropertyManager.h" + /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINITIONS @@ -100,7 +102,7 @@ public: virtual bool Run(void); virtual void SetOutput(void); inline double GetOutput (void) {return Output;} - inline int GetOutputIdx(void) { return OutputIdx; } + inline FGPropertyManager* GetOutputNode(void) { return OutputNode; } inline string GetName(void) {return Name;} inline string GetType(void) { return Type; } virtual double GetOutputPct(void) { return 0; } @@ -109,13 +111,14 @@ protected: /// Pilot/Aircraft, FCS, Autopilot inputs enum eInputType {itPilotAC, itFCS, itAP, itBias} InputType; FGFCS* fcs; + FGPropertyManager* PropertyManager; string Type; string Name; int ID; - eParam InputIdx; + FGPropertyManager* InputNode; + int InputIdx; double Input; - string sOutputIdx; - eParam OutputIdx; + FGPropertyManager* OutputNode; double Output; bool IsOutput; virtual void Debug(int from); diff --git a/src/FDM/JSBSim/filtersjb/FGFilter.cpp b/src/FDM/JSBSim/filtersjb/FGFilter.cpp index 1af9dc1dd..009eccfca 100644 --- a/src/FDM/JSBSim/filtersjb/FGFilter.cpp +++ b/src/FDM/JSBSim/filtersjb/FGFilter.cpp @@ -51,6 +51,7 @@ FGFilter::FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), { string token; double denom; + string sOutputIdx; Type = AC_cfg->GetValue("TYPE"); Name = AC_cfg->GetValue("NAME"); @@ -80,7 +81,8 @@ FGFilter::FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), token = AC_cfg->GetValue("INPUT"); if (token.find("FG_") != token.npos) { *AC_cfg >> token; - InputIdx = fcs->GetState()->GetParameterIndex(token); + InputNode = PropertyManager->GetNode( + fcs->GetState()->GetPropertyName(token) ); InputType = itPilotAC; } else { *AC_cfg >> InputIdx; @@ -91,7 +93,8 @@ FGFilter::FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), { IsOutput = true; *AC_cfg >> sOutputIdx; - OutputIdx = fcs->GetState()->GetParameterIndex(sOutputIdx); + OutputNode = PropertyManager->GetNode( + fcs->GetState()->GetPropertyName(sOutputIdx) ); } else cerr << "Unknown filter type: " << token << endl; } @@ -215,12 +218,15 @@ void FGFilter::Debug(int from) cout << " ID: " << ID << endl; switch(InputType) { case itPilotAC: - cout << " INPUT: " << fcs->GetState()->GetParameterName(InputIdx) << endl; + cout << " INPUT: " << InputNode->getName() << endl; break; case itFCS: cout << " INPUT: FCS Component " << InputIdx << " (" << fcs->GetComponentName(InputIdx) << ")" << endl; break; + case itAP: + case itBias: + break; } cout << " C1: " << C1 << endl; cout << " C2: " << C2 << endl; @@ -228,7 +234,7 @@ void FGFilter::Debug(int from) cout << " C4: " << C4 << endl; cout << " C5: " << C5 << endl; cout << " C6: " << C6 << endl; - if (IsOutput) cout << " OUTPUT: " << sOutputIdx << endl; + if (IsOutput) cout << " OUTPUT: " << OutputNode->getName() << endl; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification diff --git a/src/FDM/JSBSim/filtersjb/FGFilter.h b/src/FDM/JSBSim/filtersjb/FGFilter.h index d085bb7b9..e7e745e2c 100644 --- a/src/FDM/JSBSim/filtersjb/FGFilter.h +++ b/src/FDM/JSBSim/filtersjb/FGFilter.h @@ -77,6 +77,10 @@ CLASS DOCUMENTATION @author Jon S. Berndt @version $Id$ + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/filtersjb/FGGain.cpp b/src/FDM/JSBSim/filtersjb/FGGain.cpp index 23b3d6541..fba678284 100644 --- a/src/FDM/JSBSim/filtersjb/FGGain.cpp +++ b/src/FDM/JSBSim/filtersjb/FGGain.cpp @@ -52,6 +52,7 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), { string token; string strScheduledBy; + string sOutputIdx; State = fcs->GetState(); @@ -60,7 +61,7 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), Min = Max = 0.0; OutputPct=0; invert=false; - ScheduledBy = FG_UNDEF; + ScheduledBy = 0; Type = AC_cfg->GetValue("TYPE"); Name = AC_cfg->GetValue("NAME"); @@ -74,7 +75,8 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), token = AC_cfg->GetValue("INPUT"); if (token.find("FG_") != token.npos) { *AC_cfg >> token; - InputIdx = State->GetParameterIndex(token); + InputNode = PropertyManager->GetNode( + fcs->GetState()->GetPropertyName(token) ); InputType = itPilotAC; } else { *AC_cfg >> InputIdx; @@ -95,14 +97,15 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), token = AC_cfg->GetValue("SCHEDULED_BY"); if (token.find("FG_") != token.npos) { *AC_cfg >> strScheduledBy; - ScheduledBy = State->GetParameterIndex(strScheduledBy); - } else { - *AC_cfg >> ScheduledBy; - } + ScheduledBy = PropertyManager->GetNode( + fcs->GetState()->GetPropertyName(strScheduledBy) ); + } } else if (token == "OUTPUT") { IsOutput = true; - *AC_cfg >> sOutputIdx; - OutputIdx = State->GetParameterIndex(sOutputIdx); + *AC_cfg >> sOutputIdx; + OutputNode = PropertyManager->GetNode( + fcs->GetState()->GetPropertyName(sOutputIdx) ); + } else { AC_cfg->ResetLineIndexToZero(); *Table << *AC_cfg; @@ -130,7 +133,7 @@ bool FGGain::Run(void ) if (Type == "PURE_GAIN") { Output = Gain * Input; } else if (Type == "SCHEDULED_GAIN") { - LookupVal = State->GetParameter(ScheduledBy); + LookupVal = ScheduledBy->getDoubleValue(); SchedGain = Table->GetValue(LookupVal); Output = Gain * SchedGain * Input; } else if (Type == "AEROSURFACE_SCALE") { @@ -179,20 +182,23 @@ void FGGain::Debug(int from) cout << " ID: " << ID << endl; switch(InputType) { case itPilotAC: - cout << " INPUT: " << State->GetParameterName(InputIdx) << endl; + cout << " INPUT: " << InputNode->getName() << endl; break; case itFCS: cout << " INPUT: FCS Component " << InputIdx << " (" << fcs->GetComponentName(InputIdx) << ")" << endl; break; + case itAP: + case itBias: + break; } cout << " GAIN: " << Gain << endl; - if (IsOutput) cout << " OUTPUT: " << sOutputIdx << endl; + if (IsOutput) cout << " OUTPUT: " << OutputNode->getName() << endl; cout << " MIN: " << Min << endl; cout << " MAX: " << Max << endl; if(invert) cout << " Invert mapping" << endl; - if (ScheduledBy != FG_UNDEF) { - cout << " Scheduled by parameter: " << ScheduledBy << endl; + if (ScheduledBy != 0) { + cout << " Scheduled by parameter: " << ScheduledBy->getName() << endl; Table->Print(); } } diff --git a/src/FDM/JSBSim/filtersjb/FGGain.h b/src/FDM/JSBSim/filtersjb/FGGain.h index 23c233b47..48e2105fd 100644 --- a/src/FDM/JSBSim/filtersjb/FGGain.h +++ b/src/FDM/JSBSim/filtersjb/FGGain.h @@ -53,6 +53,7 @@ INCLUDES #include "../FGConfigFile.h" #include "../FGTable.h" + /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -84,7 +85,7 @@ private: double OutputPct; bool invert; int Rows; - eParam ScheduledBy; + FGPropertyManager* ScheduledBy; void Debug(int from); }; diff --git a/src/FDM/JSBSim/filtersjb/FGKinemat.cpp b/src/FDM/JSBSim/filtersjb/FGKinemat.cpp index 4e94e8652..404522601 100644 --- a/src/FDM/JSBSim/filtersjb/FGKinemat.cpp +++ b/src/FDM/JSBSim/filtersjb/FGKinemat.cpp @@ -49,7 +49,7 @@ CLASS IMPLEMENTATION FGKinemat::FGKinemat(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), AC_cfg(AC_cfg) { - string token; + string token,sOutputIdx; double tmpDetent; double tmpTime; @@ -70,8 +70,12 @@ FGKinemat::FGKinemat(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), token = AC_cfg->GetValue("INPUT"); if (token.find("FG_") != token.npos) { *AC_cfg >> token; - InputIdx = fcs->GetState()->GetParameterIndex(token); + InputNode = PropertyManager->GetNode( + fcs->GetState()->GetPropertyName(token) ); InputType = itPilotAC; + } else { + *AC_cfg >> InputIdx; + InputType = itFCS; } } else if ( token == "DETENTS" ) { *AC_cfg >> NumDetents; @@ -85,7 +89,8 @@ FGKinemat::FGKinemat(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), IsOutput = true; *AC_cfg >> sOutputIdx; - OutputIdx = fcs->GetState()->GetParameterIndex(sOutputIdx); + OutputNode = PropertyManager->GetNode( + fcs->GetState()->GetPropertyName(sOutputIdx) ); } } @@ -107,8 +112,8 @@ bool FGKinemat::Run(void ) { FGFCSComponent::Run(); // call the base class for initialization of Input InputCmd = Input*Detents[NumDetents-1]; - OutputPos = fcs->GetState()->GetParameter(OutputIdx); - + OutputPos = OutputNode->getDoubleValue(); + if(InputCmd < Detents[0]) { fi=0; InputCmd=Detents[0]; @@ -127,11 +132,10 @@ bool FGKinemat::Run(void ) { OutputPos=InputCmd; else { if(InputCmd != lastInputCmd) { - InTransit=1; } + //cout << "FGKinemat::Run, InTransit: " << InTransit << endl; if(InTransit) { - //fprintf(stderr,"InputCmd: %g, OutputPos: %g\n",InputCmd,OutputPos); fi=0; while(Detents[fi] < InputCmd) { @@ -142,15 +146,18 @@ bool FGKinemat::Run(void ) { output_transit_rate=(Detents[fi] - Detents[fi-1])/TransitionTimes[fi]; else output_transit_rate=(Detents[fi] - Detents[fi-1])/5; + //cout << "FGKinemat::Run, output_transit_rate: " << output_transit_rate << endl; } else { if(TransitionTimes[fi+1] > 0) output_transit_rate=(Detents[fi] - Detents[fi+1])/TransitionTimes[fi+1]; else output_transit_rate=(Detents[fi] - Detents[fi+1])/5; } - if(fabs(OutputPos - InputCmd) > fabs(dt*output_transit_rate) ) + if(fabs(OutputPos - InputCmd) > fabs(dt*output_transit_rate) ) { OutputPos+=output_transit_rate*dt; - else { + //cout << "FGKinemat::Run, OutputPos: " << OutputPos + // << " dt: " << dt << endl; + } else { InTransit=0; OutputPos=InputCmd; } @@ -195,12 +202,12 @@ void FGKinemat::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor cout << " ID: " << ID << endl; - cout << " INPUT: " << InputIdx << endl; + cout << " INPUT: " << InputNode->getName() << endl; cout << " DETENTS: " << NumDetents << endl; for(int i=0;igetName() << endl; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification diff --git a/src/FDM/JSBSim/filtersjb/FGSummer.cpp b/src/FDM/JSBSim/filtersjb/FGSummer.cpp index d291ce7cf..df77ceaa8 100644 --- a/src/FDM/JSBSim/filtersjb/FGSummer.cpp +++ b/src/FDM/JSBSim/filtersjb/FGSummer.cpp @@ -50,14 +50,14 @@ CLASS IMPLEMENTATION FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), AC_cfg(AC_cfg) { - string token; + string token,sOutputIdx; eParam tmpInputIndex; + InputRec *input; clip = false; clipmin = clipmax = 0.0; Bias = 0.0; - InputIndices.clear(); - InputTypes.clear(); + Inputs.clear(); Type = AC_cfg->GetValue("TYPE"); Name = AC_cfg->GetValue("NAME"); @@ -69,21 +69,26 @@ FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), if (token == "ID") { *AC_cfg >> ID; } else if (token == "INPUT") { + input = new InputRec; 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); + input->Node = PropertyManager->GetNode( + fcs->GetState()->GetPropertyName(token) ); + input->Idx=-1; + input->Type = itPilotAC; } else if (token.find(".") != token.npos) { // bias *AC_cfg >> Bias; - InputIndices.push_back((eParam)0); - InputTypes.push_back(itBias); + input->Node=0; + input->Idx=0; + input->Type=itBias; } else { *AC_cfg >> tmpInputIndex; - InputIndices.push_back(tmpInputIndex); - InputTypes.push_back(itFCS); + input->Idx=tmpInputIndex; + input->Node=0; + input->Type=itFCS; } + Inputs.push_back(input); } else if (token == "CLIPTO") { *AC_cfg >> clipmin >> clipmax; if (clipmax > clipmin) { @@ -92,7 +97,8 @@ FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), } else if (token == "OUTPUT") { IsOutput = true; *AC_cfg >> sOutputIdx; - OutputIdx = fcs->GetState()->GetParameterIndex(sOutputIdx); + OutputNode = PropertyManager->GetNode( + fcs->GetState()->GetPropertyName(sOutputIdx) ); } } @@ -103,6 +109,10 @@ FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), FGSummer::~FGSummer() { + unsigned i; + for(i=0;iType) { case itPilotAC: - Output += fcs->GetState()->GetParameter(InputIndices[idx]); + Output += Inputs[idx]->Node->getDoubleValue(); break; case itFCS: - Output += fcs->GetComponentOutput(InputIndices[idx]); + Output += fcs->GetComponentOutput(Inputs[idx]->Idx); break; case itBias: Output += Bias; @@ -168,14 +178,14 @@ void FGSummer::Debug(int from) if (from == 0) { // Constructor cout << " ID: " << ID << endl; cout << " INPUTS: " << endl; - for (unsigned i=0;iType) { case itPilotAC: - cout << " " << fcs->GetState()->GetParameterName(InputIndices[i]) << endl; + cout << " " << Inputs[i]->Node->getName() << endl; break; case itFCS: - cout << " FCS Component " << InputIndices[i] << " (" << - fcs->GetComponentName(InputIndices[i]) << ")" << endl; + cout << " FCS Component " << Inputs[i]->Idx << " (" << + fcs->GetComponentName(Inputs[i]->Idx) << ")" << endl; break; case itBias: cout << " " << "Bias of " << Bias << endl; @@ -184,7 +194,7 @@ void FGSummer::Debug(int from) } if (clip) cout << " CLIPTO: " << clipmin << ", " << clipmax << endl; - if (IsOutput) cout << " OUTPUT: " <getName() << endl; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification diff --git a/src/FDM/JSBSim/filtersjb/FGSummer.h b/src/FDM/JSBSim/filtersjb/FGSummer.h index 2ff7674a6..42454bd88 100644 --- a/src/FDM/JSBSim/filtersjb/FGSummer.h +++ b/src/FDM/JSBSim/filtersjb/FGSummer.h @@ -75,7 +75,10 @@ CLASS DOCUMENTATION state variables, or even floating point numbers (e.g. for a bias). @author Jon S. Berndt @version $Id$ - @see + @see + Header File + @see + Source File */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -97,8 +100,12 @@ public: private: FGConfigFile* AC_cfg; - vector InputIndices; - vector InputTypes; + typedef struct { + FGPropertyManager* Node; + int Idx; + int Type; + } InputRec; + vector Inputs; bool clip; double clipmin,clipmax; double Bias;