|
|
@@ -551,7 +551,9 @@ namespace TeamAAS_VP.Services
|
|
|
|
|
|
var visionResult = await TrackExecutionAsync(async ct =>
|
|
|
{
|
|
|
- var r = await ExecuteVisionTaskAsync(procedure, commandParams, ct);
|
|
|
+ ImageParameters imgPara = new ImageParameters();
|
|
|
+ imgPara.SNCode = "SN";
|
|
|
+ var r = await ExecuteVisionTaskAsync(procedure, commandParams, ct, imgPara);
|
|
|
return Tuple.Create(r.IsSucceed, r.Response);
|
|
|
}, isVision: true, cancellationToken);
|
|
|
if (visionResult.Item1)
|
|
|
@@ -1053,7 +1055,7 @@ namespace TeamAAS_VP.Services
|
|
|
/// - 否则根据 procedure.FeederId 调用 Feeder 引导的视觉任务或普通视觉任务
|
|
|
/// 返回是否成功以及字符串数组形式的响应(用于发送多条结果)。
|
|
|
/// </summary>
|
|
|
- public async Task<(bool IsSucceed, string[] Response)> ExecuteVisionTaskAsync(ProcedureModel procedure, string[] items, CancellationToken cancellationToken)
|
|
|
+ public async Task<(bool IsSucceed, string[] Response)> ExecuteVisionTaskAsync(ProcedureModel procedure, string[] items, CancellationToken cancellationToken, ImageParameters imgPara)
|
|
|
{
|
|
|
var currentProduct = _productService.GetCurrentProduct();
|
|
|
string scriptFilePath = FilePath.ProductsPath + "//" + currentProduct.Name + "//" + procedure.CameraName + "//" + procedure.Name + ".cs";
|
|
|
@@ -1092,11 +1094,11 @@ namespace TeamAAS_VP.Services
|
|
|
if (procedure.FeederId != Guid.Empty)
|
|
|
{
|
|
|
Feeder = _feederService.GetFeeder(procedure.FeederId);
|
|
|
- return await ExecuteFeederVisionTaskAsync(Feeder, procedure, items, cancellationToken);
|
|
|
+ return await ExecuteFeederVisionTaskAsync(Feeder, procedure, items, cancellationToken, imgPara);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- var result = await ExecuteNormalVisionTaskAsync(procedure, items, cancellationToken);
|
|
|
+ var result = await ExecuteNormalVisionTaskAsync(procedure, items, cancellationToken, imgPara);
|
|
|
return (result.IsSucceed, new string[] { result.Response });
|
|
|
}
|
|
|
}
|
|
|
@@ -1130,7 +1132,7 @@ namespace TeamAAS_VP.Services
|
|
|
/// - 多次尝试拍照并运行视觉工具,直到成功或达到失败次数上限
|
|
|
/// - 返回布尔成功标记及字符串数组形式的响应项
|
|
|
/// </summary>
|
|
|
- public async Task<(bool IsSucceed, string[] Response)> ExecuteFeederVisionTaskAsync(IVoiceCoilMotorFeeder feeder, ProcedureModel procedure, string[] items, CancellationToken cancellationToken)
|
|
|
+ public async Task<(bool IsSucceed, string[] Response)> ExecuteFeederVisionTaskAsync(IVoiceCoilMotorFeeder feeder, ProcedureModel procedure, string[] items, CancellationToken cancellationToken, ImageParameters imgPara)
|
|
|
{
|
|
|
// 如果输入的items中是否包含Vibration和NoVibration,这两个分别对应是否先振动和是否先拍照
|
|
|
bool doVibrateFirst = items != null && items.Contains("VibrateFirst");
|
|
|
@@ -1185,7 +1187,7 @@ namespace TeamAAS_VP.Services
|
|
|
SendTaskMessage(Lang.开始执行视觉流程.Replace("{0}", $"{i + 1}").Replace("{1}", procedure.Name), MessageLevel.Info);
|
|
|
|
|
|
// 1. 执行相机拍照并运行视觉工具
|
|
|
- bool visionSucceed = ExecutePhoto(procedure, InputTerminal, out CogToolBlockTerminalCollection outputCollection);
|
|
|
+ bool visionSucceed = ExecutePhoto(procedure, InputTerminal, out CogToolBlockTerminalCollection outputCollection, imgPara);
|
|
|
if (!visionSucceed)
|
|
|
{
|
|
|
SendTaskMessage(Lang.视觉任务执行失败, MessageLevel.Error);
|
|
|
@@ -1337,7 +1339,7 @@ namespace TeamAAS_VP.Services
|
|
|
/// <summary>
|
|
|
/// 执行非 Feeder 引导的普通视觉任务,返回单字符串响应。
|
|
|
/// </summary>
|
|
|
- public async Task<(bool IsSucceed, string Response)> ExecuteNormalVisionTaskAsync(ProcedureModel procedure, string[] items, CancellationToken cancellationToken)
|
|
|
+ public async Task<(bool IsSucceed, string Response)> ExecuteNormalVisionTaskAsync(ProcedureModel procedure, string[] items, CancellationToken cancellationToken, ImageParameters imgPara)
|
|
|
{
|
|
|
// 开始执行前的时间点
|
|
|
DateTime startTime = DateTime.Now;
|
|
|
@@ -1374,7 +1376,7 @@ namespace TeamAAS_VP.Services
|
|
|
}
|
|
|
// 1. 执行相机拍照并运行视觉工具
|
|
|
LogHelper.WriteLogInfo(Lang.开始执行相机拍照并运行视觉工具);
|
|
|
- bool visionSucceed = ExecutePhoto(procedure, InputTerminal, out CogToolBlockTerminalCollection outputCollection);
|
|
|
+ bool visionSucceed = ExecutePhoto(procedure, InputTerminal, out CogToolBlockTerminalCollection outputCollection, imgPara);
|
|
|
if (!visionSucceed)
|
|
|
{
|
|
|
SendTaskMessage(Lang.视觉任务执行失败, MessageLevel.Error);
|
|
|
@@ -1452,7 +1454,7 @@ namespace TeamAAS_VP.Services
|
|
|
/// 执行相机拍照并运行 ToolBlock,返回是否成功并通过 out 参数返回 Outputs。
|
|
|
/// 该方法会发布 RenderUpdateNotification 以更新 UI。
|
|
|
/// </summary>
|
|
|
- public bool ExecutePhoto(ProcedureModel procedure, Dictionary<string, string> InputTerminal, out CogToolBlockTerminalCollection outputCollection)
|
|
|
+ public bool ExecutePhoto(ProcedureModel procedure, Dictionary<string, string> InputTerminal, out CogToolBlockTerminalCollection outputCollection, ImageParameters imgPara)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
@@ -1529,6 +1531,7 @@ namespace TeamAAS_VP.Services
|
|
|
SaveImagePathModel = procedure.SaveImagePathModel,
|
|
|
SavePath = procedure.SavePath,
|
|
|
IsCompress = procedure.IsCompress,
|
|
|
+ ImgPara = imgPara,
|
|
|
});
|
|
|
SendTaskMessage($"{procedure.CameraName},{procedure.CameraId}", MessageLevel.Info);
|
|
|
return true;
|
|
|
@@ -1768,7 +1771,7 @@ namespace TeamAAS_VP.Services
|
|
|
/// <param name="positionIndex"></param>
|
|
|
/// <param name="remark"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<(bool IsSucceed, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex, string remark)
|
|
|
+ public async Task<(bool IsSucceed, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex, string remark, ImageParameters imgPara)
|
|
|
{
|
|
|
DateTime nowtime = DateTime.Now;
|
|
|
await SetLightBeforePhoto(procedure);
|
|
|
@@ -1780,7 +1783,7 @@ namespace TeamAAS_VP.Services
|
|
|
SendTaskMessage(Lang.开始执行视觉流程.Replace("{0}", $"{i + 1}").Replace("{1}", procedure.Name), MessageLevel.Info);
|
|
|
|
|
|
// 1. 执行相机拍照并运行视觉工具
|
|
|
- bool visionSucceed = ExecutePhoto(procedure, InputTerminal, out CogToolBlockTerminalCollection outputCollection);
|
|
|
+ bool visionSucceed = ExecutePhoto(procedure, InputTerminal, out CogToolBlockTerminalCollection outputCollection, imgPara);
|
|
|
if (!visionSucceed)
|
|
|
{
|
|
|
SendTaskMessage(Lang.视觉任务执行失败, MessageLevel.Error);
|