From e1a0be5401c749a5a69519894b24b75e6a6d378d Mon Sep 17 00:00:00 2001 From: Inuyaksa Date: Wed, 20 Jan 2021 21:25:37 +0100 Subject: [PATCH] cleaning the code --- Models/Instruments/MCDU/MCDU.nas | 75 ++++++++++++++------------------ Nasal/FMGC/SimbriefParser.nas | 4 +- Nasal/MCDU/FLIGHTLOG.nas | 6 +-- Nasal/MCDU/ROUTESELECTION.nas | 15 ------- 4 files changed, 38 insertions(+), 62 deletions(-) diff --git a/Models/Instruments/MCDU/MCDU.nas b/Models/Instruments/MCDU/MCDU.nas index 15e699fb..eb435712 100644 --- a/Models/Instruments/MCDU/MCDU.nas +++ b/Models/Instruments/MCDU/MCDU.nas @@ -2797,60 +2797,49 @@ var canvas_MCDU_base = { me.showRight(-1, 1, 1, 1, 1, 1); me.showRightS(-1, 1, 1, 1, 1, -1); me.showRightArrow(-1, -1, -1, -1, -1, -1); - #me.showCenter(-1, -1, 1, -1, -1, -1); - #me.showCenterS(-1, -1, 1, -1, -1, -1); - #me["Simple_C3B"].hide(); - #me["Simple_C4B"].hide(); - - #me.fontLeft(default, default, default, default, default, default); - #me.fontLeftS(default, default, default, default, default, default); - #me.fontSizeLeft(normal, normal, normal, normal, normal, normal); me.fontSizeLeftS(normal, normal, normal, normal, normal, normal); - #me.fontRight(default, default, default, default, default, default); - #me.fontRightS(default, default, default, default, default, default); me.fontSizeRight(0, small, small, small, small, normal); me.fontSizeRightS(0, small, small, small, small, normal); me.colorLeft("grn", "grn", "grn", "grn", "grn", "wht"); me.colorLeftS("grn", "grn", "grn", "grn", "grn", "wht"); - #me.colorCenter("grn", "ack", "amb", "ack", "ack", "wht"); me.colorRight("ack", "wht", "wht", "wht", "wht", "amb"); me.colorRightS("ack", "wht", "wht", "wht", "wht", "wht"); - pageSwitch[i].setBoolValue(1); + me["Simple_L1"].setText("NONE"); + me["Simple_L6"].setText(" RETURN"); + me["Simple_R6"].setText("INSERT "); + me["PRINTPAGE"].show(); + me["PRINTPAGE"].setColor(AMBER); + + var rows = ["2S","2","3S","3","4S","4","5S","5"]; + + me["Simple_L1"].setText("DUBLHR1"); + + var r = 0; + #for ( ; r < 8; r += 1) { # Example how formats rows with 4 cols + # me["Simple_L" ~ rows[r]].setText(sprintf("%11s %11s","SELKA","NUGRA")); + # me["Simple_R" ~ rows[r]].setText(sprintf("%-13s %-13s","UL975","UL975")); + #} + while (r<8) { + me["Simple_L" ~ rows[r]].setText(""); + me["Simple_R" ~ rows[r]].setText(""); + r+=1; + } + + if (fmgc.FMGCInternal.toFromSet and !fmgc.FMGCInternal.altSelected) { + me["Simple_Title"].setText(sprintf("%s", fmgc.FMGCInternal.depApt ~ "/" ~ fmgc.FMGCInternal.arrApt)); + } else if (!fmgc.FMGCInternal.toFromSet and fmgc.FMGCInternal.altAirport != "" and fmgc.FMGCInternal.altSelected) { + me["Simple_Title"].setText(sprintf("%s", fmgc.FMGCInternal.altAirport)); + } else if (fmgc.FMGCInternal.toFromSet and fmgc.FMGCInternal.altAirport != "" and fmgc.FMGCInternal.altSelected) { + me["Simple_Title"].setText(sprintf("%s", fmgc.FMGCInternal.arrApt ~ "/" ~ fmgc.FMGCInternal.altAirport)); + } else { + me["Simple_Title"].setText("ROUTE SELECTION"); + } + + pageSwitch[i].setBoolValue(1); # update on request only (left/right arrows) } - me["Simple_L1"].setText("NONE"); - me["Simple_L6"].setText(" RETURN"); - me["Simple_R6"].setText("INSERT "); - me["PRINTPAGE"].show(); - me["PRINTPAGE"].setColor(AMBER); - - var rows = ["2S","2","3S","3","4S","4","5S","5"]; - - me["Simple_L1"].setText("DUBLHR1"); - - var r = 0; - for ( ; r < 8; r += 1) { - me["Simple_L" ~ rows[r]].setText(sprintf("%11s %11s","SELKA","NUGRA")); - me["Simple_R" ~ rows[r]].setText(sprintf("%-13s %-13s","UL975","UL975")); - } - while (r<8) { - me["Simple_L" ~ rows[r]].setText(""); - me["Simple_R" ~ rows[r]].setText(""); - r+=1; - } - - if (fmgc.FMGCInternal.toFromSet and !fmgc.FMGCInternal.altSelected) { - me["Simple_Title"].setText(sprintf("%s", fmgc.FMGCInternal.depApt ~ "/" ~ fmgc.FMGCInternal.arrApt)); - } else if (!fmgc.FMGCInternal.toFromSet and fmgc.FMGCInternal.altAirport != "" and fmgc.FMGCInternal.altSelected) { - me["Simple_Title"].setText(sprintf("%s", fmgc.FMGCInternal.altAirport)); - } else if (fmgc.FMGCInternal.toFromSet and fmgc.FMGCInternal.altAirport != "" and fmgc.FMGCInternal.altSelected) { - me["Simple_Title"].setText(sprintf("%s", fmgc.FMGCInternal.arrApt ~ "/" ~ fmgc.FMGCInternal.altAirport)); - } else { - me["Simple_Title"].setText("ROUTE SELECTION"); - } - } else if (page == "INITB") { if (!pageSwitch[i].getBoolValue()) { me["Simple"].show(); diff --git a/Nasal/FMGC/SimbriefParser.nas b/Nasal/FMGC/SimbriefParser.nas index 541236bf..087c1f44 100644 --- a/Nasal/FMGC/SimbriefParser.nas +++ b/Nasal/FMGC/SimbriefParser.nas @@ -49,7 +49,7 @@ var SimbriefParser = { me.failure(i); } }, - checkValid: func(xml) { + validateFile: func(xml) { var data = io.readxml(xml); if (data != nil) { return (data.getChild("OFP") != nil); @@ -188,6 +188,7 @@ var SimbriefParser = { #setprop("/autopilot/route-manager/vnav/tc/latitude-deg",ofpFix.getNode("pos_lat").getValue()); #setprop("/autopilot/route-manager/vnav/tc/longitude-deg",ofpFix.getNode("pos_long").getValue()); #ident = "(T/C)"; + continue; # restore skip TOC/TOD } if (ident == "TOD") { @@ -195,6 +196,7 @@ var SimbriefParser = { #setprop("/autopilot/route-manager/vnav/td/latitude-deg",ofpFix.getNode("pos_lat").getValue()); #setprop("/autopilot/route-manager/vnav/td/longitude-deg",ofpFix.getNode("pos_long").getValue()); #ident = "(T/D)"; + continue; # restore skip TOC/TOD } coords = geo.Coord.new(); diff --git a/Nasal/MCDU/FLIGHTLOG.nas b/Nasal/MCDU/FLIGHTLOG.nas index 818dac51..c8550c1f 100644 --- a/Nasal/MCDU/FLIGHTLOG.nas +++ b/Nasal/MCDU/FLIGHTLOG.nas @@ -176,13 +176,13 @@ var waitingOOOIChange = maketimer(1, func(){ # 1sec precision expectedOOOIState = 0; } } - else if (!gear0) { # OFF without IN -> To without stop and opening doors + else if (!gear0) { # OFF without IN -> TO without stop and opening doors if (lastgear0) FlightLogDatabase.addReport(OOOIReport.new(expectedOOOIState,lastgear0)); # IN (estimated) FlightLogDatabase.addPage(); if (lastgsrestart) FlightLogDatabase.addReport(OOOIReport.new(0,lastgsrestart)); # OUT (estimated) - expectedOOOIState = 1; # watch for OFF state + expectedOOOIState = 1; # go on to OFF state } - else if (gs > 9 and lastgsrestart == 0) { # try to decect OFF without IN + else if (gs > 9 and lastgsrestart == 0) { # try to detect OFF without IN lastgsrestart = int(getprop("/sim/time/elapsed-sec")); } } diff --git a/Nasal/MCDU/ROUTESELECTION.nas b/Nasal/MCDU/ROUTESELECTION.nas index d1b03bff..85d1b464 100644 --- a/Nasal/MCDU/ROUTESELECTION.nas +++ b/Nasal/MCDU/ROUTESELECTION.nas @@ -1,22 +1,7 @@ # Copyright (c) 2020 Matthew Maring (mattmaring) -# enhanced inuyaksa*2021 var initInputROUTESEL = func(key, i) { if (key == "L6") { setprop("MCDU[" ~ i ~ "]/page", "INITA"); } } - -var RouteSelManager = { - - leglist: nil, - - loadFlightplan: func(path) { - if (right(path,4) == ".xml") { # plan from SimBrief? - if (SimBrief.isValid(path)) { - leglist = SimBrief.readLegs(path); - } - } - } - -} \ No newline at end of file