diff --git a/README.md b/README.md
index 3865ff7..d2ce5d1 100644
--- a/README.md
+++ b/README.md
@@ -48,7 +48,9 @@ SOP 日志显示驱动回读采集模式,状态栏分别显示 USB 实测采
Windows DirectShow 设置分辨率时可能把 MJPG 重置为 YUY2,因此程序在分辨率和帧率设置后再应用视频格式;Linux V4L2 保持先设置格式。2026-11-18 在 USB Camera(0c45:636d)上验证:原顺序在 640×480 和 800×600 下均约 15fps,修复后通过实际 UvcCameraService 采集均约 30fps,格式回读为 MJPG,手动曝光回读 15.625ms。设置接口返回成功和驱动回读 30fps 均不能代替实际采集计数。
-SOP 流程视频可在配方编辑器中录制和播放,独立保存在该配方的 `sop_stand` 目录。主界面的“播放标准 SOP”在主预览区播放当前已应用配方的视频,检测流程使用视频帧,每次播完间隔 5 秒从头重播并开始新一轮检测。播放前会停止正在进行的相机采集。配方导入导出在“运行设置”的配方行:选中配方点击“导出”,把配方定义和标准 SOP 视频打包成单个 `.bwsrecipe` 文件(zip,含 `package.json` 清单:配方名、导出时间、导出程序版本、每个文件的大小和 SHA-256)。关键帧已内联在配方 YAML 中,包内只有配方文件和 `sop_stand` 视频,不带运行图片、录像和已移除功能遗留的数据集/模型。步骤的完成图目录若位于配方目录内会改写为相对路径;位于配方目录之外时导出提醒并在包内清空,导入端使用配方默认目录,不搬运工位本地路径。
+SOP 流程视频可在配方编辑器中录制和播放,独立保存在该配方的 `sop_stand` 目录。主界面的“播放标准 SOP”在主预览区播放当前已应用配方的视频,检测流程使用视频帧,每次播完间隔 5 秒从头重播并开始新一轮检测。播放前会停止正在进行的相机采集。配方导入导出在“运行设置”的配方行:选中配方点击“导出”,把配方定义和标准 SOP 视频打包成单个 `.bwsrecipe` 文件(zip,含 `package.json` 清单:配方名、导出时间、导出程序版本、每个文件的大小和 SHA-256)。关键帧已内联在配方 YAML 中,包内只有配方文件和 `sop_stand` 视频,不带运行图片、录像和已移除功能遗留的数据集/模型。
+
+每轮检测开始时,在当前配方的 `completion-images` 下创建轮次目录。开启“保存结束图”的步骤通过后,将判定图片以步骤名保存到本轮目录。
“导入”选择配方包后先检查:清单缺失、包被改动、大小与清单不符、格式版本高于当前程序或包含越界路径都会拒绝并给出原因。同名配方弹窗选择覆盖(现有配方整目录移入 `workspace/deleted-recipes`,可找回)或另存为 `-2` 等新名称;取消不动盘上文件。导入解压到配方目录内的暂存目录,逐文件校验通过后整目录一次移动到位,中断不会留下半个配方,也不留 `.importing-*`。导入的新配方不会自动应用,区域坐标按相机分辨率标定,需要复核后手动点击“应用”。导入导出不需要登录以外的额外权限:操作员点击只弹出权限提示,工艺师和管理员可用。
diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/EditorNodes.cs b/src/SopHelper.Avalonia/VVMs/RecipeEditor/EditorNodes.cs
index cf0dd33..62e4dc8 100644
--- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/EditorNodes.cs
+++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/EditorNodes.cs
@@ -409,7 +409,6 @@ public class RecipeNode : EditorNode
Timeout = step.Timeout,
StandardDurationMs = step.StandardDurationMs,
SaveCompletionImage = step.SaveCompletionImage,
- CompletionImageDirectory = step.CompletionImageDirectory,
AiConfirmation = step.AiConfirmation is null ? null : new AiConfirmation
{
MinConfidence = step.AiConfirmation.MinConfidence,
@@ -476,7 +475,6 @@ public class RecipeNode : EditorNode
Timeout = step.Timeout,
StandardDurationMs = step.StandardDurationMs,
SaveCompletionImage = step.SaveCompletionImage,
- CompletionImageDirectory = step.CompletionImageDirectory,
AiConfirmation = new AiConfirmation
{
MinConfidence = step.AiMinConfidence,
@@ -747,7 +745,6 @@ public class StepNode : EditorNode
private int _timeout;
private int _standardDurationMs;
private bool _saveCompletionImage = true;
- private string _completionImageDirectory = "";
// 即使 YAML 没有 detection,也保留可编辑对象,供界面写入新选择的方法。
private ConditionNode? _detection = new();
@@ -793,18 +790,13 @@ public class StepNode : EditorNode
set { SetProperty(ref _standardDurationMs, value); }
}
+ /// 本步骤通过时是否将判定图写入配方的轮次归档。
public bool SaveCompletionImage
{
get => _saveCompletionImage;
set => SetProperty(ref _saveCompletionImage, value);
}
- public string CompletionImageDirectory
- {
- get => _completionImageDirectory;
- set => SetProperty(ref _completionImageDirectory, value);
- }
-
/// 判定条件(method 留空 = 本步不写 detection 节点)
public ConditionNode? Detection
{
diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml
index e942754..e33618d 100644
--- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml
+++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml
@@ -254,16 +254,8 @@
-
-
-
-
-
-
-
-
-
+
diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml.cs b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml.cs
index 48a9102..780546f 100644
--- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml.cs
+++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml.cs
@@ -1,7 +1,6 @@
// 配方编辑器视图事件:连接区域绘制、视频定位及关闭确认等需要访问控件的交互。
using Avalonia.Controls;
-using Avalonia.Platform.Storage;
using Avalonia.Threading;
using System.ComponentModel;
using SopHelper.SopVideo;
@@ -71,21 +70,6 @@ public partial class RecipeEditor : UserControl
_recording.RecordingLimitReached += RecordingLimit;
}
private async void RecordingLimit(string message) => await ShowNotice("录像时长提示", message, false);
- private async void ChooseCompletionImageDirectory(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
- if (sender is not Button { DataContext: StepNode step } || TopLevel.GetTopLevel(this) is not Window owner) return;
- try
- {
- var folders = await owner.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions { Title = "选择步骤结束图保存目录", AllowMultiple = false });
- var directory = folders.FirstOrDefault()?.TryGetLocalPath();
- if (!string.IsNullOrWhiteSpace(directory)) step.CompletionImageDirectory = directory;
- }
- catch (Exception error) { await ShowNotice("选择目录失败", error.Message, false); }
- }
- private void ResetCompletionImageDirectory(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
- {
- if (sender is Button { DataContext: StepNode step }) step.CompletionImageDirectory = "";
- }
private async Task ShowNotice(string title, string message, bool confirmation)
{
if (_closing || _dialog is not null || TopLevel.GetTopLevel(this) is not Window owner) return false;
diff --git a/src/SopHelper.Avalonia/VVMs/RuntimeSettings/ImportRecipeConflictDialog.cs b/src/SopHelper.Avalonia/VVMs/RuntimeSettings/ImportRecipeConflictDialog.cs
index 5da7af0..e1837f7 100644
--- a/src/SopHelper.Avalonia/VVMs/RuntimeSettings/ImportRecipeConflictDialog.cs
+++ b/src/SopHelper.Avalonia/VVMs/RuntimeSettings/ImportRecipeConflictDialog.cs
@@ -38,7 +38,7 @@ public sealed class ImportRecipeConflictDialog : Window
new TextBlock { Text = "覆盖前会把现有配方整目录(含录像、标注和运行图片)移入本地“已删除配方”目录,必要时可以找回。", Foreground = new SolidColorBrush(Color.FromRgb(240, 83, 60)), TextWrapping = TextWrapping.Wrap },
new TextBlock { Text = "导入的配方不会自动应用,请在列表中核对区域坐标后手动应用。", Foreground = new SolidColorBrush(Color.FromRgb(150, 150, 150)), TextWrapping = TextWrapping.Wrap }
};
- // 包内提醒(配方缺步骤、缺标准视频、完成图目录被改写等)在确认前公开,避免用户覆盖后才发现条件不足。
+ // 确认前展示包内提醒,便于操作员核对步骤和标准视频。
foreach (var warning in conflict.Info.Warnings.Take(6))
details.Add(new TextBlock { Text = "提醒:" + warning, Foreground = new SolidColorBrush(Color.FromRgb(150, 150, 150)), TextWrapping = TextWrapping.Wrap });
details.Add(new StackPanel
diff --git a/src/SopHelper.Avalonia/VVMs/SopPage/SopPageViewModel.cs b/src/SopHelper.Avalonia/VVMs/SopPage/SopPageViewModel.cs
index 6c43b9e..f97a91f 100644
--- a/src/SopHelper.Avalonia/VVMs/SopPage/SopPageViewModel.cs
+++ b/src/SopHelper.Avalonia/VVMs/SopPage/SopPageViewModel.cs
@@ -745,7 +745,7 @@ public class SopPageViewModel : ViewModelBase
}
/// 导出选中配方为配方包文件,成功后在状态栏给出路径和体积。
- /// 读配方目录在后台线程执行,不改动配方文件;配方目录之外的完成图目录写进包内说明,导入端同样显示。
+ /// 后台读取已保存的配方和标准视频,运行归档留在当前工位。
private async Task ExportRecipeAsync()
{
if (!CanExportRecipe()) return;
@@ -1092,7 +1092,7 @@ public class SopPageViewModel : ViewModelBase
foreach (var step in config.Sop.Steps.OrderBy(s => s.Id))
{
var card = new StepCard { StepId = step.Id, Name = step.Name, Message = "—",
- SaveCompletionImage = step.SaveCompletionImage, CompletionImageDirectory = step.CompletionImageDirectory };
+ SaveCompletionImage = step.SaveCompletionImage };
UpdateStepCounts(card, _engine.Statistics);
StepCards.Add(card);
}
@@ -1172,10 +1172,7 @@ public class SopPageViewModel : ViewModelBase
try
{
var recipeDirectory = DesktopPlatform.Recipes.DirectoryFor(Path.GetFileNameWithoutExtension(ActiveRecipe));
- var configured = StepCards.FirstOrDefault(card => card.SaveCompletionImage
- && !string.IsNullOrWhiteSpace(card.CompletionImageDirectory))?.CompletionImageDirectory;
- var root = configured is null ? Path.Combine(recipeDirectory, "completion-images")
- : Path.GetFullPath(configured.Trim(), recipeDirectory);
+ var root = Path.Combine(recipeDirectory, "completion-images");
var timestamp = startedAt.ToString("yyyyMMdd-HHmmss-fff", CultureInfo.InvariantCulture);
var directory = Path.Combine(root, timestamp);
for (var suffix = 2; Directory.Exists(directory) || File.Exists(directory); suffix++)
@@ -1577,7 +1574,6 @@ public class StepCard : ViewModelBase
private string _elapsedText = "00:00:00";
public string ElapsedText { get => _elapsedText; set => SetProperty(ref _elapsedText, value); }
public bool SaveCompletionImage { get; init; } = true;
- public string CompletionImageDirectory { get; init; } = "";
private BitmapSource? _completionImage;
/// 步骤完成时的独立帧,不随实时画面更新。
diff --git a/src/SopHelper.CrossPlatform.Engine/Recipes/RecipePackage.cs b/src/SopHelper.CrossPlatform.Engine/Recipes/RecipePackage.cs
index d9280cf..2943032 100644
--- a/src/SopHelper.CrossPlatform.Engine/Recipes/RecipePackage.cs
+++ b/src/SopHelper.CrossPlatform.Engine/Recipes/RecipePackage.cs
@@ -92,8 +92,6 @@ public static class RecipePackage
// 读文件再导出:内存里正在编辑的对象不参与打包,避免把未保存的半成品写进包。
var config = SopConfigLoader.Load(configPath);
config.Sop.Name = name;
- var notes = new List();
- NormalizeCompletionDirectories(config, directory, notes);
// 配方 YAML 先落到临时文件,保证包内格式与程序保存的一致(含兼容迁移),再与标准视频一起压入。
var stagedConfig = Path.Combine(Path.GetTempPath(), "bws-recipe-export-" + Guid.NewGuid().ToString("N") + ".yaml");
@@ -110,9 +108,8 @@ public static class RecipePackage
var target = DestinationPath(destination);
Directory.CreateDirectory(Path.GetDirectoryName(target)!);
var sizes = entries.ToDictionary(entry => entry.Entry, entry => new FileInfo(entry.Source).Length);
- // 导出期的处理说明写进清单 notes:导入方(通常是另一台工位)也能看到“哪个步骤的完成图目录被改写/清空”。
var manifest = new PackageManifest(FormatId, FormatVersion, name, DateTimeOffset.UtcNow,
- typeof(RecipePackage).Assembly.GetName().Version?.ToString() ?? "0.0", notes,
+ typeof(RecipePackage).Assembly.GetName().Version?.ToString() ?? "0.0", [],
entries.Select(entry => new PackageFile(entry.Entry, sizes[entry.Entry], Sha256File(entry.Source))).ToList());
// 先写临时包再原子替换:中断只留下 .tmp,不会把上一次的包改成半份。
@@ -134,7 +131,7 @@ public static class RecipePackage
TryDelete(temporary);
throw;
}
- return new ExportResult(target, name, entries.Count, sizes.Values.Sum(), notes);
+ return new ExportResult(target, name, entries.Count, sizes.Values.Sum(), []);
}
finally { TryDelete(stagedConfig); }
}
@@ -151,7 +148,7 @@ public static class RecipePackage
if (!File.Exists(packagePath)) throw new FileNotFoundException("配方包不存在", packagePath);
using var archive = OpenRead(packagePath);
var manifest = ReadManifest(archive);
- // 导出端记录的处理说明(完成图目录改写等)在导入端原样重现,两边看同一份说明。
+ // 保留旧版本配方包清单中的导出说明。
var warnings = new List(manifest.Notes ?? []);
var stagedConfig = Path.Combine(Path.GetTempPath(), "bws-recipe-inspect-" + Guid.NewGuid().ToString("N") + ".yaml");
try
@@ -271,31 +268,6 @@ public static class RecipePackage
JsonSerializer.Serialize(stream, manifest, ManifestJson);
}
- ///
- /// 把步骤的完成图目录改成相对配方目录的路径。
- ///
- ///
- /// 运行期按 Path.GetFullPath(目录, 配方目录) 解析,相对路径换机器后仍指向配方自己。
- /// 配方目录之外的绝对路径导入到别的工位只会写到不相干的位置,因此清空并提醒改用配方默认目录:
- /// 不猜测现场意图,也不把工位本地路径写进可传递的包里。
- ///
- private static void NormalizeCompletionDirectories(SopConfig config, string recipeDirectory, List warnings)
- {
- foreach (var step in config.Sop.Steps)
- {
- var value = step.CompletionImageDirectory?.Trim() ?? "";
- if (value.Length == 0 || !Path.IsPathRooted(value)) continue;
- var full = Path.GetFullPath(value, recipeDirectory);
- if (RecipeWorkspace.IsWithin(full, recipeDirectory))
- {
- step.CompletionImageDirectory = Path.GetRelativePath(recipeDirectory, full).Replace('\\', '/');
- continue;
- }
- step.CompletionImageDirectory = "";
- warnings.Add($"步骤 {step.Id}({step.Name})的完成图目录在配方目录之外({full}),导入后改用配方默认目录,请在编辑器确认。");
- }
- }
-
/// 解析并校验清单:格式标识、版本、配方名、条目路径安全、大小与包内容逐条一致。
private static PackageManifest ReadManifest(ZipArchive archive)
{
diff --git a/src/SopHelper.CrossPlatform.Engine/Recipes/RecipeWorkspace.cs b/src/SopHelper.CrossPlatform.Engine/Recipes/RecipeWorkspace.cs
index d8f16a0..473c8a2 100644
--- a/src/SopHelper.CrossPlatform.Engine/Recipes/RecipeWorkspace.cs
+++ b/src/SopHelper.CrossPlatform.Engine/Recipes/RecipeWorkspace.cs
@@ -1,7 +1,5 @@
-// 配方工作区:统一配置与关联数据的目录、导入迁移、路径修正及可回退的删除归档。
+// 配方工作区:统一管理配方及关联数据的目录、导入迁移和可回退的删除归档。
-using System.Text.Json;
-using System.Text.Json.Nodes;
using SopHelper.Engine.Sop;
namespace SopHelper.Engine.Recipes;
@@ -73,7 +71,7 @@ public sealed class RecipeWorkspace(string root)
Path.GetFullPath(path).StartsWith(Path.GetFullPath(directory).TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar,
OperatingSystem.IsWindows() ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
- /// 一次性复制旧数据并修正路径。保留旧文件供回退,后续只使用新目录。
+ /// 一次性复制旧配方及其关联文件,保留源数据供回退。
public void ImportFrom(string previousRoot)
{
var previous = new RecipeWorkspace(previousRoot);
@@ -88,7 +86,6 @@ public sealed class RecipeWorkspace(string root)
var stagedConfig = Path.Combine(staging, name + ".yaml");
var config = SopConfigLoader.Load(stagedConfig);
config.Sop.Name = name;
- RemapCompletionDirectories(config, source, destination);
SopConfigLoader.Save(config, stagedConfig);
// 配方文件最后发布,已有活动配方优先。
if (Directory.Exists(destination))
@@ -103,7 +100,7 @@ public sealed class RecipeWorkspace(string root)
}
}
- /// 从旧的散放目录复制并修正路径。
+ /// 从旧的散放目录复制配方及标准视频,按工作区目录统一配方名。
/// 初始化现有配方存储并接入旧目录,保持已存在的活动配方及删除记录的优先级。
public void Initialize(params string[] legacyConfigDirectories)
{
@@ -135,26 +132,6 @@ public sealed class RecipeWorkspace(string root)
File.Move(configPath + ".migrating", configPath);
}
foreach (var name in Names()) NormalizeName(ConfigPath(name), name);
- RefreshLocation();
- }
-
- private void RefreshLocation()
- {
- var marker = Path.Combine(RecipesDirectory, ".location.json");
- var previous = File.Exists(marker) ? JsonNode.Parse(File.ReadAllText(marker))?["recipesDirectory"]?.GetValue() : null;
- if (!string.IsNullOrWhiteSpace(previous) && !Path.GetFullPath(previous).Equals(RecipesDirectory, StringComparison.OrdinalIgnoreCase))
- {
- foreach (var name in Names())
- {
- var path = ConfigPath(name);
- var config = SopConfigLoader.Load(path);
- var oldDirectory = Path.Combine(previous, name);
- if (!RemapCompletionDirectories(config, oldDirectory, DirectoryFor(name))) continue;
- SopConfigLoader.Save(config, path + ".tmp");
- File.Move(path + ".tmp", path, true);
- }
- }
- WriteJson(marker,new JsonObject { ["recipesDirectory"] = RecipesDirectory });
}
private static void NormalizeName(string path, string name)
@@ -179,28 +156,4 @@ public sealed class RecipeWorkspace(string root)
CopyTree(child, Path.Combine(destination, Path.GetFileName(child)));
}
- /// 仅迁移旧配方目录内的绝对完成图路径,保留相对路径和工位自定义位置。
- private static bool RemapCompletionDirectories(SopConfig config, string source, string destination)
- {
- var changed = false;
- foreach (var step in config.Sop.Steps)
- {
- var path = step.CompletionImageDirectory;
- if (string.IsNullOrWhiteSpace(path) || !Path.IsPathFullyQualified(path)) continue;
- if (Path.GetFullPath(path).Equals(source, OperatingSystem.IsWindows() ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal))
- step.CompletionImageDirectory = destination;
- else if (IsWithin(path, source))
- step.CompletionImageDirectory = Path.Combine(destination, Path.GetRelativePath(source, path));
- else continue;
- changed = true;
- }
- return changed;
- }
-
- private static void WriteJson(string file, JsonNode? node)
- {
- var temporary = file + ".tmp";
- File.WriteAllText(temporary, node?.ToJsonString(new JsonSerializerOptions { WriteIndented = true }));
- File.Move(temporary, file, true);
- }
}
diff --git a/src/SopHelper.CrossPlatform.Engine/Sop/SopConfig.cs b/src/SopHelper.CrossPlatform.Engine/Sop/SopConfig.cs
index 6f74fb8..4267a84 100644
--- a/src/SopHelper.CrossPlatform.Engine/Sop/SopConfig.cs
+++ b/src/SopHelper.CrossPlatform.Engine/Sop/SopConfig.cs
@@ -150,12 +150,9 @@ public class StepDef
/// 标准节拍毫秒(报表对比用,判定不参与)
public int StandardDurationMs { get; set; }
- /// 步骤完成时保存对应判定帧,旧配方也默认开启。
+ /// 步骤完成时将对应判定帧保存到当前配方的轮次归档,旧配方默认开启。
public bool SaveCompletionImage { get; set; } = true;
- /// 按步骤顺序取第一个已启用保存的非空目录作为整轮归档根目录,全部留空时使用当前配方的 completion-images 目录。
- public string CompletionImageDirectory { get; set; } = "";
-
/// 本步判定条件(AND,全部满足才算完成)
public StepCondition? Detection { get; set; }
diff --git a/src/SopHelper.CrossPlatform.Engine/Sop/SopConfigLoader.cs b/src/SopHelper.CrossPlatform.Engine/Sop/SopConfigLoader.cs
index 6833702..0fd8489 100644
--- a/src/SopHelper.CrossPlatform.Engine/Sop/SopConfigLoader.cs
+++ b/src/SopHelper.CrossPlatform.Engine/Sop/SopConfigLoader.cs
@@ -39,7 +39,7 @@ public static partial class SopConfigLoader
.IgnoreUnmatchedProperties()
.Build();
- // 旧 model 字段由 IgnoreUnmatchedProperties 跳过;旧触发方法保留给校验提示。
+ // 旧模型与步骤结束图目录字段直接跳过,旧触发方法保留给校验提示。
var config = deserializer.Deserialize(yaml) ?? new SopConfig();
MigrateStepSettings(config);
diff --git a/src/SopHelper.CrossPlatform.Engine/SopAgent/SopDraftVerification.cs b/src/SopHelper.CrossPlatform.Engine/SopAgent/SopDraftVerification.cs
index 1037034..4bdd918 100644
--- a/src/SopHelper.CrossPlatform.Engine/SopAgent/SopDraftVerification.cs
+++ b/src/SopHelper.CrossPlatform.Engine/SopAgent/SopDraftVerification.cs
@@ -54,7 +54,7 @@ public static class SopDraftConfigBuilder
ai.ImageMode = step.ImageMode ?? (previous is null ? VisionImageMode.FixedRegion : ai.ImageMode);
ai.ImageRegion = step.ImageRegion ?? (previous is null ? (step.Method == ConditionMethod.HandMove ? step.ToRegion : step.Region) : ai.ImageRegion);
return new StepDef { Id = index + 1, Name = step.Name, Description = step.Description, CompletionCriteria = step.ResolveCompletionCriteria(), Timeout = previous?.Timeout ?? 0,
- SaveCompletionImage = previous?.SaveCompletionImage ?? true, CompletionImageDirectory = previous?.CompletionImageDirectory ?? "",
+ SaveCompletionImage = previous?.SaveCompletionImage ?? true,
MustKeep = previous?.MustKeep ?? [], RequiredObjects = previous?.RequiredObjects ?? [], ViolationRules = previous?.ViolationRules ?? [],
StandardDurationMs = Math.Max(1, (int)Math.Round((step.EndSeconds - step.StartSeconds) * 1000)),
Detection = new() { Method = step.Method, Region = step.Region, FromRegion = step.FromRegion, ToRegion = step.ToRegion,
diff --git a/tests/Avalonia.Smoke/Program.cs b/tests/Avalonia.Smoke/Program.cs
index 852ac6f..c6e2856 100644
--- a/tests/Avalonia.Smoke/Program.cs
+++ b/tests/Avalonia.Smoke/Program.cs
@@ -1121,8 +1121,7 @@ internal static class Smoke
var store=new RecipeWorkspace(Environment.GetEnvironmentVariable("SOPHELPER_WORKSPACE_ROOT")!);
var name="结束图测试";var file=name+".yaml";
var selected=sop.SelectedRecipe;
- var custom=Path.Combine(store.Root,"其它目录","结束图");
- var blocked=Path.Combine(store.Root,"不能作为目录.txt");File.WriteAllText(blocked,"blocked");
+ var archiveRoot=Path.Combine(store.DirectoryFor(name),"completion-images");
var config=new SopHelper.Engine.Sop.SopConfig();config.Sop.Name=name;
config.Sop.Settings.AutoResetOnComplete=false;config.Sop.Settings.StableFrames=1;
for(var id=1;id<=4;id++)
@@ -1131,16 +1130,17 @@ internal static class Smoke
config.Sop.Steps.Add(new()
{
Id=id,Name=id==1?"装配/检查":id==4?"装配_检查":"步骤"+id,SaveCompletionImage=id!=2,
- Description="零件安装到位",CompletionImageDirectory=id==3?custom:id==4?blocked:"",
+ Description="零件安装到位",
Detection=new(){Method="hand_in_region",Region="工位"+id,StableFrames=1,Tolerance=0},
AiConfirmation=new(){ImageMode="full_frame",EvidenceMode="single_frame",CheckWindowMs=0}
});
}
- var legacy=SopHelper.Engine.Sop.SopConfigLoader.Parse("sop:\n name: legacy\n steps:\n - id: 1\n name: first\n");
- Check(legacy.Sop.Steps[0].SaveCompletionImage&&legacy.Sop.Steps[0].CompletionImageDirectory=="","Existing recipes default to saving completion images in their own recipe directory");
+ var legacy=SopConfigLoader.Parse("sop:\n name: legacy\n steps:\n - id: 1\n name: first\n completion_image_directory: old-images\n");
+ Check(legacy.Sop.Steps[0].SaveCompletionImage&&!SopConfigLoader.ToYaml(legacy).Contains("completion_image_directory"),
+ "旧配方保留默认保存开关,旧目录配置在重新保存时清理");
var node=RecipeNode.From(config,file,false);
var roundTrip=SopHelper.Engine.Sop.SopConfigLoader.Parse(SopHelper.Engine.Sop.SopConfigLoader.ToYaml(node.ToConfig()));
- Check(roundTrip.Sop.Steps[0].SaveCompletionImage&&!roundTrip.Sop.Steps[1].SaveCompletionImage&&roundTrip.Sop.Steps[2].CompletionImageDirectory==custom,"Step image switches and custom Unicode directories survive editor and YAML round trips");
+ Check(roundTrip.Sop.Steps[0].SaveCompletionImage&&!roundTrip.Sop.Steps[1].SaveCompletionImage,"步骤编辑和 YAML 往返保留结束图开关");
Directory.CreateDirectory(store.DirectoryFor(name));
SopHelper.Engine.Sop.SopConfigLoader.Save(roundTrip,store.ConfigPath(name));
var editorVm=new RecipeEditorViewModel();
@@ -1151,17 +1151,14 @@ internal static class Smoke
{
editor.FindControl("StepAdditionalSettings")!.IsExpanded=true;await Task.Delay(20);
var toggle=editor.GetVisualDescendants().OfType().Single(c=>c.Content?.ToString()=="保存结束图");
- var directoryBox=editor.GetVisualDescendants().OfType().Single(t=>t.Name=="CompletionImageDirectoryBox");
- Check(toggle.IsChecked==true&&string.IsNullOrEmpty(directoryBox.Text),"Step editor exposes image saving enabled by default with the recipe directory selected");
+ Check(toggle.IsChecked==true&&editor.FindControl("CompletionImageDirectoryBox") is null
+ && !editor.GetVisualDescendants().OfType