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

39 lines
747 B
Text

## Electrical Bus
var bus = {
name: "",
type: "",
suppliers: [],
get_volts: func() {
var volts = 0;
foreach(var bus_supplier; me.suppliers) {
foreach(var supplier; suppliers) {
if (bus_supplier == supplier.name) {
if(supplier.supply() != 0) {
if (supplier.volts > volts) {
volts = supplier.volts;
}
}
}
}
}
return volts;
},
get_amps: func() {
var amps = 0;
foreach(var bus_supplier; me.suppliers) {
foreach(var supplier; suppliers) {
if (bus_supplier == supplier.name) {
amps += supplier.supply();
}
}
}
return amps;
},
new: func(name, type, suppliers) {
var t = {parents:[bus]};
t.name = name;
t.type = type;
t.suppliers = suppliers;
return t;
}
};