From 46ab42be56b03c0f887acf022075d0056183ccb9 Mon Sep 17 00:00:00 2001 From: Matthew Maring <56924612+hayden2000@users.noreply.github.com> Date: Fri, 26 Jun 2020 17:11:27 -0400 Subject: [PATCH 1/4] Improvements to ZFW/ZFWCG (correct order, add constraints, check decimal size) --- Models/Instruments/MCDU/MCDU.nas | 62 +- Models/Instruments/MCDU/res/mcdu.svg | 4428 +++++++++++++------------- Nasal/MCDU/FUELPRED.nas | 85 +- Nasal/MCDU/INITB.nas | 72 +- Nasal/MCDU/MCDU.nas | 4 +- 5 files changed, 2336 insertions(+), 2315 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index fccf7832..9c668347 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -294,8 +294,8 @@ var canvas_MCDU_base = { "Simple_R6","Simple_R1S","Simple_R2S","Simple_R3S","Simple_R4S","Simple_R5S","Simple_R6S","Simple_R1_Arrow","Simple_R2_Arrow","Simple_R3_Arrow", "Simple_R4_Arrow","Simple_R5_Arrow","Simple_R6_Arrow","Simple_C1","Simple_C2","Simple_C3","Simple_C3B","Simple_C4","Simple_C4B","Simple_C5","Simple_C6","Simple_C1S", "Simple_C2S","Simple_C3S","Simple_C4S","Simple_C5S","Simple_C6S","INITA","INITA_CoRoute","INITA_FltNbr","INITA_CostIndex","INITA_CruiseFLTemp", - "INITA_FromTo","INITA_InitRequest","INITA_AlignIRS","INITB","INITB_ZFWCG","INITB_ZFW","INITB_ZFW_S","INITB_Block","FUELPRED","FUELPRED_ZFW", - "FUELPRED_ZFWCG","FUELPRED_ZFW_S","PROG","PROG_UPDATE","PERFTO","PERFTO_V1","PERFTO_VR","PERFTO_V2","PERFTO_FE","PERFTO_SE","PERFTO_OE","PERFAPPR", + "INITA_FromTo","INITA_InitRequest","INITA_AlignIRS","INITB","INITB_ZFWCG","INITB_ZFW","INITB_ZFWCG_S","INITB_Block","FUELPRED","FUELPRED_ZFW", + "FUELPRED_ZFWCG","FUELPRED_ZFWCG_S","PROG","PROG_UPDATE","PERFTO","PERFTO_V1","PERFTO_VR","PERFTO_V2","PERFTO_FE","PERFTO_SE","PERFTO_OE","PERFAPPR", "PERFAPPR_FE","PERFAPPR_SE","PERFAPPR_OE","PERFAPPR_LDG_3","PERFAPPR_LDG_F","PERFGA","PERFGA_FE","PERFGA_SE","PERFGA_OE","FPLN","FPLN_From", "FPLN_TMPY_group","FPLN_FROM","FPLN_Callsign","departureTMPY", "arrowsDepArr","arrow1L","arrow2L","arrow3L","arrow4L","arrow5L","arrow1R","arrow2R", "arrow3R","arrow4R","arrow5R","DIRTO_TMPY_group","IRSINIT","IRSINIT_1","IRSINIT_2","IRSINIT_star"]; @@ -1483,7 +1483,7 @@ var canvas_MCDU_base = { me.fontRightS(default, default, default, default, default, default); me.fontSizeLeft(small, small, small, small, small, small); - me.fontSizeCenter(small, small, small, small, small, small); + me.fontSizeCenter(normal, small, small, small, small, small); me.fontSizeRight(normal, normal, normal, small, small, small); me["Simple_C4B"].setFontSize(small); @@ -1754,28 +1754,30 @@ var canvas_MCDU_base = { } } - me["Simple_R1S"].setText("ZFWCG/ ZFW"); - me["Simple_R1"].setText(sprintf("%3.1f", zfw.getValue())); + me["Simple_R1S"].setText("ZFW/ZFWCG"); + me["Simple_R1"].setText(sprintf("%3.1f", zfwcg.getValue())); + me["INITB_ZFWCG"].hide(); + me["INITB_ZFWCG_S"].show(); + me["Simple_R1"].show(); if (zfwcgSet.getValue() == 1) { - me["Simple_C1"].setFontSize(normal); - me["Simple_C1"].setText(" " ~ sprintf("%3.1f", zfwcg.getValue())); - me["INITB_ZFWCG"].hide(); + me["Simple_R1"].setFontSize(normal); } else { - me["Simple_C1"].setFontSize(small); - me["Simple_C1"].setText(" " ~ sprintf("%3.1f", zfwcg.getValue())); - me["INITB_ZFWCG"].hide(); + me["Simple_R1"].setFontSize(small); } if (zfwSet.getValue() == 1) { + if (zfw.getValue() < 100) { + me["Simple_C1"].setText(" " ~ sprintf("%3.1f", zfw.getValue())); + } else { + me["Simple_C1"].setText(" " ~ sprintf("%3.1f", zfw.getValue())); + } + me["Simple_C1"].show(); me["INITB_ZFW"].hide(); - me["INITB_ZFW_S"].show(); - me["Simple_R1"].show(); } else { + me["Simple_C1"].hide(); me["INITB_ZFW"].show(); - me["INITB_ZFW_S"].hide(); - me["Simple_R1"].hide(); } - + if (taxi_fuel_set.getValue() == 1) { me["Simple_L1"].setFontSize(normal); } else { @@ -1860,7 +1862,7 @@ var canvas_MCDU_base = { me.fontRightS(default, default, default, default, default, default); me.fontSizeLeft(normal, normal, small, small, small, small); - me.fontSizeCenter(small, small, small, small, small, small); + me.fontSizeCenter(small, small, normal, small, small, small); me.fontSizeRight(normal, normal, normal, small, small, small); me["Simple_C3B"].setFontSize(small); @@ -2026,26 +2028,28 @@ var canvas_MCDU_base = { me.colorRight("ack", "ack", "blu", "grn", "grn", "grn"); } - me["Simple_R3S"].setText("ZFWCG/ZFW"); - me["Simple_R3"].setText(sprintf("%3.1f", zfw.getValue())); + me["Simple_R3S"].setText("ZFW/ZFWCG"); + me["Simple_R3"].setText(sprintf("%3.1f", zfwcg.getValue())); + me["Simple_R3"].show(); + me["FUELPRED_ZFWCG"].hide(); + me["FUELPRED_ZFWCG_S"].show(); if (zfwcgSet.getValue() == 1) { - me["Simple_C3"].setFontSize(normal); - me["Simple_C3"].setText(" " ~ sprintf("%3.1f", zfwcg.getValue())); - me["FUELPRED_ZFWCG"].hide(); + me["Simple_R3"].setFontSize(normal); } else { - me["Simple_C3"].setFontSize(small); - me["Simple_C3"].setText(" " ~ sprintf("%3.1f", zfwcg.getValue())); - me["FUELPRED_ZFWCG"].hide(); + me["Simple_R3"].setFontSize(small); } if (zfwSet.getValue() == 1) { + if (zfw.getValue() < 100) { + me["Simple_C3"].setText(" " ~ sprintf("%3.1f", zfw.getValue())); + } else { + me["Simple_C3"].setText(" " ~ sprintf("%3.1f", zfw.getValue())); + } + me["Simple_C3"].show(); me["FUELPRED_ZFW"].hide(); - me["FUELPRED_ZFW_S"].show(); - me["Simple_R3"].show(); } else { + me["Simple_C3"].hide(); me["FUELPRED_ZFW"].show(); - me["FUELPRED_ZFW_S"].hide(); - me["Simple_R3"].hide(); } if (rte_rsv_set.getValue() == 1) { diff --git a/Models/Instruments/MCDU/res/mcdu.svg b/Models/Instruments/MCDU/res/mcdu.svg index 35f4ac4f..a2659979 100644 --- a/Models/Instruments/MCDU/res/mcdu.svg +++ b/Models/Instruments/MCDU/res/mcdu.svg @@ -7,13 +7,13 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - sodipodi:docname="mcdu.svg" - inkscape:version="1.0beta2 (2b71d25, 2019-12-03)" - id="svg2" - version="1.1" - viewBox="0 0 1024 864" + width="1280" height="1080" - width="1280"> + viewBox="0 0 1024 864" + version="1.1" + id="svg2" + inkscape:version="1.0beta2 (2b71d25, 2019-12-03)" + sodipodi:docname="mcdu.svg"> @@ -29,749 +29,656 @@ + borderopacity="1" + objecttolerance="20" + gridtolerance="20" + guidetolerance="20" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:window-width="1920" + inkscape:window-height="1035" + id="namedview371" + showgrid="true" + inkscape:zoom="1.1488097" + inkscape:cx="846.91312" + inkscape:cy="326.27773" + inkscape:window-x="0" + inkscape:window-y="23" + inkscape:window-maximized="0" + inkscape:current-layer="FUELPRED" + showguides="false" + inkscape:snap-global="false" + units="px" + inkscape:document-rotation="0"> + type="xygrid" + id="grid5153" /> SCRATCHPAD + x="20.138426" + id="tspan4242" + sodipodi:role="line">SCRATCHPAD + transform="translate(-1.2,-0.2)"> - - - - - + + + + + + inkscape:label="Simple"> + inkscape:label="Simple_Center"> TEXT + x="521.1662" + y="187.10254" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">TEXT TEXT + x="521.1662" + id="tspan4243" + sodipodi:role="line">TEXT TEXT - TEXT TEXT TEXT TEXT + TEXT + x="520.20905" + id="tspan4266" + sodipodi:role="line">TEXT TEXT + x="520.20905" + y="247.74202" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">TEXT TEXT + x="520.20905" + id="tspan4274" + sodipodi:role="line">TEXT TEXT - TEXT TEXT TEXT + id="tspan4286" + x="520.20905" + y="717.159" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">TEXT TEXT + TEXT TITLE + x="521.74713" + y="69.238266" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1">TITLE X/X + id="tspan4217" + sodipodi:role="line">X/X + cy="15.471865" + r="1.5" /> + cy="15.754708" + r="1.5" /> + cy="16.320395" + r="1.5" /> + cx="796.48511" + cy="13.774809" + r="3" /> TEXT - - - - - TEXT - - - - - TEXT - - - - - TEXT - - - - - TEXT - - - - - TEXT - - - - - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - TEXT + id="Simple_L1_Arrow" + style="fill:#ffffff;fill-opacity:1"> TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">TEXT + transform="matrix(1.0000018,0,0,0.99998906,-895.98862,236.8439)" + style="fill:#ffffff;fill-opacity:1"> TEXT + id="Simple_L3_Arrow" + style="fill:#ffffff;fill-opacity:1"> TEXT + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:70px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:start;text-anchor:start;fill:#ffffff;fill-opacity:1">TEXT + transform="matrix(1.0000018,0,0,0.99998906,-895.98862,473.56068)" + style="fill:#ffffff;fill-opacity:1"> TEXT + + + + + TEXT + + + + + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + + + + + TEXT + id="Simple_R2_Arrow" + style="fill:#ffffff;fill-opacity:1"> @@ -779,1534 +686,1024 @@ xml:space="preserve" style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;text-align:start;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" x="1022.194" - y="773.87396" - id="Simple_R6" + y="421.81125" + id="Simple_R3" transform="scale(0.991516,1.0085566)" inkscape:label="#text4244">TEXT + transform="matrix(-1.000002,0,0,0.99998904,1919.9892,355.20231)" + style="fill:#ffffff;fill-opacity:1"> - TEXT TEXT - TEXT - TEXT - TEXT - TEXT - TEXT - - - - - - - - - - - - - CALLSIG - - TMPY - - ERASE - TMPY - - - - - - - - TMPY - INSERT - - - - - - - - - FROM - - - - ERASE - DIR TO - - - - - - - - DIR TO - INSERT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + id="Simple_R4_Arrow" + style="fill:#ffffff;fill-opacity:1"> + style="fill:#ffffff;fill-opacity:1;stroke:#cdcdcd;stroke-width:4.08;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + TEXT + id="Simple_R5_Arrow" + inkscape:label="#g4241" + transform="matrix(-1.000002,0,0,0.99998904,1919.9892,591.91912)" + style="fill:#ffffff;fill-opacity:1"> - + id="path4319" + d="M 936.70791,62.1688 921.8587,47.4328" + style="fill:#ffffff;fill-opacity:1;stroke:#cdcdcd;stroke-width:4.08;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + + TEXT + + id="path4327" + d="M 936.70791,32.6968 921.8587,47.4328" + style="fill:#ffffff;fill-opacity:1;stroke:#cdcdcd;stroke-width:4.08;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + + + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + TEXT + + + + + + + + + inkscape:label="INITA" + id="INITA-9" + style="display:inline" /> + + + / + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:56px;line-height:1.25;font-family:BoeingCDULarge;-inkscape-font-specification:BoeingCDULarge;text-align:center;text-anchor:middle;fill:#ffffff;fill-opacity:1" + y="69.238258" + x="750.78857" + id="tspan4388" + sodipodi:role="line">CALLSIG - - - - + id="FPLN_TMPY_group" + inkscape:label="#g3767"> + TMPY + + ERASE + TMPY + + + + + + + + TMPY + INSERT + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - / + id="FPLN_FROM" + y="68.861366" + x="177.72771" + style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#ffff00;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve">FROM + + + + ERASE + DIR TO + + + + + + + + DIR TO + INSERT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + inkscape:groupmode="layer" + id="INITA" + inkscape:label="INITA"> - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - / - . - / - - - - - - - - - - - - - . - - - . - - - - - - - - - / - - . - / - - - - - - - - - - - - - . - - - - + id="path4490" + d="M 998.71909,284.70793 H 970.18944" + style="fill:none;stroke:#bb6100;stroke-width:4.08;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + style="fill:none;stroke:#bb6100;stroke-width:4.08;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + + / + + + + + + + + + + + + + + + + + + + + + + + + + + id="INITA_FltNbr" + transform="translate(-833.84951,236.71687)"> + + id="rect4377" + style="fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#bb6100;stroke-width:4.03199;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke" /> + id="rect4381" + style="fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#bb6100;stroke-width:4.03199;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke" /> + + + + + + + + + + + + + + + + + + / + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + / + + . + / + + + + + + + + + + + + + . + + + . + + + + + + + + + / + + . + / + + + + + + + + + + + + + . + + + + + + + + + + + id="PERFTO_VR" + transform="translate(-833.84951,118.3616)"> - F + + + + + F + S + S - O - = + x="398.21817" + id="tspan4399" + sodipodi:role="line">O = = + = - F + inkscape:label="PERFAPPR"> F + S + S - O - = + x="398.21817" + id="tspan1085" + sodipodi:role="line">O = = + = + + + + + + - - - - - - + inkscape:connector-curvature="0" + sodipodi:nodetypes="cc" /> - - - - - - - - + - + style="fill:none;stroke:#179ab7;stroke-width:4.08;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + + + + + + + + - F + inkscape:label="PERFGA"> F + S + S - O - = + x="398.21817" + id="tspan1135" + sodipodi:role="line">O = = + = diff --git a/Nasal/MCDU/FUELPRED.nas b/Nasal/MCDU/FUELPRED.nas index 63000cf2..c71ea930 100644 --- a/Nasal/MCDU/FUELPRED.nas +++ b/Nasal/MCDU/FUELPRED.nas @@ -148,14 +148,14 @@ var fuelPredInput = func(key, i) { if (scratchpad == "CLR") { mcdu_message(i, "NOT ALLOWED"); } else { - if (!getprop("/FMGC/internal/cost-index-set")) { + if (!getprop("/FMGC/internal/cost-index-set") and getprop("/FMGC/internal/tofrom-set")) { mcdu_message(i, "USING COST INDEX N", getprop("/FMGC/internal/last-cost-index")); setprop("/FMGC/internal/cost-index-set", 1); setprop("/FMGC/internal/cost-index", getprop("/FMGC/internal/last-cost-index")); } - - var tfs = size(scratchpad); - if (tfs == 0) { + var zfw_min = 80.6; #make based on performance + var zfw_max = 137.8; #make based on performance + if (size(scratchpad) == 0) { var zfw = getprop("/fdm/jsbsim/inertia/weight-lbs") - getprop("/consumables/fuel/total-fuel-lbs"); setprop("/FMGC/internal/zfw", sprintf("%3.1f", math.round(zfw / 1000, 0.1))); setprop("/FMGC/internal/zfw-set", 1); @@ -167,26 +167,45 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/block-calculating", 0); setprop("/FMGC/internal/block-confirmed", 1); } - } else if (tfs >= 2 and tfs <= 11 and find("/", scratchpad) != -1) { + mcdu_scratchpad.scratchpads[i].empty(); + } else if (find("/", scratchpad) != -1) { var zfwi = split("/", scratchpad); - var zfwcg = num(zfwi[0]); - var zfw = num(zfwi[1]); - var zfwcgs = size(zfwi[0]); - var zfws = size(zfwi[1]); - if (zfwcg != nil and zfwcgs >= 1 and zfwcgs <= 5 and zfwcg > 0 and zfwcg <= 99.9) { - setprop("/FMGC/internal/zfwcg", zfwcg); - setprop("/FMGC/internal/zfwcg-set", 1); - if (getprop("/FMGC/internal/block-set") != 1) { - setprop("/FMGC/internal/block", num(getprop("consumables/fuel/total-fuel-lbs") / 1000)); - setprop("/FMGC/internal/block-set", 1); - setprop("/FMGC/internal/fuel-request-set", 1); - setprop("/FMGC/internal/fuel-calculating", 1); - setprop("/FMGC/internal/block-calculating", 0); - setprop("/FMGC/internal/block-confirmed", 1); + var zfw = num(zfwi[0]); + var zfwcg = num(zfwi[1]); + var zfws = size(zfwi[0]); + var zfwcgs = size(zfwi[1]); + if (zfw != nil and zfws > 0 and zfws <= 5 and size(split(".", zfwi[0])[1]) <= 1 and zfwcg != nil and zfwcgs > 0 and zfwcgs <= 4 and size(split(".", zfwi[1])[1]) <= 1) { + if (zfw >= zfw_min and zfw <= zfw_max and zfwcg >= 8.0 and zfwcg <= 45.0) { + setprop("/FMGC/internal/zfw", zfw); + setprop("/FMGC/internal/zfw-set", 1); + setprop("/FMGC/internal/zfwcg", zfwcg); + setprop("/FMGC/internal/zfwcg-set", 1); + if (getprop("/FMGC/internal/block-set") != 1) { + setprop("/FMGC/internal/block", num(getprop("consumables/fuel/total-fuel-lbs") / 1000)); + setprop("/FMGC/internal/block-set", 1); + setprop("/FMGC/internal/fuel-request-set", 1); + setprop("/FMGC/internal/fuel-calculating", 1); + setprop("/FMGC/internal/block-calculating", 0); + setprop("/FMGC/internal/block-confirmed", 1); + } + mcdu_scratchpad.scratchpads[i].empty(); + } else { + mcdu_message(i, "ENTRY OUT OF RANGE"); } + } else if (zfws == 0 and zfwcg != nil and zfwcgs > 0 and zfwcgs <= 4 and size(split(".", zfwi[1])[1]) <= 1) { + if (zfwcg >= 8.0 and zfwcg <= 45.0) { + setprop("/FMGC/internal/zfwcg", zfwcg); + setprop("/FMGC/internal/zfwcg-set", 1); + mcdu_scratchpad.scratchpads[i].empty(); + } else { + mcdu_message(i, "ENTRY OUT OF RANGE"); + } + } else { + mcdu_message(i, "NOT ALLOWED"); } - if (zfw != nil and zfws >= 1 and zfws <= 5 and zfw > 0 and zfw <= 999.9) { - setprop("/FMGC/internal/zfw", zfw); + } else if (num(scratchpad) != nil and size(scratchpad) > 0 and size(scratchpad) <= 5 and size(split(".", scratchpad)[1]) <= 1) { + if (scratchpad >= zfw_min and scratchpad <= zfw_max) { + setprop("/FMGC/internal/zfw", scratchpad); setprop("/FMGC/internal/zfw-set", 1); if (getprop("/FMGC/internal/block-set") != 1) { setprop("/FMGC/internal/block", num(getprop("consumables/fuel/total-fuel-lbs") / 1000)); @@ -196,31 +215,9 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/block-calculating", 0); setprop("/FMGC/internal/block-confirmed", 1); } - if (getprop("/FMGC/internal/block-confirmed")) { - setprop("/FMGC/internal/fuel-calculating", 1); - } - } - if ((zfwcg != nil and zfwcgs >= 1 and zfwcgs <= 5 and zfwcg > 0 and zfwcg <= 99.9) or (zfw != nil and zfws >= 1 and zfws <= 5 and zfw > 0 and zfw <= 999.9)) { mcdu_scratchpad.scratchpads[i].empty(); } else { - mcdu_message(i, "NOT ALLOWED"); - } - } else if (tfs >= 1 and tfs <= 5) { - var zfwcg = size(scratchpad); - if (num(scratchpad) != nil and zfwcg >= 1 and zfwcg <= 5 and scratchpad > 0 and scratchpad <= 99.9) { - setprop("/FMGC/internal/zfwcg", scratchpad); - setprop("/FMGC/internal/zfwcg-set", 1); - if (getprop("/FMGC/internal/block-set") != 1) { - setprop("/FMGC/internal/block", num(getprop("consumables/fuel/total-fuel-lbs") / 1000)); - setprop("/FMGC/internal/block-set", 1); - setprop("/FMGC/internal/fuel-request-set", 1); - setprop("/FMGC/internal/fuel-calculating", 1); - setprop("/FMGC/internal/block-calculating", 0); - setprop("/FMGC/internal/block-confirmed", 1); - } - mcdu_scratchpad.scratchpads[i].empty(); - } else { - mcdu_message(i, "NOT ALLOWED"); + mcdu_message(i, "ENTRY OUT OF RANGE"); } } else { mcdu_message(i, "NOT ALLOWED"); diff --git a/Nasal/MCDU/INITB.nas b/Nasal/MCDU/INITB.nas index 0dd306f0..1195e122 100644 --- a/Nasal/MCDU/INITB.nas +++ b/Nasal/MCDU/INITB.nas @@ -148,14 +148,14 @@ var initInputB = func(key, i) { if (scratchpad == "CLR") { mcdu_message(i, "NOT ALLOWED"); } else { - if (!getprop("/FMGC/internal/cost-index-set")) { + if (!getprop("/FMGC/internal/cost-index-set") and getprop("/FMGC/internal/tofrom-set")) { mcdu_message(i, "USING COST INDEX N", getprop("/FMGC/internal/last-cost-index")); setprop("/FMGC/internal/cost-index-set", 1); setprop("/FMGC/internal/cost-index", getprop("/FMGC/internal/last-cost-index")); } - - var tfs = size(scratchpad); - if (tfs == 0) { + var zfw_min = 80.6; #make based on performance + var zfw_max = 137.8; #make based on performance + if (size(scratchpad) == 0) { var zfw = getprop("/fdm/jsbsim/inertia/weight-lbs") - getprop("/consumables/fuel/total-fuel-lbs"); setprop("/FMGC/internal/zfw", sprintf("%3.1f", math.round(zfw / 1000, 0.1))); setprop("/FMGC/internal/zfw-set", 1); @@ -171,18 +171,49 @@ var initInputB = func(key, i) { } else if (getprop("/FMGC/internal/fuel-request-set")) { setprop("/FMGC/internal/block-calculating", 1); } - } else if (tfs >= 2 and tfs <= 11 and find("/", scratchpad) != -1) { + mcdu_scratchpad.scratchpads[i].empty(); + } else if (find("/", scratchpad) != -1) { var zfwi = split("/", scratchpad); - var zfwcg = num(zfwi[0]); - var zfw = num(zfwi[1]); - var zfwcgs = size(zfwi[0]); - var zfws = size(zfwi[1]); - if (zfwcg != nil and zfwcgs >= 1 and zfwcgs <= 5 and zfwcg > 0 and zfwcg <= 99.9) { - setprop("/FMGC/internal/zfwcg", zfwi[0]); - setprop("/FMGC/internal/zfwcg-set", 1); + var zfw = num(zfwi[0]); + var zfwcg = num(zfwi[1]); + var zfws = size(zfwi[0]); + var zfwcgs = size(zfwi[1]); + if (zfw != nil and zfws > 0 and zfws <= 5 and size(split(".", zfwi[0])[1]) <= 1 and zfwcg != nil and zfwcgs > 0 and zfwcgs <= 4 and size(split(".", zfwi[1])[1]) <= 1) { + if (zfw >= zfw_min and zfw <= zfw_max and zfwcg >= 8.0 and zfwcg <= 45.0) { + setprop("/FMGC/internal/zfw", zfw); + setprop("/FMGC/internal/zfw-set", 1); + setprop("/FMGC/internal/zfwcg", zfwcg); + setprop("/FMGC/internal/zfwcg-set", 1); + if (!getprop("/FMGC/internal/block-confirmed") and getprop("/FMGC/internal/block-set")) { + setprop("/FMGC/internal/tow", num(getprop("/FMGC/internal/zfw") + getprop("/FMGC/internal/block") - getprop("/FMGC/internal/taxi-fuel"))); + setprop("/FMGC/internal/tow-set", 1); + setprop("/FMGC/internal/fuel-request-set", 1); + setprop("/FMGC/internal/fuel-calculating", 1); + setprop("/FMGC/internal/block-calculating", 0); + setprop("/FMGC/internal/block-confirmed", 1); + } else if (getprop("/FMGC/internal/block-confirmed")) { + setprop("/FMGC/internal/fuel-calculating", 1); + } else if (getprop("/FMGC/internal/fuel-request-set")) { + setprop("/FMGC/internal/block-calculating", 1); + } + mcdu_scratchpad.scratchpads[i].empty(); + } else { + mcdu_message(i, "ENTRY OUT OF RANGE"); + } + } else if (zfws == 0 and zfwcg != nil and zfwcgs > 0 and zfwcgs <= 4 and size(split(".", zfwi[1])[1]) <= 1) { + if (zfwcg >= 8.0 and zfwcg <= 45.0) { + setprop("/FMGC/internal/zfwcg", zfwcg); + setprop("/FMGC/internal/zfwcg-set", 1); + mcdu_scratchpad.scratchpads[i].empty(); + } else { + mcdu_message(i, "ENTRY OUT OF RANGE"); + } + } else { + mcdu_message(i, "NOT ALLOWED"); } - if (zfw != nil and zfws >= 1 and zfws <= 5 and zfw > 0 and zfw <= 999.9) { - setprop("/FMGC/internal/zfw", zfwi[1]); + } else if (num(scratchpad) != nil and size(scratchpad) > 0 and size(scratchpad) <= 5 and size(split(".", scratchpad)[1]) <= 1) { + if (scratchpad >= zfw_min and scratchpad <= zfw_max) { + setprop("/FMGC/internal/zfw", scratchpad); setprop("/FMGC/internal/zfw-set", 1); if (!getprop("/FMGC/internal/block-confirmed") and getprop("/FMGC/internal/block-set")) { setprop("/FMGC/internal/tow", num(getprop("/FMGC/internal/zfw") + getprop("/FMGC/internal/block") - getprop("/FMGC/internal/taxi-fuel"))); @@ -196,20 +227,9 @@ var initInputB = func(key, i) { } else if (getprop("/FMGC/internal/fuel-request-set")) { setprop("/FMGC/internal/block-calculating", 1); } - } - if ((zfwcg != nil and zfwcgs >= 1 and zfwcgs <= 5 and zfwcg > 0 and zfwcg <= 99.9) or (zfw != nil and zfws >= 1 and zfws <= 5 and zfw > 0 and zfw <= 999.9)) { mcdu_scratchpad.scratchpads[i].empty(); } else { - mcdu_message(i, "NOT ALLOWED"); - } - } else if (tfs >= 1 and tfs <= 5) { - var zfwcg = size(scratchpad); - if (num(scratchpad) != nil and zfwcg >= 1 and zfwcg <= 5 and scratchpad > 0 and scratchpad <= 99.9) { - setprop("/FMGC/internal/zfwcg", scratchpad); - setprop("/FMGC/internal/zfwcg-set", 1); - mcdu_scratchpad.scratchpads[i].empty(); - } else { - mcdu_message(i, "NOT ALLOWED"); + mcdu_message(i, "ENTRY OUT OF RANGE"); } } else { mcdu_message(i, "NOT ALLOWED"); diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index 576b7a67..777f63ea 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -88,7 +88,7 @@ var MCDU_reset = func(i) { # INT-B setprop("/FMGC/internal/zfw", 0); setprop("/FMGC/internal/zfw-set", 0); - setprop("/FMGC/internal/zfwcg", 55.1); + setprop("/FMGC/internal/zfwcg", 25.0); setprop("/FMGC/internal/zfwcg-set", 0); setprop("/FMGC/internal/block", 0.0); setprop("/FMGC/internal/block-set", 0); @@ -168,7 +168,7 @@ var MCDU_reset = func(i) { 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/dest-wind-grnd", -1); setprop("/FMGC/internal/vapp-speed-set", 0); setprop("/FMGC/internal/final", ""); setprop("/FMGC/internal/baro", 99999); From 61d2d171fdb896f4a1fa81bb39402efb6065f186 Mon Sep 17 00:00:00 2001 From: Matthew Maring <56924612+hayden2000@users.noreply.github.com> Date: Fri, 26 Jun 2020 17:35:48 -0400 Subject: [PATCH 2/4] Correct max ZFW to 61,000 kg --- Nasal/MCDU/FUELPRED.nas | 2 +- Nasal/MCDU/INITB.nas | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Nasal/MCDU/FUELPRED.nas b/Nasal/MCDU/FUELPRED.nas index c71ea930..9dbb490b 100644 --- a/Nasal/MCDU/FUELPRED.nas +++ b/Nasal/MCDU/FUELPRED.nas @@ -154,7 +154,7 @@ var fuelPredInput = func(key, i) { setprop("/FMGC/internal/cost-index", getprop("/FMGC/internal/last-cost-index")); } var zfw_min = 80.6; #make based on performance - var zfw_max = 137.8; #make based on performance + var zfw_max = 134.5; #61,000 kg, make based on performance if (size(scratchpad) == 0) { var zfw = getprop("/fdm/jsbsim/inertia/weight-lbs") - getprop("/consumables/fuel/total-fuel-lbs"); setprop("/FMGC/internal/zfw", sprintf("%3.1f", math.round(zfw / 1000, 0.1))); diff --git a/Nasal/MCDU/INITB.nas b/Nasal/MCDU/INITB.nas index 1195e122..b60063ab 100644 --- a/Nasal/MCDU/INITB.nas +++ b/Nasal/MCDU/INITB.nas @@ -154,7 +154,7 @@ var initInputB = func(key, i) { setprop("/FMGC/internal/cost-index", getprop("/FMGC/internal/last-cost-index")); } var zfw_min = 80.6; #make based on performance - var zfw_max = 137.8; #make based on performance + var zfw_max = 134.5; #61,000 kg, make based on performance if (size(scratchpad) == 0) { var zfw = getprop("/fdm/jsbsim/inertia/weight-lbs") - getprop("/consumables/fuel/total-fuel-lbs"); setprop("/FMGC/internal/zfw", sprintf("%3.1f", math.round(zfw / 1000, 0.1))); From 499786bb6ec1c9ae61615775bd867c87c1908bcc Mon Sep 17 00:00:00 2001 From: Matthew Maring <56924612+hayden2000@users.noreply.github.com> Date: Sat, 27 Jun 2020 07:11:53 -0400 Subject: [PATCH 3/4] Fix taxi fuel bug --- Nasal/MCDU/INITB.nas | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Nasal/MCDU/INITB.nas b/Nasal/MCDU/INITB.nas index b60063ab..5e44e127 100644 --- a/Nasal/MCDU/INITB.nas +++ b/Nasal/MCDU/INITB.nas @@ -20,9 +20,12 @@ var initInputB = func(key, i) { if (num(scratchpad) != nil and scratchpad >= 0.0 and scratchpad <= 9.9) { setprop("/FMGC/internal/taxi-fuel", scratchpad); setprop("/FMGC/internal/taxi-fuel-set", 1); - setprop("/FMGC/internal/fuel-calculating", 1); + if (getprop("/FMGC/internal/block-confirmed")) { + setprop("/FMGC/internal/fuel-calculating", 1); + } else if (getprop("/FMGC/internal/fuel-request-set")) { + setprop("/FMGC/internal/block-calculating", 1); + } mcdu_scratchpad.scratchpads[i].empty(); - fmgc.updateFuel(); } else { mcdu_message(i, "NOT ALLOWED"); } From 6cd65e9ac09516f5f9e170daecfe2aaecc54dd93 Mon Sep 17 00:00:00 2001 From: legoboyvdlp R Date: Sat, 27 Jun 2020 23:26:36 +0100 Subject: [PATCH 4/4] Several major bugfixes reported by @julienlengele - many thanks! --- Nasal/FMGC/flightplan.nas | 4 ++-- Nasal/FMGC/mcdu-messages.nas | 2 +- Nasal/MCDU/DIRTO.nas | 2 ++ Nasal/MCDU/FUELPRED.nas | 11 ++++++----- Nasal/MCDU/RADNAV.nas | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 5e515566..a3909c1b 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -368,8 +368,8 @@ 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.flightplans[plan].insertWP(createWP(waypointGhost, waypointGhost.id), 2); + fmgc.windController.insertWind(plan, 2, 0, waypointGhost.id); 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. diff --git a/Nasal/FMGC/mcdu-messages.nas b/Nasal/FMGC/mcdu-messages.nas index 4b1a247f..b66c25a3 100644 --- a/Nasal/FMGC/mcdu-messages.nas +++ b/Nasal/FMGC/mcdu-messages.nas @@ -170,7 +170,7 @@ var MessageController = { TypeIMessage.new("LIST OF 20 IN USE"),TypeIMessage.new("PILOT ELEMENT RETAINED"),TypeIMessage.new("NOT ALLOWED"), TypeIMessage.new("NOT IN DATA BASE"),TypeIMessage.new("ONLY SPD ENTRY ALLOWED"),TypeIMessage.new("REVISION IN PROGRESS"), TypeIMessage.new("TMPY F-PLN EXISTS", 1),TypeIMessage.new("SELECT DESIRED SYSTEM"),TypeIMessage.new("SELECT HDG/TRK FIRST"), - TypeIMessage.new("USING COST INDEX N", 1),TypeIMessage.new("WAIT FOR SYSTEM RESPONSE"), + TypeIMessage.new("USING COST INDEX N", 1),TypeIMessage.new("WAIT FOR SYSTEM RESPONSE"),TypeIMessage.new("RWY/LS MISMATCH"), ]), typeIIMessages: std.Vector.new([ TypeIIMessage.new("LAT DISCONT AHEAD", "amb", 0),TypeIIMessage.new("MORE DRAG"),TypeIIMessage.new("RWY/LS MISMATCH", "amb", 0),TypeIIMessage.new("STEP DELETED"), diff --git a/Nasal/MCDU/DIRTO.nas b/Nasal/MCDU/DIRTO.nas index d557490b..a440bb20 100644 --- a/Nasal/MCDU/DIRTO.nas +++ b/Nasal/MCDU/DIRTO.nas @@ -254,6 +254,7 @@ var dirTo = { dirToFlag = 0; fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 0); me.L1 = [" [ ]", " WAYPOINT", "blu"]; + me.fontMatrix = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0]]; me.R1 = ["---- --- ", "UTC DIST ", "wht"]; } else { mcdu_message(me.computer, "NOT ALLOWED"); @@ -264,6 +265,7 @@ var dirTo = { dirToFlag = 0; fmgc.flightPlanController.destroyTemporaryFlightPlan(me.computer, 1); me.L1 = [" [ ]", " WAYPOINT", "blu"]; + me.fontMatrix = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0]]; me.R1 = ["---- --- ", "UTC DIST ", "wht"]; setprop("MCDU[" ~ me.computer ~ "]/page", "F-PLNA"); # todo - remember horizontal srcoll of f-plna? } else { diff --git a/Nasal/MCDU/FUELPRED.nas b/Nasal/MCDU/FUELPRED.nas index 9dbb490b..5bceb179 100644 --- a/Nasal/MCDU/FUELPRED.nas +++ b/Nasal/MCDU/FUELPRED.nas @@ -148,11 +148,6 @@ var fuelPredInput = func(key, i) { if (scratchpad == "CLR") { mcdu_message(i, "NOT ALLOWED"); } else { - if (!getprop("/FMGC/internal/cost-index-set") and getprop("/FMGC/internal/tofrom-set")) { - mcdu_message(i, "USING COST INDEX N", getprop("/FMGC/internal/last-cost-index")); - setprop("/FMGC/internal/cost-index-set", 1); - setprop("/FMGC/internal/cost-index", getprop("/FMGC/internal/last-cost-index")); - } var zfw_min = 80.6; #make based on performance var zfw_max = 134.5; #61,000 kg, make based on performance if (size(scratchpad) == 0) { @@ -222,6 +217,12 @@ var fuelPredInput = func(key, i) { } else { mcdu_message(i, "NOT ALLOWED"); } + + if (!getprop("/FMGC/internal/cost-index-set") and getprop("/FMGC/internal/tofrom-set")) { + mcdu_message(i, "USING COST INDEX N", getprop("/FMGC/internal/last-cost-index")); + setprop("/FMGC/internal/cost-index-set", 1); + setprop("/FMGC/internal/cost-index", getprop("/FMGC/internal/last-cost-index")); + } } } else if (key == "R4") { if (scratchpad == "CLR") { diff --git a/Nasal/MCDU/RADNAV.nas b/Nasal/MCDU/RADNAV.nas index 03af4246..4e73a397 100644 --- a/Nasal/MCDU/RADNAV.nas +++ b/Nasal/MCDU/RADNAV.nas @@ -68,7 +68,7 @@ var radnavInput = func(key, i) { setprop("/FMGC/internal/ils1freq-set", 1); mcdu_scratchpad.scratchpads[i].empty(); if (num(getprop("/FMGC/internal/ils1freq-calculated")) != 0 and num(getprop("/FMGC/internal/ils1freq-calculated")) != num(getprop("instrumentation/nav[0]/frequencies/selected-mhz"))) { - genericMessage(i, "RWY/LS MISMATCH", "amb"); + mcdu_message(i, "RWY/LS MISMATCH"); } } else { mcdu_message(i, "NOT ALLOWED");