1
0
Fork 0

No smoking light / seatbelt light - correct CIDS power source; move to JSB

This commit is contained in:
Jonathan Redpath 2022-01-02 17:24:59 +00:00
parent e394db0cd9
commit b85863cf06
7 changed files with 102 additions and 86 deletions

View file

@ -391,9 +391,9 @@ var beforestart_b = func {
setprop("/controls/adirs/mcducbtn", 1);
setprop("/controls/switches/beacon", 1);
setprop("/controls/lighting/nav-lights-switch", 1);
libraries.noSmokingSwitch.setValue(0.5);
libraries.seatbeltSwitch.setValue(1.0);
libraries.emerLtsSwitch.setValue(0.5);
pts.Controls.Switches.noSmokingSwitch.setValue(0.5);
pts.Controls.Switches.seatbeltSwitch.setValue(1.0);
pts.Controls.Switches.emerLtsSwitch.setValue(0.5);
setprop("/controls/radio/rmp[0]/on", 1);
setprop("/controls/radio/rmp[1]/on", 1);
setprop("/controls/radio/rmp[2]/on", 1);
@ -488,9 +488,9 @@ var taxi_b = func {
setprop("/controls/switches/beacon", 1);
setprop("/controls/switches/wing-lights", 1);
setprop("/controls/lighting/nav-lights-switch", 1);
libraries.noSmokingSwitch.setValue(0.5);
libraries.seatbeltSwitch.setValue(1.0);
libraries.emerLtsSwitch.setValue(0.5);
pts.Controls.Switches.noSmokingSwitch.setValue(0.5);
pts.Controls.Switches.seatbeltSwitch.setValue(1.0);
pts.Controls.Switches.emerLtsSwitch.setValue(0.5);
setprop("/controls/radio/rmp[0]/on", 1);
setprop("/controls/radio/rmp[1]/on", 1);
setprop("/controls/radio/rmp[2]/on", 1);

View file

@ -3314,7 +3314,7 @@ var messages_config_memo = func {
toMemoLine1.colour = "c";
}
if (libraries.seatbeltSwitch.getValue() and libraries.noSmokingSwitch.getValue() ) {
if (pts.Controls.Switches.seatbeltSwitch.getValue() and pts.Controls.Switches.noSmokingSwitch.getValue()) {
toMemoLine2.msg = " SIGNS ON";
toMemoLine2.colour = "g";
} else {
@ -3380,7 +3380,7 @@ var messages_config_memo = func {
ldgMemoLine1.colour = "c";
}
if (libraries.seatbeltSwitch.getValue() and libraries.noSmokingSwitch.getValue()) {
if (pts.Controls.Switches.seatbeltSwitch.getValue() and pts.Controls.Switches.noSmokingSwitch.getValue()) {
ldgMemoLine2.msg = " SIGNS ON";
ldgMemoLine2.colour = "g";
} else {
@ -3505,19 +3505,19 @@ var messages_memo = func {
gnd_splrs.active = 0;
}
if (libraries.seatbeltLight.getValue() == 1 and toMemoLine1.active != 1 and ldgMemoLine1.active != 1) {
if (pts.Controls.Lighting.seatbeltSign.getValue() and toMemoLine1.active != 1 and ldgMemoLine1.active != 1) {
seatbelts.active = 1;
} else {
seatbelts.active = 0;
}
if (libraries.noSmokingLight.getValue() == 1 and toMemoLine1.active != 1 and ldgMemoLine1.active != 1) { # should go off after takeoff assuming switch is in auto due to old logic from the days when smoking was allowed!
if (pts.Controls.Lighting.noSmokingSign.getValue() and toMemoLine1.active != 1 and ldgMemoLine1.active != 1) { # should go off after takeoff assuming switch is in auto due to old logic from the days when smoking was allowed!
nosmoke.active = 1;
} else {
nosmoke.active = 0;
}
if (getprop("/controls/lighting/strobe") == 0 and !pts.Gear.wow[1].getValue() and toMemoLine1.active != 1 and ldgMemoLine1.active != 1) { # todo: use gear branch properties
if (!pts.Controls.Lighting.strobe.getValue() and !pts.Gear.wow[1].getValue() and toMemoLine1.active != 1 and ldgMemoLine1.active != 1) { # todo: use gear branch properties
strobe_lt_off.active = 1;
} else {
strobe_lt_off.active = 0;
@ -3542,7 +3542,7 @@ var messages_memo = func {
fob_66L.active = 0;
}
if (getprop("instrumentation/mk-viii/inputs/discretes/momentary-flap-all-override") == 1 and toMemoLine1.active != 1 and ldgMemoLine1.active != 1) {
if (libraries.GPWS.flapAllOverride.getValue() and toMemoLine1.active != 1 and ldgMemoLine1.active != 1) {
gpws_flap_mode_off.active = 1;
} else {
gpws_flap_mode_off.active = 0;

View file

@ -24,7 +24,7 @@ var variousReset = func() {
setprop("/instrumentation/mk-viii/inputs/discretes/momentary-flap-3-override", 0);
setprop("/controls/switches/cabinCall", 0);
setprop("/controls/switches/mechCall", 0);
libraries.emerLtsSwitch.setValue(0.5);
pts.Controls.Switches.emerLtsSwitch.setValue(0.5);
# cockpit voice recorder stuff
setprop("/controls/CVR/power", 0);
setprop("/controls/CVR/test", 0);
@ -61,9 +61,9 @@ var variousReset = func() {
setprop("/modes/fcu/hdg-time", -45);
setprop("/controls/navigation/switching/att-hdg", 0);
setprop("/controls/navigation/switching/air-data", 0);
libraries.noSmokingSwitch.setValue(0.0);
libraries.seatbeltSwitch.setValue(0.0);
libraries.emerLtsSwitch.setValue(0.0);
pts.Controls.Switches.noSmokingSwitch.setValue(0);
pts.Controls.Switches.seatbeltSwitch.setValue(0);
pts.Controls.Switches.emerLtsSwitch.setValue(0);
}
var BUTTONS = {

View file

@ -70,7 +70,7 @@ var triggerDoor = func(door, doorName, doorDesc) {
gui.popupTip("Closing " ~ doorDesc ~ " door");
door.toggle();
} else {
if (getprop("/velocities/groundspeed-kt") > 5) {
if (pts.Velocities.groundspeed.getValue() > 5) {
gui.popupTip("You cannot open the doors while the aircraft is moving!");
} else {
gui.popupTip("Opening " ~ doorDesc ~ " door");
@ -133,48 +133,6 @@ setlistener("/sim/signals/fdm-initialized", func() {
emesary.GlobalTransmitter.Register(A320Libraries);
});
var collectorTankL = props.globals.getNode("/fdm/jsbsim/propulsion/tank[5]/contents-lbs");
var collectorTankR = props.globals.getNode("/fdm/jsbsim/propulsion/tank[6]/contents-lbs");
var groundAir = props.globals.getNode("/controls/pneumatics/switches/groundair");
var groundCart = props.globals.getNode("/controls/electrical/ground-cart");
var chocks = props.globals.getNode("/services/chocks/enable");
var groundspeed = 0;
var stateL = 0;
var stateR = 0;
var seatbeltSwitch = props.globals.getNode("/controls/switches/seatbelt-sign");
var noSmokingSwitch = props.globals.getNode("/controls/switches/no-smoking-sign");
var emerLtsSwitch = props.globals.getNode("/controls/switches/emer-lights");
var seatbeltLight = props.globals.getNode("/controls/lighting/seatbelt-sign");
var noSmokingLight = props.globals.getNode("/controls/lighting/no-smoking-sign");
var update_items = [
props.UpdateManager.FromHashValue("seatbelt", nil, func(val) {
if (val) {
if (!seatbeltLight.getBoolValue()) {
seatbeltLight.setValue(1);
}
} else {
if (seatbeltLight.getBoolValue()) {
seatbeltLight.setValue(0);
}
}
}),
props.UpdateManager.FromHashList(["noSmoking","gearPosNorm"], nil, func(val) {
if (val.noSmoking == 1) {
if (!noSmokingLight.getBoolValue()) {
noSmokingLight.setBoolValue(1);
}
} elsif (val.noSmoking == 0.5 and val.gearPosNorm != 0) { # todo: should be when uplocks not engaged
if (!noSmokingLight.getBoolValue()) {
noSmokingLight.setBoolValue(1);
}
} else {
noSmokingLight.setBoolValue(0); # sign stays on in cabin but sound still occurs
}
}),
];
var systemsLoop = func(notification) {
if (!systemsInitialized and getprop("/systems/acconfig/mismatch-code") != "0x000") { return; }
systems.PNEU.loop(notification);
@ -190,15 +148,12 @@ var systemsLoop = func(notification) {
atsu.ATSU.loop();
libraries.BUTTONS.update();
if ((notification.engine1State == 2 or notification.engine1State == 3) and collectorTankL.getValue() < 1) {
if (notification.engine1State >= 2 and pts.Fdm.JSBsim.Propulsion.Tank.contentsLbs[5].getValue() < 1) {
systems.cutoff_one();
}
if ((notification.engine2State == 2 or notification.engine2State == 3) and collectorTankR.getValue() < 1) {
systems.cutoff_two();
}
foreach (var update_item; update_items) {
update_item.update(notification);
if (notification.engine2State >= 2 and pts.Fdm.JSBsim.Propulsion.Tank.contentsLbs[6].getValue() < 1) {
systems.cutoff_two();
}
}
@ -210,11 +165,13 @@ var GPWS = {
flapAllOverride: props.globals.getNode("/instrumentation/mk-viii/inputs/discretes/momentary-flap-all-override"),
flap3Override: props.globals.getNode("/instrumentation/mk-viii/inputs/discretes/momentary-flap-3-override"),
flapOverride: props.globals.getNode("/instrumentation/mk-viii/inputs/discretes/momentary-flap-override"),
alertMode: props.globals.initNode("/instrumentation/mk-viii/outputs/alert-mode",0,"INT"),
alertMode: props.globals.initNode("/instrumentation/mk-viii/outputs/alert-mode", 0, "INT"),
alert: props.globals.getNode("instrumentation/mk-viii/outputs/discretes/gpws-alert"),
warning: props.globals.getNode("instrumentation/mk-viii/outputs/discretes/gpws-warning"),
};
setlistener("/instrumentation/mk-viii/inputs/discretes/gpws-inhibit", func() {
if (GPWS.inhibitNode.getBoolValue()) {
setlistener("/instrumentation/mk-viii/inputs/discretes/gpws-inhibit", func(val) {
if (val.getBoolValue()) {
GPWS.volume.setValue(2);
} else {
GPWS.volume.setValue(0);
@ -238,18 +195,29 @@ setlistener("/instrumentation/mk-viii/inputs/discretes/momentary-flap-3-override
}, 0, 0);
# GPWS alert pooling for get mode change - a little esoteric way but it works
var gpws_alert_watch = maketimer(0.8,func {
var alert = 0;
if (getprop("instrumentation/mk-viii/outputs/discretes/gpws-warning")) alert = 2; # MODE2 - warning - RED
else if (getprop("instrumentation/mk-viii/outputs/discretes/gpws-alert")) alert = 1; # MODE1 - caution - YELLOW
if (GPWS.alertMode.getValue()!=alert) GPWS.alertMode.setValue(alert);
var GPWSAlertStatus = 0;
var gpws_alert_watch = maketimer(0.8, func() {
if (GPWS.warning.getValue()) {
GPWSAlertStatus = 2; # MODE2 - warning - RED
} else if (GPWS.alert.getValue()) {
GPWSAlertStatus = 1; # MODE1 - caution - YELLOW
} else {
GPWSAlertStatus = 0;
}
if (GPWS.alertMode.getValue() != GPWSAlertStatus) {
GPWS.alertMode.setValue(GPWSAlertStatus);
}
});
setlistener("/instrumentation/mk-viii/inputs/discretes/ta-tcf-inhibit", func{ # detect GPWS switch status
var failure = GPWS.tatcfInhibit.getBoolValue();
if (!failure) gpws_alert_watch.start();
else gpws_alert_watch.stop();
},1,0);
# detect GPWS switch status
setlistener("/instrumentation/mk-viii/inputs/discretes/ta-tcf-inhibit", func (val) {
if (!val.getBoolValue()) {
gpws_alert_watch.start();
} else {
gpws_alert_watch.stop();
}
}, 1, 0);
# Replay
var replayState = props.globals.getNode("/sim/replay/replay-state");
@ -392,8 +360,6 @@ var LibrariesRecipient =
var input = {
# Libraries
"seatbelt": "/controls/switches/seatbelt-sign",
"noSmoking": "/controls/switches/no-smoking-sign",
"gearPosNorm": "/gear/gear[0]/position-norm",
"gearPosNorm1": "/gear/gear[1]/position-norm",
"gearPosNorm2": "/gear/gear[2]/position-norm",
@ -407,8 +373,8 @@ foreach (var name; keys(input)) {
# TODO split EFIS altimeters
var newinhg = nil;
setlistener("/instrumentation/altimeter/setting-inhg", func() {
newinhg = getprop("/instrumentation/altimeter/setting-inhg");
setlistener("/instrumentation/altimeter/setting-inhg", func(val) {
newinhg = val.getValue();
setprop("/instrumentation/altimeter[1]/setting-inhg", newinhg);
setprop("/instrumentation/altimeter[2]/setting-inhg", newinhg);
setprop("/instrumentation/altimeter[3]/setting-inhg", newinhg);
@ -417,8 +383,8 @@ setlistener("/instrumentation/altimeter/setting-inhg", func() {
}, 0, 0);
var newhpa = nil;
setlistener("/instrumentation/altimeter/setting-hpa", func() {
newhpa = getprop("/instrumentation/altimeter/setting-hpa");
setlistener("/instrumentation/altimeter/setting-hpa", func(val) {
newhpa = val.getValue();
setprop("/instrumentation/altimeter[1]/setting-hpa", newhpa);
setprop("/instrumentation/altimeter[2]/setting-hpa", newhpa);
setprop("/instrumentation/altimeter[3]/setting-hpa", newhpa);

View file

@ -69,9 +69,15 @@ var Controls = {
},
Lighting: {
landingLights: [props.globals.getNode("/controls/lighting/landing-lights[0]"),props.globals.getNode("/controls/lighting/landing-lights[1]"),props.globals.getNode("/controls/lighting/landing-lights[2]")],
noSmokingSign: props.globals.getNode("/controls/lighting/no-smoking-sign"),
seatbeltSign: props.globals.getNode("/controls/lighting/seatbelt-sign"),
strobe: props.globals.getNode("/controls/lighting/strobe"),
},
Switches: {
annunTest: props.globals.getNode("/controls/switches/annun-test"),
emerLtsSwitch: props.globals.getNode("/controls/switches/emer-lights"),
noSmokingSwitch: props.globals.getNode("/controls/switches/no-smoking-sign"),
seatbeltSwitch: props.globals.getNode("/controls/switches/seatbelt-sign"),
},
};
@ -136,6 +142,10 @@ var Fdm = {
fuelUsed: [props.globals.getNode("/fdm/jsbsim/propulsion/engine[0]/fuel-used-lbs"), props.globals.getNode("/fdm/jsbsim/propulsion/engine[1]/fuel-used-lbs")],
reverserAngle: [props.globals.getNode("/fdm/jsbsim/propulsion/engine[0]/reverser-angle-rad"), props.globals.getNode("/fdm/jsbsim/propulsion/engine[1]/reverser-angle-rad")],
},
Tank: {
contentsLbs: [props.globals.getNode("/fdm/jsbsim/propulsion/tank[0]/contents-lbs"), props.globals.getNode("/fdm/jsbsim/propulsion/tank[1]/contents-lbs"), props.globals.getNode("/fdm/jsbsim/propulsion/tank[2]/contents-lbs"),
props.globals.getNode("/fdm/jsbsim/propulsion/tank[3]/contents-lbs"), props.globals.getNode("/fdm/jsbsim/propulsion/tank[4]/contents-lbs"), props.globals.getNode("/fdm/jsbsim/propulsion/tank[5]/contents-lbs"), props.globals.getNode("/fdm/jsbsim/propulsion/tank[6]/contents-lbs")],
},
},
},
};

View file

@ -19,8 +19,8 @@ var ground_services = {
setprop("/services/deicing_truck/de-ice", 0);
# Set them all to 0 if the aircraft is not stationary
if (getprop("velocities/groundspeed-kt") >= 2) {
setprop("/services/chocks/enable", 0);
if (pts.Velocities.groundspeed.getValue() >= 2) {
pts.Controls.Gear.chocks.setValue(0);
setprop("/services/fuel-truck/enable", 0);
setprop("/services/deicing_truck/enable", 0);
setprop("/services/catering/enable", 0);

View file

@ -223,5 +223,45 @@
</switch>
</channel>
<channel name="Signs">
<switch name="/controls/lighting/no-smoking-sign">
<default value="0"/>
<test logic="AND" value="1">
<test logic="OR">
/systems/electrical/bus/dc-ess ge 25
/systems/electrical/bus/dc-service-bus ge 25
</test>
<test logic="OR">
/systems/pressurization/cabinalt-norm ge 11300
/controls/switches/no-smoking-sign eq 1
</test>
</test>
<test logic="AND" value="1">
/controls/switches/no-smoking-sign eq 0.5
/gear/gear[0]/position-norm eq 1
<test logic="OR">
/systems/electrical/bus/dc-ess ge 25
/systems/electrical/bus/dc-service-bus ge 25
</test>
</test>
</switch>
<switch name="/controls/lighting/seatbelt-sign">
<default value="0"/>
<test logic="AND" value="1">
<test logic="OR">
/systems/electrical/bus/dc-ess ge 25
/systems/electrical/bus/dc-service-bus ge 25
</test>
<test logic="OR">
/systems/pressurization/cabinalt-norm ge 11300
/controls/switches/seatbelt-sign eq 1
</test>
</test>
</switch>
</channel>
</system>