+++ /dev/null
-// annunciator.hxx - manage the annunciator states
-// Written by Curtis Olson, started May, 2003.
-
-#include <math.h>
-
-#include <simgear/math/interpolater.hxx>
-
-#include <Main/fg_props.hxx>
-#include <Main/util.hxx>
-
-#include "annunciator.hxx"
-
-
-Annunciator::Annunciator ():
- timer0( 0.0 ),
- timer1( 0.0 ),
- timer2( 0.0 ),
- timer3( 0.0 ),
- timer4( 0.0 )
-{
-}
-
-Annunciator::~Annunciator ()
-{
-}
-
-void
-Annunciator::init ()
-{
- _volts = fgGetNode( "/systems/electrical/volts", true );
- _vac_l = fgGetNode( "/systems/vacuum[0]/suction-inhg", true );
- _vac_r = fgGetNode( "/systems/vacuum[1]/suction-inhg", true );
- _fuel_l = fgGetNode( "/consumables/fuel/tank[0]/level-gal_us", true );
- _fuel_r = fgGetNode( "/consumables/fuel/tank[1]/level-gal_us", true );
- _oil_px = fgGetNode( "/engines/engine[0]/oil-pressure-psi", true );
- _elec_serv = fgGetNode( "/systems/electrical/serviceable", true );
-
- _ann_volts = fgGetNode( "/instrumentation/annunciator/volts", true );
- _ann_vac_l = fgGetNode( "/instrumentation/annunciator/vacuum-left", true );
- _ann_vac_r = fgGetNode( "/instrumentation/annunciator/vacuum-right", true );
- _ann_fuel_l = fgGetNode( "/instrumentation/annunciator/fuel-left", true );
- _ann_fuel_r = fgGetNode( "/instrumentation/annunciator/fuel-right", true );
- _ann_oil_px = fgGetNode( "/instrumentation/annunciator/oil-pressure", true );
-}
-
-void
-Annunciator::update (double dt)
-{
- // timers
- timer0 += dt;
- timer1 += dt;
- timer2 += dt;
- timer3 += dt;
- timer4 += dt;
-
- if ( _volts->getDoubleValue() < 5.0 || !_elec_serv->getBoolValue() ) {
- // Not enough juice to illuminate the display
- _ann_volts->setBoolValue( false );
- _ann_vac_l->setBoolValue( false );
- _ann_vac_r->setBoolValue( false );
- _ann_fuel_l->setBoolValue( false );
- _ann_fuel_r->setBoolValue( false );
- _ann_oil_px->setBoolValue( false );
- } else {
- // Volts
- if ( _volts->getDoubleValue() < 24.5 ) {
- if ( timer1 < 10 ) {
- double rem = timer0 - (int)timer0;
- if ( rem <= 0.5 ) {
- _ann_volts->setBoolValue( true );
- } else {
- _ann_volts->setBoolValue( false );
- }
- } else {
- _ann_volts->setBoolValue( true );
- }
- } else {
- _ann_volts->setBoolValue( false );
- timer1 = 0.0;
- }
-
- if ( _fuel_l->getDoubleValue() < 5.0
- && _fuel_r->getDoubleValue() < 5.0 )
- {
- if ( timer2 < 10 ) {
- double rem = timer0 - (int)timer0;
- if ( rem <= 0.5 ) {
- _ann_fuel_l->setBoolValue( true );
- _ann_fuel_r->setBoolValue( true );
- } else {
- _ann_fuel_l->setBoolValue( false );
- _ann_fuel_r->setBoolValue( false );
- }
- } else {
- _ann_fuel_l->setBoolValue( true );
- _ann_fuel_r->setBoolValue( true );
- }
- } else if ( _fuel_l->getDoubleValue() < 5.0 ) {
- if ( timer2 < 10 ) {
- double rem = timer0 - (int)timer0;
- if ( rem <= 0.5 ) {
- _ann_fuel_l->setBoolValue( true );
- } else {
- _ann_fuel_l->setBoolValue( false );
- }
- } else {
- _ann_fuel_l->setBoolValue( true );
- }
- _ann_fuel_r->setBoolValue( false );
- } else if ( _fuel_r->getDoubleValue() < 5.0 ) {
- if ( timer2 < 10 ) {
- double rem = timer0 - (int)timer0;
- if ( rem <= 0.5 ) {
- _ann_fuel_r->setBoolValue( true );
- } else {
- _ann_fuel_r->setBoolValue( false );
- }
- } else {
- _ann_fuel_r->setBoolValue( true );
- }
- _ann_fuel_l->setBoolValue( false );
- } else {
- _ann_fuel_l->setBoolValue( false );
- _ann_fuel_r->setBoolValue( false );
- timer2 = 0.0;
- }
-
- // vacuum pumps
- if ( _vac_l->getDoubleValue() < 3.0
- && _vac_r->getDoubleValue() < 3.0 )
- {
- if ( timer3 < 10 ) {
- double rem = timer0 - (int)timer0;
- if ( rem <= 0.5 ) {
- _ann_vac_l->setBoolValue( true );
- _ann_vac_r->setBoolValue( true );
- } else {
- _ann_vac_l->setBoolValue( false );
- _ann_vac_r->setBoolValue( false );
- }
- } else {
- _ann_vac_l->setBoolValue( true );
- _ann_vac_r->setBoolValue( true );
- }
- } else if ( _vac_l->getDoubleValue() < 3.0 ) {
- if ( timer3 < 10 ) {
- double rem = timer0 - (int)timer0;
- if ( rem <= 0.5 ) {
- _ann_vac_l->setBoolValue( true );
- } else {
- _ann_vac_l->setBoolValue( false );
- }
- } else {
- _ann_vac_l->setBoolValue( true );
- }
- _ann_vac_r->setBoolValue( false );
- } else if ( _vac_r->getDoubleValue() < 3.0 ) {
- if ( timer3 < 10 ) {
- double rem = timer0 - (int)timer0;
- if ( rem <= 0.5 ) {
- _ann_vac_r->setBoolValue( true );
- } else {
- _ann_vac_r->setBoolValue( false );
- }
- } else {
- _ann_vac_r->setBoolValue( true );
- }
- _ann_vac_l->setBoolValue( false );
- } else {
- _ann_vac_l->setBoolValue( false );
- _ann_vac_r->setBoolValue( false );
- timer3 = 0.0;
- }
-
- // Oil pressure
- if ( _oil_px->getDoubleValue() < 20.0 ) {
- if ( timer4 < 10 ) {
- double rem = timer0 - (int)timer0;
- if ( rem <= 0.5 ) {
- _ann_oil_px->setBoolValue( true );
- } else {
- _ann_oil_px->setBoolValue( false );
- }
- } else {
- _ann_oil_px->setBoolValue( true );
- }
- } else {
- _ann_oil_px->setBoolValue( false );
- timer4 = 0.0;
- }
- }
-}
-
-
-// end of annunciator.cxx
+++ /dev/null
-// annunciator.hxx - manage the annunciator states
-// Written by Curtis Olson, started May, 2003.
-
-
-#ifndef __INSTRUMENTS_ANNUNCIATOR_HXX
-#define __INSTRUMENTS_ANNUNCIATOR_HXX 1
-
-#ifndef __cplusplus
-# error This library requires C++
-#endif
-
-#include <simgear/props/props.hxx>
-#include <simgear/structure/subsystem_mgr.hxx>
-
-
-/**
- * Model the annunciators. This is innitially hard coded for a C172S
- *
- * Input properties:
- *
- * Amps
- * L/R Fuel qty
- * L/R Vacuum pumps
- * Oil pressure
- *
- * Output properties:
- *
- * /instrumentation/airspeed-indicator/indicated-speed-kt
- */
-class Annunciator : public SGSubsystem
-{
-
- // timers
- double timer0; // used to sync flashing
- double timer1;
- double timer2;
- double timer3;
- double timer4;
-
- // inputs
- SGPropertyNode_ptr _volts;
- SGPropertyNode_ptr _vac_l;
- SGPropertyNode_ptr _vac_r;
- SGPropertyNode_ptr _fuel_l;
- SGPropertyNode_ptr _fuel_r;
- SGPropertyNode_ptr _oil_px;
- SGPropertyNode_ptr _elec_serv;
-
- // outputs
- SGPropertyNode_ptr _ann_volts; // VOLTS (red)
- SGPropertyNode_ptr _ann_vac_l; // L VAC (amber)
- SGPropertyNode_ptr _ann_vac_r; // VAC R (amber
- SGPropertyNode_ptr _ann_fuel_l; // L LOW FUEL (amber)
- SGPropertyNode_ptr _ann_fuel_r; // LOW FUEL R (amber)
- SGPropertyNode_ptr _ann_oil_px; // OIL PRESS (red)
-
-public:
-
- Annunciator ();
- virtual ~Annunciator ();
-
- virtual void init ();
- virtual void update (double dt);
-
-private:
-
-};
-
-#endif // __INSTRUMENTS_ANNUNCIATOR_HXX