disable nav, logo, turnoff, and taxi when there is no power to the respective buses. Make all exterior lighting consume power

This commit is contained in:
Jonathan Redpath 2017-12-11 16:23:11 -04:00
parent fe82a2bcef
commit e92ba6e14c
2 changed files with 86 additions and 14 deletions

View file

@ -16,6 +16,9 @@ var ac2_src = "XX";
var power_consumption = nil;
var screen_power_consumption = nil;
var screens = nil;
var lpower_consumption = nil;
var light_power_consumption = nil;
var lights = nil;
setlistener("/sim/signals/fdm-initialized", func {
var galley_sw = getprop("/controls/electrical/switches/galley");
@ -98,11 +101,41 @@ var screen = {
}
};
# Power Consumption, lights
# from docs found on google
var light = {
name: "",
max_watts: 0,
control_prop: "",
elec_prop: "",
power_consumption: func() {
if (getprop(me.control_prop) != 0 and getprop(me.elec_prop) != 0) {
light_power_consumption = me.max_watts;
} else {
light_power_consumption = 0;
}
return light_power_consumption;
},
new: func(name,max_watts,control_prop,elec_prop) {
var l = {parents:[light]};
l.name = name;
l.max_watts = max_watts;
l.control_prop = control_prop;
l.elec_prop = elec_prop;
return l;
}
};
# Main Elec System
var ELEC = {
init: func() {
setprop("/controls/switches/annun-test", 0);
setprop("/systems/electrical/nav-lights-power", 0);
setprop("/controls/electrical/switches/galley", 1);
setprop("/controls/electrical/switches/idg1", 0);
setprop("/controls/electrical/switches/idg2", 0);
@ -188,11 +221,31 @@ var ELEC = {
setprop("/systems/electrical/outputs/turn-coordinator", 0);
screens = [screen.new(name: "DU1", type:"LCD", max_watts:60, dim_watts:50, dim_prop:"controls/lighting/DU/du1", elec_prop:"systems/electrical/bus/ac-ess"),
screen.new(name: "DU2", type:"LCD", max_watts:60, dim_watts:50, dim_prop:"controls/lighting/DU/du2", elec_prop:"systems/electrical/bus/ac-ess"),
screen.new(name: "DU2", type:"LCD", max_watts:60, dim_watts:50, dim_prop:"controls/lighting/DU/du2", elec_prop:"systems/electrical/bus/ac-ess-shed"),
screen.new(name: "DU3", type:"LCD", max_watts:60, dim_watts:50, dim_prop:"controls/lighting/DU/du3", elec_prop:"systems/electrical/bus/ac-ess"),
screen.new(name: "DU4", type:"LCD", max_watts:60, dim_watts:50, dim_prop:"controls/lighting/DU/du4", elec_prop:"systems/electrical/bus/ac-ess"),
screen.new(name: "DU5", type:"LCD", max_watts:60, dim_watts:50, dim_prop:"controls/lighting/DU/du5", elec_prop:"systems/electrical/bus/ac-ess"),
screen.new(name: "DU6", type:"LCD", max_watts:60, dim_watts:50, dim_prop:"controls/lighting/DU/du6", elec_prop:"systems/electrical/bus/ac-ess")];
screen.new(name: "DU4", type:"LCD", max_watts:60, dim_watts:50, dim_prop:"controls/lighting/DU/du4", elec_prop:"systems/electrical/bus/ac2"),
screen.new(name: "DU5", type:"LCD", max_watts:60, dim_watts:50, dim_prop:"controls/lighting/DU/du5", elec_prop:"systems/electrical/bus/ac2"),
screen.new(name: "DU6", type:"LCD", max_watts:60, dim_watts:50, dim_prop:"controls/lighting/DU/du6", elec_prop:"systems/electrical/bus/ac2")];
lights = [light.new(name: "logo-left", max_watts:31.5, control_prop:"sim/model/lights/logo-lights", elec_prop:"systems/electrical/bus/ac1"),
light.new(name: "logo-right", max_watts:31.5, control_prop:"sim/model/lights/logo-lights", elec_prop:"systems/electrical/bus/ac2"),
light.new(name: "upper-beacon", max_watts:40, control_prop:"sim/model/lights/beacon/state", elec_prop:"systems/electrical/bus/ac1"),
light.new(name: "lower-beacon", max_watts:40, control_prop:"sim/model/lights/beacon/state", elec_prop:"systems/electrical/bus/ac2"),
light.new(name: "strobe-left", max_watts:38, control_prop:"sim/model/lights/strobe/state", elec_prop:"systems/electrical/bus/ac2"),
light.new(name: "strobe-right", max_watts:38, control_prop:"sim/model/lights/strobe/state", elec_prop:"systems/electrical/bus/ac2"),
light.new(name: "tail-strobe", max_watts:12, control_prop:"sim/model/lights/tailstrobe/state", elec_prop:"systems/electrical/bus/ac2"),
light.new(name: "tail-strobe-ctl", max_watts:30, control_prop:"sim/model/lights/tailstrobe/state", elec_prop:"systems/electrical/bus/ac2"),
light.new(name: "tail-nav", max_watts:12, control_prop:"sim/model/lights/nav-lights", elec_prop:"systems/electrical/nav-lights-power"),
light.new(name: "left-nav", max_watts:12, control_prop:"sim/model/lights/nav-lights", elec_prop:"systems/electrical/nav-lights-power"),
light.new(name: "right-nav", max_watts:12, control_prop:"sim/model/lights/nav-lights", elec_prop:"systems/electrical/nav-lights-power"),
light.new(name: "left-land", max_watts:39, control_prop:"controls/lighting/landing-lights[1]", elec_prop:"systems/electrical/bus/ac1"),
light.new(name: "right-land", max_watts:39, control_prop:"controls/lighting/landing-lights[2]", elec_prop:"systems/electrical/bus/ac2"),
light.new(name: "left-taxi", max_watts:31, control_prop:"sim/model/lights/nose-lights", elec_prop:"systems/electrical/bus/ac1"),
light.new(name: "right-taxi", max_watts:31, control_prop:"sim/model/lights/nose-lights", elec_prop:"systems/electrical/bus/ac2"),
light.new(name: "left-turnoff", max_watts:21, control_prop:"controls/lighting/leftturnoff", elec_prop:"systems/electrical/bus/ac1"),
light.new(name: "right-turnoff", max_watts:21, control_prop:"controls/lighting/rightturnoff", elec_prop:"systems/electrical/bus/ac2"),
light.new(name: "left-wing", max_watts:24, control_prop:"controls/lighting/wing-lights", elec_prop:"systems/electrical/bus/ac1"),
light.new(name: "right-wing", max_watts:24, control_prop:"controls/lighting/wing-lights", elec_prop:"systems/electrical/bus/ac2")];
},
loop: func() {
@ -633,9 +686,18 @@ var ELEC = {
foreach(var screena; screens) {
power_consumption = screena.power_consumption();
if (getprop(screena.elec_prop) != 0) {
setprop("/systems/electrical/DU/" ~ screena.name ~ "/watts",power_consumption);
setprop("/systems/electrical/DU/" ~ screena.name ~ "/watts", power_consumption);
} else {
setprop("/systems/electrical/DU/" ~ screena.name ~ "/watts",0);
setprop("/systems/electrical/DU/" ~ screena.name ~ "/watts", 0);
}
}
foreach(var lighta; lights) {
power_consumption = lighta.power_consumption();
if (getprop(screena.elec_prop) != 0 and getprop(lighta.control_prop) != 0) {
setprop("/systems/electrical/light/" ~ lighta.name ~ "/watts", power_consumption);
} else {
setprop("/systems/electrical/light/" ~ lighta.name ~ "/watts", 0);
}
}
},

View file

@ -34,11 +34,11 @@ setprop("/engines/engine[1]/oil-qt-actual", qty2);
# Lights #
##########
var beacon_switch = props.globals.getNode("/controls/switches/beacon", 2);
var beacon = aircraft.light.new("/sim/model/lights/beacon", [0.16, 1], "/controls/lighting/beacon");
var beacon = aircraft.light.new("/sim/model/lights/beacon", [0.1, 1], "/controls/lighting/beacon");
var strobe_switch = props.globals.getNode("/controls/switches/strobe", 2);
var strobe = aircraft.light.new("/sim/model/lights/strobe", [0.05, 0.06, 0.05, 1], "/controls/lighting/strobe");
var tail_strobe_switch = props.globals.getNode("/controls/switches/tailstrobe", 2);
var tail_strobe = aircraft.light.new("/sim/model/lights/tailstrobe", [0.11, 1], "/controls/lighting/strobe");
var tail_strobe = aircraft.light.new("/sim/model/lights/tailstrobe", [0.1, 1], "/controls/lighting/strobe");
var logo_lights = getprop("/sim/model/lights/logo-lights");
var nav_lights = props.globals.getNode("/sim/model/lights/nav-lights");
var wow = getprop("/gear/gear[2]/wow");
@ -365,9 +365,9 @@ var lightsLoop = maketimer(0.2, func {
# nose lights
if (settingT == 0.5 and gear > 0.9) {
if (settingT == 0.5 and gear > 0.9 and (getprop("/systems/electrical/bus/ac1") > 0 or getprop("/systems/electrical/bus/ac2") > 0)) {
setprop("/sim/model/lights/nose-lights", 0.85);
} else if (settingT == 1 and gear > 0.9) {
} else if (settingT == 1 and gear > 0.9 and (getprop("/systems/electrical/bus/ac1") > 0 or getprop("/systems/electrical/bus/ac2") > 0)) {
setprop("/sim/model/lights/nose-lights", 1);
} else {
setprop("/sim/model/lights/nose-lights", 0);
@ -378,11 +378,15 @@ var lightsLoop = maketimer(0.2, func {
left_turnoff_light = props.globals.getNode("/controls/lighting/leftturnoff");
right_turnoff_light = props.globals.getNode("/controls/lighting/rightturnoff");
if (settingTurnoff == 1 and gear > 0.9) {
if (settingTurnoff == 1 and gear > 0.9 and getprop("/systems/electrical/bus/ac1") > 0) {
left_turnoff_light.setBoolValue(1);
right_turnoff_light.setBoolValue(1);
} else {
left_turnoff_light.setBoolValue(0);
}
if (settingTurnoff == 1 and gear > 0.9 and getprop("/systems/electrical/bus/ac2") > 0) {
right_turnoff_light.setBoolValue(1);
} else {
right_turnoff_light.setBoolValue(0);
}
@ -393,9 +397,15 @@ var lightsLoop = maketimer(0.2, func {
wow = getprop("/gear/gear[2]/wow");
slats = getprop("/controls/flight/slats");
if (getprop("/systems/electrical/bus/ac1") > 0 or getprop("/systems/electrical/bus/ac2") > 0) {
setprop("/systems/electrical/nav-lights-power", 1);
} else {
setprop("/systems/electrical/nav-lights-power", 0);
}
if (setting == 0 and logo_lights == 1) {
logo_lights.setBoolValue(0);
} else if (setting == 1 or setting == 2) {
} else if (setting == 1 or setting == 2 and (getprop("/systems/electrical/bus/ac1") > 0 or getprop("/systems/electrical/bus/ac2") > 0)) {
if ((wow) or (!wow and slats > 0)) {
logo_lights.setBoolValue(1);
} else {
@ -405,7 +415,7 @@ var lightsLoop = maketimer(0.2, func {
logo_lights.setBoolValue(0);
}
if (setting == 1 or setting == 2) {
if (setting == 1 or setting == 2 and (getprop("/systems/electrical/bus/ac1") > 0 or getprop("/systems/electrical/bus/ac2") > 0 or getprop("/systems/electrical/bus/dc1") > 0 or getprop("/systems/electrical/bus/dc2") > 0)) {
nav_lights.setBoolValue(1);
} else {
nav_lights.setBoolValue(0);