From 0b04d000e80265db36ce3fd5e9cbe828730e1024 Mon Sep 17 00:00:00 2001
From: tfarcraw <123211521@163.com>
Date: Thu, 19 Nov 2026 14:30:07 +0800
Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=81=9C=E7=A8=B3=E7=AD=89?=
=?UTF-8?q?=E5=BE=85=E9=85=8D=E7=BD=AE=E5=B9=B6=E7=BB=9F=E4=B8=80=E5=86=85?=
=?UTF-8?q?=E9=83=A8=E9=BB=98=E8=AE=A4=E6=97=B6=E5=BA=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../VVMs/RecipeEditor/EditorNodes.cs | 9 ++++----
.../VVMs/RecipeEditor/RecipeEditor.axaml | 4 ----
.../RecipeEditor/SopVideoAgentViewModel.cs | 4 ++--
.../Sop/SopEngine.ContinuousChecks.cs | 11 +++++----
.../Sop/VisionDecision.cs | 2 --
.../SopAgent/SopStepDesignPrompt.cs | 2 +-
.../SopAgent/SopVideoDraftClient.cs | 6 ++---
.../InspectionPolicyChecks.cs | 7 +++---
tests/VideoFlowTest.Smoke/Program.cs | 5 ++--
.../VideoFlowTest.Smoke/StepTransferChecks.cs | 2 +-
.../ContinuousCheckTests.cs | 23 ++++++++++---------
11 files changed, 34 insertions(+), 41 deletions(-)
diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/EditorNodes.cs b/src/SopHelper.Avalonia/VVMs/RecipeEditor/EditorNodes.cs
index 9e1b868..4a2a474 100644
--- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/EditorNodes.cs
+++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/EditorNodes.cs
@@ -425,7 +425,7 @@ public class RecipeNode : EditorNode
AiConfirmation = step.AiConfirmation is null ? null : new AiConfirmation
{
MinConfidence = step.AiConfirmation.MinConfidence,
- CheckWindowMs = step.AiConfirmation.CheckWindowMs, CheckSettleMs = step.AiConfirmation.CheckSettleMs,
+ CheckWindowMs = step.AiConfirmation.CheckWindowMs,
EvidenceMode = step.AiConfirmation.EvidenceMode,
ObservationPreRollMs = step.AiConfirmation.ObservationPreRollMs, ObservationMinMs = step.AiConfirmation.ObservationMinMs,
ObservationMaxMs = step.AiConfirmation.ObservationMaxMs, ObservationSampleMs = step.AiConfirmation.ObservationSampleMs,
@@ -495,7 +495,7 @@ public class RecipeNode : EditorNode
AiConfirmation = new AiConfirmation
{
MinConfidence = step.AiMinConfidence,
- CheckWindowMs = step.AiCheckWindowMs, CheckSettleMs = step.AiCheckSettleMs,
+ CheckWindowMs = step.AiCheckWindowMs,
EvidenceMode = step.AiEvidenceMode, ObservationPreRollMs = step.AiObservationPreRollMs,
ObservationMinMs = step.AiObservationMinMs, ObservationMaxMs = step.AiObservationMaxMs,
ObservationSampleMs = step.AiObservationSampleMs, ObservationMaxFrames = step.AiObservationMaxFrames, ObservationRequestMaxFrames = step.AiObservationRequestMaxFrames,
@@ -825,10 +825,9 @@ public class StepNode : EditorNode
public double? KeyFrameSeconds { get => _keyFrameSeconds; set { if (SetProperty(ref _keyFrameSeconds, value)) RaisePropertyChanged(nameof(KeyFrameLabel)); } }
public string KeyFrameLabel => string.IsNullOrEmpty(KeyFrameBase64) ? "尚未保存关键帧" : $"已保存关键帧:{KeyFrameSeconds:0.###} 秒(保存配方后持久化)";
- private int _aiCheckWindowMs = 10000, _aiCheckSettleMs = 100;
+ private int _aiCheckWindowMs = 10000;
public int AiCheckWindowMs { get => _aiCheckWindowMs; set { if (SetProperty(ref _aiCheckWindowMs, value)) RaisePropertyChanged(nameof(AiContinueAfterWindow)); } }
public bool AiContinueAfterWindow { get => AiCheckWindowMs > 0; set { if (value != AiContinueAfterWindow) AiCheckWindowMs = value ? 10000 : 0; } }
- public int AiCheckSettleMs { get => _aiCheckSettleMs; set => SetProperty(ref _aiCheckSettleMs, value); }
private string _aiEvidenceMode = VisionEvidenceMode.SingleFrame;
private int _aiObservationPreRollMs = 1000, _aiObservationMinMs = 2400, _aiObservationMaxMs = 10000,
_aiObservationSampleMs = 400, _aiObservationMaxFrames = 24, _aiObservationRequestMaxFrames = 12;
@@ -867,7 +866,7 @@ public class StepNode : EditorNode
{
if (value is null) return;
AiMinConfidence = value.MinConfidence;
- AiCheckWindowMs = value.CheckWindowMs; AiCheckSettleMs = value.CheckSettleMs;
+ AiCheckWindowMs = value.CheckWindowMs;
AiEvidenceMode = value.EvidenceMode; AiObservationPreRollMs = value.ObservationPreRollMs;
AiObservationMinMs = value.ObservationMinMs; AiObservationMaxMs = value.ObservationMaxMs;
AiObservationSampleMs = value.ObservationSampleMs; AiObservationMaxFrames = value.ObservationMaxFrames; AiObservationRequestMaxFrames = value.ObservationRequestMaxFrames;
diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml
index e503e6f..03a4d6f 100644
--- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml
+++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml
@@ -173,10 +173,6 @@
-
-
-
-
diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/SopVideoAgentViewModel.cs b/src/SopHelper.Avalonia/VVMs/RecipeEditor/SopVideoAgentViewModel.cs
index ee49505..676da6c 100644
--- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/SopVideoAgentViewModel.cs
+++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/SopVideoAgentViewModel.cs
@@ -418,7 +418,7 @@ public partial class RecipeEditorViewModel
step.StableFrames = node.Detection?.StableFrames; step.Tolerance = node.Detection?.Tolerance;
step.ImageMode = node.AiImageMode; step.ImageRegion = node.AiImageRegion;
step.Inspection = new() { EvidenceMode = node.AiEvidenceMode, CheckWindowMs = node.AiCheckWindowMs > 0 ? node.AiCheckWindowMs : null,
- CheckSettleMs = node.AiCheckSettleMs, ObservationMinMs = node.AiObservationMinMs,
+ ObservationMinMs = node.AiObservationMinMs,
ObservationMaxMs = node.AiObservationMaxMs, ObservationMaxFrames = node.AiObservationMaxFrames,
ObservationRequestMaxFrames = node.AiObservationRequestMaxFrames };
}
@@ -433,7 +433,7 @@ public partial class RecipeEditorViewModel
{
var ai = step.AiConfirmation!;
return new SopAgentImageScope(index + 1, VisionImageMode.Resolve(ai), ai.ImageRegion,
- ai.HandPadding, ai.HandMinSize, ai.HandMemoryMs, ai.EvidenceMode, ai.CheckWindowMs, ai.CheckSettleMs,
+ ai.HandPadding, ai.HandMinSize, ai.HandMemoryMs, ai.EvidenceMode, ai.CheckWindowMs,
ai.ObservationMaxMs, ai.ObservationMaxFrames, ai.ObservationRequestMaxFrames, ai.TimeoutSeconds);
}).ToArray();
}
diff --git a/src/SopHelper.CrossPlatform.Engine/Sop/SopEngine.ContinuousChecks.cs b/src/SopHelper.CrossPlatform.Engine/Sop/SopEngine.ContinuousChecks.cs
index 8ea9c75..775c0f8 100644
--- a/src/SopHelper.CrossPlatform.Engine/Sop/SopEngine.ContinuousChecks.cs
+++ b/src/SopHelper.CrossPlatform.Engine/Sop/SopEngine.ContinuousChecks.cs
@@ -4,6 +4,7 @@ namespace SopHelper.Engine.Sop;
public partial class SopEngine
{
+ private const int HandSettleMs = 100;
private readonly Dictionary _continuousChecks = [];
public event Action>? DecisionCandidatesObserved;
private double PriorCompletedEvidenceTime() => _acceptedEvidenceTimes.Where(p => p.Key < _index)
@@ -72,7 +73,7 @@ public partial class SopEngine
state.LastMotionSeconds = seconds; state.Anchors = selected;
state.StoredBoundary = false;
}
- else if ((seconds - state.LastMotionSeconds) * 1000 >= state.Step.AiConfirmation!.CheckSettleMs)
+ else if ((seconds - state.LastMotionSeconds) * 1000 >= HandSettleMs)
state.SawQuiet = true;
var trigger = EvaluateCaptureGate(state.Step, frame, state.Gate, "continuous");
if (trigger.IsMet && !state.GateWasMet)
@@ -92,9 +93,9 @@ public partial class SopEngine
if (state.Triggered && state.ElapsedMs >= state.Step.AiConfirmation!.CheckWindowMs) return;
if (IsHandInside(state.Step, frame)) { state.OutsideSince = null; state.StoredOutside = false; }
else state.OutsideSince ??= seconds;
- var quietBoundary = !state.StoredBoundary && (seconds - state.LastMotionSeconds) * 1000 >= state.Step.AiConfirmation!.CheckSettleMs;
+ var quietBoundary = !state.StoredBoundary && (seconds - state.LastMotionSeconds) * 1000 >= HandSettleMs;
var outsideBoundary = !state.StoredOutside && state.OutsideSince is { } outside
- && (seconds - outside) * 1000 >= state.Step.AiConfirmation!.CheckSettleMs;
+ && (seconds - outside) * 1000 >= HandSettleMs;
if (state.Triggered && (quietBoundary || outsideBoundary) && state.Step.AiConfirmation!.EvidenceMode == VisionEvidenceMode.SingleFrame)
{
var boundary = CaptureDecision(state.Step, frame, state.Gate.HandRegion, capture, crop, out _, notify: false);
@@ -180,11 +181,11 @@ public partial class SopEngine
if (client is null || options.EvidenceMode == VisionEvidenceMode.Sequence && !client.SupportsSequences)
{ state.Reason = "检查服务未配置或不支持所需证据"; return new() { Message = state.Reason + ";窗口到期后记录未通过并继续" }; }
if (state.Window.Error is { } error) { state.Reason = error; return new() { Message = error }; }
- var quiet = (state.LatestSeconds - state.LastMotionSeconds) * 1000 >= options.CheckSettleMs;
+ var quiet = (state.LatestSeconds - state.LastMotionSeconds) * 1000 >= HandSettleMs;
// 按配置间隔检查当前新图,不能为历史补判扩大等待时间。
var interval = Math.Max(50, options.RetryDelayMs);
var sinceRequest = state.Attempts == 0 ? state.ElapsedMs : Environment.TickCount64 - state.LastSubmittedAt;
- var firstWait = Math.Min(interval, Math.Max(50, options.CheckSettleMs));
+ var firstWait = Math.Min(interval, Math.Max(50, HandSettleMs));
var freshEvent = discrete && state.LatestTriggerSeconds > state.LastSubmittedSourceSeconds
&& sinceRequest >= Math.Max(50, options.RetryDelayMs);
var timeToCheck = state.Attempts == 0 ? quiet || sinceRequest >= firstWait : sinceRequest >= interval || freshEvent;
diff --git a/src/SopHelper.CrossPlatform.Engine/Sop/VisionDecision.cs b/src/SopHelper.CrossPlatform.Engine/Sop/VisionDecision.cs
index 064e783..11551b7 100644
--- a/src/SopHelper.CrossPlatform.Engine/Sop/VisionDecision.cs
+++ b/src/SopHelper.CrossPlatform.Engine/Sop/VisionDecision.cs
@@ -8,7 +8,6 @@ public sealed class AiConfirmation
{
/// 0 保留原来的等待策略;正值为触发后的检查预算,到期未确认则跳过。
public int CheckWindowMs { get; set; }
- public int CheckSettleMs { get; set; } = 100;
public string EvidenceMode { get; set; } = VisionEvidenceMode.SingleFrame;
public int ObservationPreRollMs { get; set; } = 1000;
public int ObservationMinMs { get; set; } = 2400;
@@ -33,7 +32,6 @@ public static class VisionEvidenceMode
public const string SingleFrame = "single_frame", Sequence = "sequence";
public static bool IsCheckPolicyValid(AiConfirmation options) => options.CheckWindowMs == 0
|| options.CheckWindowMs is >= 500 and <= 60000
- && options.CheckSettleMs is >= 100 and <= 3000 && options.CheckSettleMs < options.CheckWindowMs
&& IsObservationValid(options);
public static bool IsValid(AiConfirmation options) => options.EvidenceMode == SingleFrame
|| options.EvidenceMode == Sequence && IsObservationValid(options);
diff --git a/src/SopHelper.CrossPlatform.Engine/SopAgent/SopStepDesignPrompt.cs b/src/SopHelper.CrossPlatform.Engine/SopAgent/SopStepDesignPrompt.cs
index 34e692e..b7f7b43 100644
--- a/src/SopHelper.CrossPlatform.Engine/SopAgent/SopStepDesignPrompt.cs
+++ b/src/SopHelper.CrossPlatform.Engine/SopAgent/SopStepDesignPrompt.cs
@@ -18,7 +18,7 @@ public static class SopStepDesignPrompt
- 触发区和送检区可以独立。image_mode=fixed_region/full_frame/hand,image_region须覆盖完整验收关系;局部细节优先清晰ROI,整体位置需要完整空间上下文。默认主区域,hand_move默认终点,禁止假设跟手范围必然覆盖主体。
- 已缓存的旧图不能排队补判为实时通过;运行仅检查新鲜单图,记录触发/取图/提交/返回时间、图片数量、耗时和超时。
- inspection:evidence_mode只能为single_frame;check_window_ms=500–60000为本步多次观察总窗口,不是单次模型耗时;check_settle_ms=100–3000且小于总窗口。新步骤默认观察10秒、停稳100ms;每次dlite最多500ms,超时不延长。人的动作连续,不能让人停下来等待;适时取新图复查,仅在窗口到期仍未通过时跳过,不限制检查次数,整轮不计合格。
+ inspection:evidence_mode只能为single_frame;check_window_ms=500–60000为本步多次观察总窗口,不是单次模型耗时。新步骤默认观察10秒;每次dlite最多500ms,超时不延长。人的动作连续,不能让人停下来等待;适时取新图复查,仅在窗口到期仍未通过时跳过,不限制检查次数,整轮不计合格。
提交前核对:全程操作完整、有据、有序不重叠、区域有效、单图可辨、触发对应本步、正反状态可区分。仅为具体缺口补看,不重复读清楚的图,不凭措辞修改反复调用工具。步骤生成和dlite回测是独立操作。
""";
}
diff --git a/src/SopHelper.CrossPlatform.Engine/SopAgent/SopVideoDraftClient.cs b/src/SopHelper.CrossPlatform.Engine/SopAgent/SopVideoDraftClient.cs
index ee7cbd5..2ca8fe5 100644
--- a/src/SopHelper.CrossPlatform.Engine/SopAgent/SopVideoDraftClient.cs
+++ b/src/SopHelper.CrossPlatform.Engine/SopAgent/SopVideoDraftClient.cs
@@ -21,7 +21,7 @@ public sealed record SopVideoAnalysisRequest(string Recipe, string Instructions,
public sealed record SopAgentPrompt(int Round, long EstimatedTokens, int ContextLength, string Compression, string Text);
public sealed record SopAgentTrace(string Kind, int Round, string Text, IReadOnlyList? Images = null);
public sealed record SopAgentTraceImage(string Name, byte[] Jpeg);
-public sealed record SopAgentImageScope(int StepIndex, string Mode, string Region, int HandPadding, int HandMinSize, int HandMemoryMs, string EvidenceMode = VisionEvidenceMode.SingleFrame, int CheckWindowMs = 0, int CheckSettleMs = 350, int ObservationMaxMs = 10000, int ObservationMaxFrames = 24, int ObservationRequestMaxFrames = 12, int TimeoutSeconds = 30);
+public sealed record SopAgentImageScope(int StepIndex, string Mode, string Region, int HandPadding, int HandMinSize, int HandMemoryMs, string EvidenceMode = VisionEvidenceMode.SingleFrame, int CheckWindowMs = 0, int ObservationMaxMs = 10000, int ObservationMaxFrames = 24, int ObservationRequestMaxFrames = 12, int TimeoutSeconds = 30);
public sealed record SopAgentChatTurn(string Role, string Text);
public sealed record SopAgentChatResult(string Reply, SopVideoDraft? Draft, IReadOnlyList ObservedFrames);
public sealed class SopVideoDraft
@@ -59,7 +59,6 @@ public sealed class SopDraftInspectionPolicy
{
[JsonPropertyName("evidence_mode")] public string? EvidenceMode { get; set; }
[JsonPropertyName("check_window_ms")] public int? CheckWindowMs { get; set; }
- [JsonPropertyName("check_settle_ms")] public int? CheckSettleMs { get; set; }
[JsonPropertyName("observation_min_ms")] public int? ObservationMinMs { get; set; }
[JsonPropertyName("observation_max_ms")] public int? ObservationMaxMs { get; set; }
[JsonPropertyName("observation_max_frames")] public int? ObservationMaxFrames { get; set; }
@@ -69,7 +68,6 @@ public sealed class SopDraftInspectionPolicy
{
target.EvidenceMode = EvidenceMode ?? target.EvidenceMode;
target.CheckWindowMs = CheckWindowMs ?? target.CheckWindowMs;
- target.CheckSettleMs = CheckSettleMs ?? target.CheckSettleMs;
target.ObservationMinMs = ObservationMinMs ?? target.ObservationMinMs;
target.ObservationMaxMs = ObservationMaxMs ?? target.ObservationMaxMs;
target.ObservationMaxFrames = ObservationMaxFrames ?? target.ObservationMaxFrames;
@@ -79,7 +77,7 @@ public sealed class SopDraftInspectionPolicy
public static SopDraftInspectionPolicy From(AiConfirmation options) => new()
{
EvidenceMode = options.EvidenceMode, CheckWindowMs = options.CheckWindowMs > 0 ? options.CheckWindowMs : null,
- CheckSettleMs = options.CheckSettleMs, ObservationMinMs = options.ObservationMinMs,
+ ObservationMinMs = options.ObservationMinMs,
ObservationMaxMs = options.ObservationMaxMs, ObservationMaxFrames = options.ObservationMaxFrames,
ObservationRequestMaxFrames = options.ObservationRequestMaxFrames
};
diff --git a/tests/SopVideoAgent.Smoke/InspectionPolicyChecks.cs b/tests/SopVideoAgent.Smoke/InspectionPolicyChecks.cs
index 479af89..ce943b4 100644
--- a/tests/SopVideoAgent.Smoke/InspectionPolicyChecks.cs
+++ b/tests/SopVideoAgent.Smoke/InspectionPolicyChecks.cs
@@ -10,9 +10,10 @@ internal static class InspectionPolicyChecks
template.Sop.Steps = [new() { AiConfirmation = new() { MinConfidence = .94, RetryDelayMs = 4100 } }];
var draft = new SopVideoDraft { Steps = [new() { Inspection = new() { EvidenceMode = "sequence",
CheckWindowMs = 22000, ObservationMaxFrames = 24, ObservationRequestMaxFrames = 9 } }] };
- var legacy = JsonSerializer.Deserialize("""{"check_window_ms":10000,"max_checks":1}""")!;
+ var legacy = JsonSerializer.Deserialize("""{"check_window_ms":10000,"max_checks":1,"check_settle_ms":3000}""")!;
SopVideoDraftClient.ValidateInspection(legacy);
- Check(!JsonSerializer.Serialize(legacy).Contains("max_checks"), "旧草稿次数参数应被忽略且不再输出");
+ Check(!JsonSerializer.Serialize(legacy).Contains("max_checks")
+ && !JsonSerializer.Serialize(legacy).Contains("check_settle_ms"), "旧草稿次数和停稳参数应被忽略且不再输出");
var before = SopConfigLoader.ToYaml(template);
var roundTrip = JsonSerializer.Deserialize(JsonSerializer.Serialize(draft))!;
var config = SopDraftConfigBuilder.Build(template, roundTrip);
@@ -26,7 +27,7 @@ internal static class InspectionPolicyChecks
Reject(() => SopVideoDraftClient.ValidateCapabilities(draft, request with { CurrentDraft = draft }), "旧草稿不能豁免单图要求");
foreach (var invalid in new SopDraftInspectionPolicy[] {
new() { EvidenceMode = "unknown" }, new() { CheckWindowMs = 0 },
- new() { CheckWindowMs = 500, CheckSettleMs = 600 }, new() { ObservationMinMs = 11000 },
+ new() { CheckWindowMs = 499 }, new() { ObservationMinMs = 11000 },
new() { ObservationRequestMaxFrames = 33 }, new() { ObservationMaxFrames = 2 } })
Reject(() => SopVideoDraftClient.ValidateInspection(invalid), "非法策略不能进入回测或配方");
template.Sop.Steps = [];
diff --git a/tests/VideoFlowTest.Smoke/Program.cs b/tests/VideoFlowTest.Smoke/Program.cs
index 250441f..bb1341b 100644
--- a/tests/VideoFlowTest.Smoke/Program.cs
+++ b/tests/VideoFlowTest.Smoke/Program.cs
@@ -53,15 +53,14 @@ internal static class Program
var config = new SopConfig();
config.Sop.Steps.Add(new() { Id = 1, Description = "状态变化", AiConfirmation = new()
{ EvidenceMode = VisionEvidenceMode.Sequence, ObservationMinMs = 1800, ObservationMaxFrames = 13, ObservationRequestMaxFrames = 7, ObservationSampleMs = 300,
- CheckWindowMs = 7000, CheckSettleMs = 450 } });
+ CheckWindowMs = 7000 } });
var editor = RecipeNode.From(config, "试验.yaml", false);
Check(editor.Steps[0].UsesSequenceEvidence, "编辑器须识别过程时序模式");
var restored = SopConfigLoader.Parse(SopConfigLoader.ToYaml(editor.ToConfig())).Sop.Steps[0].AiConfirmation!;
Check(restored.EvidenceMode == VisionEvidenceMode.Sequence && restored.ObservationMinMs == 1800
&& restored.ObservationMaxFrames == 13 && restored.ObservationRequestMaxFrames == 7 && restored.ObservationSampleMs == 300,
"编辑保存不得丢失时序模式、缓存容量与单次请求预算");
- Check(editor.Steps[0].AiContinueAfterWindow && restored.CheckWindowMs == 7000
- && restored.CheckSettleMs == 450, "编辑保存须保留连续操作限时复检参数");
+ Check(editor.Steps[0].AiContinueAfterWindow && restored.CheckWindowMs == 7000, "编辑保存须保留连续操作限时复检参数");
editor.Steps[0].AiContinueAfterWindow = false;
Check(editor.ToConfig().Sop.Steps[0].AiConfirmation!.CheckWindowMs == 0, "关闭限时复检须恢复原等待策略");
Console.WriteLine("PASS: 编辑器过程时序模式及观察参数往返保留");
diff --git a/tests/VideoFlowTest.Smoke/StepTransferChecks.cs b/tests/VideoFlowTest.Smoke/StepTransferChecks.cs
index a5ce51a..101ba83 100644
--- a/tests/VideoFlowTest.Smoke/StepTransferChecks.cs
+++ b/tests/VideoFlowTest.Smoke/StepTransferChecks.cs
@@ -17,7 +17,7 @@ internal static class StepTransferChecks
ViolationRules = [new() { Type = "object_removed", Description = "工具移除", Severity = 3 }],
Detection = new() { Method = "hand_move", FromRegion = "start", ToRegion = "finish", Hand = "left", StableFrames = 7, Tolerance = 9, MinConfidence = .81f },
AiConfirmation = new() { EvidenceMode = "sequence", ImageMode = "fixed_region", ImageRegion = "inspect_area", CheckWindowMs = 32900,
- CheckSettleMs = 550, ObservationMaxFrames = 26, ObservationRequestMaxFrames = 9, MinConfidence = .94,
+ ObservationMaxFrames = 26, ObservationRequestMaxFrames = 9, MinConfidence = .94,
TimeoutSeconds = 25, RetryDelayMs = 1700, HandPadding = 180, HandMemoryMs = 2400 } }];
var original = JsonSerializer.Serialize(source);
var text = SopStepTransfer.Export(source);
diff --git a/tests/VisionDecision.Smoke/ContinuousCheckTests.cs b/tests/VisionDecision.Smoke/ContinuousCheckTests.cs
index e64ab3f..388e164 100644
--- a/tests/VisionDecision.Smoke/ContinuousCheckTests.cs
+++ b/tests/VisionDecision.Smoke/ContinuousCheckTests.cs
@@ -1,4 +1,4 @@
-using System.Collections.Concurrent;
+using System.Collections.Concurrent;
using SopHelper.Engine.Common;
using SopHelper.Engine.Sop;
@@ -28,7 +28,7 @@ internal static class ContinuousCheckTests
config.Sop.Regions["r" + i] = new() { X1 = i * 100, Y1 = 0, X2 = i * 100 + 90, Y2 = 100 };
config.Sop.Steps.Add(new() { Id = i + 1, Name = "工序" + i, Description = "结果到位",
Detection = new() { Method = ConditionMethod.HandInRegion, Region = "r" + i, Hand = "right", StableFrames = 1 },
- AiConfirmation = new() { CheckWindowMs = 2000, CheckSettleMs = 150,
+ AiConfirmation = new() { CheckWindowMs = 2000,
RetryDelayMs = 500, ObservationSampleMs = 100 } });
}
return config;
@@ -42,9 +42,10 @@ internal static class ContinuousCheckTests
var unlimitedConfig = Config(1);
unlimitedConfig.Sop.Steps[0].AiConfirmation!.CheckWindowMs = 10000;
unlimitedConfig.Sop.Steps[0].AiConfirmation!.RetryDelayMs = 50;
- var legacyYaml = SopConfigLoader.ToYaml(unlimitedConfig).Replace("check_window_ms: 10000", "check_window_ms: 10000\n max_checks: 1");
+ var legacyYaml = SopConfigLoader.ToYaml(unlimitedConfig).Replace("check_window_ms: 10000", "check_window_ms: 10000\n max_checks: 1\n check_settle_ms: 3000");
var legacyConfig = SopConfigLoader.Parse(legacyYaml);
- Check(!SopConfigLoader.ToYaml(legacyConfig).Contains("max_checks"), "旧次数参数须忽略且不再保存");
+ Check(!SopConfigLoader.ToYaml(legacyConfig).Contains("max_checks")
+ && !SopConfigLoader.ToYaml(legacyConfig).Contains("check_settle_ms"), "旧次数和停稳参数须忽略且不再保存");
var unlimitedClient = new Client();
var unlimited = new SopEngine { VisionDecisionClient = unlimitedClient };
unlimited.Load(legacyConfig); unlimited.Start();
@@ -79,7 +80,7 @@ internal static class ContinuousCheckTests
engine.StepSnapshotChanged += snapshots.Add; engine.DecisionEvaluated += (_, _, _) => evaluated++;
engine.ViolationRaised += _ => alarms++; engine.RoundFinished += result => passed = result;
void Feed(int id, double seconds, int x) => engine.ProcessFrame(Frame(id, seconds, x), () => [(byte)id]);
- Feed(1, 0, 10); Feed(2, .1, 30);
+ Feed(1, 0, 10); Feed(2, .05, 30);
Check(client.Calls.Count == 0, "进入后仍在移动不能立即检查");
Feed(3, .3, 30); await Until(() => client.Calls.Count == 1);
var first = client.Calls.ElementAt(0);
@@ -147,13 +148,13 @@ internal static class ContinuousCheckTests
"低于阈值的正向线索不能放行,但下一次检查应跟进新结果,不能回退到较早历史帧");
following.Stop();
var temporalConfig = Config();
- temporalConfig.Sop.Steps[0].AiConfirmation = new() { CheckWindowMs = 10000, CheckSettleMs = 2500, RetryDelayMs = 2500, ObservationMinMs = 5000 };
+ temporalConfig.Sop.Steps[0].AiConfirmation = new() { CheckWindowMs = 10000, RetryDelayMs = 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);
+ TemporalFeed(2.8);
await Until(() => temporalClient.Calls.Count == 1);
Check(temporalClient.Calls.ElementAt(0).Request.SourceSeconds == 2.8, "测试前序结果必须来自实际较晚帧");
temporalClient.Calls.ElementAt(0).Result.SetResult(new(true, .99, "前序完成"));
@@ -165,20 +166,20 @@ internal static class ContinuousCheckTests
var effective = temporalClient.Calls.ElementAt(1).Request.Frames!;
Check(effective[^1].SourceSeconds - effective[0].SourceSeconds >= 2.4, "首次过程检查必须覆盖配置要求的实际有效片段时长");
temporal.Stop();
- var leaveConfig = Config(); leaveConfig.Sop.Steps[0].AiConfirmation!.CheckSettleMs = 350; leaveConfig.Sop.Steps[1].Detection!.Method = ConditionMethod.HandLeaveRegion;
+ var leaveConfig = Config(); leaveConfig.Sop.Steps[1].Detection!.Method = ConditionMethod.HandLeaveRegion;
var leaveClient = new Client(); var leave = new SopEngine { VisionDecisionClient = leaveClient };
leave.Load(leaveConfig); leave.Start();
void LeaveFeed(int id, double seconds, int x) => leave.ProcessFrame(Frame(id, seconds, x), () => [(byte)id]);
- LeaveFeed(0, 0, 10); LeaveFeed(1, .1, 120); LeaveFeed(2, .3, 10); LeaveFeed(3, .5, 10);
+ LeaveFeed(0, 0, 10); LeaveFeed(1, .02, 120); LeaveFeed(2, .04, 10); LeaveFeed(3, .2, 10);
await Until(() => leaveClient.Calls.Count == 1);
leaveClient.Calls.ElementAt(0).Result.SetResult(new(true, .99, "前序结果"));
- await Until(() => { leave.ProcessFrame(Frame(3, .5, 10)); return leave.CurrentStep?.Id == 2; });
+ await Until(() => { leave.ProcessFrame(Frame(3, .2, 10)); return leave.CurrentStep?.Id == 2; });
LeaveFeed(4, .7, 10);
Check(leaveClient.Calls.Count == 1, "离散动作不能复用早于前序完成的旧离开事件");
LeaveFeed(5, .9, 120); LeaveFeed(6, 1.1, 10); LeaveFeed(7, 1.3, 10);
await Until(() => leaveClient.Calls.Count == 2);
Check(leaveClient.Calls.ElementAt(1).Request.SourceSeconds >= 1.1 && leaveClient.Calls.ElementAt(1).Request.TriggerObservation?.SourceSeconds == 1.1,
- "必须用前序结果之后新发生的离开事件触发检查,已采集的后续证据仍须保留");
+ $"必须用前序结果之后新发生的离开事件触发检查:图={leaveClient.Calls.ElementAt(1).Request.SourceSeconds},触发={leaveClient.Calls.ElementAt(1).Request.TriggerObservation?.SourceSeconds}");
leave.Stop();
Console.WriteLine("PASS: 停稳触发、新帧重试、限时跳过、后续动作持续取证、挂起硬截止、迟到结果隔离和非合格整轮统计");
}