1
0
Fork 0

Add support for normalized control surface positions

This commit is contained in:
tony 2002-02-28 13:30:25 +00:00
parent 3966e02de0
commit a073e35c7c
5 changed files with 33 additions and 4 deletions

View file

@ -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

View file

@ -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();

View file

@ -71,6 +71,8 @@ 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;

View file

@ -56,6 +56,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");
AC_cfg->GetNextConfigLine();
@ -158,6 +160,10 @@ bool FGKinemat::Run(void ) {
Output = OutputPos;
}
if( Detents[NumDetents-1] > 0 ) {
OutputPct = Output / Detents[NumDetents-1];
}
if (IsOutput) SetOutput();
return true;

View file

@ -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);