1 // annunciator.hxx - manage the annunciator states
2 // Written by Curtis Olson, started May, 2003.
6 #include <simgear/math/interpolater.hxx>
8 #include <Main/fg_props.hxx>
9 #include <Main/util.hxx>
11 #include "annunciator.hxx"
14 Annunciator::Annunciator ():
23 Annunciator::~Annunciator ()
30 _volts = fgGetNode( "/systems/electrical/volts", true );
31 _vac_l = fgGetNode( "/systems/vacuum[0]/suction-inhg", true );
32 _vac_r = fgGetNode( "/systems/vacuum[1]/suction-inhg", true );
33 _fuel_l = fgGetNode( "/consumables/fuel/tank[0]/level-gal_us", true );
34 _fuel_r = fgGetNode( "/consumables/fuel/tank[1]/level-gal_us", true );
35 _oil_px = fgGetNode( "/engines/engine[0]/oil-pressure-psi", true );
37 _ann_volts = fgGetNode( "/instrumentation/annunciator/volts", true );
38 _ann_vac_l = fgGetNode( "/instrumentation/annunciator/vacuum-left", true );
39 _ann_vac_r = fgGetNode( "/instrumentation/annunciator/vacuum-right", true );
40 _ann_fuel_l = fgGetNode( "/instrumentation/annunciator/fuel-left", true );
41 _ann_fuel_r = fgGetNode( "/instrumentation/annunciator/fuel-right", true );
42 _ann_oil_px = fgGetNode( "/instrumentation/annunciator/oil-pressure", true );
46 Annunciator::update (double dt)
55 if ( _volts->getDoubleValue() < 5.0 ) {
56 // Not enough juice to illuminate the display
57 _ann_volts->setBoolValue( false );
58 _ann_vac_l->setBoolValue( false );
59 _ann_vac_r->setBoolValue( false );
60 _ann_fuel_l->setBoolValue( false );
61 _ann_fuel_r->setBoolValue( false );
62 _ann_oil_px->setBoolValue( false );
65 if ( _volts->getDoubleValue() < 24.5 ) {
67 double rem = timer0 - (int)timer0;
69 _ann_volts->setBoolValue( true );
71 _ann_volts->setBoolValue( false );
74 _ann_volts->setBoolValue( true );
77 _ann_volts->setBoolValue( false );
81 if ( _fuel_l->getDoubleValue() < 5.0
82 && _fuel_r->getDoubleValue() < 5.0 )
85 double rem = timer0 - (int)timer0;
87 _ann_fuel_l->setBoolValue( true );
88 _ann_fuel_r->setBoolValue( true );
90 _ann_fuel_l->setBoolValue( false );
91 _ann_fuel_r->setBoolValue( false );
94 _ann_fuel_l->setBoolValue( true );
95 _ann_fuel_r->setBoolValue( true );
97 } else if ( _fuel_l->getDoubleValue() < 5.0 ) {
99 double rem = timer0 - (int)timer0;
101 _ann_fuel_l->setBoolValue( true );
103 _ann_fuel_l->setBoolValue( false );
106 _ann_fuel_l->setBoolValue( true );
108 _ann_fuel_r->setBoolValue( false );
109 } else if ( _fuel_r->getDoubleValue() < 5.0 ) {
111 double rem = timer0 - (int)timer0;
113 _ann_fuel_r->setBoolValue( true );
115 _ann_fuel_r->setBoolValue( false );
118 _ann_fuel_r->setBoolValue( true );
120 _ann_fuel_l->setBoolValue( false );
122 _ann_fuel_l->setBoolValue( false );
123 _ann_fuel_r->setBoolValue( false );
128 if ( _vac_l->getDoubleValue() < 3.0
129 && _vac_r->getDoubleValue() < 3.0 )
132 double rem = timer0 - (int)timer0;
134 _ann_vac_l->setBoolValue( true );
135 _ann_vac_r->setBoolValue( true );
137 _ann_vac_l->setBoolValue( false );
138 _ann_vac_r->setBoolValue( false );
141 _ann_vac_l->setBoolValue( true );
142 _ann_vac_r->setBoolValue( true );
144 } else if ( _vac_l->getDoubleValue() < 3.0 ) {
146 double rem = timer0 - (int)timer0;
148 _ann_vac_l->setBoolValue( true );
150 _ann_vac_l->setBoolValue( false );
153 _ann_vac_l->setBoolValue( true );
155 _ann_vac_r->setBoolValue( false );
156 } else if ( _vac_r->getDoubleValue() < 3.0 ) {
158 double rem = timer0 - (int)timer0;
160 _ann_vac_r->setBoolValue( true );
162 _ann_vac_r->setBoolValue( false );
165 _ann_vac_r->setBoolValue( true );
167 _ann_vac_l->setBoolValue( false );
169 _ann_vac_l->setBoolValue( false );
170 _ann_vac_r->setBoolValue( false );
175 if ( _oil_px->getDoubleValue() < 20.0 ) {
177 double rem = timer0 - (int)timer0;
179 _ann_oil_px->setBoolValue( true );
181 _ann_oil_px->setBoolValue( false );
184 _ann_oil_px->setBoolValue( true );
187 _ann_oil_px->setBoolValue( false );
194 // end of annunciator.cxx