diff --git a/Nasal/FMGC/SimbriefParser.nas b/Nasal/FMGC/SimbriefParser.nas index 8fa4136f..6312b49c 100644 --- a/Nasal/FMGC/SimbriefParser.nas +++ b/Nasal/FMGC/SimbriefParser.nas @@ -270,7 +270,7 @@ var SimbriefParser = { fmgc.FMGCInternal.costIndex = me.OFP.getNode("general/costindex").getValue(); fmgc.FMGCInternal.costIndexSet = 1; fmgc.FMGCNodes.costIndex.setValue(fmgc.FMGCInternal.costIndex); - fmgc.FMGCInternal.tropo = me.OFP.getNode("general/avg_tropopause").getValue(); + fmgc.FMGCInternal.tropo = math.round(me.OFP.getNode("general/avg_tropopause").getValue(), 10); fmgc.FMGCInternal.tropoSet = 1; # Set cruise altitude diff --git a/Nasal/MCDU/INITA.nas b/Nasal/MCDU/INITA.nas index 741aa009..5bdd3815 100644 --- a/Nasal/MCDU/INITA.nas +++ b/Nasal/MCDU/INITA.nas @@ -310,27 +310,65 @@ var initInputA = func(key, i) { setprop("MCDU[" ~ i ~ "]/page", "WINDCLB"); } else if (key == "R5") { if (scratchpad == "CLR") { - fmgc.FMGCInternal.tropo = 36090; - fmgc.FMGCInternal.tropoSet = 0; - mcdu_scratchpad.scratchpads[i].empty(); - } else { - var tropo = size(scratchpad); - if (tropo == 5 and scratchpad <= 99990) { - fmgc.FMGCInternal.tropo = scratchpad; - fmgc.FMGCInternal.tropoSet = 1; + if (fmgc.FMGCInternal.tropoSet) { + fmgc.FMGCInternal.tropo = 36090; + fmgc.FMGCInternal.tropoSet = 0; mcdu_scratchpad.scratchpads[i].empty(); } else { mcdu_message(i, "NOT ALLOWED"); } + } else { + if (num(scratchpad) == nil) { + if (find("FL", scratchpad) != -1) { + var tropos = size(split("FL", scratchpad)[1]); + var tropon = num(split("FL", scratchpad)[1]); + if (tropon != nil) { + if ((tropos == 2 or tropos == 3) and tropon >= 10 and tropon <= 999) { + fmgc.FMGCInternal.tropo = tropon * 100; + fmgc.FMGCInternal.tropoSet = 1; + mcdu_scratchpad.scratchpads[i].empty(); + } else { + mcdu_message(i, "ENTRY OUT OF RANGE"); + } + } else { + mcdu_message(i, "NOT ALLOWED"); + } + } else { + mcdu_message(i, "NOT ALLOWED"); + } + } else { + var tropos = size(scratchpad); + var tropon = num(scratchpad); + if ((tropos == 4 or tropos == 5) and tropon >= 1000 and tropon <= 99990) { + fmgc.FMGCInternal.tropo = math.round(tropon, 10); + fmgc.FMGCInternal.tropoSet = 1; + mcdu_scratchpad.scratchpads[i].empty(); + } else if ((tropos == 2 or tropos == 3) and tropon >= 10 and tropon <= 999) { + fmgc.FMGCInternal.tropo = num(scratchpad) * 100; + fmgc.FMGCInternal.tropoSet = 1; + mcdu_scratchpad.scratchpads[i].empty(); + } else { + mcdu_message(i, "ENTRY OUT OF RANGE"); + } + } } } else if (key == "R6") { if (scratchpad == "CLR") { - fmgc.FMGCInternal.gndTempSet = 0; - mcdu_scratchpad.scratchpads[i].empty(); - } else if (int(scratchpad) != nil and fmgc.FMGCInternal.phase == 0 and size(scratchpad) >= 1 and size(scratchpad) <= 3 and scratchpad >= -99 and scratchpad <= 99) { - fmgc.FMGCInternal.gndTemp = scratchpad; - fmgc.FMGCInternal.gndTempSet = 1; - mcdu_scratchpad.scratchpads[i].empty(); + if (fmgc.FMGCInternal.gndTempSet) { + fmgc.FMGCInternal.gndTempSet = 0; + fmgc.FMGCInternal.gndTemp = 15; + mcdu_scratchpad.scratchpads[i].empty(); + } else { + mcdu_message(i, "NOT ALLOWED"); + } + } else if (isnum(scratchpad) and fmgc.FMGCInternal.phase == 0) { + if (size(scratchpad) >= 1 and size(scratchpad) <= 3 and scratchpad >= -99 and scratchpad <= 99) { + fmgc.FMGCInternal.gndTemp = scratchpad; + fmgc.FMGCInternal.gndTempSet = 1; + mcdu_scratchpad.scratchpads[i].empty(); + } else { + mcdu_message(i, "ENTRY OUT OF RANGE"); + } } else { mcdu_message(i, "NOT ALLOWED"); } diff --git a/Nasal/Systems/Comm/Notification.nas b/Nasal/Systems/Comm/Notification.nas index c4b0cd72..97470397 100644 --- a/Nasal/Systems/Comm/Notification.nas +++ b/Nasal/Systems/Comm/Notification.nas @@ -340,6 +340,7 @@ var ATIS = { print("Failed to parse ATIS for " ~ airport); debug.dump(r.response); debug.printerror(errs); + me.sent = 0; mcdu.mcdu_message(i, "BAD SERVER RESPONSE"); } }); @@ -391,6 +392,14 @@ var ATIS = { code = split(".", code)[0]; } + if (find(",", code) != -1) { + code = split(",", code)[0]; + } + + if (size(code) > 1) { + code = left(code, 1); + } + me.receivedCode = code; var time = ""; @@ -403,26 +412,47 @@ var ATIS = { } else if (find("TIME ", raw) != -1) { time = split("TIME ", raw)[1]; time = split(" ", time)[0]; + } else if (find("WEATHER AT ", raw) != -1) { + time = split("WEATHER AT ", raw)[1]; + time = left(split(" ", time)[0], 4); + } else if (find(" UTC", raw) != -1) { + time = split(" UTC", raw)[0]; + time = right(time, 4); } else if (find("Z.", raw) != -1) { time = split("Z.", raw)[0]; time = right(time, 4); } else if (find("Z SPECIAL", raw) != -1) { time = split("Z SPECIAL", raw)[0]; time = right(time, 4); + } else if (find("Z EXPECT", raw) != -1) { + time = split("Z EXPECT", raw)[0]; + time = right(time, 4); } else if (find("metreport", raw) != -1) { time = split("metreport", raw)[0]; time = right(time, 4); + } else if (find("METREPORT ", raw) != -1) { + time = split("METREPORT ", raw)[1]; + time = left(time, 4); + } else if (find("INFORMATION " ~ code ~ " AT ", raw) != -1) { + time = split("INFORMATION " ~ code ~ " AT ", raw)[1]; + time = left(time, 4); } else if (find((code ~ " "), raw) != -1) { if (size(split(" ",split(code ~ " ", raw)[1])[0]) == 4) { time = split(" ",split(code ~ " ", raw)[1])[0]; } + } else if (size(split(" ",split(code, raw)[1])[0]) == 4) { + time = split(" ",split(code, raw)[1])[0]; } else { print("Failed to find a valid ATIS time for " ~ me.station); debug.dump(raw); } + # Handle UK airport issue + # Limitation: always ends in 0 if (size(time) == 3) { - time ~= " "; + time ~= "0"; + } else if (size(time) > 4) { + time = left(time, 4); } raw = string.uc(raw);