namespace PLCSharp.VVMs.Vision.VisionFlowHandler.Access
{
///
/// 保存图像To全局Handler
///
public class ImageToGlobalHandler : IVisionFlowHandler
{
///
/// 类型
///
public VisionFlowType Type => VisionFlowType.存到全局图像;
///
/// 执行
///
/// 视觉功能
/// 变量项
/// 返回布尔值
public bool Execute(VisionFunction func, VisionFlow item)
{
if (item.StringParams.TryGetValue("Image", out string imageName))
{
var imageData = func.ImageDatas.Where(i => i.Name == imageName).FirstOrDefault();
if (imageData != null)
{
imageData.Mat = func.Src.Clone();
item.Flow.Completed = true;
return true;
}
else
{
throw new Exception("图像池中未找到对应图片!");
}
}
else
{
throw new Exception("未配置图像名称,请重新配置!");
}
}
}
}