diff --git a/PLCSharpWpf/Models/GlobalModel.Recipes.cs b/PLCSharpWpf/Models/GlobalModel.Recipes.cs
index 641b402..5a9d231 100644
--- a/PLCSharpWpf/Models/GlobalModel.Recipes.cs
+++ b/PLCSharpWpf/Models/GlobalModel.Recipes.cs
@@ -246,8 +246,7 @@ namespace PLCSharp.Models
ID = i.ID.ToString(),
RecipeID = i.RecipeID.ToString(),
i.Name,
- i.Comment,
- 图像数据 = i.SerializedMat != null ? Convert.ToBase64String(i.SerializedMat) : ""
+ i.Comment
}).ToList();
// 运动控制点位
@@ -297,6 +296,23 @@ namespace PLCSharp.Models
r.SerializedParams
}).ToList();
+ // 机器人矩阵
+ sheets["机器人矩阵"] = _DatasContext.RobotMatrices
+ .Where(m => m.RecipeID == recipeId)
+ .Select(m => new
+ {
+ ID = m.ID.ToString(),
+ RecipeID = m.RecipeID.ToString(),
+ RobotID = m.RobotID.ToString(),
+ m.Name,
+ m.StartName,
+ m.XEndName,
+ m.YEndName,
+ m.XCount,
+ m.YCount,
+ m.MatrixType
+ }).ToList();
+
// 系统变量
sheets["系统变量"] = _DatasContext.SystemVariables
.Where(s => s.RecipeID == recipeId)
@@ -326,6 +342,22 @@ namespace PLCSharp.Models
g.SerializedInterpolations
}).ToList();
+ // 运动控制矩阵
+ sheets["运动控制矩阵"] = _DatasContext.Matrices
+ .Where(m => m.RecipeID == recipeId)
+ .Select(m => new
+ {
+ ID = m.ID.ToString(),
+ RecipeID = m.RecipeID.ToString(),
+ m.Name,
+ m.StartName,
+ m.XEndName,
+ m.YEndName,
+ m.XCount,
+ m.YCount,
+ m.MatrixType
+ }).ToList();
+
// 画布配置
sheets["画布配置"] = _DatasContext.CanvasConfigs
.Where(c => c.RecipeID == recipeId)
@@ -464,17 +496,13 @@ namespace PLCSharp.Models
if (string.IsNullOrWhiteSpace(name)) continue;
if (_DatasContext.ImageDatas.Any(i => i.Name == name && i.RecipeID == recipeId)) continue;
- var imgData = new ImageData
+ _DatasContext.ImageDatas.Add(new ImageData
{
ID = id,
RecipeID = recipeId,
Name = name,
Comment = (string)row.Comment
- };
- var base64 = (string)row.图像数据;
- if (!string.IsNullOrWhiteSpace(base64))
- imgData.SerializedMat = Convert.FromBase64String(base64);
- _DatasContext.ImageDatas.Add(imgData);
+ });
}
// 运动控制点位
@@ -547,6 +575,35 @@ namespace PLCSharp.Models
_DatasContext.RobotPoints.Add(rp);
}
+ // 机器人矩阵
+ foreach (var row in MiniExcel.Query(dialog.FileName, sheetName: "机器人矩阵"))
+ {
+ var idStr = (string)row.ID;
+ if (string.IsNullOrWhiteSpace(idStr)) continue;
+ if (!Guid.TryParse(idStr, out var id)) continue;
+ if (_DatasContext.RobotMatrices.Any(m => m.ID == id)) continue;
+
+ var name = (string)row.Name;
+ if (string.IsNullOrWhiteSpace(name)) continue;
+ if (_DatasContext.RobotMatrices.Any(m => m.Name == name && m.RecipeID == recipeId)) continue;
+
+ var rm = new RobotMatrix
+ {
+ ID = id,
+ RecipeID = recipeId,
+ Name = name,
+ StartName = (string)row.StartName,
+ XEndName = (string)row.XEndName,
+ YEndName = (string)row.YEndName,
+ XCount = (int)row.XCount,
+ YCount = (int)row.YCount,
+ MatrixType = (int)row.MatrixType
+ };
+ if (Guid.TryParse((string)row.RobotID, out var robotId))
+ rm.RobotID = robotId;
+ _DatasContext.RobotMatrices.Add(rm);
+ }
+
// 系统变量
foreach (var row in MiniExcel.Query(dialog.FileName, sheetName: "系统变量"))
{
@@ -598,6 +655,32 @@ namespace PLCSharp.Models
});
}
+ // 运动控制矩阵
+ foreach (var row in MiniExcel.Query(dialog.FileName, sheetName: "运动控制矩阵"))
+ {
+ var idStr = (string)row.ID;
+ if (string.IsNullOrWhiteSpace(idStr)) continue;
+ if (!Guid.TryParse(idStr, out var id)) continue;
+ if (_DatasContext.Matrices.Any(m => m.ID == id)) continue;
+
+ var name = (string)row.Name;
+ if (string.IsNullOrWhiteSpace(name)) continue;
+ if (_DatasContext.Matrices.Any(m => m.Name == name && m.RecipeID == recipeId)) continue;
+
+ _DatasContext.Matrices.Add(new Matrix
+ {
+ ID = id,
+ RecipeID = recipeId,
+ Name = name,
+ StartName = (string)row.StartName,
+ XEndName = (string)row.XEndName,
+ YEndName = (string)row.YEndName,
+ XCount = (int)row.XCount,
+ YCount = (int)row.YCount,
+ MatrixType = (int)row.MatrixType
+ });
+ }
+
// 画布配置
foreach (var row in MiniExcel.Query(dialog.FileName, sheetName: "画布配置"))
{
@@ -826,6 +909,34 @@ namespace PLCSharp.Models
_DatasContext.InterpolationGroups.Add(itemCopy);
}
}
+ // 机器人矩阵
+
+ var robotMatrices = _DatasContext.RobotMatrices.Where(c => c.RecipeID == RecipeSelected.ID);
+ foreach (var item in robotMatrices)
+ {
+ if (item != null)
+ {
+ var itemCopy = item.DeepCopy();
+ itemCopy.RecipeID = newRecipe.ID;
+ itemCopy.ID = Guid.NewGuid();
+ _DatasContext.RobotMatrices.Add(itemCopy);
+ }
+ }
+
+ // 运动控制矩阵
+
+ var matrices = _DatasContext.Matrices.Where(c => c.RecipeID == RecipeSelected.ID);
+ foreach (var item in matrices)
+ {
+ if (item != null)
+ {
+ var itemCopy = item.DeepCopy();
+ itemCopy.RecipeID = newRecipe.ID;
+ itemCopy.ID = Guid.NewGuid();
+ _DatasContext.Matrices.Add(itemCopy);
+ }
+ }
+
// 任务列表
var workflows = _DatasContext.Workflows.Where(c => c.RecipeID == RecipeSelected.ID);
diff --git a/PLCSharpWpf/VVMs/Vision/VisionConfigViewModel.PublicCommands.cs b/PLCSharpWpf/VVMs/Vision/VisionConfigViewModel.PublicCommands.cs
index 86d8395..72e25a7 100644
--- a/PLCSharpWpf/VVMs/Vision/VisionConfigViewModel.PublicCommands.cs
+++ b/PLCSharpWpf/VVMs/Vision/VisionConfigViewModel.PublicCommands.cs
@@ -340,7 +340,7 @@ public partial class VisionConfigViewModel
double rowBase = SelectVisionFlow.DoubleParams.TryGetValue("CalibRowBase", out double rb) ? rb : 0;
double colBase = SelectVisionFlow.DoubleParams.TryGetValue("CalibColBase", out double cb) ? cb : 0;
double spacing = SelectVisionFlow.DoubleParams.TryGetValue("CalibSpacing", out double sp) ? Math.Max(sp, 0.1) : 5;
- string matName = SelectVisionFlow.StringParams.TryGetValue("CalibMatName", out var mn) && !string.IsNullOrEmpty(mn) ? mn : "标定矩阵";
+ string matName = SelectVisionFlow.StringParams.TryGetValue("TransformMat", out var mn) && !string.IsNullOrEmpty(mn) ? mn : "标定矩阵";
Mat gray;
if (src.Channels() == 3)
diff --git a/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Algorithm/ORBMatch.xaml b/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Algorithm/ORBMatch.xaml
index 2a19223..3d41c7a 100644
--- a/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Algorithm/ORBMatch.xaml
+++ b/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Algorithm/ORBMatch.xaml
@@ -73,7 +73,7 @@
-
+
diff --git a/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/CoordTransform.xaml b/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/CoordTransform.xaml
index 3161a1f..3f50b44 100644
--- a/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/CoordTransform.xaml
+++ b/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/CoordTransform.xaml
@@ -19,22 +19,19 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/CoordinateTransformHandler.cs b/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/CoordinateTransformHandler.cs
index 29179a6..24ae1b3 100644
--- a/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/CoordinateTransformHandler.cs
+++ b/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/CoordinateTransformHandler.cs
@@ -39,9 +39,9 @@ namespace PLCSharp.VVMs.Vision.VisionFlowHandler.Processing
}
// 2. 从全局变量中读取变换矩阵
- if (!item.StringParams.TryGetValue("TransformMat", out string matName) ||
+ if (!item.StringParams.TryGetValue("TransformMat", out string? matName) ||
string.IsNullOrEmpty(matName))
- item.StringParams["TransformMat"] = "TransformMat";
+ item.StringParams["TransformMat"] = "标定矩阵";
var matVar = func.GlobalModel.VariablesModel.SystemVariables.FirstOrDefault(v => v.Name == matName);
if (matVar?.Value == null)