From cc13067a49c64b4a8cd719f768875c7c2f6ad17e Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Thu, 25 Apr 2019 15:10:54 +0100 Subject: [PATCH] Agent 1 timer works, need to fix agent 2 timer --- Nasal/ECAM/ECAM-logic.nas | 95 +++++++++++++++++++++++++++++++----- Nasal/ECAM/ECAM-messages.nas | 5 +- Nasal/fire.nas | 60 ++++++++++++++++++++--- 3 files changed, 140 insertions(+), 20 deletions(-) diff --git a/Nasal/ECAM/ECAM-logic.nas b/Nasal/ECAM/ECAM-logic.nas index aebd14d4..16ca95f9 100644 --- a/Nasal/ECAM/ECAM-logic.nas +++ b/Nasal/ECAM/ECAM-logic.nas @@ -270,10 +270,39 @@ var messages_priority_3 = func { ECAM_controller.warningReset(eng1FireFlPB); } - eng1FireFlAgent1.active = 1; - eng1FireFlATC.active = 1; - eng1FireFl30Sec.active = 1; - eng1FireFlAgent2.active = 1; + if (getprop("/systems/fire/engine1/agent1-timer") != 0 and getprop("/systems/fire/engine1/agent1-timer") != 99) { + eng1FireFlAgent1Timer.msg = " -AGENT AFT " ~ getprop("/systems/fire/engine1/agent1-timer") ~ " S...DISCH"; + } + + if (eng1FireFlAgent1.clearFlag == 0 and !getprop("/systems/fire/engine1/disch1") and getprop("/systems/fire/engine1/agent1-timer") != 0 and getprop("/systems/fire/engine1/agent1-timer") != 99) { + eng1FireFlAgent1Timer.active = 1; + } else { + ECAM_controller.warningReset(eng1FireFlAgent1Timer); + } + + if (eng1FireFlAgent1.clearFlag == 0 and !getprop("/systems/fire/engine1/disch1") and (getprop("/systems/fire/engine1/agent1-timer") == 0 or getprop("/systems/fire/engine1/agent1-timer") == 99)) { + eng1FireFlAgent1.active = 1; + } else { + ECAM_controller.warningReset(eng1FireFlAgent1); + } + + if (eng1FireFlATC.clearFlag == 0) { + eng1FireFlATC.active = 1; + } else { + ECAM_controller.warningReset(eng1FireFlATC); + } + + if (getprop("/systems/fire/engine1/agent2-timer") != 0 and getprop("/systems/fire/engine1/agent2-timer") != 99) { + eng1FireFl30Sec.msg = "•IF FIRE AFTER " ~ getprop("/systems/fire/engine1/agent2-timer") ~ " S:"; + } + + if (eng1FireFlAgent2.clearFlag == 0 and !getprop("/systems/fire/engine1/disch2")) { + eng1FireFl30Sec.active = 1; + eng1FireFlAgent2.active = 1; + } else { + ECAM_controller.warningReset(eng1FireFl30Sec); + ECAM_controller.warningReset(eng1FireFlAgent2); + } } else { ECAM_controller.warningReset(eng1FireFllever); ECAM_controller.warningReset(eng1FireFlmaster); @@ -317,13 +346,57 @@ var messages_priority_3 = func { } if (eng2FireFl.active == 1) { - eng2FireFllever.active = 1; - eng2FireFlmaster.active = 1; - eng2FireFlPB.active = 1; - eng2FireFlAgent1.active = 1; - eng2FireFlATC.active = 1; - eng2FireFl30Sec.active = 1; - eng2FireFlAgent2.active = 1; + if (eng2FireFllever.clearFlag == 0 and getprop("/fdm/jsbsim/fcs/throttle-lever[1]") > 0.01) { + eng2FireFllever.active = 1; + } else { + ECAM_controller.warningReset(eng2FireFllever); + } + + if (eng2FireFlmaster.clearFlag == 0 and getprop("/controls/engines/engine[1]/cutoff-switch") == 0) { + eng2FireFlmaster.active = 1; + } else { + ECAM_controller.warningReset(eng2FireFlmaster); + } + + if (eng2FireFlPB.clearFlag == 0 and getprop("/controls/engines/engine[1]/fire-btn") == 0) { + eng2FireFlPB.active = 1; + } else { + ECAM_controller.warningReset(eng2FireFlPB); + } + + if (getprop("/systems/fire/engine2/agent1-timer") != 0 and getprop("/systems/fire/engine2/agent1-timer") != 99) { + eng2FireFlAgent1Timer.msg = " -AGENT AFT " ~ getprop("/systems/fire/engine2/agent1-timer") ~ " S...DISCH"; + } + + if (eng2FireFlAgent1.clearFlag == 0 and !getprop("/systems/fire/engine2/disch1") and getprop("/systems/fire/engine1/agent2-timer") != 0 and getprop("/systems/fire/engine2/agent1-timer") != 99) { + eng2FireFlAgent1Timer.active = 1; + } else { + ECAM_controller.warningReset(eng2FireFlAgent1Timer); + } + + if (eng2FireFlAgent1.clearFlag == 0 and !getprop("/systems/fire/engine2/disch1") and (getprop("/systems/fire/engine2/agent1-timer") == 0 or getprop("/systems/fire/engine2/agent1-timer") == 99)) { + eng2FireFlAgent1.active = 1; + } else { + ECAM_controller.warningReset(eng2FireFlAgent1); + } + + if (eng2FireFlATC.clearFlag == 0) { + eng2FireFlATC.active = 1; + } else { + ECAM_controller.warningReset(eng2FireFlATC); + } + + if (getprop("/systems/fire/engine2/agent2-timer") != 0 and getprop("/systems/fire/engine2/agent2-timer") != 99) { + eng2FireFl30Sec.msg = "•IF FIRE AFTER " ~ getprop("/systems/fire/engine2/agent2-timer") ~ " S:"; + } + + if (eng2FireFlAgent2.clearFlag == 0 and !getprop("/systems/fire/engine2/disch2")) { + eng2FireFl30Sec.active = 1; + eng2FireFlAgent2.active = 1; + } else { + ECAM_controller.warningReset(eng2FireFl30Sec); + ECAM_controller.warningReset(eng2FireFlAgent2); + } } else { ECAM_controller.warningReset(eng2FireFllever); ECAM_controller.warningReset(eng2FireFlmaster); diff --git a/Nasal/ECAM/ECAM-messages.nas b/Nasal/ECAM/ECAM-messages.nas index c9bc2394..011c0617 100644 --- a/Nasal/ECAM/ECAM-messages.nas +++ b/Nasal/ECAM/ECAM-messages.nas @@ -47,9 +47,10 @@ var warnings = std.Vector.new([ var eng1FireFllever = warning.new(msg: " -THR LEVER 1.......IDLE", colour: "c"), var eng1FireFlmaster = warning.new(msg: " -ENG MASTER 1.......OFF", colour: "c"), var eng1FireFlPB = warning.new(msg: " -ENG 1 FIRE P/B....PUSH", colour: "c"), - var eng1FireFlAgent1 = warning.new(msg: " -AGENT 1 AFT 10 S.DISCH", colour: "w"), + var eng1FireFlAgent1Timer = warning.new(msg: " -AGENT 1 AFT 10 S.DISCH", colour: "w"), + var eng1FireFlAgent1 = warning.new(msg: " -AGENT 1..........DISCH", colour: "c"), var eng1FireFlATC = warning.new(msg: " -ATC.............NOTIFY", colour: "c"), - var eng1FireFl30Sec = warning.new(msg: " •IF FIRE AFTER 30 S:", colour: "w"), + var eng1FireFl30Sec = warning.new(msg: " •IF FIRE AFTER 30 S:", colour: "w", hasSubmsg: 1), var eng1FireFlAgent2 = warning.new(msg: " -AGENT 2..........DISCH", colour: "c"), # ENG 1 FIRE (ground) diff --git a/Nasal/fire.nas b/Nasal/fire.nas index 2fe781ef..3ee25d75 100644 --- a/Nasal/fire.nas +++ b/Nasal/fire.nas @@ -36,11 +36,15 @@ var testBtn2 = props.globals.getNode("/controls/fire/test-btn-2", 1); var eng1FireWarn = props.globals.initNode("/systems/fire/engine1/warning-active", 0, "BOOL"); var eng2FireWarn = props.globals.initNode("/systems/fire/engine2/warning-active", 0, "BOOL"); var apuFireWarn = props.globals.initNode("/systems/fire/apu/warning-active", 0, "BOOL"); -var eng1AgentTimer = props.globals.initNode("/systems/fire/engine1/agent-timer", 99, "INT"); -var eng2AgentTimer = props.globals.initNode("/systems/fire/engine2/agent-timer", 99, "INT"); +var eng1AgentTimer = props.globals.initNode("/systems/fire/engine1/agent1-timer", 99, "INT"); +var eng2AgentTimer = props.globals.initNode("/systems/fire/engine2/agent1-timer", 99, "INT"); +var eng1Agent2Timer = props.globals.initNode("/systems/fire/engine1/agent2-timer", 99, "INT"); +var eng2Agent2Timer = props.globals.initNode("/systems/fire/engine2/agent2-timer", 99, "INT"); var apuAgentTimer = props.globals.initNode("/systems/fire/apu/agent-timer", 99, "INT"); -var eng1AgentTimerTime = props.globals.initNode("/systems/fire/engine1/agent-timer-time", 0, "INT"); -var eng2AgentTimerTime = props.globals.initNode("/systems/fire/engine2/agent-timer-time", 0, "INT"); +var eng1AgentTimerTime = props.globals.initNode("/systems/fire/engine1/agent1-timer-time", 0, "INT"); +var eng2AgentTimerTime = props.globals.initNode("/systems/fire/engine2/agent1-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 apuAgentTimerTime = props.globals.initNode("/systems/fire/apu/agent-timer-time", 0, "INT"); var wow = props.globals.getNode("/fdm/jsbsim/position/wow", 1); var dcbatNode = props.globals.getNode("systems/electrical/bus/dcbat", 1); @@ -373,7 +377,7 @@ var extinguisherBottle = { return eB; }, emptyBottle: func() { - me.quantity -= 5; + me.quantity -= 10; if (me.quantity > 0) { settimer(func() { me.emptyBottle() @@ -519,11 +523,20 @@ setlistener("/controls/engines/engine[0]/fire-btn", func() { ecam.shutUpYou(); eng1AgentTimerMakeTimer.stop(); eng1AgentTimer.setValue(10); - eng1AgentTimerTime.setValue(elapsedTime.getValue() + 10); + eng1AgentTimerTime.setValue(elapsedTime.getValue() + 11); eng1AgentTimerMakeTimer.start(); } }, 0, 0); +setlistener("/systems/fire/engine1/disch1", func() { + if (getprop("/systems/fire/engine1/disch1") == 1) { + eng1Agent2TimerMakeTimer.stop(); + eng1Agent2Timer.setValue(30); + eng1Agent2TimerTime.setValue(elapsedTime.getValue() + 31); + eng1Agent2TimerMakeTimer.start(); + } +}, 0, 0); + eng1AgentTimerMakeTimerFunc = func() { if (eng1AgentTimer.getValue() > 0) { var eng1Time = eng1AgentTimerTime.getValue(); @@ -535,16 +548,36 @@ eng1AgentTimerMakeTimerFunc = func() { } } +eng1Agent2TimerMakeTimerFunc = func() { + if (eng1Agent2Timer.getValue() > 0) { + var eng1Time2 = eng1AgentTimerTime.getValue(); + var etEng12 = elapsedTime.getValue(); + var timeToSetEng12 = eng1Time2 - etEng12; + eng1Agent2Timer.setValue(timeToSetEng12); + } else { + eng1Agent2TimerMakeTimer.stop(); + } +} + setlistener("/controls/engines/engine[1]/fire-btn", func() { if (getprop("/controls/engines/engine[1]/fire-btn") == 1) { ecam.shutUpYou(); eng2AgentTimerMakeTimer.stop(); eng2AgentTimer.setValue(10); - eng2AgentTimerTime.setValue(elapsedTime.getValue() + 10); + eng2AgentTimerTime.setValue(elapsedTime.getValue() + 11); eng2AgentTimerMakeTimer.start(); } }, 0, 0); +setlistener("/systems/fire/engine2/disch1", func() { + if (getprop("/systems/fire/engine2/disch1") == 1) { + eng2Agent2TimerMakeTimer.stop(); + eng2Agent2Timer.setValue(30); + eng2Agent2TimerTime.setValue(elapsedTime.getValue() + 31); + eng2Agent2TimerMakeTimer.start(); + } +}, 0, 0); + eng2AgentTimerMakeTimerFunc = func() { if (eng2AgentTimer.getValue() > 0) { var eng2Time = eng2AgentTimerTime.getValue(); @@ -556,6 +589,17 @@ eng2AgentTimerMakeTimerFunc = func() { } } +eng2Agent2TimerMakeTimerFunc = func() { + if (eng2Agent2Timer.getValue() > 0) { + var eng2Time2 = eng2AgentTimerTime.getValue(); + var etEng22 = elapsedTime.getValue(); + var timeToSetEng22 = eng2Time2 - etEng22; + eng2Agent2Timer.setValue(timeToSetEng22); + } else { + eng2Agent2TimerMakeTimer.stop(); + } +} + setlistener("/controls/APU/fire-btn", func() { if (getprop("/controls/APU/fire-btn") == 1) { ecam.shutUpYou(); @@ -641,4 +685,6 @@ var update_fire = func() { var fire_timer = maketimer(0.2, update_fire); var eng1AgentTimerMakeTimer = maketimer(0.1, eng1AgentTimerMakeTimerFunc); var eng2AgentTimerMakeTimer = maketimer(0.1, eng2AgentTimerMakeTimerFunc); +var eng1Agent2TimerMakeTimer = maketimer(0.1, eng1Agent2TimerMakeTimerFunc); +var eng2Agent2TimerMakeTimer = maketimer(0.1, eng2Agent2TimerMakeTimerFunc); var apuAgentTimerMakeTimer = maketimer(0.1, apuAgentTimerMakeTimerFunc); \ No newline at end of file