A350-family/Systems/Electrical/output.nas
fly 2c15b8362f Initial commit
Signed-off-by: fly <merspieler@airmail.cc>
2020-07-19 00:49:38 +10:00

40 lines
967 B
Text

## Electrical Outputs
var output = {
name: "",
min_volt: "",
run_amps: 0,
bus: [],
serviceableVolts: 0,
serviceable: func() {
var serviceable = 0;
foreach(var out_bus; me.bus) {
foreach(var bus; buses) {
if (out_bus == bus.name) {
if ((bus.get_volts() >= me.min_volt) and (bus.get_amps() >= me.run_amps)) {
serviceable = 1;
if (me.serviceableVolts < bus.get_volts())
{
me.serviceableVolts = bus.get_volts();
}
}
}
}
}
if (serviceable == 1) {
setprop("/systems/electric/outputs/" ~ me.name, 1);
setprop("/systems/electrical/outputs/" ~ me.name, me.serviceableVolts);
} else {
setprop("/systems/electric/outputs/" ~ me.name, 0);
setprop("/systems/electrical/outputs/" ~ me.name, me.serviceableVolts);
}
},
new: func(name, min_volt, run_amps, bus) {
var t = {parents:[output]};
t.name = name;
t.min_volt = min_volt;
t.run_amps = run_amps;
t.bus = bus;
return t;
}
};