diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 0eae042d..7d9304b3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -23,9 +23,9 @@ A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. -** System (please complete the following information):** - - OS: - - FlightGear version: +**System (please complete the following information):** + - OS: + - FlightGear version: **Additional context** diff --git a/A320-main.xml b/A320-main.xml index db0014bb..32964294 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -961,9 +961,7 @@ - 0 - 0 - 0 + 0 0 @@ -4054,6 +4052,7 @@ Aircraft/A320-family/Nasal/FMGC/FMGC.nas Aircraft/A320-family/Nasal/FMGC/FMGC-b.nas Aircraft/A320-family/Nasal/FMGC/FMGC-c.nas + Aircraft/A320-family/Nasal/FMGC/winds.nas Aircraft/A320-family/Nasal/MCDU/DUPLICATE.nas @@ -4067,6 +4066,10 @@ Aircraft/A320-family/Nasal/MCDU/PILOTWAYPOINT.nas Aircraft/A320-family/Nasal/MCDU/HOLD.nas Aircraft/A320-family/Nasal/MCDU/F-PLN.nas + Aircraft/A320-family/Nasal/MCDU/WINDCLB.nas + Aircraft/A320-family/Nasal/MCDU/WINDCRZ.nas + Aircraft/A320-family/Nasal/MCDU/WINDDES.nas + Aircraft/A320-family/Nasal/MCDU/WINDHIST.nas Aircraft/A320-family/Nasal/MCDU/MCDU.nas Aircraft/A320-family/Nasal/MCDU/INITA.nas Aircraft/A320-family/Nasal/MCDU/IRSINIT.nas @@ -4085,6 +4088,7 @@ Aircraft/A320-family/Nasal/MCDU/PERFTO.nas Aircraft/A320-family/Nasal/MCDU/RADNAV.nas Aircraft/A320-family/Nasal/MCDU/DATA.nas + Aircraft/A320-family/Nasal/MCDU/DATA2.nas Aircraft/A320-family/Nasal/MCDU/STATUS.nas diff --git a/AircraftConfig/autopush-config.xml b/AircraftConfig/autopush-config.xml index 0e9926c0..fbe49dbf 100644 --- a/AircraftConfig/autopush-config.xml +++ b/AircraftConfig/autopush-config.xml @@ -5,7 +5,7 @@ 0.0 15 5.0 - + 1 false diff --git a/AircraftConfig/groundservices.xml b/AircraftConfig/groundservices.xml index 48a25f1e..1598bb0e 100644 --- a/AircraftConfig/groundservices.xml +++ b/AircraftConfig/groundservices.xml @@ -8,7 +8,7 @@ ground-services vbox - + hbox @@ -26,12 +26,345 @@ - + - + vbox + + hbox + + true + + + + + + true + + + + + vbox + + + left + + + /gear/gear[0]/wow + /gear/gear[1]/wow + /gear/gear[2]/wow + + + /services/chocks/enable + + dialog-apply + + true + + + + + + vbox + + + hbox + + true + + + + + + true + + + + + + + + + hbox + + + /systems/apu/oil/allow-oil-consumption + + 10 + 50 + 200 + /systems/apu/oil/level-l + 3.9 + 5.4 + true + + dialog-apply + + + + + 10 + 200 + + %.1f litres + /systems/apu/oil/level-l + true + + + + + + left + /controls/electrical/ground-cart + + property-assign + /controls/electrical/switches/ext-pwr + 0 + + + + + /controls/gear/brake-parking + /services/chocks/enable + + + /velocities/groundspeed-kt + 2 + + + + + dialog-apply + + true + + + + + left + /controls/pneumatic/switches/groundair + + property-toggle + /controls/pneumatic/switches/groundair + + + + + /controls/gear/brake-parking + /services/chocks/enable + + + /velocities/groundspeed-kt + 2 + + + + + dialog-apply + + true + + + + + left + /controls/hydraulic/hand-pump-yellow + + property-toggle + /controls/hydraulic/hand-pump-yellow + + + + + /controls/gear/brake-parking + /services/chocks/enable + + + /velocities/groundspeed-kt + 2 + + + /systems/electrical/bus/ac-2 + 115 + + + /controls/electrical/switches/ext-pwr + 0 + + + + + dialog-apply + + true + + + + + vbox + + + hbox + + true + + + + + + true + + + + + + left + /services/stairs/l1 + + dialog-apply + + true + + + + + left + /services/stairs/l4 + + dialog-apply + + true + + + + + left + /services/stairs/cover + + dialog-apply + + true + + + + hbox + + true + + + + + + true + + + + + + left + /services/baggage/enable + + dialog-apply + + true + + + + hbox + + true + + + + + + true + + + + + + left + /services/catering/enable + + dialog-apply + + true + + + + + + hbox + + true + + + + + + true + + + + + + + hbox + + true + + + + + + true + + + left @@ -55,159 +388,6 @@ 1 - - - - - - - - - - left - /services/catering/enable - - dialog-apply - - true - - - - - - - left - /services/baggage/enable - - dialog-apply - - true - - - - hbox - - - true - - - - - - true - - - - - - left - /services/stairs/l1 - - dialog-apply - - true - - - - - left - /services/stairs/l4 - - dialog-apply - - true - - - - - left - /services/stairs/cover - - dialog-apply - - true - - - - hbox - - - true - - - - - - true - - - - - hbox - - - /systems/apu/oil/allow-oil-consumption - - 10 - 50 - 200 - /systems/apu/oil/level-l - 3.9 - 5.4 - true - - dialog-apply - - - - - 10 - 200 - - %.1f litres - /systems/apu/oil/level-l - true - - - + diff --git a/AircraftConfig/main.xml b/AircraftConfig/main.xml index eeb97261..e99c51c3 100644 --- a/AircraftConfig/main.xml +++ b/AircraftConfig/main.xml @@ -220,150 +220,6 @@ - - - left - - - /gear/gear[0]/wow - /gear/gear[1]/wow - /gear/gear[2]/wow - - - /services/chocks/nose - - dialog-apply - - true - - - - - left - - - /gear/gear[0]/wow - /gear/gear[1]/wow - /gear/gear[2]/wow - - - /services/chocks/left - - dialog-apply - - true - - - - - left - - - /gear/gear[0]/wow - /gear/gear[1]/wow - /gear/gear[2]/wow - - - /services/chocks/right - - dialog-apply - - true - - - - - left - /controls/electrical/ground-cart - - property-assign - /controls/electrical/switches/ext-pwr - 0 - - - - - /controls/gear/brake-parking - /services/chocks/nose - /services/chocks/left - /services/chocks/right - - - /velocities/groundspeed-kt - 2 - - - - - dialog-apply - - true - - - - - left - /controls/pneumatic/switches/groundair - - property-toggle - /controls/pneumatic/switches/groundair - - - - - /controls/gear/brake-parking - /services/chocks/nose - /services/chocks/left - /services/chocks/right - - - /velocities/groundspeed-kt - 2 - - - - - dialog-apply - - true - - - - - left - /controls/hydraulic/hand-pump-yellow - - property-toggle - /controls/hydraulic/hand-pump-yellow - - - - - /controls/gear/brake-parking - /services/chocks/nose - /services/chocks/left - /services/chocks/right - - - /velocities/groundspeed-kt - 2 - - - /systems/electrical/bus/ac-2 - 115 - - - /controls/electrical/switches/ext-pwr - 0 - - - - - dialog-apply - - true - - diff --git a/Models/A320-groundservices.xml b/Models/A320-groundservices.xml index 321dd5e9..b964707f 100644 --- a/Models/A320-groundservices.xml +++ b/Models/A320-groundservices.xml @@ -132,7 +132,7 @@ Aircraft/A320-family/Models/Services/Chocks/chock_nose.ac - services/chocks/nose + services/chocks/enable 1 @@ -147,7 +147,7 @@ Aircraft/A320-family/Models/Services/Chocks/chock_left.ac - services/chocks/left + services/chocks/enable 1 @@ -163,7 +163,7 @@ Aircraft/A320-family/Models/Services/Chocks/chock_right.ac - services/chocks/right + services/chocks/enable 1 diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index a64e2d99..fccf7832 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -18,8 +18,14 @@ var myAirways = [nil, nil]; var myDuplicate = [nil, nil]; var myClosestAirport = [nil, nil]; var myPilotWP = [nil, nil]; +var myWind = [nil, nil]; +var myCLBWIND = [nil, nil]; +var myCRZWIND = [nil, nil]; +var myDESWIND = [nil, nil]; +var myHISTWIND = [nil, nil]; var default = "BoeingCDU-Large.ttf"; -var symbol = "helvetica_medium.txf"; +#var symbol = "helvetica_medium.txf"; +var symbol = "LiberationMonoCustom.ttf"; var normal = 70; var small = 56; var page = ""; @@ -204,6 +210,8 @@ var dest_qnh = props.globals.getNode("/FMGC/internal/dest-qnh", 1); var dest_temp = props.globals.getNode("/FMGC/internal/dest-temp", 1); var dest_mag = props.globals.getNode("/FMGC/internal/dest-mag", 1); var dest_wind = props.globals.getNode("/FMGC/internal/dest-wind", 1); +# var grnd_mag = props.globals.getNode("/FMGC/internal/dest-mag-grnd", 1); +# var grnd_wind = props.globals.getNode("/FMGC/internal/dest-wind-grnd", 1); var vapp_speed_set = props.globals.getNode("/FMGC/internal/vapp-speed-set", 1); var final = props.globals.getNode("/FMGC/internal/final", 1); var radio = props.globals.getNode("/FMGC/internal/radio", 1); @@ -978,7 +986,7 @@ var canvas_MCDU_base = { } else { me["Simple_L5"].setFont(symbol); me["Simple_L5"].setFontSize(small); - me["Simple_L5"].setText("[ ]/[ . ]"); + me["Simple_L5"].setText("[ ]/[ ]"); } if (vor2FreqSet.getValue() == 1) { @@ -998,7 +1006,7 @@ var canvas_MCDU_base = { } else { me["Simple_R5"].setFont(symbol); me["Simple_R5"].setFontSize(small); - me["Simple_R5"].setText("[ . ]/[ ]"); + me["Simple_R5"].setText("[ ]/[ ]"); } me["Simple_L1"].setText(" " ~ vor1.getValue()); @@ -1012,7 +1020,7 @@ var canvas_MCDU_base = { me["Simple_L5S"].setText("ADF1/FREQ"); me["Simple_R1"].setText(" " ~ vor2.getValue()); me["Simple_R2"].setText(sprintf("%3.0f", vor2CRS.getValue())); - me["Simple_R3"].setText("[ ]/[ ]"); + me["Simple_R3"].setText("[ ]/[ ]"); me["Simple_R4"].setText("-.- [ ]"); me["Simple_R1S"].setText("FREQ/VOR2"); me["Simple_R2S"].setText("CRS"); @@ -2288,7 +2296,7 @@ var canvas_MCDU_base = { me["Simple_L4S"].setText("TRANS ALT"); me["Simple_L5S"].setText("THR RED/ACC"); me["Simple_L6S"].setText(" UPLINK"); - me["Simple_R2"].setText("[ ] "); + me["Simple_R2"].setText("[ ] "); me["Simple_R5"].setText(sprintf("%3.0f", engOutAcc.getValue())); me["Simple_R6"].setText("PHASE "); me["Simple_R1S"].setText("RWY "); @@ -2364,7 +2372,7 @@ var canvas_MCDU_base = { } else { me["Simple_R3"].setFont(symbol); me["Simple_R3"].setFontSize(small); - me["Simple_R3"].setText("[ ]/[ ]"); + me["Simple_R3"].setText("[ ]/[ ]"); } if (flexSet.getValue() == 1) { me["Simple_R4"].setFont(default); @@ -2968,6 +2976,8 @@ var canvas_MCDU_base = { me["Simple_L3S"].setText("MAG WIND"); if (dest_mag.getValue() != -1 and dest_wind.getValue() != -1) { me["Simple_L3"].setText(sprintf("%03.0fg", dest_mag.getValue()) ~ sprintf("/%.0f", dest_wind.getValue())); + # } else if (grnd_mag.getValue() != -1 and grnd_wind.getValue() != -1) { +# me["Simple_L3"].setText(sprintf("%03.0fg", grnd_mag.getValue()) ~ sprintf("/%.0f", grnd_wind.getValue())); } else { me["Simple_L3"].setText("---g/---");; } @@ -3161,6 +3171,135 @@ var canvas_MCDU_base = { me["Simple_C1S"].setText("FLP RETR"); me["Simple_C2S"].setText("SLT RETR"); me["Simple_C3S"].setText("CLEAN "); + } else if (page == "WINDCLB" or page == "WINDCRZ" or page == "WINDDES" or page == "WINDHIST") { + if (!pageSwitch[i].getBoolValue()) { + me["Simple"].show(); + me["Simple_Center"].show(); + me["FPLN"].hide(); + me["DIRTO_TMPY_group"].hide(); + me["INITA"].hide(); + me["IRSINIT"].hide(); + me["INITB"].hide(); + me["FUELPRED"].hide(); + me["PROG"].hide(); + me["PERFTO"].hide(); + # if (page == "WINDCRZ") { + # up/down arrows show + # } else { + # up/down arrows hide + # } + me["Simple_PageNum"].setText("X/X"); + me["Simple_PageNum"].hide(); + me["Simple_Title"].show(); + me["ArrowLeft"].hide(); + me["ArrowRight"].hide(); + + me["Simple_L0S"].hide(); + me["Simple_C3B"].hide(); + me["Simple_C4B"].hide(); + + me.fontLeft(default, default, default, default, default, default); + me.fontLeftS(default, default, default, default, default, default); + me.fontRight(default, default, default, default, default, default); + me.fontRightS(default, default, default, default, default, default); + + me.fontSizeLeft(normal, normal, normal, normal, normal, normal); + + me.colorLeftArrow("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht"); + + if (page == "WINDCLB") { + myWind = myCLBWIND; + me.colorLeftS("wht", "wht", "wht", "wht", "wht", "amb"); + me.colorRightS("wht", "wht", "amb", "wht", "wht", "amb"); + me.fontSizeCenter(normal, normal, normal, normal, normal, normal); + } else if (page == "WINDCRZ") { + myWind = myCRZWIND; + me.colorLeftS("wht", "wht", "wht", "wht", "wht", "amb"); + me.colorRightS("wht", "amb", "wht", "wht", "wht", "amb"); + me.fontSizeCenter(normal, normal, normal, normal, normal, normal); + } else if (page == "WINDDES") { + myWind = myDESWIND; + me.colorLeftS("wht", "wht", "wht", "wht", "wht", "amb"); + me.colorRightS("wht", "wht", "amb", "wht", "wht", "amb"); + me.fontSizeCenter(normal, normal, normal, normal, normal, normal); + } else if (page == "WINDHIST") { + myWind = myHISTWIND; + me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht"); + me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht"); + me.fontSizeCenter(small, small, small, small, small, normal); + } + + if (myWind[i] != nil) { + if (page == "WINDCRZ") { + me["Simple_Title"].setText(sprintf("%s", myWind[i].title[0] ~ myWind[i].title[1] ~ myWind[i].title[2])); + } else { + me["Simple_Title"].setText(sprintf("%s", myWind[i].title)); + } + me["Simple_Title"].setColor(getprop("/MCDUC/colors/" ~ myWind[i].titleColour ~ "/r"), getprop("/MCDUC/colors/" ~ myWind[i].titleColour ~ "/g"), getprop("/MCDUC/colors/" ~ myWind[i].titleColour ~ "/b")); + + forindex (var matrixArrow; myWind[i].arrowsMatrix) { + if (matrixArrow == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myWind[i].arrowsMatrix[matrixArrow]) { + if (myWind[i].arrowsMatrix[matrixArrow][item] == 1) { + me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].show(); + } else { + me["Simple_" ~ sign ~ (item + 1) ~ "_Arrow"].hide(); + } + } + } + me.colorLeftArrow(myWind[i].arrowsColour[0][0],myWind[i].arrowsColour[0][1],myWind[i].arrowsColour[0][2],myWind[i].arrowsColour[0][3],myWind[i].arrowsColour[0][4],myWind[i].arrowsColour[0][5]); + + forindex (var matrixFont; myWind[i].fontMatrix) { + if (matrixFont == 0) { + var sign = "L"; + } else { + var sign = "R"; + } + forindex (var item; myWind[i].fontMatrix[matrixFont]) { + if (myWind[i].fontMatrix[matrixFont][item] == 1) { + me["Simple_" ~ sign ~ (item + 1)].setFont(symbol); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(small); + } else { + me["Simple_" ~ sign ~ (item + 1)].setFont(default); + me["Simple_" ~ sign ~ (item + 1)].setFontSize(normal); + } + } + } + + me.dynamicPageFunc(myWind[i].L1, "Simple_L1"); + me.dynamicPageFunc(myWind[i].L2, "Simple_L2"); + me.dynamicPageFunc(myWind[i].L3, "Simple_L3"); + me.dynamicPageFunc(myWind[i].L4, "Simple_L4"); + me.dynamicPageFunc(myWind[i].L5, "Simple_L5"); + me.dynamicPageFunc(myWind[i].L6, "Simple_L6"); + + me.colorLeft(myWind[i].L1[2],myWind[i].L2[2],myWind[i].L3[2],myWind[i].L4[2],myWind[i].L5[2],myWind[i].L6[2]); + + me.dynamicPageFunc(myWind[i].C1, "Simple_C1"); + me.dynamicPageFunc(myWind[i].C2, "Simple_C2"); + me.dynamicPageFunc(myWind[i].C3, "Simple_C3"); + me.dynamicPageFunc(myWind[i].C4, "Simple_C4"); + me.dynamicPageFunc(myWind[i].C5, "Simple_C5"); + me.dynamicPageFunc(myWind[i].C6, "Simple_C6"); + + me.colorCenter(myWind[i].C1[2],myWind[i].C2[2],myWind[i].C3[2],myWind[i].C4[2],myWind[i].C5[2],myWind[i].C6[2]); + + me.dynamicPageFunc(myWind[i].R1, "Simple_R1"); + me.dynamicPageFunc(myWind[i].R2, "Simple_R2"); + me.dynamicPageFunc(myWind[i].R3, "Simple_R3"); + me.dynamicPageFunc(myWind[i].R4, "Simple_R4"); + me.dynamicPageFunc(myWind[i].R5, "Simple_R5"); + me.dynamicPageFunc(myWind[i].R6, "Simple_R6"); + + me.colorRight(myWind[i].R1[2],myWind[i].R2[2],myWind[i].R3[2],myWind[i].R4[2],myWind[i].R5[2],myWind[i].R6[2]); + } + pageSwitch[i].setBoolValue(1); + } } else if (page == "LATREV") { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); @@ -3200,6 +3339,8 @@ var canvas_MCDU_base = { if (myLatRev[i] != nil) { me["Simple_Title"].setText(sprintf("%s", myLatRev[i].title[0] ~ myLatRev[i].title[1] ~ myLatRev[i].title[2])); + me["Simple_Title"].setColor(getprop("/MCDUC/colors/" ~ myLatRev[i].titleColour ~ "/r"), getprop("/MCDUC/colors/" ~ myLatRev[i].titleColour ~ "/g"), getprop("/MCDUC/colors/" ~ myLatRev[i].titleColour ~ "/b")); + if (myLatRev[i].subtitle[0] != nil) { me["Simple_Center"].show(); diff --git a/Nasal/FMGC/FMGC-b.nas b/Nasal/FMGC/FMGC-b.nas index 229a098f..2bed42dc 100644 --- a/Nasal/FMGC/FMGC-b.nas +++ b/Nasal/FMGC/FMGC-b.nas @@ -430,6 +430,12 @@ var ITAF = { if (FPLN.wp0Dist.getValue() <= FPLN.turnDist and !Gear.wow1.getBoolValue()) { flightPlanController.autoSequencing(); } + + #if (FPLN.wp0Dist.getValue() <= FPLN.turnDist and !Gear.wow1.getBoolValue() and fmgc.flightPlanController.flightplans[2].getWP(FPLN.currentWPTemp).fly_type == "flyBy") { + # flightPlanController.autoSequencing(); + #} elsif (FPLN.wp0Dist.getValue() <= 0.1) { + # flightPlanController.autoSequencing(); + #} } } }, diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index efb38c8d..b38d756f 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -269,9 +269,9 @@ var updateFuel = func { temp = getprop("/FMGC/internal/cruise-temp"); dist = flightPlanController.arrivalDist; - wind = getprop("/FMGC/internal/trip-wind"); + trpWind = getprop("/FMGC/internal/trip-wind"); wind_value = getprop("/FMGC/internal/trip-wind-value"); - if (find("HD", wind) != -1 or find("-", wind) != -1 or find("H", wind) != -1) { + if (find("HD", trpWind) != -1 or find("-", trpWind) != -1 or find("H", trpWind) != -1) { wind_value = wind_value * -1; } dist = dist - (dist * wind_value * 0.002); @@ -722,6 +722,8 @@ var reset_FMGC = func { ITAF.init(); FMGCinit(); flightPlanController.reset(); + windController.reset(); + mcdu.MCDU_reset(0); mcdu.MCDU_reset(1); setprop("it-autoflight/input/fd1", fd1); diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 3dd3c1bb..5e515566 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -96,6 +96,7 @@ var flightPlanController = { if (canvas_mcdu.myAirways[n] != nil) { canvas_mcdu.myAirways[n].updateTmpy(); } + fmgc.windController.createTemporaryWinds(n); me.flightPlanChanged(n); }, @@ -105,8 +106,6 @@ var flightPlanController = { print(err[0]); print("Load failed."); } - # try to fix fgfp - me.flightplans[3].destination = airportinfo(getprop("/FMGC/internal/arr-arpt")); me.destroyTemporaryFlightPlan(3, 1); }, @@ -116,34 +115,36 @@ var flightPlanController = { me.resetFlightplan(2); me.flightplans[2] = me.flightplans[n].clone(); - if (mcdu.isNoSid[n] == 1) { - mcdu.isNoSid[2] = 1; - } else { - mcdu.isNoSid[2] = 0; - } - - if (mcdu.isNoStar[n] == 1) { - mcdu.isNoStar[2] = 1; - } else { - mcdu.isNoStar[2] = 0; - } - - if (mcdu.isNoVia[n] == 1) { - mcdu.isNoVia[2] = 1; - } else { - mcdu.isNoVia[2] = 0; - } - - if (mcdu.isNoTransDep[n] == 1) { - mcdu.isNoTransDep[2] = 1; - } else { - mcdu.isNoTransDep[2] = 0; - } - - if (mcdu.isNoTransArr[n] == 1) { - mcdu.isNoTransArr[2] = 1; - } else { - mcdu.isNoTransArr[2] = 0; + if (n != 3) { + if (mcdu.isNoSid[n] == 1) { + mcdu.isNoSid[2] = 1; + } else { + mcdu.isNoSid[2] = 0; + } + + if (mcdu.isNoStar[n] == 1) { + mcdu.isNoStar[2] = 1; + } else { + mcdu.isNoStar[2] = 0; + } + + if (mcdu.isNoVia[n] == 1) { + mcdu.isNoVia[2] = 1; + } else { + mcdu.isNoVia[2] = 0; + } + + if (mcdu.isNoTransDep[n] == 1) { + mcdu.isNoTransDep[2] = 1; + } else { + mcdu.isNoTransDep[2] = 0; + } + + if (mcdu.isNoTransArr[n] == 1) { + mcdu.isNoTransArr[2] = 1; + } else { + mcdu.isNoTransArr[2] = 0; + } } me.flightPlanChanged(2); @@ -155,6 +156,8 @@ var flightPlanController = { if (canvas_mcdu.myDirTo[n] != nil) { canvas_mcdu.myDirTo[n].updateTmpy(); } + fmgc.windController.destroyTemporaryWinds(n, a); + me.flightPlanChanged(n); }, updateAirports: func(dep, arr, plan) { @@ -165,6 +168,7 @@ var flightPlanController = { me.destroyTemporaryFlightPlan(0, 0); me.destroyTemporaryFlightPlan(1, 0); me.currentToWptIndex.setValue(0); + me.arrivalIndex = [0, 0, 0]; # reset arrival index calculations } me.addDiscontinuity(1, plan); @@ -286,10 +290,12 @@ var flightPlanController = { insertTP: func(n, index = 1) { me.flightplans[n].insertWP(createWP(geo.aircraft_position(), "T-P"), index); + fmgc.windController.insertWind(n, index, 0, "T-P"); }, insertPPOS: func(n, index = 0) { me.flightplans[n].insertWP(createWP(geo.aircraft_position(), "PPOS"), index); + fmgc.windController.insertWind(n, index, 0, "PPOS"); }, # childWPBearingDistance - return waypoint at bearing and distance from specified waypoint ghost @@ -319,6 +325,7 @@ var flightPlanController = { # fudge the altitude since we cannot create a hdgtoAlt from nasal. Assume 600 feet per mile - 2.5 miles me.flightplans[n].insertWP(createWP(me.childWPBearingDistance(wptStore, me.flightplans[n].departure_runway.heading, 2.5), "1500", "sid"), 1); + fmgc.windController.insertWind(n, 1, 0, "1500"); } me.flightPlanChanged(n); }, @@ -339,6 +346,7 @@ var flightPlanController = { hdg = hdg - 360; } me.flightplans[n].insertWP(createWP(me.childWPBearingDistance(wptStore, hdg, 5), "CF", "star"), me.arrivalIndex[n]); + fmgc.windController.insertWind(n, me.arrivalIndex[n], 0, "CF"); } me.flightPlanChanged(n); }, @@ -361,6 +369,7 @@ var flightPlanController = { # use createWP here as createWPFrom doesn't accept waypoints # createWPFrom worked before... but be sure! me.flightplans[plan].insertWP(createWP(waypointGhost, waypointGhost.wp_name), 2); + fmgc.windController.insertWind(plan, 2, 0, waypointGhost.wp_name); me.addDiscontinuity(3, plan); } else { # we want to delete the intermediate waypoints up to but not including the waypoint. Leave index 0, we delete it later. @@ -386,6 +395,7 @@ var flightPlanController = { if (((s == 0 and left(wp, 4) != FMGCdep.getValue() and left(wp, 4) != FMGCarr.getValue()) or (s == 1)) and me.flightplans[n].getPlanSize() > 2) { if (me.flightplans[n].getWP(index).id != "DISCONTINUITY" and a == 0) { # if it is a discont, don't make a new one me.flightplans[n].deleteWP(index); + fmgc.windController.deleteWind(n, index); if (me.flightplans[n].getWP(index) != nil and s == 0) { if (me.flightplans[n].getWP(index).id != "DISCONTINUITY") { # else, if the next one isn't a discont, add one me.addDiscontinuity(index, n); @@ -393,6 +403,7 @@ var flightPlanController = { } } else { me.flightplans[n].deleteWP(index); + fmgc.windController.deleteWind(n, index); } me.flightPlanChanged(n); canvas_nd.A3XXRouteDriver.triggerSignal("fp-removed"); @@ -452,6 +463,7 @@ var flightPlanController = { var indexPresent = me.flightplans[plan].indexOfWP(airport[indexToInsert]); if (me.flightplans[plan].indexOfWP(airport[indexToInsert]) == -1) { me.flightplans[plan].insertWP(createWPFrom(airport[indexToInsert]), index); + fmgc.windController.insertWind(plan, index, 0, text); me.addDiscontinuity(index + 1, plan); me.flightPlanChanged(plan); return 2; @@ -485,6 +497,7 @@ var flightPlanController = { var indexPresent = me.flightplans[plan].indexOfWP(fix[indexToInsert]); if (me.flightplans[plan].indexOfWP(fix[indexToInsert]) == -1) { me.flightplans[plan].insertWP(createWPFrom(fix[indexToInsert]), index); + fmgc.windController.insertWind(plan, index, 1, text); me.addDiscontinuity(index + 1, plan); me.flightPlanChanged(plan); return 2; @@ -518,6 +531,7 @@ var flightPlanController = { var indexPresent = me.flightplans[plan].indexOfWP(navaid[indexToInsert]); if (me.flightplans[plan].indexOfWP(navaid[indexToInsert]) == -1) { me.flightplans[plan].insertWP(createWPFrom(navaid[indexToInsert]), index); + fmgc.windController.insertWind(plan, index, 1, text); me.addDiscontinuity(index + 1, plan); me.flightPlanChanged(plan); return 2; @@ -538,6 +552,7 @@ var flightPlanController = { if (me.flightplans[plan].indexOfWP(wpGhost) == -1) { # use createWP here as createWPFrom doesn't accept waypoints me.flightplans[plan].insertWP(createWP(wpGhost, wpGhost.wp_name), index); + fmgc.windController.insertWind(plan, index, 1, wpGhost.wp_name); me.addDiscontinuity(index + 1, plan); me.flightPlanChanged(plan); return 2; @@ -567,6 +582,7 @@ var flightPlanController = { } me.flightplans[plan].insertWP(waypoint.wpGhost, index); + fmgc.windController.insertWind(plan, index, 1, "LL"); me.addDiscontinuity(index + 1, plan); me.flightPlanChanged(plan); return 2; @@ -638,6 +654,37 @@ var flightPlanController = { return me.insertPlaceBearingDistance(wpGhost, textSplit[1] + localMagvar, textSplit[2], index, plan); # magnetic to true? I don't know. But this works! }, + getNavCount: func(plan) { + var count = 0; + for (var wpt = 0; wpt < me.flightplans[plan].getPlanSize(); wpt += 1) { + #print(me.flightplans[plan].getWP(wpt).wp_type); + if (me.flightplans[plan].getWP(wpt).wp_type == "navaid") { + count += 1; + } + } + return count; + }, + + getDepartureCount: func(plan) { + var count = 0; + for (var wpt = 0; wpt < me.flightplans[plan].getPlanSize(); wpt += 1) { + #print(me.flightplans[plan].getWP(wpt).wp_role); + if (me.flightplans[plan].getWP(wpt).wp_role == "sid") { + count += 1; + } + } + return count; + }, + + getArrivalCount: func(plan) { + var count = 0; + for (var wpt = 0; wpt < me.flightplans[plan].getPlanSize(); wpt += 1) { + if (me.flightplans[plan].getWP(wpt).wp_role == "star" or me.flightplans[plan].getWP(wpt).wp_role == "approach" or me.flightplans[plan].getWP(wpt).wp_role == "missed") { + count += 1; + } + } + return count; + }, # insertPlaceBearingDistance - insert PBD waypoint at specified index, # at some specified bearing, distance from a specified location @@ -654,6 +701,7 @@ var flightPlanController = { } me.flightplans[plan].insertWP(waypoint.wpGhost, index); + fmgc.windController.insertWind(plan, index, 0, "PBD"); me.addDiscontinuity(index + 1, plan); me.flightPlanChanged(plan); return 2; @@ -709,7 +757,10 @@ var flightPlanController = { append(wpCoursePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/course-from-prev", 0, "DOUBLE")); append(wpDistancePrev[n], props.globals.initNode("/FMGC/flightplan[" ~ n ~ "]/wp[" ~ counter ~ "]/distance-from-prev", 0, "DOUBLE")); } + me.updatePlans(); + fmgc.windController.updatePlans(); + # push update to fuel if (getprop("/FMGC/internal/block-confirmed")) { setprop("/FMGC/internal/fuel-calculating", 0); @@ -773,6 +824,12 @@ var flightPlanController = { } } } + + if (me.flightplans[2].getWP(me.arrivalIndex[2]) == nil or me.flightplans[2].getWP(1) == nil) { + me.arrivalDist = 9999; + print(me.arrivalIndex[2]); + } + me.arrivalDist = me.flightplans[2].getWP(me.arrivalIndex[2]).distance_along_route - me.flightplans[2].getWP(1).leg_distance + me._arrivalDist; me.updateMCDUDriver(n); }, diff --git a/Nasal/FMGC/winds.nas b/Nasal/FMGC/winds.nas new file mode 100644 index 00000000..b4c31a92 --- /dev/null +++ b/Nasal/FMGC/winds.nas @@ -0,0 +1,378 @@ +# A3XX FMGC Wind Driver +# Copyright (c) 2020 Matthew Maring (mattmaring) + +var wind = { + new: func() { + var w = {parents: [wind]}; + w.heading = 0; + w.magnitude = 0; + w.altitude = ""; + return w; + }, + + newcopy: func(heading, magnitude, altitude) { + var w = {parents: [wind]}; + w.heading = heading; + w.magnitude = magnitude; + w.altitude = altitude; + return w; + } +}; + +var alt_wind = { + new: func() { + var aw = {parents: [alt_wind]}; + aw.heading = 0; + aw.magnitude = 0; + return aw; + }, + + newcopy: func(heading, magnitude) { + var aw = {parents: [alt_wind]}; + aw.heading = heading ; + aw.magnitude = magnitude; + return aw; + } +}; + +var sat_temp = { + new: func() { + var st = {parents: [sat_temp]}; + st.temp = 0; + st.altitude = ""; + return st; + }, + + newcopy: func(temp, altitude) { + var st = {parents: [sat_temp]}; + st.temp = temp; + st.altitude = altitude; + return st; + } +}; + +var waypoint_winds = { + new: func(id, type, includeWind) { + var ww = {parents: [waypoint_winds]}; + ww.id = id; + ww.type = type; #departure, waypoint, arrival + ww.includeWind = includeWind; + ww.wind1 = wind.new(); + ww.wind2 = wind.new(); + ww.wind3 = wind.new(); + ww.wind4 = wind.new(); + ww.wind5 = wind.new(); + ww.sat1 = sat_temp.new(); + ww.alt1 = alt_wind.new(); + return ww; + }, + + newcopy: func(id, type, includeWind, wind1, wind2, wind3, wind4, wind5, sat1, alt1) { + var ww = {parents: [waypoint_winds]}; + ww.id = id; + ww.type = type; #departure, waypoint, arrival + ww.includeWind = includeWind; + ww.wind1 = wind1; + ww.wind2 = wind2; + ww.wind3 = wind3; + ww.wind4 = wind4; + ww.wind5 = wind5; + ww.sat1 = sat1; + ww.alt1 = alt1; + return ww; + } +}; + +var windController = { + clb_winds: [0, 0, 0], + crz_winds: [0, 0, 0], + des_winds: [0, 0, 0], + winds: [[], [], []], #waypoint winds used if route includes navaids + nav_indicies: [[], [], []], + windSizes: [0, 0, 0], + accessPage: ["", ""], + #temporaryFlag: [0, 0], + + init: func() { + me.resetWind(2); + me.clb_winds[2] = waypoint_winds.new("climb", "waypoint", 1); + me.crz_winds[2] = waypoint_winds.new("cruize", "waypoint", 1); + me.des_winds[2] = waypoint_winds.new("descent", "waypoint", 1); + }, + + reset: func() { + #me.temporaryFlag[0] = 0; + #me.temporaryFlag[1] = 0; + me.resetWind(0); + me.resetWind(1); + me.resetWind(2); + }, + + resetWind: func(n) { + me.clb_winds[n] = 0; + me.crz_winds[n] = 0; + me.des_winds[n] = 0; + me.winds[n] = []; + me.nav_indicies[n] = []; + me.windSizes[n] = 0; + }, + + copyClbWind: func(n) { + var id = me.clb_winds[n].id; + var type = me.clb_winds[n].type; + var includeWind = me.clb_winds[n].includeWind; + var wind1 = wind.newcopy(me.clb_winds[n].wind1.heading, me.clb_winds[n].wind1.magnitude, me.clb_winds[n].wind1.altitude); + var wind2 = wind.newcopy(me.clb_winds[n].wind2.heading, me.clb_winds[n].wind2.magnitude, me.clb_winds[n].wind2.altitude); + var wind3 = wind.newcopy(me.clb_winds[n].wind3.heading, me.clb_winds[n].wind3.magnitude, me.clb_winds[n].wind3.altitude); + var wind4 = wind.newcopy(me.clb_winds[n].wind4.heading, me.clb_winds[n].wind4.magnitude, me.clb_winds[n].wind4.altitude); + var wind5 = wind.newcopy(me.clb_winds[n].wind5.heading, me.clb_winds[n].wind5.magnitude, me.clb_winds[n].wind5.altitude); + var sat1 = sat_temp.newcopy(me.clb_winds[n].sat1.temp, me.clb_winds[n].sat1.altitude); + var alt1 = alt_wind.newcopy(me.clb_winds[n].alt1.heading, me.clb_winds[n].alt1.magnitude); + return waypoint_winds.newcopy(id, type, includeWind, wind1, wind2, wind3, wind4, wind5, sat1, alt1); + }, + + copyCrzWind: func(n) { + var id = me.crz_winds[n].id; + var type = me.crz_winds[n].type; + var includeWind = me.crz_winds[n].includeWind; + var wind1 = wind.newcopy(me.crz_winds[n].wind1.heading, me.crz_winds[n].wind1.magnitude, me.crz_winds[n].wind1.altitude); + var wind2 = wind.newcopy(me.crz_winds[n].wind2.heading, me.crz_winds[n].wind2.magnitude, me.crz_winds[n].wind2.altitude); + var wind3 = wind.newcopy(me.crz_winds[n].wind3.heading, me.crz_winds[n].wind3.magnitude, me.crz_winds[n].wind3.altitude); + var wind4 = wind.newcopy(me.crz_winds[n].wind4.heading, me.crz_winds[n].wind4.magnitude, me.crz_winds[n].wind4.altitude); + var wind5 = wind.newcopy(me.crz_winds[n].wind5.heading, me.crz_winds[n].wind5.magnitude, me.crz_winds[n].wind5.altitude); + var sat1 = sat_temp.newcopy(me.crz_winds[n].sat1.temp, me.crz_winds[n].sat1.altitude); + var alt1 = alt_wind.newcopy(me.crz_winds[n].alt1.heading, me.crz_winds[n].alt1.magnitude); + return waypoint_winds.newcopy(id, type, includeWind, wind1, wind2, wind3, wind4, wind5, sat1, alt1); + }, + + copyDesWind: func(n) { + var id = me.des_winds[n].id; + var type = me.des_winds[n].type; + var includeWind = me.des_winds[n].includeWind; + var wind1 = wind.newcopy(me.des_winds[n].wind1.heading, me.des_winds[n].wind1.magnitude, me.des_winds[n].wind1.altitude); + var wind2 = wind.newcopy(me.des_winds[n].wind2.heading, me.des_winds[n].wind2.magnitude, me.des_winds[n].wind2.altitude); + var wind3 = wind.newcopy(me.des_winds[n].wind3.heading, me.des_winds[n].wind3.magnitude, me.des_winds[n].wind3.altitude); + var wind4 = wind.newcopy(me.des_winds[n].wind4.heading, me.des_winds[n].wind4.magnitude, me.des_winds[n].wind4.altitude); + var wind5 = wind.newcopy(me.des_winds[n].wind5.heading, me.des_winds[n].wind5.magnitude, me.des_winds[n].wind5.altitude); + var sat1 = sat_temp.newcopy(me.des_winds[n].sat1.temp, me.des_winds[n].sat1.altitude); + var alt1 = alt_wind.newcopy(me.des_winds[n].alt1.heading, me.des_winds[n].alt1.magnitude); + return waypoint_winds.newcopy(id, type, includeWind, wind1, wind2, wind3, wind4, wind5, sat1, alt1); + }, + + copyWinds: func(n) { + var tempWind = []; + for (i = 0; i < size(me.winds[n]); i += 1) { + var id = me.winds[n][i].id; + var type = me.winds[n][i].type; + var includeWind = me.winds[n][i].includeWind; + var wind1 = wind.newcopy(me.winds[n][i].wind1.heading, me.winds[n][i].wind1.magnitude, me.winds[n][i].wind1.altitude); + var wind2 = wind.newcopy(me.winds[n][i].wind2.heading, me.winds[n][i].wind2.magnitude, me.winds[n][i].wind2.altitude); + var wind3 = wind.newcopy(me.winds[n][i].wind3.heading, me.winds[n][i].wind3.magnitude, me.winds[n][i].wind3.altitude); + var wind4 = wind.newcopy(me.winds[n][i].wind4.heading, me.winds[n][i].wind4.magnitude, me.winds[n][i].wind4.altitude); + var wind5 = wind.newcopy(me.winds[n][i].wind5.heading, me.winds[n][i].wind5.magnitude, me.winds[n][i].wind5.altitude); + var sat1 = sat_temp.newcopy(me.winds[n][i].sat1.temp, me.winds[n][i].sat1.altitude); + var alt1 = alt_wind.newcopy(me.winds[n][i].alt1.heading, me.winds[n][i].alt1.magnitude); + append(tempWind, waypoint_winds.newcopy(id, type, includeWind, wind1, wind2, wind3, wind4, wind5, sat1, alt1)); + } + return tempWind; + }, + + createTemporaryWinds: func(n) { + me.resetWind(n); + me.clb_winds[n] = me.copyClbWind(2); + me.crz_winds[n] = me.copyCrzWind(2); + me.des_winds[n] = me.copyDesWind(2); + me.winds[n] = me.copyWinds(2); + me.nav_indicies[n] = me.nav_indicies[2]; + me.windSizes[n] = me.windSizes[2]; + #me.temporaryFlag[n] = 1; + }, + + destroyTemporaryWinds: func(n, a) { # a = 1 activate, a = 0 erase + #print("destroying temporary ", n); + if (a == 1) { + me.resetWind(2); + me.clb_winds[2] = me.copyClbWind(n); + me.crz_winds[2] = me.copyCrzWind(n); + me.des_winds[2] = me.copyDesWind(n); + me.winds[2] = me.copyWinds(n); + me.nav_indicies[2] = me.nav_indicies[n]; + me.windSizes[2] = me.windSizes[n]; + } + if (n == 3) { return; } + me.resetWind(n); + #me.updatePlans(); + #me.temporaryFlag[n] = 0; + }, + + insertWind: func(plan, index, value, id) { + if (me.windSizes[plan] == index) { + if (value == 3) { + append(me.winds[plan], waypoint_winds.new(id, "arrival", 0)); + } else if (value == 2) { + append(me.winds[plan], waypoint_winds.new(id, "departure", 0)); + } else if (value == 1) { + append(me.winds[plan], waypoint_winds.new(id, "waypoint", 1)); + } else { + append(me.winds[plan], waypoint_winds.new(id, "waypoint", 0)); + } + me.windSizes[plan] += 1; + } else if (me.windSizes[plan] > index and index >= 0) { + append(me.winds[plan], waypoint_winds.new(id, "waypoint", 0)); + me.windSizes[plan] += 1; + for (i = me.windSizes[plan] - 1; i > index; i -= 1) { + me.winds[plan][i] = me.winds[plan][i - 1]; + } + if (value == 3) { + me.winds[plan][index] = waypoint_winds.new(id, "arrival", 0); + } else if (value == 2) { + me.winds[plan][index] = waypoint_winds.new(id, "departure", 0); + } else if (value == 1) { + me.winds[plan][index] = waypoint_winds.new(id, "waypoint", 1); + } else { + me.winds[plan][index] = waypoint_winds.new(id, "waypoint", 0); + } + } else { + #print("insert invalid id: ", id, ", plan: ", plan, ", index: ", index, ", size: ", me.windSizes[plan]); + #debug.dump(me.winds); + #debug.dump(me.windSizes); + return; + } + #print("insert plan: ", plan, ", index: ", index); + #debug.dump(me.winds); + #debug.dump(me.windSizes); + }, + + deleteWind: func(plan, index) { + if (me.windSizes[plan] == index) { + pop(me.winds[plan]); + me.windSizes[plan] -= 1; + } else if (me.windSizes[plan] > index and index >= 0) { + for (i = index; i < me.windSizes[plan] - 1; i += 1) { + me.winds[plan][i] = me.winds[plan][i + 1]; + } + pop(me.winds[plan]); + me.windSizes[plan] -= 1; + } else { + #print("delete invalid plan: ", plan, ", index: ", index, ", size: ", me.windSizes[plan]); + #debug.dump(me.winds); + #debug.dump(me.windSizes); + return; + } + #print("delete plan: ", plan, ", index: ", index); + #debug.dump(me.winds); + #debug.dump(me.windSizes); + }, + + updatePlans: func() { + var winds_copy = me.winds; + var windSizes_copy = me.windSizes; + me.winds = [[], [], []]; + me.nav_indicies = [[], [], []]; + me.windSizes = [0, 0, 0]; + + # loop through waypoints + for (plan = 0; plan <= 2; plan += 1) { + for (i = 0; i < fmgc.flightPlanController.flightplans[plan].getPlanSize(); i += 1) { + var waypoint = fmgc.flightPlanController.flightplans[plan].getWP(i); + #print(waypoint.wp_role, "| : |", waypoint.wp_type); + if (waypoint.wp_role == "sid") { + append(me.winds[plan], waypoint_winds.new(waypoint.id, "departure", 0)); + me.windSizes[plan] += 1; + } else if (waypoint.wp_role == "star" or waypoint.wp_role == "approach" or waypoint.wp_role == "missed") { + append(me.winds[plan], waypoint_winds.new(waypoint.id, "arrival", 0)); + me.windSizes[plan] += 1; + } else if (waypoint.wp_role == nil and waypoint.wp_type == "navaid") { + var found = 0; + for (index = 0; index < windSizes_copy[plan]; index += 1) { + #print(waypoint.id, " : ", winds_copy[plan][index].id); + if (waypoint.id == winds_copy[plan][index].id) { + append(me.winds[plan], winds_copy[plan][index]); + append(me.nav_indicies[plan], i); + me.windSizes[plan] += 1; + found = 1; + } + } + if (found != 1) { + append(me.winds[plan], waypoint_winds.new(waypoint.id, "waypoint", 0)); + me.windSizes[plan] += 1; + } + } else { + append(me.winds[plan], waypoint_winds.new(waypoint.id, "waypoint", 0)); + me.windSizes[plan] += 1; + } + #print("insert plan: ", plan, ", index: ", i); + #debug.dump(me.winds); + #debug.dump(me.nav_indicies); + #debug.dump(me.windSizes); + } + } + + if (canvas_mcdu.myCLBWIND[1] != nil) { + canvas_mcdu.myCLBWIND[1].reload(); + } + if (canvas_mcdu.myCLBWIND[0] != nil) { + canvas_mcdu.myCLBWIND[0].reload(); + } + if (canvas_mcdu.myCRZWIND[1] != nil) { + if (!fmgc.flightPlanController.temporaryFlag[1]) { + if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[2]) > 0) { + canvas_mcdu.myCRZWIND[1].waypoint = fmgc.flightPlanController.flightplans[2].getWP(me.nav_indicies[2][0]); + canvas_mcdu.myCRZWIND[1].singleCRZ = 0; + canvas_mcdu.myCRZWIND[1].cur_location = 0; + } else { + canvas_mcdu.myCRZWIND[1].waypoint = nil; + canvas_mcdu.myCRZWIND[1].singleCRZ = 1; + canvas_mcdu.myCRZWIND[1].cur_location = 0; + } + } else { + if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[1]) > 0) { + canvas_mcdu.myCRZWIND[1].waypoint = fmgc.flightPlanController.flightplans[1].getWP(me.nav_indicies[1][0]); + canvas_mcdu.myCRZWIND[1].singleCRZ = 0; + canvas_mcdu.myCRZWIND[1].cur_location = 0; + } else { + canvas_mcdu.myCRZWIND[1].waypoint = nil; + canvas_mcdu.myCRZWIND[1].singleCRZ = 1; + canvas_mcdu.myCRZWIND[1].cur_location = 0; + } + } + canvas_mcdu.myCRZWIND[1].reload(); + } + if (canvas_mcdu.myCRZWIND[0] != nil) { + if (!fmgc.flightPlanController.temporaryFlag[0]) { + if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[2]) > 0) { + canvas_mcdu.myCRZWIND[0].waypoint = fmgc.flightPlanController.flightplans[2].getWP(me.nav_indicies[2][0]); + canvas_mcdu.myCRZWIND[0].singleCRZ = 0; + canvas_mcdu.myCRZWIND[0].cur_location = 0; + } else { + canvas_mcdu.myCRZWIND[0].waypoint = nil; + canvas_mcdu.myCRZWIND[0].singleCRZ = 1; + canvas_mcdu.myCRZWIND[0].cur_location = 0; + } + } else { + if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[0]) > 0) { + canvas_mcdu.myCRZWIND[0].waypoint = fmgc.flightPlanController.flightplans[0].getWP(me.nav_indicies[0][0]); + canvas_mcdu.myCRZWIND[0].singleCRZ = 0; + canvas_mcdu.myCRZWIND[0].cur_location = 0; + } else { + canvas_mcdu.myCRZWIND[0].waypoint = nil; + canvas_mcdu.myCRZWIND[0].singleCRZ = 1; + canvas_mcdu.myCRZWIND[0].cur_location = 0; + } + } + canvas_mcdu.myCRZWIND[0].reload(); + } + if (canvas_mcdu.myDESWIND[1] != nil) { + canvas_mcdu.myDESWIND[1].reload(); + } + if (canvas_mcdu.myDESWIND[0] != nil) { + canvas_mcdu.myDESWIND[0].reload(); + } + if (canvas_mcdu.myHISTWIND[1] != nil) { + canvas_mcdu.myHISTWIND[1].reload(); + } + if (canvas_mcdu.myHISTWIND[0] != nil) { + canvas_mcdu.myHISTWIND[0].reload(); + } + } +}; diff --git a/Nasal/Libraries/libraries.nas b/Nasal/Libraries/libraries.nas index aa6f6f93..fcce0265 100644 --- a/Nasal/Libraries/libraries.nas +++ b/Nasal/Libraries/libraries.nas @@ -204,6 +204,7 @@ var systemsInit = func { systems.fire_init(); systems.icingInit(); fmgc.flightPlanController.reset(); + fmgc.windController.reset(); fadec.FADEC.init(); fmgc.ITAF.init(); fmgc.FMGCinit(); @@ -222,6 +223,7 @@ var systemsInit = func { fcu.FCUController.init(); dmc.DMController.init(); fmgc.flightPlanController.init(); + fmgc.windController.init(); } setlistener("/sim/signals/fdm-initialized", func { @@ -245,7 +247,7 @@ var systemsLoop = maketimer(0.1, func { systems.APUController.loop(); systems.HFLoop(); - if ((getprop("/controls/pneumatic/switches/groundair") or getprop("/controls/electrical/ground-cart")) and ((getprop("/velocities/groundspeed-kt") > 2) or (getprop("/controls/gear/brake-parking") == 0 and getprop("/services/chocks/nose") == 0 and getprop("/services/chocks/left") == 0 and getprop("/services/chocks/right") == 0))) { + if ((getprop("/controls/pneumatic/switches/groundair") or getprop("/controls/electrical/ground-cart")) and ((getprop("/velocities/groundspeed-kt") > 2) or (getprop("/controls/gear/brake-parking") == 0 and getprop("/services/chocks/enable") == 0))) { setprop("/controls/electrical/ground-cart", 0); setprop("/controls/pneumatic/switches/groundair", 0); } diff --git a/Nasal/MCDU/DATA2.nas b/Nasal/MCDU/DATA2.nas new file mode 100644 index 00000000..650f8bd7 --- /dev/null +++ b/Nasal/MCDU/DATA2.nas @@ -0,0 +1,15 @@ +# A3XX mCDU by Joshua Davidson (Octal450), Jonathan Redpath, and Matthew Maring (mattmaring) + +# Copyright (c) 2020 Matthew Maring (mattmaring) + +var data2Input = func(key, i) { + if (key == "L5") { + if (canvas_mcdu.myCLBWIND[i] == nil) { + canvas_mcdu.myCLBWIND[i] = windCLBPage.new(i); + } else { + canvas_mcdu.myCLBWIND[i].reload(); + } + fmgc.windController.accessPage[i] = "DATA2"; + setprop("MCDU[" ~ i ~ "]/page", "WINDCLB"); + } +} diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas index 468c6caf..90adf249 100644 --- a/Nasal/MCDU/F-PLN.nas +++ b/Nasal/MCDU/F-PLN.nas @@ -156,33 +156,73 @@ var fplnItem = { setprop("MCDU[" ~ me.computer ~ "]/page", "LATREV"); }, pushButtonRight: func() { - if (canvas_mcdu.myVertRev[me.computer] != nil) { - canvas_mcdu.myVertRev[me.computer].del(); - } - canvas_mcdu.myVertRev[me.computer] = nil; - - if (fmgc.flightPlanController.temporaryFlag[me.computer]) { - if (me.index == fmgc.flightPlanController.arrivalIndex[me.computer]) { - canvas_mcdu.myVertRev[me.computer] = vertRev.new(1, left(me.wp.wp_name, 4), me.index, me.computer); - } if (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[me.computer].departure.id) { - canvas_mcdu.myVertRev[me.computer] = vertRev.new(0, left(me.wp.wp_name, 4), me.index, me.computer); - } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1)) { - canvas_mcdu.myVertRev[me.computer] = vertRev.new(3, me.wp.wp_name, me.index, me.computer); + if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) == 0) { + if (canvas_mcdu.myVertRev[me.computer] != nil) { + canvas_mcdu.myVertRev[me.computer].del(); + } + canvas_mcdu.myVertRev[me.computer] = nil; + + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (me.index == fmgc.flightPlanController.arrivalIndex[me.computer]) { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(1, left(me.wp.wp_name, 4), me.index, me.computer, me.wp, me.plan); + } if (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[me.computer].departure.id) { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(0, left(me.wp.wp_name, 4), me.index, me.computer, me.wp, me.plan); + } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1)) { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(3, me.wp.wp_name, me.index, me.computer, me.wp, me.plan); + } else { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(2, me.wp.wp_name, me.index, me.computer, me.wp, me.plan); + } } else { - canvas_mcdu.myVertRev[me.computer] = vertRev.new(2, me.wp.wp_name, me.index, me.computer); + if (me.index == fmgc.flightPlanController.arrivalIndex[2]) { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(1, left(me.wp.wp_name, 4), me.index, me.computer, me.wp, me.plan); + } elsif (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[2].departure.id) { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(0, left(me.wp.wp_name, 4), me.index, me.computer, me.wp, me.plan); + } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1)) { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(3, me.wp.wp_name, me.index, me.computer, me.wp, me.plan); + } else { + canvas_mcdu.myVertRev[me.computer] = vertRev.new(2, me.wp.wp_name, me.index, me.computer, me.wp, me.plan); + } + } + setprop("MCDU[" ~ me.computer ~ "]/page", "VERTREV"); + } elsif (me.index != 0) { # todo - only apply to climb, descent, or missed waypoints + var scratchpadStore = mcdu_scratchpad.scratchpads[me.computer].scratchpad; + + if (scratchpadStore == "CLR") { + me.wp.setSpeed("delete"); + me.wp.setAltitude("delete"); + mcdu_scratchpad.scratchpads[me.computer].empty(); + } elsif (find("/", scratchpadStore) != -1) { + var scratchpadSplit = split("/", scratchpadStore); + + if (size(scratchpadSplit[0]) == 0) { + if (num(scratchpadSplit[1]) != nil and (size(scratchpadSplit[1]) == 4 or size(scratchpadSplit[1]) == 5) and scratchpadSplit[1] >= 0 and scratchpadSplit[1] <= 39000) { + me.wp.setAltitude(math.round(scratchpadSplit[1], 10), "at"); + mcdu_scratchpad.scratchpads[me.computer].empty(); + } else { + mcdu_message(me.computer, "FORMAT ERROR"); + } + } else { + if (num(scratchpadSplit[0]) != nil and size(scratchpadSplit[0]) == 3 and scratchpadSplit[0] >= 100 and scratchpadSplit[0] <= 350 and + num(scratchpadSplit[1]) != nil and (size(scratchpadSplit[1]) == 4 or size(scratchpadSplit[1]) == 5) and scratchpadSplit[1] >= 0 and scratchpadSplit[1] <= 39000) { + me.wp.setSpeed(scratchpadSplit[0], "at"); + me.wp.setAltitude(math.round(scratchpadSplit[1], 10), "at"); + mcdu_scratchpad.scratchpads[me.computer].empty(); + } elsif (num(scratchpadSplit[0]) != nil and size(scratchpadSplit[0]) == 3 and scratchpadSplit[0] >= 100 and scratchpadSplit[0] <= 350 and size(scratchpadSplit[1]) == 0) { + me.wp.setSpeed(scratchpadSplit[0], "at"); + mcdu_scratchpad.scratchpads[me.computer].empty(); + } else { + mcdu_message(me.computer, "FORMAT ERROR"); + } + } + } elsif (num(scratchpadStore) != nil and size(scratchpadStore) == 3 and scratchpadStore >= 100 and scratchpadStore <= 350) { + me.wp.setSpeed(scratchpadStore, "at"); + mcdu_scratchpad.scratchpads[me.computer].empty(); + } else { + mcdu_message(me.computer, "FORMAT ERROR"); } } else { - if (me.index == fmgc.flightPlanController.arrivalIndex[2]) { - canvas_mcdu.myVertRev[me.computer] = vertRev.new(1, left(me.wp.wp_name, 4), me.index, me.computer); - } elsif (left(me.wp.wp_name, 4) == fmgc.flightPlanController.flightplans[2].departure.id) { - canvas_mcdu.myVertRev[me.computer] = vertRev.new(0, left(me.wp.wp_name, 4), me.index, me.computer); - } elsif (me.index == (fmgc.flightPlanController.currentToWptIndex.getValue() - 1)) { - canvas_mcdu.myVertRev[me.computer] = vertRev.new(3, me.wp.wp_name, me.index, me.computer); - } else { - canvas_mcdu.myVertRev[me.computer] = vertRev.new(2, me.wp.wp_name, me.index, me.computer); - } + mcdu_message(me.computer, "NOT ALLOWED"); } - setprop("MCDU[" ~ me.computer ~ "]/page", "VERTREV"); }, }; @@ -446,11 +486,7 @@ var fplnPage = { # this one is only created once, and then updated - remember th } } else { if (size(me.outputList) >= index) { - if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) > 0) { - mcdu_message(me.computer, "NOT ALLOWED"); - } else { - me.outputList[index - 1].pushButtonRight(); - } + me.outputList[index - 1].pushButtonRight(); } else { mcdu_message(me.computer, "NOT ALLOWED"); } diff --git a/Nasal/MCDU/HOLD.nas b/Nasal/MCDU/HOLD.nas index b25be522..4b0399da 100644 --- a/Nasal/MCDU/HOLD.nas +++ b/Nasal/MCDU/HOLD.nas @@ -40,21 +40,42 @@ var holdPage = { _setupPageWithData: func() { me.title = ["HOLD", " AT ", me.waypoint.wp_name]; me.titleColour = "wht"; - me.L1 = [" [ ]", "INB CRS", "blu"]; - me.L2 = [" R", " TURN", "blu"]; - if (pts.Instrumentation.Altimeter.indicatedFt.getValue() >= 14000) { - me.L2 = [" 1.5/----", "TIME/DIST", "blu"]; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["wht", "wht", "ack", "ack", "ack", "ack"]]; + me.fontMatrix = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; + if (me.waypoint.fly_type == "Hold") { + me.makeTmpy(); + me.L1 = [" " ~ sprintf("%03.0f", me.waypoint.hold_inbound_radial), "INB CRS", "blu"]; + me.fontMatrix[0][0] = 0; + + if (me.waypoint.hold_is_left_handed) { + me.L2 = [" L", " TURN", "blu"]; + } else { + me.L2 = [" R", " TURN", "blu"]; + } + + if (me.waypoint.hold_is_distance) { + me.L2 = [" -.-/" ~ me.waypoint.hold_time_or_distance, "TIME/DIST", "blu"]; + } else { + me.L2 = [" " ~ sprintf("%3.1f", (me.waypoint.hold_time_or_distance / 60)) ~ "/----", "TIME/DIST", "blu"]; + } + me.R1 = ["COMPUTED ", nil, "wht"]; + me.R2 = ["DATABASE ", nil, "yel"]; + me.arrowsMatrix[1][1] = 0; } else { - me.L2 = [" 1.0/----", "TIME/DIST", "blu"]; + me.L1 = [" 100", "INB CRS", "blu"]; + me.L2 = [" R", " TURN", "blu"]; + if (pts.Instrumentation.Altimeter.indicatedFt.getValue() >= 14000) { + me.L2 = [" 1.5/----", "TIME/DIST", "blu"]; + } else { + me.L2 = [" 1.0/----", "TIME/DIST", "blu"]; + } + me.R1 = ["COMPUTED ", nil, "wht"]; + me.R2 = ["DATABASE ", nil, "wht"]; } me.L6 = [" RETURN", nil, "wht"]; me.C4 = ["LAST EXIT", nil, "wht"]; me.C5 = ["---- ---.-", "UTC FUEL", "wht"]; - me.R1 = ["COMPUTED ", nil, "wht"]; - me.R2 = ["DATABASE ", nil, "wht"]; - me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 0]]; - me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["wht", "wht", "ack", "ack", "ack", "ack"]]; - me.fontMatrix = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); }, makeTmpy: func() { @@ -67,7 +88,7 @@ var holdPage = { me.L1[2] = "yel"; me.L2[2] = "yel"; me.L6 = [" F-PLN", " TMPY", "yel"]; - me.R6 = ["INSERT* ", " TMPY", "yel"]; + me.R6 = ["INSERT ", " TMPY", "yel"]; me.arrowsColour[0][5] = "yel"; me.titleColour = "yel"; canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); diff --git a/Nasal/MCDU/INITA.nas b/Nasal/MCDU/INITA.nas index 2fb0d757..5a9fef65 100644 --- a/Nasal/MCDU/INITA.nas +++ b/Nasal/MCDU/INITA.nas @@ -9,6 +9,7 @@ var initInputA = func(key, i) { if (scratchpad == "CLR") { setprop("/FMGC/internal/alt-airport", ""); setprop("/FMGC/internal/alt-set", 0); + fmgc.windController.updatePlans(); if (getprop("/FMGC/internal/block-confirmed")) { setprop("/FMGC/internal/fuel-calculating", 0); setprop("/FMGC/internal/fuel-calculating", 1); @@ -24,6 +25,7 @@ var initInputA = func(key, i) { if (tfs == 4) { setprop("/FMGC/internal/alt-airport", scratchpad); setprop("/FMGC/internal/alt-set", 1); + fmgc.windController.updatePlans(); if (getprop("/FMGC/internal/block-confirmed")) { setprop("/FMGC/internal/fuel-calculating", 0); setprop("/FMGC/internal/fuel-calculating", 1); @@ -169,7 +171,9 @@ var initInputA = func(key, i) { setprop("/FMGC/internal/fuel-calculating", 1); } fmgc.flightPlanController.reset(2); + fmgc.windController.reset(2); fmgc.flightPlanController.init(); + fmgc.windController.init(); mcdu_scratchpad.scratchpads[i].empty(); #} else if (scratchpad == "") { #setprop("/FMGC/internal/alt-selected", 0); @@ -222,6 +226,14 @@ var initInputA = func(key, i) { } } else if (key == "R3") { setprop("MCDU[" ~ i ~ "]/page", "IRSINIT"); + } else if (key == "R4") { + if (canvas_mcdu.myCLBWIND[i] == nil) { + canvas_mcdu.myCLBWIND[i] = windCLBPage.new(i); + } else { + canvas_mcdu.myCLBWIND[i].reload(); + } + fmgc.windController.accessPage[i] = "INITA"; + setprop("MCDU[" ~ i ~ "]/page", "WINDCLB"); } else if (key == "R5") { if (scratchpad == "CLR") { setprop("/FMGC/internal/tropo", 36090); diff --git a/Nasal/MCDU/LATREV.nas b/Nasal/MCDU/LATREV.nas index f60900b6..0896a37a 100644 --- a/Nasal/MCDU/LATREV.nas +++ b/Nasal/MCDU/LATREV.nas @@ -1,5 +1,6 @@ var latRev = { title: [nil, nil, nil], + titleColour: "wht", subtitle: [nil, nil], fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], @@ -36,6 +37,7 @@ var latRev = { _checkTmpy: func() { if (fmgc.flightPlanController.temporaryFlag[me.computer]) { me.L6 = [" F-PLN", " TMPY", "yel"]; + me.titleColour = "yel"; me.arrowsColour[0][5] = "yel"; me.R2[2] = "yel"; me.R3[2] = "yel"; @@ -50,7 +52,7 @@ var latRev = { me.L3 = [" HOLD", nil, "wht"]; me.L6 = [" RETURN", nil, "wht"]; me.R1 = ["FIX INFO ", nil, "wht"]; - me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; + me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; me.arrowsMatrix = [[0, 1, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0]]; me.arrowsColour = [["ack", "wht", "wht", "ack", "ack", "wht"], ["wht", "ack", "ack", "ack", "ack", "ack"]]; me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0]]; @@ -75,7 +77,7 @@ var latRev = { me.L2 = [" OFFSET", nil, "wht"]; me.L6 = [" RETURN", nil, "wht"]; me.R1 = ["FIX INFO ", nil, "wht"]; - me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; + me.R2 = ["[ ]°/[ ]°/[ ]", "LL XING/INCR/NO", "blu"]; me.R3 = ["[ ]", "NEXT WPT ", "blu"]; me.R4 = ["[ ]", "NEW DEST", "blu"]; me.arrowsMatrix = [[1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]; diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 92334a6a..576b7a67 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -167,6 +167,8 @@ var MCDU_reset = func(i) { setprop("/FMGC/internal/dest-temp", -999); setprop("/FMGC/internal/dest-mag", -1); setprop("/FMGC/internal/dest-wind", -1); + # setprop("/FMGC/internal/dest-mag-grnd", -1); +# setprop("/FMGC/internal/dest-wind-grnd", -1); setprop("/FMGC/internal/vapp-speed-set", 0); setprop("/FMGC/internal/final", ""); setprop("/FMGC/internal/baro", 99999); @@ -207,6 +209,12 @@ var lskbutton = func(btn, i) { initInputIRS("L1",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { initInputB("L1",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + canvas_mcdu.myCLBWIND[i].pushButtonLeft(1); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCRZ") { + canvas_mcdu.myCRZWIND[i].pushButtonLeft(1); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { + canvas_mcdu.myDESWIND[i].pushButtonLeft(1); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PROGTO") { progTOInput("L1",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PROGCLB") { @@ -250,6 +258,12 @@ var lskbutton = func(btn, i) { } else if (btn == "2") { if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { initInputA("L2",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + canvas_mcdu.myCLBWIND[i].pushButtonLeft(2); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCRZ") { + canvas_mcdu.myCRZWIND[i].pushButtonLeft(2); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { + canvas_mcdu.myDESWIND[i].pushButtonLeft(2); } else if (getprop("MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("L2",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFAPPR") { @@ -288,6 +302,12 @@ var lskbutton = func(btn, i) { initInputB("L3",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "FUELPRED") { fuelPredInput("L3",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + canvas_mcdu.myCLBWIND[i].pushButtonLeft(3); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCRZ") { + canvas_mcdu.myCRZWIND[i].pushButtonLeft(3); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { + canvas_mcdu.myDESWIND[i].pushButtonLeft(3); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("L3",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFAPPR") { @@ -331,6 +351,12 @@ var lskbutton = func(btn, i) { initInputB("L4",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "FUELPRED") { fuelPredInput("L4",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + canvas_mcdu.myCLBWIND[i].pushButtonLeft(4); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCRZ") { + canvas_mcdu.myCRZWIND[i].pushButtonLeft(4); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { + canvas_mcdu.myDESWIND[i].pushButtonLeft(4); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("L4",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFAPPR") { @@ -359,6 +385,12 @@ var lskbutton = func(btn, i) { initInputB("L5",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "FUELPRED") { fuelPredInput("L5",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + canvas_mcdu.myCLBWIND[i].pushButtonLeft(5); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCRZ") { + canvas_mcdu.myCRZWIND[i].pushButtonLeft(5); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { + canvas_mcdu.myDESWIND[i].pushButtonLeft(5); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("L5",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFCLB") { @@ -379,12 +411,16 @@ var lskbutton = func(btn, i) { printInput2("L5",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA") { dataInput("L5",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DATA2") { + data2Input("L5",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { canvas_mcdu.myFpln[i].pushButtonLeft(5); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DEPARTURE") { canvas_mcdu.myDeparture[i].depPushbuttonLeft(5); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ARRIVAL") { canvas_mcdu.myArrival[i].arrPushbuttonLeft(5); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "VERTREV") { + canvas_mcdu.myVertRev[i].pushButtonLeft(5); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DIRTO") { canvas_mcdu.myDirTo[i].leftFieldBtn(5); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "DUPLICATENAMES") { @@ -404,6 +440,21 @@ var lskbutton = func(btn, i) { fuelPredInput("L6",i); } else if (getprop("MCDU[" ~ i ~ "]/page") == "IRSINIT") { initInputIRS("L6",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + canvas_mcdu.myCLBWIND[i].pushButtonLeft(6); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCRZ") { + canvas_mcdu.myCRZWIND[i].pushButtonLeft(6); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { + canvas_mcdu.myDESWIND[i].pushButtonLeft(6); + #} else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDHIST") { + # canvas_mcdu.myHISTWIND[i].pushButtonRight(6); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDHIST") { + if (canvas_mcdu.myCLBWIND[i] == nil) { + canvas_mcdu.myCLBWIND[i] = windCLBPage.new(i); + } else { + canvas_mcdu.myCLBWIND[i].reload(); + } + setprop("MCDU[" ~ i ~ "]/page", "WINDCLB"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "ROUTESELECTION") { initInputROUTESEL("L6",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFCLB") { @@ -448,6 +499,15 @@ var rskbutton = func(btn, i) { initInputIRS("R1",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { initInputB("R1",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + if (canvas_mcdu.myHISTWIND[i] == nil) { + canvas_mcdu.myHISTWIND[i] = windHISTPage.new(i); + } else { + canvas_mcdu.myHISTWIND[i].reload(); + } + setprop("MCDU[" ~ i ~ "]/page", "WINDHIST"); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { + canvas_mcdu.myDESWIND[i].pushButtonRight(1); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "RADNAV") { radnavInput("R1",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PRINTFUNC") { @@ -475,7 +535,7 @@ var rskbutton = func(btn, i) { } canvas_mcdu.myPilotWP[i] = nil; canvas_mcdu.myPilotWP[i] = pilotWaypointPage.new(i); - setprop("/MCDU[" ~ i ~ "]/page", "PILOTWP"); + setprop("/MCDU[" ~ i ~ "]/page", "PILOTWP"); } else { mcdu_message(i, "NOT ALLOWED"); # todo spawn new waypoints page } @@ -533,8 +593,48 @@ var rskbutton = func(btn, i) { mcdu_message(i, "NOT ALLOWED"); } } else if (btn == "4") { - if (getprop("/MCDU[" ~ i ~ "]/page") == "FUELPRED") { + if (getprop("/MCDU[" ~ i ~ "]/page") == "INITA") { + initInputA("R4",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "FUELPRED") { fuelPredInput("R4",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCRZ") { + if (canvas_mcdu.myCLBWIND[i] == nil) { + canvas_mcdu.myCLBWIND[i] = windCLBPage.new(i); + } else { + canvas_mcdu.myCLBWIND[i].reload(); + } + setprop("MCDU[" ~ i ~ "]/page", "WINDCLB"); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { + if (fmgc.flightPlanController.temporaryFlag[i]) { + if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[i]) > 0) { + if (canvas_mcdu.myCRZWIND[i] != nil) { + canvas_mcdu.myCRZWIND[i].del(); + } + canvas_mcdu.myCRZWIND[i] = nil; + canvas_mcdu.myCRZWIND[i] = windCRZPage.new(i, fmgc.flightPlanController.flightplans[i].getWP(fmgc.windController.nav_indicies[i][0]), 0); + } else { + if (canvas_mcdu.myCRZWIND[i] == nil) { + canvas_mcdu.myCRZWIND[i] = windCRZPage.new(i, nil, nil); + } else { + canvas_mcdu.myCRZWIND[i].reload(); + } + } + } else { + if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[2]) > 0) { + if (canvas_mcdu.myCRZWIND[i] != nil) { + canvas_mcdu.myCRZWIND[i].del(); + } + canvas_mcdu.myCRZWIND[i] = nil; + canvas_mcdu.myCRZWIND[i] = windCRZPage.new(i, fmgc.flightPlanController.flightplans[2].getWP(fmgc.windController.nav_indicies[2][0]), 0); + } else { + if (canvas_mcdu.myCRZWIND[i] == nil) { + canvas_mcdu.myCRZWIND[i] = windCRZPage.new(i, nil, nil); + } else { + canvas_mcdu.myCRZWIND[i].reload(); + } + } + } + setprop("MCDU[" ~ i ~ "]/page", "WINDCRZ"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("R4",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFAPPR") { @@ -557,6 +657,44 @@ var rskbutton = func(btn, i) { initInputA("R5",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "INITB") { initInputB("R5",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + if (fmgc.flightPlanController.temporaryFlag[i]) { + if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[i]) > 0) { + if (canvas_mcdu.myCRZWIND[i] != nil) { + canvas_mcdu.myCRZWIND[i].del(); + } + canvas_mcdu.myCRZWIND[i] = nil; + canvas_mcdu.myCRZWIND[i] = windCRZPage.new(i, fmgc.flightPlanController.flightplans[i].getWP(fmgc.windController.nav_indicies[i][0]), 0); + } else { + if (canvas_mcdu.myCRZWIND[i] == nil) { + canvas_mcdu.myCRZWIND[i] = windCRZPage.new(i, nil, nil); + } else { + canvas_mcdu.myCRZWIND[i].reload(); + } + } + } else { + if (getprop("/FMGC/internal/tofrom-set") and size(fmgc.windController.nav_indicies[2]) > 0) { + if (canvas_mcdu.myCRZWIND[i] != nil) { + canvas_mcdu.myCRZWIND[i].del(); + } + canvas_mcdu.myCRZWIND[i] = nil; + canvas_mcdu.myCRZWIND[i] = windCRZPage.new(i, fmgc.flightPlanController.flightplans[2].getWP(fmgc.windController.nav_indicies[2][0]), 0); + } else { + if (canvas_mcdu.myCRZWIND[i] == nil) { + canvas_mcdu.myCRZWIND[i] = windCRZPage.new(i, nil, nil); + } else { + canvas_mcdu.myCRZWIND[i].reload(); + } + } + } + setprop("MCDU[" ~ i ~ "]/page", "WINDCRZ"); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCRZ") { + if (canvas_mcdu.myDESWIND[i] == nil) { + canvas_mcdu.myDESWIND[i] = windDESPage.new(i, ""); + } else { + canvas_mcdu.myDESWIND[i].reload(); + } + setprop("MCDU[" ~ i ~ "]/page", "WINDDES"); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "STATUS") { statusInput("R5",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") { @@ -601,6 +739,14 @@ var rskbutton = func(btn, i) { initInputA("R6",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "IRSINIT") { initInputIRS("R6",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCLB") { + canvas_mcdu.myCLBWIND[i].pushButtonRight(6); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCRZ") { + canvas_mcdu.myCRZWIND[i].pushButtonRight(6); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDDES") { + canvas_mcdu.myDESWIND[i].pushButtonRight(6); + #} else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDHIST") { + # canvas_mcdu.myHISTWIND[i].pushButtonRight(6); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFTO") { perfTOInput("R6",i); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "PERFCLB") { @@ -697,6 +843,8 @@ var arrowbutton = func(btn, i) { canvas_mcdu.myDirTo[i].scrollUp(); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "IRSINIT") { initInputIRS("up",i); + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCRZ") { + canvas_mcdu.myCRZWIND[i].pushButtonUp(); } } else if (btn == "down") { if (getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNA" or getprop("/MCDU[" ~ i ~ "]/page") == "F-PLNB") { @@ -709,7 +857,9 @@ var arrowbutton = func(btn, i) { canvas_mcdu.myDirTo[i].scrollDn(); } else if (getprop("/MCDU[" ~ i ~ "]/page") == "IRSINIT") { initInputIRS("down",i); - } + } else if (getprop("/MCDU[" ~ i ~ "]/page") == "WINDCRZ") { + canvas_mcdu.myCRZWIND[i].pushButtonDown(); + } } } diff --git a/Nasal/MCDU/PERFAPPR.nas b/Nasal/MCDU/PERFAPPR.nas index 2e986681..a59aff03 100644 --- a/Nasal/MCDU/PERFAPPR.nas +++ b/Nasal/MCDU/PERFAPPR.nas @@ -35,12 +35,10 @@ var perfAPPRInput = func(key, 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]); var mags = size(weather[0]); - var wind = int(weather[1]); var winds = size(weather[1]); if (mags >= 1 and mags <= 3 and winds >= 1 and winds <= 3) { - if (mag != nil and wind != nil and mag >= 0 and mag <= 360 and wind >= 0 and wind <= 200) { + if (num(weather[0]) != nil and num(weather[1]) != nil and int(weather[0]) >= 0 and int(weather[0]) <= 360 and int(weather[1]) >= 0 and int(weather[1]) <= 200) { setprop("/FMGC/internal/dest-mag", weather[0]); setprop("/FMGC/internal/dest-wind", weather[1]); mcdu_scratchpad.scratchpads[i].empty(); diff --git a/Nasal/MCDU/VERTREV.nas b/Nasal/MCDU/VERTREV.nas index bc647651..86bd332b 100644 --- a/Nasal/MCDU/VERTREV.nas +++ b/Nasal/MCDU/VERTREV.nas @@ -20,12 +20,14 @@ var vertRev = { arrAirport: nil, index: nil, computer: nil, - new: func(type, id, index, computer) { + new: func(type, id, index, computer, wp, plan) { var vr = {parents:[vertRev]}; vr.type = type; # 0 = origin 1 = destination 2 = wpt not ppos 3 = ppos 4 = cruise wpt 5 = climb wpt (3 + 4 not needed yet) vr.id = id; vr.index = index; vr.computer = computer; + vr.wp = wp; + vr.plan = plan; vr._setupPageWithData(); vr._checkTmpy(); return vr; @@ -53,7 +55,7 @@ var vertRev = { me.arrowsMatrix = [[0, 0, 0, 1, 1, 1], [0, 1, 0, 0, 0, 0]]; me.arrowsColour = [["ack", "ack", "ack", "wht", "wht", "wht"], ["ack", "wht", "ack", "ack", "wht", "wht"]]; me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]; - } if (me.type == 2) { + } elsif (me.type == 2) { me.title = ["VERT REV", " AT ", me.id]; me.L1 = ["", " EFOB ---.-", "wht"]; me.R1 = ["", "EXTRA ---.- ", "wht"]; @@ -132,6 +134,52 @@ var vertRev = { me.arrowsMatrix[1][4] = 0; } }, + pushButtonLeft: func(index) { + if (index == 5) { + #print("role: ", me.wp.wp_role, ", type: ", me.wp.wp_type); + if (me.wp.wp_role == "sid") { + if (canvas_mcdu.myCLBWIND[me.computer] == nil) { + canvas_mcdu.myCLBWIND[me.computer] = windCLBPage.new(me.computer); + } else { + canvas_mcdu.myCLBWIND[me.computer].reload(); + } + fmgc.windController.accessPage[me.computer] = "VERTREV"; + setprop("MCDU[" ~ me.computer ~ "]/page", "WINDCLB"); + } else if (me.wp.wp_role == "star" or me.wp.wp_role == "approach" or me.wp.wp_role == "missed") { + if (canvas_mcdu.myDESWIND[me.computer] == nil) { + canvas_mcdu.myDESWIND[me.computer] = windDESPage.new(me.computer); + } else { + canvas_mcdu.myDESWIND[me.computer].reload(); + } + fmgc.windController.accessPage[me.computer] = "VERTREV"; + setprop("MCDU[" ~ me.computer ~ "]/page", "WINDDES"); + } else if (me.wp.wp_role == nil and me.wp.wp_type == "navaid") { + if (canvas_mcdu.myCRZWIND[me.computer] == nil) { + cur_location = 0; + for (i = 0; i < size(fmgc.windController.nav_indicies[me.plan]); i += 1) { + if (fmgc.windController.nav_indicies[me.plan][i] == me.index) { + cur_location = i; + } + } + canvas_mcdu.myCRZWIND[me.computer] = windCRZPage.new(me.computer, me.wp, cur_location); + } else { + canvas_mcdu.myCRZWIND[me.computer].reload(); + } + fmgc.windController.accessPage[me.computer] = "VERTREV"; + setprop("MCDU[" ~ me.computer ~ "]/page", "WINDCRZ"); + } else { + if (canvas_mcdu.myCRZWIND[me.computer] == nil) { + canvas_mcdu.myCRZWIND[me.computer] = windCRZPage.new(me.computer, nil, 0); + } else { + canvas_mcdu.myCRZWIND[me.computer].reload(); + } + fmgc.windController.accessPage[me.computer] = "VERTREV"; + setprop("MCDU[" ~ me.computer ~ "]/page", "WINDCRZ"); + } + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + }, }; setlistener("FMGC/internal/cruise-lvl-set", func() { diff --git a/Nasal/MCDU/WINDCLB.nas b/Nasal/MCDU/WINDCLB.nas new file mode 100644 index 00000000..e7619834 --- /dev/null +++ b/Nasal/MCDU/WINDCLB.nas @@ -0,0 +1,313 @@ +# A3XX mCDU by Joshua Davidson (Octal450), Jonathan Redpath, and Matthew Maring (mattmaring) + +# Copyright (c) 2020 Matthew Maring (mattmaring) + +var windCLBPage = { + title: nil, + titleColour: "wht", + fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]], + L1: [nil, nil, "ack"], # content, title, colour + L2: [nil, nil, "ack"], + L3: [nil, nil, "ack"], + L4: [nil, nil, "ack"], + L5: [nil, nil, "ack"], + L6: [nil, nil, "ack"], + C1: [nil, nil, "ack"], + C2: [nil, nil, "ack"], + C3: [nil, nil, "ack"], + C4: [nil, nil, "ack"], + C5: [nil, nil, "ack"], + C6: [nil, nil, "ack"], + R1: [nil, nil, "ack"], + R2: [nil, nil, "ack"], + R3: [nil, nil, "ack"], + R4: [nil, nil, "ack"], + R5: [nil, nil, "ack"], + R6: [nil, nil, "ack"], + scroll: 0, + vector: [], + index: nil, + computer: nil, + items: 0, + new: func(computer) { + var wcp = {parents:[windCLBPage]}; + wcp.computer = computer; + wcp._setupPageWithData(); + wcp.updateTmpy(); + return wcp; + }, + del: func() { + return nil; + }, + _setupPageWithData: func() { + me.title = "CLIMB WIND"; + me.titleColour = "wht"; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 1, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "ack"], ["wht", "ack", "ack", "ack", "wht", "ack"]]; + me.fontMatrix = [[1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]; + + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + + #debug.dump(fmgc.windController.clb_winds[0]); + #debug.dump(fmgc.windController.clb_winds[1]); + #debug.dump(fmgc.windController.clb_winds[2]); + + if (fmgc.windController.clb_winds[computer_temp] == 0 or fmgc.windController.clb_winds[computer_temp].wind1.altitude == "") { + me.items = 1; + } else if (fmgc.windController.clb_winds[computer_temp].wind2.altitude == "") { + me.items = 2; + } else if (fmgc.windController.clb_winds[computer_temp].wind3.altitude == "") { + me.items = 3; + } else if (fmgc.windController.clb_winds[computer_temp].wind4.altitude == "") { + me.items = 4; + } else { + me.items = 5; + } + + if (me.items >= 5) { + var windStore = fmgc.windController.clb_winds[computer_temp].wind5; + if (windStore.altitude != "") { + me.L5 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][4] = 1; + } else { + me.L5 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][4] = 1; + } + } else { + me.L5 = [nil, nil, "ack"]; + } + + if (me.items >= 4) { + var windStore = fmgc.windController.clb_winds[computer_temp].wind4; + if (windStore.altitude != "") { + me.L4 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][3] = 1; + } else { + me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][3] = 1; + } + } else { + me.L4 = [nil, nil, "ack"]; + } + + if (me.items >= 3) { + var windStore = fmgc.windController.clb_winds[computer_temp].wind3; + if (windStore.altitude != "") { + me.L3 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][2] = 1; + } else { + me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][2] = 1; + } + } else { + me.L3 = [nil, nil, "ack"]; + } + + if (me.items >= 2) { + var windStore = fmgc.windController.clb_winds[computer_temp].wind2; + if (windStore.altitude != "") { + me.L2 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][1] = 1; + } else { + me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][1] = 1; + } + } else { + me.L2 = [nil, nil, "ack"]; + } + + if (me.items >= 1) { + var windStore = fmgc.windController.clb_winds[computer_temp].wind1; + if (windStore.altitude != "") { + me.L1 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, "TRU WIND/ALT", "blu"]; + me.fontMatrix[0][0] = 1; + } else { + me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"]; + me.fontMatrix[0][0] = 1; + } + } + + me.L6 = [" RETURN", nil, "wht"]; + me.R1 = [" HISTORY ", "WIND ", "wht"]; + me.R3 = [" REQUEST ", "WIND ", "amb"]; + me.R5 = [" PHASE ", "NEXT ", "wht"]; + + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + makeTmpy: func() { + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); + } + }, + updateTmpy: func() { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + me.L1[2] = "yel"; + me.L2[2] = "yel"; + me.L3[2] = "yel"; + me.L4[2] = "yel"; + me.L5[2] = "yel"; + me.L6 = [" CANCEL", " WIND", "amb"]; + me.R6 = ["UPDATE ", "WIND ", "amb"]; + me.arrowsMatrix[0][5] = 0; + me.title = "DRAFT CLIMB WIND"; + me.titleColour = "yel"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } else { + me.L1[2] = "blu"; + me.L2[2] = "blu"; + me.L3[2] = "blu"; + me.L4[2] = "blu"; + me.L5[2] = "blu"; + me.L6 = [" RETURN", nil, "wht"]; + me.R6 = [nil, nil, "ack"]; + me.arrowsMatrix[0][5] = 1; + me.title = "CLIMB WIND"; + me.titleColour = "wht"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } + }, + reload: func() { + me._setupPageWithData(); + me.updateTmpy(); + }, + pushButtonLeft: func(index) { + if (index == 6 and fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (canvas_mcdu.myFpln[me.computer] != nil) { + canvas_mcdu.myFpln[me.computer].pushButtonLeft(index); + } else { + fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 0); + # push update to fuel + if (getprop("/FMGC/internal/block-confirmed")) { + setprop("/FMGC/internal/fuel-calculating", 0); + setprop("/FMGC/internal/fuel-calculating", 1); + } + } + me.reload(); + } else if (index == 6) { + setprop("/MCDU[" ~ me.computer ~ "]/page", fmgc.windController.accessPage[me.computer]); + } else if (me.items >= index) { + if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) >= 5 and size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) <= 13) { + var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad); + if (size(winds[0]) >= 1 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and + size(winds[1]) >= 1 and size(winds[1]) <= 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200 and + size(winds[2]) >= 4 and size(winds[2]) <= 5 and ((num(winds[2]) != nil and winds[2] >= 1000 and winds[2] <= 39000) or + (num(split("FL", winds[2])[1]) != nil and split("FL", winds[2])[1] >= 10 and split("FL", winds[2])[1] <= 390))) { + me.makeTmpy(); + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + #print(computer_temp); + if (index == 5) { + fmgc.windController.clb_winds[computer_temp].wind5.heading = winds[0]; + fmgc.windController.clb_winds[computer_temp].wind5.magnitude = winds[1]; + fmgc.windController.clb_winds[computer_temp].wind5.altitude = winds[2]; + } else if (index == 4) { + fmgc.windController.clb_winds[computer_temp].wind4.heading = winds[0]; + fmgc.windController.clb_winds[computer_temp].wind4.magnitude = winds[1]; + fmgc.windController.clb_winds[computer_temp].wind4.altitude = winds[2]; + } else if (index == 3) { + fmgc.windController.clb_winds[computer_temp].wind3.heading = winds[0]; + fmgc.windController.clb_winds[computer_temp].wind3.magnitude = winds[1]; + fmgc.windController.clb_winds[computer_temp].wind3.altitude = winds[2]; + } else if (index == 2) { + fmgc.windController.clb_winds[computer_temp].wind2.heading = winds[0]; + fmgc.windController.clb_winds[computer_temp].wind2.magnitude = winds[1]; + fmgc.windController.clb_winds[computer_temp].wind2.altitude = winds[2]; + } else if (index == 1) { + fmgc.windController.clb_winds[computer_temp].wind1.heading = winds[0]; + fmgc.windController.clb_winds[computer_temp].wind1.magnitude = winds[1]; + fmgc.windController.clb_winds[computer_temp].wind1.altitude = winds[2]; + } + mcdu_scratchpad.scratchpads[me.computer].empty(); + if (me.items == index and index != 5) { + me.items += 1; + } + me._setupPageWithData(); + me.updateTmpy(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } else if (mcdu_scratchpad.scratchpads[me.computer].scratchpad == "CLR") { + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + if (me.items == index) { + if (index == 5) { + fmgc.windController.clb_winds[computer_temp].wind5.heading = 0; + fmgc.windController.clb_winds[computer_temp].wind5.magnitude = 0; + fmgc.windController.clb_winds[computer_temp].wind5.altitude = ""; + } else if (index == 4) { + fmgc.windController.clb_winds[computer_temp].wind4.heading = 0; + fmgc.windController.clb_winds[computer_temp].wind4.magnitude = 0; + fmgc.windController.clb_winds[computer_temp].wind4.altitude = ""; + } else if (index == 3) { + fmgc.windController.clb_winds[computer_temp].wind3.heading = 0; + fmgc.windController.clb_winds[computer_temp].wind3.magnitude = 0; + fmgc.windController.clb_winds[computer_temp].wind3.altitude = ""; + } else if (index == 2) { + fmgc.windController.clb_winds[computer_temp].wind2.heading = 0; + fmgc.windController.clb_winds[computer_temp].wind2.magnitude = 0; + fmgc.windController.clb_winds[computer_temp].wind2.altitude = ""; + } else if (index == 1) { + fmgc.windController.clb_winds[computer_temp].wind1.heading = 0; + fmgc.windController.clb_winds[computer_temp].wind1.magnitude = 0; + fmgc.windController.clb_winds[computer_temp].wind1.altitude = ""; + } + } else { + if (index <= 1) { + fmgc.windController.clb_winds[computer_temp].wind1.heading = fmgc.windController.clb_winds[computer_temp].wind2.heading; + fmgc.windController.clb_winds[computer_temp].wind1.magnitude = fmgc.windController.clb_winds[computer_temp].wind2.magnitude; + fmgc.windController.clb_winds[computer_temp].wind1.altitude = fmgc.windController.clb_winds[computer_temp].wind2.altitude; + } + if (index <= 2) { + fmgc.windController.clb_winds[computer_temp].wind2.heading = fmgc.windController.clb_winds[computer_temp].wind3.heading; + fmgc.windController.clb_winds[computer_temp].wind2.magnitude = fmgc.windController.clb_winds[computer_temp].wind3.magnitude; + fmgc.windController.clb_winds[computer_temp].wind2.altitude = fmgc.windController.clb_winds[computer_temp].wind3.altitude; + } + if (index <= 3) { + fmgc.windController.clb_winds[computer_temp].wind3.heading = fmgc.windController.clb_winds[computer_temp].wind4.heading; + fmgc.windController.clb_winds[computer_temp].wind3.magnitude = fmgc.windController.clb_winds[computer_temp].wind4.magnitude; + fmgc.windController.clb_winds[computer_temp].wind3.altitude = fmgc.windController.clb_winds[computer_temp].wind4.altitude; + } + if (index <= 4) { + fmgc.windController.clb_winds[computer_temp].wind4.heading = fmgc.windController.clb_winds[computer_temp].wind5.heading; + fmgc.windController.clb_winds[computer_temp].wind4.magnitude = fmgc.windController.clb_winds[computer_temp].wind5.magnitude; + fmgc.windController.clb_winds[computer_temp].wind4.altitude = fmgc.windController.clb_winds[computer_temp].wind5.altitude; + } + } + mcdu_scratchpad.scratchpads[me.computer].empty(); + me.items -= 1; + me._setupPageWithData(); + me.updateTmpy(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + }, + pushButtonRight: func(index) { + if (index == 6 and fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (canvas_mcdu.myFpln[me.computer] != nil) { + canvas_mcdu.myFpln[me.computer].pushButtonRight(index); + } else { + fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 1); + # push update to fuel + if (getprop("/FMGC/internal/block-confirmed")) { + setprop("/FMGC/internal/fuel-calculating", 0); + setprop("/FMGC/internal/fuel-calculating", 1); + } + } + me.reload(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } +}; \ No newline at end of file diff --git a/Nasal/MCDU/WINDCRZ.nas b/Nasal/MCDU/WINDCRZ.nas new file mode 100644 index 00000000..f69d45cd --- /dev/null +++ b/Nasal/MCDU/WINDCRZ.nas @@ -0,0 +1,521 @@ +# A3XX mCDU by Joshua Davidson (Octal450), Jonathan Redpath, and Matthew Maring (mattmaring) + +# Copyright (c) 2020 Matthew Maring (mattmaring) + +var windCRZPage = { + title: [nil, nil, nil], + titleColour: "wht", + fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]], + L1: [nil, nil, "ack"], # content, title, colour + L2: [nil, nil, "ack"], + L3: [nil, nil, "ack"], + L4: [nil, nil, "ack"], + L5: [nil, nil, "ack"], + L6: [nil, nil, "ack"], + C1: [nil, nil, "ack"], + C2: [nil, nil, "ack"], + C3: [nil, nil, "ack"], + C4: [nil, nil, "ack"], + C5: [nil, nil, "ack"], + C6: [nil, nil, "ack"], + R1: [nil, nil, "ack"], + R2: [nil, nil, "ack"], + R3: [nil, nil, "ack"], + R4: [nil, nil, "ack"], + R5: [nil, nil, "ack"], + R6: [nil, nil, "ack"], + scroll: 0, + vector: [], + index: nil, + computer: nil, + cur_location: 0, + match_location: 0, + items: 0, + singleCRZ: 0, + new: func(computer, waypoint, cur_location) { + var wcp = {parents:[windCRZPage]}; + wcp.computer = computer; + wcp.waypoint = waypoint; + wcp.cur_location = cur_location; + if (waypoint == nil) { + wcp.singleCRZ = 1; + } + wcp._setupPageWithData(); + wcp.updateTmpy(); + return wcp; + }, + del: func() { + return nil; + }, + _setupPageWithData: func() { + + if (me.singleCRZ == 1) { + me.title = ["","CRZ WIND",""]; + } else { + me.title = ["CRZ WIND", " AT ", me.waypoint.wp_name]; + } + me.titleColour = "wht"; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 1, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "wht", "wht", "ack"]]; + me.fontMatrix = [[1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]; + + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + + #debug.dump(fmgc.windController.crz_winds[0]); + #debug.dump(fmgc.windController.crz_winds[1]); + #debug.dump(fmgc.windController.crz_winds[2]); + + if (me.singleCRZ == 1) { + if (fmgc.windController.crz_winds[computer_temp] == 0 or fmgc.windController.crz_winds[computer_temp].wind1.altitude == "") { + me.items = 1; + } else if (fmgc.windController.crz_winds[computer_temp].wind2.altitude == "") { + me.items = 2; + } else if (fmgc.windController.crz_winds[computer_temp].wind3.altitude == "") { + me.items = 3; + } else { + me.items = 4; + } + } else { + me.match_location = fmgc.windController.nav_indicies[computer_temp][me.cur_location]; + if (size(fmgc.windController.winds[computer_temp]) == 0 or fmgc.windController.winds[computer_temp][me.match_location].wind1.altitude == "") { + me.items = 1; + } else if (fmgc.windController.winds[computer_temp][me.match_location].wind2.altitude == "") { + me.items = 2; + } else if (fmgc.windController.winds[computer_temp][me.match_location].wind3.altitude == "") { + me.items = 3; + } else { + me.items = 4; + } + } + + # load data + if (me.singleCRZ == 1) { + if (me.items >= 4) { + var windStore = fmgc.windController.crz_winds[computer_temp].wind4; + if (windStore.altitude != "") { + me.L4 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][3] = 1; + } else { + me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][3] = 1; + } + } else { + me.L4 = [nil, nil, "ack"]; + } + + if (me.items >= 3) { + var windStore = fmgc.windController.crz_winds[computer_temp].wind3; + if (windStore.altitude != "") { + me.L3 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][2] = 1; + } else { + me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][2] = 1; + } + } else { + me.L3 = [nil, nil, "ack"]; + } + + if (me.items >= 2) { + var windStore = fmgc.windController.crz_winds[computer_temp].wind2; + if (windStore.altitude != "") { + me.L2 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][1] = 1; + } else { + me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][1] = 1; + } + } else { + me.L2 = [nil, nil, "ack"]; + } + + if (me.items >= 1) { + var windStore = fmgc.windController.crz_winds[computer_temp].wind1; + if (windStore.altitude != "") { + me.L1 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, "TRU WIND/ALT", "blu"]; + me.fontMatrix[0][0] = 1; + } else { + me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"]; + me.fontMatrix[0][0] = 1; + } + } + + var windStore = fmgc.windController.crz_winds[computer_temp].sat1; + if (windStore.altitude != "") { + me.L5 = [windStore.temp ~ "/" ~ windStore.altitude, "SAT / ALT", "blu"]; + me.fontMatrix[0][4] = 1; + } else { + me.L5 = ["[ ]/[ ]", "SAT / ALT", "blu"]; + me.fontMatrix[0][4] = 1; + } + } else { + if (me.items >= 4) { + var windStore = fmgc.windController.winds[computer_temp][me.match_location].wind4; + if (windStore.altitude != "") { + me.L4 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][3] = 1; + } else { + me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][3] = 1; + } + } else { + me.L4 = [nil, nil, "ack"]; + } + + if (me.items >= 3) { + var windStore = fmgc.windController.winds[computer_temp][me.match_location].wind3; + if (windStore.altitude != "") { + me.L3 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][2] = 1; + } else { + me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][2] = 1; + } + } else { + me.L3 = [nil, nil, "ack"]; + } + + if (me.items >= 2) { + var windStore = fmgc.windController.winds[computer_temp][me.match_location].wind2; + if (windStore.altitude != "") { + me.L2 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][1] = 1; + } else { + me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][1] = 1; + } + } else { + me.L2 = [nil, nil, "ack"]; + } + + if (me.items >= 1) { + var windStore = fmgc.windController.winds[computer_temp][me.match_location].wind1; + if (windStore.altitude != "") { + me.L1 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, "TRU WIND/ALT", "blu"]; + me.fontMatrix[0][0] = 1; + } else { + me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"]; + me.fontMatrix[0][0] = 1; + } + } + + var windStore = fmgc.windController.winds[computer_temp][me.match_location].sat1; + if (windStore.altitude != "") { + me.L5 = [windStore.temp ~ "/" ~ windStore.altitude, "SAT / ALT", "blu"]; + me.fontMatrix[0][4] = 1; + } else { + me.L5 = ["[ ]/[ ]", "SAT / ALT", "blu"]; + me.fontMatrix[0][4] = 1; + } + } + + me.L6 = [" RETURN", nil, "wht"]; + me.R2 = [" REQUEST ", "WIND ", "amb"]; + me.R4 = [" PHASE ", "PREV ", "wht"]; + me.R5 = [" PHASE ", "NEXT ", "wht"]; + + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + makeTmpy: func() { + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); + } + }, + updateTmpy: func() { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + me.L1[2] = "yel"; + me.L2[2] = "yel"; + me.L3[2] = "yel"; + me.L4[2] = "yel"; + me.L5[2] = "yel"; + me.L6 = [" CANCEL", "UPDATE", "amb"]; + me.R6 = ["INSERT ", "UPDATE ", "amb"]; + me.arrowsMatrix[0][5] = 0; + if (me.singleCRZ == 1) { + me.title = ["","DRAFT CRZ WIND",""]; + } else { + me.title = ["DRAFT CRZ WIND", " AT ", me.waypoint.wp_name]; + } + me.titleColour = "yel"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } else { + me.L1[2] = "blu"; + me.L2[2] = "blu"; + me.L3[2] = "blu"; + me.L4[2] = "blu"; + me.L5[2] = "blu"; + me.L6 = [" RETURN", nil, "wht"]; + me.R6 = [nil, nil, "ack"]; + me.arrowsMatrix[0][5] = 1; + if (me.singleCRZ == 1) { + me.title = ["","CRZ WIND",""]; + } else { + me.title = ["CRZ WIND", " AT ", me.waypoint.wp_name]; + } + me.titleColour = "wht"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } + }, + reload: func() { + me._setupPageWithData(); + me.updateTmpy(); + }, + pushButtonLeft: func(index) { + if (index == 6 and fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (canvas_mcdu.myFpln[me.computer] != nil) { + canvas_mcdu.myFpln[me.computer].pushButtonLeft(index); + } else { + fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 0); + # push update to fuel + if (getprop("/FMGC/internal/block-confirmed")) { + setprop("/FMGC/internal/fuel-calculating", 0); + setprop("/FMGC/internal/fuel-calculating", 1); + } + } + me.reload(); + } else if (index == 6) { + setprop("/MCDU[" ~ me.computer ~ "]/page", fmgc.windController.accessPage[me.computer]); + } else if (index == 5) { + if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) >= 6 and size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) <= 9) { + var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad); + if (size(winds[0]) >= 1 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= -99 and winds[0] <= 99 and + size(winds[1]) >= 4 and size(winds[1]) <= 5 and ((num(winds[1]) != nil and winds[1] >= 1000 and winds[1] <= 39000) or + (num(split("FL", winds[1])[1]) != nil and split("FL", winds[1])[1] >= 10 and split("FL", winds[1])[1] <= 390))) { + me.makeTmpy(); + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + #print(computer_temp); + if (me.singleCRZ == 1) { + fmgc.windController.crz_winds[computer_temp].sat1.temp = winds[0]; + fmgc.windController.crz_winds[computer_temp].sat1.altitude = winds[1]; + } else { + fmgc.windController.winds[computer_temp][me.match_location].sat1.temp = winds[0]; + fmgc.windController.winds[computer_temp][me.match_location].sat1.altitude = winds[1]; + } + mcdu_scratchpad.scratchpads[me.computer].empty(); + me._setupPageWithData(); + me.updateTmpy(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } else if (mcdu_scratchpad.scratchpads[me.computer].scratchpad == "CLR") { + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + #print(computer_temp); + if (me.singleCRZ == 1) { + fmgc.windController.crz_winds[computer_temp].sat1.temp = 0; + fmgc.windController.crz_winds[computer_temp].sat1.altitude = ""; + } else { + fmgc.windController.winds[computer_temp][me.match_location].sat1.temp = 0; + fmgc.windController.winds[computer_temp][me.match_location].sat1.altitude = ""; + } + mcdu_scratchpad.scratchpads[me.computer].empty(); + me._setupPageWithData(); + me.updateTmpy(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } else if (me.items >= index) { + if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) >= 5 and size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) <= 13) { + var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad); + if (size(winds[0]) >= 1 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and + size(winds[1]) >= 1 and size(winds[1]) <= 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200 and + size(winds[2]) >= 4 and size(winds[2]) <= 5 and ((num(winds[2]) != nil and winds[2] >= 1000 and winds[2] <= 39000) or + (num(split("FL", winds[2])[1]) != nil and split("FL", winds[2])[1] >= 10 and split("FL", winds[2])[1] <= 390))) { + me.makeTmpy(); + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + #print(computer_temp); + if (me.singleCRZ == 1) { + if (index == 4) { + fmgc.windController.crz_winds[computer_temp].wind4.heading = winds[0]; + fmgc.windController.crz_winds[computer_temp].wind4.magnitude = winds[1]; + fmgc.windController.crz_winds[computer_temp].wind4.altitude = winds[2]; + } else if (index == 3) { + fmgc.windController.crz_winds[computer_temp].wind3.heading = winds[0]; + fmgc.windController.crz_winds[computer_temp].wind3.magnitude = winds[1]; + fmgc.windController.crz_winds[computer_temp].wind3.altitude = winds[2]; + } else if (index == 2) { + fmgc.windController.crz_winds[computer_temp].wind2.heading = winds[0]; + fmgc.windController.crz_winds[computer_temp].wind2.magnitude = winds[1]; + fmgc.windController.crz_winds[computer_temp].wind2.altitude = winds[2]; + } else if (index == 1) { + fmgc.windController.crz_winds[computer_temp].wind1.heading = winds[0]; + fmgc.windController.crz_winds[computer_temp].wind1.magnitude = winds[1]; + fmgc.windController.crz_winds[computer_temp].wind1.altitude = winds[2]; + } + } else { + if (index == 4) { + fmgc.windController.winds[computer_temp][me.match_location].wind4.heading = winds[0]; + fmgc.windController.winds[computer_temp][me.match_location].wind4.magnitude = winds[1]; + fmgc.windController.winds[computer_temp][me.match_location].wind4.altitude = winds[2]; + } else if (index == 3) { + fmgc.windController.winds[computer_temp][me.match_location].wind3.heading = winds[0]; + fmgc.windController.winds[computer_temp][me.match_location].wind3.magnitude = winds[1]; + fmgc.windController.winds[computer_temp][me.match_location].wind3.altitude = winds[2]; + } else if (index == 2) { + fmgc.windController.winds[computer_temp][me.match_location].wind2.heading = winds[0]; + fmgc.windController.winds[computer_temp][me.match_location].wind2.magnitude = winds[1]; + fmgc.windController.winds[computer_temp][me.match_location].wind2.altitude = winds[2]; + } else if (index == 1) { + fmgc.windController.winds[computer_temp][me.match_location].wind1.heading = winds[0]; + fmgc.windController.winds[computer_temp][me.match_location].wind1.magnitude = winds[1]; + fmgc.windController.winds[computer_temp][me.match_location].wind1.altitude = winds[2]; + } + } + mcdu_scratchpad.scratchpads[me.computer].empty(); + if (me.items == index and index != 4) { + me.items += 1; + } + me._setupPageWithData(); + me.updateTmpy(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } else if (mcdu_scratchpad.scratchpads[me.computer].scratchpad == "CLR") { + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + #print(computer_temp); + if (me.singleCRZ == 1) { + if (me.items == index) { + if (index == 4) { + fmgc.windController.crz_winds[computer_temp].wind4.heading = 0; + fmgc.windController.crz_winds[computer_temp].wind4.magnitude = 0; + fmgc.windController.crz_winds[computer_temp].wind4.altitude = ""; + } else if (index == 3) { + fmgc.windController.crz_winds[computer_temp].wind3.heading = 0; + fmgc.windController.crz_winds[computer_temp].wind3.magnitude = 0; + fmgc.windController.crz_winds[computer_temp].wind3.altitude = ""; + } else if (index == 2) { + fmgc.windController.crz_winds[computer_temp].wind2.heading = 0; + fmgc.windController.crz_winds[computer_temp].wind2.magnitude = 0; + fmgc.windController.crz_winds[computer_temp].wind2.altitude = ""; + } else if (index == 1) { + fmgc.windController.crz_winds[computer_temp].wind1.heading = 0; + fmgc.windController.crz_winds[computer_temp].wind1.magnitude = 0; + fmgc.windController.crz_winds[computer_temp].wind1.altitude = ""; + } + } else { + if (index <= 1) { + fmgc.windController.crz_winds[computer_temp].wind1.heading = fmgc.windController.crz_winds[computer_temp].wind2.heading; + fmgc.windController.crz_winds[computer_temp].wind1.magnitude = fmgc.windController.crz_winds[computer_temp].wind2.magnitude; + fmgc.windController.crz_winds[computer_temp].wind1.altitude = fmgc.windController.crz_winds[computer_temp].wind2.altitude; + } + if (index <= 2) { + fmgc.windController.crz_winds[computer_temp].wind2.heading = fmgc.windController.crz_winds[computer_temp].wind3.heading; + fmgc.windController.crz_winds[computer_temp].wind2.magnitude = fmgc.windController.crz_winds[computer_temp].wind3.magnitude; + fmgc.windController.crz_winds[computer_temp].wind2.altitude = fmgc.windController.crz_winds[computer_temp].wind3.altitude; + } + if (index <= 3) { + fmgc.windController.crz_winds[computer_temp].wind3.heading = fmgc.windController.crz_winds[computer_temp].wind4.heading; + fmgc.windController.crz_winds[computer_temp].wind3.magnitude = fmgc.windController.crz_winds[computer_temp].wind4.magnitude; + fmgc.windController.crz_winds[computer_temp].wind3.altitude = fmgc.windController.crz_winds[computer_temp].wind4.altitude; + } + } + } else { + if (me.items == index) { + if (index == 4) { + fmgc.windController.winds[computer_temp][me.match_location].wind4.heading = 0; + fmgc.windController.winds[computer_temp][me.match_location].wind4.magnitude = 0; + fmgc.windController.winds[computer_temp][me.match_location].wind4.altitude = ""; + } else if (index == 3) { + fmgc.windController.winds[computer_temp][me.match_location].wind3.heading = 0; + fmgc.windController.winds[computer_temp][me.match_location].wind3.magnitude = 0; + fmgc.windController.winds[computer_temp][me.match_location].wind3.altitude = ""; + } else if (index == 2) { + fmgc.windController.winds[computer_temp][me.match_location].wind2.heading = 0; + fmgc.windController.winds[computer_temp][me.match_location].wind2.magnitude = 0; + fmgc.windController.winds[computer_temp][me.match_location].wind2.altitude = ""; + } else if (index == 1) { + fmgc.windController.winds[computer_temp][me.match_location].wind1.heading = 0; + fmgc.windController.winds[computer_temp][me.match_location].wind1.magnitude = 0; + fmgc.windController.winds[computer_temp][me.match_location].wind1.altitude = ""; + } + } else { + if (index <= 1) { + fmgc.windController.winds[computer_temp][me.match_location].wind1.heading = fmgc.windController.winds[computer_temp][me.match_location].wind2.heading; + fmgc.windController.winds[computer_temp][me.match_location].wind1.magnitude = fmgc.windController.winds[computer_temp][me.match_location].wind2.magnitude; + fmgc.windController.winds[computer_temp][me.match_location].wind1.altitude = fmgc.windController.winds[computer_temp][me.match_location].wind2.altitude; + } + if (index <= 2) { + fmgc.windController.winds[computer_temp][me.match_location].wind2.heading = fmgc.windController.winds[computer_temp][me.match_location].wind3.heading; + fmgc.windController.winds[computer_temp][me.match_location].wind2.magnitude = fmgc.windController.winds[computer_temp][me.match_location].wind3.magnitude; + fmgc.windController.winds[computer_temp][me.match_location].wind2.altitude = fmgc.windController.winds[computer_temp][me.match_location].wind3.altitude; + } + if (index <= 3) { + fmgc.windController.winds[computer_temp][me.match_location].wind3.heading = fmgc.windController.winds[computer_temp][me.match_location].wind4.heading; + fmgc.windController.winds[computer_temp][me.match_location].wind3.magnitude = fmgc.windController.winds[computer_temp][me.match_location].wind4.magnitude; + fmgc.windController.winds[computer_temp][me.match_location].wind3.altitude = fmgc.windController.winds[computer_temp][me.match_location].wind4.altitude; + } + } + } + mcdu_scratchpad.scratchpads[me.computer].empty(); + me.items -= 1; + me._setupPageWithData(); + me.updateTmpy(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + }, + pushButtonRight: func(index) { + if (index == 6 and fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (canvas_mcdu.myFpln[me.computer] != nil) { + canvas_mcdu.myFpln[me.computer].pushButtonRight(index); + } else { + fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 1); + # push update to fuel + if (getprop("/FMGC/internal/block-confirmed")) { + setprop("/FMGC/internal/fuel-calculating", 0); + setprop("/FMGC/internal/fuel-calculating", 1); + } + } + me.reload(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + }, + pushButtonUp: func() { + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + if (me.cur_location < size(fmgc.windController.nav_indicies[computer_temp]) - 1) { + me.cur_location = me.cur_location + 1; + } else { + me.cur_location = 0; + } + me.match_location = fmgc.windController.nav_indicies[computer_temp][me.cur_location]; + me.waypoint = fmgc.flightPlanController.flightplans[computer_temp].getWP(me.match_location); + me.reload(); + }, + pushButtonDown: func() { + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + if (me.cur_location > 0) { + me.cur_location = me.cur_location - 1; + } else { + me.cur_location = size(fmgc.windController.nav_indicies[computer_temp]) - 1; + } + me.match_location = fmgc.windController.nav_indicies[computer_temp][me.cur_location]; + me.waypoint = fmgc.flightPlanController.flightplans[computer_temp].getWP(me.match_location); + me.reload(); + } +}; \ No newline at end of file diff --git a/Nasal/MCDU/WINDDES.nas b/Nasal/MCDU/WINDDES.nas new file mode 100644 index 00000000..b2f14947 --- /dev/null +++ b/Nasal/MCDU/WINDDES.nas @@ -0,0 +1,365 @@ +# A3XX mCDU by Joshua Davidson (Octal450), Jonathan Redpath, and Matthew Maring (mattmaring) + +# Copyright (c) 2020 Matthew Maring (mattmaring) + +var windDESPage = { + title: nil, + titleColour: "wht", + fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]], + L1: [nil, nil, "ack"], # content, title, colour + L2: [nil, nil, "ack"], + L3: [nil, nil, "ack"], + L4: [nil, nil, "ack"], + L5: [nil, nil, "ack"], + L6: [nil, nil, "ack"], + C1: [nil, nil, "ack"], + C2: [nil, nil, "ack"], + C3: [nil, nil, "ack"], + C4: [nil, nil, "ack"], + C5: [nil, nil, "ack"], + C6: [nil, nil, "ack"], + R1: [nil, nil, "ack"], + R2: [nil, nil, "ack"], + R3: [nil, nil, "ack"], + R4: [nil, nil, "ack"], + R5: [nil, nil, "ack"], + R6: [nil, nil, "ack"], + scroll: 0, + vector: [], + index: nil, + computer: nil, + items: 0, + new: func(computer) { + var wdp = {parents:[windDESPage]}; + wdp.computer = computer; + wdp._setupPageWithData(); + wdp.updateTmpy(); + return wdp; + }, + del: func() { + return nil; + }, + _setupPageWithData: func() { + me.title = "DES WIND"; + #me.title = ["DES WIND", " AT ", me.waypoint.wp_name]; + me.titleColour = "wht"; + me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "wht", "ack", "ack"]]; + me.fontMatrix = [[1, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 0]]; + + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + + # debug.dump(fmgc.windController.des_winds[0]); +# debug.dump(fmgc.windController.des_winds[1]); +# debug.dump(fmgc.windController.des_winds[2]); + + if (fmgc.windController.des_winds[computer_temp] == 0 or fmgc.windController.des_winds[computer_temp].wind1.altitude == "") { + me.items = 1; + } else if (fmgc.windController.des_winds[computer_temp].wind2.altitude == "") { + me.items = 2; + } else if (fmgc.windController.des_winds[computer_temp].wind3.altitude == "") { + me.items = 3; + } else if (fmgc.windController.des_winds[computer_temp].wind4.altitude == "") { + me.items = 4; + } else { + me.items = 5; + } + + if (me.items >= 5) { + var windStore = fmgc.windController.des_winds[computer_temp].wind5; + if (windStore.altitude != "") { + me.L5 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][4] = 1; + } else { + me.L5 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][4] = 1; + } + } else { + me.L5 = [nil, nil, "ack"]; + } + + if (me.items >= 4) { + var windStore = fmgc.windController.des_winds[computer_temp].wind4; + if (windStore.altitude != "") { + me.L4 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][3] = 1; + } else { + me.L4 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][3] = 1; + } + } else { + me.L4 = [nil, nil, "ack"]; + } + + if (me.items >= 3) { + var windStore = fmgc.windController.des_winds[computer_temp].wind3; + if (windStore.altitude != "") { + me.L3 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][2] = 1; + } else { + me.L3 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][2] = 1; + } + } else { + me.L3 = [nil, nil, "ack"]; + } + + if (me.items >= 2) { + var windStore = fmgc.windController.des_winds[computer_temp].wind2; + if (windStore.altitude != "") { + me.L2 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, nil, "blu"]; + me.fontMatrix[0][1] = 1; + } else { + me.L2 = ["[ ]/[ ]/[ ]", nil, "blu"]; + me.fontMatrix[0][1] = 1; + } + } else { + me.L2 = [nil, nil, "ack"]; + } + + if (me.items >= 1) { + var windStore = fmgc.windController.des_winds[computer_temp].wind1; + if (windStore.altitude != "") { + me.L1 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude) ~ "/" ~ windStore.altitude, "TRU WIND/ALT", "blu"]; + me.fontMatrix[0][0] = 1; + } else { + me.L1 = ["[ ]/[ ]/[ ]", "TRU WIND/ALT", "blu"]; + me.fontMatrix[0][0] = 1; + } + } + + me.L6 = [" RETURN", nil, "wht"]; + + if (getprop("/FMGC/internal/alt-set")) { + var windStore = fmgc.windController.des_winds[computer_temp].alt1; + if (windStore.heading != 0 and windStore.magnitude != 0) { + me.R1 = [sprintf("%03.0f", windStore.heading) ~ "°/" ~ sprintf("%03.0f", windStore.magnitude), "ALTN WIND ", "blu"]; + me.fontMatrix[1][0] = 1; + } else { + me.R1 = ["[ ]/[ ]", "ALTN WIND ", "blu"]; + me.fontMatrix[1][0] = 1; + } + } else { + me.R1 = ["", "", "blu"]; + } + + me.R3 = [" REQUEST ", "WIND ", "amb"]; + me.R4 = [" PHASE ", "PREV ", "wht"]; + + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + makeTmpy: func() { + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); + } + }, + updateTmpy: func() { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + me.L1[2] = "yel"; + me.L2[2] = "yel"; + me.L3[2] = "yel"; + me.L4[2] = "yel"; + me.L5[2] = "yel"; + me.R1[2] = "yel"; + me.L6 = [" CANCEL", " WIND", "amb"]; + me.R6 = ["UPDATE ", "WIND ", "amb"]; + me.arrowsMatrix[0][5] = 0; + me.title = "DRAFT DES WIND"; + me.titleColour = "yel"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } else { + me.L1[2] = "blu"; + me.L2[2] = "blu"; + me.L3[2] = "blu"; + me.L4[2] = "blu"; + me.L5[2] = "blu"; + me.R1[2] = "blu"; + me.L6 = [" RETURN", nil, "wht"]; + me.R6 = [nil, nil, "ack"]; + me.arrowsMatrix[0][5] = 1; + me.title = "DES WIND"; + me.titleColour = "wht"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } + }, + reload: func() { + me._setupPageWithData(); + me.updateTmpy(); + }, + pushButtonLeft: func(index) { + if (index == 6 and fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (canvas_mcdu.myFpln[me.computer] != nil) { + canvas_mcdu.myFpln[me.computer].pushButtonLeft(index); + } else { + fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 0); + # push update to fuel + if (getprop("/FMGC/internal/block-confirmed")) { + setprop("/FMGC/internal/fuel-calculating", 0); + setprop("/FMGC/internal/fuel-calculating", 1); + } + } + me.reload(); + } else if (index == 6) { + setprop("/MCDU[" ~ me.computer ~ "]/page", fmgc.windController.accessPage[me.computer]); + } else if (me.items >= index) { + if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) >= 5 and size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) <= 13) { + var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad); + if (size(winds[0]) >= 0 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and + size(winds[1]) >= 0 and size(winds[1]) <= 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200 and + size(winds[2]) >= 4 and size(winds[2]) <= 5 and (winds[2] == "GRND" or (num(winds[2]) != nil and winds[2] >= 1000 and winds[2] <= 39000) or + (num(split("FL", winds[2])[1]) != nil and split("FL", winds[2])[1] >= 10 and split("FL", winds[2])[1] <= 390))) { + me.makeTmpy(); + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + # if (winds[2] == "GRND") { +# setprop("/FMGC/internal/dest-mag-grnd", winds[0]); +# setprop("/FMGC/internal/dest-wind-grnd", winds[1]); +# } + #print(computer_temp); + if (index == 5) { + fmgc.windController.des_winds[computer_temp].wind5.heading = winds[0]; + fmgc.windController.des_winds[computer_temp].wind5.magnitude = winds[1]; + fmgc.windController.des_winds[computer_temp].wind5.altitude = winds[2]; + } else if (index == 4) { + fmgc.windController.des_winds[computer_temp].wind4.heading = winds[0]; + fmgc.windController.des_winds[computer_temp].wind4.magnitude = winds[1]; + fmgc.windController.des_winds[computer_temp].wind4.altitude = winds[2]; + } else if (index == 3) { + fmgc.windController.des_winds[computer_temp].wind3.heading = winds[0]; + fmgc.windController.des_winds[computer_temp].wind3.magnitude = winds[1]; + fmgc.windController.des_winds[computer_temp].wind3.altitude = winds[2]; + } else if (index == 2) { + fmgc.windController.des_winds[computer_temp].wind2.heading = winds[0]; + fmgc.windController.des_winds[computer_temp].wind2.magnitude = winds[1]; + fmgc.windController.des_winds[computer_temp].wind2.altitude = winds[2]; + } else if (index == 1) { + fmgc.windController.des_winds[computer_temp].wind1.heading = winds[0]; + fmgc.windController.des_winds[computer_temp].wind1.magnitude = winds[1]; + fmgc.windController.des_winds[computer_temp].wind1.altitude = winds[2]; + } + mcdu_scratchpad.scratchpads[me.computer].empty(); + if (me.items == index and index != 5) { + me.items += 1; + } + me._setupPageWithData(); + me.updateTmpy(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } else if (mcdu_scratchpad.scratchpads[me.computer].scratchpad == "CLR") { + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + if (me.items == index) { + if (index == 5) { + fmgc.windController.des_winds[computer_temp].wind5.heading = 0; + fmgc.windController.des_winds[computer_temp].wind5.magnitude = 0; + fmgc.windController.des_winds[computer_temp].wind5.altitude = ""; + } else if (index == 4) { + fmgc.windController.des_winds[computer_temp].wind4.heading = 0; + fmgc.windController.des_winds[computer_temp].wind4.magnitude = 0; + fmgc.windController.des_winds[computer_temp].wind4.altitude = ""; + } else if (index == 3) { + fmgc.windController.des_winds[computer_temp].wind3.heading = 0; + fmgc.windController.des_winds[computer_temp].wind3.magnitude = 0; + fmgc.windController.des_winds[computer_temp].wind3.altitude = ""; + } else if (index == 2) { + fmgc.windController.des_winds[computer_temp].wind2.heading = 0; + fmgc.windController.des_winds[computer_temp].wind2.magnitude = 0; + fmgc.windController.des_winds[computer_temp].wind2.altitude = ""; + } else if (index == 1) { + fmgc.windController.des_winds[computer_temp].wind1.heading = 0; + fmgc.windController.des_winds[computer_temp].wind1.magnitude = 0; + fmgc.windController.des_winds[computer_temp].wind1.altitude = ""; + } + } else { + if (index <= 1) { + fmgc.windController.des_winds[computer_temp].wind1.heading = fmgc.windController.des_winds[computer_temp].wind2.heading; + fmgc.windController.des_winds[computer_temp].wind1.magnitude = fmgc.windController.des_winds[computer_temp].wind2.magnitude; + fmgc.windController.des_winds[computer_temp].wind1.altitude = fmgc.windController.des_winds[computer_temp].wind2.altitude; + } + if (index <= 2) { + fmgc.windController.des_winds[computer_temp].wind2.heading = fmgc.windController.des_winds[computer_temp].wind3.heading; + fmgc.windController.des_winds[computer_temp].wind2.magnitude = fmgc.windController.des_winds[computer_temp].wind3.magnitude; + fmgc.windController.des_winds[computer_temp].wind2.altitude = fmgc.windController.des_winds[computer_temp].wind3.altitude; + } + if (index <= 3) { + fmgc.windController.des_winds[computer_temp].wind3.heading = fmgc.windController.des_winds[computer_temp].wind4.heading; + fmgc.windController.des_winds[computer_temp].wind3.magnitude = fmgc.windController.des_winds[computer_temp].wind4.magnitude; + fmgc.windController.des_winds[computer_temp].wind3.altitude = fmgc.windController.des_winds[computer_temp].wind4.altitude; + } + if (index <= 4) { + fmgc.windController.des_winds[computer_temp].wind4.heading = fmgc.windController.des_winds[computer_temp].wind5.heading; + fmgc.windController.des_winds[computer_temp].wind4.magnitude = fmgc.windController.des_winds[computer_temp].wind5.magnitude; + fmgc.windController.des_winds[computer_temp].wind4.altitude = fmgc.windController.des_winds[computer_temp].wind5.altitude; + } + } + mcdu_scratchpad.scratchpads[me.computer].empty(); + me.items -= 1; + me._setupPageWithData(); + me.updateTmpy(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + }, + pushButtonRight: func(index) { + if (index == 1 and getprop("/FMGC/internal/alt-set")) { + if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) >= 3 and size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) <= 7) { + var winds = split("/", mcdu_scratchpad.scratchpads[me.computer].scratchpad); + if (size(winds[0]) >= 1 and size(winds[0]) <= 3 and num(winds[0]) != nil and winds[0] >= 0 and winds[0] <= 360 and + size(winds[1]) >= 1 and size(winds[1]) <= 3 and num(winds[1]) != nil and winds[1] >= 0 and winds[1] <= 200) { + me.makeTmpy(); + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + #print(computer_temp); + fmgc.windController.des_winds[computer_temp].alt1.heading = winds[0]; + fmgc.windController.des_winds[computer_temp].alt1.magnitude = winds[1]; + mcdu_scratchpad.scratchpads[me.computer].empty(); + me._setupPageWithData(); + me.updateTmpy(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } else if (mcdu_scratchpad.scratchpads[me.computer].scratchpad == "CLR") { + var computer_temp = 2; + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + computer_temp = me.computer; + } + fmgc.windController.des_winds[computer_temp].alt1.heading = 0; + fmgc.windController.des_winds[computer_temp].alt1.magnitude = 0; + mcdu_scratchpad.scratchpads[me.computer].empty(); + me._setupPageWithData(); + me.updateTmpy(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } else if (index == 6 and fmgc.flightPlanController.temporaryFlag[me.computer]) { + if (canvas_mcdu.myFpln[me.computer] != nil) { + canvas_mcdu.myFpln[me.computer].pushButtonRight(index); + } else { + fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 1); + # push update to fuel + if (getprop("/FMGC/internal/block-confirmed")) { + setprop("/FMGC/internal/fuel-calculating", 0); + setprop("/FMGC/internal/fuel-calculating", 1); + } + } + me.reload(); + } else { + mcdu_message(me.computer, "NOT ALLOWED"); + } + } +}; \ No newline at end of file diff --git a/Nasal/MCDU/WINDHIST.nas b/Nasal/MCDU/WINDHIST.nas new file mode 100644 index 00000000..94bd5b08 --- /dev/null +++ b/Nasal/MCDU/WINDHIST.nas @@ -0,0 +1,99 @@ +# A3XX mCDU by Joshua Davidson (Octal450), Jonathan Redpath, and Matthew Maring (mattmaring) + +# Copyright (c) 2020 Matthew Maring (mattmaring) + +var windHISTPage = { + title: nil, + fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]], + arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]], + L1: [nil, nil, "ack"], # content, title, colour + L2: [nil, nil, "ack"], + L3: [nil, nil, "ack"], + L4: [nil, nil, "ack"], + L5: [nil, nil, "ack"], + L6: [nil, nil, "ack"], + C1: [nil, nil, "ack"], + C2: [nil, nil, "ack"], + C3: [nil, nil, "ack"], + C4: [nil, nil, "ack"], + C5: [nil, nil, "ack"], + C6: [nil, nil, "ack"], + R1: [nil, nil, "ack"], + R2: [nil, nil, "ack"], + R3: [nil, nil, "ack"], + R4: [nil, nil, "ack"], + R5: [nil, nil, "ack"], + R6: [nil, nil, "ack"], + scroll: 0, + vector: [], + index: nil, + computer: nil, + new: func(computer) { + var whp = {parents:[windHISTPage]}; + whp.computer = computer; + whp._setupPageWithData(); + whp.updateTmpy(); + return whp; + }, + del: func() { + return nil; + }, + _setupPageWithData: func() { + me.title = "HISTORY WIND"; + me.titleColour = "wht"; + me.L1 = ["----/---", "", "blu"]; + me.L2 = ["----/---", "", "blu"]; + me.L3 = ["----/---", "", "blu"]; + me.L4 = ["----/---", "", "blu"]; + me.L5 = ["----/---", "", "blu"]; + me.L6 = [" CLIMB WIND", "", "wht"]; + me.C1 = ["FL050", "", "blu"]; + me.C2 = ["FL150", "", "blu"]; + me.C3 = ["FL250", "", "blu"]; + me.C4 = [" FL--- CRZ FL", "", "blu"]; + me.C5 = ["FL370", "", "blu"]; + me.R6 = ["SELECT ", "", "amb"]; + + me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]; + me.arrowsColour = [["ack", "ack", "ack", "ack", "ack", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]]; + me.fontMatrix = [[1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + }, + makeTmpy: func() { + if (!fmgc.flightPlanController.temporaryFlag[me.computer]) { + fmgc.flightPlanController.createTemporaryFlightPlan(me.computer); + } + }, + updateTmpy: func() { + if (fmgc.flightPlanController.temporaryFlag[me.computer]) { + me.L1[2] = "yel"; + me.L2[2] = "yel"; + me.L3[2] = "yel"; + me.L4[2] = "yel"; + me.L5[2] = "yel"; + me.C1[2] = "yel"; + me.C2[2] = "yel"; + me.C3[2] = "yel"; + me.C4[2] = "yel"; + me.C5[2] = "yel"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } else { + me.L1[2] = "blu"; + me.L2[2] = "blu"; + me.L3[2] = "blu"; + me.L4[2] = "blu"; + me.L5[2] = "blu"; + me.C1[2] = "blu"; + me.C2[2] = "blu"; + me.C3[2] = "blu"; + me.C4[2] = "blu"; + me.C5[2] = "blu"; + canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); + } + }, + reload: func() { + me._setupPageWithData(); + me.updateTmpy(); + } +}; \ No newline at end of file diff --git a/Nasal/Systems/brakesystem.nas b/Nasal/Systems/brakesystem.nas index 13aebae2..0e70979b 100755 --- a/Nasal/Systems/brakesystem.nas +++ b/Nasal/Systems/brakesystem.nas @@ -169,7 +169,7 @@ var BrakeSystem = var V2_R = V1 - me.BrakeDecel * dt * RBrakeLevel; LThermalEnergy += (Mass * getprop("gear/gear[1]/compression-norm") * (math.pow(V1, 2) - math.pow(V2_L, 2)) / 2); - if (getprop("services/chocks/left")) { + if (getprop("services/chocks/enable")) { if (!getprop("controls/gear/brake-parking")) { # cooling effect: reduce thermal energy by (LnCoolFactor) * dt LThermalEnergy = LThermalEnergy * math.exp(LnCoolFactor * dt); @@ -202,7 +202,7 @@ var BrakeSystem = }; RThermalEnergy += (Mass * getprop("gear/gear[2]/compression-norm") * (math.pow(V1, 2) - math.pow(V2_R, 2)) / 2); - if (getprop("services/chocks/right")) { + if (getprop("services/chocks/enable")) { if (!getprop("controls/gear/brake-parking")) { # cooling effect: reduce thermal energy by (RnCoolFactor) * dt RThermalEnergy = RThermalEnergy * math.exp(RnCoolFactor * dt); diff --git a/Nasal/Systems/ground_services.nas b/Nasal/Systems/ground_services.nas index 164e8919..88541e28 100644 --- a/Nasal/Systems/ground_services.nas +++ b/Nasal/Systems/ground_services.nas @@ -20,9 +20,7 @@ var ground_services = { # Set them all to 0 if the aircraft is not stationary if (getprop("velocities/groundspeed-kt") >= 2) { - setprop("services/chocks/nose", 0); - setprop("services/chocks/left", 0); - setprop("services/chocks/right", 0); + setprop("services/chocks/enable", 0); setprop("services/fuel-truck/enable", 0); setprop("services/deicing_truck/enable", 0); setprop("services/catering/enable", 0); diff --git a/Systems/a320-fcs.xml b/Systems/a320-fcs.xml index a3ddad8d..0d8af793 100644 --- a/Systems/a320-fcs.xml +++ b/Systems/a320-fcs.xml @@ -930,16 +930,10 @@ 20 - - /services/chocks/nose - 0.5 - - /controls/gear/brake-left /controls/gear/brake-parking - /services/chocks/nose-half - /services/chocks/left + /services/chocks/enable 0 1 @@ -957,8 +951,7 @@ /controls/gear/brake-right /controls/gear/brake-parking - /services/chocks/nose-half - /services/chocks/right + /services/chocks/enable 0 1