Skip to content

Commit

Permalink
refactor(mcdu): AC STATUS page (flybywiresim#3310)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: ZigTag <[email protected]>
Co-authored-by: DerL30N <[email protected]>
  • Loading branch information
4 people authored Feb 6, 2021
1 parent 1ec7e64 commit 05c4136
Showing 1 changed file with 76 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,93 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

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();
mcdu.clearDisplay();
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"]
]);
}
}

0 comments on commit 05c4136

Please sign in to comment.