Lights loop to JSBSIM
This commit is contained in:
parent
a61de8e6e9
commit
81e501ea88
4 changed files with 170 additions and 150 deletions
|
@ -89,6 +89,7 @@
|
|||
</iceable>
|
||||
</icing>
|
||||
<lights>
|
||||
<dome-light type="double">0</dome-light>
|
||||
<nose-lights type="double">0</nose-lights>
|
||||
</lights>
|
||||
</model>
|
||||
|
|
|
@ -29,29 +29,6 @@ var beacon = aircraft.light.new("/sim/model/lights/beacon", [0.1, 1], "/controls
|
|||
var strobe = aircraft.light.new("/sim/model/lights/strobe", [0.05, 0.06, 0.05, 1], "/controls/lighting/strobe");
|
||||
var tail_strobe = aircraft.light.new("/sim/model/lights/tailstrobe", [0.1, 1], "/controls/lighting/strobe");
|
||||
|
||||
var beacon_switch = props.globals.getNode("controls/switches/beacon", 1);
|
||||
var beacon_ctl = props.globals.getNode("controls/lighting/beacon", 1);
|
||||
var strobe_switch = props.globals.getNode("controls/switches/strobe", 1);
|
||||
var strobe_light = props.globals.getNode("controls/lighting/strobe", 1);
|
||||
var logo_lights = getprop("/sim/model/lights/logo-lights");
|
||||
var nav_lights = props.globals.getNode("sim/model/lights/nav-lights");
|
||||
var wing_switch = props.globals.getNode("controls/switches/wing-lights", 1);
|
||||
var wing_ctl = props.globals.getNode("controls/lighting/wing-lights", 1);
|
||||
var dome_light = props.globals.initNode("/sim/model/lights/dome-light", 0.0, "DOUBLE");
|
||||
var wow = getprop("/gear/gear[2]/wow");
|
||||
var slats = getprop("/controls/flight/slats");
|
||||
var gear = getprop("/gear/gear[0]/position-norm");
|
||||
var nose_lights = getprop("/sim/model/lights/nose-lights");
|
||||
var left_turnoff_light = props.globals.getNode("controls/lighting/leftturnoff");
|
||||
var right_turnoff_light = props.globals.getNode("controls/lighting/rightturnoff");
|
||||
var settingT = getprop("/controls/lighting/taxi-light-switch");
|
||||
var settingTurnoff = getprop("/controls/lighting/turnoff-light-switch");
|
||||
var setting = getprop("/controls/lighting/nav-lights-switch");
|
||||
var domeSetting = getprop("/controls/lighting/dome-norm");
|
||||
var landL = props.globals.getNode("controls/lighting/landing-lights[1]", 1);
|
||||
var landR = props.globals.getNode("controls/lighting/landing-lights[2]", 1);
|
||||
var landlSw = props.globals.getNode("controls/switches/landing-lights-l", 1);
|
||||
var landrSw = props.globals.getNode("controls/switches/landing-lights-r", 1);
|
||||
var stateL = 0;
|
||||
var stateR = 0;
|
||||
|
||||
|
@ -466,119 +443,6 @@ setlistener("/controls/flight/elevator-trim", func {
|
|||
##########
|
||||
|
||||
var lightsLoop = maketimer(0.2, func {
|
||||
gear = getprop("/gear/gear[0]/position-norm");
|
||||
nose_lights = getprop("/sim/model/lights/nose-lights");
|
||||
settingT = getprop("/controls/lighting/taxi-light-switch");
|
||||
domeSetting = getprop("/controls/lighting/dome-norm");
|
||||
|
||||
# nose lights
|
||||
|
||||
if (settingT == 0.5 and gear > 0.9 and (getprop("/systems/electrical/bus/ac-1") > 0 or getprop("/systems/electrical/bus/ac-2") > 0)) {
|
||||
setprop("/sim/model/lights/nose-lights", 0.85);
|
||||
} else if (settingT == 1 and gear > 0.9 and (getprop("/systems/electrical/bus/ac-1") > 0 or getprop("/systems/electrical/bus/ac-2") > 0)) {
|
||||
setprop("/sim/model/lights/nose-lights", 1);
|
||||
} else {
|
||||
setprop("/sim/model/lights/nose-lights", 0);
|
||||
}
|
||||
|
||||
# turnoff lights
|
||||
settingTurnoff = getprop("/controls/lighting/turnoff-light-switch");
|
||||
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 and getprop("/systems/electrical/bus/ac-1") > 0) {
|
||||
left_turnoff_light.setBoolValue(1);
|
||||
} else {
|
||||
left_turnoff_light.setBoolValue(0);
|
||||
}
|
||||
|
||||
if (settingTurnoff == 1 and gear > 0.9 and getprop("/systems/electrical/bus/ac-2") > 0) {
|
||||
right_turnoff_light.setBoolValue(1);
|
||||
} else {
|
||||
right_turnoff_light.setBoolValue(0);
|
||||
}
|
||||
|
||||
# logo and navigation lights
|
||||
setting = getprop("/controls/lighting/nav-lights-switch");
|
||||
nav_lights = props.globals.getNode("sim/model/lights/nav-lights");
|
||||
logo_lights = props.globals.getNode("sim/model/lights/logo-lights");
|
||||
wow = getprop("/gear/gear[2]/wow");
|
||||
slats = getprop("/controls/flight/slats");
|
||||
|
||||
if (getprop("/systems/electrical/bus/ac-1") > 0 or getprop("/systems/electrical/bus/ac-2") > 0 or getprop("/systems/electrical/bus/dc-1") > 0 or getprop("/systems/electrical/bus/dc-2") > 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 and (getprop("/systems/electrical/bus/ac-1") > 0 or getprop("/systems/electrical/bus/ac-2") > 0)) {
|
||||
if ((wow) or (!wow and slats > 0)) {
|
||||
logo_lights.setBoolValue(1);
|
||||
} else {
|
||||
logo_lights.setBoolValue(0);
|
||||
}
|
||||
} else {
|
||||
logo_lights.setBoolValue(0);
|
||||
}
|
||||
|
||||
if (setting == 1 or setting == 2 and (getprop("/systems/electrical/bus/ac-1") > 0 or getprop("/systems/electrical/bus/ac-2") > 0 or getprop("/systems/electrical/bus/dc-1") > 0 or getprop("/systems/electrical/bus/dc-2") > 0)) {
|
||||
nav_lights.setBoolValue(1);
|
||||
} else {
|
||||
nav_lights.setBoolValue(0);
|
||||
}
|
||||
|
||||
if (domeSetting == 0.5 and getprop("/systems/electrical/bus/dc-ess") > 0) {
|
||||
dome_light.setValue(0.5);
|
||||
} elsif (domeSetting == 1 and getprop("/systems/electrical/bus/dc-ess") > 0) {
|
||||
dome_light.setValue(1);
|
||||
} else {
|
||||
dome_light.setValue(0);
|
||||
}
|
||||
|
||||
# strobe
|
||||
strobe_sw = strobe_switch.getValue();
|
||||
|
||||
if (strobe_sw == 1 and getprop("/systems/electrical/bus/ac-2") > 0) {
|
||||
strobe_light.setValue(1);
|
||||
} elsif (strobe_sw == 0.5 and getprop("/gear/gear[1]/wow") == 0 and getprop("/gear/gear[2]/wow") == 0 and getprop("/systems/electrical/bus/ac-2") > 0) {
|
||||
# todo: use lgciu output 5
|
||||
strobe_light.setValue(1);
|
||||
} else {
|
||||
strobe_light.setValue(0);
|
||||
}
|
||||
|
||||
# beacon
|
||||
|
||||
if (beacon_switch.getValue() == 1 and (getprop("/systems/electrical/bus/ac-1") > 0 or getprop("/systems/electrical/bus/ac-2") > 0)) {
|
||||
beacon_ctl.setValue(1);
|
||||
} else {
|
||||
beacon_ctl.setValue(0);
|
||||
}
|
||||
|
||||
# wing
|
||||
|
||||
if (wing_switch.getValue() == 1 and (getprop("/systems/electrical/bus/ac-1") > 0 or getprop("/systems/electrical/bus/ac-2") > 0)) {
|
||||
wing_ctl.setValue(1);
|
||||
} else {
|
||||
wing_ctl.setValue(0);
|
||||
}
|
||||
|
||||
# landL
|
||||
|
||||
if (landlSw.getValue() == 1 and getprop("/systems/electrical/bus/ac-1") > 0) {
|
||||
landL.setValue(1);
|
||||
} else {
|
||||
landL.setValue(0);
|
||||
}
|
||||
|
||||
if (landrSw.getValue() == 1 and getprop("/systems/electrical/bus/ac-2") > 0) {
|
||||
landR.setValue(1);
|
||||
} else {
|
||||
landR.setValue(0);
|
||||
}
|
||||
|
||||
# signs
|
||||
|
||||
if (getprop("/systems/pressurization/cabinalt-norm") > 11300) {
|
||||
|
@ -607,18 +471,6 @@ var lightsLoop = maketimer(0.2, func {
|
|||
setprop("/controls/lighting/no-smoking-sign", 0); # sign stays on in cabin but sound still occurs
|
||||
}
|
||||
}
|
||||
|
||||
if (getprop("/controls/lighting/landing-lights[1]") >= 0.5) {
|
||||
setprop("/fdm/jsbsim/rubbish/landL", 1);
|
||||
} else {
|
||||
setprop("/fdm/jsbsim/rubbish/landL", 0);
|
||||
}
|
||||
|
||||
if (getprop("/controls/lighting/landing-lights[2]") >= 0.5) {
|
||||
setprop("/fdm/jsbsim/rubbish/landR", 1);
|
||||
} else {
|
||||
setprop("/fdm/jsbsim/rubbish/landR", 0);
|
||||
}
|
||||
});
|
||||
|
||||
var pilotComfortTwoPos = func(prop) {
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
|
||||
<property value="0.0">ice/wingL</property>
|
||||
<property value="0.0">ice/wingR</property>
|
||||
<property value="0">rubbish/landL</property>
|
||||
<property value="0">rubbish/landR</property>
|
||||
|
||||
<axis name="LIFT">
|
||||
|
||||
|
|
|
@ -54,6 +54,175 @@
|
|||
/systems/electrical/bus/dc-2 gt 25
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
<switch name="/sim/model/lights/dome-light">
|
||||
<default value="0" />
|
||||
<test logic="AND" value="0.5">
|
||||
/controls/lighting/dome-norm eq 0.5
|
||||
/systems/electrical/bus/dc-ess ge 25
|
||||
</test>
|
||||
<test logic="AND" value="1.0">
|
||||
/controls/lighting/dome-norm eq 1.0
|
||||
/systems/electrical/bus/dc-ess ge 25
|
||||
</test>
|
||||
</switch>
|
||||
</channel>
|
||||
|
||||
<channel name="Exterior Lights">
|
||||
|
||||
<switch name="/sim/model/lights/nose-lights">
|
||||
<default value="0"/>
|
||||
<test logic="AND" value="1">
|
||||
/controls/lighting/taxi-light-switch eq 1
|
||||
/gear/gear[0]/position-norm gt 0.8
|
||||
<test logic="OR">
|
||||
/systems/electrical/bus/ac-1 ge 110
|
||||
/systems/electrical/bus/ac-2 ge 110
|
||||
</test>
|
||||
</test>
|
||||
<test logic="AND" value="0.85">
|
||||
/controls/lighting/taxi-light-switch eq 0.5
|
||||
/gear/gear[0]/position-norm gt 0.8
|
||||
<test logic="OR">
|
||||
/systems/electrical/bus/ac-1 ge 110
|
||||
/systems/electrical/bus/ac-2 ge 110
|
||||
</test>
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
<switch name="controls/lighting/leftturnoff">
|
||||
<default value="0"/>
|
||||
<test logic="AND" value="1">
|
||||
/controls/lighting/turnoff-light-switch eq 1
|
||||
/gear/gear[0]/position-norm gt 0.8
|
||||
/systems/electrical/bus/ac-1 ge 110
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
<switch name="/controls/lighting/rightturnoff">
|
||||
<default value="0"/>
|
||||
<test logic="AND" value="1">
|
||||
/controls/lighting/turnoff-light-switch eq 1
|
||||
/gear/gear[0]/position-norm gt 0.8
|
||||
/systems/electrical/bus/ac-2 ge 110
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
<switch name="/controls/lighting/rightturnoff">
|
||||
<default value="0"/>
|
||||
<test logic="AND" value="1">
|
||||
/controls/lighting/turnoff-light-switch eq 1
|
||||
/gear/gear[0]/position-norm gt 0.8
|
||||
/systems/electrical/bus/ac-2 ge 110
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
<switch name="/systems/electrical/nav-lights-power">
|
||||
<default value="0"/>
|
||||
<test logic="OR" value="1">
|
||||
/systems/electrical/bus/dc-1 ge 25
|
||||
/systems/electrical/bus/dc-2 ge 25
|
||||
/systems/electrical/bus/ac-1 ge 110
|
||||
/systems/electrical/bus/ac-2 ge 110
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
<switch name="/sim/model/lights/logo-lights">
|
||||
<default value="0"/>
|
||||
<test logic="AND" value="1">
|
||||
<test logic="OR">
|
||||
/controls/lighting/nav-lights-switch eq 1
|
||||
/controls/lighting/nav-lights-switch eq 2
|
||||
</test>
|
||||
<test logic="OR">
|
||||
/systems/electrical/bus/ac-1 ge 110
|
||||
/systems/electrical/bus/ac-2 ge 110
|
||||
</test>
|
||||
<test logic="OR">
|
||||
/controls/flight/slats ge 0
|
||||
/gear/gear[2]/wow eq 1
|
||||
</test>
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
<switch name="/sim/model/lights/nav-lights">
|
||||
<default value="0"/>
|
||||
<test logic="AND" value="1">
|
||||
<test logic="OR">
|
||||
/controls/lighting/nav-lights-switch eq 1
|
||||
/controls/lighting/nav-lights-switch eq 2
|
||||
</test>
|
||||
/systems/electrical/nav-lights-power eq 1
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
<switch name="/controls/lighting/strobe">
|
||||
<default value="0"/>
|
||||
<test logic="AND" value="1">
|
||||
/controls/switches/strobe eq 1
|
||||
/systems/electrical/bus/ac-2 ge 110
|
||||
</test>
|
||||
<test logic="AND" value="1">
|
||||
/controls/switches/strobe eq 0.5
|
||||
/systems/electrical/bus/ac-2 ge 110
|
||||
/gear/gear[1]/wow eq 0
|
||||
/gear/gear[2]/wow eq 0
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
<switch name="/controls/lighting/beacon">
|
||||
<default value="0"/>
|
||||
<test logic="AND" value="1">
|
||||
/controls/switches/beacon eq 1
|
||||
<test logic="OR">
|
||||
/systems/electrical/bus/ac-1 ge 110
|
||||
/systems/electrical/bus/ac-2 ge 110
|
||||
</test>
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
<switch name="/controls/lighting/wing-lights">
|
||||
<default value="0"/>
|
||||
<test logic="AND" value="1">
|
||||
/controls/switches/wing-lights eq 1
|
||||
<test logic="OR">
|
||||
/systems/electrical/bus/ac-1 ge 110
|
||||
/systems/electrical/bus/ac-2 ge 110
|
||||
</test>
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
<switch name="/controls/lighting/landing-lights[1]">
|
||||
<default value="0"/>
|
||||
<test logic="AND" value="1">
|
||||
/controls/switches/landing-lights-l eq 1
|
||||
/systems/electrical/bus/ac-1 ge 110
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
<switch name="/controls/lighting/landing-lights[2]">
|
||||
<default value="0"/>
|
||||
<test logic="AND" value="1">
|
||||
/controls/switches/landing-lights-r eq 1
|
||||
/systems/electrical/bus/ac-2 ge 110
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
|
||||
<switch name="/fdm/jsbsim/rubbish/landL">
|
||||
<default value="0"/>
|
||||
<test logic="AND" value="1">
|
||||
/controls/lighting/landing-lights[1] ge 0.5
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
<switch name="/fdm/jsbsim/rubbish/landR">
|
||||
<default value="0"/>
|
||||
<test logic="AND" value="1">
|
||||
/controls/lighting/landing-lights[2] ge 0.5
|
||||
</test>
|
||||
</switch>
|
||||
|
||||
</channel>
|
||||
|
||||
</system>
|
||||
|
|
Loading…
Add table
Reference in a new issue