]> git.mxchange.org Git - flightgear.git/commitdiff
Additional failure modeling.
authorcurt <curt>
Mon, 16 Dec 2002 01:13:39 +0000 (01:13 +0000)
committercurt <curt>
Mon, 16 Dec 2002 01:13:39 +0000 (01:13 +0000)
Support parking brake in external fdm.

src/Cockpit/kr_87.cxx
src/Cockpit/kr_87.hxx
src/Cockpit/navcom.cxx
src/Cockpit/navcom.hxx
src/FDM/ExternalNet/ExternalNet.cxx

index 67a0586dbf341ae13d53f58ab928e8525f079cc2..c26f30348e94d1362129a15ddafeab3f81f0e8c3 100644 (file)
@@ -74,6 +74,7 @@ FGKR_87::FGKR_87() :
     lat_node(fgGetNode("/position/latitude-deg", true)),
     alt_node(fgGetNode("/position/altitude-ft", true)),
     bus_power(fgGetNode("/systems/electrical/outputs/adf", true)),
+    servicable(fgGetNode("/instrumentation/adf/servicable", true)),
     need_update(true),
     valid(false),
     inrange(false),
@@ -113,6 +114,7 @@ FGKR_87::~FGKR_87() {
 
 
 void FGKR_87::init () {
+    servicable->setBoolValue( true );
     morse.init();
 }
 
@@ -245,7 +247,7 @@ void FGKR_87::update( double dt ) {
     // Radio
     ////////////////////////////////////////////////////////////////////////
 
-    if ( has_power() ) {
+    if ( has_power() && servicable->getBoolValue() ) {
         // buttons
         if ( adf_btn == 0 ) {
             ant_mode = 1;
@@ -438,7 +440,7 @@ void FGKR_87::update( double dt ) {
     //      << " needle = " << needle_deg << endl;
 
 #ifdef ENABLE_AUDIO_SUPPORT
-    if ( valid && inrange ) {
+    if ( valid && inrange && servicable->getBoolValue() ) {
        // play station ident via audio system if on + ident_btn,
        // otherwise turn it off
        if ( vol_btn >= 0.01 && ident_btn ) {
index c0b482e5ae6533320f8e3df7e92eec093b322099..492a20874662f042fd24d1b0fabdf9f8d74d8883 100644 (file)
@@ -44,6 +44,7 @@ class FGKR_87 : public FGSubsystem
     SGPropertyNode *lat_node;
     SGPropertyNode *alt_node;
     SGPropertyNode *bus_power;
+    SGPropertyNode *servicable;
 
     bool need_update;
 
index 665f8b3bc71bd1f242b8fa876235c70ecc349666..f4c47dbd634d1ecd3e22e1a624c031d16c2ca141 100644 (file)
@@ -93,10 +93,31 @@ FGNavCom::init ()
     // We assume that index is valid now (it must be set before init()
     // is called.)
     char propname[256];
+
     sprintf( propname, "/systems/electrical/outputs/navcom[%d]", index );
     // default to true in case no electrical system defined.
     fgSetDouble( propname, 60.0 );
     bus_power = fgGetNode( propname, true );
+
+    sprintf( propname, "/instrumentation/comm[%d]/servicable", index );
+    com_servicable = fgGetNode( propname, true );
+    com_servicable->setBoolValue( true );
+
+    sprintf( propname, "/instrumentation/nav[%d]/servicable", index );
+    nav_servicable = fgGetNode( propname, true );
+    nav_servicable->setBoolValue( true );
+
+    sprintf( propname, "/instrumentation/vor[%d]/cdi/servicable", index );
+    cdi_servicable = fgGetNode( propname, true );
+    cdi_servicable->setBoolValue( true );
+
+    sprintf( propname, "/instrumentation/vor[%d]/gs/servicable", index );
+    gs_servicable = fgGetNode( propname, true );
+    gs_servicable->setBoolValue( true );
+
+    sprintf( propname, "/instrumentation/vor[%d]/to-from/servicable", index );
+    tofrom_servicable = fgGetNode( propname, true );
+    tofrom_servicable->setBoolValue( true );
 }
 
 void
@@ -209,7 +230,7 @@ FGNavCom::unbind ()
 
 // model standard VOR/DME/TACAN service volumes as per AIM 1-1-8
 double FGNavCom::adjustNavRange( double stationElev, double aircraftElev,
-                             double nominalRange )
+                                 double nominalRange )
 {
     // extend out actual usable range to be 1.3x the published safe range
     const double usability_factor = 1.3;
@@ -287,7 +308,9 @@ FGNavCom::update(double dt)
     // Nav.
     ////////////////////////////////////////////////////////////////////////
 
-    if ( nav_valid && power_btn && (bus_power->getDoubleValue() > 1.0) ) {
+    if ( nav_valid && power_btn && (bus_power->getDoubleValue() > 1.0)
+         && nav_servicable->getBoolValue() )
+    {
        station = Point3D( nav_x, nav_y, nav_z );
        nav_loc_dist = aircraft.distance3D( station );
 
@@ -339,7 +362,7 @@ FGNavCom::update(double dt)
     }
 
 #ifdef ENABLE_AUDIO_SUPPORT
-    if ( nav_valid && nav_inrange ) {
+    if ( nav_valid && nav_inrange && nav_servicable->getBoolValue() ) {
        // play station ident via audio system if on + ident,
        // otherwise turn it off
        if ( power_btn && (bus_power->getDoubleValue() > 1.0)
@@ -547,7 +570,9 @@ void FGNavCom::search()
 double FGNavCom::get_nav_heading_needle_deflection() const {
     double r;
 
-    if ( nav_inrange ) {
+    if ( nav_inrange
+         && nav_servicable->getBoolValue() && cdi_servicable->getBoolValue() )
+    {
         r = nav_heading - nav_radial;
        // cout << "Radial = " << nav_radial 
        //      << "  Bearing = " << nav_heading << endl;
@@ -572,7 +597,9 @@ double FGNavCom::get_nav_heading_needle_deflection() const {
 // return the amount of glide slope needle deflection (.i.e. the
 // number of degrees we are off the glide slope * 5.0
 double FGNavCom::get_nav_gs_needle_deflection() const {
-    if ( nav_inrange && nav_has_gs ) {
+    if ( nav_inrange && nav_has_gs
+         && nav_servicable->getBoolValue() && gs_servicable->getBoolValue() )
+    {
        double x = nav_gs_dist;
        double y = (fgGetDouble("/position/altitude-ft") - nav_elev)
             * SG_FEET_TO_METER;
@@ -590,15 +617,19 @@ double FGNavCom::get_nav_gs_needle_deflection() const {
 bool 
 FGNavCom::get_nav_to_flag () const
 {
-  if (nav_inrange) {
-    double offset = fabs(nav_heading - nav_radial);
-    if (nav_loc)
-      return true;
-    else
-      return (offset <= 90.0 || offset >= 270.0);
-  } else {
-    return false;
-  }
+    if ( nav_inrange
+         && nav_servicable->getBoolValue()
+         && tofrom_servicable->getBoolValue() )
+    {
+        double offset = fabs(nav_heading - nav_radial);
+        if (nav_loc) {
+            return true;
+        } else {
+            return (offset <= 90.0 || offset >= 270.0);
+        }
+    } else {
+        return false;
+    }
 }
 
 
@@ -608,13 +639,16 @@ FGNavCom::get_nav_to_flag () const
 bool
 FGNavCom::get_nav_from_flag () const
 {
-  if (nav_inrange) {
-    double offset = fabs(nav_heading - nav_radial);
-    if (nav_loc)
-      return false;
-    else
-      return (offset > 90.0 && offset < 270.0);
-  } else {
-    return false;
-  }
+    if ( nav_inrange
+         && nav_servicable->getBoolValue()
+         && tofrom_servicable->getBoolValue() ) {
+        double offset = fabs(nav_heading - nav_radial);
+        if (nav_loc) {
+            return false;
+        } else {
+          return (offset > 90.0 && offset < 270.0);
+        }
+    } else {
+        return false;
+    }
 }
index 6eb52d1f04fc2a67d58e6079cc5125b30ff88f65..e3ae300bfaa335aea605595fe88f45a01d48d4b0 100644 (file)
@@ -49,6 +49,8 @@ class FGNavCom : public FGSubsystem
     SGPropertyNode *lat_node;
     SGPropertyNode *alt_node;
     SGPropertyNode *bus_power;
+    SGPropertyNode *com_servicable, *nav_servicable;
+    SGPropertyNode *cdi_servicable, *gs_servicable, *tofrom_servicable;
 
     string last_nav_id;
     bool last_nav_vor;
index 4c288ec26a75508eaffb561ee3ddbf96b4d4f536..d8b184bf244f68c17d402f145b4c9a824454163e 100644 (file)
@@ -108,8 +108,12 @@ static void global2net( FGNetCtrls *net ) {
     net->num_wheels = FGNetCtrls::FG_MAX_WHEELS;
     for ( i = 0; i < FGNetCtrls::FG_MAX_WHEELS; ++i ) {
         if ( node->getChild("brakes", i) != 0 ) {
-            net->brake[i]
-                = node->getChild("brakes", i)->getDoubleValue();
+            if ( node->getChild("parking-brake")->getDoubleValue() > 0.0 ) {
+                net->brake[i] = 1.0;
+           } else {
+                net->brake[i]
+                    = node->getChild("brakes", i)->getDoubleValue();
+            }
         } else {
             net->brake[i] = 0.0;
         }