+float FGElectricalSupplier::apply_load( float amps, float dt ) {
+ if ( model == FG_BATTERY ) {
+ // calculate amp hours used
+ float amphrs_used = amps * dt / 3600.0;
+
+ // calculate percent of total available capacity
+ float percent_used = amphrs_used / amp_hours;
+ percent_remaining -= percent_used;
+ if ( percent_remaining < 0.0 ) {
+ percent_remaining = 0.0;
+ } else if ( percent_remaining > 1.0 ) {
+ percent_remaining = 1.0;
+ }
+ // cout << "battery percent = " << percent_remaining << endl;
+ return amp_hours * percent_remaining;
+ } else if ( model == FG_ALTERNATOR ) {
+ // scale alternator output for rpms < 600. For rpms >= 600
+ // give full output. This is just a WAG, and probably not how
+ // it really works but I'm keeping things "simple" to start.
+ float rpm = _rpm_node->getFloatValue();
+ float factor = rpm / rpm_threshold;
+ if ( factor > 1.0 ) {
+ factor = 1.0;
+ }
+ // cout << "alternator amps = " << amps * factor << endl;
+ float available_amps = ideal_amps * factor;
+ return available_amps - amps;
+ } else if ( model == FG_EXTERNAL ) {
+ // cout << "external amps = " << 0.0 << endl;
+ float available_amps = ideal_amps;
+ return available_amps - amps;
+ } else {
+ SG_LOG( SG_SYSTEMS, SG_ALERT, "unknown supplier type" );
+ }
+
+ return 0.0;
+}
+
+
+float FGElectricalSupplier::get_output_volts() {