From 2b74a7c3d62edc8250b1d9fd028695da13d47702 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 16 Dec 2002 01:13:39 +0000 Subject: [PATCH] Additional failure modeling. Support parking brake in external fdm. --- src/Cockpit/kr_87.cxx | 6 ++- src/Cockpit/kr_87.hxx | 1 + src/Cockpit/navcom.cxx | 80 ++++++++++++++++++++--------- src/Cockpit/navcom.hxx | 2 + src/FDM/ExternalNet/ExternalNet.cxx | 8 ++- 5 files changed, 70 insertions(+), 27 deletions(-) diff --git a/src/Cockpit/kr_87.cxx b/src/Cockpit/kr_87.cxx index 67a0586db..c26f30348 100644 --- a/src/Cockpit/kr_87.cxx +++ b/src/Cockpit/kr_87.cxx @@ -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 ) { diff --git a/src/Cockpit/kr_87.hxx b/src/Cockpit/kr_87.hxx index c0b482e5a..492a20874 100644 --- a/src/Cockpit/kr_87.hxx +++ b/src/Cockpit/kr_87.hxx @@ -44,6 +44,7 @@ class FGKR_87 : public FGSubsystem SGPropertyNode *lat_node; SGPropertyNode *alt_node; SGPropertyNode *bus_power; + SGPropertyNode *servicable; bool need_update; diff --git a/src/Cockpit/navcom.cxx b/src/Cockpit/navcom.cxx index 665f8b3bc..f4c47dbd6 100644 --- a/src/Cockpit/navcom.cxx +++ b/src/Cockpit/navcom.cxx @@ -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; + } } diff --git a/src/Cockpit/navcom.hxx b/src/Cockpit/navcom.hxx index 6eb52d1f0..e3ae300bf 100644 --- a/src/Cockpit/navcom.hxx +++ b/src/Cockpit/navcom.hxx @@ -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; diff --git a/src/FDM/ExternalNet/ExternalNet.cxx b/src/FDM/ExternalNet/ExternalNet.cxx index 4c288ec26..d8b184bf2 100644 --- a/src/FDM/ExternalNet/ExternalNet.cxx +++ b/src/FDM/ExternalNet/ExternalNet.cxx @@ -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; } -- 2.39.5