1
0
Fork 0

APU: correct un-init property, and ensure start signal is ended when master switch is turned off in pre-init phase

This commit is contained in:
legoboyvdlp R 2020-08-13 10:45:08 +01:00
parent e3266e5325
commit 5fe512a913
2 changed files with 40 additions and 40 deletions

View file

@ -19,7 +19,7 @@ var APUNodes = {
var APU = { var APU = {
state: 0, # off, power up, watch, starting preparation, starting, run, cooldown, shutdown state: 0, # off, power up, watch, starting preparation, starting, run, cooldown, shutdown
inletFlap: aircraft.door.new("controls/apu/inlet-flap", 12), inletFlap: aircraft.door.new("/controls/apu/inlet-flap", 12),
fuelValveCmd: props.globals.getNode("/systems/fuel/valves/apu-lp-valve-cmd"), fuelValveCmd: props.globals.getNode("/systems/fuel/valves/apu-lp-valve-cmd"),
fuelValvePos: props.globals.getNode("/systems/fuel/valves/apu-lp-valve"), fuelValvePos: props.globals.getNode("/systems/fuel/valves/apu-lp-valve"),
inletFlapPos: props.globals.getNode("/controls/apu/inlet-flap/position-norm"), inletFlapPos: props.globals.getNode("/controls/apu/inlet-flap/position-norm"),
@ -95,7 +95,7 @@ var APU = {
me.checkOil(); me.checkOil();
me.listenSignals = 1; me.listenSignals = 1;
settimer(func() { settimer(func() {
if (APUNodes.Controls.master.getValue() and !getprop("systems/acconfig/autoconfig-running")) { if (APUNodes.Controls.master.getValue() and !getprop("/systems/acconfig/autoconfig-running")) {
me.setState(2); me.setState(2);
} }
}, 3); }, 3);
@ -103,7 +103,7 @@ var APU = {
}, },
startCommand: func(fast = 0) { startCommand: func(fast = 0) {
if (me.listenSignals and (me.state == 1 or me.state == 2)) { if (me.listenSignals and (me.state == 1 or me.state == 2)) {
me.signals.startInProgress.setValue(1); me.signals.startInProgress.setBoolValue(1);
me.setState(3); me.setState(3);
checkApuStartTimer.start(); checkApuStartTimer.start();
me.fastStart = fast; me.fastStart = fast;
@ -137,7 +137,7 @@ var APU = {
waitStart2: func() { waitStart2: func() {
if (pts.APU.rpm.getValue() >= 99.9) { if (pts.APU.rpm.getValue() >= 99.9) {
me.GenericControls.starter.setValue(0); me.GenericControls.starter.setValue(0);
me.signals.startInProgress.setValue(0); me.signals.startInProgress.setBoolValue(0);
me.signals.available.setValue(1); me.signals.available.setValue(1);
me.setState(5); me.setState(5);
apuStartTimer2.stop(); apuStartTimer2.stop();
@ -187,11 +187,14 @@ var APU = {
# Signal generators / receivers # Signal generators / receivers
stop: func() { stop: func() {
if (me.listenStopSignal and me.state == 4) { if (me.listenStopSignal and me.state == 4) {
me.signals.startInProgress.setValue(0); me.signals.startInProgress.setBoolValue(0);
me.stopAPU(); me.stopAPU();
me.setState(7); me.setState(7);
shutdownTimer.start(); shutdownTimer.start();
} else { } else {
if (me.signals.startInProgress.getBoolValue()) {
me.signals.startInProgress.setBoolValue(0);
}
if (me.signals.bleedWasUsed) { if (me.signals.bleedWasUsed) {
if (me.bleedTime == 0) { me.shutBleed(); } if (me.bleedTime == 0) { me.shutBleed(); }
if (120 - (pts.Sim.Time.elapsedSec.getValue() - me.bleedTime) > 0) { if (120 - (pts.Sim.Time.elapsedSec.getValue() - me.bleedTime) > 0) {
@ -290,7 +293,7 @@ var APUController = {
}; };
var _masterTime = 0; var _masterTime = 0;
setlistener("controls/apu/master", func() { setlistener("/controls/apu/master", func() {
if (APUController.APU != nil) { if (APUController.APU != nil) {
if (APUNodes.Controls.master.getValue() and APUController.APU.state == 0) { if (APUNodes.Controls.master.getValue() and APUController.APU.state == 0) {
shutdownTimer.stop(); shutdownTimer.stop();
@ -304,7 +307,7 @@ setlistener("controls/apu/master", func() {
} }
}, 0, 0); }, 0, 0);
setlistener("controls/pneumatics/switches/apu", func() { setlistener("/controls/pneumatics/switches/apu", func() {
if (APUController.APU != nil) { if (APUController.APU != nil) {
if (APUNodes.Controls.bleed.getValue()) { if (APUNodes.Controls.bleed.getValue()) {
APUController.APU.signals.bleedWasUsed = 1; APUController.APU.signals.bleedWasUsed = 1;

View file

@ -3,10 +3,10 @@
# Copyright (c) 2020 Josh Davidson (Octal450) # Copyright (c) 2020 Josh Davidson (Octal450)
var elapsedTime = props.globals.getNode("sim/time/elapsed-sec"); var elapsedTime = props.globals.getNode("/sim/time/elapsed-sec");
var apuTestBtn = props.globals.getNode("controls/fire/apu-test-btn", 1); var apuTestBtn = props.globals.getNode("/controls/fire/apu-test-btn", 1);
var testBtn = props.globals.getNode("controls/fire/test-btn-1", 1); var testBtn = props.globals.getNode("/controls/fire/test-btn-1", 1);
var testBtn2 = props.globals.getNode("controls/fire/test-btn-2", 1); var testBtn2 = props.globals.getNode("/controls/fire/test-btn-2", 1);
var dischTest = props.globals.initNode("/systems/fire/cargo/disch-test", 0, "BOOL"); var dischTest = props.globals.initNode("/systems/fire/cargo/disch-test", 0, "BOOL");
var cargoTestBtn = props.globals.initNode("/controls/fire/cargo/test", 0, "BOOL"); var cargoTestBtn = props.globals.initNode("/controls/fire/cargo/test", 0, "BOOL");
var cargoTestTime = props.globals.initNode("/controls/fire/cargo/test-time", 0, "DOUBLE"); var cargoTestTime = props.globals.initNode("/controls/fire/cargo/test-time", 0, "DOUBLE");
@ -32,20 +32,19 @@ var eng2AgentTimerTime = props.globals.initNode("/systems/fire/engine2/agent1-ti
var eng1Agent2TimerTime = props.globals.initNode("/systems/fire/engine1/agent2-timer-time", 0, "INT"); var eng1Agent2TimerTime = props.globals.initNode("/systems/fire/engine1/agent2-timer-time", 0, "INT");
var eng2Agent2TimerTime = props.globals.initNode("/systems/fire/engine2/agent2-timer-time", 0, "INT"); var eng2Agent2TimerTime = props.globals.initNode("/systems/fire/engine2/agent2-timer-time", 0, "INT");
var apuAgentTimerTime = props.globals.initNode("/systems/fire/apu/agent-timer-time", 0, "INT"); var apuAgentTimerTime = props.globals.initNode("/systems/fire/apu/agent-timer-time", 0, "INT");
var wow = props.globals.getNode("fdm/jsbsim/position/wow", 1); var wow = props.globals.getNode("/fdm/jsbsim/position/wow", 1);
var dcbatNode = props.globals.getNode("systems/electrical/bus/dc-bat", 1); var dcbatNode = props.globals.getNode("/systems/electrical/bus/dc-bat", 1);
var dcessNode = props.globals.getNode("systems/electrical/bus/dc-ess", 1); var dcessNode = props.globals.getNode("/systems/electrical/bus/dc-ess", 1);
var apuBleedNode = props.globals.getNode("systems/apu/bleed-used", 1); var apuMaster = props.globals.getNode("/controls/apu/master", 1);
var apuMaster = props.globals.getNode("controls/apu/master", 1);
var fire_init = func { var fire_init = func {
setprop("controls/OH/protectors/fwddisch", 0); setprop("/controls/OH/protectors/fwddisch", 0);
setprop("controls/OH/protectors/aftdisch", 0); setprop("/controls/OH/protectors/aftdisch", 0);
setprop("controls/fire/cargo/fwddisch", 0); setprop("/controls/fire/cargo/fwddisch", 0);
setprop("controls/fire/cargo/aftdisch", 0); setprop("/controls/fire/cargo/aftdisch", 0);
setprop("systems/failures/cargo-fwd-fire", 0); setprop("/systems/failures/cargo-fwd-fire", 0);
setprop("systems/failures/cargo-aft-fire", 0); setprop("/systems/failures/cargo-aft-fire", 0);
setprop("controls/fire/cargo/test", 0); setprop("/controls/fire/cargo/test", 0);
fire_timer.start(); fire_timer.start();
} }
@ -68,7 +67,7 @@ var engFireDetectorUnit = {
eF.loopTwo = 0; eF.loopTwo = 0;
eF.fireProp = props.globals.getNode(fireProp, 1); eF.fireProp = props.globals.getNode(fireProp, 1);
eF.testProp = props.globals.getNode(testProp, 1); eF.testProp = props.globals.getNode(testProp, 1);
eF.wow = props.globals.getNode("fdm/jsbsim/position/wow", 1); eF.wow = props.globals.getNode("/fdm/jsbsim/position/wow", 1);
eF.condition = 100; eF.condition = 100;
return eF; return eF;
}, },
@ -179,7 +178,6 @@ var engFireDetectorUnit = {
} elsif (system == 2) { } elsif (system == 2) {
apuFireWarn.setBoolValue(1); apuFireWarn.setBoolValue(1);
if (me.wow.getValue() == 1) { if (me.wow.getValue() == 1) {
apuBleedNode.setValue(0);
systems.APUController.APU.emergencyStop(); systems.APUController.APU.emergencyStop();
settimer(func() { # 3 sec delay - source TTM ATA 26 FIRE PROTECTION p102 settimer(func() { # 3 sec delay - source TTM ATA 26 FIRE PROTECTION p102
extinguisherBottles.vector[4].discharge(); extinguisherBottles.vector[4].discharge();
@ -284,9 +282,9 @@ var detectorLoop = {
} }
}, },
sendSignal: func(system, typeLoop) { sendSignal: func(system, typeLoop) {
if (system == 0 and !getprop("systems/failures/engine-left-fire")) { return; } if (system == 0 and !getprop("/systems/failures/engine-left-fire")) { return; }
elsif (system == 1 and !getprop("systems/failures/engine-right-fire")) { return; } elsif (system == 1 and !getprop("/systems/failures/engine-right-fire")) { return; }
elsif (system == 2 and !getprop("systems/failures/apu-fire")) { return; } elsif (system == 2 and !getprop("/systems/failures/apu-fire")) { return; }
engFireDetectorUnits.vector[system].receiveSignal(typeLoop); engFireDetectorUnits.vector[system].receiveSignal(typeLoop);
} }
}; };
@ -311,8 +309,8 @@ var cargoDetectorLoop = {
} }
}, },
sendSignal: func(system, typeLoop) { sendSignal: func(system, typeLoop) {
if ((system == 0 or system == 1) and !getprop("systems/failures/cargo-aft-fire")) { return; } if ((system == 0 or system == 1) and !getprop("/systems/failures/cargo-aft-fire")) { return; }
elsif (system == 2 and !getprop("systems/failures/cargo-fwd-fire")) { return; } elsif (system == 2 and !getprop("/systems/failures/cargo-fwd-fire")) { return; }
cargoSmokeDetectorUnits.vector[system].receiveSignal(typeLoop); cargoSmokeDetectorUnits.vector[system].receiveSignal(typeLoop);
} }
@ -552,7 +550,7 @@ var createCargoFireBottleListener = func(prop, index) {
# Listeners # Listeners
setlistener("/controls/engines/engine[0]/fire-btn", func() { setlistener("/controls/engines/engine[0]/fire-btn", func() {
if (getprop("controls/engines/engine[0]/fire-btn") == 1) { if (getprop("/controls/engines/engine[0]/fire-btn") == 1) {
ecam.shutUpYou(); ecam.shutUpYou();
eng1AgentTimerMakeTimer.stop(); eng1AgentTimerMakeTimer.stop();
eng1AgentTimer.setValue(10); eng1AgentTimer.setValue(10);
@ -562,7 +560,7 @@ setlistener("/controls/engines/engine[0]/fire-btn", func() {
}, 0, 0); }, 0, 0);
setlistener("/systems/fire/engine1/disch1", func() { setlistener("/systems/fire/engine1/disch1", func() {
if (getprop("systems/fire/engine1/disch1") == 1) { if (getprop("/systems/fire/engine1/disch1") == 1) {
eng1Agent2TimerMakeTimer.stop(); eng1Agent2TimerMakeTimer.stop();
eng1Agent2Timer.setValue(30); eng1Agent2Timer.setValue(30);
eng1Agent2TimerTime.setValue(elapsedTime.getValue() + 31); eng1Agent2TimerTime.setValue(elapsedTime.getValue() + 31);
@ -595,7 +593,7 @@ eng1Agent2TimerMakeTimerFunc = func() {
} }
setlistener("/controls/engines/engine[1]/fire-btn", func() { setlistener("/controls/engines/engine[1]/fire-btn", func() {
if (getprop("controls/engines/engine[1]/fire-btn") == 1) { if (getprop("/controls/engines/engine[1]/fire-btn") == 1) {
ecam.shutUpYou(); ecam.shutUpYou();
eng2AgentTimerMakeTimer.stop(); eng2AgentTimerMakeTimer.stop();
eng2AgentTimer.setValue(10); eng2AgentTimer.setValue(10);
@ -605,7 +603,7 @@ setlistener("/controls/engines/engine[1]/fire-btn", func() {
}, 0, 0); }, 0, 0);
setlistener("/systems/fire/engine2/disch1", func() { setlistener("/systems/fire/engine2/disch1", func() {
if (getprop("systems/fire/engine2/disch1") == 1) { if (getprop("/systems/fire/engine2/disch1") == 1) {
eng2Agent2TimerMakeTimer.stop(); eng2Agent2TimerMakeTimer.stop();
eng2Agent2Timer.setValue(30); eng2Agent2Timer.setValue(30);
eng2Agent2TimerTime.setValue(elapsedTime.getValue() + 31); eng2Agent2TimerTime.setValue(elapsedTime.getValue() + 31);
@ -638,9 +636,8 @@ eng2Agent2TimerMakeTimerFunc = func() {
} }
setlistener("/controls/apu/fire-btn", func() { setlistener("/controls/apu/fire-btn", func() {
if (getprop("controls/apu/fire-btn") == 1) { if (getprop("/controls/apu/fire-btn") == 1) {
ecam.shutUpYou(); ecam.shutUpYou();
apuBleedNode.setValue(0);
systems.APUController.APU.emergencyStop(); systems.APUController.APU.emergencyStop();
apuAgentTimerMakeTimer.stop(); apuAgentTimerMakeTimer.stop();
apuAgentTimer.setValue(10); apuAgentTimer.setValue(10);
@ -661,7 +658,7 @@ apuAgentTimerMakeTimerFunc = func() {
} }
setlistener("/controls/fire/test-btn-1", func() { setlistener("/controls/fire/test-btn-1", func() {
if (getprop("systems/failures/engine-left-fire")) { return; } if (getprop("/systems/failures/engine-left-fire")) { return; }
if (testBtn.getValue() == 1) { if (testBtn.getValue() == 1) {
if (dcbatNode.getValue() > 25 or dcessNode.getValue() > 25) { if (dcbatNode.getValue() > 25 or dcessNode.getValue() > 25) {
@ -674,7 +671,7 @@ setlistener("/controls/fire/test-btn-1", func() {
}, 0, 0); }, 0, 0);
setlistener("/controls/fire/test-btn-2", func() { setlistener("/controls/fire/test-btn-2", func() {
if (getprop("systems/failures/engine-right-fire")) { return; } if (getprop("/systems/failures/engine-right-fire")) { return; }
if (testBtn2.getValue() == 1) { if (testBtn2.getValue() == 1) {
if (dcbatNode.getValue() > 25 or dcessNode.getValue() > 25) { if (dcbatNode.getValue() > 25 or dcessNode.getValue() > 25) {
eng2FireWarn.setBoolValue(1); eng2FireWarn.setBoolValue(1);
@ -686,7 +683,7 @@ setlistener("/controls/fire/test-btn-2", func() {
}, 0, 0); }, 0, 0);
setlistener("/controls/fire/apu-test-btn", func() { setlistener("/controls/fire/apu-test-btn", func() {
if (getprop("systems/failures/apu-fire")) { return; } if (getprop("/systems/failures/apu-fire")) { return; }
if (apuTestBtn.getValue() == 1) { if (apuTestBtn.getValue() == 1) {
if (dcbatNode.getValue() > 25 or dcessNode.getValue() > 25) { if (dcbatNode.getValue() > 25 or dcessNode.getValue() > 25) {
apuFireWarn.setBoolValue(1); apuFireWarn.setBoolValue(1);
@ -698,7 +695,7 @@ setlistener("/controls/fire/apu-test-btn", func() {
}, 0, 0); }, 0, 0);
setlistener("/controls/fire/cargo/test", func() { setlistener("/controls/fire/cargo/test", func() {
if (getprop("systems/failures/aft-cargo-fire") or getprop("systems/failures/fwd-cargo-fire") or dcbatNode.getValue() < 25 or dcessNode.getValue() < 25) { return; } if (getprop("/systems/failures/aft-cargo-fire") or getprop("/systems/failures/fwd-cargo-fire") or dcbatNode.getValue() < 25 or dcessNode.getValue() < 25) { return; }
if (cargoTestBtn.getBoolValue()) { if (cargoTestBtn.getBoolValue()) {
cargoTestTime.setValue(elapsedTime.getValue()); cargoTestTime.setValue(elapsedTime.getValue());
cargoTestChecker.start(); cargoTestChecker.start();