1
0
Fork 0

Rework the system display handler to properly handle failures and manual calling of pages

This commit is contained in:
legoboyvdlp R 2021-06-21 16:38:22 +01:00
parent 0c72d737ff
commit 01018ef743
6 changed files with 357 additions and 153 deletions

View file

@ -4656,6 +4656,7 @@
<file>Aircraft/A320-family/Nasal/Systems/tyresmoke.nas</file>
</systems>
<ecam>
<file>Aircraft/A320-family/Nasal/ECAM/SystemDisplay.nas</file>
<file>Aircraft/A320-family/Nasal/ECAM/ECAM-main.nas</file>
<file>Aircraft/A320-family/Nasal/ECAM/ECAM-controller.nas</file>
<file>Aircraft/A320-family/Nasal/ECAM/ECAM-logic.nas</file>

View file

@ -2157,7 +2157,7 @@
</greater-than-equals>
</condition>
<command>nasal</command>
<script>ecam.ECAMControlPanel.sysPageBtn("sts");</script>
<script>ecam.ECAMControlPanel.stsBtn();</script>
</binding>
</action>
</animation>
@ -2176,7 +2176,7 @@
</greater-than-equals>
</condition>
<command>nasal</command>
<script>ecam.ECAMControlPanel.sysPageBtn("apu");</script>
<script>ecam.ECAMControlPanel.sysPageBtn("apuPage");</script>
</binding>
</action>
</animation>
@ -2195,7 +2195,7 @@
</greater-than-equals>
</condition>
<command>nasal</command>
<script>ecam.ECAMControlPanel.sysPageBtn("bleed");</script>
<script>ecam.ECAMControlPanel.sysPageBtn("bleedPage");</script>
</binding>
</action>
</animation>
@ -2214,7 +2214,7 @@
</greater-than-equals>
</condition>
<command>nasal</command>
<script>ecam.ECAMControlPanel.sysPageBtn("press");</script>
<script>ecam.ECAMControlPanel.sysPageBtn("cabPressPage");</script>
</binding>
</action>
</animation>
@ -2233,7 +2233,7 @@
</greater-than-equals>
</condition>
<command>nasal</command>
<script>ecam.ECAMControlPanel.sysPageBtn("elec");</script>
<script>ecam.ECAMControlPanel.sysPageBtn("elecPage");</script>
</binding>
</action>
</animation>
@ -2252,7 +2252,7 @@
</greater-than-equals>
</condition>
<command>nasal</command>
<script>ecam.ECAMControlPanel.sysPageBtn("hyd");</script>
<script>ecam.ECAMControlPanel.sysPageBtn("hydraulicPage");</script>
</binding>
</action>
</animation>
@ -2271,7 +2271,7 @@
</greater-than-equals>
</condition>
<command>nasal</command>
<script>ecam.ECAMControlPanel.sysPageBtn("fuel");</script>
<script>ecam.ECAMControlPanel.sysPageBtn("fuelPage");</script>
</binding>
</action>
</animation>
@ -2290,7 +2290,7 @@
</greater-than-equals>
</condition>
<command>nasal</command>
<script>ecam.ECAMControlPanel.sysPageBtn("eng");</script>
<script>ecam.ECAMControlPanel.sysPageBtn("enginePage");</script>
</binding>
</action>
</animation>
@ -2309,7 +2309,7 @@
</greater-than-equals>
</condition>
<command>nasal</command>
<script>ecam.ECAMControlPanel.sysPageBtn("cond");</script>
<script>ecam.ECAMControlPanel.sysPageBtn("condPage");</script>
</binding>
</action>
</animation>
@ -2328,7 +2328,7 @@
</greater-than-equals>
</condition>
<command>nasal</command>
<script>ecam.ECAMControlPanel.sysPageBtn("door");</script>
<script>ecam.ECAMControlPanel.sysPageBtn("doorPage");</script>
</binding>
</action>
</animation>
@ -2347,7 +2347,7 @@
</greater-than-equals>
</condition>
<command>nasal</command>
<script>ecam.ECAMControlPanel.sysPageBtn("wheel");</script>
<script>ecam.ECAMControlPanel.sysPageBtn("wheelPage");</script>
</binding>
</action>
</animation>
@ -2366,7 +2366,7 @@
</greater-than-equals>
</condition>
<command>nasal</command>
<script>ecam.ECAMControlPanel.sysPageBtn("fctl");</script>
<script>ecam.ECAMControlPanel.sysPageBtn("fctlPage");</script>
</binding>
</action>
</animation>

View file

@ -5,9 +5,6 @@
var ap_active = 0;
var athr_active = 0;
var engModeSel = 0;
var APUMaster = 0;
var APURPM = 0;
var apOffTime = props.globals.initNode("/ECAM/warnings/ap-off-time", 0, "INT");
var athrOffTime = props.globals.initNode("/ECAM/warnings/athr-off-time", 0, "INT");
var engStrtTimeSw = props.globals.initNode("/ECAM/engine-start-time-switch", 0, "BOOL");
@ -28,6 +25,7 @@ var ECAM = {
engStrtTime.setValue(0);
apWarnNode.setValue(0);
athrWarnNode.setValue(0);
SystemDisplayController.init();
me.reset();
},
update_items: [
@ -77,7 +75,6 @@ var ECAM = {
setprop("ECAM/rightmsg/linec" ~ i, "w");
}
page.setValue("door");
me.lights.apu.setValue(0);
me.lights.bleed.setValue(0);
me.lights.cond.setValue(0);
@ -124,10 +121,8 @@ var ECAM = {
update_item.update(notification);
}
SystemDisplay.update(notification);
if (me._cachePage != SystemDisplay.page) {
me.updateSDPage(SystemDisplay.page);
if (me._cachePage != SystemDisplayController.displayedPage.name) {
me.updateSDPage(SystemDisplayController.displayedPage.name);
}
},
updateSDPage: func(newPage) {
@ -139,128 +134,9 @@ var ECAM = {
},
};
var SystemDisplay = {
page: "",
manShownPage: 0,
failShownPage: 0,
APU10sec: 9,
eng10sec: 9,
fctl20sc: 9,
_apuTime: 0,
_engTime: 0,
_fctlTime: 0,
failCall: func(page) {
if (me.manShownPage) {
me.manShownPage = 0;
ECAMControlPanel.lightOff(me.page);
}
ECAMControlPanel.lightOn(page);
me.page = page;
me.failShownPage = 1;
},
manCall: func(page) {
ECAMControlPanel.lightOff(me.page);
ECAMControlPanel.lightOn(page);
me.page = page;
me.manShownPage = 1;
},
autoCall: func(page) {
if (me.manShownPage or me.failShownPage) { return; }
if (me.page != page) {
me.page = page;
}
},
update: func(notification) {
APUMaster = systems.APUNodes.Controls.master.getValue();
APURPM = pts.APU.rpm.getValue();
engModeSel = pts.Controls.Engines.startSw.getValue();
if (APUMaster == 1 and me.APU10sec != 1) {
me.autoCall("apu");
me.fctl20sec = 0;
if (me.APU10sec == 9 and APURPM >= 95.0) {
me.APU10sec = 0;
me._apuTime = notification.elapsedTime;
}
if (me.APU10sec != 9 and notification.elapsedTime > me._apuTime + 10) {
me.APU10sec = 1;
}
} elsif (engModeSel == 0 or engModeSel == 2 or (engModeSel == 1 and me.eng10sec == 0)) {
me.autoCall("eng");
me.fctl20sec = 0;
if (me.eng10sec == 9 and engModeSel == 1) {
me.eng10sec = 0;
me._engTime = notification.elapsedTime;
}
if (me.eng10sec != 9 and notification.elapsedTime > me._engTime + 10) {
me.eng10sec = 1;
}
} else {
# Reset variables
if (APUMaster == 0) {
me.APU10sec = 9;
}
me.eng10sec = 9;
# Phase logic
if (notification.FWCPhase == 1) {
me.autoCall("door");
me.fctl20sec = 9;
} elsif (notification.FWCPhase == 2) {
if (notification.aileronFBW >= 0.15 or notification.elevatorFBW >= 0.15 and me.fctl20sec == 9) {
me.autoCall("fctl");
if (me.fctl20sec == 9) {
me.fctl20sec = 0;
me._fctlTime = notification.elapsedTime;
}
if (me.fctl20sec != 9 and notification.elapsedTime > me._fctlTime + 20) {
me.fctl20sec = 1;
}
} elsif (me.fctl20sec == 0) {
if (me.fctl20sec != 9 and notification.elapsedTime > me._fctlTime + 20) {
me.fctl20sec = 1;
}
} else {
me.autoCall("wheel");
me.fctl20sec = 9;
}
} elsif (notification.FWCPhase >= 3 and notification.FWCPhase <= 5) {
me.autoCall("eng");
me.fctl20sec = 9;
} elsif (notification.FWCPhase == 6) {
if (notification.gearLever and notification.agl <= 16000) {
me.autoCall("wheel");
} else {
me.autoCall("crz");
}
me.fctl20sec = 9;
} elsif (notification.FWCPhase >= 7 and notification.FWCPhase <= 9) {
me.autoCall("wheel");
me.fctl20sec = 9;
} elsif (notification.FWCPhase == 10) {
me.autoCall("door");
me.fctl20sec = 9;
}
}
},
};
var ECAMControlPanel = {
sysPageBtn: func(page) {
if (SystemDisplay.page != page) {
SystemDisplay.manCall(page);
} else {
me.lightOff(SystemDisplay.page);
SystemDisplay.manShownPage = 0;
}
SystemDisplayController.manCall(page);
},
rclBtn: func() {
ecam.ECAM_controller.recall();
@ -278,22 +154,13 @@ var ECAMControlPanel = {
return;
}
if (SystemDisplay.manShownPage) {
me.lightOff(SystemDisplay.page);
SystemDisplay.manShownPage = 0;
return;
}
if (SystemDisplay.failShownPage) {
me.lightOff(SystemDisplay.page);
SystemDisplay.failShownPage = 0;
return;
}
SystemDisplayController.manCall("CLR");
ecam.ECAM_controller.clear();
},
stsBtn: func() {
SystemDisplay.manCall("sts");
if (SystemDisplayController.displayedPage.name != "statusPage") {
SystemDisplayController.manCall("statusPage");
}
},
allBtn: func() {
# todo

View file

@ -0,0 +1,332 @@
var Page = {
new: func(name) {
var page = {parents:[Page]};
page.name = name;
return page;
},
};
var SystemDisplayController = {
PageList: {
apuPage: Page.new("apu"),
bleedPage: Page.new("bleed"),
cabPressPage: Page.new("press"),
condPage: Page.new("cond"),
cruisePage: Page.new("cruise"),
doorPage: Page.new("door"),
enginePage: Page.new("eng"),
elecPage: Page.new("elec"),
fctlPage: Page.new("fctl"),
fuelPage: Page.new("fuel"),
hydraulicPage: Page.new("hyd"),
statusPage: Page.new("sts"),
wheelPage: Page.new("wheel"),
},
displayedPage: nil,
lastDisplayedPage: nil,
lastMode: nil,
mode: 0, # 0 = man, 1 = warning, 2 = advisory (not used yet), 3 = auto
tempFWCPhase: nil,
tempElapsedTime: nil,
tempEngineModeSel: nil,
init: func() {
me.displayedPage = me.PageList.doorPage;
ECAMTimer.start();
},
autoCallLoop: func() {
me.tempFWCPhase = pts.ECAM.fwcWarningPhase.getValue();
if (me.Display.APU) {
me.displayedPage = me.PageList.apuPage;
} else if (me.Display.Engine) {
me.displayedPage = me.PageList.enginePage;
} else if (me.tempFWCPhase == 1) {
if (me.Display.Elec) {
me.displayedPage = me.PageList.elecPage;
} else {
me.displayedPage = me.PageList.doorPage;
}
} else if (me.tempFWCPhase == 2) {
if (me.Display.Elec) {
me.displayedPage = me.PageList.elecPage;
} else if (me.Display.FCTL) {
me.displayedPage = me.PageList.fctlPage;
} else {
me.displayedPage = me.PageList.wheelPage;
}
} else if (me.tempFWCPhase == 3 or me.tempFWCPhase == 4 or me.tempFWCPhase == 5) {
me.displayedPage = me.PageList.enginePage;
} else if (me.tempFWCPhase == 6) {
if (pts.Controls.Gear.gearDown.getValue() and me.altitudeBelow16000) {
me.displayedPage = me.PageList.wheelPage;
} else if (me.Display.Cruise) {
me.displayedPage = me.PageList.cruisePage;
} else {
me.displayedPage = me.PageList.enginePage;
}
} else if (me.tempFWCPhase == 7) {
me.displayedPage = me.PageList.wheelPage;
} else if (me.tempFWCPhase == 8 or me.tempFWCPhase == 9) {
if (me.Display.Elec) {
me.displayedPage = me.PageList.elecPage;
} else {
me.displayedPage = me.PageList.wheelPage;
}
} else if (me.tempFWCPhase == 10) {
if (me.Display.Elec) {
me.displayedPage = me.PageList.elecPage;
} else {
me.displayedPage = me.PageList.doorPage;
}
}
},
Timers: {
APUTimeOn: 0,
APUTime: 0,
CruiseTime: 0,
CruiseTimeOn: 0,
EngineTime: 0,
EngineTimeStart: 0,
EngineTimeOn: 0,
FCTLTimeStart: 0,
FCTLTimeOn: 0,
FCTLTime: 0,
},
Display: {
APU: 0,
Cruise: 0,
Elec: 0,
Engine: 0,
FCTL: 0,
},
altitudeBelow16000: 0,
update: func() {
me.tempElapsedTime = pts.Sim.Time.elapsedSec.getValue();
me.altitude = pts.Position.altitudeFt.getValue();
if (me.altitude < 16000) {
if (!me.altitudeBelow16000) {
me.altitudeBelow16000 = 1;
me.autoCallLoop();
}
} else {
if (me.altitudeBelow16000) {
me.altitudeBelow16000 = 0;
me.autoCallLoop();
}
}
if (systems.ELEC.Switch.emerGenTest.getValue()) {
if (!me.Display.Elec) {
me.Display.Elec = 1;
me.autoCallLoop();
}
} else {
if (me.Display.Elec) {
me.Display.Elec = 0;
me.autoCallLoop();
}
}
if (systems.APUNodes.Controls.master.getValue()) {
if (pts.APU.rpm.getValue() > 95 and !me.Timers.APUTimeOn) {
me.Timers.APUTimeOn = 1;
me.Timers.APUTime = me.tempElapsedTime;
}
if ((me.Timers.APUTimeOn and (me.tempElapsedTime - me.Timers.APUTime) < 10) or !me.Timers.APUTimeOn) {
if (!me.Display.APU) {
me.Display.APU = 1;
me.autoCallLoop();
}
} else {
if (me.Display.APU) {
me.Display.APU = 0;
me.autoCallLoop();
}
}
} else {
me.Timers.APUTimeOn = 0;
me.Timers.APUTime = 0;
if (me.Display.APU) {
me.Display.APU = 0;
me.autoCallLoop();
}
}
if (abs(pts.Controls.Flight.aileron.getValue()) > 0.05 or abs(pts.Controls.Flight.elevator.getValue()) > 0.05 or abs(pts.Controls.Flight.rudder.getValue()) > 0.50) {
me.Timers.FCTLTimeStart = 1;
if (!me.Display.FCTL) {
me.Display.FCTL = 1;
me.autoCallLoop();
}
me.autoCallLoop();
} else {
if (!me.Timers.FCTLTimeOn and me.Timers.FCTLTimeStart) {
me.Timers.FCTLTimeOn = 1;
me.Timers.FCTLTimeStart = 0;
me.Timers.FCTLTime = me.tempElapsedTime;
} else if (me.Timers.FCTLTimeOn) {
if ((me.tempElapsedTime - me.Timers.FCTLTime) < 20) {
if (!me.Display.FCTL) {
me.Display.FCTL = 1;
me.autoCallLoop();
}
} else {
me.Timers.FCTLTimeOn = 0;
me.Timers.FCTLTime = 0;
}
} else {
if (me.Display.FCTL) {
me.Display.FCTL = 0;
me.autoCallLoop();
}
me.Timers.FCTLTime = 0;
}
}
me.tempFWCPhase = pts.ECAM.fwcWarningPhase.getValue();
if (me.tempFWCPhase == 6) {
if (!ecam.FWC.toPower.getValue() and pts.Controls.Flight.flapsPos.getValue() == 0) {
if (!me.Display.Cruise) {
me.Display.Cruise = 1;
me.autoCallLoop();
}
} else if (!me.Display.Cruise) {
if (!me.Timers.CruiseTimeOn) {
me.Timers.CruiseTimeOn = 1;
me.Timers.CruiseTime = me.tempElapsedTime;
} else {
if ((me.tempElapsedTime - me.Timers.CruiseTime) > 60) {
if (!me.Display.Cruise) {
me.Display.Cruise = 1;
me.autoCallLoop();
}
}
}
}
} else {
me.Timers.CruiseTime = 0;
me.Timers.CruiseTimeOn = 0;
if (me.Display.Cruise) {
me.Display.Cruise = 0;
me.autoCallLoop();
}
}
me.tempEngineModeSel = pts.Controls.Engines.startSw.getValue();
if (me.tempEngineModeSel == 0 or me.tempEngineModeSel == 2) {
if (!me.Display.Engine) {
me.Display.Engine = 1;
me.autoCallLoop();
}
if (me.tempEngineModeSel == 2) {
me.Timers.EngineTimeStart = 1;
}
} else {
if (me.Timers.EngineTimeStart and !me.Timers.EngineTimeOn) {
me.Timers.EngineTimeOn = 1;
me.Timers.EngineTime = me.tempElapsedTime;
}
if (me.Timers.EngineTimeOn) {
if ((me.tempElapsedTime - me.Timers.EngineTime) < 10) {
if (!me.Display.Engine) {
me.Display.Engine = 1;
me.autoCallLoop();
}
} else {
me.Timers.EngineTimeStart = 0;
me.Timers.EngineTimeOn = 0;
me.Timers.EngineTime = 0;
if (me.Display.Engine) {
me.Display.Engine = 0;
me.autoCallLoop();
}
}
} else {
if (me.Display.Engine) {
me.Display.Engine = 0;
me.autoCallLoop();
}
}
}
},
autoCall: func() {
me.mode = 3;
me.autoCallLoop();
},
failureCall: func(newPage) {
if (contains(me.PageList, newPage)) {
me.lastDisplayedPage = me.displayedPage;
me.displayedPage = me.PageList[newPage];
me.lastMode = me.mode;
me.mode = 1;
ECAMControlPanel.lightOff(me.lastDisplayedPage.name);
ECAMControlPanel.lightOn(me.displayedPage.name);
} else {
debug.dump("Attempted to set page to unknown page", newPage);
}
},
manCall: func(newPage) {
if (contains(me.PageList, newPage)) {
if (me.displayedPage == me.PageList[newPage] and me.mode != 3) {
ECAMControlPanel.lightOff(me.displayedPage.name);
me.displayedPage = me.autoCall();
} else {
ECAMControlPanel.lightOff(me.displayedPage.name);
if (me.mode == 1) {
me.lastDisplayedPage = me.displayedPage;
me.lastMode = me.mode;
}
me.displayedPage = me.PageList[newPage];
me.mode = 0;
ECAMControlPanel.lightOn(me.displayedPage.name);
}
} elsif (newPage == "CLR") {
if (me.mode == 1) {
if (me.lastMode == 0) {
ECAMControlPanel.lightOff(me.displayedPage.name);
me.displayedPage = me.lastDisplayedPage;
ECAMControlPanel.lightOn(me.displayedPage.name);
me.lastDisplayedPage = nil;
me.mode = 0;
} else {
ECAMControlPanel.lightOff(me.displayedPage.name);
me.displayedPage = me.autoCall();
}
} elsif (me.mode == 0) {
if (me.lastMode == 1) {
ECAMControlPanel.lightOff(me.displayedPage.name);
me.displayedPage = me.lastDisplayedPage;
ECAMControlPanel.lightOn(me.displayedPage.name);
me.lastDisplayedPage = nil;
me.mode = 1;
} else {
ECAMControlPanel.lightOff(me.displayedPage.name);
me.displayedPage = me.autoCall();
}
}
} else {
debug.dump("Attempted to set page to unknown page", newPage);
}
},
};
setlistener("/ECAM/warning-phase", func() {
if (SystemDisplayController.mode == 3) {
SystemDisplayController.autoCall();
}
}, 0, 0);
setlistener("/controls/gear/gear-down", func() {
if (SystemDisplayController.mode == 3) {
SystemDisplayController.autoCall();
}
}, 0, 0);
var ECAMTimer = maketimer(1, func() {
SystemDisplayController.update();
});

View file

@ -50,6 +50,7 @@ var Controls = {
aileron: props.globals.getNode("/controls/flight/aileron"),
aileronDrivesTiller: props.globals.getNode("/controls/flight/aileron-drives-tiller"),
autoCoordination: props.globals.getNode("/controls/flight/auto-coordination"),
elevator: props.globals.getNode("/controls/flight/elevator"),
elevatorTrim: props.globals.getNode("/controls/flight/elevator-trim"),
flaps: props.globals.getNode("/controls/flight/flaps"),
flapsTemp: 0,
@ -57,6 +58,7 @@ var Controls = {
flapsPos: props.globals.getNode("/controls/flight/flaps-pos"),
speedbrake: props.globals.getNode("/controls/flight/speedbrake"),
speedbrakeArm: props.globals.getNode("/controls/flight/speedbrake-arm"),
rudder: props.globals.getNode("/controls/flight/rudder"),
rudderTrim: props.globals.getNode("/controls/flight/rudder-trim"),
},
Gear: {
@ -217,6 +219,7 @@ var Orientation = {
};
var Position = {
altitudeFt: props.globals.getNode("/position/altitude-ft"),
gearAglFt: props.globals.getNode("/position/gear-agl-ft"),
latitude: props.globals.getNode("/position/latitude-deg"),
longitude: props.globals.getNode("/position/longitude-deg"),

View file

@ -182,6 +182,7 @@
</function>
<output>/systems/apu/oil/level-l</output>
</fcs_function>
</channel>
</system>