From ccbfee96e557066b1272404d36a2842b0477e80f Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sat, 23 May 2020 12:16:20 +0100 Subject: [PATCH] Port to new method --- Models/Instruments/MCDU/MCDU.nas | 35 +++--- Nasal/FMGC/flightplan-waypoints.nas | 3 +- Nasal/FMGC/mcdu-messages.nas | 59 +++++----- Nasal/MCDU/ARRIVAL.nas | 21 ++-- Nasal/MCDU/CLOSESTAIRPORT.nas | 7 +- Nasal/MCDU/DEPARTURE.nas | 21 ++-- Nasal/MCDU/DIRTO.nas | 21 ++-- Nasal/MCDU/F-PLN.nas | 50 +++------ Nasal/MCDU/FUELPRED.nas | 63 +++++------ Nasal/MCDU/INITA.nas | 67 ++++++------ Nasal/MCDU/INITB.nas | 89 +++++++--------- Nasal/MCDU/IRSINIT.nas | 30 ++---- Nasal/MCDU/LATREV.nas | 10 +- Nasal/MCDU/MCDU.nas | 160 +++++++--------------------- Nasal/MCDU/PERFAPPR.nas | 61 +++++------ Nasal/MCDU/PERFCLB.nas | 14 ++- Nasal/MCDU/PERFCRZ.nas | 11 +- Nasal/MCDU/PERFDES.nas | 11 +- Nasal/MCDU/PERFGA.nas | 16 ++- Nasal/MCDU/PERFTO.nas | 99 ++++++++--------- Nasal/MCDU/PROGCLB.nas | 9 +- Nasal/MCDU/PROGCRZ.nas | 9 +- Nasal/MCDU/PROGDES.nas | 9 +- Nasal/MCDU/PROGTO.nas | 9 +- Nasal/MCDU/RADNAV.nas | 82 +++++++------- Nasal/MCDU/VERTREV.nas | 3 +- 26 files changed, 396 insertions(+), 573 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index 20a87d1b..0991fe6d 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -308,24 +308,6 @@ var canvas_MCDU_base = { }, updateCommon: func(i) { page = pageProp[i].getValue(); - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - color_selected = getprop("/MCDU[" ~ i ~ "]/scratchpad-color"); - if (color_selected == "grn") { - me["Scratchpad"].setColor(GREEN); - } else if (color_selected == "blu") { - me["Scratchpad"].setColor(BLUE); - } else if (color_selected == "amb") { - me["Scratchpad"].setColor(AMBER); - } else if (color_selected == "yel") { - me["Scratchpad"].setColor(YELLOW); - } else if (color_selected == "mag") { - me["Scratchpad"].setColor(MAGENTA); - } else { - me["Scratchpad"].setColor(WHITE); - } - } else { - me["Scratchpad"].setColor(WHITE); - } if (page == "F-PLNA" or page == "F-PLNB") { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); @@ -4928,6 +4910,20 @@ var canvas_MCDU_base = { }, updateScratchpad: func(i) { me["Scratchpad"].setText(sprintf("%s", mcdu_scratchpad.scratchpads[i].scratchpad)); + var color_selected = mcdu_scratchpad.scratchpads[i].scratchpadColour; + if (color_selected == "grn") { + me["Scratchpad"].setColor(GREEN); + } else if (color_selected == "blu") { + me["Scratchpad"].setColor(BLUE); + } else if (color_selected == "amb") { + me["Scratchpad"].setColor(AMBER); + } else if (color_selected == "yel") { + me["Scratchpad"].setColor(YELLOW); + } else if (color_selected == "mag") { + me["Scratchpad"].setColor(MAGENTA); + } else { + me["Scratchpad"].setColor(WHITE); + } }, }; @@ -4984,6 +4980,9 @@ setlistener("sim/signals/fdm-initialized", func { MCDU_1.updateScratchpadCall(); MCDU_2.updateScratchpadCall(); + mcdu.mcdu_message(0, "SELECT DESIRED SYSTEM"); + mcdu.mcdu_message(1, "SELECT DESIRED SYSTEM"); + MCDU_update.start(); }); diff --git a/Nasal/FMGC/flightplan-waypoints.nas b/Nasal/FMGC/flightplan-waypoints.nas index b278bbbb..a7808639 100644 --- a/Nasal/FMGC/flightplan-waypoints.nas +++ b/Nasal/FMGC/flightplan-waypoints.nas @@ -59,8 +59,7 @@ var WaypointDatabase = { } me.write(); if (me.getCount() != 0) { - setprop("/MCDU[" ~ callerIdx ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ callerIdx ~ "]/scratchpad", "PILOT ELEMENT RETAINED"); + mcdu.mcdu_message(callerIdx, "PILOT ELEMENT RETAINED"); } }, # deleteAtIndex - delete at specific index. Set to nil, so it still exists in vector diff --git a/Nasal/FMGC/mcdu-messages.nas b/Nasal/FMGC/mcdu-messages.nas index 2d92b259..df8a5e85 100644 --- a/Nasal/FMGC/mcdu-messages.nas +++ b/Nasal/FMGC/mcdu-messages.nas @@ -5,13 +5,13 @@ var TypeIMessage = { new: func(msgText) { var msg = { parents: [TypeIMessage] }; msg.msgText = msgText; - msg.colour = "w"; + msg.colour = "wht"; return msg; }, }; var TypeIIMessage = { - new: func(msgText, colour = "w", isInhibit = 0) { + new: func(msgText, colour = "wht", isInhibit = 0) { var msg = { parents: [TypeIIMessage] }; msg.msgText = msgText; msg.colour = colour; @@ -49,9 +49,9 @@ var scratchpadController = { var sp = { parents: [scratchpadController] }; sp.scratchpad = ""; sp.scratchpadSave = ""; - sp.scratchpadColour = "w"; - sp.scratchpadShowTypeIMsg = 0; - sp.scratchpadShowTypeIIMsg = 0; + sp.scratchpadColour = "wht"; + sp.showTypeIMsg = 0; + sp.showTypeIIMsg = 0; sp.mcdu = mcdu; return sp; }, @@ -62,13 +62,13 @@ var scratchpadController = { } # any shown type ii is hidden - if (me.scratchpadShowTypeIIMsg) { - me.clearTypeIIMsg(); + if (me.showTypeIIMsg) { + me.clearTypeII(); } # any shown type i is hidden - if (me.scratchpadShowTypeIMsg) { - me.clearTypeIMsg(); + if (me.showTypeIMsg) { + me.clearTypeI(); } me.scratchpad = me.scratchpad ~ character; @@ -76,32 +76,36 @@ var scratchpadController = { }, showTypeI: func(msg) { # any shown type ii is hidden - if (me.scratchpadShowTypeIIMsg) { - me.clearTypeIIMsg(); + if (me.showTypeIIMsg) { + me.clearTypeII(); } - me.scratchpadShowTypeIMsg = 1; + me.showTypeIMsg = 1; + # save any data entered me.scratchpadSave = me.scratchpad; - me.scratchpad = msg; + + me.scratchpad = msg.msgText; + me.scratchpadColour = msg.colour; me.update(); }, showTypeII: func(msg) { # only show if scratchpad empty if (me.scratchpad = "") { - me.scratchpadShowTypeIIMsg = 1; - me.scratchpad = msg; + me.showTypeIIMsg = 1; + me.scratchpad = msg.msgText; + me.scratchpadColour = msg.colour; } me.update(); }, clearTypeI: func() { me.scratchpad = me.scratchpadSave; me.scratchpadSave = nil; - me.scratchpadShowTypeIMsg = 0; + me.showTypeIMsg = 0; me.update(); }, clearTypeII: func() { - me.scratchpadShowTypeIIMsg = 0; + me.showTypeIIMsg = 0; me.empty(); me.update(); }, @@ -110,12 +114,14 @@ var scratchpadController = { me.update(); }, clear: func() { - if (me.showTypeIMsg) { - me.clearTypeIMsg(); + if (me.scratchpad == "CLR") { + me.empty(); + } elsif (me.showTypeIMsg) { + me.clearTypeI(); } elsif (!me.showTypeIIMsg) { me.scratchpad = left(me.scratchpad, size(me.scratchpad) - 1); } else { - me.clearTypeIIMsg(); + me.clearTypeII(); } me.update(); }, @@ -130,12 +136,13 @@ var scratchpadController = { var MessageController = { typeIMessages: std.Vector.new([ - TypeIMessage.new("AWY/WPT MISMATCH"),TypeIMessage.new("DEST/ALTN MISMATCH"),TypeIMessage.new("DIR TO IN PROGRESS"), - TypeIMessage.new("ENTRY OUT OF RANGE"),TypeIMessage.new("FORMAT ERROR"),TypeIMessage.new("INSERT/ERASE TMPY FIRST"), - TypeIMessage.new("LIST OF 20 IN USE"),TypeIMessage.new("PILOT ELEMENT RETAINED"),TypeIMessage.new("NOT ALLOWED"), - TypeIMessage.new("NOT IN DATA BASE"),TypeIMessage.new("ONLY SPD ENTRY ALLOWED"),TypeIMessage.new("PLEASE WAIT"), - TypeIMessage.new("REVISION IN PROGRESS"),TypeIMessage.new("TMPY F-PLN EXISTS"),TypeIMessage.new("SELECT DESIRED SYSTEM"), - TypeIMessage.new("SELECT HDG/TRK FIRST"),TypeIMessage.new("USING COST INDEX N"), + TypeIMessage.new("AOC DISABLED"),TypeIMessage.new("AWY/WPT MISMATCH"),TypeIMessage.new("DEST/ALTN MISMATCH"), + TypeIMessage.new("DIR TO IN PROGRESS"),TypeIMessage.new("ENTRY OUT OF RANGE"),TypeIMessage.new("FORMAT ERROR"), + TypeIMessage.new("INSERT/ERASE TMPY FIRST"),TypeIMessage.new("LIST OF 20 IN USE"),TypeIMessage.new("PILOT ELEMENT RETAINED"), + TypeIMessage.new("NOT ALLOWED"),TypeIMessage.new("NOT IN DATA BASE"),TypeIMessage.new("ONLY SPD ENTRY ALLOWED"), + TypeIMessage.new("PLEASE WAIT"),TypeIMessage.new("REVISION IN PROGRESS"),TypeIMessage.new("TMPY F-PLN EXISTS"), + TypeIMessage.new("SELECT DESIRED SYSTEM"),TypeIMessage.new("SELECT HDG/TRK FIRST"),TypeIMessage.new("USING COST INDEX N"), + TypeIMessage.new("WAIT FOR SYSTEM RESPONSE"), ]), typeIIMessages: std.Vector.new([ diff --git a/Nasal/MCDU/ARRIVAL.nas b/Nasal/MCDU/ARRIVAL.nas index 306c8128..1ad92187 100644 --- a/Nasal/MCDU/ARRIVAL.nas +++ b/Nasal/MCDU/ARRIVAL.nas @@ -506,8 +506,7 @@ var arrivalPage = { me.arrowsColour[0][5] = "yel"; canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); } else { - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ i ~ "]/scratchpad", "DIR TO IN PROGRESS"); + mcdu_message(me.computer, "DIR TO IN PROGRESS"); } } }, @@ -593,11 +592,10 @@ var arrivalPage = { fmgc.flightPlanController.flightPlanChanged(me.computer); me.scrollRight(); } else { - setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + mcdu_message(me.computer, "DIR TO IN PROGRESS"); } } else { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } } else { if (size(me.stars) >= (index - 2)) { @@ -625,11 +623,10 @@ var arrivalPage = { me.updateActiveTransitions(); fmgc.flightPlanController.flightPlanChanged(me.computer); } else { - setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + mcdu_message(me.computer, "DIR TO IN PROGRESS"); } } else { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } } }, @@ -640,8 +637,7 @@ var arrivalPage = { me.updateActiveTransitions(); me.updateTransitions(); } else { - setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + mcdu_message(me.computer, "DIR TO IN PROGRESS"); } } elsif (size(me.transitions) >= (index - 1)) { if (!dirToFlag) { @@ -652,11 +648,10 @@ var arrivalPage = { me.updateTransitions(); fmgc.flightPlanController.flightPlanChanged(me.computer); } else { - setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + mcdu_message(me.computer, "DIR TO IN PROGRESS"); } } else { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } }, }; \ No newline at end of file diff --git a/Nasal/MCDU/CLOSESTAIRPORT.nas b/Nasal/MCDU/CLOSESTAIRPORT.nas index b0e3502d..ddec61e9 100644 --- a/Nasal/MCDU/CLOSESTAIRPORT.nas +++ b/Nasal/MCDU/CLOSESTAIRPORT.nas @@ -52,6 +52,11 @@ var closestAirportPage = { }, freeze: func() { me.frozen = !me.frozen; + if (me.frozen) { + me.L6 = [" UNFREEZE", nil, "blu"]; + } else { + me.L6 = [" FREEZE", nil, "blu"]; + } }, update: func() { if (me.frozen) { return; } @@ -106,7 +111,7 @@ var closestAirportPage = { return; } if (size(id) > 4) { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } if (airportinfo(id) == nil) { notInDataBase(me.computer); diff --git a/Nasal/MCDU/DEPARTURE.nas b/Nasal/MCDU/DEPARTURE.nas index ba106ff7..a9aefb44 100644 --- a/Nasal/MCDU/DEPARTURE.nas +++ b/Nasal/MCDU/DEPARTURE.nas @@ -430,8 +430,7 @@ var departurePage = { me.arrowsColour[0][5] = "yel"; canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); } else { - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ i ~ "]/scratchpad", "DIR TO IN PROGRESS"); + mcdu_message(me.computer, "DIR TO IN PROGRESS"); } } }, @@ -508,11 +507,10 @@ var departurePage = { fmgc.flightPlanController.flightPlanChanged(me.computer); me.scrollRight(); } else { - setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + mcdu_message(me.computer, "DIR TO IN PROGRESS"); } } else { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } } else { if (size(me.sids) >= (index - 1)) { @@ -538,11 +536,10 @@ var departurePage = { me.updateActiveTransitions(); fmgc.flightPlanController.flightPlanChanged(me.computer); } else { - setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + mcdu_message(me.computer, "DIR TO IN PROGRESS"); } } else { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } } }, @@ -553,8 +550,7 @@ var departurePage = { me.updateActiveTransitions(); me.updateTransitions(); } else { - setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + mcdu_message(me.computer, "DIR TO IN PROGRESS"); } } elsif (size(me.transitions) >= (index - 1)) { if (!dirToFlag) { @@ -565,11 +561,10 @@ var departurePage = { me.updateTransitions(); fmgc.flightPlanController.flightPlanChanged(me.computer); } else { - setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + mcdu_message(me.computer, "DIR TO IN PROGRESS"); } } else { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } }, }; \ No newline at end of file diff --git a/Nasal/MCDU/DIRTO.nas b/Nasal/MCDU/DIRTO.nas index 50bc54aa..2ae0b57a 100644 --- a/Nasal/MCDU/DIRTO.nas +++ b/Nasal/MCDU/DIRTO.nas @@ -156,7 +156,7 @@ var dirTo = { var lonDecimal = mcdu.stringToDegrees(lon, "lon"); if (latDecimal > 90 or latDecimal < -90 or lonDecimal > 180 or lonDecimal < -180) { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } var myWpLatLon = createWP(latDecimal, lonDecimal, "LL" ~ 01); @@ -229,10 +229,9 @@ var dirTo = { } } else { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } - setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", ""); - setprop("MCDU[" ~ me.computer ~ "]/scratchpad", ""); + mcdu_scratchpad.scratchpads[me.computer].empty(); }, leftFieldBtn: func(index) { me.makeTmpy(); @@ -252,22 +251,22 @@ var dirTo = { if (fmgc.flightPlanController.temporaryFlag[me.computer] and dirToFlag) { dirToFlag = 0; fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 0); + me.L1 = [" [ ]", " WAYPOINT", "blu"]; + me.R1 = ["---- --- ", "UTC DIST ", "wht"]; } else { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } - me.L1 = [" [ ]", " WAYPOINT", "blu"]; - me.R1 = ["---- --- ", "UTC DIST ", "wht"]; }, fieldR6: func() { if (fmgc.flightPlanController.temporaryFlag[me.computer] and dirToFlag) { dirToFlag = 0; fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 1); + me.L1 = [" [ ]", " WAYPOINT", "blu"]; + me.R1 = ["---- --- ", "UTC DIST ", "wht"]; + setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); # todo - remember horizontal srcoll of f-plna? } else { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } - me.L1 = [" [ ]", " WAYPOINT", "blu"]; - me.R1 = ["---- --- ", "UTC DIST ", "wht"]; - setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); # todo - remember horizontal srcoll of f-plna? }, updateDist: func(dist) { me.R1 = ["---- " ~ sprintf("%.0f", dist) ~ " ", "UTC DIST ", "wht"]; diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas index 7666b9d2..f205f457 100644 --- a/Nasal/MCDU/F-PLN.nas +++ b/Nasal/MCDU/F-PLN.nas @@ -188,10 +188,10 @@ var staticText = { return [nil, nil, "ack"]; }, pushButtonLeft: func() { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); }, pushButtonRight: func() { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); }, }; @@ -406,26 +406,24 @@ var fplnPage = { # this one is only created once, and then updated - remember th } } else { if (size(me.outputList) >= index) { - if (size(getprop("MCDU[" ~ me.computer ~ "]/scratchpad")) > 0) { - var returny = fmgc.flightPlanController.scratchpad(getprop("MCDU[" ~ me.computer ~ "]/scratchpad"), (index - 1 + me.scroll), me.computer); + if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) > 0) { + var returny = fmgc.flightPlanController.scratchpad(mcdu_scratchpad.scratchpads[me.computer].scratchpad, (index - 1 + me.scroll), me.computer); if (returny == 3) { - setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + mcdu_message(me.computer, "DIR TO IN PROGRESS"); } elsif (returny == 0) { - notInDataBase(me.computer); + mcdu_message(me.computer, "NOT IN DATA BASE"); } elsif (returny == 1) { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } elsif (returny == 4) { - databaseFull(me.computer); + mcdu_message(me.computer, "LIST OF 20 IN USE"); } else { - setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", ""); - setprop("MCDU[" ~ me.computer ~ "]/scratchpad", ""); + mcdu_scratchpad.scratchpads[me.computer].empty(); } } else { me.outputList[index - 1].pushButtonLeft(); } } else { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } } }, @@ -440,42 +438,22 @@ var fplnPage = { # this one is only created once, and then updated - remember th setprop("/FMGC/internal/fuel-calculating", 1); } } else { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } } else { if (size(me.outputList) >= index) { - if (size(getprop("MCDU[" ~ me.computer ~ "]/scratchpad")) > 0) { - notAllowed(me.computer); + if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) > 0) { + mcdu_message(me.computer, "NOT ALLOWED"); } else { me.outputList[index - 1].pushButtonRight(); } } else { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } } }, }; -var notInDataBase = func(i) { - if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("MCDU[" ~ i ~ "]/last-scratchpad", "NOT IN DATABASE"); - } else { - setprop("MCDU[" ~ i ~ "]/last-scratchpad", mcdu_scratchpad.scratchpads[i].scratchpad); - } - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ i ~ "]/scratchpad", "NOT IN DATABASE"); -} - -var databaseFull = func(i) { - if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("MCDU[" ~ i ~ "]/last-scratchpad", "LIST OF 20 IN USE"); - } else { - setprop("MCDU[" ~ i ~ "]/last-scratchpad", mcdu_scratchpad.scratchpads[i].scratchpad); - } - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ i ~ "]/scratchpad", "LIST OF 20 IN USE"); -} - var decimalToShortString = func(dms, type) { var degrees = split(".", sprintf(dms))[0]; if (type == "lat") { diff --git a/Nasal/MCDU/FUELPRED.nas b/Nasal/MCDU/FUELPRED.nas index 97521b42..37e4859c 100644 --- a/Nasal/MCDU/FUELPRED.nas +++ b/Nasal/MCDU/FUELPRED.nas @@ -35,8 +35,7 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/rte-rsv", 0.05 * num(getprop("/FMGC/internal/trip-fuel"))); setprop("/FMGC/internal/rte-percent", 5.0); setprop("/FMGC/internal/fuel-calculating", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (getprop("/FMGC/internal/trip-fuel") != 0) { var tf = num(scratchpad); var tfs = size(scratchpad); @@ -46,7 +45,7 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/rte-rsv", num(perc) / 100 * num(getprop("/FMGC/internal/trip-fuel"))); setprop("/FMGC/internal/rte-percent", perc); setprop("/FMGC/internal/fuel-calculating", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } } else if (tfs >= 1 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 21.7) { setprop("/FMGC/internal/rte-rsv", scratchpad); @@ -56,12 +55,12 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/rte-percent", 15.0); # need reasearch on this value } setprop("/FMGC/internal/fuel-calculating", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L4" and getprop("/FMGC/internal/block-confirmed") and !getprop("/FMGC/internal/fuel-calculating") and getprop("/FMGC/internal/alt-set")) { if (scratchpad == "CLR") { @@ -69,8 +68,7 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/alt-time", "0000"); setprop("/FMGC/internal/alt-fuel-set", 0); setprop("/FMGC/internal/fuel-calculating", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (find(".", scratchpad) != -1) { var tf = num(scratchpad); var tfs = size(scratchpad); @@ -79,12 +77,12 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/alt-time", "0000"); setprop("/FMGC/internal/alt-fuel-set", 1); setprop("/FMGC/internal/fuel-calculating", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L5" and getprop("/FMGC/internal/block-confirmed") and !getprop("/FMGC/internal/fuel-calculating")) { if (scratchpad == "CLR") { @@ -93,8 +91,7 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/final-fuel-set", 0); setprop("/FMGC/internal/final-time-set", 0); setprop("/FMGC/internal/fuel-calculating", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (find(".", scratchpad) != -1) { var tf = num(scratchpad); var tfs = size(scratchpad); @@ -102,9 +99,9 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/final-fuel", tf); setprop("/FMGC/internal/final-fuel-set", 1); setprop("/FMGC/internal/fuel-calculating", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { var tf = num(scratchpad); @@ -113,9 +110,9 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/final-time", scratchpad); setprop("/FMGC/internal/final-time-set", 1); setprop("/FMGC/internal/fuel-calculating", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L6" and getprop("/FMGC/internal/block-confirmed") and !getprop("/FMGC/internal/fuel-calculating")) { @@ -123,8 +120,7 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/min-dest-fob", 0); setprop("/FMGC/internal/min-dest-fob-set", 0); setprop("/FMGC/internal/fuel-calculating", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (find(".", scratchpad) != -1) { var tf = num(scratchpad); var tfs = size(scratchpad); @@ -132,19 +128,19 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/min-dest-fob", tf); setprop("/FMGC/internal/min-dest-fob-set", 1); setprop("/FMGC/internal/fuel-calculating", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); if (num(getprop("/FMGC/internal/min-dest-fob")) < num(getprop("/FMGC/internal/final-fuel") + getprop("/FMGC/internal/alt-fuel"))) { genericMessage(i, "CHECK MIN DEST FOB", "wht"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "R3" and !getprop("/FMGC/internal/fuel-calculating")) { if (scratchpad == "CLR") { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } else { var tfs = size(scratchpad); if (tfs == 0) { @@ -185,9 +181,9 @@ var fuelPredInput = func(key, i) { } } if ((zfwcg != nil and zfwcgs >= 1 and zfwcgs <= 5 and zfwcg > 0 and zfwcg <= 99.9) or (zfw != nil and zfws >= 1 and zfws <= 5 and zfw > 0 and zfw <= 999.9)) { - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (tfs >= 1 and tfs <= 5) { var zfwcg = size(scratchpad); @@ -202,31 +198,30 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/block-calculating", 0); setprop("/FMGC/internal/block-confirmed", 1); } - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "R4") { if (scratchpad == "CLR") { setprop("/FMGC/internal/fffq-sensor", "FF+FQ"); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (find("/", scratchpad) == 0) { var sensor = substr(scratchpad, 1); if (sensor == "FF+FQ" or sensor == "FQ+FF" or sensor == "FF" or sensor == "FQ") { setprop("FMGC/internal/fffq-sensor", sensor); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } diff --git a/Nasal/MCDU/INITA.nas b/Nasal/MCDU/INITA.nas index 416af594..6f5d7853 100644 --- a/Nasal/MCDU/INITA.nas +++ b/Nasal/MCDU/INITA.nas @@ -13,8 +13,7 @@ var initInputA = func(key, i) { setprop("/FMGC/internal/fuel-calculating", 0); setprop("/FMGC/internal/fuel-calculating", 1); } - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); fmgc.updateARPT(); #} else if (scratchpad == "") { #setprop("/FMGC/internal/alt-selected", 1); @@ -28,38 +27,36 @@ var initInputA = func(key, i) { setprop("/FMGC/internal/fuel-calculating", 0); setprop("/FMGC/internal/fuel-calculating", 1); } - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); fmgc.updateARPT(); #setprop("/FMGC/internal/alt-selected", 1); #setprop("MCDU[" ~ i ~ "]/page", "ROUTESELECTION"); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L3") { if (scratchpad == "CLR") { setprop("MCDUC/flight-num", ""); setprop("MCDUC/flight-num-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var flts = size(scratchpad); if (flts >= 1 and flts <= 8) { setprop("MCDUC/flight-num", scratchpad); setprop("MCDUC/flight-num-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L5") { if (scratchpad == "CLR") { setprop("/FMGC/internal/cost-index", 0); setprop("/FMGC/internal/cost-index-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var ci = int(scratchpad); var cis = size(scratchpad); @@ -67,12 +64,12 @@ var initInputA = func(key, i) { if (ci != nil and ci >= 0 and ci <= 999) { setprop("/FMGC/internal/cost-index", ci); setprop("/FMGC/internal/cost-index-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L6") { @@ -86,8 +83,7 @@ var initInputA = func(key, i) { setprop("/FMGC/internal/fuel-calculating", 0); setprop("/FMGC/internal/fuel-calculating", 1); } - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (find("/", scratchpad) != -1) { var crztemp = split("/", scratchpad); if (find("FL", crztemp[0]) != -1) { @@ -106,9 +102,9 @@ var initInputA = func(key, i) { setprop("/FMGC/internal/fuel-calculating", 0); setprop("/FMGC/internal/fuel-calculating", 1); } - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (crzs >= 1 and crzs <= 3 and crz != nil and temps >= 1 and temps <= 3 and temp != nil) { if (crz > 0 and crz <= 390 and temp >= -99 and temp <= 99) { @@ -122,12 +118,12 @@ var initInputA = func(key, i) { setprop("/FMGC/internal/fuel-calculating", 0); setprop("/FMGC/internal/fuel-calculating", 1); } - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { if (find("FL", scratchpad) != -1) { @@ -147,12 +143,12 @@ var initInputA = func(key, i) { setprop("/FMGC/internal/fuel-calculating", 0); setprop("/FMGC/internal/fuel-calculating", 1); } - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "R1") { @@ -170,8 +166,7 @@ var initInputA = func(key, i) { } fmgc.flightPlanController.reset(2); fmgc.flightPlanController.init(); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); #} else if (scratchpad == "") { #setprop("/FMGC/internal/alt-selected", 0); #setprop("MCDU[" ~ i ~ "]/page", "ROUTESELECTION"); @@ -187,7 +182,7 @@ var initInputA = func(key, i) { setprop("/FMGC/internal/arr-arpt", fromto[1]); setprop("/FMGC/internal/tofrom-set", 1); #scratchpad - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); fmgc.flightPlanController.updateAirports(fromto[0], fromto[1], 2); setprop("/FMGC/internal/alt-selected", 0); #ref lat @@ -211,10 +206,10 @@ var initInputA = func(key, i) { setprop("/FMGC/internal/align-ref-long-edit", 0); #setprop("MCDU[" ~ i ~ "]/page", "ROUTESELECTION"); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "R3") { @@ -223,29 +218,27 @@ var initInputA = func(key, i) { if (scratchpad == "CLR") { setprop("/FMGC/internal/tropo", 36090); setprop("/FMGC/internal/tropo-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tropo = size(scratchpad); if (tropo == 5 and scratchpad <= 99990) { setprop("FMGC/internal/tropo-set", 1); setprop("FMGC/internal/tropo", scratchpad); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "R6") { if (scratchpad == "CLR") { setprop("/FMGC/internal/gndtemp-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (int(scratchpad) != nil and getprop("/FMGC/status/phase") == 0 and size(scratchpad) >= 1 and size(scratchpad) <= 3 and scratchpad >= -99 and scratchpad <= 99) { setprop("/FMGC/internal/gndtemp", scratchpad); setprop("/FMGC/internal/gndtemp-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } diff --git a/Nasal/MCDU/INITB.nas b/Nasal/MCDU/INITB.nas index 94d7587b..f12d6439 100644 --- a/Nasal/MCDU/INITB.nas +++ b/Nasal/MCDU/INITB.nas @@ -13,8 +13,7 @@ var initInputB = func(key, i) { } else if (getprop("/FMGC/internal/fuel-request-set")) { setprop("/FMGC/internal/block-calculating", 1); } - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs >= 1 and tfs <= 4) { @@ -22,13 +21,13 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/taxi-fuel", scratchpad); setprop("/FMGC/internal/taxi-fuel-set", 1); setprop("/FMGC/internal/fuel-calculating", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); fmgc.updateFuel(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L3" and getprop("/FMGC/internal/block-confirmed") and !getprop("/FMGC/internal/fuel-calculating")) { @@ -38,8 +37,7 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/rte-percent", 5.0); setprop("/FMGC/internal/rte-percent-set", 0); setprop("/FMGC/internal/fuel-calculating", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (getprop("/FMGC/internal/trip-fuel") != 0) { var tf = num(scratchpad); var tfs = size(scratchpad); @@ -51,7 +49,7 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/rte-percent", perc); setprop("/FMGC/internal/rte-percent-set", 1); setprop("/FMGC/internal/fuel-calculating", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } } else if (tfs >= 1 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 21.7) { setprop("/FMGC/internal/rte-rsv", scratchpad); @@ -63,12 +61,12 @@ var initInputB = func(key, i) { } setprop("/FMGC/internal/rte-percent-set", 0); setprop("/FMGC/internal/fuel-calculating", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L4" and getprop("/FMGC/internal/block-confirmed") and !getprop("/FMGC/internal/fuel-calculating") and getprop("/FMGC/internal/alt-set")) { if (scratchpad == "CLR") { @@ -76,8 +74,7 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/alt-time", "0000"); setprop("/FMGC/internal/alt-fuel-set", 0); setprop("/FMGC/internal/fuel-calculating", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (find(".", scratchpad) != -1) { var tf = num(scratchpad); var tfs = size(scratchpad); @@ -86,12 +83,12 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/alt-time", "0000"); setprop("/FMGC/internal/alt-fuel-set", 1); setprop("/FMGC/internal/fuel-calculating", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L5" and getprop("/FMGC/internal/block-confirmed") and !getprop("/FMGC/internal/fuel-calculating")) { if (scratchpad == "CLR") { @@ -100,8 +97,7 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/final-fuel-set", 0); setprop("/FMGC/internal/final-time-set", 0); setprop("/FMGC/internal/fuel-calculating", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (find(".", scratchpad) != -1) { var tf = num(scratchpad); var tfs = size(scratchpad); @@ -109,9 +105,9 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/final-fuel", tf); setprop("/FMGC/internal/final-fuel-set", 1); setprop("/FMGC/internal/fuel-calculating", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { var tf = num(scratchpad); @@ -120,9 +116,9 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/final-time", scratchpad); setprop("/FMGC/internal/final-time-set", 1); setprop("/FMGC/internal/fuel-calculating", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L6" and getprop("/FMGC/internal/block-confirmed") and !getprop("/FMGC/internal/fuel-calculating")) { @@ -130,8 +126,7 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/min-dest-fob", 0); setprop("/FMGC/internal/min-dest-fob-set", 0); setprop("/FMGC/internal/fuel-calculating", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (find(".", scratchpad) != -1) { var tf = num(scratchpad); var tfs = size(scratchpad); @@ -139,19 +134,19 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/min-dest-fob", tf); setprop("/FMGC/internal/min-dest-fob-set", 1); setprop("/FMGC/internal/fuel-calculating", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); if (num(getprop("/FMGC/internal/min-dest-fob")) < num(getprop("/FMGC/internal/final-fuel") + getprop("/FMGC/internal/alt-fuel"))) { genericMessage(i, "CHECK MIN DEST FOB", "wht"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "R1" and !getprop("/FMGC/internal/fuel-calculating")) { if (scratchpad == "CLR") { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } else { var tfs = size(scratchpad); if (tfs == 0) { @@ -197,21 +192,21 @@ var initInputB = func(key, i) { } } if ((zfwcg != nil and zfwcgs >= 1 and zfwcgs <= 5 and zfwcg > 0 and zfwcg <= 99.9) or (zfw != nil and zfws >= 1 and zfws <= 5 and zfw > 0 and zfw <= 999.9)) { - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (tfs >= 1 and tfs <= 5) { var zfwcg = size(scratchpad); if (num(scratchpad) != nil and zfwcg >= 1 and zfwcg <= 5 and scratchpad > 0 and scratchpad <= 99.9) { setprop("/FMGC/internal/zfwcg", scratchpad); setprop("/FMGC/internal/zfwcg-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "R2" and !getprop("/FMGC/internal/fuel-calculating")) { @@ -246,8 +241,7 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/fuel-calculating", 0); setprop("/FMGC/internal/block-calculating", 0); setprop("/FMGC/internal/block-confirmed", 0); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); var maxblock = getprop("/options/maxblock"); @@ -274,12 +268,12 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/block-calculating", 0); setprop("/FMGC/internal/block-confirmed", 1); } - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "R3") { @@ -290,7 +284,7 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/block-confirmed", 1); setprop("/FMGC/internal/fuel-calculating", 1); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "R5" and !getprop("/FMGC/internal/fuel-calculating")) { if (scratchpad == "CLR") { @@ -299,8 +293,7 @@ var initInputB = func(key, i) { if (getprop("/FMGC/internal/block-confirmed")) { setprop("/FMGC/internal/fuel-calculating", 1); } - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { if (find("TL", scratchpad) != -1 or find("HD", scratchpad) != -1) { var effwind = substr(scratchpad, 2); @@ -310,9 +303,9 @@ var initInputB = func(key, i) { if (getprop("/FMGC/internal/block-confirmed")) { setprop("/FMGC/internal/fuel-calculating", 1); } - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (find("-", scratchpad) != -1 or find("+", scratchpad) != -1 or find("T", scratchpad) != -1 or find("H", scratchpad) != -1) { var effwind = substr(scratchpad, 1); @@ -322,9 +315,9 @@ var initInputB = func(key, i) { if (getprop("/FMGC/internal/block-confirmed")) { setprop("/FMGC/internal/fuel-calculating", 1); } - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { if (num(scratchpad) != nil and scratchpad >= 0 and scratchpad <= 500) { @@ -333,13 +326,13 @@ var initInputB = func(key, i) { if (getprop("/FMGC/internal/block-confirmed")) { setprop("/FMGC/internal/fuel-calculating", 1); } - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } diff --git a/Nasal/MCDU/IRSINIT.nas b/Nasal/MCDU/IRSINIT.nas index 8397ccca..7ba66c6b 100644 --- a/Nasal/MCDU/IRSINIT.nas +++ b/Nasal/MCDU/IRSINIT.nas @@ -29,7 +29,7 @@ var initInputIRS = func(key, i) { setprop("FMGC/internal/align-ref-long-minutes", getprop("FMGC/internal/align-ref-long-minutes") + 0.1); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "down") { if (getprop("FMGC/internal/align-ref-lat-edit")) { @@ -59,14 +59,14 @@ var initInputIRS = func(key, i) { setprop("FMGC/internal/align-ref-long-minutes", getprop("FMGC/internal/align-ref-long-minutes") - 0.1); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L1") { if (getprop("FMGC/internal/tofrom-set")) { setprop("FMGC/internal/align-ref-lat-edit", 1); setprop("FMGC/internal/align-ref-long-edit", 0); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L6") { setprop("FMGC/internal/align-ref-lat-edit", 0); @@ -77,7 +77,7 @@ var initInputIRS = func(key, i) { setprop("FMGC/internal/align-ref-lat-edit", 0); setprop("FMGC/internal/align-ref-long-edit", 1); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "R6") { setprop("FMGC/internal/align-ref-lat-edit", 0); @@ -91,27 +91,11 @@ var initInputIRS = func(key, i) { setprop("MCDU[" ~ i ~ "]/page", "INITA"); } } else if (getprop("FMGC/internal/tofrom-set") == 0) { - if (mcdu_scratchpad.scratchpads[i].scratchpad != "SELECT REFERENCE") { - if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("MCDU[" ~ i ~ "]/last-scratchpad", ""); - } else { - setprop("MCDU[" ~ i ~ "]/last-scratchpad", mcdu_scratchpad.scratchpads[i].scratchpad); - } - } - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ i ~ "]/scratchpad", "SELECT REFERENCE"); + # setprop("MCDU[" ~ i ~ "]/scratchpad", "SELECT REFERENCE"); } else if (getprop("systems/navigation/adr/any-adr-on") == 0) { - if (mcdu_scratchpad.scratchpads[i].scratchpad != "IRS NOT ALIGNED") { - if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("MCDU[" ~ i ~ "]/last-scratchpad", ""); - } else { - setprop("MCDU[" ~ i ~ "]/last-scratchpad", mcdu_scratchpad.scratchpads[i].scratchpad); - } - } - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ i ~ "]/scratchpad", "IRS NOT ALIGNED"); + # setprop("MCDU[" ~ i ~ "]/scratchpad", "IRS NOT ALIGNED"); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } diff --git a/Nasal/MCDU/LATREV.nas b/Nasal/MCDU/LATREV.nas index a048724b..f60900b6 100644 --- a/Nasal/MCDU/LATREV.nas +++ b/Nasal/MCDU/LATREV.nas @@ -120,8 +120,7 @@ var latRev = { if (!dirToFlag) { fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); } else { - setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + mcdu_message(me.computer, "DIR TO IN PROGRESS"); } me._checkTmpy(); } @@ -129,14 +128,13 @@ var latRev = { nextWpt: func() { me.makeTmpy(); - var returny = fmgc.flightPlanController.scratchpad(getprop("/MCDU[" ~ me.computer ~ "]/scratchpad"), me.index + 1, me.computer); + var returny = fmgc.flightPlanController.scratchpad(mcdu_scratchpad.scratchpads[me.computer].scratchpad, me.index + 1, me.computer); if (returny == 0) { notInDataBase(me.computer); } elsif (returny == 1) { - notAllowed(me.computer); + mcdu_message(me.computer, "NOT ALLOWED"); } else { - setprop("/MCDU[" ~ me.computer ~ "]/scratchpad-msg", ""); - setprop("/MCDU[" ~ me.computer ~ "]/scratchpad", ""); + mcdu_scratchpad.scratchpads[me.computer].empty(); fmgc.flightPlanController.flightPlanChanged(me.computer); if (getprop("/MCDU[" ~ me.computer ~ "]/page") != "DUPLICATENAMES") { setprop("/MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index b6313a00..6a4e300a 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -5,21 +5,15 @@ var scratchpadNode = [nil, nil]; var MCDU_init = func(i) { - scratchpadNode = [props.globals.initNode("/MCDU[0]/scratchpad", "", "STRING"), props.globals.initNode("/MCDU[1]/scratchpad", "", "STRING")]; - MCDU_reset(i); # Reset MCDU, clears data - setprop("/MCDU[" ~ i ~ "]/scratchpad", "SELECT DESIRED SYSTEM"); + MCDU_reset(i); } var MCDU_reset = func(i) { setprop("/MCDU[" ~ i ~ "]/active", 0); setprop("it-autoflight/settings/togaspd", 157); #aka v2 clone - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); setprop("/MCDU[" ~ i ~ "]/last-page", "NONE"); setprop("/MCDU[" ~ i ~ "]/last-fmgc-page", "STATUS"); setprop("/MCDU[" ~ i ~ "]/page", "MCDU"); - mcdu.clearScratchpad(i); - setprop("/MCDU[" ~ i ~ "]/scratchpad-color", "wht"); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); setprop("/FMGC/keyboard-left", 0); setprop("/FMGC/keyboard-right", 0); @@ -197,19 +191,16 @@ var lskbutton = func(btn, i) { if (btn == "1") { if (getprop("/MCDU[" ~ i ~ "]/page") == "MCDU") { if (getprop("/MCDU[" ~ i ~ "]/active") != 2) { - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad", "WAIT FOR SYSTEM RESPONSE"); + mcdu_message(i, "WAIT FOR SYSTEM RESPONSE"); setprop("/MCDU[" ~ i ~ "]/active", 1); settimer(func(){ setprop("/MCDU[" ~ i ~ "]/page", getprop("/MCDU[" ~ i ~ "]/last-fmgc-page")); - mcdu.clearScratchpad(i); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); + mcdu_scratchpad.scratchpads[i].empty(); setprop("/MCDU[" ~ i ~ "]/active", 2); }, 2); } else { setprop("/MCDU[" ~ i ~ "]/page", getprop("/MCDU[" ~ i ~ "]/last-fmgc-page")); - mcdu.clearScratchpad(i); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); + mcdu_scratchpad.scratchpads[i].empty(); } } else if (getprop("/MCDU[" ~ i ~ "]/page") == "IRSINIT") { initInputIRS("L1",i); @@ -244,7 +235,7 @@ var lskbutton = func(btn, i) { canvas_mcdu.myDeparture[i] = departurePage.new(canvas_mcdu.myLatRev[i].title[2], i); setprop("/MCDU[" ~ i ~ "]/page", "DEPARTURE"); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(1); @@ -253,7 +244,7 @@ var lskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(1); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (btn == "2") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { @@ -287,7 +278,7 @@ var lskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(2); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (btn == "3") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { @@ -325,12 +316,12 @@ var lskbutton = func(btn, i) { canvas_mcdu.myHold[i] = holdPage.new(i, canvas_mcdu.myLatRev[i].wpt); setprop("/MCDU[" ~ i ~ "]/page", "HOLD"); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(3); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (btn == "4") { if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { @@ -358,7 +349,7 @@ var lskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(4); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (btn == "5") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { @@ -399,9 +390,9 @@ var lskbutton = func(btn, i) { canvas_mcdu.myDuplicate[i].pushButtonLeft(5); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CLOSESTAIRPORT") { canvas_mcdu.myClosestAirport[i].manAirportCall(mcdu_scratchpad.scratchpads[i].scratchpad); - setprop("/MCDU[" ~ i ~ "]/scratchpad", ""); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (btn == "6") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { @@ -441,7 +432,7 @@ var lskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CLOSESTAIRPORT") { canvas_mcdu.myClosestAirport[i].freeze(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } @@ -470,7 +461,7 @@ var rskbutton = func(btn, i) { canvas_mcdu.myArrival[i]._setupPageWithData(); setprop("/MCDU[" ~ i ~ "]/page", "ARRIVAL"); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonRight(1); @@ -483,10 +474,10 @@ var rskbutton = func(btn, i) { canvas_mcdu.myPilotWP[i] = pilotWaypointPage.new(i); setprop("/MCDU[" ~ i ~ "]/page", "PILOTWP"); } else { - notAllowed(i); # todo spawn new waypoints page + mcdu_message(i, "NOT ALLOWED"); # todo spawn new waypoints page } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (btn == "2") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { @@ -506,7 +497,7 @@ var rskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonRight(2); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (btn == "3") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { @@ -531,12 +522,12 @@ var rskbutton = func(btn, i) { if (canvas_mcdu.myLatRev[i].type != 2) { canvas_mcdu.myLatRev[i].nextWpt(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonRight(3); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (btn == "4") { if (getprop("/MCDU[" ~ i ~ "]/page") == "FUELPRED") { @@ -556,7 +547,7 @@ var rskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonRight(4); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (btn == "5") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { @@ -590,19 +581,18 @@ var rskbutton = func(btn, i) { canvas_mcdu.myAirways[i] = airwaysPage.new(i, canvas_mcdu.myLatRev[i].wpt); setprop("/MCDU[" ~ i ~ "]/page", "AIRWAYS"); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (btn == "6") { if (getprop("/MCDU[" ~ i ~ "]/page") == "MCDU") { if (getprop("/MCDU[" ~ i ~ "]/last-page") != "NONE") { setprop("/MCDU[" ~ i ~ "]/page", getprop("/MCDU[" ~ i ~ "]/last-page")); - mcdu.clearScratchpad(i); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { initInputA("R6",i); @@ -619,15 +609,7 @@ var rskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFAPPR") { perfAPPRInput("R6",i); } else if ((getprop("/MCDU[" ~ i ~ "]/page") == "DATA") or (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") or (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC2")) { - if (mcdu_scratchpad.scratchpads[i].scratchpad != "AOC DISABLED") { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); - } else { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", mcdu_scratchpad.scratchpads[i].scratchpad); - } - } - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad", "AOC DISABLED"); + mcdu_message(i, "AOC DISABLED"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { initInputA("R6",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { @@ -647,7 +629,7 @@ var rskbutton = func(btn, i) { } } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } @@ -769,7 +751,7 @@ var pagebutton = func(btn, i) { } else if (btn == "mcdu") { setprop("/MCDU[" ~ i ~ "]/last-page", getprop("/MCDU[" ~ i ~ "]/page")); setprop("/MCDU[" ~ i ~ "]/last-fmgc-page", getprop("/MCDU[" ~ i ~ "]/page")); - setprop("/MCDU[" ~ i ~ "]/scratchpad", "SELECT DESIRED SYSTEM"); + mcdu_message(i, "SELECT DESIRED SYSTEM"); setprop("/MCDU[" ~ i ~ "]/page", "MCDU"); } else if (btn == "f-pln" or btn == "airport") { if (canvas_mcdu.myFpln[i] == nil) { @@ -794,8 +776,7 @@ var pagebutton = func(btn, i) { setprop("/MCDU[" ~ i ~ "]/page", "FUELPRED"); } else if (btn == "dirto") { if (fmgc.flightPlanController.temporaryFlag[i] and !dirToFlag) { - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad", "INSRT / ERASE TMPY FIRST"); + mcdu_message(i, "INSERT/ERASE TMPY FIRST"); return; } elsif (canvas_mcdu.myDirTo[i] == nil) { canvas_mcdu.myDirTo[i] = dirTo.new(i); @@ -806,94 +787,31 @@ var pagebutton = func(btn, i) { } var button = func(btn, i) { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 0 and getprop("/MCDU[" ~ i ~ "]/page") != "MCDU") { + if (getprop("/MCDU[" ~ i ~ "]/page") != "MCDU") { var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (btn == "SLASH") { - setprop("/MCDU[" ~ i ~ "]/scratchpad", scratchpad ~ "/"); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); + mcdu_scratchpad.scratchpads[i].addChar("/"); } else if (btn == "SP") { - setprop("/MCDU[" ~ i ~ "]/scratchpad", scratchpad ~ " "); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); + mcdu_scratchpad.scratchpads[i].addChar(" "); } else if (btn == "CLR") { var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (size(scratchpad) == 0) { - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad", "CLR"); - } else if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - mcdu.clearScratchpad(i); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - } else if (size(scratchpad) > 0) { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); - setprop("/MCDU[" ~ i ~ "]/scratchpad", left(scratchpad, size(scratchpad) - 1)); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); + mcdu_scratchpad.scratchpads[i].addChar("CLR"); + } else { + mcdu_scratchpad.scratchpads[i].clear(); } } else if (btn == "DOT") { - setprop("/MCDU[" ~ i ~ "]/scratchpad", scratchpad ~ "."); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); + mcdu_scratchpad.scratchpads[i].addChar("."); } else if (btn == "PLUSMINUS") { - setprop("/MCDU[" ~ i ~ "]/scratchpad", scratchpad ~ "-"); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); + mcdu_scratchpad.scratchpads[i].addChar("-"); } else { - setprop("/MCDU[" ~ i ~ "]/scratchpad", scratchpad ~ btn); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - } - } else { - if (btn == "CLR") { - setprop("/MCDU[" ~ i ~ "]/scratchpad-color", "wht"); - var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; - if (size(scratchpad) == 0) { - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad", "CLR"); - } else if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("/MCDU[" ~ i ~ "]/scratchpad", getprop("/MCDU[" ~ i ~ "]/last-scratchpad")); - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - } + mcdu_scratchpad.scratchpads[i].addChar(btn); } } } -var genericMessage = func(i, text, color) { - if (mcdu_scratchpad.scratchpads[i].scratchpad != text) { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); - } else { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", mcdu_scratchpad.scratchpads[i].scratchpad); - } - } - setprop("/MCDU[" ~ i ~ "]/scratchpad-color", color); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad", text); -} - -var notAllowed = func(i) { - setprop("/MCDU[" ~ i ~ "]/scratchpad-color", "wht"); - if (mcdu_scratchpad.scratchpads[i].scratchpad != "NOT ALLOWED") { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); - } else { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", mcdu_scratchpad.scratchpads[i].scratchpad); - } - } - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad", "NOT ALLOWED"); -} - -var formatError = func(i) { - setprop("/MCDU[" ~ i ~ "]/scratchpad-color", "wht"); - if (mcdu_scratchpad.scratchpads[i].scratchpad != "FORMAT ERROR") { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); - } else { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", mcdu_scratchpad.scratchpads[i].scratchpad); - } - } - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 1); - setprop("/MCDU[" ~ i ~ "]/scratchpad", "FORMAT ERROR"); -} - -var clearScratchpad = func(i) { - scratchpadNode[i].setValue(""); +var mcdu_message = func(i, string) { + mcdu_scratchpad.scratchpads[i].showTypeI(mcdu_scratchpad.MessageController.getTypeIMsgByText(string)); } var screenFlash = func(time, i) { diff --git a/Nasal/MCDU/PERFAPPR.nas b/Nasal/MCDU/PERFAPPR.nas index 3eb8f2fe..2e986681 100644 --- a/Nasal/MCDU/PERFAPPR.nas +++ b/Nasal/MCDU/PERFAPPR.nas @@ -9,33 +9,30 @@ var perfAPPRInput = func(key, i) { if (key == "L1") { if (scratchpad == "CLR") { setprop("/FMGC/internal/dest-qnh", -1); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (num(scratchpad) != nil and (scratchpad >= 28.06 and scratchpad <= 31.01) or (scratchpad >= 745 and scratchpad <= 1050)) { # doesn't support accidental temp input yet setprop("/FMGC/internal/dest-qnh", scratchpad); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L2") { if (scratchpad == "CLR") { setprop("/FMGC/internal/dest-temp", -999); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (num(scratchpad) != nil and scratchpad >= -99 and scratchpad < 99) { setprop("/FMGC/internal/dest-temp", scratchpad); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L3") { var tfs = size(scratchpad); if (scratchpad == "CLR") { setprop("/FMGC/internal/dest-mag", -1); setprop("/FMGC/internal/dest-wind", -1); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (tfs >= 3 and tfs <= 7 and find("/", scratchpad) != -1) { var weather = split("/", scratchpad); var mag = int(weather[0]); @@ -46,96 +43,92 @@ var perfAPPRInput = func(key, i) { if (mag != nil and wind != nil and mag >= 0 and mag <= 360 and wind >= 0 and wind <= 200) { setprop("/FMGC/internal/dest-mag", weather[0]); setprop("/FMGC/internal/dest-wind", weather[1]); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); fmgc.updateARPT(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L4") { if (scratchpad == "CLR") { fmgc.FMGCInternal.transAlt = 18000; fmgc.FMGCInternal.transAltSet = 0; - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (int(scratchpad) != nil and (tfs == 4 or tfs == 5) and scratchpad >= 1000 and scratchpad <= 39000) { fmgc.FMGCInternal.transAlt = math.round(scratchpad, 500); fmgc.FMGCInternal.transAltSet = 1; - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } elsif (int(scratchpad) != nil and (tfs == 2 or tfs == 3) and scratchpad >= 10 and scratchpad <= 390) { fmgc.FMGCInternal.transAlt = math.round(scratchpad * 100, 5); fmgc.FMGCInternal.transAltSet = 1; - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L5") { if (scratchpad == "CLR") { setprop("/FMGC/internal/vapp-speed-set", 0); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (int(scratchpad) != nil and scratchpad >= 100 and scratchpad <= 350) { setprop("/FMGC/internal/vapp-speed-set", 1); setprop("/FMGC/internal/computed-speeds/vapp_appr", scratchpad); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L6") { setprop("/MCDU[" ~ i ~ "]/page", "PERFDES"); } else if (key == "R2") { if (scratchpad == "CLR") { setprop("/FMGC/internal/baro", 99999); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (int(scratchpad) != nil and scratchpad >= getprop("/FMGC/internal/ldg-elev") and scratchpad <= 5000 + getprop("/FMGC/internal/ldg-elev")) { if (getprop("/FMGC/internal/radio-no") == 0) { setprop("/FMGC/internal/radio", 99999); } setprop("/FMGC/internal/baro", scratchpad); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "R3") { if (scratchpad == "CLR") { setprop("/FMGC/internal/radio", 99999); setprop("/FMGC/internal/radio-no", 0); - setprop("/MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (scratchpad == "NO") { setprop("/FMGC/internal/radio", 99999); setprop("/FMGC/internal/radio-no", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (int(scratchpad) != nil and scratchpad >= 0 and scratchpad <= 700) { setprop("/FMGC/internal/baro", 99999); setprop("/FMGC/internal/radio-no", 0); setprop("/FMGC/internal/radio", scratchpad); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "R4") { if (scratchpad == "" and ldg_config_f_set.getValue() == 1 and ldg_config_3_set.getValue() == 0) { setprop("/FMGC/internal/ldg-config-3-set", 1); setprop("/FMGC/internal/ldg-config-f-set", 0); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "R5") { if (scratchpad == "" and ldg_config_3_set.getValue() == 1 and ldg_config_f_set.getValue() == 0) { setprop("/FMGC/internal/ldg-config-3-set", 0); setprop("/FMGC/internal/ldg-config-f-set", 1); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "R6") { setprop("/MCDU[" ~ i ~ "]/page", "PERFGA"); diff --git a/Nasal/MCDU/PERFCLB.nas b/Nasal/MCDU/PERFCLB.nas index 6a30216a..f57d1b7a 100644 --- a/Nasal/MCDU/PERFCLB.nas +++ b/Nasal/MCDU/PERFCLB.nas @@ -8,8 +8,7 @@ var perfCLBInput = func(key, i) { if (scratchpad == "CLR") { setprop("/FMGC/internal/cost-index", 0); setprop("/FMGC/internal/cost-index-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var ci = int(scratchpad); var cis = size(scratchpad); @@ -17,20 +16,19 @@ var perfCLBInput = func(key, i) { if (ci != nil and ci >= 0 and ci <= 999) { setprop("/FMGC/internal/cost-index", ci); setprop("/FMGC/internal/cost-index-set", 1); - setprop("MCDU[" ~ i ~ "]/scratchpad", ""); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L5") { if (getprop("/FMGC/status/phase") == 2) { setprop("MCDU[" ~ i ~ "]/page", "PERFTO"); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L6") { if (getprop("/FMGC/status/phase") == 2) { @@ -41,7 +39,7 @@ var perfCLBInput = func(key, i) { setprop("/FMGC/internal/decel", 1); setprop("MCDU[" ~ i ~ "]/page", "PERFAPPR"); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { setprop("/FMGC/internal/activate-once", 1); diff --git a/Nasal/MCDU/PERFCRZ.nas b/Nasal/MCDU/PERFCRZ.nas index 9cfda4af..b26af62c 100644 --- a/Nasal/MCDU/PERFCRZ.nas +++ b/Nasal/MCDU/PERFCRZ.nas @@ -8,8 +8,7 @@ var perfCRZInput = func(key, i) { if (scratchpad == "CLR") { setprop("/FMGC/internal/cost-index", 0); setprop("/FMGC/internal/cost-index-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var ci = int(scratchpad); var cis = size(scratchpad); @@ -17,12 +16,12 @@ var perfCRZInput = func(key, i) { if (ci != nil and ci >= 0 and ci <= 999) { setprop("/FMGC/internal/cost-index", ci); setprop("/FMGC/internal/cost-index-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L6") { @@ -34,7 +33,7 @@ var perfCRZInput = func(key, i) { setprop("/FMGC/internal/decel", 1); setprop("MCDU[" ~ i ~ "]/page", "PERFAPPR"); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { setprop("/FMGC/internal/activate-once", 1); diff --git a/Nasal/MCDU/PERFDES.nas b/Nasal/MCDU/PERFDES.nas index 9614440c..c3c5c611 100644 --- a/Nasal/MCDU/PERFDES.nas +++ b/Nasal/MCDU/PERFDES.nas @@ -8,8 +8,7 @@ var perfDESInput = func(key, i) { if (scratchpad == "CLR") { setprop("/FMGC/internal/cost-index", 0); setprop("/FMGC/internal/cost-index-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var ci = int(scratchpad); var cis = size(scratchpad); @@ -17,12 +16,12 @@ var perfDESInput = func(key, i) { if (ci != nil and ci >= 0 and ci <= 999) { setprop("/FMGC/internal/cost-index", ci); setprop("/FMGC/internal/cost-index-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L6") { @@ -34,7 +33,7 @@ var perfDESInput = func(key, i) { setprop("/FMGC/internal/decel", 1); setprop("MCDU[" ~ i ~ "]/page", "PERFAPPR"); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { setprop("/FMGC/internal/activate-once", 1); diff --git a/Nasal/MCDU/PERFGA.nas b/Nasal/MCDU/PERFGA.nas index c7b34543..09032900 100644 --- a/Nasal/MCDU/PERFGA.nas +++ b/Nasal/MCDU/PERFGA.nas @@ -9,8 +9,7 @@ var perfGAInput = func(key, i) { setprop("systems/thrust/clbreduc-ft", "1500"); setprop("/FMGC/internal/accel-agl-ft", "1500"); setprop("MCDUC/thracc-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs >= 7 and tfs <= 9 and find("/", scratchpad) != -1) { @@ -21,12 +20,12 @@ var perfGAInput = func(key, i) { setprop("systems/thrust/clbreduc-ft", thracc[0]); setprop("/FMGC/internal/accel-agl-ft", thracc[1]); setprop("MCDUC/thracc-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L6") { @@ -35,16 +34,15 @@ var perfGAInput = func(key, i) { if (scratchpad == "CLR") { setprop("/FMGC/internal/eng-out-reduc", "1500"); setprop("MCDUC/reducacc-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (int(scratchpad) != nil and tfs >= 3 and tfs <= 5) { setprop("/FMGC/internal/eng-out-reduc", scratchpad); setprop("MCDUC/reducacc-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } diff --git a/Nasal/MCDU/PERFTO.nas b/Nasal/MCDU/PERFTO.nas index 435ab078..b50fd2a7 100644 --- a/Nasal/MCDU/PERFTO.nas +++ b/Nasal/MCDU/PERFTO.nas @@ -10,49 +10,46 @@ var perfTOInput = func(key, i) { if (scratchpad == "CLR") { setprop("/FMGC/internal/v1", 0); setprop("/FMGC/internal/v1-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs == 3) { if (int(scratchpad) != nil and scratchpad >= 100 and scratchpad <= 350) { setprop("/FMGC/internal/v1", scratchpad); setprop("/FMGC/internal/v1-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L2") { if (getprop("/FMGC/status/phase") != 1) { if (scratchpad == "CLR") { setprop("/FMGC/internal/vr", 0); setprop("/FMGC/internal/vr-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs == 3) { if (int(scratchpad) != nil and scratchpad >= 100 and scratchpad <= 350) { setprop("/FMGC/internal/vr", scratchpad); setprop("/FMGC/internal/vr-set", 1); - setprop("MCDU[" ~ i ~ "]/scratchpad", ""); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L3") { if (getprop("/FMGC/status/phase") != 1) { @@ -60,8 +57,7 @@ var perfTOInput = func(key, i) { setprop("/FMGC/internal/v2", 0); setprop("/FMGC/internal/v2-set", 0); setprop("it-autoflight/settings/togaspd", 157); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs == 3) { @@ -69,31 +65,30 @@ var perfTOInput = func(key, i) { setprop("/FMGC/internal/v2", scratchpad); setprop("/FMGC/internal/v2-set", 1); setprop("it-autoflight/settings/togaspd", scratchpad); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (key == "L4") { if (scratchpad == "CLR") { fmgc.FMGCInternal.transAlt = 18000; fmgc.FMGCInternal.transAltSet = 0; - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (int(scratchpad) != nil and (tfs == 4 or tfs <= 5) and scratchpad >= 1000 and scratchpad <= 39000) { fmgc.FMGCInternal.transAlt = int(scratchpad / 10) * 10; fmgc.FMGCInternal.transAltSet = 1; - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L5") { @@ -101,8 +96,7 @@ var perfTOInput = func(key, i) { setprop("systems/thrust/clbreduc-ft", "1500"); setprop("/FMGC/internal/accel-agl-ft", "1500"); setprop("MCDUC/thracc-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (find("/", scratchpad) != -1) { @@ -115,18 +109,18 @@ var perfTOInput = func(key, i) { setprop("systems/thrust/clbreduc-ft", int(thrred / 10) * 10); setprop("/FMGC/internal/accel-agl-ft", int(acc / 10) * 10); setprop("MCDUC/thracc-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (thrreds == 0 and int(acc) != nil and (accs >= 3 and accs <= 5) and acc >= 400 and acc <= 39000) { setprop("/FMGC/internal/accel-agl-ft", int(acc / 10) * 10); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (num(scratchpad) != nil and (tfs >= 3 and tfs <= 5) and scratchpad >= 400 and scratchpad <= 39000) { setprop("systems/thrust/clbreduc-ft", int(scratchpad / 10) * 10); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "R3") { @@ -134,8 +128,7 @@ var perfTOInput = func(key, i) { setprop("/FMGC/internal/to-flap", 0); setprop("/FMGC/internal/to-ths", "0.0"); setprop("/FMGC/internal/flap-ths-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { if (find("/", scratchpad) != -1) { var flapths = split("/", scratchpad); @@ -150,62 +143,61 @@ var perfTOInput = func(key, i) { if (flaps == 0 and getprop("/FMGC/internal/flap-ths-set")) { if (trims == 5 and find("DN", trim) != -1 and validtrima) { setprop("/FMGC/internal/to-ths", -1 * trima); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (trims == 5 and find("DN", trim) != -1 and validtrimb) { setprop("/FMGC/internal/to-ths", -1 * trimb); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (trims == 5 and find("UP", trim) != -1 and validtrima) { setprop("/FMGC/internal/to-ths", trima); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (trims == 5 and find("UP", trim) != -1 and validtrimb) { setprop("/FMGC/internal/to-ths", trimb); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (flaps == 1 and num(flap) != nil and flap >= 0 and flap <= 3) { if (trims == 5 and find("DN", trim) != -1 and validtrima) { setprop("/FMGC/internal/to-flap", flap); setprop("/FMGC/internal/to-ths", -1 * trima); setprop("/FMGC/internal/flap-ths-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (trims == 5 and find("DN", trim) != -1 and validtrimb) { setprop("/FMGC/internal/to-flap", flap); setprop("/FMGC/internal/to-ths", -1 * trimb); setprop("/FMGC/internal/flap-ths-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (trims == 5 and find("UP", trim) != -1 and validtrima) { setprop("/FMGC/internal/to-flap", flap); setprop("/FMGC/internal/to-ths", trima); setprop("/FMGC/internal/flap-ths-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (trims == 5 and find("UP", trim) != -1 and validtrimb) { setprop("/FMGC/internal/to-flap", flap); setprop("/FMGC/internal/to-ths", trimb); setprop("/FMGC/internal/flap-ths-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else if (size(scratchpad) == 1 and num(scratchpad) != nil and scratchpad >= 0 and scratchpad <= 3) { setprop("/FMGC/internal/to-flap", scratchpad); if (!getprop("/FMGC/internal/flap-ths-set")) { setprop("/FMGC/internal/flap-ths-set", 1); } - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "R4") { if (scratchpad == "CLR") { setprop("/FMGC/internal/flex", 0); setprop("/FMGC/internal/flex-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs == 1 or tfs == 2) { @@ -214,28 +206,27 @@ var perfTOInput = func(key, i) { setprop("/FMGC/internal/flex-set", 1); var flex_calc = getprop("/FMGC/internal/flex") - getprop("environment/temperature-degc"); setprop("/FMGC/internal/flex-cmd", flex_calc); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "R5") { if (scratchpad == "CLR") { setprop("/FMGC/internal/eng-out-reduc", "1500"); setprop("MCDUC/reducacc-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (int(scratchpad) != nil and (tfs == 4 or tfs == 5) and scratchpad >= 1000 and scratchpad <= 39000) { setprop("/FMGC/internal/eng-out-reduc", scratchpad); setprop("MCDUC/reducacc-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "R6") { diff --git a/Nasal/MCDU/PROGCLB.nas b/Nasal/MCDU/PROGCLB.nas index 80dfec29..db5fcb53 100644 --- a/Nasal/MCDU/PROGCLB.nas +++ b/Nasal/MCDU/PROGCLB.nas @@ -11,13 +11,12 @@ var progCLBInput = func(key, i) { setprop("/FMGC/internal/activate-twice", 0); setprop("/FMGC/internal/decel", 0); } - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (int(scratchpad) != nil) { var crzs = size(scratchpad); if (crzs >= 1 and crzs <= 3 and scratchpad > 0 and scratchpad <= 430 and altSet.getValue() <= scratchpad * 100) { setprop("/FMGC/internal/cruise-fl-prog", scratchpad); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); if (getprop("/FMGC/status/phase") == 5) { setprop("/FMGC/status/phase", 3); setprop("/FMGC/internal/activate-once", 0); @@ -25,10 +24,10 @@ var progCLBInput = func(key, i) { setprop("/FMGC/internal/decel", 0); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } diff --git a/Nasal/MCDU/PROGCRZ.nas b/Nasal/MCDU/PROGCRZ.nas index 56283d2e..38eccee2 100644 --- a/Nasal/MCDU/PROGCRZ.nas +++ b/Nasal/MCDU/PROGCRZ.nas @@ -11,13 +11,12 @@ var progCRZInput = func(key, i) { setprop("/FMGC/internal/activate-twice", 0); setprop("/FMGC/internal/decel", 0); } - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (int(scratchpad) != nil) { var crzs = size(scratchpad); if (crzs >= 1 and crzs <= 3 and scratchpad > 0 and scratchpad <= 430 and altSet.getValue() <= scratchpad * 100) { setprop("/FMGC/internal/cruise-fl-prog", scratchpad); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); if (getprop("/FMGC/status/phase") == 5) { setprop("/FMGC/status/phase", 3); setprop("/FMGC/internal/activate-once", 0); @@ -25,10 +24,10 @@ var progCRZInput = func(key, i) { setprop("/FMGC/internal/decel", 0); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } diff --git a/Nasal/MCDU/PROGDES.nas b/Nasal/MCDU/PROGDES.nas index b400d0b9..69cbc55e 100644 --- a/Nasal/MCDU/PROGDES.nas +++ b/Nasal/MCDU/PROGDES.nas @@ -11,13 +11,12 @@ var progDESInput = func(key, i) { setprop("/FMGC/internal/activate-twice", 0); setprop("/FMGC/internal/decel", 0); } - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (int(scratchpad) != nil) { var crzs = size(scratchpad); if (crzs >= 1 and crzs <= 3 and scratchpad > 0 and scratchpad <= 430 and altSet.getValue() <= scratchpad * 100) { setprop("/FMGC/internal/cruise-fl-prog", scratchpad); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); if (getprop("/FMGC/status/phase") == 4 or getprop("/FMGC/status/phase") == 5 or getprop("/FMGC/status/phase") == 6) { setprop("/FMGC/status/phase", 3); setprop("/FMGC/internal/activate-once", 0); @@ -25,10 +24,10 @@ var progDESInput = func(key, i) { setprop("/FMGC/internal/decel", 0); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } diff --git a/Nasal/MCDU/PROGTO.nas b/Nasal/MCDU/PROGTO.nas index f1e74dde..d3dfbd65 100644 --- a/Nasal/MCDU/PROGTO.nas +++ b/Nasal/MCDU/PROGTO.nas @@ -7,18 +7,17 @@ var progTOInput = func(key, i) { if (key == "L1") { if (scratchpad == "CLR") { setprop("/FMGC/internal/cruise-fl-prog", getprop("/FMGC/internal/cruise-fl")); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else if (int(scratchpad) != nil) { var crzs = size(scratchpad); if (crzs >= 1 and crzs <= 3 and scratchpad > 0 and scratchpad <= 430 and altSet.getValue() <= scratchpad * 100 and getprop("/FMGC/internal/cruise-lvl-set")) { setprop("/FMGC/internal/cruise-fl-prog", scratchpad); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } diff --git a/Nasal/MCDU/RADNAV.nas b/Nasal/MCDU/RADNAV.nas index 0999ef4c..d8a47321 100644 --- a/Nasal/MCDU/RADNAV.nas +++ b/Nasal/MCDU/RADNAV.nas @@ -7,8 +7,7 @@ var radnavInput = func(key, i) { if (key == "L1") { if (scratchpad == "CLR") { setprop("/FMGC/internal/vor1freq-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs == 3 or tfs == 5 or tfs == 6) { @@ -17,47 +16,45 @@ var radnavInput = func(key, i) { or scratchpad == 109.10 or scratchpad == 109.15 or scratchpad == 109.30 or scratchpad == 109.35 or scratchpad == 109.50 or scratchpad == 109.55 or scratchpad == 109.70 or scratchpad == 109.75 or scratchpad == 109.90 or scratchpad == 109.95 or scratchpad == 110.10 or scratchpad == 110.15 or scratchpad == 110.30 or scratchpad == 110.35 or scratchpad == 110.50 or scratchpad == 110.55 or scratchpad == 110.70 or scratchpad == 110.75 or scratchpad == 110.90 or scratchpad == 110.95 or scratchpad == 111.10 or scratchpad == 111.15 or scratchpad == 111.30 or scratchpad == 111.35 or scratchpad == 111.50 or scratchpad == 111.55 or scratchpad == 111.70 or scratchpad == 111.75 or scratchpad == 111.90 or scratchpad == 111.95) { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } else { setprop("instrumentation/nav[2]/frequencies/selected-mhz", scratchpad); setprop("/FMGC/internal/vor1freq-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } } else if (scratchpad >= 112.00 and scratchpad <= 117.95) { setprop("instrumentation/nav[2]/frequencies/selected-mhz", scratchpad); setprop("/FMGC/internal/vor1freq-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L2") { if (scratchpad == "CLR") { setprop("/FMGC/internal/vor1crs-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs >= 1 and tfs <= 3) { if (scratchpad >= 0 and scratchpad <= 360) { setprop("instrumentation/nav[2]/radials/selected-deg", scratchpad); setprop("/FMGC/internal/vor1crs-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L3") { if (scratchpad == "CLR") { setprop("/FMGC/internal/ils1freq-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs == 3 or tfs == 5 or tfs == 6) { @@ -68,63 +65,60 @@ var radnavInput = func(key, i) { or scratchpad == 111.10 or scratchpad == 111.15 or scratchpad == 111.30 or scratchpad == 111.35 or scratchpad == 111.50 or scratchpad == 111.55 or scratchpad == 111.70 or scratchpad == 111.75 or scratchpad == 111.90 or scratchpad == 111.95) { setprop("instrumentation/nav[0]/frequencies/selected-mhz", scratchpad); setprop("/FMGC/internal/ils1freq-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); if (num(getprop("/FMGC/internal/ils1freq-calculated")) != 0 and num(getprop("/FMGC/internal/ils1freq-calculated")) != num(getprop("instrumentation/nav[0]/frequencies/selected-mhz"))) { genericMessage(i, "RWY/LS MISMATCH", "amb"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L4") { if (scratchpad == "CLR") { setprop("/FMGC/internal/ils1crs-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs >= 1 and tfs <= 3) { if (scratchpad >= 0 and scratchpad <= 360) { setprop("instrumentation/nav[0]/radials/selected-deg", scratchpad); setprop("/FMGC/internal/ils1crs-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "L5") { if (scratchpad == "CLR") { setprop("/FMGC/internal/adf1freq-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs == 3 or tfs == 4) { if (scratchpad >= 190 and scratchpad <= 1750) { setprop("instrumentation/adf[0]/frequencies/selected-khz", scratchpad); setprop("/FMGC/internal/adf1freq-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "R1") { if (scratchpad == "CLR") { setprop("/FMGC/internal/vor2freq-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs == 3 or tfs == 5 or tfs == 6) { @@ -133,59 +127,57 @@ var radnavInput = func(key, i) { or scratchpad == 109.10 or scratchpad == 109.15 or scratchpad == 109.30 or scratchpad == 109.35 or scratchpad == 109.50 or scratchpad == 109.55 or scratchpad == 109.70 or scratchpad == 109.75 or scratchpad == 109.90 or scratchpad == 109.95 or scratchpad == 110.10 or scratchpad == 110.15 or scratchpad == 110.30 or scratchpad == 110.35 or scratchpad == 110.50 or scratchpad == 110.55 or scratchpad == 110.70 or scratchpad == 110.75 or scratchpad == 110.90 or scratchpad == 110.95 or scratchpad == 111.10 or scratchpad == 111.15 or scratchpad == 111.30 or scratchpad == 111.35 or scratchpad == 111.50 or scratchpad == 111.55 or scratchpad == 111.70 or scratchpad == 111.75 or scratchpad == 111.90 or scratchpad == 111.95) { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } else { setprop("instrumentation/nav[3]/frequencies/selected-mhz", scratchpad); setprop("/FMGC/internal/vor2freq-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } } else if (scratchpad >= 112.00 and scratchpad <= 117.95) { setprop("instrumentation/nav[3]/frequencies/selected-mhz", scratchpad); setprop("/FMGC/internal/vor2freq-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "R2") { if (scratchpad == "CLR") { setprop("/FMGC/internal/vor2crs-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs >= 1 and tfs <= 3) { if (scratchpad >= 0 and scratchpad <= 360) { setprop("instrumentation/nav[3]/radials/selected-deg", scratchpad); setprop("/FMGC/internal/vor2crs-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } else if (key == "R5") { if (scratchpad == "CLR") { setprop("/FMGC/internal/adf2freq-set", 0); - setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { var tfs = size(scratchpad); if (tfs == 3 or tfs == 4) { if (scratchpad >= 190 and scratchpad <= 1750) { setprop("instrumentation/adf[1]/frequencies/selected-khz", scratchpad); setprop("/FMGC/internal/adf2freq-set", 1); - mcdu.clearScratchpad(i); + mcdu_scratchpad.scratchpads[i].empty(); } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } diff --git a/Nasal/MCDU/VERTREV.nas b/Nasal/MCDU/VERTREV.nas index 39bdc1fc..bc647651 100644 --- a/Nasal/MCDU/VERTREV.nas +++ b/Nasal/MCDU/VERTREV.nas @@ -118,8 +118,7 @@ var vertRev = { if (!dirToFlag) { fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); } else { - setprop("MCDU[" ~ me.computer ~ "]/scratchpad-msg", 1); - setprop("MCDU[" ~ me.computer ~ "]/scratchpad", "DIR TO IN PROGRESS"); + mcdu_message(me.computer, "DIR TO IN PROGRESS"); } me._checkTmpy(); }