完善配方导入导出功能
This commit is contained in:
parent
a7a097e952
commit
70c6e47828
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="特征点数量" VerticalAlignment="Center" ToolTip="提取的特征点越多越精确,但速度越慢" />
|
||||
<TextBox Grid.Column="1" Text="{Binding SelectVisionFlow.IntParams[NFeatures], Mode=TwoWay, TargetNullValue=500, UpdateSourceTrigger=LostFocus}" />
|
||||
<TextBox Grid.Column="1" Text="{Binding SelectVisionFlow.IntParams[NFeatures], Mode=TwoWay, TargetNullValue=1000, UpdateSourceTrigger=LostFocus}" />
|
||||
|
||||
<TextBlock Grid.Row="1" Text="最小匹配数" VerticalAlignment="Center" ToolTip="最少需要的优质匹配点数" />
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding SelectVisionFlow.IntParams[MinMatches], Mode=TwoWay, TargetNullValue=8, UpdateSourceTrigger=LostFocus}" />
|
||||
|
||||
@ -19,22 +19,19 @@
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="70" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="矩阵名称" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding SelectVisionFlow.StringParams[CalibMatName], Mode=TwoWay, TargetNullValue=标定矩阵}" />
|
||||
<TextBlock Grid.Row="1" Text="行基准" VerticalAlignment="Center" ToolTip="第一行的世界Y坐标" />
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding SelectVisionFlow.DoubleParams[CalibRowBase], Mode=TwoWay, TargetNullValue=0, UpdateSourceTrigger=LostFocus}" />
|
||||
<TextBlock Grid.Row="2" Text="列基准" VerticalAlignment="Center" ToolTip="第一列的世界X坐标" />
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding SelectVisionFlow.DoubleParams[CalibColBase], Mode=TwoWay, TargetNullValue=0, UpdateSourceTrigger=LostFocus}" />
|
||||
<TextBlock Grid.Row="3" Text="间距" VerticalAlignment="Center" ToolTip="相邻圆点的世界间距" />
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding SelectVisionFlow.DoubleParams[CalibSpacing], Mode=TwoWay, TargetNullValue=5, UpdateSourceTrigger=LostFocus}" />
|
||||
<TextBlock Grid.Row="4" Text="9点圆心数" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Row="4" Grid.Column="1"
|
||||
<TextBlock Grid.Row="0" Text="行基准" VerticalAlignment="Center" ToolTip="第一行的世界Y坐标" />
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding SelectVisionFlow.DoubleParams[CalibRowBase], Mode=TwoWay, TargetNullValue=0, UpdateSourceTrigger=LostFocus}" />
|
||||
<TextBlock Grid.Row="1" Text="列基准" VerticalAlignment="Center" ToolTip="第一列的世界X坐标" />
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding SelectVisionFlow.DoubleParams[CalibColBase], Mode=TwoWay, TargetNullValue=0, UpdateSourceTrigger=LostFocus}" />
|
||||
<TextBlock Grid.Row="2" Text="间距" VerticalAlignment="Center" ToolTip="相邻圆点的世界间距" />
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding SelectVisionFlow.DoubleParams[CalibSpacing], Mode=TwoWay, TargetNullValue=5, UpdateSourceTrigger=LostFocus}" />
|
||||
<TextBlock Grid.Row="3" Text="9点圆心数" VerticalAlignment="Center" />
|
||||
<TextBox Grid.Row="3" Grid.Column="1"
|
||||
Text="{Binding SelectedVisionFunction.Params.ResultDoubles[CalibDotCount], Mode=OneWay, TargetNullValue=—}"
|
||||
IsReadOnly="True" Background="#FFF0F0F0" />
|
||||
</Grid>
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user