diff --git a/Nasal/FMGC/FMGC-b.nas b/Nasal/FMGC/FMGC-b.nas index 4eb4aaad..02455aef 100644 --- a/Nasal/FMGC/FMGC-b.nas +++ b/Nasal/FMGC/FMGC-b.nas @@ -433,7 +433,13 @@ var ITAF = { # TODO - if in HDG mode, if no distance, then crosstrack error must be less than 5nm # TODO - if in nav, no distance condition applies, but DEST course error must be less than 30 (CONFIRM) - if (FPLN.wp0Dist.getValue() <= FPLN.turnDist and !Gear.wow1.getBoolValue() and fmgc.flightPlanController.flightplans[2].getWP(FPLN.currentWPTemp).fly_type == "flyBy") { + var enableFlyBy = 0; + var maxCourseDelta = 120; + if (abs(fmgc.flightPlanController.flightplans[2].getWP(FPLN.currentWPTemp).leg_bearing - fmgc.flightPlanController.flightplans[2].getWP(FPLN.currentWPTemp + 1).leg_bearing) < maxCourseDelta) { + enableFlyBy = 1; + } + + if (enableFlyBy and FPLN.wp0Dist.getValue() <= FPLN.turnDist and !Gear.wow1.getBoolValue() and fmgc.flightPlanController.flightplans[2].getWP(FPLN.currentWPTemp).fly_type == "flyBy") { flightPlanController.autoSequencing(); } elsif (FPLN.wp0Dist.getValue() <= 0.15) { flightPlanController.autoSequencing(); diff --git a/Nasal/FMGC/flightplan-delegates.nas b/Nasal/FMGC/flightplan-delegates.nas index 5fa00820..377e424f 100644 --- a/Nasal/FMGC/flightplan-delegates.nas +++ b/Nasal/FMGC/flightplan-delegates.nas @@ -87,11 +87,6 @@ var A320GPSDeleagte = { logprint(LOG_INFO,'flightplan activated, default GPS to LEG mode'); setprop(GPSPath ~ "/command", "leg"); - - if (getprop(GPSPath ~ '/wp/wp[1]/from-flag')) { - logprint(LOG_INFO, '\tat GPS activation, already passed active WP, sequencing'); - me.sequence(); - } }, deactivated: func @@ -127,46 +122,6 @@ var A320GPSDeleagte = { sequence: func { return; - - if (!me.flightplan.active) - return; - #flightPlanController.autoSequencing(); - var mode = me._modeProp.getValue(); - if (mode == 'dto') { - # direct-to is done, check if we should resume the following leg - var index = me.flightplan.indexOfWP(getprop(GPSPath ~ '/wp/wp[1]/latitude-deg'), - getprop(GPSPath ~ '/wp/wp[1]/longitude-deg')); - if (index >= 0) { - logprint(LOG_INFO, "default GPS reached Direct-To, resuming FP leg at " ~ index); - me.flightplan.current = index + 1; - setprop(GPSPath ~ "/command", "leg"); - } else { - # revert to OBS mode - logprint(LOG_INFO, "default GPS reached Direct-To, resuming to OBS"); - - me._captureCurrentCourse(); - me._selectOBSMode(); - } - } else if (mode == 'leg') { - # standard leq sequencing - var nextIndex = me.flightplan.current + 1; - - if (nextIndex >= me.flightplan.numWaypoints()) { - logprint(LOG_INFO, "default GPS sequencing, finishing flightplan"); - me.flightplan.finish(); - } elsif (me.flightplan.nextWP().wp_type == 'discontinuity') { - logprint(LOG_INFO, "default GPS sequencing DISCONTINUITY in flightplan, switching to OBS mode"); - # TODO - revert autopilot to hdg / vs - me._captureCurrentCourse(); - me._selectOBSMode(); - } else { - logprint(LOG_INFO, "default GPS sequencing to next WP"); - me.flightplan.current = nextIndex; - } - } else { - # OBS, do nothing - } - }, currentWaypointChanged: func diff --git a/Nasal/FMGC/flightplan.nas b/Nasal/FMGC/flightplan.nas index 5ee910ab..66965495 100644 --- a/Nasal/FMGC/flightplan.nas +++ b/Nasal/FMGC/flightplan.nas @@ -369,36 +369,23 @@ var flightPlanController = { me.addDiscontinuity(me.currentToWptIndex.getValue() + 2, plan); me.DirToIndex = me.currentToWptIndex.getValue() + 1; } else { - # we want to delete the intermediate waypoints up to but not including the waypoint. Leave index 0, we delete it later. - # example - waypoint dirto is index 5, we want to delete indexes 1 -> 4. 5 - 1 = 4. - # so four individual deletions. Delete index 1 four times. - var indexWP = me.flightplans[plan].indexOfWP(waypointGhost); - + me.deleteTillIndex(waypointGhost, me.currentToWptIndex.getValue(), plan); me.insertTP(plan, indexWP - 1); - for (var i = 0; i < indexWP - 1; i = i + 1) { - if (me.temporaryFlag[0]) { - me.deleteWP(i, 0, 1); - } - if (me.temporaryFlag[1]) { - me.deleteWP(i, 1, 1); - } - me.deleteWP(i, 2, 1); - } } var curAircraftPosDirTo = geo.aircraft_position(); canvas_mcdu.myDirTo[plan].updateDist(me.flightplans[plan].getWP(me.currentToWptIndex.getValue() + 1).courseAndDistanceFrom(curAircraftPosDirTo)[1]); me.flightPlanChanged(plan); }, - deleteWP: func(index, n, a = 0, s = 0) { # a = 1, means adding a waypoint via deleting intermediate. s = 1, means autosequencing + deleteWP: func(index, n, a = 0) { # a = 1, means adding a waypoint via deleting intermediate var wp = me.flightplans[n].getWP(index); - if (((s == 0 and left(wp.wp_name, 4) != FMGCInternal.depApt and left(wp.wp_name, 4) != FMGCInternal.arrApt) or (s == 1)) and me.flightplans[n].getPlanSize() > 2) { + if ((left(wp.wp_name, 4) != FMGCInternal.depApt and left(wp.wp_name, 4) != FMGCInternal.arrApt) and me.flightplans[n].getPlanSize() > 2) { if (me.flightplans[n].getWP(index).id != "DISCONTINUITY" and a == 0) { # if it is a discont, don't make a new one me.flightplans[n].deleteWP(index); fmgc.windController.deleteWind(n, index); - if (me.flightplans[n].getWP(index) != nil and s == 0) { + if (me.flightplans[n].getWP(index) != nil) { if (me.flightplans[n].getWP(index).id != "DISCONTINUITY") { # else, if the next one isn't a discont, add one me.addDiscontinuity(index, n); } @@ -767,6 +754,7 @@ var flightPlanController = { return 3; } + if (!me.temporaryFlag[plan]) { if (text == "CLR" and me.flightplans[2].getWP(index).wp_name == "DISCONTINUITY") { if (me.flightplans[2].getPlanSize() == 3 and me.flightplans[2].departure_runway == nil and me.flightplans[2].destination_runway == nil and index == 1) { @@ -780,6 +768,7 @@ var flightPlanController = { } else { var thePlan = plan; } + debug.dump(me.flightplans[thePlan].getWP(index).wp_name); # check waypoints database here var wpFromDB = WaypointDatabase.getWP(text); diff --git a/Nasal/MCDU/F-PLN.nas b/Nasal/MCDU/F-PLN.nas index 004f5769..4f77d6c1 100644 --- a/Nasal/MCDU/F-PLN.nas +++ b/Nasal/MCDU/F-PLN.nas @@ -580,15 +580,8 @@ var fplnPage = { # this one is only created once, and then updated - remember th } else { if ((index - 1 + me.scroll) < size(me.planList) and me.outputList[index - 1].wp != "STATIC" and me.outputList[index - 1].wp != "PSEUDO" and !mcdu_scratchpad.scratchpads[me.computer].showTypeIMsg and !mcdu_scratchpad.scratchpads[me.computer].showTypeIIMsg) { if (size(mcdu_scratchpad.scratchpads[me.computer].scratchpad) > 0) { - if (!me.temporaryFlagFpln) { - decelIndex = getprop("/instrumentation/nd/symbols/decel/index"); - decelShow = getprop("/instrumentation/nd/symbols/decel/show"); - if (decelShow and (index - 1 + me.scroll) > decelIndex) { - index = index - 1; - } - } - - var returny = fmgc.flightPlanController.scratchpad(mcdu_scratchpad.scratchpads[me.computer].scratchpad, (index - 1 + me.scroll), me.computer); + # Use outputList.index to correct the index the call goes to after sequencing + var returny = fmgc.flightPlanController.scratchpad(mcdu_scratchpad.scratchpads[me.computer].scratchpad, me.outputList[index - 1].index, me.computer); if (returny == 3) { mcdu_message(me.computer, "DIR TO IN PROGRESS"); } elsif (returny == 0) {