From 23142d2959325908bf5e22ccde0b2451ba92db70 Mon Sep 17 00:00:00 2001 From: hayden2000 Date: Tue, 24 Mar 2020 08:33:40 -0400 Subject: [PATCH] Implement alternate airport on INTA --- Models/Instruments/MCDU/MCDU.nas | 12 ++++++++++-- Nasal/FMGC/FMGC.nas | 6 ++++++ Nasal/MCDU/INITA.nas | 21 ++++++++++++++++++++- Nasal/MCDU/MCDU.nas | 4 ++-- Nasal/MCDU/PERFAPPR.nas | 2 +- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index fa62af90..48aa1093 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -937,7 +937,11 @@ var canvas_MCDU_base = { me["INITA_FromTo"].hide(); me["Simple_L1"].show(); me["Simple_L2"].setColor(0.0901,0.6039,0.7176); - me["Simple_L2"].setText("NONE"); + if (alt_airport.getValue() == "") { + me["Simple_L2"].setText("NONE"); + } else { + me["Simple_L2"].setText(alt_airport.getValue()); + } me["Simple_R1"].show(); me["Simple_R2"].hide(); me["Simple_R2S"].hide(); @@ -1249,7 +1253,11 @@ var canvas_MCDU_base = { } else { me["Simple_L1"].setText(arrArpt.getValue()); } - me["Simple_L2"].setText("----"); + if (!engrdy.getBoolValue() or alt_airport.getValue() == "") { + me["Simple_L2"].setText("----"); + } else { + me["Simple_L2"].setText(alt_airport.getValue()); + } me["Simple_L1S"].setText("AT"); me["Simple_L2S"].setText("X"); diff --git a/Nasal/FMGC/FMGC.nas b/Nasal/FMGC/FMGC.nas index dae2db71..07f50e78 100644 --- a/Nasal/FMGC/FMGC.nas +++ b/Nasal/FMGC/FMGC.nas @@ -155,13 +155,19 @@ var trimReset = func { var updateARPT = func { dep = getprop("FMGC/internal/dep-arpt"); arr = getprop("FMGC/internal/arr-arpt"); + alt = getprop("FMGC/internal/alt-airport"); setprop("autopilot/route-manager/departure/airport", dep); setprop("autopilot/route-manager/destination/airport", arr); + setprop("autopilot/route-manager/alternate/airport", alt); if (getprop("autopilot/route-manager/active") != 1) { fgcommand("activate-flightplan", props.Node.new({"activate": 1})); } } +# var updateVSPEEDS = func { +# +# } + setlistener("/FMGC/internal/cruise-ft", func { setprop("autopilot/route-manager/cruise/altitude-ft", getprop("FMGC/internal/cruise-ft")); }); diff --git a/Nasal/MCDU/INITA.nas b/Nasal/MCDU/INITA.nas index 4f5ae68d..ad4f9224 100644 --- a/Nasal/MCDU/INITA.nas +++ b/Nasal/MCDU/INITA.nas @@ -1,10 +1,29 @@ # A3XX mCDU by Joshua Davidson (Octal450), Jonathan Redpath, and Matthew Maring (hayden2000) # Copyright (c) 2019 Joshua Davidson (Octal450) +# Copyright (c) 2020 Matthew Maring (hayden2000) var initInputA = func(key, i) { var scratchpad = getprop("MCDU[" ~ i ~ "]/scratchpad"); - if (key == "L3") { + if (key == "L2") { + if (scratchpad == "CLR") { + setprop("FMGC/internal/alt-airport", ""); + setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); + setprop("MCDU[" ~ i ~ "]/scratchpad", ""); + fmgc.updateARPT(); + } else if (getprop("FMGC/internal/tofrom-set") == 1) { + var tfs = size(scratchpad); + if (tfs == 4) { + setprop("FMGC/internal/alt-airport", scratchpad); + setprop("MCDU[" ~ i ~ "]/scratchpad", ""); + fmgc.updateARPT(); + } else { + notAllowed(i); + } + } else { + notAllowed(i); + } + } else if (key == "L3") { if (scratchpad == "CLR") { setprop("MCDUC/flight-num", ""); setprop("MCDUC/flight-num-set", 0); diff --git a/Nasal/MCDU/MCDU.nas b/Nasal/MCDU/MCDU.nas index b8139f50..d4a1adc9 100644 --- a/Nasal/MCDU/MCDU.nas +++ b/Nasal/MCDU/MCDU.nas @@ -64,7 +64,7 @@ var MCDU_reset = func(i) { setprop("FMGC/internal/extra-time", "0000"); #FUELPRED - setprop("FMGC/internal/alt-airport", 0); + setprop("FMGC/internal/alt-airport", ""); setprop("FMGC/internal/pri-utc", "0000"); setprop("FMGC/internal/alt-utc", "0000"); setprop("FMGC/internal/pri-efob", 0); @@ -169,7 +169,7 @@ var lskbutton = func(btn, i) { } } else if (btn == "2") { if (getprop("MCDU[" ~ i ~ "]/page") == "INITA") { - PerfInput("L2",i); + initInputA("L2",i); } else if (getprop("MCDU[" ~ i ~ "]/page") == "INITB") { initInputB("L2",i); } else if (getprop("MCDU[" ~ i ~ "]/page") == "TO") { diff --git a/Nasal/MCDU/PERFAPPR.nas b/Nasal/MCDU/PERFAPPR.nas index 1a9e0e49..92c59a19 100644 --- a/Nasal/MCDU/PERFAPPR.nas +++ b/Nasal/MCDU/PERFAPPR.nas @@ -25,7 +25,7 @@ var perfAPPRInput = func(key, i) { setprop("FMGC/internal/dest-qnh", -1); setprop("MCDU[" ~ i ~ "]/scratchpad-msg", 0); setprop("MCDU[" ~ i ~ "]/scratchpad", ""); - } else if (scratchpad >= 0 and scratchpad < 1100) { + } else if (scratchpad >= 0 and scratchpad <= 1100) { setprop("FMGC/internal/dest-qnh", scratchpad); setprop("MCDU[" ~ i ~ "]/scratchpad", ""); } else {