82 const bool owns=a.AutopilotEngaged&&a.AutothrottleEngaged&&!a.DorOn&&!a.TvmOn&&
83 (a.CurrentLateralMode==Afcs::Navigation||(
final==
Final::Ils&&a.CurrentLateralMode==Afcs::Localizer))&&
84 a.CurrentVerticalMode==Afcs::FlightPathAngle&&
85 (a.StandbyLateralMode==Afcs::LateralMode_Off||(
final==
Final::Ils&&a.StandbyLateralMode==Afcs::Localizer))&&
86 (a.StandbyVerticalMode==Afcs::VerticalMode_Off||(
final==
Final::Ils&&a.StandbyVerticalMode==Afcs::Glideslope))&&
87 std::abs(a.DesiredFpaRadians-
lastFpa)<1e-5&&std::abs(a.DesiredTasKms-
lastTas)<1e-5&&
88 std::abs(std::remainder(a.DesiredCourseRadians-
lastCourse,
Tau))<1e-5&&
90 auto stop=[&](
const wchar_t* reason,
bool capture) {
93 a.CurrentVerticalMode=Afcs::AltitudeMsl;
98 if(!owns)
return stop(L
"ILS DESCENT CANCELLED",
false);
106 return stop(L
"ILS DATA LOST / ALT HOLD",
true);
108 if(!std::isfinite(value)||value<=0)
return stop(L
"ILS DATA LOST / ALT HOLD",
true);
110 if(s.
frozen)
return false;
119 return stop(L
"ILS TERRAIN / ALT HOLD",
true);
125 return stop(L
"ILS PATH LIMIT / ALT HOLD",
true);
129 if(!std::isfinite(tas)||tas<=0)
return stop(L
"ILS SPEED DATA / ALT HOLD",
true);
132 if(!std::isfinite(wanted)||wanted<=0)
return stop(L
"ILS SPEED DATA / ALT HOLD",
true);
136 a.DesiredTasKms=float((std::max)(wanted,
lastTas-rate*s.
dt));
lastTas=a.DesiredTasKms;
138 a.DesiredCourseRadians=float(course);
lastCourse=a.DesiredCourseRadians;
140 const double reference=
path.Height(distance);
141 const double slope=
path.Slope(distance);
142 double vertical=-slope*s.
groundSpeed+(reference-altitude)/20;
146 if(s.
ias>.93*in.
vneKms) vertical=(std::max)(vertical,0.0);
156 std::abs(cross)<std::tan(
Pi/180)*distance&&
160 if(a.CurrentLateralMode!=Afcs::Localizer) a.StandbyLateralMode=Afcs::Localizer;
161 a.StandbyVerticalMode=Afcs::Glideslope;