]> git.mxchange.org Git - flightgear.git/commitdiff
Added very simplistic volt and amp modeling to the electrical model. This
authorcurt <curt>
Tue, 27 May 2003 19:18:14 +0000 (19:18 +0000)
committercurt <curt>
Tue, 27 May 2003 19:18:14 +0000 (19:18 +0000)
should really be made more generic and part of the electrical model config
but this is all I had time for this weekend.

src/Systems/electrical.cxx
src/Systems/electrical.hxx

index 4f8329af5706e2675feae2a6782212bbbdb93ceb..6e781f050729d0c760f16b121921c2ebf9953217 100644 (file)
@@ -237,6 +237,8 @@ void FGElectricalSystem::init () {
     config_props = new SGPropertyNode;
 
     SGPropertyNode *path_n = fgGetNode("/sim/systems/electrical/path");
+    _volts_out = fgGetNode( "/systems/electrical/volts", true );
+    _amps_out = fgGetNode( "/systems/electrical/amps", true );
 
     if (path_n) {
         SGPath config( globals->get_fg_root() );
@@ -281,6 +283,7 @@ void FGElectricalSystem::unbind () {
 
 void FGElectricalSystem::update (double dt) {
     if ( !enabled ) {
+        _amps_out->setDoubleValue(0);
         return;
     }
 
@@ -308,6 +311,45 @@ void FGElectricalSystem::update (double dt) {
         propagate( suppliers[i], 0.0, " " );
     }
 
+    double alt_norm
+        = fgGetDouble("/systems/electrical/suppliers/alternator") / 60.0;
+
+    // impliment an extremely simplistic voltage model (assumes
+    // certain naming conventions in electrical system config)
+    double volts = 0.0;
+    if ( fgGetBool("/controls/switches/master-bat") ) {
+        volts = 24.0;
+    }
+    if ( fgGetBool("/controls/switches/master-alt") &&
+         fgGetDouble("/engines/engine[0]/rpm") > 800 )
+    {
+        double alt_contrib = 28.0;
+        if ( alt_contrib > volts ) {
+            volts = alt_contrib;
+        }
+    }
+    _volts_out->setDoubleValue( volts );
+
+    // impliment an extremely simplistic amps model (assumes certain
+    // naming conventions in the electrical system config) ... FIXME:
+    // make this more generic
+    double amps = 0.0;
+    if ( fgGetBool("/controls/switches/master-bat") ) {
+        if ( fgGetBool("/controls/switches/master-alt") ) {
+            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->setDoubleValue( amps );
 }
 
 
index 1668c917187d38da0f6ae0d4cf660ca71d73a504..9761a955c644b6297dac8e1542cf0bbd8363b8b0 100644 (file)
@@ -215,6 +215,9 @@ private:
     comp_list buses;
     comp_list outputs;
     comp_list connectors;
+
+    SGPropertyNode *_volts_out;
+    SGPropertyNode *_amps_out;
 };