对未达阈值的正向线索继续跟进新结果而不提前放行
This commit is contained in:
parent
2ed2b235a6
commit
0133a199a4
@ -21,7 +21,7 @@ public partial class SopEngine
|
||||
ObservationMaxMs = 60000,
|
||||
ObservationMaxFrames = step.AiConfirmation.ObservationMaxFrames,
|
||||
});
|
||||
public bool Triggered, SawQuiet, BudgetStarted, StoredBoundary, StoredOutside;
|
||||
public bool Triggered, SawQuiet, BudgetStarted, StoredBoundary, StoredOutside, FollowCurrentResult;
|
||||
public double? OutsideSince;
|
||||
public List<VisionEvidenceFrame> Boundaries = [];
|
||||
public Dictionary<long, double> Inspected = [];
|
||||
@ -146,6 +146,9 @@ public partial class SopEngine
|
||||
_acceptedEvidenceTimes[_index] = evaluated.SourceSeconds ?? (evaluated.CapturedAt - DateTime.UnixEpoch).TotalSeconds;
|
||||
return new() { IsMet = true, Message = $"窗口内第 {state.Attempts} 次检查通过:{result.Reason}" };
|
||||
}
|
||||
// 已识别到结果但未达放行门槛时,继续观察新结果,不把下一次机会用于无关旧图。
|
||||
state.FollowCurrentResult = options.EvidenceMode == VisionEvidenceMode.SingleFrame
|
||||
&& result.Completed && result.EffectiveStatus == VisionDecisionStatus.Completed;
|
||||
}
|
||||
if (expired)
|
||||
{
|
||||
@ -182,7 +185,9 @@ public partial class SopEngine
|
||||
DecisionCandidatesObserved?.Invoke(step.Id, valid);
|
||||
// 硬截止前的最后检查机会优先看正在形成的新结果,不再全部用于补查历史。
|
||||
var finalChance = options.CheckWindowMs - state.ElapsedMs <= firstWait;
|
||||
var selected = InspectionFrameSelector.Select(valid, state.Inspected, state.Boundaries, options.ObservationMinMs / 1000d, finalChance);
|
||||
var followNewResult = state.FollowCurrentResult && valid.Any(f => ObservationEvidenceWindow.Time(f)
|
||||
> state.Inspected.Values.DefaultIfEmpty(double.NegativeInfinity).Max());
|
||||
var selected = InspectionFrameSelector.Select(valid, state.Inspected, state.Boundaries, options.ObservationMinMs / 1000d, finalChance || followNewResult);
|
||||
frames = selected is null ? [] : [selected];
|
||||
}
|
||||
if (frames.Length == 0 || state.Inspected.ContainsKey(frames[^1].FrameId)
|
||||
|
||||
@ -100,6 +100,21 @@ internal static class ContinuousCheckTests
|
||||
SameFeed(4, .5, 35);
|
||||
Check(secondTriggered, "同区域停稳后开始新运动,应能触发下一步,不能强求手离开操作区");
|
||||
same.Stop();
|
||||
var hintConfig = Config(1); hintConfig.Sop.Steps[0].AiConfirmation!.MaxChecks = 3;
|
||||
var hinted = new Client(); var following = new SopEngine { VisionDecisionClient = hinted };
|
||||
following.Load(hintConfig); following.Start(); var hintResults = 0;
|
||||
following.DecisionEvaluated += (_, _, _) => hintResults++;
|
||||
void HintFeed(int id, double seconds) => following.ProcessFrame(Frame(id, seconds, 10), () => [(byte)id]);
|
||||
HintFeed(0, 0); HintFeed(1, .2); await Until(() => hinted.Calls.Count == 1);
|
||||
HintFeed(2, .4); hinted.Calls.ElementAt(0).Result.SetResult(new(true, .7, "结果尚不够清晰"));
|
||||
await Until(() => { following.ProcessFrame(Frame(2, .4, 10)); return hintResults == 1; });
|
||||
await Until(() => { following.ProcessFrame(Frame(2, .4, 10)); return hinted.Calls.Count == 2; });
|
||||
HintFeed(3, .6); HintFeed(4, .8); hinted.Calls.ElementAt(1).Result.SetResult(new(true, .7, "仍未达到完成门槛"));
|
||||
await Until(() => { following.ProcessFrame(Frame(4, .8, 10)); return hintResults == 2; });
|
||||
await Until(() => { following.ProcessFrame(Frame(4, .8, 10)); return hinted.Calls.Count == 3; });
|
||||
Check(following.State == EngineState.Running && hinted.Calls.ElementAt(2).Request.FrameId == 4,
|
||||
"低于阈值的正向线索不能放行,但下一次检查应跟进新结果,不能回退到较早历史帧");
|
||||
following.Stop();
|
||||
Console.WriteLine("PASS: 停稳触发、新帧重试、限时跳过、后续动作持续取证、挂起硬截止、迟到结果隔离和非合格整轮统计");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user