按前序结果后的有效片段时长触发首次时序检查
This commit is contained in:
parent
0133a199a4
commit
1edcd1ce06
@ -190,9 +190,12 @@ public partial class SopEngine
|
||||
var selected = InspectionFrameSelector.Select(valid, state.Inspected, state.Boundaries, options.ObservationMinMs / 1000d, finalChance || followNewResult);
|
||||
frames = selected is null ? [] : [selected];
|
||||
}
|
||||
var eof = capture is null && crop is null;
|
||||
var processReady = frames.Length >= 3 && (eof || state.Window.Ready
|
||||
&& ObservationEvidenceWindow.Time(frames[^1]) - ObservationEvidenceWindow.Time(frames[0]) >= options.ObservationMinMs / 1000d);
|
||||
if (frames.Length == 0 || state.Inspected.ContainsKey(frames[^1].FrameId)
|
||||
|| options.EvidenceMode == VisionEvidenceMode.Sequence && state.Window.Version <= state.SentVersion
|
||||
|| options.EvidenceMode == VisionEvidenceMode.Sequence && (frames.Length < 3 || !state.Window.Ready))
|
||||
|| options.EvidenceMode == VisionEvidenceMode.Sequence && !processReady)
|
||||
return new() { Message = $"窗口内观察,优先在手部停稳或离开后检查(已送检 {state.Attempts}/{options.MaxChecks} 次)" };
|
||||
var last = frames[^1];
|
||||
var request = new VisionDecisionRequest(_config.Sop.Name, step.Id, step.Name, step.Description, step.Description,
|
||||
|
||||
@ -13,6 +13,7 @@ internal static class ContinuousCheckTests
|
||||
}
|
||||
private sealed class Client : IVisionDecisionClient
|
||||
{
|
||||
public bool SupportsSequences => true;
|
||||
public ConcurrentQueue<(VisionDecisionRequest Request, TaskCompletionSource<VisionDecisionResult> Result)> Calls = new();
|
||||
public Task<VisionDecisionResult> DecideAsync(VisionDecisionRequest request, CancellationToken token)
|
||||
{
|
||||
@ -115,6 +116,25 @@ internal static class ContinuousCheckTests
|
||||
Check(following.State == EngineState.Running && hinted.Calls.ElementAt(2).Request.FrameId == 4,
|
||||
"低于阈值的正向线索不能放行,但下一次检查应跟进新结果,不能回退到较早历史帧");
|
||||
following.Stop();
|
||||
var temporalConfig = Config();
|
||||
temporalConfig.Sop.Steps[0].AiConfirmation = new() { CheckWindowMs = 10000, CheckSettleMs = 2500, ObservationMinMs = 5000 };
|
||||
temporalConfig.Sop.Steps[1].AiConfirmation = new() { CheckWindowMs = 10000, EvidenceMode = VisionEvidenceMode.Sequence };
|
||||
var temporalClient = new Client(); var temporal = new SopEngine { VisionDecisionClient = temporalClient };
|
||||
temporal.Load(temporalConfig); temporal.Start(); var frameIndex = 0;
|
||||
void TemporalFeed(double seconds, int x = 120) => temporal.ProcessFrame(Frame(frameIndex++, seconds, x), () => [(byte)frameIndex]);
|
||||
TemporalFeed(0, 10);
|
||||
foreach (var seconds in new[] { .4, .8, 1.2, 1.6, 2.0, 2.4, 2.8 }) TemporalFeed(seconds);
|
||||
await Until(() => temporalClient.Calls.Count == 1);
|
||||
Check(temporalClient.Calls.ElementAt(0).Request.SourceSeconds == 2.8, "测试前序结果必须来自实际较晚帧");
|
||||
temporalClient.Calls.ElementAt(0).Result.SetResult(new(true, .99, "前序完成"));
|
||||
await Until(() => { temporal.ProcessFrame(Frame(frameIndex, 2.8, 120)); return temporal.CurrentStep?.Id == 2; });
|
||||
foreach (var seconds in new[] { 3.2, 3.6, 4.0 }) TemporalFeed(seconds);
|
||||
Check(temporalClient.Calls.Count == 1, "预热窗口就绪不代表前序完成后的有效过程片段已经足够,不能只看三张图就送检");
|
||||
foreach (var seconds in new[] { 4.4, 4.8, 5.3, 5.8 }) TemporalFeed(seconds);
|
||||
await Until(() => temporalClient.Calls.Count == 2);
|
||||
var effective = temporalClient.Calls.ElementAt(1).Request.Frames!;
|
||||
Check(effective[^1].SourceSeconds - effective[0].SourceSeconds >= 2.4, "首次过程检查必须覆盖配置要求的实际有效片段时长");
|
||||
temporal.Stop();
|
||||
Console.WriteLine("PASS: 停稳触发、新帧重试、限时跳过、后续动作持续取证、挂起硬截止、迟到结果隔离和非合格整轮统计");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user