diff --git a/src/FDM/JSBSim/filtersjb/FGFCSComponent.h b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h index c8df597b4..6c8c51984 100644 --- a/src/FDM/JSBSim/filtersjb/FGFCSComponent.h +++ b/src/FDM/JSBSim/filtersjb/FGFCSComponent.h @@ -100,7 +100,10 @@ public: virtual bool Run(void); virtual void SetOutput(void); inline double GetOutput (void) {return Output;} + inline int GetOutputIdx(void) { return OutputIdx; } inline string GetName(void) {return Name;} + inline string GetType(void) { return Type; } + virtual double GetOutputPct(void) { return 0; } protected: /// Pilot/Aircraft, FCS, Autopilot inputs diff --git a/src/FDM/JSBSim/filtersjb/FGGain.cpp b/src/FDM/JSBSim/filtersjb/FGGain.cpp index b2548f8d7..23b3d6541 100644 --- a/src/FDM/JSBSim/filtersjb/FGGain.cpp +++ b/src/FDM/JSBSim/filtersjb/FGGain.cpp @@ -58,6 +58,8 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), Gain = 1.000; Rows = 0; Min = Max = 0.0; + OutputPct=0; + invert=false; ScheduledBy = FG_UNDEF; Type = AC_cfg->GetValue("TYPE"); @@ -84,6 +86,8 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), *AC_cfg >> Min; } else if (token == "MAX") { *AC_cfg >> Max; + } else if (token == "INVERT") { + invert=true; } else if (token == "ROWS") { *AC_cfg >> Rows; Table = new FGTable(Rows); @@ -130,8 +134,15 @@ bool FGGain::Run(void ) SchedGain = Table->GetValue(LookupVal); Output = Gain * SchedGain * Input; } else if (Type == "AEROSURFACE_SCALE") { - if (Output >= 0.0) Output = Input * Max; - else Output = Input * (-Min); + if(!invert) { + OutputPct = Input; + if (Input >= 0.0) Output = Input * Max; + else Output = Input * -Min; + } else { + OutputPct=-1*Input; + if (Input <= 0.0) Output = Input * -Max; + else Output = Input * Min; + } Output *= Gain; } @@ -179,6 +190,7 @@ void FGGain::Debug(int from) if (IsOutput) cout << " OUTPUT: " << sOutputIdx << 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; Table->Print(); diff --git a/src/FDM/JSBSim/filtersjb/FGGain.h b/src/FDM/JSBSim/filtersjb/FGGain.h index 7fced50e1..23c233b47 100644 --- a/src/FDM/JSBSim/filtersjb/FGGain.h +++ b/src/FDM/JSBSim/filtersjb/FGGain.h @@ -70,7 +70,9 @@ class FGGain : public FGFCSComponent public: FGGain(FGFCS* fcs, FGConfigFile* AC_cfg); ~FGGain(); - + + double GetOutputPct() { return OutputPct; } + bool Run (void); private: @@ -79,6 +81,8 @@ private: FGState* State; double Gain; double Min, Max; + double OutputPct; + bool invert; int Rows; eParam ScheduledBy; diff --git a/src/FDM/JSBSim/filtersjb/FGKinemat.cpp b/src/FDM/JSBSim/filtersjb/FGKinemat.cpp index 15375be44..4e94e8652 100644 --- a/src/FDM/JSBSim/filtersjb/FGKinemat.cpp +++ b/src/FDM/JSBSim/filtersjb/FGKinemat.cpp @@ -55,6 +55,8 @@ FGKinemat::FGKinemat(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs), Detents.clear(); TransitionTimes.clear(); + + OutputPct=0; Type = AC_cfg->GetValue("TYPE"); Name = AC_cfg->GetValue("NAME"); @@ -157,7 +159,11 @@ bool FGKinemat::Run(void ) { lastInputCmd = InputCmd; Output = OutputPos; } - + + if( Detents[NumDetents-1] > 0 ) { + OutputPct = Output / Detents[NumDetents-1]; + } + if (IsOutput) SetOutput(); return true; diff --git a/src/FDM/JSBSim/filtersjb/FGKinemat.h b/src/FDM/JSBSim/filtersjb/FGKinemat.h index cea2b549e..c4891b96f 100644 --- a/src/FDM/JSBSim/filtersjb/FGKinemat.h +++ b/src/FDM/JSBSim/filtersjb/FGKinemat.h @@ -70,6 +70,9 @@ class FGKinemat : public FGFCSComponent { public: FGKinemat(FGFCS* fcs, FGConfigFile* AC_cfg); ~FGKinemat(); + + double GetOutputPct() { return OutputPct; } + bool Run (void ); private: @@ -80,6 +83,7 @@ private: double lastInputCmd; double InputCmd; double OutputPos; + double OutputPct; bool InTransit; void Debug(int from);