diff --git a/A320-main.xml b/A320-main.xml index 32827d87..e9b59f60 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -95,6 +95,17 @@ /systems/pitot/icing + + 1.0 + 0.95 + 1.0 + 0.741 + 0.32 + 0.741 + 0.10 + 0.02 + 0.09 + @@ -613,6 +624,10 @@ 0 + + 0 + 0 + 0 0 diff --git a/AircraftConfig/acconfig.nas b/AircraftConfig/acconfig.nas index ba269095..ccf47903 100644 --- a/AircraftConfig/acconfig.nas +++ b/AircraftConfig/acconfig.nas @@ -73,6 +73,8 @@ var failReset = func { setprop("/systems/failures/fuelmode", 0); setprop("/systems/failures/cargo-aft-fire", 0); setprop("/systems/failures/cargo-fwd-fire", 0); + setprop("/systems/failures/engine-left-fire", 0); + setprop("/systems/failures/engine-right-fire", 0); } failReset(); diff --git a/AircraftConfig/fail.xml b/AircraftConfig/fail.xml index 9550ada6..87991a31 100644 --- a/AircraftConfig/fail.xml +++ b/AircraftConfig/fail.xml @@ -487,6 +487,39 @@ true + + hbox + + + true + + + + + + true + + + + + + left + /systems/failures/engine-left-fire + + dialog-apply + + true + + + + + left + /systems/failures/engine-right-fire + + dialog-apply + + true + @@ -502,9 +535,7 @@ - - diff --git a/Models/Effects/flame.eff b/Models/Effects/flame.eff new file mode 100644 index 00000000..815a425d --- /dev/null +++ b/Models/Effects/flame.eff @@ -0,0 +1,25 @@ + + + AB-flame + Effects/thrust-flame + + /sim/model/flame/blue-base + 0.01 + /sim/model/flame/green-base + /sim/model/flame/red-base + 0 + /sim/model/flame/blue-high + /sim/model/flame/green-high + /sim/model/flame/red-high + /sim/model/flame/blue-low + /sim/model/flame/green-low + /sim/model/flame/red-low + 0.82 + 0.8 + 0.2 + 0.2 + 0.8 + 1 + 0 + + \ No newline at end of file diff --git a/Models/Instruments/OHpanel/OHpanel.xml b/Models/Instruments/OHpanel/OHpanel.xml index 02a32e9b..5c76df2c 100644 --- a/Models/Instruments/OHpanel/OHpanel.xml +++ b/Models/Instruments/OHpanel/OHpanel.xml @@ -182,21 +182,11 @@ select AftCargoIsoBtn1F AftCargoIsoBtn2O - APUFireAgtBtn1S - APUFireAgtBtn2D CargoHotAirBtn1F CargoHotAirBtn2O EmerCallBtn1C EmerCallBtn2O EmerGenInd1F - Eng1FireAgt1Btn1S - Eng1FireAgt1Btn2D - Eng1FireAgt2Btn1S - Eng1FireAgt2Btn2D - Eng2FireAgt1Btn1S - Eng2FireAgt1Btn2D - Eng2FireAgt2Btn1S - Eng2FireAgt2Btn2D EvacCommandBtn1E EvacCommandBtn2O Gen1LineBtn1S @@ -6203,6 +6193,159 @@ + + material + Eng1FireBtn + + systems/fire/engine1/warning-active + + + 1.0 + 1.0 + 1.0 + + + + + pick + Eng1FireAgt1Btn1S + Eng1FireAgt1Btn2D + Eng1FireAgt1Btn + + + false + + property-assign + controls/engines/engine[0]/agent1-btn + 1 + + + + + + pick + Eng1FireAgt2Btn1S + Eng1FireAgt2Btn2D + Eng1FireAgt2Btn + + + false + + property-assign + controls/engines/engine[0]/agent2-btn + 1 + + + + + + select + Eng1FireAgt1Btn1S + Eng1FireAgt2Btn1S + + + + controls/engines/engine[0]/fire-btn + 1 + + + /controls/fire/test-btn + 1 + + + controls/switches/annun-test + 1 + + + + + + + select + Eng1FireAgt1Btn2D + + + + /systems/fire/engine1/disch1 + 1 + + + /controls/fire/test-btn + 1 + + + controls/switches/annun-test + 1 + + + + + + + select + Eng1FireAgt2Btn2D + + + + /systems/fire/engine1/disch2 + 1 + + + /controls/fire/test-btn + 1 + + + controls/switches/annun-test + 1 + + + + + + + + pick + Eng1FireTst + Eng2FireTst + + + false + + property-assign + controls/fire/test-btn + 1 + + + + property-assign + controls/fire/test-btn + 0 + + + + + + + pick + APUFireTst + + + false + + property-assign + controls/fire/apu-test-btn + 1 + + + + property-assign + controls/fire/apu-test-btn + 0 + + + + + pick @@ -6289,6 +6432,77 @@ + + material + APUFireBtn + + systems/fire/apu/warning-active + + + 1.0 + 1.0 + 1.0 + + + + + pick + APUFireAgtBtn1S + APUFireAgtBtn2D + APUFireAgtBtn + + + false + + property-assign + controls/APU/agent-btn + 1 + + + + + + select + APUFireAgtBtn1S + + + + controls/APU/fire-btn + 1 + + + controls/fire/apu-test-btn + true + + + controls/switches/annun-test + 1 + + + + + + + select + APUFireAgtBtn2D + + + + systems/fire/apu/disch + 1 + + + controls/fire/apu-test-btn + 1 + + + controls/switches/annun-test + 1 + + + + + pick @@ -6375,6 +6589,115 @@ + + material + Eng2FireBtn + + systems/fire/engine2/warning-active + + + 1.0 + 1.0 + 1.0 + + + + + pick + Eng2FireAgt1Btn1S + Eng2FireAgt1Btn2D + Eng2FireAgt1Btn + + + false + + property-assign + controls/engines/engine[1]/agent1-btn + 1 + + + + + + pick + Eng2FireAgt2Btn1S + Eng2FireAgt2Btn2D + Eng2FireAgt2Btn + + + false + + property-assign + controls/engines/engine[1]/agent2-btn + 1 + + + + + + select + Eng2FireAgt1Btn1S + Eng2FireAgt2Btn1S + + + + controls/engines/engine[1]/fire-btn + 1 + + + controls/fire/test-btn + 1 + + + controls/switches/annun-test + 1 + + + + + + + select + Eng2FireAgt1Btn2D + + + + systems/fire/engine2/disch1 + 1 + + + controls/fire/test-btn + 1 + + + controls/switches/annun-test + 1 + + + + + + + select + Eng2FireAgt2Btn2D + + + + systems/fire/engine2/disch2 + 1 + + + controls/fire/test-btn + 1 + + + controls/switches/annun-test + 1 + + + + + pick diff --git a/Models/Wings/a320-fire-left.xml b/Models/Wings/a320-fire-left.xml new file mode 100644 index 00000000..cbb80919 --- /dev/null +++ b/Models/Wings/a320-fire-left.xml @@ -0,0 +1,35 @@ + + + + Aircraft/Generic/Effects/Thruster/thrust_flame.ac + + + scale + systems/failures/engine-left-fire + 0.2 + 0.3 + 0.3 + 0.8 + 0.8 + 0.4 + 0.7 + 0.7 + + + + select + Bounding_box + + + systems/failures/engine-left-fire + 0.8 + + + + + + Aircraft/IDG-A32X/Models/Effects/flame + Bounding_box + + + \ No newline at end of file diff --git a/Models/Wings/a320-fire-right.xml b/Models/Wings/a320-fire-right.xml new file mode 100644 index 00000000..0186c979 --- /dev/null +++ b/Models/Wings/a320-fire-right.xml @@ -0,0 +1,35 @@ + + + + Aircraft/Generic/Effects/Thruster/thrust_flame.ac + + + scale + systems/failures/engine-right-fire + 0.2 + 0.3 + 0.3 + 0.8 + 0.8 + 0.4 + 0.7 + 0.7 + + + + select + Bounding_box + + + systems/failures/engine-right-fire + 0.8 + + + + + + Aircraft/IDG-A32X/Models/Effects/flame + Bounding_box + + + \ No newline at end of file diff --git a/Models/Wings/a320.wings.cfm.xml b/Models/Wings/a320.wings.cfm.xml index cad1d559..f567faf9 100644 --- a/Models/Wings/a320.wings.cfm.xml +++ b/Models/Wings/a320.wings.cfm.xml @@ -24,7 +24,27 @@ -1.0170087 - + + + Engine.CFM.Left.FireBBox + Aircraft/IDG-A32X/Models/Wings/a320-fire-left.xml + + -1.6387912 + -5.755 + -1.0170087 + + + + + Engine.CFM.RightFireBBox + Aircraft/IDG-A32X/Models/Wings/a320-fire-right.xml + + -1.6387912 + 5.755 + -1.0170087 + + + diff --git a/Models/Wings/a320.wings.iae.xml b/Models/Wings/a320.wings.iae.xml index c8c0901f..d5ed012e 100644 --- a/Models/Wings/a320.wings.iae.xml +++ b/Models/Wings/a320.wings.iae.xml @@ -24,6 +24,26 @@ -1.0170087 + + + Engine.IAE.Left.FireBBox + Aircraft/IDG-A32X/Models/Wings/a320-fire-left.xml + + 3.2 + -5.755 + -1.15 + + + + + Engine.IAE.RightFireBBox + Aircraft/IDG-A32X/Models/Wings/a320-fire-right.xml + + 3.2 + 5.755 + -1.15 + + diff --git a/Models/Wings/a320.wings.neocfm.xml b/Models/Wings/a320.wings.neocfm.xml index 63fa1fb5..f52f79af 100644 --- a/Models/Wings/a320.wings.neocfm.xml +++ b/Models/Wings/a320.wings.neocfm.xml @@ -24,6 +24,26 @@ -1.0170087 + + + Engine.CFM.Left.FireBBox + Aircraft/IDG-A32X/Models/Wings/a320-fire-left.xml + + -1.6387912 + -5.755 + -1.0170087 + + + + + Engine.CFM.RightFireBBox + Aircraft/IDG-A32X/Models/Wings/a320-fire-right.xml + + -1.6387912 + 5.755 + -1.0170087 + + diff --git a/Models/Wings/a320.wings.neopw.xml b/Models/Wings/a320.wings.neopw.xml index 03b02064..69016fbb 100644 --- a/Models/Wings/a320.wings.neopw.xml +++ b/Models/Wings/a320.wings.neopw.xml @@ -24,6 +24,26 @@ -1.0170087 + + + Engine.PW.Left.FireBBox + Aircraft/IDG-A32X/Models/Wings/a320-fire-left.xml + + -1.6387912 + -5.755 + -1.0170087 + + + + + Engine.PW.RightFireBBox + Aircraft/IDG-A32X/Models/Wings/a320-fire-right.xml + + -1.6387912 + 5.755 + -1.0170087 + + diff --git a/Nasal/ECAM/ECAM-controller.nas b/Nasal/ECAM/ECAM-controller.nas index ed076337..185c8254 100644 --- a/Nasal/ECAM/ECAM-controller.nas +++ b/Nasal/ECAM/ECAM-controller.nas @@ -161,9 +161,14 @@ var ECAM_controller = { } # write to ECAM + var counter = 0; foreach (var w; warnings.vector) { - w.write(); + if (counter >= 9) { break; } + if (w.active == 1) { + w.write(); + counter += 1; + } } foreach (var w2; warnings.vector) { diff --git a/Nasal/ECAM/ECAM-logic.nas b/Nasal/ECAM/ECAM-logic.nas index 6a00369e..f17e46a2 100644 --- a/Nasal/ECAM/ECAM-logic.nas +++ b/Nasal/ECAM/ECAM-logic.nas @@ -41,7 +41,7 @@ var messages_priority_3 = func { if (phaseVar >= 5 and phaseVar <= 7 and dualFailNode.getBoolValue()) { dualFail.active = 1; - } elsif (dualFailbatt.clearFlag == 1) { + } elsif (dualFailbatt.clearFlag == 1 or !dualFailNode.getBoolValue()) { ECAM_controller.warningReset(dualFail); dualFailFACActive = 1; # reset FAC local variable @@ -190,6 +190,95 @@ var messages_priority_3 = func { ECAM_controller.warningReset(dualFailbatt); ECAM_controller.warningReset(dualFailtouch); } + } else { + ECAM_controller.warningReset(dualFailModeSel); + ECAM_controller.warningReset(dualFailLevers); + ECAM_controller.warningReset(dualFailRelightSPD); + ECAM_controller.warningReset(dualFailRelightSPDCFM); + ECAM_controller.warningReset(dualFailElec); + ECAM_controller.warningReset(dualFailRadio); + ECAM_controller.warningReset(dualFailFAC); + ECAM_controller.warningReset(dualFailRelight); + ECAM_controller.warningReset(dualFailMasters); + ECAM_controller.warningReset(dualFailSuccess); + ECAM_controller.warningReset(dualFailSPDGD); + ECAM_controller.warningReset(dualFailAPU); + ECAM_controller.warningReset(dualFailAPUwing); + ECAM_controller.warningReset(dualFailAPUbleed); + ECAM_controller.warningReset(dualFailMastersAPU); + ECAM_controller.warningReset(dualFailAPPR); + ECAM_controller.warningReset(dualFailflap); + ECAM_controller.warningReset(dualFailcabin); + ECAM_controller.warningReset(dualFailrudd); + ECAM_controller.warningReset(dualFailgear); + ECAM_controller.warningReset(dualFail5000); + ECAM_controller.warningReset(dualFailfinalspeed); + ECAM_controller.warningReset(dualFailmasteroff); + ECAM_controller.warningReset(dualFailapuoff); + ECAM_controller.warningReset(dualFailevac); + ECAM_controller.warningReset(dualFailbatt); + ECAM_controller.warningReset(dualFailtouch); + } + + # ENG FIRE + if (eng1FireFlAgent2.clearFlag == 0 and getprop("/systems/fire/engine1/warning-active") == 1 and phaseVar >= 5 and phaseVar <= 7) { + eng1FireFl.active = 1; + } else { + ECAM_controller.warningReset(eng1FireFl); + } + + if (eng1FireGnevacBat.clearFlag == 0 and getprop("/systems/fire/engine1/warning-active") == 1 and (phaseVar < 5 or phaseVar > 7)) { + eng1FireGn.active = 1; + } else { + ECAM_controller.warningReset(eng1FireGn); + } + + if (eng2FireFlAgent2.clearFlag == 0 and getprop("/systems/fire/engine2/warning-active") == 1 and phaseVar >= 5 and phaseVar <= 7) { + eng2FireFl.active = 1; + } else { + ECAM_controller.warningReset(eng2FireFl); + } + + if (eng2FireGnevacBat.clearFlag == 0 and getprop("/systems/fire/engine2/warning-active") == 1 and (phaseVar < 5 or phaseVar > 7)) { + eng2FireGn.active = 1; + } else { + ECAM_controller.warningReset(eng2FireGn); + } + + if (eng1FireFl.active == 1) { + eng1FireFllever.active = 1; + eng1FireFlmaster.active = 1; + eng1FireFlPB.active = 1; + eng1FireFlAgent1.active = 1; + eng1FireFlATC.active = 1; + eng1FireFl30Sec.active = 1; + eng1FireFlAgent2.active = 1; + } else { + ECAM_controller.warningReset(eng1FireFllever); + ECAM_controller.warningReset(eng1FireFlmaster); + ECAM_controller.warningReset(eng1FireFlPB); + ECAM_controller.warningReset(eng1FireFlAgent1); + ECAM_controller.warningReset(eng1FireFlATC); + ECAM_controller.warningReset(eng1FireFl30Sec); + ECAM_controller.warningReset(eng1FireFlAgent2); + } + + 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; + } else { + ECAM_controller.warningReset(eng2FireFllever); + ECAM_controller.warningReset(eng2FireFlmaster); + ECAM_controller.warningReset(eng2FireFlPB); + ECAM_controller.warningReset(eng2FireFlAgent1); + ECAM_controller.warningReset(eng2FireFlATC); + ECAM_controller.warningReset(eng2FireFl30Sec); + ECAM_controller.warningReset(eng2FireFlAgent2); } # CONFIG diff --git a/Nasal/ECAM/ECAM-messages.nas b/Nasal/ECAM/ECAM-messages.nas index 8f49ea92..f3010e28 100644 --- a/Nasal/ECAM/ECAM-messages.nas +++ b/Nasal/ECAM/ECAM-messages.nas @@ -42,6 +42,60 @@ var warnings = std.Vector.new([ var dualFailevac = warning.new(msg: " -EVAC..........INITIATE", colour: "c"), var dualFailbatt = warning.new(msg: " -BAT 1+2............OFF", colour: "c"), + # ENG 1 FIRE (flight) + var eng1FireFl = warning.new(msg: "ENG 1 FIRE", colour: "r", aural: 0, light: 0, hasSubmsg: 1), + 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 eng1FireFlATC = warning.new(msg: " -ATC.............NOTIFY", colour: "c"), + var eng1FireFl30Sec = warning.new(msg: " •IF FIRE AFTER 30 S:", colour: "w"), + var eng1FireFlAgent2 = warning.new(msg: " -AGENT 2..........DISCH", colour: "c"), + + # ENG 1 FIRE (ground) + var eng1FireGn = warning.new(msg: "ENG 1 FIRE", colour: "r", aural: 0, light: 0, hasSubmsg: 1), + var eng1FireGnlever = warning.new(msg: " -THR LEVER 1.......IDLE", colour: "c"), + var eng1FireGnstopped = warning.new(msg: " •WHEN A/C IS STOPPED:", colour: "w"), + var eng1FireGnparkbrk = warning.new(msg: " -PARKING BRK.........ON", colour: "c"), + var eng1FireGnmaster = warning.new(msg: " -ENG MASTER 1.......OFF", colour: "c"), + var eng1FireGnPB = warning.new(msg: " -ENG 1 FIRE P/B....PUSH", colour: "c"), + var eng1FireGnAgent1 = warning.new(msg: " -AGENT 1..........DISCH", colour: "c"), + var eng1FireGnAgent2 = warning.new(msg: " -AGENT 2..........DISCH", colour: "c"), + var eng1FireGnmaster2 = warning.new(msg: " -ENG MASTER 2.......OFF", colour: "c"), + var eng1FireGnATC = warning.new(msg: " -ATC.............NOTIFY", colour: "c"), + var eng1FireGncrew = warning.new(msg: " -CABIN CREW.......ALERT", colour: "c"), + var eng1FireGnevac = warning.new(msg: " •IF EVAC RQRD:", colour: "w"), + var eng1FireGnevacSw = warning.new(msg: " -EVAC COMMAND........ON", colour: "c"), + var eng1FireGnevacApu = warning.new(msg: " -APU MASTER SW......OFF", colour: "c"), + var eng1FireGnevacBat = warning.new(msg: " -BAT 1+2............OFF", colour: "c"), + + # ENG 2 FIRE (flight) + var eng2FireFl = warning.new(msg: "ENG 2 FIRE", colour: "r", aural: 0, light: 0, hasSubmsg: 1), + var eng2FireFllever = warning.new(msg: " -THR LEVER 2.......IDLE", colour: "c"), + var eng2FireFlmaster = warning.new(msg: " -ENG MASTER 2.......OFF", colour: "c"), + var eng2FireFlPB = warning.new(msg: " -ENG 2 FIRE P/B....PUSH", colour: "c"), + var eng2FireFlAgent1 = warning.new(msg: " -AGENT 1 AFT 10 S.DISCH", colour: "w"), + var eng2FireFlATC = warning.new(msg: " -ATC.............NOTIFY", colour: "c"), + var eng2FireFl30Sec = warning.new(msg: " •IF FIRE AFTER 30 S:", colour: "w"), + var eng2FireFlAgent2 = warning.new(msg: " -AGENT 2..........DISCH", colour: "c"), + + # ENG 2 FIRE (ground) + var eng2FireGn = warning.new(msg: "ENG 2 FIRE", colour: "r", aural: 0, light: 0, hasSubmsg: 1), + var eng2FireGnlever = warning.new(msg: " -THR LEVER 2.......IDLE", colour: "c"), + var eng2FireGnstopped = warning.new(msg: " •WHEN A/C IS STOPPED:", colour: "w"), + var eng2FireGnparkbrk = warning.new(msg: " -PARKING BRK.........ON", colour: "c"), + var eng2FireGnmaster = warning.new(msg: " -ENG MASTER 2.......OFF", colour: "c"), + var eng2FireGnPB = warning.new(msg: " -ENG 1 FIRE P/B....PUSH", colour: "c"), + var eng2FireGnAgent1 = warning.new(msg: " -AGENT 1..........DISCH", colour: "c"), + var eng2FireGnAgent2 = warning.new(msg: " -AGENT 2..........DISCH", colour: "c"), + var eng2FireGnmaster2 = warning.new(msg: " -ENG MASTER 1.......OFF", colour: "c"), + var eng2FireGnATC = warning.new(msg: " -ATC.............NOTIFY", colour: "c"), + var eng2FireGncrew = warning.new(msg: " -CABIN CREW.......ALERT", colour: "c"), + var eng2FireGnevac = warning.new(msg: " •IF EVAC RQRD:", colour: "w"), + var eng2FireGnevacSw = warning.new(msg: " -EVAC COMMAND........ON", colour: "c"), + var eng2FireGnevacApu = warning.new(msg: " -APU MASTER SW......OFF", colour: "c"), + var eng2FireGnevacBat = warning.new(msg: " -BAT 1+2............OFF", colour: "c"), + # Config var slats_config = warning.new(msg: "CONFIG", colour: "r", aural: 0, light: 0), var slats_config_1 = warning.new(msg: "SLATS NOT IN T.O. CONFIG", colour: "r", aural: 0, light: 0), diff --git a/Nasal/fire.nas b/Nasal/fire.nas index d888ff3a..57e8721b 100644 --- a/Nasal/fire.nas +++ b/Nasal/fire.nas @@ -27,6 +27,17 @@ var dc1 = 0; var dc2 = 0; var dcbat = 0; var pause = 0; +var et = 0; + +var elapsedTime = props.globals.getNode("/sim/time/elapsed-sec"); +var apuTestBtn = props.globals.getNode("/controls/fire/apu-test-btn", 1); +var testBtn = props.globals.getNode("/controls/fire/test-btn", 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 wow = props.globals.getNode("/fdm/jsbsim/position/wow", 1); +var dcbatNode = props.globals.getNode("systems/electrical/bus/dcbat", 1); +var dcessNode = props.globals.getNode("systems/electrical/bus/dc-ess", 1); var fire_init = func { setprop("/controls/OH/protectors/fwddisch", 0); @@ -78,7 +89,7 @@ var master_fire = func { state = getprop("/controls/fire/cargo/test/state"); dc1 = getprop("/systems/electrical/bus/dc1"); dc2 = getprop("/systems/electrical/bus/dc2"); - dcbat = getprop("/systems/electrical/bus/dcbat"); + dcbat = dcbatNode.getValue(); pause = getprop("/sim/freeze/master"); ############### @@ -171,7 +182,6 @@ var master_fire = func { setprop("/controls/fire/cargo/fwddischLight", 0); setprop("/controls/fire/cargo/aftdischLight", 0); } - } ################### @@ -185,7 +195,7 @@ setlistener("/systems/failures/cargo-fwd-fire", func() { } else { setprop("/controls/fire/cargo/fwdsmokeLight", 0); } -}, 0, ); +}, 0, 0); setlistener("/systems/failures/cargo-aft-fire", func() { if (getprop("/systems/failures/cargo-aft-fire")) { @@ -194,8 +204,280 @@ setlistener("/systems/failures/cargo-aft-fire", func() { } else { setprop("/controls/fire/cargo/aftsmokeLight", 0); } -}, 0, ); +}, 0, 0); +################### +# Engine Fire # +################### +var engFireDetectorUnit = { + sys: 0, + active: 0, + loopOne: 0, + loopTwo: 0, + condition: 100, + new: func(sys) { + var eF = {parents:[engFireDetectorUnit]}; + eF.sys = sys; + eF.active = 0; + eF.loopOne = 0; + eF.loopTwo = 0; + + return eF; + }, + update: func() { + foreach(var detector; detectorLoops.vector) { + detector.updateTemp(detector.sys, detector.type); + } + + if ((me.loopOne == 1 and me.loopOne == 2) or (me.loopOne == 9 and me.loopOne == 1) or (me.loopOne == 1 and me.loopOne == 9)) { + me.TriggerWarning(me.sys); + } + }, + receiveSignal: func(type) { + if (type == 1 and me.loopOne != 9) { + me.loopOne = 1; + } elsif (type == 2 and me.loopTwo != 9) { + me.loopTwo = 1; + } + }, + fail: func(loop) { + if (loop != 1 and loop != 2) { return; } + + if (loop == 1) { me.loopOne = 9; } + else { me.loopTwo = 9; } + + me.startFailTimer(loop); + }, + startFailTimer: func(loop) { + if (me.sys != 2) { + if (loop == 1) { + propsNasFireTime[sys].setValue(elapsedTime.getValue()); + } elsif (loop == 2) { + propsNasFireTime[sys + 1].setValue(elapsedTime.getValue()); + } + } else { + if (loop == 1) { + propsNasFireTime[4].setValue(elapsedTime.getValue()); + } elsif (loop == 2) { + propsNasFireTime[5].setValue(elapsedTime.getValue()); + } + } + + if (!fireTimer.isRunning) { + fireTimer.start(); + } + }, + TriggerWarning: func(system) { + if (system == 0) { + eng1FireWarn.setBoolValue(1); + } elsif (system == 1) { + eng2FireWarn.setBoolValue(1); + } elsif (system == 2) { + apuFireWarn.setBoolValue(1); + if (wow.getValue() == 1) { + extinguisherBottles[4].discharge(); + } + } + } +}; + +var detectorLoop = { + sys: 9, + type: 0, + temperature: "", + new: func(type, sys, temperature) { + var dL = {parents:[detectorLoop]}; + dL.sys = sys; + dL.type = type; + dL.temperature = temperature; + + return dL; + }, + updateTemp: func(system, typeLoop) { + var index = 0; + if (system == 1) { index += 2 } + elsif (system == 2) { index += 4 } + + if (typeLoop == 1) { index += 1 } + + if (propsNasFire[index].getValue() > 250) { + me.sendSignal(system,typeLoop); + } + }, + sendSignal: func(system,typeLoop) { + engFireDetectorUnits[system].receiveSignal(typeLoop); + } +}; + +var extinguisherBottle = { + quantity: 100, + squib: 0, + lightProp: "", + elecProp: "", + new: func(lightProp, elecProp) { + var eB = {parents:[extinguisherBottle]}; + eB.quantity = 100; + eB.squib = 0; + eB.lightProp = props.globals.getNode(lightProp, 1); + eB.elecProp = props.globals.getNode(elecProp, 1); + return eB; + }, + emptyBottle: func() { + me.quantity = me.quantity - 1; + if (me.quantity > 0) { settimer(me.emptyBottle, 0.05); } + else { + me.lightProp.setValue(1); + } + }, + discharge: func() { + if (me.elecProp.getValue() < 25) { return; } + me.squib = 1; + me.emptyBottle(); + } +}; + +# If two loops fail within five seconds then assume there is a fire + +var propsNasFireTime = std.Vector.new([ +props.globals.getNode("/systems/fire/engine1/loop1-failtime", 1), props.globals.getNode("/systems/fire/engine1/loop2-failtime", 1), +props.globals.getNode("/systems/fire/engine2/loop1-failtime", 1), props.globals.getNode("/systems/fire/engine2/loop2-failtime", 1), +props.globals.getNode("/systems/fire/apu/loop1-failtime", 1), props.globals.getNode("/systems/fire/apu/loop2-failtime", 1) +]); + +var checkTimeFire1 = func() { + et = elapsedTime.getValue(); + var loop1 = propsNasFireTime[0].getValue(); + var loop2 = propsNasFireTime[1].getValue(); + + if ((loop1 != 0 and et > loop1 + 5) or (loop2 != 0 and et > loop2 + 5)) { + fireTimer1.stop(); + loop1.setValue(0); + loop2.setValue(0); + } + + if (engFireDetectorUnits[0].loop1 == 9 and engFireDetectorUnits[0].loop2 == 9) { + fireTimer1.stop(); + engFireDetectorUnits[0].TriggerWarning(engFireDetectorUnits[0].sys); + loop1.setValue(0); + loop2.setValue(0); + } +} + +var checkTimeFire2 = func() { + et = elapsedTime.getValue(); + var loop3 = propsNasFireTime[2].getValue(); + var loop4 = propsNasFireTime[3].getValue(); + + if ((loop3 != 0 and et > loop3 + 5) or (loop4 != 0 and et > loop4 + 5)) { + fireTimer2.stop(); + loop3.setValue(0); + loop4.setValue(0); + } + + if (engFireDetectorUnits[1].loop1 == 9 and engFireDetectorUnits[1].loop2 == 9) { + fireTimer2.stop(); + engFireDetectorUnits[1].TriggerWarning(engFireDetectorUnits[1].sys); + loop3.setValue(0); + loop4.setValue(0); + } +} +var checkTimeFire3 = func() { + et = elapsedTime.getValue(); + var loop4 = propsNasFireTime[3].getValue(); + var loop5 = propsNasFireTime[4].getValue(); + + if ((loop4 != 0 and et > loop4 + 5) or (loop5 != 0 and et > loop5 + 5)) { + fireTimer3.stop(); + loop4.setValue(0); + loop5.setValue(0); + } + + if (engFireDetectorUnits[2].loop1 == 9 and engFireDetectorUnits[2].loop2 == 9) { + fireTimer3.stop(); + engFireDetectorUnits[2].TriggerWarning(engFireDetectorUnits[2].sys); + loop4.setValue(0); + loop5.setValue(0); + } +} + +var fireTimer1 = maketimer(0.25, checkTimeFire1); +fireTimer1.simulatedTime = 1; +var fireTimer2 = maketimer(0.25, checkTimeFire2); +fireTimer2.simulatedTime = 1; +var fireTimer3 = maketimer(0.25, checkTimeFire3); +fireTimer3.simulatedTime = 1; + +# Create engine fire systems +var engFireDetectorUnits = std.Vector.new([ engFireDetectorUnit.new(0), engFireDetectorUnit.new(1), engFireDetectorUnit.new(2) ]); + +# Create detector loops +var detectorLoops = std.Vector.new([ +detectorLoop.new(0, 0, "/systems/fire/engine1/temperature"), detectorLoop.new(1, 0, "/systems/fire/engine1/temperature"), +detectorLoop.new(0, 1, "/systems/fire/engine2/temperature"), detectorLoop.new(1, 1, "/systems/fire/engine2/temperature"), +detectorLoop.new(0, 2, "/systems/fire/apu/temperature"), detectorLoop.new(1, 2, "/systems/fire/apu/temperature") +]); + +# Create extinguisher bottles +var extinguisherBottles = std.Vector.new([extinguisherBottle.new("/systems/fire/engine1/disch1", "/systems/electrical/bus/dcbat"), extinguisherBottle.new("/systems/fire/engine1/disch2", "/systems/electrical/bus/dc2"), +extinguisherBottle.new("/systems/fire/engine2/disch1", "/systems/electrical/bus/dcbat"), extinguisherBottle.new("/systems/fire/engine2/disch2", "/systems/electrical/bus/dc2"), extinguisherBottle.new("/systems/fire/apu/disch", "/systems/electrical/bus/dcbat") ]); + +# Props.nas helper +var propsNasFire = std.Vector.new(); +foreach (detectorLoop; detectorLoops.vector) { + propsNasFire.append(props.globals.getNode(detectorLoop.temperature)); +}; + +# Setlistener helper +var createFireBottleListener = func(prop, index) { + if (index >= extinguisherBottles.size()) { + print("Error - calling listener on non-existent fire extinguisher bottle, index: " ~ index); + return; + } + + setlistener(prop, func() { + if (getprop(prop) == 1) { + extinguisherBottles.vector[index].discharge(); + } + }, 0, 0); +} + +# Listeners +setlistener("/controls/engines/engine[0]/fire-btn", func() { eng1FireWarn.setBoolValue(0); }, 0, 0); +setlistener("/controls/engines/engine[1]/fire-btn", func() { eng2FireWarn.setBoolValue(0); }, 0, 0); +setlistener("/controls/APU/fire-btn", func() { apuFireWarn.setBoolValue(0); }, 0, 0); + +setlistener("/controls/fire/test-btn", func() { + if (testBtn.getValue() == 1) { + if (dcbatNode.getValue() > 25 or dcessNode.getValue() > 25) { + eng1FireWarn.setBoolValue(1); + eng2FireWarn.setBoolValue(1); + } else { + eng1FireWarn.setBoolValue(0); + eng2FireWarn.setBoolValue(0); + } + } else { + eng1FireWarn.setBoolValue(0); + eng2FireWarn.setBoolValue(0); + } +}, 0, 0); + +setlistener("/controls/fire/apu-test-btn", func() { + if (apuTestBtn.getValue() == 1) { + if (dcbatNode.getValue() > 25 or dcessNode.getValue() > 25) { + apuFireWarn.setBoolValue(1); + } else { + apuFireWarn.setBoolValue(0); + } + } else { + apuFireWarn.setBoolValue(0); + } +}, 0, 0); + +createFireBottleListener("/controls/engines/engine[0]/agent1-btn", 0); +createFireBottleListener("/controls/engines/engine[0]/agent2-btn", 1); +createFireBottleListener("/controls/engines/engine[1]/agent1-btn", 2); +createFireBottleListener("/controls/engines/engine[1]/agent2-btn", 3); +createFireBottleListener("/controls/APU/agent-btn", 4); ################### # Update Function # ################### diff --git a/Systems/libraries.xml b/Systems/libraries.xml index ac181f7e..d8a43bf6 100644 --- a/Systems/libraries.xml +++ b/Systems/libraries.xml @@ -1169,5 +1169,4 @@ /instrumentation/ddrmi/flag-2 0.64 -