2007-01-29 22:24:05 +00:00
|
|
|
var VOLTS_THRESHOLD = 24.5;
|
|
|
|
var FUEL_THRESHOLD = 5.0;
|
|
|
|
var VACUUM_THRESHOLD = 3.0;
|
|
|
|
var OIL_PRESSURE_THRESHOLD = 20.0;
|
|
|
|
|
|
|
|
|
2007-10-01 22:31:30 +00:00
|
|
|
var ann = {
|
2007-01-29 22:24:05 +00:00
|
|
|
new : func(p) {
|
|
|
|
var m = { parents : [ann] };
|
2008-11-20 20:00:26 +00:00
|
|
|
m.node = props.globals.initNode(p, 0, "BOOL");
|
2007-01-29 22:24:05 +00:00
|
|
|
m.stamp = nil;
|
|
|
|
m.state = 0;
|
|
|
|
return m;
|
|
|
|
},
|
|
|
|
switch : func(v) {
|
|
|
|
if (v) {
|
|
|
|
if (!me.state) {
|
|
|
|
me.stamp = sec + 10;
|
|
|
|
me.state = 1;
|
|
|
|
}
|
2008-06-04 20:52:09 +00:00
|
|
|
me.node.setBoolValue(sec < me.stamp ? clock : 1);
|
|
|
|
|
2007-01-29 22:24:05 +00:00
|
|
|
} else {
|
2008-06-04 20:52:09 +00:00
|
|
|
if (me.state)
|
|
|
|
me.node.setBoolValue(me.state = 0);
|
2007-01-29 22:24:05 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-11-20 20:00:26 +00:00
|
|
|
var volts = props.globals.initNode("/systems/electrical/volts");
|
|
|
|
var vac_l = props.globals.initNode("/systems/vacuum[0]/suction-inhg");
|
|
|
|
var vac_r = props.globals.initNode("/systems/vacuum[1]/suction-inhg");
|
|
|
|
var fuel_l = props.globals.initNode("/consumables/fuel/tank[0]/level-gal_us");
|
|
|
|
var fuel_r = props.globals.initNode("/consumables/fuel/tank[1]/level-gal_us");
|
|
|
|
var oil_px = props.globals.initNode("/engines/engine[0]/oil-pressure-psi");
|
|
|
|
var elapsed = props.globals.initNode("/sim/time/elapsed-sec");
|
2007-01-29 22:24:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
var ann_volts = ann.new("/instrumentation/annunciator/volts");
|
|
|
|
var ann_vac_l = ann.new("/instrumentation/annunciator/vacuum-left");
|
|
|
|
var ann_vac_r = ann.new("/instrumentation/annunciator/vacuum-right");
|
|
|
|
var ann_fuel_l = ann.new("/instrumentation/annunciator/fuel-left");
|
|
|
|
var ann_fuel_r = ann.new("/instrumentation/annunciator/fuel-right");
|
|
|
|
var ann_oil_px = ann.new("/instrumentation/annunciator/oil-pressure");
|
|
|
|
|
|
|
|
|
|
|
|
var clock = 0;
|
|
|
|
var sec = nil;
|
|
|
|
|
2007-10-01 22:31:30 +00:00
|
|
|
var main = func {
|
2007-01-29 22:24:05 +00:00
|
|
|
clock = !clock;
|
|
|
|
sec = elapsed.getValue();
|
|
|
|
|
|
|
|
var v = volts.getValue();
|
|
|
|
if (v < 5.0 or !serviceable) {
|
|
|
|
ann_volts.switch(0);
|
|
|
|
ann_vac_l.switch(0);
|
|
|
|
ann_vac_r.switch(0);
|
|
|
|
ann_fuel_l.switch(0);
|
|
|
|
ann_fuel_r.switch(0);
|
|
|
|
ann_oil_px.switch(0);
|
|
|
|
} else {
|
|
|
|
ann_volts.switch(v < VOLTS_THRESHOLD);
|
|
|
|
ann_fuel_l.switch(fuel_l.getValue() < FUEL_THRESHOLD);
|
|
|
|
ann_fuel_r.switch(fuel_r.getValue() < FUEL_THRESHOLD);
|
|
|
|
ann_vac_l.switch(vac_l.getValue() < VACUUM_THRESHOLD);
|
|
|
|
ann_vac_r.switch(vac_r.getValue() < VACUUM_THRESHOLD);
|
|
|
|
ann_oil_px.switch(oil_px.getValue() < OIL_PRESSURE_THRESHOLD);
|
|
|
|
}
|
|
|
|
settimer(main, 0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var serviceable = nil;
|
|
|
|
|
|
|
|
settimer(func {
|
2008-06-04 20:52:09 +00:00
|
|
|
setlistener("/systems/electrical/serviceable", func(n) serviceable = n.getBoolValue(), 1);
|
2007-01-29 22:24:05 +00:00
|
|
|
main();
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
|