diff --git a/A320-main.xml b/A320-main.xml index 859b3a0c..f0a86be2 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -4090,6 +4090,9 @@ Aircraft/A320-family/Models/Instruments/MCDU/MCDU.nas + + Aircraft/A320-family/Nasal/FMGC/mcdu-messages.nas + Aircraft/A320-family/Nasal/Autopush/autopush.nas diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index 5a96f980..845e3f98 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -217,7 +217,6 @@ var ldg_config_f_set = props.globals.getNode("/FMGC/internal/ldg-config-f-set", # Fetch nodes into vectors var pageProp = [props.globals.getNode("/MCDU[0]/page", 1), props.globals.getNode("/MCDU[1]/page", 1)]; var active = [props.globals.getNode("/MCDU[0]/active", 1), props.globals.getNode("/MCDU[1]/active", 1)]; -var scratchpad = [props.globals.getNode("/MCDU[0]/scratchpad", 1), props.globals.getNode("/MCDU[1]/scratchpad", 1)]; # Create Nodes: var pageSwitch = [props.globals.initNode("/MCDU[0]/internal/switch", 0, "BOOL"), props.globals.initNode("/MCDU[1]/internal/switch", 0, "BOOL")]; @@ -309,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(); @@ -384,260 +365,28 @@ var canvas_MCDU_base = { me["FPLN_Callsign"].hide(); } - if (myFpln[i].L1[0] == nil) { - me["Simple_L1"].hide(); - me["Simple_L1S"].hide(); - } else { - me["Simple_L1"].show(); - me["Simple_L1"].setText(myFpln[i].L1[0]); - if (myFpln[i].L1[1] != nil) { - me["Simple_L1S"].show(); - me["Simple_L1S"].setText(myFpln[i].L1[1]); - } else { - me["Simple_L1S"].hide(); - } - } + me.dynamicPageFunc(myFpln[i].L1, "Simple_L1"); + me.dynamicPageFunc(myFpln[i].L2, "Simple_L2"); + me.dynamicPageFunc(myFpln[i].L3, "Simple_L3"); + me.dynamicPageFunc(myFpln[i].L4, "Simple_L4"); + me.dynamicPageFunc(myFpln[i].L5, "Simple_L5"); - if (myFpln[i].L2[0] == nil) { - me["Simple_L2"].hide(); - me["Simple_L2S"].hide(); - } else { - me["Simple_L2"].show(); - me["Simple_L2"].setText(myFpln[i].L2[0]); - if (myFpln[i].L2[1] != nil) { - me["Simple_L2S"].show(); - me["Simple_L2S"].setText(myFpln[i].L2[1]); - } else { - me["Simple_L2S"].hide(); - } - } - - if (myFpln[i].L3[0] == nil) { - me["Simple_L3"].hide(); - me["Simple_L3S"].hide(); - } else { - me["Simple_L3"].show(); - me["Simple_L3"].setText(myFpln[i].L3[0]); - if (myFpln[i].L3[1] != nil) { - me["Simple_L3S"].show(); - me["Simple_L3S"].setText(myFpln[i].L3[1]); - } else { - me["Simple_L3S"].hide(); - } - } - - if (myFpln[i].L4[0] == nil) { - me["Simple_L4"].hide(); - me["Simple_L4S"].hide(); - } else { - me["Simple_L4"].show(); - me["Simple_L4"].setText(myFpln[i].L4[0]); - if (myFpln[i].L4[1] != nil) { - me["Simple_L4S"].show(); - me["Simple_L4S"].setText(myFpln[i].L4[1]); - } else { - me["Simple_L4S"].hide(); - } - } - - if (myFpln[i].L5[0] == nil) { - me["Simple_L5"].hide(); - me["Simple_L5S"].hide(); - } else { - me["Simple_L5"].show(); - me["Simple_L5"].setText(myFpln[i].L5[0]); - if (myFpln[i].L5[1] != nil) { - me["Simple_L5S"].show(); - me["Simple_L5S"].setText(myFpln[i].L5[1]); - } else { - me["Simple_L5S"].hide(); - } - } - - if (myFpln[i].L6[0] == nil or fmgc.flightPlanController.temporaryFlag[i]) { - me["Simple_L6"].hide(); - me["Simple_L6S"].hide(); - } else { - me["Simple_L6"].show(); - me["Simple_L6"].setText(myFpln[i].L6[0]); - if (myFpln[i].L6[1] != nil) { - me["Simple_L6S"].show(); - me["Simple_L6S"].setText(myFpln[i].L6[1]); - } else { - me["Simple_L6S"].hide(); - } - } me.colorLeft(myFpln[i].L1[2],myFpln[i].L2[2],myFpln[i].L3[2],myFpln[i].L4[2],myFpln[i].L5[2],myFpln[i].L6[2]); - if (myFpln[i].C1[0] == nil) { - me["Simple_C1"].hide(); - me["Simple_C1S"].hide(); - } else { - me["Simple_C1"].show(); - me["Simple_C1"].setText(myFpln[i].C1[0]); - if (myFpln[i].C1[1] != nil) { - me["Simple_C1S"].show(); - me["Simple_C1S"].setText(myFpln[i].C1[1]); - } else { - me["Simple_C1S"].hide(); - } - } - - if (myFpln[i].C2[0] == nil) { - me["Simple_C2"].hide(); - me["Simple_C2S"].hide(); - } else { - me["Simple_C2"].show(); - me["Simple_C2"].setText(myFpln[i].C2[0]); - if (myFpln[i].C2[1] != nil) { - me["Simple_C2S"].show(); - me["Simple_C2S"].setText(myFpln[i].C2[1]); - } else { - me["Simple_C2S"].hide(); - } - } - - if (myFpln[i].C3[0] == nil) { - me["Simple_C3"].hide(); - me["Simple_C3S"].hide(); - } else { - me["Simple_C3"].show(); - me["Simple_C3"].setText(myFpln[i].C3[0]); - if (myFpln[i].C3[1] != nil) { - me["Simple_C3S"].show(); - me["Simple_C3S"].setText(myFpln[i].C3[1]); - } else { - me["Simple_C3S"].hide(); - } - } - - if (myFpln[i].C4[0] == nil) { - me["Simple_C4"].hide(); - me["Simple_C4S"].hide(); - } else { - me["Simple_C4"].show(); - me["Simple_C4"].setText(myFpln[i].C4[0]); - if (myFpln[i].C4[1] != nil) { - me["Simple_C4S"].show(); - me["Simple_C4S"].setText(myFpln[i].C4[1]); - } else { - me["Simple_C4S"].hide(); - } - } - - if (myFpln[i].C5[0] == nil) { - me["Simple_C5"].hide(); - me["Simple_C5S"].hide(); - } else { - me["Simple_C5"].show(); - me["Simple_C5"].setText(myFpln[i].C5[0]); - if (myFpln[i].C5[1] != nil) { - me["Simple_C5S"].show(); - me["Simple_C5S"].setText(myFpln[i].C5[1]); - } else { - me["Simple_C5S"].hide(); - } - } - - if (myFpln[i].C6[0] == nil or fmgc.flightPlanController.temporaryFlag[i]) { - me["Simple_C6"].hide(); - me["Simple_C6S"].hide(); - } else { - me["Simple_C6"].show(); - me["Simple_C6"].setText(myFpln[i].C6[0]); - if (myFpln[i].C6[1] != nil) { - me["Simple_C6S"].show(); - me["Simple_C6S"].setText(myFpln[i].C6[1]); - } else { - me["Simple_C6S"].hide(); - } - } + me.dynamicPageFunc(myFpln[i].C1, "Simple_C1"); + me.dynamicPageFunc(myFpln[i].C2, "Simple_C2"); + me.dynamicPageFunc(myFpln[i].C3, "Simple_C3"); + me.dynamicPageFunc(myFpln[i].C4, "Simple_C4"); + me.dynamicPageFunc(myFpln[i].C5, "Simple_C5"); me.colorCenter(myFpln[i].C1[2],myFpln[i].C2[2],myFpln[i].C3[2],myFpln[i].C4[2],myFpln[i].C5[2],myFpln[i].C6[2]); - if (myFpln[i].R1[0] == nil) { - me["Simple_R1"].hide(); - me["Simple_R1S"].hide(); - } else { - me["Simple_R1"].show(); - me["Simple_R1"].setText(myFpln[i].R1[0]); - if (myFpln[i].R1[1] != nil) { - me["Simple_R1S"].show(); - me["Simple_R1S"].setText(myFpln[i].R1[1]); - } else { - me["Simple_R1S"].hide(); - } - } + me.dynamicPageFunc(myFpln[i].R1, "Simple_R1"); + me.dynamicPageFunc(myFpln[i].R2, "Simple_R2"); + me.dynamicPageFunc(myFpln[i].R3, "Simple_R3"); + me.dynamicPageFunc(myFpln[i].R4, "Simple_R4"); + me.dynamicPageFunc(myFpln[i].R5, "Simple_R5"); - if (myFpln[i].R2[0] == nil) { - me["Simple_R2"].hide(); - me["Simple_R2S"].hide(); - } else { - me["Simple_R2"].show(); - me["Simple_R2"].setText(myFpln[i].R2[0]); - if (myFpln[i].R2[1] != nil) { - me["Simple_R2S"].show(); - me["Simple_R2S"].setText(myFpln[i].R2[1]); - } else { - me["Simple_R2S"].hide(); - } - } - - if (myFpln[i].R3[0] == nil) { - me["Simple_R3"].hide(); - me["Simple_R3S"].hide(); - } else { - me["Simple_R3"].show(); - me["Simple_R3"].setText(myFpln[i].R3[0]); - if (myFpln[i].R3[1] != nil) { - me["Simple_R3S"].show(); - me["Simple_R3S"].setText(myFpln[i].R3[1]); - } else { - me["Simple_R3S"].hide(); - } - } - - if (myFpln[i].R4[0] == nil) { - me["Simple_R4"].hide(); - me["Simple_R4S"].hide(); - } else { - me["Simple_R4"].show(); - me["Simple_R4"].setText(myFpln[i].R4[0]); - if (myFpln[i].R4[1] != nil) { - me["Simple_R4S"].show(); - me["Simple_R4S"].setText(myFpln[i].R4[1]); - } else { - me["Simple_R4S"].hide(); - } - } - - if (myFpln[i].R5[0] == nil) { - me["Simple_R5"].hide(); - me["Simple_R5S"].hide(); - } else { - me["Simple_R5"].show(); - me["Simple_R5"].setText(myFpln[i].R5[0]); - if (myFpln[i].R5[1] != nil) { - me["Simple_R5S"].show(); - me["Simple_R5S"].setText(myFpln[i].R5[1]); - } else { - me["Simple_R5S"].hide(); - } - } - - if (myFpln[i].R6[0] == nil or fmgc.flightPlanController.temporaryFlag[i]) { - me["Simple_R6"].hide(); - me["Simple_R6S"].hide(); - } else { - me["Simple_R6"].show(); - me["Simple_R6"].setText(myFpln[i].R6[0]); - if (myFpln[i].R6[1] != nil) { - me["Simple_R6S"].show(); - me["Simple_R6S"].setText(myFpln[i].R6[1]); - } else { - me["Simple_R6S"].hide(); - } - } me.colorRight(myFpln[i].R1[2],myFpln[i].R2[2],myFpln[i].R3[2],myFpln[i].R4[2],myFpln[i].R5[2],myFpln[i].R6[2]); me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht"); @@ -645,13 +394,19 @@ var canvas_MCDU_base = { me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht"); me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht"); - #if (mcdu.FPLNLines[i].index == 0) { - # me["FPLN_From"].show(); - #} else { - # me["FPLN_From"].hide(); - #} + if (myFpln[i].scroll == 0) { + me["FPLN_FROM"].show(); + } else { + me["FPLN_FROM"].hide(); + } if (fmgc.flightPlanController.temporaryFlag[i]) { + me["Simple_L6"].hide(); + me["Simple_C6"].hide(); + me["Simple_R6"].hide(); + me["Simple_L6S"].hide(); + me["Simple_C6S"].hide(); + me["Simple_R6S"].hide(); if (!mcdu.dirToFlag) { me["FPLN_TMPY_group"].show(); me["DIRTO_TMPY_group"].hide(); @@ -662,6 +417,9 @@ var canvas_MCDU_base = { } else { me["FPLN_TMPY_group"].hide(); me["DIRTO_TMPY_group"].hide(); + me.dynamicPageFunc(myFpln[i].L6, "Simple_L6"); + me.dynamicPageFunc(myFpln[i].C6, "Simple_C6"); + me.dynamicPageFunc(myFpln[i].R6, "Simple_R6"); } } } else if (page == "MCDU") { @@ -3471,174 +3229,22 @@ var canvas_MCDU_base = { } } - if (myLatRev[i].L1[0] == nil) { - me["Simple_L1"].hide(); - me["Simple_L1S"].hide(); - } else { - me["Simple_L1"].show(); - me["Simple_L1"].setText(myLatRev[i].L1[0]); - if (myLatRev[i].L1[1] != nil) { - me["Simple_L1S"].show(); - me["Simple_L1S"].setText(myLatRev[i].L1[1]); - } else { - me["Simple_L1S"].hide(); - } - } + me.dynamicPageFunc(myLatRev[i].L1, "Simple_L1"); + me.dynamicPageFunc(myLatRev[i].L2, "Simple_L2"); + me.dynamicPageFunc(myLatRev[i].L3, "Simple_L3"); + me.dynamicPageFunc(myLatRev[i].L4, "Simple_L4"); + me.dynamicPageFunc(myLatRev[i].L5, "Simple_L5"); + me.dynamicPageFunc(myLatRev[i].L6, "Simple_L6"); - if (myLatRev[i].L2[0] == nil) { - me["Simple_L2"].hide(); - me["Simple_L2S"].hide(); - } else { - me["Simple_L2"].show(); - me["Simple_L2"].setText(myLatRev[i].L2[0]); - if (myLatRev[i].L2[1] != nil) { - me["Simple_L2S"].show(); - me["Simple_L2S"].setText(myLatRev[i].L2[1]); - } else { - me["Simple_L2S"].hide(); - } - } - - if (myLatRev[i].L3[0] == nil) { - me["Simple_L3"].hide(); - me["Simple_L3S"].hide(); - } else { - me["Simple_L3"].show(); - me["Simple_L3"].setText(myLatRev[i].L3[0]); - if (myLatRev[i].L3[1] != nil) { - me["Simple_L3S"].show(); - me["Simple_L3S"].setText(myLatRev[i].L3[1]); - } else { - me["Simple_L3S"].hide(); - } - } - - if (myLatRev[i].L4[0] == nil) { - me["Simple_L4"].hide(); - me["Simple_L4S"].hide(); - } else { - me["Simple_L4"].show(); - me["Simple_L4"].setText(myLatRev[i].L4[0]); - if (myLatRev[i].L4[1] != nil) { - me["Simple_L4S"].show(); - me["Simple_L4S"].setText(myLatRev[i].L4[1]); - } else { - me["Simple_L4S"].hide(); - } - } - - if (myLatRev[i].L5[0] == nil) { - me["Simple_L5"].hide(); - me["Simple_L5S"].hide(); - } else { - me["Simple_L5"].show(); - me["Simple_L5"].setText(myLatRev[i].L5[0]); - if (myLatRev[i].L5[1] != nil) { - me["Simple_L5S"].show(); - me["Simple_L5S"].setText(myLatRev[i].L5[1]); - } else { - me["Simple_L5S"].hide(); - } - } - - if (myLatRev[i].L6[0] == nil) { - me["Simple_L6"].hide(); - me["Simple_L6S"].hide(); - } else { - me["Simple_L6"].show(); - me["Simple_L6"].setText(myLatRev[i].L6[0]); - if (myLatRev[i].L6[1] != nil) { - me["Simple_L6S"].show(); - me["Simple_L6S"].setText(myLatRev[i].L6[1]); - } else { - me["Simple_L6S"].hide(); - } - } me.colorLeft(myLatRev[i].L1[2],myLatRev[i].L2[2],myLatRev[i].L3[2],myLatRev[i].L4[2],myLatRev[i].L5[2],myLatRev[i].L6[2]); + + me.dynamicPageFunc(myLatRev[i].R1, "Simple_R1"); + me.dynamicPageFunc(myLatRev[i].R2, "Simple_R2"); + me.dynamicPageFunc(myLatRev[i].R3, "Simple_R3"); + me.dynamicPageFunc(myLatRev[i].R4, "Simple_R4"); + me.dynamicPageFunc(myLatRev[i].R5, "Simple_R5"); + me.dynamicPageFunc(myLatRev[i].R6, "Simple_R6"); - if (myLatRev[i].R1[0] == nil) { - me["Simple_R1"].hide(); - me["Simple_R1S"].hide(); - } else { - me["Simple_R1"].show(); - me["Simple_R1"].setText(myLatRev[i].R1[0]); - if (myLatRev[i].R1[1] != nil) { - me["Simple_R1S"].show(); - me["Simple_R1S"].setText(myLatRev[i].R1[1]); - } else { - me["Simple_R1S"].hide(); - } - } - - if (myLatRev[i].R2[0] == nil) { - me["Simple_R2"].hide(); - me["Simple_R2S"].hide(); - } else { - me["Simple_R2"].show(); - me["Simple_R2"].setText(myLatRev[i].R2[0]); - if (myLatRev[i].R2[1] != nil) { - me["Simple_R2S"].show(); - me["Simple_R2S"].setText(myLatRev[i].R2[1]); - } else { - me["Simple_R2S"].hide(); - } - } - - if (myLatRev[i].R3[0] == nil) { - me["Simple_R3"].hide(); - me["Simple_R3S"].hide(); - } else { - me["Simple_R3"].show(); - me["Simple_R3"].setText(myLatRev[i].R3[0]); - if (myLatRev[i].R3[1] != nil) { - me["Simple_R3S"].show(); - me["Simple_R3S"].setText(myLatRev[i].R3[1]); - } else { - me["Simple_R3S"].hide(); - } - } - - if (myLatRev[i].R4[0] == nil) { - me["Simple_R4"].hide(); - me["Simple_R4S"].hide(); - } else { - me["Simple_R4"].show(); - me["Simple_R4"].setText(myLatRev[i].R4[0]); - if (myLatRev[i].R4[1] != nil) { - me["Simple_R4S"].show(); - me["Simple_R4S"].setText(myLatRev[i].R4[1]); - } else { - me["Simple_R4S"].hide(); - } - } - - if (myLatRev[i].R5[0] == nil) { - me["Simple_R5"].hide(); - me["Simple_R5S"].hide(); - } else { - me["Simple_R5"].show(); - me["Simple_R5"].setText(myLatRev[i].R5[0]); - if (myLatRev[i].R5[1] != nil) { - me["Simple_R5S"].show(); - me["Simple_R5S"].setText(myLatRev[i].R5[1]); - } else { - me["Simple_R5S"].hide(); - } - } - - if (myLatRev[i].R6[0] == nil) { - me["Simple_R6"].hide(); - me["Simple_R6S"].hide(); - } else { - me["Simple_R6"].show(); - me["Simple_R6"].setText(myLatRev[i].R6[0]); - if (myLatRev[i].R6[1] != nil) { - me["Simple_R6S"].show(); - me["Simple_R6S"].setText(myLatRev[i].R6[1]); - } else { - me["Simple_R6S"].hide(); - } - } me.colorRight(myLatRev[i].R1[2],myLatRev[i].R2[2],myLatRev[i].R3[2],myLatRev[i].R4[2],myLatRev[i].R5[2],myLatRev[i].R6[2]); } pageSwitch[i].setBoolValue(1); @@ -3735,174 +3341,22 @@ var canvas_MCDU_base = { } } - if (myVertRev[i].L1[0] == nil) { - me["Simple_L1"].hide(); - me["Simple_L1S"].hide(); - } else { - me["Simple_L1"].show(); - me["Simple_L1"].setText(myVertRev[i].L1[0]); - if (myVertRev[i].L1[1] != nil) { - me["Simple_L1S"].show(); - me["Simple_L1S"].setText(myVertRev[i].L1[1]); - } else { - me["Simple_L1S"].hide(); - } - } + me.dynamicPageFunc(myVertRev[i].L1, "Simple_L1"); + me.dynamicPageFunc(myVertRev[i].L2, "Simple_L2"); + me.dynamicPageFunc(myVertRev[i].L3, "Simple_L3"); + me.dynamicPageFunc(myVertRev[i].L4, "Simple_L4"); + me.dynamicPageFunc(myVertRev[i].L5, "Simple_L5"); + me.dynamicPageFunc(myVertRev[i].L6, "Simple_L6"); - if (myVertRev[i].L2[0] == nil) { - me["Simple_L2"].hide(); - me["Simple_L2S"].hide(); - } else { - me["Simple_L2"].show(); - me["Simple_L2"].setText(myVertRev[i].L2[0]); - if (myVertRev[i].L2[1] != nil) { - me["Simple_L2S"].show(); - me["Simple_L2S"].setText(myVertRev[i].L2[1]); - } else { - me["Simple_L2S"].hide(); - } - } - - if (myVertRev[i].L3[0] == nil) { - me["Simple_L3"].hide(); - me["Simple_L3S"].hide(); - } else { - me["Simple_L3"].show(); - me["Simple_L3"].setText(myVertRev[i].L3[0]); - if (myVertRev[i].L3[1] != nil) { - me["Simple_L3S"].show(); - me["Simple_L3S"].setText(myVertRev[i].L3[1]); - } else { - me["Simple_L3S"].hide(); - } - } - - if (myVertRev[i].L4[0] == nil) { - me["Simple_L4"].hide(); - me["Simple_L4S"].hide(); - } else { - me["Simple_L4"].show(); - me["Simple_L4"].setText(myVertRev[i].L4[0]); - if (myVertRev[i].L4[1] != nil) { - me["Simple_L4S"].show(); - me["Simple_L4S"].setText(myVertRev[i].L4[1]); - } else { - me["Simple_L4S"].hide(); - } - } - - if (myVertRev[i].L5[0] == nil) { - me["Simple_L5"].hide(); - me["Simple_L5S"].hide(); - } else { - me["Simple_L5"].show(); - me["Simple_L5"].setText(myVertRev[i].L5[0]); - if (myVertRev[i].L5[1] != nil) { - me["Simple_L5S"].show(); - me["Simple_L5S"].setText(myVertRev[i].L5[1]); - } else { - me["Simple_L5S"].hide(); - } - } - - if (myVertRev[i].L6[0] == nil) { - me["Simple_L6"].hide(); - me["Simple_L6S"].hide(); - } else { - me["Simple_L6"].show(); - me["Simple_L6"].setText(myVertRev[i].L6[0]); - if (myVertRev[i].L6[1] != nil) { - me["Simple_L6S"].show(); - me["Simple_L6S"].setText(myVertRev[i].L6[1]); - } else { - me["Simple_L6S"].hide(); - } - } me.colorLeft(myVertRev[i].L1[2],myVertRev[i].L2[2],myVertRev[i].L3[2],myVertRev[i].L4[2],myVertRev[i].L5[2],myVertRev[i].L6[2]); + + me.dynamicPageFunc(myVertRev[i].R1, "Simple_R1"); + me.dynamicPageFunc(myVertRev[i].R2, "Simple_R2"); + me.dynamicPageFunc(myVertRev[i].R3, "Simple_R3"); + me.dynamicPageFunc(myVertRev[i].R4, "Simple_R4"); + me.dynamicPageFunc(myVertRev[i].R5, "Simple_R5"); + me.dynamicPageFunc(myVertRev[i].R6, "Simple_R6"); - if (myVertRev[i].R1[0] == nil) { - me["Simple_R1"].hide(); - me["Simple_R1S"].hide(); - } else { - me["Simple_R1"].show(); - me["Simple_R1"].setText(myVertRev[i].R1[0]); - if (myVertRev[i].R1[1] != nil) { - me["Simple_R1S"].show(); - me["Simple_R1S"].setText(myVertRev[i].R1[1]); - } else { - me["Simple_R1S"].hide(); - } - } - - if (myVertRev[i].R2[0] == nil) { - me["Simple_R2"].hide(); - me["Simple_R2S"].hide(); - } else { - me["Simple_R2"].show(); - me["Simple_R2"].setText(myVertRev[i].R2[0]); - if (myVertRev[i].R2[1] != nil) { - me["Simple_R2S"].show(); - me["Simple_R2S"].setText(myVertRev[i].R2[1]); - } else { - me["Simple_R2S"].hide(); - } - } - - if (myVertRev[i].R3[0] == nil) { - me["Simple_R3"].hide(); - me["Simple_R3S"].hide(); - } else { - me["Simple_R3"].show(); - me["Simple_R3"].setText(myVertRev[i].R3[0]); - if (myVertRev[i].R3[1] != nil) { - me["Simple_R3S"].show(); - me["Simple_R3S"].setText(myVertRev[i].R3[1]); - } else { - me["Simple_R3S"].hide(); - } - } - - if (myVertRev[i].R4[0] == nil) { - me["Simple_R4"].hide(); - me["Simple_R4S"].hide(); - } else { - me["Simple_R4"].show(); - me["Simple_R4"].setText(myVertRev[i].R4[0]); - if (myVertRev[i].R4[1] != nil) { - me["Simple_R4S"].show(); - me["Simple_R4S"].setText(myVertRev[i].R4[1]); - } else { - me["Simple_R4S"].hide(); - } - } - - if (myVertRev[i].R5[0] == nil) { - me["Simple_R5"].hide(); - me["Simple_R5S"].hide(); - } else { - me["Simple_R5"].show(); - me["Simple_R5"].setText(myVertRev[i].R5[0]); - if (myVertRev[i].R5[1] != nil) { - me["Simple_R5S"].show(); - me["Simple_R5S"].setText(myVertRev[i].R5[1]); - } else { - me["Simple_R5S"].hide(); - } - } - - if (myVertRev[i].R6[0] == nil) { - me["Simple_R6"].hide(); - me["Simple_R6S"].hide(); - } else { - me["Simple_R6"].show(); - me["Simple_R6"].setText(myVertRev[i].R6[0]); - if (myVertRev[i].R6[1] != nil) { - me["Simple_R6S"].show(); - me["Simple_R6S"].setText(myVertRev[i].R6[1]); - } else { - me["Simple_R6S"].hide(); - } - } me.colorRight(myVertRev[i].R1[2],myVertRev[i].R2[2],myVertRev[i].R3[2],myVertRev[i].R4[2],myVertRev[i].R5[2],myVertRev[i].R6[2]); } pageSwitch[i].setBoolValue(1); @@ -3994,248 +3448,33 @@ var canvas_MCDU_base = { } } - if (myDeparture[i].L1[0] == nil) { - me["Simple_L1"].hide(); - me["Simple_L1S"].hide(); - } else { - me["Simple_L1"].show(); - me["Simple_L1"].setText(myDeparture[i].L1[0]); - if (myDeparture[i].L1[1] != nil) { - me["Simple_L1S"].show(); - me["Simple_L1S"].setText(myDeparture[i].L1[1]); - } else { - me["Simple_L1S"].hide(); - } - } + me.dynamicPageFunc(myDeparture[i].L1, "Simple_L1"); + me.dynamicPageFunc(myDeparture[i].L2, "Simple_L2"); + me.dynamicPageFunc(myDeparture[i].L3, "Simple_L3"); + me.dynamicPageFunc(myDeparture[i].L4, "Simple_L4"); + me.dynamicPageFunc(myDeparture[i].L5, "Simple_L5"); + me.dynamicPageFunc(myDeparture[i].L6, "Simple_L6"); - if (myDeparture[i].L2[0] == nil) { - me["Simple_L2"].hide(); - me["Simple_L2S"].hide(); - } else { - me["Simple_L2"].show(); - me["Simple_L2"].setText(myDeparture[i].L2[0]); - if (myDeparture[i].L2[1] != nil) { - me["Simple_L2S"].show(); - me["Simple_L2S"].setText(myDeparture[i].L2[1]); - } else { - me["Simple_L2S"].hide(); - } - } - - if (myDeparture[i].L3[0] == nil) { - me["Simple_L3"].hide(); - me["Simple_L3S"].hide(); - } else { - me["Simple_L3"].show(); - me["Simple_L3"].setText(myDeparture[i].L3[0]); - if (myDeparture[i].L3[1] != nil) { - me["Simple_L3S"].show(); - me["Simple_L3S"].setText(myDeparture[i].L3[1]); - } else { - me["Simple_L3S"].hide(); - } - } - - if (myDeparture[i].L4[0] == nil) { - me["Simple_L4"].hide(); - me["Simple_L4S"].hide(); - } else { - me["Simple_L4"].show(); - me["Simple_L4"].setText(myDeparture[i].L4[0]); - if (myDeparture[i].L4[1] != nil) { - me["Simple_L4S"].show(); - me["Simple_L4S"].setText(myDeparture[i].L4[1]); - } else { - me["Simple_L4S"].hide(); - } - } - - if (myDeparture[i].L5[0] == nil) { - me["Simple_L5"].hide(); - me["Simple_L5S"].hide(); - } else { - me["Simple_L5"].show(); - me["Simple_L5"].setText(myDeparture[i].L5[0]); - if (myDeparture[i].L5[1] != nil) { - me["Simple_L5S"].show(); - me["Simple_L5S"].setText(myDeparture[i].L5[1]); - } else { - me["Simple_L5S"].hide(); - } - } - - if (myDeparture[i].L6[0] == nil) { - me["Simple_L6"].hide(); - me["Simple_L6S"].hide(); - } else { - me["Simple_L6"].show(); - me["Simple_L6"].setText(myDeparture[i].L6[0]); - if (myDeparture[i].L6[1] != nil) { - me["Simple_L6S"].show(); - me["Simple_L6S"].setText(myDeparture[i].L6[1]); - } else { - me["Simple_L6S"].hide(); - } - } me.colorLeft(myDeparture[i].L1[2],myDeparture[i].L2[2],myDeparture[i].L3[2],myDeparture[i].L4[2],myDeparture[i].L5[2],myDeparture[i].L6[2]); - if (myDeparture[i].C1[0] == nil) { - me["Simple_C1"].hide(); - me["Simple_C1S"].hide(); - } else { - me["Simple_C1"].show(); - me["Simple_C1"].setText(myDeparture[i].C1[0]); - if (myDeparture[i].C1[1] != nil) { - me["Simple_C1S"].show(); - me["Simple_C1S"].setText(myDeparture[i].C1[1]); - } else { - me["Simple_C1S"].hide(); - } - } + me.dynamicPageFunc(myDeparture[i].C1, "Simple_C1"); + me.dynamicPageFunc(myDeparture[i].C2, "Simple_C2"); + me.dynamicPageFunc(myDeparture[i].C3, "Simple_C3"); + me.dynamicPageFunc(myDeparture[i].C4, "Simple_C4"); + me.dynamicPageFunc(myDeparture[i].C5, "Simple_C5"); - if (myDeparture[i].C2[0] == nil) { - me["Simple_C2"].hide(); - me["Simple_C2S"].hide(); - } else { - me["Simple_C2"].show(); - me["Simple_C2"].setText(myDeparture[i].C2[0]); - if (myDeparture[i].C2[1] != nil) { - me["Simple_C2S"].show(); - me["Simple_C2S"].setText(myDeparture[i].C2[1]); - } else { - me["Simple_C2S"].hide(); - } - } - - if (myDeparture[i].C3[0] == nil) { - me["Simple_C3"].hide(); - me["Simple_C3S"].hide(); - } else { - me["Simple_C3"].show(); - me["Simple_C3"].setText(myDeparture[i].C3[0]); - if (myDeparture[i].C3[1] != nil) { - me["Simple_C3S"].show(); - me["Simple_C3S"].setText(myDeparture[i].C3[1]); - } else { - me["Simple_C3S"].hide(); - } - } - - if (myDeparture[i].C4[0] == nil) { - me["Simple_C4"].hide(); - me["Simple_C4S"].hide(); - } else { - me["Simple_C4"].show(); - me["Simple_C4"].setText(myDeparture[i].C4[0]); - if (myDeparture[i].C4[1] != nil) { - me["Simple_C4S"].show(); - me["Simple_C4S"].setText(myDeparture[i].C4[1]); - } else { - me["Simple_C4S"].hide(); - } - } - - if (myDeparture[i].C5[0] == nil) { - me["Simple_C5"].hide(); - me["Simple_C5S"].hide(); - } else { - me["Simple_C5"].show(); - me["Simple_C5"].setText(myDeparture[i].C5[0]); - if (myDeparture[i].C5[1] != nil) { - me["Simple_C5S"].show(); - me["Simple_C5S"].setText(myDeparture[i].C5[1]); - } else { - me["Simple_C5S"].hide(); - } - } me.colorCenter(myDeparture[i].C1[2],myDeparture[i].C2[2],myDeparture[i].C3[2],myDeparture[i].C4[2],myDeparture[i].C5[2],myDeparture[i].C6[2]); me["Simple_C6"].hide(); me["Simple_C6S"].hide(); - if (myDeparture[i].R1[0] == nil) { - me["Simple_R1"].hide(); - me["Simple_R1S"].hide(); - } else { - me["Simple_R1"].show(); - me["Simple_R1"].setText(myDeparture[i].R1[0]); - if (myDeparture[i].R1[1] != nil) { - me["Simple_R1S"].show(); - me["Simple_R1S"].setText(myDeparture[i].R1[1]); - } else { - me["Simple_R1S"].hide(); - } - } + me.dynamicPageFunc(myDeparture[i].R1, "Simple_R1"); + me.dynamicPageFunc(myDeparture[i].R2, "Simple_R2"); + me.dynamicPageFunc(myDeparture[i].R3, "Simple_R3"); + me.dynamicPageFunc(myDeparture[i].R4, "Simple_R4"); + me.dynamicPageFunc(myDeparture[i].R5, "Simple_R5"); + me.dynamicPageFunc(myDeparture[i].R6, "Simple_R6"); - if (myDeparture[i].R2[0] == nil) { - me["Simple_R2"].hide(); - me["Simple_R2S"].hide(); - } else { - me["Simple_R2"].show(); - me["Simple_R2"].setText(myDeparture[i].R2[0]); - if (myDeparture[i].R2[1] != nil) { - me["Simple_R2S"].show(); - me["Simple_R2S"].setText(myDeparture[i].R2[1]); - } else { - me["Simple_R2S"].hide(); - } - } - - if (myDeparture[i].R3[0] == nil) { - me["Simple_R3"].hide(); - me["Simple_R3S"].hide(); - } else { - me["Simple_R3"].show(); - me["Simple_R3"].setText(myDeparture[i].R3[0]); - if (myDeparture[i].R3[1] != nil) { - me["Simple_R3S"].show(); - me["Simple_R3S"].setText(myDeparture[i].R3[1]); - } else { - me["Simple_R3S"].hide(); - } - } - - if (myDeparture[i].R4[0] == nil) { - me["Simple_R4"].hide(); - me["Simple_R4S"].hide(); - } else { - me["Simple_R4"].show(); - me["Simple_R4"].setText(myDeparture[i].R4[0]); - if (myDeparture[i].R4[1] != nil) { - me["Simple_R4S"].show(); - me["Simple_R4S"].setText(myDeparture[i].R4[1]); - } else { - me["Simple_R4S"].hide(); - } - } - - if (myDeparture[i].R5[0] == nil) { - me["Simple_R5"].hide(); - me["Simple_R5S"].hide(); - } else { - me["Simple_R5"].show(); - me["Simple_R5"].setText(myDeparture[i].R5[0]); - if (myDeparture[i].R5[1] != nil) { - me["Simple_R5S"].show(); - me["Simple_R5S"].setText(myDeparture[i].R5[1]); - } else { - me["Simple_R5S"].hide(); - } - } - - if (myDeparture[i].R6[0] == nil) { - me["Simple_R6"].hide(); - me["Simple_R6S"].hide(); - } else { - me["Simple_R6"].show(); - me["Simple_R6"].setText(myDeparture[i].R6[0]); - if (myDeparture[i].R6[1] != nil) { - me["Simple_R6S"].show(); - me["Simple_R6S"].setText(myDeparture[i].R6[1]); - } else { - me["Simple_R6S"].hide(); - } - } me.colorRight(myDeparture[i].R1[2],myDeparture[i].R2[2],myDeparture[i].R3[2],myDeparture[i].R4[2],myDeparture[i].R5[2],myDeparture[i].R6[2]); } pageSwitch[i].setBoolValue(1); @@ -4314,249 +3553,33 @@ var canvas_MCDU_base = { } } - if (myDuplicate[i].L1[0] == nil) { - me["Simple_L1"].hide(); - me["Simple_L1S"].hide(); - } else { - me["Simple_L1"].show(); - me["Simple_L1"].setText(myDuplicate[i].L1[0]); - if (myDuplicate[i].L1[1] != nil) { - me["Simple_L1S"].show(); - me["Simple_L1S"].setText(myDuplicate[i].L1[1]); - } else { - me["Simple_L1S"].hide(); - } - } + me.dynamicPageFunc(myDuplicate[i].L1, "Simple_L1"); + me.dynamicPageFunc(myDuplicate[i].L2, "Simple_L2"); + me.dynamicPageFunc(myDuplicate[i].L3, "Simple_L3"); + me.dynamicPageFunc(myDuplicate[i].L4, "Simple_L4"); + me.dynamicPageFunc(myDuplicate[i].L5, "Simple_L5"); + me.dynamicPageFunc(myDuplicate[i].L6, "Simple_L6"); - if (myDuplicate[i].L2[0] == nil) { - me["Simple_L2"].hide(); - me["Simple_L2S"].hide(); - } else { - me["Simple_L2"].show(); - me["Simple_L2"].setText(myDuplicate[i].L2[0]); - if (myDuplicate[i].L2[1] != nil) { - me["Simple_L2S"].show(); - me["Simple_L2S"].setText(myDuplicate[i].L2[1]); - } else { - me["Simple_L2S"].hide(); - } - } - - if (myDuplicate[i].L3[0] == nil) { - me["Simple_L3"].hide(); - me["Simple_L3S"].hide(); - } else { - me["Simple_L3"].show(); - me["Simple_L3"].setText(myDuplicate[i].L3[0]); - if (myDuplicate[i].L3[1] != nil) { - me["Simple_L3S"].show(); - me["Simple_L3S"].setText(myDuplicate[i].L3[1]); - } else { - me["Simple_L3S"].hide(); - } - } - - if (myDuplicate[i].L4[0] == nil) { - me["Simple_L4"].hide(); - me["Simple_L4S"].hide(); - } else { - me["Simple_L4"].show(); - me["Simple_L4"].setText(myDuplicate[i].L4[0]); - if (myDuplicate[i].L4[1] != nil) { - me["Simple_L4S"].show(); - me["Simple_L4S"].setText(myDuplicate[i].L4[1]); - } else { - me["Simple_L4S"].hide(); - } - } - - if (myDuplicate[i].L5[0] == nil) { - me["Simple_L5"].hide(); - me["Simple_L5S"].hide(); - } else { - me["Simple_L5"].show(); - me["Simple_L5"].setText(myDuplicate[i].L5[0]); - if (myDuplicate[i].L5[1] != nil) { - me["Simple_L5S"].show(); - me["Simple_L5S"].setText(myDuplicate[i].L5[1]); - } else { - me["Simple_L5S"].hide(); - } - } - - if (myDuplicate[i].L6[0] == nil) { - me["Simple_L6"].hide(); - me["Simple_L6S"].hide(); - } else { - me["Simple_L6"].show(); - me["Simple_L6"].setText(myDuplicate[i].L6[0]); - if (myDuplicate[i].L6[1] != nil) { - me["Simple_L6S"].show(); - me["Simple_L6S"].setText(myDuplicate[i].L6[1]); - } else { - me["Simple_L6S"].hide(); - } - } me.colorLeft(myDuplicate[i].L1[2],myDuplicate[i].L2[2],myDuplicate[i].L3[2],myDuplicate[i].L4[2],myDuplicate[i].L5[2],myDuplicate[i].L6[2]); + me.dynamicPageFunc(myDuplicate[i].C1, "Simple_C1"); + me.dynamicPageFunc(myDuplicate[i].C2, "Simple_C2"); + me.dynamicPageFunc(myDuplicate[i].C3, "Simple_C3"); + me.dynamicPageFunc(myDuplicate[i].C4, "Simple_C4"); + me.dynamicPageFunc(myDuplicate[i].C5, "Simple_C5"); - if (myDuplicate[i].C1[0] == nil) { - me["Simple_C1"].hide(); - me["Simple_C1S"].hide(); - } else { - me["Simple_C1"].show(); - me["Simple_C1"].setText(myDuplicate[i].C1[0]); - if (myDuplicate[i].C1[1] != nil) { - me["Simple_C1S"].show(); - me["Simple_C1S"].setText(myDuplicate[i].C1[1]); - } else { - me["Simple_C1S"].hide(); - } - } - - if (myDuplicate[i].C2[0] == nil) { - me["Simple_C2"].hide(); - me["Simple_C2S"].hide(); - } else { - me["Simple_C2"].show(); - me["Simple_C2"].setText(myDuplicate[i].C2[0]); - if (myDuplicate[i].C2[1] != nil) { - me["Simple_C2S"].show(); - me["Simple_C2S"].setText(myDuplicate[i].C2[1]); - } else { - me["Simple_C2S"].hide(); - } - } - - if (myDuplicate[i].C3[0] == nil) { - me["Simple_C3"].hide(); - me["Simple_C3S"].hide(); - } else { - me["Simple_C3"].show(); - me["Simple_C3"].setText(myDuplicate[i].C3[0]); - if (myDuplicate[i].C3[1] != nil) { - me["Simple_C3S"].show(); - me["Simple_C3S"].setText(myDuplicate[i].C3[1]); - } else { - me["Simple_C3S"].hide(); - } - } - - if (myDuplicate[i].C4[0] == nil) { - me["Simple_C4"].hide(); - me["Simple_C4S"].hide(); - } else { - me["Simple_C4"].show(); - me["Simple_C4"].setText(myDuplicate[i].C4[0]); - if (myDuplicate[i].C4[1] != nil) { - me["Simple_C4S"].show(); - me["Simple_C4S"].setText(myDuplicate[i].C4[1]); - } else { - me["Simple_C4S"].hide(); - } - } - - if (myDuplicate[i].C5[0] == nil) { - me["Simple_C5"].hide(); - me["Simple_C5S"].hide(); - } else { - me["Simple_C5"].show(); - me["Simple_C5"].setText(myDuplicate[i].C5[0]); - if (myDuplicate[i].C5[1] != nil) { - me["Simple_C5S"].show(); - me["Simple_C5S"].setText(myDuplicate[i].C5[1]); - } else { - me["Simple_C5S"].hide(); - } - } me.colorCenter(myDuplicate[i].C1[2],myDuplicate[i].C2[2],myDuplicate[i].C3[2],myDuplicate[i].C4[2],myDuplicate[i].C5[2],myDuplicate[i].C6[2]); me["Simple_C6"].hide(); me["Simple_C6S"].hide(); + + me.dynamicPageFunc(myDuplicate[i].R1, "Simple_R1"); + me.dynamicPageFunc(myDuplicate[i].R2, "Simple_R2"); + me.dynamicPageFunc(myDuplicate[i].R3, "Simple_R3"); + me.dynamicPageFunc(myDuplicate[i].R4, "Simple_R4"); + me.dynamicPageFunc(myDuplicate[i].R5, "Simple_R5"); + me.dynamicPageFunc(myDuplicate[i].R6, "Simple_R6"); - if (myDuplicate[i].R1[0] == nil) { - me["Simple_R1"].hide(); - me["Simple_R1S"].hide(); - } else { - me["Simple_R1"].show(); - me["Simple_R1"].setText(myDuplicate[i].R1[0]); - if (myDuplicate[i].R1[1] != nil) { - me["Simple_R1S"].show(); - me["Simple_R1S"].setText(myDuplicate[i].R1[1]); - } else { - me["Simple_R1S"].hide(); - } - } - - if (myDuplicate[i].R2[0] == nil) { - me["Simple_R2"].hide(); - me["Simple_R2S"].hide(); - } else { - me["Simple_R2"].show(); - me["Simple_R2"].setText(myDuplicate[i].R2[0]); - if (myDuplicate[i].R2[1] != nil) { - me["Simple_R2S"].show(); - me["Simple_R2S"].setText(myDuplicate[i].R2[1]); - } else { - me["Simple_R2S"].hide(); - } - } - - if (myDuplicate[i].R3[0] == nil) { - me["Simple_R3"].hide(); - me["Simple_R3S"].hide(); - } else { - me["Simple_R3"].show(); - me["Simple_R3"].setText(myDuplicate[i].R3[0]); - if (myDuplicate[i].R3[1] != nil) { - me["Simple_R3S"].show(); - me["Simple_R3S"].setText(myDuplicate[i].R3[1]); - } else { - me["Simple_R3S"].hide(); - } - } - - if (myDuplicate[i].R4[0] == nil) { - me["Simple_R4"].hide(); - me["Simple_R4S"].hide(); - } else { - me["Simple_R4"].show(); - me["Simple_R4"].setText(myDuplicate[i].R4[0]); - if (myDuplicate[i].R4[1] != nil) { - me["Simple_R4S"].show(); - me["Simple_R4S"].setText(myDuplicate[i].R4[1]); - } else { - me["Simple_R4S"].hide(); - } - } - - if (myDuplicate[i].R5[0] == nil) { - me["Simple_R5"].hide(); - me["Simple_R5S"].hide(); - } else { - me["Simple_R5"].show(); - me["Simple_R5"].setText(myDuplicate[i].R5[0]); - if (myDuplicate[i].R5[1] != nil) { - me["Simple_R5S"].show(); - me["Simple_R5S"].setText(myDuplicate[i].R5[1]); - } else { - me["Simple_R5S"].hide(); - } - } - - if (myDuplicate[i].R6[0] == nil) { - me["Simple_R6"].hide(); - me["Simple_R6S"].hide(); - } else { - me["Simple_R6"].show(); - me["Simple_R6"].setText(myDuplicate[i].R6[0]); - if (myDuplicate[i].R6[1] != nil) { - me["Simple_R6S"].show(); - me["Simple_R6S"].setText(myDuplicate[i].R6[1]); - } else { - me["Simple_R6S"].hide(); - } - } me.colorRight(myDuplicate[i].R1[2],myDuplicate[i].R2[2],myDuplicate[i].R3[2],myDuplicate[i].R4[2],myDuplicate[i].R5[2],myDuplicate[i].R6[2]); } pageSwitch[i].setBoolValue(1); @@ -4648,248 +3671,33 @@ var canvas_MCDU_base = { } } - if (myArrival[i].L1[0] == nil) { - me["Simple_L1"].hide(); - me["Simple_L1S"].hide(); - } else { - me["Simple_L1"].show(); - me["Simple_L1"].setText(myArrival[i].L1[0]); - if (myArrival[i].L1[1] != nil) { - me["Simple_L1S"].show(); - me["Simple_L1S"].setText(myArrival[i].L1[1]); - } else { - me["Simple_L1S"].hide(); - } - } + me.dynamicPageFunc(myArrival[i].L1, "Simple_L1"); + me.dynamicPageFunc(myArrival[i].L2, "Simple_L2"); + me.dynamicPageFunc(myArrival[i].L3, "Simple_L3"); + me.dynamicPageFunc(myArrival[i].L4, "Simple_L4"); + me.dynamicPageFunc(myArrival[i].L5, "Simple_L5"); + me.dynamicPageFunc(myArrival[i].L6, "Simple_L6"); - if (myArrival[i].L2[0] == nil) { - me["Simple_L2"].hide(); - me["Simple_L2S"].hide(); - } else { - me["Simple_L2"].show(); - me["Simple_L2"].setText(myArrival[i].L2[0]); - if (myArrival[i].L2[1] != nil) { - me["Simple_L2S"].show(); - me["Simple_L2S"].setText(myArrival[i].L2[1]); - } else { - me["Simple_L2S"].hide(); - } - } - - if (myArrival[i].L3[0] == nil) { - me["Simple_L3"].hide(); - me["Simple_L3S"].hide(); - } else { - me["Simple_L3"].show(); - me["Simple_L3"].setText(myArrival[i].L3[0]); - if (myArrival[i].L3[1] != nil) { - me["Simple_L3S"].show(); - me["Simple_L3S"].setText(myArrival[i].L3[1]); - } else { - me["Simple_L3S"].hide(); - } - } - - if (myArrival[i].L4[0] == nil) { - me["Simple_L4"].hide(); - me["Simple_L4S"].hide(); - } else { - me["Simple_L4"].show(); - me["Simple_L4"].setText(myArrival[i].L4[0]); - if (myArrival[i].L4[1] != nil) { - me["Simple_L4S"].show(); - me["Simple_L4S"].setText(myArrival[i].L4[1]); - } else { - me["Simple_L4S"].hide(); - } - } - - if (myArrival[i].L5[0] == nil) { - me["Simple_L5"].hide(); - me["Simple_L5S"].hide(); - } else { - me["Simple_L5"].show(); - me["Simple_L5"].setText(myArrival[i].L5[0]); - if (myArrival[i].L5[1] != nil) { - me["Simple_L5S"].show(); - me["Simple_L5S"].setText(myArrival[i].L5[1]); - } else { - me["Simple_L5S"].hide(); - } - } - - if (myArrival[i].L6[0] == nil) { - me["Simple_L6"].hide(); - me["Simple_L6S"].hide(); - } else { - me["Simple_L6"].show(); - me["Simple_L6"].setText(myArrival[i].L6[0]); - if (myArrival[i].L6[1] != nil) { - me["Simple_L6S"].show(); - me["Simple_L6S"].setText(myArrival[i].L6[1]); - } else { - me["Simple_L6S"].hide(); - } - } me.colorLeft(myArrival[i].L1[2],myArrival[i].L2[2],myArrival[i].L3[2],myArrival[i].L4[2],myArrival[i].L5[2],myArrival[i].L6[2]); - if (myArrival[i].C1[0] == nil) { - me["Simple_C1"].hide(); - me["Simple_C1S"].hide(); - } else { - me["Simple_C1"].show(); - me["Simple_C1"].setText(myArrival[i].C1[0]); - if (myArrival[i].C1[1] != nil) { - me["Simple_C1S"].show(); - me["Simple_C1S"].setText(myArrival[i].C1[1]); - } else { - me["Simple_C1S"].hide(); - } - } + me.dynamicPageFunc(myArrival[i].C1, "Simple_C1"); + me.dynamicPageFunc(myArrival[i].C2, "Simple_C2"); + me.dynamicPageFunc(myArrival[i].C3, "Simple_C3"); + me.dynamicPageFunc(myArrival[i].C4, "Simple_C4"); + me.dynamicPageFunc(myArrival[i].C5, "Simple_C5"); - if (myArrival[i].C2[0] == nil) { - me["Simple_C2"].hide(); - me["Simple_C2S"].hide(); - } else { - me["Simple_C2"].show(); - me["Simple_C2"].setText(myArrival[i].C2[0]); - if (myArrival[i].C2[1] != nil) { - me["Simple_C2S"].show(); - me["Simple_C2S"].setText(myArrival[i].C2[1]); - } else { - me["Simple_C2S"].hide(); - } - } - - if (myArrival[i].C3[0] == nil) { - me["Simple_C3"].hide(); - me["Simple_C3S"].hide(); - } else { - me["Simple_C3"].show(); - me["Simple_C3"].setText(myArrival[i].C3[0]); - if (myArrival[i].C3[1] != nil) { - me["Simple_C3S"].show(); - me["Simple_C3S"].setText(myArrival[i].C3[1]); - } else { - me["Simple_C3S"].hide(); - } - } - - if (myArrival[i].C4[0] == nil) { - me["Simple_C4"].hide(); - me["Simple_C4S"].hide(); - } else { - me["Simple_C4"].show(); - me["Simple_C4"].setText(myArrival[i].C4[0]); - if (myArrival[i].C4[1] != nil) { - me["Simple_C4S"].show(); - me["Simple_C4S"].setText(myArrival[i].C4[1]); - } else { - me["Simple_C4S"].hide(); - } - } - - if (myArrival[i].C5[0] == nil) { - me["Simple_C5"].hide(); - me["Simple_C5S"].hide(); - } else { - me["Simple_C5"].show(); - me["Simple_C5"].setText(myArrival[i].C5[0]); - if (myArrival[i].C5[1] != nil) { - me["Simple_C5S"].show(); - me["Simple_C5S"].setText(myArrival[i].C5[1]); - } else { - me["Simple_C5S"].hide(); - } - } me.colorCenter(myArrival[i].C1[2],myArrival[i].C2[2],myArrival[i].C3[2],myArrival[i].C4[2],myArrival[i].C5[2],myArrival[i].C6[2]); me["Simple_C6"].hide(); me["Simple_C6S"].hide(); - if (myArrival[i].R1[0] == nil) { - me["Simple_R1"].hide(); - me["Simple_R1S"].hide(); - } else { - me["Simple_R1"].show(); - me["Simple_R1"].setText(myArrival[i].R1[0]); - if (myArrival[i].R1[1] != nil) { - me["Simple_R1S"].show(); - me["Simple_R1S"].setText(myArrival[i].R1[1]); - } else { - me["Simple_R1S"].hide(); - } - } + me.dynamicPageFunc(myArrival[i].R1, "Simple_R1"); + me.dynamicPageFunc(myArrival[i].R2, "Simple_R2"); + me.dynamicPageFunc(myArrival[i].R3, "Simple_R3"); + me.dynamicPageFunc(myArrival[i].R4, "Simple_R4"); + me.dynamicPageFunc(myArrival[i].R5, "Simple_R5"); + me.dynamicPageFunc(myArrival[i].R6, "Simple_R6"); - if (myArrival[i].R2[0] == nil) { - me["Simple_R2"].hide(); - me["Simple_R2S"].hide(); - } else { - me["Simple_R2"].show(); - me["Simple_R2"].setText(myArrival[i].R2[0]); - if (myArrival[i].R2[1] != nil) { - me["Simple_R2S"].show(); - me["Simple_R2S"].setText(myArrival[i].R2[1]); - } else { - me["Simple_R2S"].hide(); - } - } - - if (myArrival[i].R3[0] == nil) { - me["Simple_R3"].hide(); - me["Simple_R3S"].hide(); - } else { - me["Simple_R3"].show(); - me["Simple_R3"].setText(myArrival[i].R3[0]); - if (myArrival[i].R3[1] != nil) { - me["Simple_R3S"].show(); - me["Simple_R3S"].setText(myArrival[i].R3[1]); - } else { - me["Simple_R3S"].hide(); - } - } - - if (myArrival[i].R4[0] == nil) { - me["Simple_R4"].hide(); - me["Simple_R4S"].hide(); - } else { - me["Simple_R4"].show(); - me["Simple_R4"].setText(myArrival[i].R4[0]); - if (myArrival[i].R4[1] != nil) { - me["Simple_R4S"].show(); - me["Simple_R4S"].setText(myArrival[i].R4[1]); - } else { - me["Simple_R4S"].hide(); - } - } - - if (myArrival[i].R5[0] == nil) { - me["Simple_R5"].hide(); - me["Simple_R5S"].hide(); - } else { - me["Simple_R5"].show(); - me["Simple_R5"].setText(myArrival[i].R5[0]); - if (myArrival[i].R5[1] != nil) { - me["Simple_R5S"].show(); - me["Simple_R5S"].setText(myArrival[i].R5[1]); - } else { - me["Simple_R5S"].hide(); - } - } - - if (myArrival[i].R6[0] == nil) { - me["Simple_R6"].hide(); - me["Simple_R6S"].hide(); - } else { - me["Simple_R6"].show(); - me["Simple_R6"].setText(myArrival[i].R6[0]); - if (myArrival[i].R6[1] != nil) { - me["Simple_R6S"].show(); - me["Simple_R6S"].setText(myArrival[i].R6[1]); - } else { - me["Simple_R6S"].hide(); - } - } me.colorRight(myArrival[i].R1[2],myArrival[i].R2[2],myArrival[i].R3[2],myArrival[i].R4[2],myArrival[i].R5[2],myArrival[i].R6[2]); } pageSwitch[i].setBoolValue(1); @@ -4983,248 +3791,33 @@ var canvas_MCDU_base = { } } - if (myHold[i].L1[0] == nil) { - me["Simple_L1"].hide(); - me["Simple_L1S"].hide(); - } else { - me["Simple_L1"].show(); - me["Simple_L1"].setText(myHold[i].L1[0]); - if (myHold[i].L1[1] != nil) { - me["Simple_L1S"].show(); - me["Simple_L1S"].setText(myHold[i].L1[1]); - } else { - me["Simple_L1S"].hide(); - } - } + me.dynamicPageFunc(myHold[i].L1, "Simple_L1"); + me.dynamicPageFunc(myHold[i].L2, "Simple_L2"); + me.dynamicPageFunc(myHold[i].L3, "Simple_L3"); + me.dynamicPageFunc(myHold[i].L4, "Simple_L4"); + me.dynamicPageFunc(myHold[i].L5, "Simple_L5"); + me.dynamicPageFunc(myHold[i].L6, "Simple_L6"); - if (myHold[i].L2[0] == nil) { - me["Simple_L2"].hide(); - me["Simple_L2S"].hide(); - } else { - me["Simple_L2"].show(); - me["Simple_L2"].setText(myHold[i].L2[0]); - if (myHold[i].L2[1] != nil) { - me["Simple_L2S"].show(); - me["Simple_L2S"].setText(myHold[i].L2[1]); - } else { - me["Simple_L2S"].hide(); - } - } - - if (myHold[i].L3[0] == nil) { - me["Simple_L3"].hide(); - me["Simple_L3S"].hide(); - } else { - me["Simple_L3"].show(); - me["Simple_L3"].setText(myHold[i].L3[0]); - if (myHold[i].L3[1] != nil) { - me["Simple_L3S"].show(); - me["Simple_L3S"].setText(myHold[i].L3[1]); - } else { - me["Simple_L3S"].hide(); - } - } - - if (myHold[i].L4[0] == nil) { - me["Simple_L4"].hide(); - me["Simple_L4S"].hide(); - } else { - me["Simple_L4"].show(); - me["Simple_L4"].setText(myHold[i].L4[0]); - if (myHold[i].L4[1] != nil) { - me["Simple_L4S"].show(); - me["Simple_L4S"].setText(myHold[i].L4[1]); - } else { - me["Simple_L4S"].hide(); - } - } - - if (myHold[i].L5[0] == nil) { - me["Simple_L5"].hide(); - me["Simple_L5S"].hide(); - } else { - me["Simple_L5"].show(); - me["Simple_L5"].setText(myHold[i].L5[0]); - if (myHold[i].L5[1] != nil) { - me["Simple_L5S"].show(); - me["Simple_L5S"].setText(myHold[i].L5[1]); - } else { - me["Simple_L5S"].hide(); - } - } - - if (myHold[i].L6[0] == nil) { - me["Simple_L6"].hide(); - me["Simple_L6S"].hide(); - } else { - me["Simple_L6"].show(); - me["Simple_L6"].setText(myHold[i].L6[0]); - if (myHold[i].L6[1] != nil) { - me["Simple_L6S"].show(); - me["Simple_L6S"].setText(myHold[i].L6[1]); - } else { - me["Simple_L6S"].hide(); - } - } me.colorLeft(myHold[i].L1[2],myHold[i].L2[2],myHold[i].L3[2],myHold[i].L4[2],myHold[i].L5[2],myHold[i].L6[2]); - if (myHold[i].C1[0] == nil) { - me["Simple_C1"].hide(); - me["Simple_C1S"].hide(); - } else { - me["Simple_C1"].show(); - me["Simple_C1"].setText(myHold[i].C1[0]); - if (myHold[i].C1[1] != nil) { - me["Simple_C1S"].show(); - me["Simple_C1S"].setText(myHold[i].C1[1]); - } else { - me["Simple_C1S"].hide(); - } - } + me.dynamicPageFunc(myHold[i].C1, "Simple_C1"); + me.dynamicPageFunc(myHold[i].C2, "Simple_C2"); + me.dynamicPageFunc(myHold[i].C3, "Simple_C3"); + me.dynamicPageFunc(myHold[i].C4, "Simple_C4"); + me.dynamicPageFunc(myHold[i].C5, "Simple_C5"); - if (myHold[i].C2[0] == nil) { - me["Simple_C2"].hide(); - me["Simple_C2S"].hide(); - } else { - me["Simple_C2"].show(); - me["Simple_C2"].setText(myHold[i].C2[0]); - if (myHold[i].C2[1] != nil) { - me["Simple_C2S"].show(); - me["Simple_C2S"].setText(myHold[i].C2[1]); - } else { - me["Simple_C2S"].hide(); - } - } - - if (myHold[i].C3[0] == nil) { - me["Simple_C3"].hide(); - me["Simple_C3S"].hide(); - } else { - me["Simple_C3"].show(); - me["Simple_C3"].setText(myHold[i].C3[0]); - if (myHold[i].C3[1] != nil) { - me["Simple_C3S"].show(); - me["Simple_C3S"].setText(myHold[i].C3[1]); - } else { - me["Simple_C3S"].hide(); - } - } - - if (myHold[i].C4[0] == nil) { - me["Simple_C4"].hide(); - me["Simple_C4S"].hide(); - } else { - me["Simple_C4"].show(); - me["Simple_C4"].setText(myHold[i].C4[0]); - if (myHold[i].C4[1] != nil) { - me["Simple_C4S"].show(); - me["Simple_C4S"].setText(myHold[i].C4[1]); - } else { - me["Simple_C4S"].hide(); - } - } - - if (myHold[i].C5[0] == nil) { - me["Simple_C5"].hide(); - me["Simple_C5S"].hide(); - } else { - me["Simple_C5"].show(); - me["Simple_C5"].setText(myHold[i].C5[0]); - if (myHold[i].C5[1] != nil) { - me["Simple_C5S"].show(); - me["Simple_C5S"].setText(myHold[i].C5[1]); - } else { - me["Simple_C5S"].hide(); - } - } me.colorCenter(myHold[i].C1[2],myHold[i].C2[2],myHold[i].C3[2],myHold[i].C4[2],myHold[i].C5[2],myHold[i].C6[2]); me["Simple_C6"].hide(); me["Simple_C6S"].hide(); - if (myHold[i].R1[0] == nil) { - me["Simple_R1"].hide(); - me["Simple_R1S"].hide(); - } else { - me["Simple_R1"].show(); - me["Simple_R1"].setText(myHold[i].R1[0]); - if (myHold[i].R1[1] != nil) { - me["Simple_R1S"].show(); - me["Simple_R1S"].setText(myHold[i].R1[1]); - } else { - me["Simple_R1S"].hide(); - } - } + me.dynamicPageFunc(myHold[i].R1, "Simple_R1"); + me.dynamicPageFunc(myHold[i].R2, "Simple_R2"); + me.dynamicPageFunc(myHold[i].R3, "Simple_R3"); + me.dynamicPageFunc(myHold[i].R4, "Simple_R4"); + me.dynamicPageFunc(myHold[i].R5, "Simple_R5"); + me.dynamicPageFunc(myHold[i].R6, "Simple_R6"); - if (myHold[i].R2[0] == nil) { - me["Simple_R2"].hide(); - me["Simple_R2S"].hide(); - } else { - me["Simple_R2"].show(); - me["Simple_R2"].setText(myHold[i].R2[0]); - if (myHold[i].R2[1] != nil) { - me["Simple_R2S"].show(); - me["Simple_R2S"].setText(myHold[i].R2[1]); - } else { - me["Simple_R2S"].hide(); - } - } - - if (myHold[i].R3[0] == nil) { - me["Simple_R3"].hide(); - me["Simple_R3S"].hide(); - } else { - me["Simple_R3"].show(); - me["Simple_R3"].setText(myHold[i].R3[0]); - if (myHold[i].R3[1] != nil) { - me["Simple_R3S"].show(); - me["Simple_R3S"].setText(myHold[i].R3[1]); - } else { - me["Simple_R3S"].hide(); - } - } - - if (myHold[i].R4[0] == nil) { - me["Simple_R4"].hide(); - me["Simple_R4S"].hide(); - } else { - me["Simple_R4"].show(); - me["Simple_R4"].setText(myHold[i].R4[0]); - if (myHold[i].R4[1] != nil) { - me["Simple_R4S"].show(); - me["Simple_R4S"].setText(myHold[i].R4[1]); - } else { - me["Simple_R4S"].hide(); - } - } - - if (myHold[i].R5[0] == nil) { - me["Simple_R5"].hide(); - me["Simple_R5S"].hide(); - } else { - me["Simple_R5"].show(); - me["Simple_R5"].setText(myHold[i].R5[0]); - if (myHold[i].R5[1] != nil) { - me["Simple_R5S"].show(); - me["Simple_R5S"].setText(myHold[i].R5[1]); - } else { - me["Simple_R5S"].hide(); - } - } - - if (myHold[i].R6[0] == nil) { - me["Simple_R6"].hide(); - me["Simple_R6S"].hide(); - } else { - me["Simple_R6"].show(); - me["Simple_R6"].setText(myHold[i].R6[0]); - if (myHold[i].R6[1] != nil) { - me["Simple_R6S"].show(); - me["Simple_R6S"].setText(myHold[i].R6[1]); - } else { - me["Simple_R6S"].hide(); - } - } me.colorRight(myHold[i].R1[2],myHold[i].R2[2],myHold[i].R3[2],myHold[i].R4[2],myHold[i].R5[2],myHold[i].R6[2]); } pageSwitch[i].setBoolValue(1); @@ -5318,248 +3911,33 @@ var canvas_MCDU_base = { } } - if (myAirways[i].L1[0] == nil) { - me["Simple_L1"].hide(); - me["Simple_L1S"].hide(); - } else { - me["Simple_L1"].show(); - me["Simple_L1"].setText(myAirways[i].L1[0]); - if (myAirways[i].L1[1] != nil) { - me["Simple_L1S"].show(); - me["Simple_L1S"].setText(myAirways[i].L1[1]); - } else { - me["Simple_L1S"].hide(); - } - } + me.dynamicPageFunc(myAirways[i].L1, "Simple_L1"); + me.dynamicPageFunc(myAirways[i].L2, "Simple_L2"); + me.dynamicPageFunc(myAirways[i].L3, "Simple_L3"); + me.dynamicPageFunc(myAirways[i].L4, "Simple_L4"); + me.dynamicPageFunc(myAirways[i].L5, "Simple_L5"); + me.dynamicPageFunc(myAirways[i].L6, "Simple_L6"); - if (myAirways[i].L2[0] == nil) { - me["Simple_L2"].hide(); - me["Simple_L2S"].hide(); - } else { - me["Simple_L2"].show(); - me["Simple_L2"].setText(myAirways[i].L2[0]); - if (myAirways[i].L2[1] != nil) { - me["Simple_L2S"].show(); - me["Simple_L2S"].setText(myAirways[i].L2[1]); - } else { - me["Simple_L2S"].hide(); - } - } - - if (myAirways[i].L3[0] == nil) { - me["Simple_L3"].hide(); - me["Simple_L3S"].hide(); - } else { - me["Simple_L3"].show(); - me["Simple_L3"].setText(myAirways[i].L3[0]); - if (myAirways[i].L3[1] != nil) { - me["Simple_L3S"].show(); - me["Simple_L3S"].setText(myAirways[i].L3[1]); - } else { - me["Simple_L3S"].hide(); - } - } - - if (myAirways[i].L4[0] == nil) { - me["Simple_L4"].hide(); - me["Simple_L4S"].hide(); - } else { - me["Simple_L4"].show(); - me["Simple_L4"].setText(myAirways[i].L4[0]); - if (myAirways[i].L4[1] != nil) { - me["Simple_L4S"].show(); - me["Simple_L4S"].setText(myAirways[i].L4[1]); - } else { - me["Simple_L4S"].hide(); - } - } - - if (myAirways[i].L5[0] == nil) { - me["Simple_L5"].hide(); - me["Simple_L5S"].hide(); - } else { - me["Simple_L5"].show(); - me["Simple_L5"].setText(myAirways[i].L5[0]); - if (myAirways[i].L5[1] != nil) { - me["Simple_L5S"].show(); - me["Simple_L5S"].setText(myAirways[i].L5[1]); - } else { - me["Simple_L5S"].hide(); - } - } - - if (myAirways[i].L6[0] == nil) { - me["Simple_L6"].hide(); - me["Simple_L6S"].hide(); - } else { - me["Simple_L6"].show(); - me["Simple_L6"].setText(myAirways[i].L6[0]); - if (myAirways[i].L6[1] != nil) { - me["Simple_L6S"].show(); - me["Simple_L6S"].setText(myAirways[i].L6[1]); - } else { - me["Simple_L6S"].hide(); - } - } me.colorLeft(myAirways[i].L1[2],myAirways[i].L2[2],myAirways[i].L3[2],myAirways[i].L4[2],myAirways[i].L5[2],myAirways[i].L6[2]); - if (myAirways[i].C1[0] == nil) { - me["Simple_C1"].hide(); - me["Simple_C1S"].hide(); - } else { - me["Simple_C1"].show(); - me["Simple_C1"].setText(myAirways[i].C1[0]); - if (myAirways[i].C1[1] != nil) { - me["Simple_C1S"].show(); - me["Simple_C1S"].setText(myAirways[i].C1[1]); - } else { - me["Simple_C1S"].hide(); - } - } + me.dynamicPageFunc(myAirways[i].C1, "Simple_C1"); + me.dynamicPageFunc(myAirways[i].C2, "Simple_C2"); + me.dynamicPageFunc(myAirways[i].C3, "Simple_C3"); + me.dynamicPageFunc(myAirways[i].C4, "Simple_C4"); + me.dynamicPageFunc(myAirways[i].C5, "Simple_C5"); - if (myAirways[i].C2[0] == nil) { - me["Simple_C2"].hide(); - me["Simple_C2S"].hide(); - } else { - me["Simple_C2"].show(); - me["Simple_C2"].setText(myAirways[i].C2[0]); - if (myAirways[i].C2[1] != nil) { - me["Simple_C2S"].show(); - me["Simple_C2S"].setText(myAirways[i].C2[1]); - } else { - me["Simple_C2S"].hide(); - } - } - - if (myAirways[i].C3[0] == nil) { - me["Simple_C3"].hide(); - me["Simple_C3S"].hide(); - } else { - me["Simple_C3"].show(); - me["Simple_C3"].setText(myAirways[i].C3[0]); - if (myAirways[i].C3[1] != nil) { - me["Simple_C3S"].show(); - me["Simple_C3S"].setText(myAirways[i].C3[1]); - } else { - me["Simple_C3S"].hide(); - } - } - - if (myAirways[i].C4[0] == nil) { - me["Simple_C4"].hide(); - me["Simple_C4S"].hide(); - } else { - me["Simple_C4"].show(); - me["Simple_C4"].setText(myAirways[i].C4[0]); - if (myAirways[i].C4[1] != nil) { - me["Simple_C4S"].show(); - me["Simple_C4S"].setText(myAirways[i].C4[1]); - } else { - me["Simple_C4S"].hide(); - } - } - - if (myAirways[i].C5[0] == nil) { - me["Simple_C5"].hide(); - me["Simple_C5S"].hide(); - } else { - me["Simple_C5"].show(); - me["Simple_C5"].setText(myAirways[i].C5[0]); - if (myAirways[i].C5[1] != nil) { - me["Simple_C5S"].show(); - me["Simple_C5S"].setText(myAirways[i].C5[1]); - } else { - me["Simple_C5S"].hide(); - } - } me.colorCenter(myAirways[i].C1[2],myAirways[i].C2[2],myAirways[i].C3[2],myAirways[i].C4[2],myAirways[i].C5[2],myAirways[i].C6[2]); me["Simple_C6"].hide(); me["Simple_C6S"].hide(); - if (myAirways[i].R1[0] == nil) { - me["Simple_R1"].hide(); - me["Simple_R1S"].hide(); - } else { - me["Simple_R1"].show(); - me["Simple_R1"].setText(myAirways[i].R1[0]); - if (myAirways[i].R1[1] != nil) { - me["Simple_R1S"].show(); - me["Simple_R1S"].setText(myAirways[i].R1[1]); - } else { - me["Simple_R1S"].hide(); - } - } + me.dynamicPageFunc(myAirways[i].R1, "Simple_R1"); + me.dynamicPageFunc(myAirways[i].R2, "Simple_R2"); + me.dynamicPageFunc(myAirways[i].R3, "Simple_R3"); + me.dynamicPageFunc(myAirways[i].R4, "Simple_R4"); + me.dynamicPageFunc(myAirways[i].R5, "Simple_R5"); + me.dynamicPageFunc(myAirways[i].R6, "Simple_R6"); - if (myAirways[i].R2[0] == nil) { - me["Simple_R2"].hide(); - me["Simple_R2S"].hide(); - } else { - me["Simple_R2"].show(); - me["Simple_R2"].setText(myAirways[i].R2[0]); - if (myAirways[i].R2[1] != nil) { - me["Simple_R2S"].show(); - me["Simple_R2S"].setText(myAirways[i].R2[1]); - } else { - me["Simple_R2S"].hide(); - } - } - - if (myAirways[i].R3[0] == nil) { - me["Simple_R3"].hide(); - me["Simple_R3S"].hide(); - } else { - me["Simple_R3"].show(); - me["Simple_R3"].setText(myAirways[i].R3[0]); - if (myAirways[i].R3[1] != nil) { - me["Simple_R3S"].show(); - me["Simple_R3S"].setText(myAirways[i].R3[1]); - } else { - me["Simple_R3S"].hide(); - } - } - - if (myAirways[i].R4[0] == nil) { - me["Simple_R4"].hide(); - me["Simple_R4S"].hide(); - } else { - me["Simple_R4"].show(); - me["Simple_R4"].setText(myAirways[i].R4[0]); - if (myAirways[i].R4[1] != nil) { - me["Simple_R4S"].show(); - me["Simple_R4S"].setText(myAirways[i].R4[1]); - } else { - me["Simple_R4S"].hide(); - } - } - - if (myAirways[i].R5[0] == nil) { - me["Simple_R5"].hide(); - me["Simple_R5S"].hide(); - } else { - me["Simple_R5"].show(); - me["Simple_R5"].setText(myAirways[i].R5[0]); - if (myAirways[i].R5[1] != nil) { - me["Simple_R5S"].show(); - me["Simple_R5S"].setText(myAirways[i].R5[1]); - } else { - me["Simple_R5S"].hide(); - } - } - - if (myAirways[i].R6[0] == nil) { - me["Simple_R6"].hide(); - me["Simple_R6S"].hide(); - } else { - me["Simple_R6"].show(); - me["Simple_R6"].setText(myAirways[i].R6[0]); - if (myAirways[i].R6[1] != nil) { - me["Simple_R6S"].show(); - me["Simple_R6S"].setText(myAirways[i].R6[1]); - } else { - me["Simple_R6S"].hide(); - } - } me.colorRight(myAirways[i].R1[2],myAirways[i].R2[2],myAirways[i].R3[2],myAirways[i].R4[2],myAirways[i].R5[2],myAirways[i].R6[2]); } pageSwitch[i].setBoolValue(1); @@ -5634,248 +4012,33 @@ var canvas_MCDU_base = { } } - if (myClosestAirport[i].L1[0] == nil) { - me["Simple_L1"].hide(); - me["Simple_L1S"].hide(); - } else { - me["Simple_L1"].show(); - me["Simple_L1"].setText(myClosestAirport[i].L1[0]); - if (myClosestAirport[i].L1[1] != nil) { - me["Simple_L1S"].show(); - me["Simple_L1S"].setText(myClosestAirport[i].L1[1]); - } else { - me["Simple_L1S"].hide(); - } - } + me.dynamicPageFunc(myClosestAirport[i].L1, "Simple_L1"); + me.dynamicPageFunc(myClosestAirport[i].L2, "Simple_L2"); + me.dynamicPageFunc(myClosestAirport[i].L3, "Simple_L3"); + me.dynamicPageFunc(myClosestAirport[i].L4, "Simple_L4"); + me.dynamicPageFunc(myClosestAirport[i].L5, "Simple_L5"); + me.dynamicPageFunc(myClosestAirport[i].L6, "Simple_L6"); - if (myClosestAirport[i].L2[0] == nil) { - me["Simple_L2"].hide(); - me["Simple_L2S"].hide(); - } else { - me["Simple_L2"].show(); - me["Simple_L2"].setText(myClosestAirport[i].L2[0]); - if (myClosestAirport[i].L2[1] != nil) { - me["Simple_L2S"].show(); - me["Simple_L2S"].setText(myClosestAirport[i].L2[1]); - } else { - me["Simple_L2S"].hide(); - } - } - - if (myClosestAirport[i].L3[0] == nil) { - me["Simple_L3"].hide(); - me["Simple_L3S"].hide(); - } else { - me["Simple_L3"].show(); - me["Simple_L3"].setText(myClosestAirport[i].L3[0]); - if (myClosestAirport[i].L3[1] != nil) { - me["Simple_L3S"].show(); - me["Simple_L3S"].setText(myClosestAirport[i].L3[1]); - } else { - me["Simple_L3S"].hide(); - } - } - - if (myClosestAirport[i].L4[0] == nil) { - me["Simple_L4"].hide(); - me["Simple_L4S"].hide(); - } else { - me["Simple_L4"].show(); - me["Simple_L4"].setText(myClosestAirport[i].L4[0]); - if (myClosestAirport[i].L4[1] != nil) { - me["Simple_L4S"].show(); - me["Simple_L4S"].setText(myClosestAirport[i].L4[1]); - } else { - me["Simple_L4S"].hide(); - } - } - - if (myClosestAirport[i].L5[0] == nil) { - me["Simple_L5"].hide(); - me["Simple_L5S"].hide(); - } else { - me["Simple_L5"].show(); - me["Simple_L5"].setText(myClosestAirport[i].L5[0]); - if (myClosestAirport[i].L5[1] != nil) { - me["Simple_L5S"].show(); - me["Simple_L5S"].setText(myClosestAirport[i].L5[1]); - } else { - me["Simple_L5S"].hide(); - } - } - - if (myClosestAirport[i].L6[0] == nil) { - me["Simple_L6"].hide(); - me["Simple_L6S"].hide(); - } else { - me["Simple_L6"].show(); - me["Simple_L6"].setText(myClosestAirport[i].L6[0]); - if (myClosestAirport[i].L6[1] != nil) { - me["Simple_L6S"].show(); - me["Simple_L6S"].setText(myClosestAirport[i].L6[1]); - } else { - me["Simple_L6S"].hide(); - } - } me.colorLeft(myClosestAirport[i].L1[2],myClosestAirport[i].L2[2],myClosestAirport[i].L3[2],myClosestAirport[i].L4[2],myClosestAirport[i].L5[2],myClosestAirport[i].L6[2]); - if (myClosestAirport[i].C1[0] == nil) { - me["Simple_C1"].hide(); - me["Simple_C1S"].hide(); - } else { - me["Simple_C1"].show(); - me["Simple_C1"].setText(myClosestAirport[i].C1[0]); - if (myClosestAirport[i].C1[1] != nil) { - me["Simple_C1S"].show(); - me["Simple_C1S"].setText(myClosestAirport[i].C1[1]); - } else { - me["Simple_C1S"].hide(); - } - } + me.dynamicPageFunc(myClosestAirport[i].C1, "Simple_C1"); + me.dynamicPageFunc(myClosestAirport[i].C2, "Simple_C2"); + me.dynamicPageFunc(myClosestAirport[i].C3, "Simple_C3"); + me.dynamicPageFunc(myClosestAirport[i].C4, "Simple_C4"); + me.dynamicPageFunc(myClosestAirport[i].C5, "Simple_C5"); - if (myClosestAirport[i].C2[0] == nil) { - me["Simple_C2"].hide(); - me["Simple_C2S"].hide(); - } else { - me["Simple_C2"].show(); - me["Simple_C2"].setText(myClosestAirport[i].C2[0]); - if (myClosestAirport[i].C2[1] != nil) { - me["Simple_C2S"].show(); - me["Simple_C2S"].setText(myClosestAirport[i].C2[1]); - } else { - me["Simple_C2S"].hide(); - } - } - - if (myClosestAirport[i].C3[0] == nil) { - me["Simple_C3"].hide(); - me["Simple_C3S"].hide(); - } else { - me["Simple_C3"].show(); - me["Simple_C3"].setText(myClosestAirport[i].C3[0]); - if (myClosestAirport[i].C3[1] != nil) { - me["Simple_C3S"].show(); - me["Simple_C3S"].setText(myClosestAirport[i].C3[1]); - } else { - me["Simple_C3S"].hide(); - } - } - - if (myClosestAirport[i].C4[0] == nil) { - me["Simple_C4"].hide(); - me["Simple_C4S"].hide(); - } else { - me["Simple_C4"].show(); - me["Simple_C4"].setText(myClosestAirport[i].C4[0]); - if (myClosestAirport[i].C4[1] != nil) { - me["Simple_C4S"].show(); - me["Simple_C4S"].setText(myClosestAirport[i].C4[1]); - } else { - me["Simple_C4S"].hide(); - } - } - - if (myClosestAirport[i].C5[0] == nil) { - me["Simple_C5"].hide(); - me["Simple_C5S"].hide(); - } else { - me["Simple_C5"].show(); - me["Simple_C5"].setText(myClosestAirport[i].C5[0]); - if (myClosestAirport[i].C5[1] != nil) { - me["Simple_C5S"].show(); - me["Simple_C5S"].setText(myClosestAirport[i].C5[1]); - } else { - me["Simple_C5S"].hide(); - } - } me.colorCenter(myClosestAirport[i].C1[2],myClosestAirport[i].C2[2],myClosestAirport[i].C3[2],myClosestAirport[i].C4[2],myClosestAirport[i].C5[2],myClosestAirport[i].C6[2]); me["Simple_C6"].hide(); me["Simple_C6S"].hide(); - if (myClosestAirport[i].R1[0] == nil) { - me["Simple_R1"].hide(); - me["Simple_R1S"].hide(); - } else { - me["Simple_R1"].show(); - me["Simple_R1"].setText(myClosestAirport[i].R1[0]); - if (myClosestAirport[i].R1[1] != nil) { - me["Simple_R1S"].show(); - me["Simple_R1S"].setText(myClosestAirport[i].R1[1]); - } else { - me["Simple_R1S"].hide(); - } - } + me.dynamicPageFunc(myClosestAirport[i].R1, "Simple_R1"); + me.dynamicPageFunc(myClosestAirport[i].R2, "Simple_R2"); + me.dynamicPageFunc(myClosestAirport[i].R3, "Simple_R3"); + me.dynamicPageFunc(myClosestAirport[i].R4, "Simple_R4"); + me.dynamicPageFunc(myClosestAirport[i].R5, "Simple_R5"); + me.dynamicPageFunc(myClosestAirport[i].R6, "Simple_R6"); - if (myClosestAirport[i].R2[0] == nil) { - me["Simple_R2"].hide(); - me["Simple_R2S"].hide(); - } else { - me["Simple_R2"].show(); - me["Simple_R2"].setText(myClosestAirport[i].R2[0]); - if (myClosestAirport[i].R2[1] != nil) { - me["Simple_R2S"].show(); - me["Simple_R2S"].setText(myClosestAirport[i].R2[1]); - } else { - me["Simple_R2S"].hide(); - } - } - - if (myClosestAirport[i].R3[0] == nil) { - me["Simple_R3"].hide(); - me["Simple_R3S"].hide(); - } else { - me["Simple_R3"].show(); - me["Simple_R3"].setText(myClosestAirport[i].R3[0]); - if (myClosestAirport[i].R3[1] != nil) { - me["Simple_R3S"].show(); - me["Simple_R3S"].setText(myClosestAirport[i].R3[1]); - } else { - me["Simple_R3S"].hide(); - } - } - - if (myClosestAirport[i].R4[0] == nil) { - me["Simple_R4"].hide(); - me["Simple_R4S"].hide(); - } else { - me["Simple_R4"].show(); - me["Simple_R4"].setText(myClosestAirport[i].R4[0]); - if (myClosestAirport[i].R4[1] != nil) { - me["Simple_R4S"].show(); - me["Simple_R4S"].setText(myClosestAirport[i].R4[1]); - } else { - me["Simple_R4S"].hide(); - } - } - - if (myClosestAirport[i].R5[0] == nil) { - me["Simple_R5"].hide(); - me["Simple_R5S"].hide(); - } else { - me["Simple_R5"].show(); - me["Simple_R5"].setText(myClosestAirport[i].R5[0]); - if (myClosestAirport[i].R5[1] != nil) { - me["Simple_R5S"].show(); - me["Simple_R5S"].setText(myClosestAirport[i].R5[1]); - } else { - me["Simple_R5S"].hide(); - } - } - - if (myClosestAirport[i].R6[0] == nil) { - me["Simple_R6"].hide(); - me["Simple_R6S"].hide(); - } else { - me["Simple_R6"].show(); - me["Simple_R6"].setText(myClosestAirport[i].R6[0]); - if (myClosestAirport[i].R6[1] != nil) { - me["Simple_R6S"].show(); - me["Simple_R6S"].setText(myClosestAirport[i].R6[1]); - } else { - me["Simple_R6S"].hide(); - } - } me.colorRight(myClosestAirport[i].R1[2],myClosestAirport[i].R2[2],myClosestAirport[i].R3[2],myClosestAirport[i].R4[2],myClosestAirport[i].R5[2],myClosestAirport[i].R6[2]); } pageSwitch[i].setBoolValue(1); @@ -5974,174 +4137,22 @@ var canvas_MCDU_base = { me["DIRTO_TMPY_group"].hide(); } - if (myDirTo[i].L1[0] == nil) { - me["Simple_L1"].hide(); - me["Simple_L1S"].hide(); - } else { - me["Simple_L1"].show(); - me["Simple_L1"].setText(myDirTo[i].L1[0]); - if (myDirTo[i].L1[1] != nil) { - me["Simple_L1S"].show(); - me["Simple_L1S"].setText(myDirTo[i].L1[1]); - } else { - me["Simple_L1S"].hide(); - } - } + me.dynamicPageFunc(myDirTo[i].L1, "Simple_L1"); + me.dynamicPageFunc(myDirTo[i].L2, "Simple_L2"); + me.dynamicPageFunc(myDirTo[i].L3, "Simple_L3"); + me.dynamicPageFunc(myDirTo[i].L4, "Simple_L4"); + me.dynamicPageFunc(myDirTo[i].L5, "Simple_L5"); + me.dynamicPageFunc(myDirTo[i].L6, "Simple_L6"); - if (myDirTo[i].L2[0] == nil) { - me["Simple_L2"].hide(); - me["Simple_L2S"].hide(); - } else { - me["Simple_L2"].show(); - me["Simple_L2"].setText(myDirTo[i].L2[0]); - if (myDirTo[i].L2[1] != nil) { - me["Simple_L2S"].show(); - me["Simple_L2S"].setText(myDirTo[i].L2[1]); - } else { - me["Simple_L2S"].hide(); - } - } - - if (myDirTo[i].L3[0] == nil) { - me["Simple_L3"].hide(); - me["Simple_L3S"].hide(); - } else { - me["Simple_L3"].show(); - me["Simple_L3"].setText(myDirTo[i].L3[0]); - if (myDirTo[i].L3[1] != nil) { - me["Simple_L3S"].show(); - me["Simple_L3S"].setText(myDirTo[i].L3[1]); - } else { - me["Simple_L3S"].hide(); - } - } - - if (myDirTo[i].L4[0] == nil) { - me["Simple_L4"].hide(); - me["Simple_L4S"].hide(); - } else { - me["Simple_L4"].show(); - me["Simple_L4"].setText(myDirTo[i].L4[0]); - if (myDirTo[i].L4[1] != nil) { - me["Simple_L4S"].show(); - me["Simple_L4S"].setText(myDirTo[i].L4[1]); - } else { - me["Simple_L4S"].hide(); - } - } - - if (myDirTo[i].L5[0] == nil) { - me["Simple_L5"].hide(); - me["Simple_L5S"].hide(); - } else { - me["Simple_L5"].show(); - me["Simple_L5"].setText(myDirTo[i].L5[0]); - if (myDirTo[i].L5[1] != nil) { - me["Simple_L5S"].show(); - me["Simple_L5S"].setText(myDirTo[i].L5[1]); - } else { - me["Simple_L5S"].hide(); - } - } - - if (myDirTo[i].L6[0] == nil) { - me["Simple_L6"].hide(); - me["Simple_L6S"].hide(); - } else { - me["Simple_L6"].show(); - me["Simple_L6"].setText(myDirTo[i].L6[0]); - if (myDirTo[i].L6[1] != nil) { - me["Simple_L6S"].show(); - me["Simple_L6S"].setText(myDirTo[i].L6[1]); - } else { - me["Simple_L6S"].hide(); - } - } me.colorLeft(myDirTo[i].L1[2],myDirTo[i].L2[2],myDirTo[i].L3[2],myDirTo[i].L4[2],myDirTo[i].L5[2],myDirTo[i].L6[2]); - if (myDirTo[i].R1[0] == nil) { - me["Simple_R1"].hide(); - me["Simple_R1S"].hide(); - } else { - me["Simple_R1"].show(); - me["Simple_R1"].setText(myDirTo[i].R1[0]); - if (myDirTo[i].R1[1] != nil) { - me["Simple_R1S"].show(); - me["Simple_R1S"].setText(myDirTo[i].R1[1]); - } else { - me["Simple_R1S"].hide(); - } - } + me.dynamicPageFunc(myDirTo[i].R1, "Simple_R1"); + me.dynamicPageFunc(myDirTo[i].R2, "Simple_R2"); + me.dynamicPageFunc(myDirTo[i].R3, "Simple_R3"); + me.dynamicPageFunc(myDirTo[i].R4, "Simple_R4"); + me.dynamicPageFunc(myDirTo[i].R5, "Simple_R5"); + me.dynamicPageFunc(myDirTo[i].R6, "Simple_R6"); - if (myDirTo[i].R2[0] == nil) { - me["Simple_R2"].hide(); - me["Simple_R2S"].hide(); - } else { - me["Simple_R2"].show(); - me["Simple_R2"].setText(myDirTo[i].R2[0]); - if (myDirTo[i].R2[1] != nil) { - me["Simple_R2S"].show(); - me["Simple_R2S"].setText(myDirTo[i].R2[1]); - } else { - me["Simple_R2S"].hide(); - } - } - - if (myDirTo[i].R3[0] == nil) { - me["Simple_R3"].hide(); - me["Simple_R3S"].hide(); - } else { - me["Simple_R3"].show(); - me["Simple_R3"].setText(myDirTo[i].R3[0]); - if (myDirTo[i].R3[1] != nil) { - me["Simple_R3S"].show(); - me["Simple_R3S"].setText(myDirTo[i].R3[1]); - } else { - me["Simple_R3S"].hide(); - } - } - - if (myDirTo[i].R4[0] == nil) { - me["Simple_R4"].hide(); - me["Simple_R4S"].hide(); - } else { - me["Simple_R4"].show(); - me["Simple_R4"].setText(myDirTo[i].R4[0]); - if (myDirTo[i].R4[1] != nil) { - me["Simple_R4S"].show(); - me["Simple_R4S"].setText(myDirTo[i].R4[1]); - } else { - me["Simple_R4S"].hide(); - } - } - - if (myDirTo[i].R5[0] == nil) { - me["Simple_R5"].hide(); - me["Simple_R5S"].hide(); - } else { - me["Simple_R5"].show(); - me["Simple_R5"].setText(myDirTo[i].R5[0]); - if (myDirTo[i].R5[1] != nil) { - me["Simple_R5S"].show(); - me["Simple_R5S"].setText(myDirTo[i].R5[1]); - } else { - me["Simple_R5S"].hide(); - } - } - - if (myDirTo[i].R6[0] == nil) { - me["Simple_R6"].hide(); - me["Simple_R6S"].hide(); - } else { - me["Simple_R6"].show(); - me["Simple_R6"].setText(myDirTo[i].R6[0]); - if (myDirTo[i].R6[1] != nil) { - me["Simple_R6S"].show(); - me["Simple_R6S"].setText(myDirTo[i].R6[1]); - } else { - me["Simple_R6S"].hide(); - } - } me.colorRight(myDirTo[i].R1[2],myDirTo[i].R2[2],myDirTo[i].R3[2],myDirTo[i].R4[2],myDirTo[i].R5[2],myDirTo[i].R6[2]); } pageSwitch[i].setBoolValue(1); @@ -6166,8 +4177,6 @@ var canvas_MCDU_base = { pageSwitch[i].setBoolValue(1); } } - - me["Scratchpad"].setText(sprintf("%s", scratchpad[i].getValue())); }, # ack = ignore, wht = white, grn = green, blu = blue, amb = amber, yel = yellow, mag = magenta colorLeft: func(a, b, c, d, e, f) { @@ -6899,6 +4908,23 @@ 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); + } + }, }; var canvas_MCDU_1 = { @@ -6911,6 +4937,9 @@ var canvas_MCDU_1 = { update: func() { me.updateCommon(0); }, + updateScratchpadCall: func() { + me.updateScratchpad(0); + }, }; var canvas_MCDU_2 = { @@ -6923,6 +4952,9 @@ var canvas_MCDU_2 = { update: func() { me.updateCommon(1); }, + updateScratchpadCall: func() { + me.updateScratchpad(1); + }, }; setlistener("sim/signals/fdm-initialized", func { @@ -6945,6 +4977,11 @@ setlistener("sim/signals/fdm-initialized", func { MCDU_1 = canvas_MCDU_1.new(group_MCDU1, "Aircraft/A320-family/Models/Instruments/MCDU/res/mcdu.svg"); MCDU_2 = canvas_MCDU_2.new(group_MCDU2, "Aircraft/A320-family/Models/Instruments/MCDU/res/mcdu.svg"); + 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/FMGC.nas b/Nasal/FMGC/FMGC.nas index 2ba54eed..efb38c8d 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -1078,6 +1078,11 @@ setlistener("/FMGC/internal/fuel-calculating", func() { var timer30secLanding = maketimer(1, func() { if (pts.Sim.Time.elapsedSec.getValue() > getprop("/FMGC/internal/landing-time") + 30) { setprop("/FMGC/status/phase", 7); + if (getprop("/FMGC/internal/cost-index-set")) { + setprop("/FMGC/internal/last-cost-index", getprop("/FMGC/internal/cost-index")); + } else { + setprop("/FMGC/internal/last-cost-index", 0); + } setprop("/FMGC/internal/landing-time", -99); timer30secLanding.stop(); } 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 new file mode 100644 index 00000000..88b573a0 --- /dev/null +++ b/Nasal/FMGC/mcdu-messages.nas @@ -0,0 +1,220 @@ +# A3XX FMGC MCDU Message Generator and Control +# Copyright (c) 2020 Josh Davidson (Octal450) and Jonathan Redpath (legoboyvdlp) + +var TypeIMessage = { + new: func(msgText, isInhibit = 0) { + var msg = { parents: [TypeIMessage] }; + msg.msgText = msgText; + msg.colour = "wht"; + msg.inhibitable = isInhibit; + return msg; + }, +}; + +var TypeIIMessage = { + new: func(msgText, colour = "wht", isInhibit = 0) { + var msg = { parents: [TypeIIMessage] }; + msg.msgText = msgText; + msg.colour = colour; + msg.inhibitable = isInhibit; + return msg; + }, +}; + +var MessageQueueController = { + new: func(computer) { + var msgC = { parents: [MessageQueueController] }; + msgC.computer = computer; + msgC.messages = std.Vector.new(); # show left to right + return msgC; + }, + # first in first out + addNewMsg: func(msg) { + if (me.messages.size() < 5) { + if (!me.messages.contains(msg)) { + me.messages.append(msg); + } + } + }, + getNextMsg: func() { + if (me.messages.size() >= 1) { + return me.messages.vector[0]; + } + return nil; + }, + deleteAtIndex: func(index) { + if (num(me.messages.size()) >= (index + 1)) { + me.messages.pop(index); + } + }, + clearQueue: func() { + me.messages.clear(); + }, + loop: func() { + if (me.getNextMsg() != nil) { + if (!scratchpads[me.computer].showTypeIIMsg) { + if (scratchpads[me.computer].showTypeII(me.getNextMsg())) { + me.deleteAtIndex(me.getNextMsg()); + } + } + } + }, +}; + +var scratchpadController = { + new: func(mcdu) { + var sp = { parents: [scratchpadController] }; + sp.scratchpad = ""; + sp.scratchpadSave = ""; + sp.scratchpadColour = "wht"; + sp.showTypeIMsg = 0; + sp.showTypeIIMsg = 0; + sp.mcdu = mcdu; + return sp; + }, + + addChar: func(character) { + if (size(me.scratchpad) >= 22) { + return; + } + + # any shown type ii is hidden + if (me.showTypeIIMsg) { + me.clearTypeII(); + } + + # any shown type i is hidden + if (me.showTypeIMsg) { + me.clearTypeI(); + } + + me.scratchpad = me.scratchpad ~ character; + me.scratchpadColour = "wht"; + me.update(); + }, + showTypeI: func(msg) { + # any shown type ii is hidden + if (me.showTypeIIMsg) { + me.clearTypeII(); + } + + if (!me.showTypeIMsg) { + me.showTypeIMsg = 1; + + # save any data entered + me.scratchpadSave = me.scratchpad; + } + + me.scratchpad = msg.msgText; + me.scratchpadColour = msg.colour; + me.update(); + }, + showTypeII: func(msg) { + # only show if scratchpad empty + if (me.scratchpad == "") { + me.showTypeIIMsg = 1; + me.scratchpad = msg.msgText; + me.scratchpadColour = msg.colour; + me.update(); + return 1; + } + me.update(); + return 0; + }, + clearTypeI: func() { + me.scratchpad = me.scratchpadSave; + me.scratchpadSave = nil; + me.showTypeIMsg = 0; + me.update(); + }, + clearTypeII: func() { + me.showTypeIIMsg = 0; + me.empty(); + me.update(); + }, + override: func(str) { + if (me.scratchpad == "USING COST INDEX N") { + me.scratchpad = "USING COST INDEX " ~ str; + me.update(); + } + }, + empty: func() { + me.scratchpad = ""; + me.update(); + }, + clear: func() { + 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.clearTypeII(); + } + me.update(); + }, + update: func() { + if (me.mcdu == 1) { + canvas_mcdu.MCDU_1.updateScratchpadCall(); + } else { + canvas_mcdu.MCDU_2.updateScratchpadCall(); + } + }, +}; + +var MessageController = { + typeIMessages: std.Vector.new([ + TypeIMessage.new("AOC DISABLED"),TypeIMessage.new("AWY/WPT 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("REVISION IN PROGRESS"), + TypeIMessage.new("TMPY F-PLN EXISTS", 1),TypeIMessage.new("SELECT DESIRED SYSTEM"),TypeIMessage.new("SELECT HDG/TRK FIRST"), + TypeIMessage.new("USING COST INDEX N", 1),TypeIMessage.new("WAIT FOR SYSTEM RESPONSE"), + ]), + typeIIMessages: std.Vector.new([ + TypeIIMessage.new("LAT DISCONT AHEAD", "amb", 0),TypeIIMessage.new("MORE DRAG"),TypeIIMessage.new("RWY/LS MISMATCH", "amb", 0),TypeIIMessage.new("STEP DELETED"), + TypeIIMessage.new("STEP NOW"),TypeIIMessage.new("TIME TO EXIT", "amb", 0), + ]), + + getTypeIMsgByText: func(text) { + return me.getMsgByText(text, me.typeIMessages.vector); + }, + getTypeIIMsgByText: func(text) { + return me.getMsgByText(text, me.typeIIMessages.vector); + }, + getMsgByText: func(text, theVector) { + foreach (var message; theVector) { + if (message.msgText = text) { + return message; + } + } + return nil; + }, +}; + +var scratchpads = [scratchpadController.new(1), scratchpadController.new(2)]; +var messageQueues = [MessageQueueController.new(0), MessageQueueController.new(1)]; + +var loop1MsgTimer = func() { + if (messageQueues[0].getNextMsg() != nil) { + if (!scratchpads[messageQueues[0].computer].showTypeIIMsg) { + if (scratchpads[messageQueues[0].computer].showTypeII(messageQueues[0].getNextMsg())) { + messageQueues[0].deleteAtIndex(0); + } + } + } +} + +var loop2MsgTimer = func() { + if (messageQueues[1].getNextMsg() != nil) { + if (!scratchpads[messageQueues[1].computer].showTypeIIMsg) { + if (scratchpads[messageQueues[1].computer].showTypeII(messageQueues[1].getNextMsg())) { + messageQueues[1].deleteAtIndex(0); + } + } + } +} + +var mcduMsgtimer1 = maketimer(1, loop1MsgTimer); +var mcduMsgtimer2 = maketimer(1, loop2MsgTimer); \ No newline at end of file diff --git a/Nasal/Libraries/libraries.nas b/Nasal/Libraries/libraries.nas index 99ecb3fa..1953bcf9 100644 --- a/Nasal/Libraries/libraries.nas +++ b/Nasal/Libraries/libraries.nas @@ -212,6 +212,8 @@ var systemsInit = func { fmgc.FMGCinit(); mcdu.MCDU_init(0); mcdu.MCDU_init(1); + mcdu_scratchpad.mcduMsgtimer1.start(); + mcdu_scratchpad.mcduMsgtimer2.start(); systemsLoop.start(); lightsLoop.start(); ecam.ECAM.init(); 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 4d803bb3..d557490b 100644 --- a/Nasal/MCDU/DIRTO.nas +++ b/Nasal/MCDU/DIRTO.nas @@ -157,7 +157,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); @@ -230,10 +230,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(); @@ -254,24 +253,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.fontMatrix = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0]]; - 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.fontMatrix = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0]]; - 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 68cf90ca..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", getprop("MCDU[" ~ 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", getprop("MCDU[" ~ 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 f76cdfbc..c06a5b4d 100644 --- a/Nasal/MCDU/FUELPRED.nas +++ b/Nasal/MCDU/FUELPRED.nas @@ -29,14 +29,13 @@ var extra_fuel = props.globals.getNode("FMGC/internal/extra-fuel", 1); var extra_time = props.globals.getNode("FMGC/internal/extra-time", 1); var fuelPredInput = func(key, i) { - var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L3" and getprop("/FMGC/internal/block-confirmed") and !getprop("/FMGC/internal/fuel-calculating")) { if (scratchpad == "CLR") { 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,20 +128,26 @@ 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 { + if (!getprop("/FMGC/internal/cost-index-set")) { + mcdu_message(i, "USING COST INDEX N", getprop("/FMGC/internal/last-cost-index")); + setprop("/FMGC/internal/cost-index-set", 1); + setprop("/FMGC/internal/cost-index", getprop("/FMGC/internal/last-cost-index")); + } + var tfs = size(scratchpad); if (tfs == 0) { var zfw = getprop("/fdm/jsbsim/inertia/weight-lbs") - getprop("/consumables/fuel/total-fuel-lbs"); @@ -193,9 +195,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); @@ -210,31 +212,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 e0f0fde1..2fb0d757 100644 --- a/Nasal/MCDU/INITA.nas +++ b/Nasal/MCDU/INITA.nas @@ -4,7 +4,7 @@ # Copyright (c) 2020 Matthew Maring (mattmaring) var initInputA = func(key, i) { - var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L2") { if (scratchpad == "CLR") { setprop("/FMGC/internal/alt-airport", ""); @@ -13,53 +13,54 @@ 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); #setprop("MCDU[" ~ i ~ "]/page", "ROUTESELECTION"); } else if (getprop("/FMGC/internal/tofrom-set") == 1) { - var tfs = size(scratchpad); - if (tfs == 4) { - setprop("/FMGC/internal/alt-airport", scratchpad); - setprop("/FMGC/internal/alt-set", 1); - if (getprop("/FMGC/internal/block-confirmed")) { - setprop("/FMGC/internal/fuel-calculating", 0); - setprop("/FMGC/internal/fuel-calculating", 1); + if (!fmgc.flightPlanController.temporaryFlag[i]) { + var tfs = size(scratchpad); + if (tfs == 4) { + setprop("/FMGC/internal/alt-airport", scratchpad); + setprop("/FMGC/internal/alt-set", 1); + if (getprop("/FMGC/internal/block-confirmed")) { + setprop("/FMGC/internal/fuel-calculating", 0); + setprop("/FMGC/internal/fuel-calculating", 1); + } + mcdu_scratchpad.scratchpads[i].empty(); + fmgc.updateARPT(); + #setprop("/FMGC/internal/alt-selected", 1); + #setprop("MCDU[" ~ i ~ "]/page", "ROUTESELECTION"); + } else { + mcdu_message(i, "NOT ALLOWED"); } - mcdu.clearScratchpad(i); - fmgc.updateARPT(); - #setprop("/FMGC/internal/alt-selected", 1); - #setprop("MCDU[" ~ i ~ "]/page", "ROUTESELECTION"); } else { - notAllowed(i); + mcdu_message(i, "TMPY F-PLN EXISTS"); } } 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 +68,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 +87,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 +106,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 +122,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 +147,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,51 +170,54 @@ 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"); } else { - var tfs = size(scratchpad); - if (tfs == 9 and find("/", scratchpad) != -1) { - var fromto = split("/", scratchpad); - var froms = size(fromto[0]); - var tos = size(fromto[1]); - if (froms == 4 and tos == 4) { - #route - setprop("/FMGC/internal/dep-arpt", fromto[0]); - setprop("/FMGC/internal/arr-arpt", fromto[1]); - setprop("/FMGC/internal/tofrom-set", 1); - #scratchpad - mcdu.clearScratchpad(i); - fmgc.flightPlanController.updateAirports(fromto[0], fromto[1], 2); - setprop("/FMGC/internal/alt-selected", 0); - #ref lat - dms = getprop("/FMGC/flightplan[2]/wp[0]/lat"); - degrees = int(dms); - minutes = sprintf("%.1f",abs((dms - degrees) * 60)); - sign = degrees >= 0 ? "N" : "S"; - setprop("/FMGC/internal/align-ref-lat-degrees", degrees); - setprop("/FMGC/internal/align-ref-lat-minutes", minutes); - setprop("/FMGC/internal/align-ref-lat-sign", sign); - #ref long - dms = getprop("/FMGC/flightplan[2]/wp[0]/lon"); - degrees = int(dms); - minutes = sprintf("%.1f",abs((dms - degrees) * 60)); - sign = degrees >= 0 ? "E" : "W"; - setprop("/FMGC/internal/align-ref-long-degrees", degrees); - setprop("/FMGC/internal/align-ref-long-minutes", minutes); - setprop("/FMGC/internal/align-ref-long-sign", sign); - #ref edit - setprop("/FMGC/internal/align-ref-lat-edit", 0); - setprop("/FMGC/internal/align-ref-long-edit", 0); - #setprop("MCDU[" ~ i ~ "]/page", "ROUTESELECTION"); + if (!fmgc.flightPlanController.temporaryFlag[i]) { + var tfs = size(scratchpad); + if (tfs == 9 and find("/", scratchpad) != -1) { + var fromto = split("/", scratchpad); + var froms = size(fromto[0]); + var tos = size(fromto[1]); + if (froms == 4 and tos == 4) { + #route + setprop("/FMGC/internal/dep-arpt", fromto[0]); + setprop("/FMGC/internal/arr-arpt", fromto[1]); + setprop("/FMGC/internal/tofrom-set", 1); + #scratchpad + mcdu_scratchpad.scratchpads[i].empty(); + fmgc.flightPlanController.updateAirports(fromto[0], fromto[1], 2); + setprop("/FMGC/internal/alt-selected", 0); + #ref lat + dms = getprop("/FMGC/flightplan[2]/wp[0]/lat"); + degrees = int(dms); + minutes = sprintf("%.1f",abs((dms - degrees) * 60)); + sign = degrees >= 0 ? "N" : "S"; + setprop("/FMGC/internal/align-ref-lat-degrees", degrees); + setprop("/FMGC/internal/align-ref-lat-minutes", minutes); + setprop("/FMGC/internal/align-ref-lat-sign", sign); + #ref long + dms = getprop("/FMGC/flightplan[2]/wp[0]/lon"); + degrees = int(dms); + minutes = sprintf("%.1f",abs((dms - degrees) * 60)); + sign = degrees >= 0 ? "E" : "W"; + setprop("/FMGC/internal/align-ref-long-degrees", degrees); + setprop("/FMGC/internal/align-ref-long-minutes", minutes); + setprop("/FMGC/internal/align-ref-long-sign", sign); + #ref edit + setprop("/FMGC/internal/align-ref-lat-edit", 0); + setprop("/FMGC/internal/align-ref-long-edit", 0); + #setprop("MCDU[" ~ i ~ "]/page", "ROUTESELECTION"); + } else { + mcdu_message(i, "NOT ALLOWED"); + } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } else { - notAllowed(i); + mcdu_message(i, "TMPY F-PLN EXISTS"); } } } else if (key == "R3") { @@ -223,29 +226,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 7078cf46..0dd306f0 100644 --- a/Nasal/MCDU/INITB.nas +++ b/Nasal/MCDU/INITB.nas @@ -3,7 +3,7 @@ # Copyright (c) 2020 Matthew Maring (mattmaring) var initInputB = func(key, i) { - var scratchpad = getprop("/MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L1" and !getprop("/FMGC/internal/fuel-calculating")) { if (scratchpad == "CLR") { setprop("/FMGC/internal/taxi-fuel", 0.4); @@ -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,20 +134,26 @@ 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 { + if (!getprop("/FMGC/internal/cost-index-set")) { + mcdu_message(i, "USING COST INDEX N", getprop("/FMGC/internal/last-cost-index")); + setprop("/FMGC/internal/cost-index-set", 1); + setprop("/FMGC/internal/cost-index", getprop("/FMGC/internal/last-cost-index")); + } + var tfs = size(scratchpad); if (tfs == 0) { var zfw = getprop("/fdm/jsbsim/inertia/weight-lbs") - getprop("/consumables/fuel/total-fuel-lbs"); @@ -197,21 +198,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 +247,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 +274,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 +290,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 +299,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 +309,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 +321,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 +332,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 e99f5b3e..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 (getprop("MCDU[" ~ i ~ "]/scratchpad") != "SELECT REFERENCE") { - if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("MCDU[" ~ i ~ "]/last-scratchpad", ""); - } else { - setprop("MCDU[" ~ i ~ "]/last-scratchpad", getprop("MCDU[" ~ 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 (getprop("MCDU[" ~ i ~ "]/scratchpad") != "IRS NOT ALIGNED") { - if (getprop("MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("MCDU[" ~ i ~ "]/last-scratchpad", ""); - } else { - setprop("MCDU[" ~ i ~ "]/last-scratchpad", getprop("MCDU[" ~ 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 77034d1d..8eaf94a8 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); @@ -65,6 +59,7 @@ var MCDU_reset = func(i) { setprop("/FMGC/internal/alt-set", 0); setprop("/FMGC/internal/cost-index", "0"); setprop("/FMGC/internal/cost-index-set", 0); + setprop("/FMGC/internal/last-cost-index", 0); setprop("/FMGC/internal/cruise-ft", 10000); setprop("/FMGC/internal/cruise-fl", 100); setprop("/FMGC/internal/cruise-lvl-set", 0); @@ -197,19 +192,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,16 +236,16 @@ 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); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DIRTO") { - canvas_mcdu.myDirTo[i].fieldL1(getprop("/MCDU[" ~ i ~ "]/scratchpad")); + canvas_mcdu.myDirTo[i].fieldL1(mcdu_scratchpad.scratchpads[i].scratchpad); } 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 +279,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 +317,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 +350,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") { @@ -398,10 +390,10 @@ var lskbutton = func(btn, i) { } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { canvas_mcdu.myDuplicate[i].pushButtonLeft(5); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "CLOSESTAIRPORT") { - canvas_mcdu.myClosestAirport[i].manAirportCall(getprop("/MCDU[" ~ i ~ "]/scratchpad")); - setprop("/MCDU[" ~ i ~ "]/scratchpad", ""); + canvas_mcdu.myClosestAirport[i].manAirportCall(mcdu_scratchpad.scratchpads[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 +433,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 +462,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 +475,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 +498,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 +523,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 +548,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 +582,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 +610,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 (getprop("/MCDU[" ~ i ~ "]/scratchpad") != "AOC DISABLED") { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); - } else { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ 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 +630,7 @@ var rskbutton = func(btn, i) { } } } else { - notAllowed(i); + mcdu_message(i, "NOT ALLOWED"); } } } @@ -769,7 +752,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) { @@ -785,6 +768,8 @@ var pagebutton = func(btn, i) { canvas_mcdu.myFpln[i].scroll = fmgc.flightPlanController.arrivalIndex[2]; } } + } else { + canvas_mcdu.myFpln[i].scroll = 0; } setprop("/MCDU[" ~ i ~ "]/page", "F-PLNA"); @@ -792,8 +777,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); @@ -804,94 +788,32 @@ var pagebutton = func(btn, i) { } var button = func(btn, i) { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 0 and getprop("/MCDU[" ~ i ~ "]/page") != "MCDU") { - var scratchpad = getprop("/MCDU[" ~ i ~ "]/scratchpad"); + 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 = getprop("/MCDU[" ~ i ~ "]/scratchpad"); + 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 = getprop("/MCDU[" ~ 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 (getprop("/MCDU[" ~ i ~ "]/scratchpad") != text) { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); - } else { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ 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 (getprop("/MCDU[" ~ i ~ "]/scratchpad") != "NOT ALLOWED") { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); - } else { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ 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 (getprop("/MCDU[" ~ i ~ "]/scratchpad") != "FORMAT ERROR") { - if (getprop("/MCDU[" ~ i ~ "]/scratchpad-msg") == 1) { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", ""); - } else { - setprop("/MCDU[" ~ i ~ "]/last-scratchpad", getprop("/MCDU[" ~ 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, overrideStr = "") { + mcdu_scratchpad.scratchpads[i].showTypeI(mcdu_scratchpad.MessageController.getTypeIMsgByText(string)); + mcdu_scratchpad.scratchpads[i].override(overrideStr); } var screenFlash = func(time, i) { diff --git a/Nasal/MCDU/PERFAPPR.nas b/Nasal/MCDU/PERFAPPR.nas index 06479715..2e986681 100644 --- a/Nasal/MCDU/PERFAPPR.nas +++ b/Nasal/MCDU/PERFAPPR.nas @@ -5,37 +5,34 @@ var ldg_config_3_set = props.globals.getNode("/FMGC/internal/ldg-config-3-set", var ldg_config_f_set = props.globals.getNode("/FMGC/internal/ldg-config-f-set", 1); var perfAPPRInput = func(key, i) { - var scratchpad = getprop("/MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; 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 dc90c544..f57d1b7a 100644 --- a/Nasal/MCDU/PERFCLB.nas +++ b/Nasal/MCDU/PERFCLB.nas @@ -3,13 +3,12 @@ # Copyright (c) 2020 Matthew Maring (mattmaring) var perfCLBInput = func(key, i) { - var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L2") { 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 aa5134d3..b26af62c 100644 --- a/Nasal/MCDU/PERFCRZ.nas +++ b/Nasal/MCDU/PERFCRZ.nas @@ -3,13 +3,12 @@ # Copyright (c) 2020 Matthew Maring (mattmaring) var perfCRZInput = func(key, i) { - var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L2") { 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 f6527a7c..c3c5c611 100644 --- a/Nasal/MCDU/PERFDES.nas +++ b/Nasal/MCDU/PERFDES.nas @@ -3,13 +3,12 @@ # Copyright (c) 2020 Matthew Maring (mattmaring) var perfDESInput = func(key, i) { - var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L2") { 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 1969bf2f..09032900 100644 --- a/Nasal/MCDU/PERFGA.nas +++ b/Nasal/MCDU/PERFGA.nas @@ -3,14 +3,13 @@ # uses universal values, will implement separately once FPLN is finished var perfGAInput = func(key, i) { - var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L5") { if (scratchpad == "CLR") { 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 e0cd73da..b50fd2a7 100644 --- a/Nasal/MCDU/PERFTO.nas +++ b/Nasal/MCDU/PERFTO.nas @@ -4,55 +4,52 @@ # Copyright (c) 2020 Matthew Maring (mattmaring) var perfTOInput = func(key, i) { - var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L1") { if (getprop("/FMGC/status/phase") != 1) { 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 f21c5d9b..db5fcb53 100644 --- a/Nasal/MCDU/PROGCLB.nas +++ b/Nasal/MCDU/PROGCLB.nas @@ -1,7 +1,7 @@ # Copyright (c) 2020 Matthew Maring (mattmaring) var progCLBInput = func(key, i) { - var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L1") { if (scratchpad == "CLR") { setprop("/FMGC/internal/cruise-fl-prog", getprop("/FMGC/internal/cruise-fl")); @@ -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 c5ab86c4..38eccee2 100644 --- a/Nasal/MCDU/PROGCRZ.nas +++ b/Nasal/MCDU/PROGCRZ.nas @@ -1,7 +1,7 @@ # Copyright (c) 2020 Matthew Maring (mattmaring) var progCRZInput = func(key, i) { - var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L1") { if (scratchpad == "CLR") { setprop("/FMGC/internal/cruise-fl-prog", getprop("/FMGC/internal/cruise-fl")); @@ -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 0bbfae25..69cbc55e 100644 --- a/Nasal/MCDU/PROGDES.nas +++ b/Nasal/MCDU/PROGDES.nas @@ -1,7 +1,7 @@ # Copyright (c) 2020 Matthew Maring (mattmaring) var progDESInput = func(key, i) { - var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; if (key == "L1") { if (scratchpad == "CLR") { setprop("/FMGC/internal/cruise-fl-prog", getprop("/FMGC/internal/cruise-fl")); @@ -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 63e8135a..d3dfbd65 100644 --- a/Nasal/MCDU/PROGTO.nas +++ b/Nasal/MCDU/PROGTO.nas @@ -3,22 +3,21 @@ var altSet = props.globals.getNode("it-autoflight/input/alt", 1); var progTOInput = func(key, i) { - var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; 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 8f9b6d83..d8a47321 100644 --- a/Nasal/MCDU/RADNAV.nas +++ b/Nasal/MCDU/RADNAV.nas @@ -3,12 +3,11 @@ # Copyright (c) 2020 Josh Davidson (Octal450) var radnavInput = func(key, i) { - var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); + var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; 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(); } diff --git a/Nasal/Systems/save.nas b/Nasal/Systems/save.nas index f1256ba5..35869a63 100644 --- a/Nasal/Systems/save.nas +++ b/Nasal/Systems/save.nas @@ -47,7 +47,9 @@ var default = [ "/controls/gear/brake-parking", # electrics "/systems/electrical/sources/bat-1/percent-calc", - "/systems/electrical/sources/bat-2/percent-calc" + "/systems/electrical/sources/bat-2/percent-calc", + # FMGC + "/FMGC/internal/last-cost-index", ]; var save = func (saved_props, file) {