updated the network interface files to add fuel tank selector information.
flaps( 0.0 ),
parking_brake( 0.0 ),
throttle_idle( true ),
- fuel_selector( FUEL_BOTH ),
gear_down( false )
{
}
set_starter( ALL_ENGINES, false );
set_magnetos( ALL_ENGINES, 0 );
throttle_idle = true;
- fuel_selector = FUEL_BOTH;
+ set_fuel_selector( ALL_TANKS, true );
gear_down = true;
}
&FGControls::get_parking_brake, &FGControls::set_parking_brake);
fgSetArchivable("/controls/parking-brake");
for (index = 0; index < MAX_WHEELS; index++) {
- char name[32];
- sprintf(name, "/controls/brakes[%d]", index);
- fgTie(name, this, index,
- &FGControls::get_brake, &FGControls::set_brake);
- fgSetArchivable(name);
+ char name[32];
+ sprintf(name, "/controls/brakes[%d]", index);
+ fgTie(name, this, index,
+ &FGControls::get_brake, &FGControls::set_brake);
+ 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,
&FGControls::get_gear_down, &FGControls::set_gear_down);
fgSetArchivable("/controls/gear-down");
}
}
+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
FGControls::set_parking_brake( double pos )
{
};
enum {
- FUEL_OFF = 0,
- FUEL_LEFT = 1,
- FUEL_RIGHT = 2,
- FUEL_BOTH = 3
+ ALL_TANKS = -1,
+ MAX_TANKS = 4
};
private:
int magnetos[MAX_ENGINES];
bool throttle_idle;
bool starter[MAX_ENGINES];
- int fuel_selector;
+ bool fuel_selector[MAX_TANKS];
bool gear_down;
SGPropertyNode * auto_coordination;
inline double get_brake(int wheel) const { return brake[wheel]; }
inline int get_magnetos(int engine) const { return magnetos[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; }
// Update functions
void set_magnetos( int engine, int pos );
void move_magnetos( int engine, int amt );
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_brake( int wheel, double pos );
void move_brake( int wheel, double amt );
// << 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 ) {
raw->brake[i] = node->getDoubleValue( "brakes", 0.0 );
}
htond(raw->throttle[i]);
htond(raw->mixture[i]);
htond(raw->prop_advance[i]);
- htonl(raw->magnetos[i]);
- htonl(raw->starter[i]);
+ raw->magnetos[i] = htonl(raw->magnetos[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 ) {
htond(raw->brake[i]);
starter = false;
}
- // flaps
- float flaps = 0.0;
- if ( switch_matrix[board][6][3] == 1 ) {
- flaps = 1.0;
- } else if ( switch_matrix[board][5][3] == 1 ) {
- flaps = 2.0 / 3.0;
- } else if ( switch_matrix[board][4][3] == 1 ) {
- flaps = 1.0 / 3.0;
- } else if ( switch_matrix[board][4][3] == 0 ) {
- flaps = 0.0;
- }
-
// 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;
if ( mag1 == mag2 && mag2 == mag3 ) {
fgSetInt( "/controls/magnetos[0]", magnetos );
}
-
static bool start1, start2, start3;
start3 = start2;
start2 = start1;
fgSetBool( "/controls/starter[0]", starter );
}
+
+ // flaps
+ float flaps = 0.0;
+ if ( switch_matrix[board][6][3] == 1 ) {
+ flaps = 1.0;
+ } else if ( switch_matrix[board][5][3] == 1 ) {
+ flaps = 2.0 / 3.0;
+ } else if ( switch_matrix[board][4][3] == 1 ) {
+ flaps = 1.0 / 3.0;
+ } else if ( switch_matrix[board][4][3] == 0 ) {
+ flaps = 0.0;
+ }
+
+ // do a bit of filtering on the magneto/starter switch and the
+ // flap lever because these are not well debounced in hardware
static float flap1, flap2, flap3;
flap3 = flap2;
flap2 = flap1;
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;
}
raw->mixture[i] = globals->get_controls()->get_mixture(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 ) {
raw->brake[i] = globals->get_controls()->get_brake(i);
}
globals->get_controls()->set_mixture( i, raw->mixture[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 ) {
globals->get_controls()->set_brake( i, raw->brake[i] );
}
#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
enum {
FG_MAX_ENGINES = 4,
FG_MAX_WHEELS = 3,
- FG_MAX_TANKS = 2
+ FG_MAX_TANKS = 4
};
// Positions
# error This library requires C++
#endif
-const int FG_RAW_CTRLS_VERSION = 6;
+const int FG_RAW_CTRLS_VERSION = 7;
// Define a structure containing the control parameters
enum {
FG_MAX_ENGINES = 4,
- FG_MAX_WHEELS = 3
+ FG_MAX_WHEELS = 3,
+ FG_MAX_TANKS = 4
};
// Aero controls
double mixture[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
int num_wheels; // number of valid wheels
double brake[FG_MAX_WHEELS]; // 0 ... 1