1
0
Fork 0

Update controls so we can specify each tank on/off individually. Also

updated the network interface files to add fuel tank selector information.
This commit is contained in:
curt 2002-07-05 19:04:04 +00:00
parent eab0479417
commit b17e1bb7c0
7 changed files with 95 additions and 39 deletions

View file

@ -62,7 +62,6 @@ FGControls::FGControls() :
flaps( 0.0 ), flaps( 0.0 ),
parking_brake( 0.0 ), parking_brake( 0.0 ),
throttle_idle( true ), throttle_idle( true ),
fuel_selector( FUEL_BOTH ),
gear_down( false ) gear_down( false )
{ {
} }
@ -80,7 +79,7 @@ void FGControls::reset_all()
set_starter( ALL_ENGINES, false ); set_starter( ALL_ENGINES, false );
set_magnetos( ALL_ENGINES, 0 ); set_magnetos( ALL_ENGINES, 0 );
throttle_idle = true; throttle_idle = true;
fuel_selector = FUEL_BOTH; set_fuel_selector( ALL_TANKS, true );
gear_down = true; gear_down = true;
} }
@ -161,15 +160,19 @@ FGControls::bind ()
&FGControls::get_parking_brake, &FGControls::set_parking_brake); &FGControls::get_parking_brake, &FGControls::set_parking_brake);
fgSetArchivable("/controls/parking-brake"); fgSetArchivable("/controls/parking-brake");
for (index = 0; index < MAX_WHEELS; index++) { for (index = 0; index < MAX_WHEELS; index++) {
char name[32]; char name[32];
sprintf(name, "/controls/brakes[%d]", index); sprintf(name, "/controls/brakes[%d]", index);
fgTie(name, this, index, fgTie(name, this, index,
&FGControls::get_brake, &FGControls::set_brake); &FGControls::get_brake, &FGControls::set_brake);
fgSetArchivable(name); fgSetArchivable(name);
}
for (index = 0; index < MAX_TANKS; index++) {
char name[32];
sprintf(name, "/controls/fuel-selector[%d]", index);
fgTie(name, this, index,
&FGControls::get_fuel_selector, &FGControls::set_fuel_selector);
fgSetArchivable(name);
} }
fgTie("/controls/fuel-selector", this,
&FGControls::get_fuel_selector, &FGControls::set_fuel_selector);
fgSetArchivable("/controls/fuel-selector");
fgTie("/controls/gear-down", this, fgTie("/controls/gear-down", this,
&FGControls::get_gear_down, &FGControls::set_gear_down); &FGControls::get_gear_down, &FGControls::set_gear_down);
fgSetArchivable("/controls/gear-down"); fgSetArchivable("/controls/gear-down");
@ -472,6 +475,21 @@ FGControls::set_starter( int engine, bool flag )
} }
} }
void
FGControls::set_fuel_selector( int tank, bool pos )
{
if ( tank == ALL_TANKS ) {
for ( int i = 0; i < MAX_TANKS; i++ ) {
fuel_selector[i] = pos;
}
} else {
if ( (tank >= 0) && (tank < MAX_TANKS) ) {
fuel_selector[tank] = pos;
}
}
}
void void
FGControls::set_parking_brake( double pos ) FGControls::set_parking_brake( double pos )
{ {

View file

@ -52,10 +52,8 @@ public:
}; };
enum { enum {
FUEL_OFF = 0, ALL_TANKS = -1,
FUEL_LEFT = 1, MAX_TANKS = 4
FUEL_RIGHT = 2,
FUEL_BOTH = 3
}; };
private: private:
@ -75,7 +73,7 @@ private:
int magnetos[MAX_ENGINES]; int magnetos[MAX_ENGINES];
bool throttle_idle; bool throttle_idle;
bool starter[MAX_ENGINES]; bool starter[MAX_ENGINES];
int fuel_selector; bool fuel_selector[MAX_TANKS];
bool gear_down; bool gear_down;
SGPropertyNode * auto_coordination; SGPropertyNode * auto_coordination;
@ -111,7 +109,9 @@ public:
inline double get_brake(int wheel) const { return brake[wheel]; } inline double get_brake(int wheel) const { return brake[wheel]; }
inline int get_magnetos(int engine) const { return magnetos[engine]; } inline int get_magnetos(int engine) const { return magnetos[engine]; }
inline bool get_starter(int engine) const { return starter[engine]; } inline bool get_starter(int engine) const { return starter[engine]; }
inline int get_fuel_selector() const { return fuel_selector; } inline bool get_fuel_selector(int tank) const {
return fuel_selector[tank];
}
inline bool get_gear_down() const { return gear_down; } inline bool get_gear_down() const { return gear_down; }
// Update functions // Update functions
@ -138,7 +138,7 @@ public:
void set_magnetos( int engine, int pos ); void set_magnetos( int engine, int pos );
void move_magnetos( int engine, int amt ); void move_magnetos( int engine, int amt );
void set_starter( int engine, bool flag ); void set_starter( int engine, bool flag );
void set_fuel_selector( int pos ) { fuel_selector = pos; } void set_fuel_selector( int tank, bool pos );
void set_parking_brake( double pos ); void set_parking_brake( double pos );
void set_brake( int wheel, double pos ); void set_brake( int wheel, double pos );
void move_brake( int wheel, double amt ); void move_brake( int wheel, double amt );

View file

@ -87,6 +87,9 @@ static void global2raw( FGRawCtrls *raw ) {
// << endl; // << endl;
} }
} }
for ( i = 0; i < FGRawCtrls::FG_MAX_TANKS; ++i ) {
raw->fuel_selector[i] = node->getDoubleValue( "fuel-selector", true );
}
for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) { for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) {
raw->brake[i] = node->getDoubleValue( "brakes", 0.0 ); raw->brake[i] = node->getDoubleValue( "brakes", 0.0 );
} }
@ -105,8 +108,11 @@ static void global2raw( FGRawCtrls *raw ) {
htond(raw->throttle[i]); htond(raw->throttle[i]);
htond(raw->mixture[i]); htond(raw->mixture[i]);
htond(raw->prop_advance[i]); htond(raw->prop_advance[i]);
htonl(raw->magnetos[i]); raw->magnetos[i] = htonl(raw->magnetos[i]);
htonl(raw->starter[i]); raw->starter[i] = htonl(raw->starter[i]);
}
for ( i = 0; i < FGRawCtrls::FG_MAX_TANKS; ++i ) {
raw->fuel_selector[i] = htonl(raw->fuel_selector[i]);
} }
for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) { for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) {
htond(raw->brake[i]); htond(raw->brake[i]);

View file

@ -1340,6 +1340,24 @@ bool FGATC610x::do_switches() {
starter = false; starter = false;
} }
// do a bit of filtering on the magneto/starter switch and the
// flap lever because these are not well debounced in hardware
static int mag1, mag2, mag3;
mag3 = mag2;
mag2 = mag1;
mag1 = magnetos;
if ( mag1 == mag2 && mag2 == mag3 ) {
fgSetInt( "/controls/magnetos[0]", magnetos );
}
static bool start1, start2, start3;
start3 = start2;
start2 = start1;
start1 = starter;
if ( start1 == start2 && start2 == start3 ) {
fgSetBool( "/controls/starter[0]", starter );
}
// flaps // flaps
float flaps = 0.0; float flaps = 0.0;
if ( switch_matrix[board][6][3] == 1 ) { if ( switch_matrix[board][6][3] == 1 ) {
@ -1354,22 +1372,6 @@ bool FGATC610x::do_switches() {
// do a bit of filtering on the magneto/starter switch and the // do a bit of filtering on the magneto/starter switch and the
// flap lever because these are not well debounced in hardware // flap lever because these are not well debounced in hardware
static int mag1, mag2, mag3;
mag3 = mag2;
mag2 = mag1;
mag1 = magnetos;
if ( mag1 == mag2 && mag2 == mag3 ) {
fgSetInt( "/controls/magnetos[0]", magnetos );
}
static bool start1, start2, start3;
start3 = start2;
start2 = start1;
start1 = starter;
if ( start1 == start2 && start2 == start3 ) {
fgSetBool( "/controls/starter[0]", starter );
}
static float flap1, flap2, flap3; static float flap1, flap2, flap3;
flap3 = flap2; flap3 = flap2;
flap2 = flap1; flap2 = flap1;
@ -1378,6 +1380,25 @@ bool FGATC610x::do_switches() {
fgSetFloat( "/controls/flaps", flaps ); fgSetFloat( "/controls/flaps", flaps );
} }
// fuel selector (not finished)
if ( true ) {
// both
fgSetFloat( "/controls/fuel-selector[0]", true );
fgSetFloat( "/controls/fuel-selector[1]", true );
} else if ( true ) {
// left
fgSetFloat( "/controls/fuel-selector[0]", true );
fgSetFloat( "/controls/fuel-selector[1]", false );
} else if ( true ) {
// right
fgSetFloat( "/controls/fuel-selector[0]", false );
fgSetFloat( "/controls/fuel-selector[1]", true );
} else {
// fuel cutoff
fgSetFloat( "/controls/fuel-selector[0]", false );
fgSetFloat( "/controls/fuel-selector[1]", false );
}
return true; return true;
} }

View file

@ -71,6 +71,9 @@ static void global2raw( const FGControls *global, FGRawCtrls *raw ) {
raw->mixture[i] = globals->get_controls()->get_mixture(i); raw->mixture[i] = globals->get_controls()->get_mixture(i);
raw->prop_advance[i] = globals->get_controls()->get_prop_advance(i); raw->prop_advance[i] = globals->get_controls()->get_prop_advance(i);
} }
for ( i = 0; i < FGRawCtrls::FG_MAX_TANKS; ++i ) {
raw->fuel_selector[i] = globals->get_controls()->get_fuel_selector(i);
}
for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) { for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) {
raw->brake[i] = globals->get_controls()->get_brake(i); raw->brake[i] = globals->get_controls()->get_brake(i);
} }
@ -93,6 +96,9 @@ static void raw2global( const FGRawCtrls *raw, FGControls *global ) {
globals->get_controls()->set_mixture( i, raw->mixture[i] ); globals->get_controls()->set_mixture( i, raw->mixture[i] );
globals->get_controls()->set_prop_advance( i, raw->prop_advance[i]); globals->get_controls()->set_prop_advance( i, raw->prop_advance[i]);
} }
for ( i = 0; i < FGRawCtrls::FG_MAX_TANKS; ++i ) {
globals->get_controls()->set_fuel_selector( i, raw->fuel_selector[i] );
}
for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) { for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) {
globals->get_controls()->set_brake( i, raw->brake[i] ); globals->get_controls()->set_brake( i, raw->brake[i] );
} }

View file

@ -32,7 +32,7 @@
#include <time.h> // time_t #include <time.h> // time_t
const int FG_NET_FDM_VERSION = 7; const int FG_NET_FDM_VERSION = 8;
// Define a structure containing the top level flight dynamics model // Define a structure containing the top level flight dynamics model
@ -51,7 +51,7 @@ public:
enum { enum {
FG_MAX_ENGINES = 4, FG_MAX_ENGINES = 4,
FG_MAX_WHEELS = 3, FG_MAX_WHEELS = 3,
FG_MAX_TANKS = 2 FG_MAX_TANKS = 4
}; };
// Positions // Positions

View file

@ -30,7 +30,7 @@
# error This library requires C++ # error This library requires C++
#endif #endif
const int FG_RAW_CTRLS_VERSION = 6; const int FG_RAW_CTRLS_VERSION = 7;
// Define a structure containing the control parameters // Define a structure containing the control parameters
@ -43,7 +43,8 @@ public:
enum { enum {
FG_MAX_ENGINES = 4, FG_MAX_ENGINES = 4,
FG_MAX_WHEELS = 3 FG_MAX_WHEELS = 3,
FG_MAX_TANKS = 4
}; };
// Aero controls // Aero controls
@ -61,6 +62,10 @@ public:
double mixture[FG_MAX_ENGINES]; // 0 ... 1 double mixture[FG_MAX_ENGINES]; // 0 ... 1
double prop_advance[FG_MAX_ENGINES]; // 0 ... 1 double prop_advance[FG_MAX_ENGINES]; // 0 ... 1
// Fuel management
int num_tanks; // number of valid tanks
bool fuel_selector[FG_MAX_TANKS]; // false = off, true = on
// Brake controls // Brake controls
int num_wheels; // number of valid wheels int num_wheels; // number of valid wheels
double brake[FG_MAX_WHEELS]; // 0 ... 1 double brake[FG_MAX_WHEELS]; // 0 ... 1