+ // for each "battery" supplier, propagate the electrical
+ // current
+ for ( i = 0; i < suppliers.size(); ++i ) {
+ FGElectricalSupplier *node = (FGElectricalSupplier *)suppliers[i];
+ if ( node->get_model() == FGElectricalSupplier::FG_BATTERY ) {
+ float load;
+ // cout << "Starting propagation: " << suppliers[i]->get_name()
+ // << endl;
+ load = propagate( suppliers[i], dt,
+ node->get_output_volts(),
+ node->get_output_amps(),
+ " " );
+ // cout << "battery load = " << load << endl;
+
+ if ( node->apply_load( load, dt ) < 0.0 ) {
+ SG_LOG(SG_SYSTEMS, SG_ALERT,
+ "Error drawing more current than available!");
+ }
+ }
+ }
+
+ float alt_norm
+ = fgGetFloat("/systems/electrical/suppliers/alternator") / 60.0;
+
+ // impliment an extremely simplistic voltage model (assumes
+ // certain naming conventions in electrical system config)
+ // FIXME: we probably want to be able to feed power from all
+ // engines if they are running and the master-alt is switched on
+ float volts = 0.0;
+ if ( fgGetBool("/controls/engines/engine[0]/master-bat") ) {
+ volts = 24.0;
+ }
+ if ( fgGetBool("/controls/engines/engine[0]/master-alt") ) {
+ if ( fgGetFloat("/engines/engine[0]/rpm") > 800 ) {
+ float alt_contrib = 28.0;
+ if ( alt_contrib > volts ) {
+ volts = alt_contrib;
+ }
+ } else if ( fgGetFloat("/engines/engine[0]/rpm") > 200 ) {
+ float alt_contrib = 20.0;
+ if ( alt_contrib > volts ) {
+ volts = alt_contrib;
+ }
+ }
+ }
+ _volts_out->setFloatValue( volts );
+
+ // impliment an extremely simplistic amps model (assumes certain
+ // naming conventions in the electrical system config) ... FIXME:
+ // make this more generic
+ float amps = 0.0;
+ if ( fgGetBool("/controls/engines/engine[0]/master-bat") ) {
+ if ( fgGetBool("/controls/engines/engine[0]/master-alt") &&
+ fgGetFloat("/engines/engine[0]/rpm") > 800 )
+ {
+ amps += 40.0 * alt_norm;
+ }
+ amps -= 15.0; // normal load
+ if ( fgGetBool("/controls/switches/flashing-beacon") ) {
+ amps -= 7.5;
+ }
+ if ( fgGetBool("/controls/switches/nav-lights") ) {
+ amps -= 7.5;
+ }
+ if ( amps > 7.0 ) {
+ amps = 7.0;
+ }
+ }
+ _amps_out->setFloatValue( amps );