bool ConditionMonitorLandableReachable::CheckCondition(const GlideComputer& cmp) { if (!cmp.Calculated().flight.flying) return false; now_reachable = cmp.Calculated().common_stats.landable_reachable; // warn when becoming unreachable return (!now_reachable && last_reachable); }
bool ConditionMonitorGlideTerrain::CheckCondition(const GlideComputer& cmp) { if (!cmp.Calculated().flight.flying || !cmp.Calculated().task_stats.task_valid) return false; const GlideResult& res = cmp.Calculated().task_stats.total.solution_remaining; if (!res.IsFinalGlide()) // only give message about terrain warnings if above final glide return false; return cmp.Calculated().terrain_warning; }
bool ConditionMonitorFinalGlide::CheckCondition(const GlideComputer& cmp) { if (!cmp.Calculated().flight.flying || !cmp.Calculated().task_stats.task_valid) return false; const GlideResult& res = cmp.Calculated().task_stats.total.solution_remaining; // TODO: use low pass filter tad = res.altitude_difference * fixed(0.2) + fixed(0.8) * tad; bool BeforeFinalGlide = !res.IsFinalGlide(); if (BeforeFinalGlide) { Interval_Notification = fixed(60 * 5); if ((tad > fixed(50)) && (last_tad < fixed(-50))) // report above final glide early return true; else if (tad < fixed(-50)) last_tad = tad; } else { Interval_Notification = fixed(60); if (res.IsFinalGlide()) { if ((last_tad < fixed(-50)) && (tad > fixed_one)) // just reached final glide, previously well below return true; if ((last_tad > fixed_one) && (tad < fixed(-50))) { // dropped well below final glide, previously above last_tad = tad; return true; // JMW this was true before } } } return false; }
bool ConditionMonitorStartRules::CheckCondition(const GlideComputer& cmp) { #ifdef OLD_TASK // start condition warnings if (!task.Valid() || !cmp.Basic().flying || (task.getActiveIndex() > 0) || !task.ValidTaskPoint(task.getActiveIndex() + 1)) return false; if (cmp.Calculated().LegDistanceToGo > task.getSettings().StartRadius) return false; if (cmp.ValidStartSpeed(task.getSettings().StartMaxSpeedMargin) && cmp.InsideStartHeight(task.getSettings().StartMaxHeightMargin)) withinMargin = true; else withinMargin = false; }
static void LoadReplay(DebugReplay *replay, GlideComputer &glide_computer, InterfaceBlackboard &blackboard) { unsigned i = 0; while (replay->Next()) { const MoreData &basic = replay->Basic(); glide_computer.ReadBlackboard(basic); glide_computer.ProcessGPS(); if (++i == 8) { i = 0; glide_computer.ProcessIdle(); } } glide_computer.ProcessExhaustive(); blackboard.ReadBlackboardBasic(glide_computer.Basic()); blackboard.ReadBlackboardCalculated(glide_computer.Calculated()); }
void ConditionMonitor::Update(const GlideComputer& cmp) { if (!cmp.Calculated().flight.flying) return; bool restart = false; const fixed Time = cmp.Basic().time; if (Ready_Time_Check(Time, &restart)) { LastTime_Check = Time; if (CheckCondition(cmp)) { if (Ready_Time_Notification(Time) && !restart) { LastTime_Notification = Time; Notify(); SaveLast(); } } if (restart) SaveLast(); } }