From 05c413683627fa74aea71646308fe02d60b1acc6 Mon Sep 17 00:00:00 2001 From: Awemeter <71922517+Awemeter@users.noreply.github.com> Date: Sat, 6 Feb 2021 12:49:29 -0500 Subject: [PATCH] refactor(mcdu): AC STATUS page (#3310) * Happy falcon * Fix color code * Added inop to CHG CODE * Added place holder and fixed aircraft model number * Removed imenes trailing space * feat: the secondary navdata is now dynamic * Remove Orignal code since it can be found on github * Remove trailing space * Add comment on aircraft code Co-authored-by: pepperoni505 <49950581+pepperoni505@users.noreply.github.com> Co-authored-by: ZigTag <17077422+ZigTag@users.noreply.github.com> Co-authored-by: DerL30N --- .../A320_Neo/CDU/A320_Neo_CDU_IdentPage.js | 85 +++++++++++++++++-- 1 file changed, 76 insertions(+), 9 deletions(-) diff --git a/A32NX/html_ui/Pages/VCockpit/Instruments/Airliners/A320_Neo/CDU/A320_Neo_CDU_IdentPage.js b/A32NX/html_ui/Pages/VCockpit/Instruments/Airliners/A320_Neo/CDU/A320_Neo_CDU_IdentPage.js index 046d43a1d08..dade1c39e90 100644 --- a/A32NX/html_ui/Pages/VCockpit/Instruments/Airliners/A320_Neo/CDU/A320_Neo_CDU_IdentPage.js +++ b/A32NX/html_ui/Pages/VCockpit/Instruments/Airliners/A320_Neo/CDU/A320_Neo_CDU_IdentPage.js @@ -16,6 +16,73 @@ * along with this program. If not, see . */ +const months = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"]; +const monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + +function findNewMonthIndex(index) { + if (index === 0) { + return 11; + } else { + return index - 1; + } +} + +function lessThan10(num) { + if (num < 10) { + return `0${num}`; + } else { + return num; + } +} + +function calculateActiveDate(date) { + if (date.length === 13) { + const startMonth = date.slice(0, 3); + const startDay = date.slice(3, 5); + + const endMonth = date.slice(5, 8); + const endDay = date.slice(8, 10); + + return `${startDay}${startMonth}-${endDay}${endMonth}`; + } else { + return date; + } +} + +function calculateSecDate(date) { + if (date.length === 13) { + const primStartMonth = date.slice(0, 3); + const primStartDay = date.slice(3, 5); + + const primStartMonthIndex = months.findIndex((item) => item === primStartMonth); + + if (primStartMonthIndex === -1) { + return "ERR"; + } + + let newEndMonth = primStartMonth; + let newEndDay = primStartDay - 1; + + let newStartDay = newEndDay - 27; + let newStartMonth = primStartMonth; + + if (newEndDay === 0) { + newEndMonth = months[findNewMonthIndex(primStartMonthIndex)]; + newEndDay = monthLength[findNewMonthIndex(primStartMonthIndex)]; + } + + if (newStartDay <= 0) { + newStartMonth = months[findNewMonthIndex(primStartMonthIndex)]; + newStartDay = monthLength[findNewMonthIndex(primStartMonthIndex)] + newStartDay; + } + + return `${lessThan10(newStartDay)}${newStartMonth}-${lessThan10(newEndDay)}${newEndMonth}`; + } else { + return "ERR"; + } + +} + class CDUIdentPage { static ShowPage(mcdu) { const date = mcdu.getNavDataDateRange(); @@ -23,19 +90,19 @@ class CDUIdentPage { mcdu.page.Current = mcdu.page.IdentPage; mcdu.activeSystem = 'FMGC'; mcdu.setTemplate([ - ["A320-200"], + ["A320-200"],//This aircraft code is correct and does not include the engine type. ["\xa0ENG"], - ["LEAP 1A-26[color]green"], + ["LEAP-1A26[color]green"], ["\xa0ACTIVE NAV DATA BASE"], - ["\xa0" + (date.length === 13 ? date[3] + date[4] + date[0] + date[1] + date[2] + "-" + date[8] + date[9] + date[5] + date[6] + date[7] : date) + "[color]cyan", "AIRAC[color]green"], + ["\xa0" + calculateActiveDate(date) + "[color]cyan", "AIRAC[color]green"], ["\xa0SECOND NAV DATA BASE"], - ["{small}{04MAY-04JUL{end}[color]cyan"], - ["", "STORED"], - ["", "{green}10{end}{small}RTES\xa0{end}{green}10{end}{small}RWYS{end}"], - ["CHG CODE", "[b-text]{big}{green}20{end}{end}WPTS\xa0{big}{green}20{end}{end}NAVS"], - ["{small}[ ]{end}[color]cyan", "DELETE ALL}[color]cyan"], + ["{small}{" + calculateSecDate(date) + "{end}[color]inop"], + ["", ""], + ["", ""], + ["CHG CODE", ""], + ["{small}[ ]{end}[color]inop", ""], ["IDLE/PERF", "SOFTWARE"], - ["+0.0/+0.0[color]green", "STATUS/XLOAD>"] + ["+0.0/+0.0[color]green", "STATUS/XLOAD>[color]inop"] ]); } }