|
|
@@ -1456,7 +1456,7 @@ namespace TeamAAS_VP.Services
|
|
|
/// 执行相机拍照并运行 ToolBlock,返回是否成功并通过 out 参数返回 Outputs。
|
|
|
/// 该方法会发布 RenderUpdateNotification 以更新 UI。
|
|
|
/// </summary>
|
|
|
- public bool ExecutePhoto(int index, ProcedureModel procedure, Dictionary<string, string> InputTerminal, out CogToolBlockTerminalCollection outputCollection, ImageParameters imgPara,int ScrewNum=1)
|
|
|
+ public bool ExecutePhoto(int index, ProcedureModel procedure, Dictionary<string, string> InputTerminal, out CogToolBlockTerminalCollection outputCollection, ImageParameters imgPara, int ScrewNum = 1)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
@@ -1610,6 +1610,223 @@ namespace TeamAAS_VP.Services
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 执行翻转相机拍照流程运行
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="procedure"></param>
|
|
|
+ /// <param name="outputCollection"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public bool ExecutePhotoGetDistance(ProcedureModel procedure, Dictionary<string, string> InputTerminal)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //string dis = "";
|
|
|
+ //拍照失败时,需要多次拍照
|
|
|
+ for (int i = 0; i < procedure.FeederFailLimit; i++)
|
|
|
+ {
|
|
|
+ SendTaskMessage(Lang.开始执行视觉流程.Replace("{0}", $"{i + 1}").Replace("{1}", procedure.Name), MessageLevel.Info);
|
|
|
+
|
|
|
+ // 1. 执行相机拍照并运行视觉工具
|
|
|
+ bool visionSucceed = ExecutePhotos(procedure, InputTerminal, out CogToolBlockTerminalCollection outputCollection);
|
|
|
+ if (!visionSucceed)
|
|
|
+ {
|
|
|
+ SendTaskMessage(Lang.视觉任务执行失败, MessageLevel.Error);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!outputCollection.Contains("Found"))
|
|
|
+ {
|
|
|
+ SendTaskMessage(Lang.未找到视觉输出结果, MessageLevel.Error);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 获取视觉输出结果NA
|
|
|
+ bool Found = (bool)(outputCollection["Found"].Value);
|
|
|
+ if (!Found)
|
|
|
+ {
|
|
|
+ SendTaskMessage(Lang.拍照NG, MessageLevel.Debug);
|
|
|
+ //dis = (string)(outputCollection["dis"].Value);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ SendTaskMessage(Lang.拍照OK, MessageLevel.Debug);
|
|
|
+
|
|
|
+ LogHelper.WriteLogInfo("开始获取视觉输出结果");
|
|
|
+ //dis = (string)(outputCollection["dis"].Value);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ SendTaskMessage(Lang.多次拍照失败, MessageLevel.Alarm);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogError("执行相机取图并获取单点位时出错!", ex);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 翻转相机拍照方法
|
|
|
+ /// 该方法会发布 RenderUpdateNotification 以更新 UI。
|
|
|
+ /// </summary>
|
|
|
+ public bool ExecutePhotos(ProcedureModel procedure, Dictionary<string, string> InputTerminal, out CogToolBlockTerminalCollection outputCollection)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ // 1. 采集图像
|
|
|
+ var camera = _cameraService.GetCamera(procedure.CameraId);
|
|
|
+ bool succed = camera.SetExposureTime(procedure.ExposureTime);
|
|
|
+ if (!succed)
|
|
|
+ {
|
|
|
+ SendTaskMessage($"相机曝光设置失败!", MessageLevel.Error);
|
|
|
+ }
|
|
|
+ succed = camera.SetGain(procedure.Gain);
|
|
|
+ if (!succed)
|
|
|
+ {
|
|
|
+ SendTaskMessage($"相机增益设置失败!", MessageLevel.Error);
|
|
|
+ }
|
|
|
+ DateTime nowtime = DateTime.Now;
|
|
|
+ LogHelper.WriteLogInfo("开始采集图像");
|
|
|
+ //var image = camera.Grab();
|
|
|
+ var image = camera.Grab();
|
|
|
+
|
|
|
+ if (image == null)
|
|
|
+ {
|
|
|
+
|
|
|
+ SendTaskMessage(Lang.图像采集失败, MessageLevel.Error);
|
|
|
+ outputCollection = null;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ procedure.ToolBlock.Inputs["InputImage"].Value = image;
|
|
|
+ LogHelper.WriteLogInfo($"采集图像完成;用时:{(DateTime.Now - nowtime).Milliseconds}ms");
|
|
|
+
|
|
|
+ // 2. 为ToolBlock传入其他输入终端
|
|
|
+ if (InputTerminal != null)
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogInfo($"为ToolBlock传入输入终端");
|
|
|
+ foreach (var item in InputTerminal)
|
|
|
+ {
|
|
|
+ if (procedure.ToolBlock.Inputs.Contains(item.Key))
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogInfo($"传入[{item.Key}]={item.Value}");
|
|
|
+ procedure.ToolBlock.Inputs[item.Key].Value = item.Value;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogInfo($"创建并传入[{item.Key}]={item.Value}");
|
|
|
+ procedure.ToolBlock.Inputs.Add(new CogToolBlockTerminal(item.Key, item.Value));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ LogHelper.WriteLogInfo(Lang.开始运行视觉工具);
|
|
|
+ procedure.ToolBlock.Run(); //运行ToolBlock
|
|
|
+
|
|
|
+ if (procedure.ToolBlock.RunStatus.Result == CogToolResultConstants.Accept)
|
|
|
+ {
|
|
|
+ SendTaskMessage(Lang.视觉流程执行耗时.Replace("{0}", procedure.Name).Replace("{1}", $"{procedure.ToolBlock.RunStatus.ProcessingTime:F1}"), MessageLevel.Info);
|
|
|
+ outputCollection = procedure.ToolBlock.Outputs; //获取输出终端集合
|
|
|
+ DatabaseHelper.AddCameraRecords(_productService.GetCurrentProduct().Name, procedure.Name, outputCollection);
|
|
|
+ ICogRecord record = null;
|
|
|
+ foreach (CogToolBlockTerminal item in outputCollection)
|
|
|
+ {
|
|
|
+ if (item.Value is ICogRecord)
|
|
|
+ record = item.Value as ICogRecord;
|
|
|
+ }
|
|
|
+ bool Found = (bool)(outputCollection["Found"].Value);
|
|
|
+ //获取图片存储的图片文件名
|
|
|
+ string imgName = string.Empty;
|
|
|
+ if (procedure.IsSaveImage && !string.IsNullOrEmpty(procedure.ImageFileNameFormat))
|
|
|
+ {
|
|
|
+ // 创建模板,使用 {变量名:格式} 语法
|
|
|
+ var template = new FileNameTemplate(procedure.ImageFileNameFormat);
|
|
|
+
|
|
|
+ // 注册变量
|
|
|
+ template.RegisterVariable("ProductSN", () => _productService.CurrentProductCode);
|
|
|
+ template.RegisterVariable("CameraName", () => procedure.CameraName);
|
|
|
+ //template.RegisterVariable("ShotCount", () => 1);
|
|
|
+ template.RegisterVariable("Result", () => Found ? "OK" : "NG");
|
|
|
+ //template.RegisterVariable("Number", () => 1);
|
|
|
+ template.RegisterVariable("DateTime", () => DateTime.Now);
|
|
|
+
|
|
|
+ // 生成文件名
|
|
|
+ imgName = template.Generate();
|
|
|
+ }
|
|
|
+
|
|
|
+ _eventAggregator.GetEvent<RenderUpdateNotification>().Publish(new ShowRender()
|
|
|
+ {
|
|
|
+ Id = procedure.Id,
|
|
|
+ Image = (ICogImage)procedure.ToolBlock.Inputs["InputImage"].Value,
|
|
|
+ Graphic = outputCollection["Graphic"].Value as CogGraphicCollection,
|
|
|
+ Record = record,
|
|
|
+ Result = Found,
|
|
|
+ IsShow = true,
|
|
|
+ IsSaveImage = procedure.IsSaveImage,
|
|
|
+ SaveImageModel = procedure.SaveImageModel,
|
|
|
+ SaveImagePathModel = procedure.SaveImagePathModel,
|
|
|
+ SavePath = procedure.SavePath,
|
|
|
+ IsCompress = procedure.IsCompress,
|
|
|
+ IsDelaySaveImage = procedure.IsDelaySaveImage,
|
|
|
+ //ImgPara = imgPara,
|
|
|
+ ImageFileName = imgName,
|
|
|
+ ProceductName = procedure.Name,
|
|
|
+ });
|
|
|
+ SendTaskMessage($"{procedure.CameraName},{procedure.CameraId}", MessageLevel.Info);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SendTaskMessage(Lang.视觉流程执行出错耗时.Replace("{0}", procedure.Name).Replace("{1}", $"{procedure.ToolBlock.RunStatus.ProcessingTime:F1}"), MessageLevel.Error);
|
|
|
+ SendTaskMessage(procedure.ToolBlock.RunStatus.Message, MessageLevel.Error);
|
|
|
+ outputCollection = null;
|
|
|
+
|
|
|
+ //获取图片存储的图片文件名
|
|
|
+ string imgName = string.Empty;
|
|
|
+ if (procedure.IsSaveImage && !string.IsNullOrEmpty(procedure.ImageFileNameFormat))
|
|
|
+ {
|
|
|
+ // 创建模板,使用 {变量名:格式} 语法
|
|
|
+ var template = new FileNameTemplate(procedure.ImageFileNameFormat);
|
|
|
+
|
|
|
+ // 注册变量
|
|
|
+ template.RegisterVariable("ProductSN", () => _productService.CurrentProductCode);
|
|
|
+ template.RegisterVariable("CameraName", () => procedure.CameraName);
|
|
|
+ //template.RegisterVariable("ShotCount", () => index);
|
|
|
+ template.RegisterVariable("Result", () => "NG");
|
|
|
+ template.RegisterVariable("DateTime", () => DateTime.Now);
|
|
|
+
|
|
|
+ // 生成文件名
|
|
|
+ imgName = template.Generate();
|
|
|
+ }
|
|
|
+ _eventAggregator.GetEvent<RenderUpdateNotification>().Publish(new ShowRender()
|
|
|
+ {
|
|
|
+ Id = procedure.Id,
|
|
|
+ Image = (ICogImage)procedure.ToolBlock.Inputs["InputImage"].Value,
|
|
|
+ Graphic = new CogGraphicCollection(),
|
|
|
+ Result = false,
|
|
|
+ IsShow = true,
|
|
|
+ IsSaveImage = procedure.IsSaveImage,
|
|
|
+ SaveImageModel = procedure.SaveImageModel,
|
|
|
+ SaveImagePathModel = procedure.SaveImagePathModel,
|
|
|
+ SavePath = procedure.SavePath,
|
|
|
+ IsCompress = procedure.IsCompress,
|
|
|
+ IsDelaySaveImage = procedure.IsDelaySaveImage,
|
|
|
+ ProceductName = procedure.Name,
|
|
|
+ ImageFileName = imgName
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ SendTaskMessage(ex.Message, MessageLevel.Error);
|
|
|
+ LogHelper.WriteLogError("执行相机取图并执行视觉工具组时出错!", ex);
|
|
|
+ outputCollection = null;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 执行拍照二维码流程运行
|
|
|
/// </summary>
|
|
|
@@ -1858,14 +2075,14 @@ namespace TeamAAS_VP.Services
|
|
|
/// <param name="positionIndex"></param>
|
|
|
/// <param name="remark"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<(bool IsSucceed, string distance, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex,int num, string remark, ImageParameters imgPara)
|
|
|
+ public async Task<(bool IsSucceed, string distance, double X, double Y, double U)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex, int num, string remark, ImageParameters imgPara)
|
|
|
{
|
|
|
var systemConfig = _configService.GetSystemConfiguration();
|
|
|
DateTime nowtime = DateTime.Now;
|
|
|
string cc = "999";
|
|
|
if (systemConfig.IsBasePartOpenLight)
|
|
|
{
|
|
|
- if (positionIndex == 0|| positionIndex==1)
|
|
|
+ if (positionIndex == 0 || positionIndex == 1)
|
|
|
{
|
|
|
await SetLightBeforePhoto(procedure);
|
|
|
}
|
|
|
@@ -1875,6 +2092,105 @@ namespace TeamAAS_VP.Services
|
|
|
await SetLightBeforePhoto(procedure);
|
|
|
}
|
|
|
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //拍照失败时,需要多次拍照
|
|
|
+ for (int i = 0; i < procedure.FeederFailLimit; i++)
|
|
|
+ {
|
|
|
+ SendTaskMessage(Lang.开始执行视觉流程.Replace("{0}", $"{i + 1}").Replace("{1}", procedure.Name), MessageLevel.Info);
|
|
|
+
|
|
|
+ // 1. 执行相机拍照并运行视觉工具
|
|
|
+ bool visionSucceed = ExecutePhoto(i + 1, procedure, InputTerminal, out CogToolBlockTerminalCollection outputCollection, imgPara);
|
|
|
+ if (!visionSucceed)
|
|
|
+ {
|
|
|
+ SendTaskMessage(Lang.视觉任务执行失败, MessageLevel.Error);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!outputCollection.Contains("Found"))
|
|
|
+ {
|
|
|
+ SendTaskMessage(Lang.未找到视觉输出结果, MessageLevel.Error);
|
|
|
+ await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
|
|
|
+ return (false, cc, 0, 0, 0);
|
|
|
+ }
|
|
|
+ // 2. 获取视觉输出结果
|
|
|
+ bool Found = (bool)(outputCollection["Found"].Value);
|
|
|
+ if (!Found)
|
|
|
+ {
|
|
|
+ SendTaskMessage(Lang.拍照NG, MessageLevel.Debug);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (outputCollection.Contains("CC"))
|
|
|
+ {
|
|
|
+ cc = outputCollection["CC"].Value.ToString();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ SendTaskMessage(Lang.拍照OK, MessageLevel.Debug);
|
|
|
+
|
|
|
+ if (procedure.CalibrationId == Guid.Empty)
|
|
|
+ {
|
|
|
+ //没有关联校准时,则执行检测任务
|
|
|
+ await RecordPhotoCaptureAsync(procedure, robotCoord, true, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
|
|
|
+ return (true, cc, 0, 0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 获取视觉输出结果
|
|
|
+ LogHelper.WriteLogInfo(Lang.开始获取视觉输出结果);
|
|
|
+ //获取相机校准
|
|
|
+ var calib = _calibrationService.GetCalibration(procedure.CalibrationId);
|
|
|
+ string points = (string)(outputCollection["Point"].Value);
|
|
|
+ string[] strpoints = points.Split(';');
|
|
|
+ //先将pos按照逗号进行分隔,拿到数组
|
|
|
+ var posParts = strpoints[0].Split(',');
|
|
|
+ double _pixel_x = double.Parse(posParts[0]);
|
|
|
+ double _pixel_y = double.Parse(posParts[1]);
|
|
|
+ double _pixel_u = double.Parse(posParts[2]);
|
|
|
+ //转换点位-像素转换成机器人绝对坐标
|
|
|
+ var calibResult = _calibrationService.ConvertPixelToPosition((_pixel_x, _pixel_y, _pixel_u), robotCoord, calib, RobotBrand.XYZ_Platform);
|
|
|
+ if (!calibResult.IsSucceed)
|
|
|
+ {
|
|
|
+ await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { _pixel_x, _pixel_y, _pixel_u }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
|
|
|
+ return (false, cc, 0, 0, 0);
|
|
|
+ }
|
|
|
+ await RecordPhotoCaptureAsync(procedure, robotCoord, true, new double[] { _pixel_x, _pixel_y, _pixel_u }, new double[] { calibResult.X, calibResult.Y, calibResult.U }, string.Empty, positionIndex, remark);
|
|
|
+ return (true, cc, calibResult.X, calibResult.Y, calibResult.U);
|
|
|
+ }
|
|
|
+ SendTaskMessage(Lang.多次拍照失败, MessageLevel.Alarm);
|
|
|
+ await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
|
|
|
+ return (false, cc, 0, 0, 0);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogHelper.WriteLogError(Lang.执行相机取图并获取单点位时出错, ex);
|
|
|
+ await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
|
|
|
+ return (false, cc, 0, 0, 0);
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ if (systemConfig.IsBasePartOpenLight)
|
|
|
+ {
|
|
|
+ if (positionIndex == num)
|
|
|
+ {
|
|
|
+ await TurnOffLightAfterPhoto(procedure);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await TurnOffLightAfterPhoto(procedure);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task<(bool IsSucceed, string item)> ExecutePhotoGetSinglePoint(ProcedureModel procedure, Dictionary<string, string> InputTerminal, double[] robotCoord, CancellationToken cancellationToken, int positionIndex, int num, string remark)
|
|
|
+ {
|
|
|
+ var systemConfig = _configService.GetSystemConfiguration();
|
|
|
+ DateTime nowtime = DateTime.Now;
|
|
|
+ string result = "";
|
|
|
+ return await Task.Run(async () =>
|
|
|
+ {
|
|
|
+ await SetLightBeforePhoto(procedure);
|
|
|
try
|
|
|
{
|
|
|
//拍照失败时,需要多次拍照
|
|
|
@@ -1883,7 +2199,7 @@ namespace TeamAAS_VP.Services
|
|
|
SendTaskMessage(Lang.开始执行视觉流程.Replace("{0}", $"{i + 1}").Replace("{1}", procedure.Name), MessageLevel.Info);
|
|
|
|
|
|
// 1. 执行相机拍照并运行视觉工具
|
|
|
- bool visionSucceed = ExecutePhoto(i + 1, procedure, InputTerminal, out CogToolBlockTerminalCollection outputCollection, imgPara);
|
|
|
+ bool visionSucceed = ExecutePhoto(i + 1, procedure, InputTerminal, out CogToolBlockTerminalCollection outputCollection, new ImageParameters());
|
|
|
if (!visionSucceed)
|
|
|
{
|
|
|
SendTaskMessage(Lang.视觉任务执行失败, MessageLevel.Error);
|
|
|
@@ -1893,80 +2209,40 @@ namespace TeamAAS_VP.Services
|
|
|
if (!outputCollection.Contains("Found"))
|
|
|
{
|
|
|
SendTaskMessage(Lang.未找到视觉输出结果, MessageLevel.Error);
|
|
|
- await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
|
|
|
- return (false,cc, 0, 0, 0);
|
|
|
- }
|
|
|
+ return (false, "");
|
|
|
+ }
|
|
|
// 2. 获取视觉输出结果
|
|
|
bool Found = (bool)(outputCollection["Found"].Value);
|
|
|
if (!Found)
|
|
|
{
|
|
|
SendTaskMessage(Lang.拍照NG, MessageLevel.Debug);
|
|
|
+ result = (string)(outputCollection["Point"].Value);
|
|
|
continue;
|
|
|
}
|
|
|
- if (outputCollection.Contains("CC"))
|
|
|
- {
|
|
|
- cc = outputCollection["CC"].Value.ToString();
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
SendTaskMessage(Lang.拍照OK, MessageLevel.Debug);
|
|
|
|
|
|
- if (procedure.CalibrationId == Guid.Empty)
|
|
|
- {
|
|
|
- //没有关联校准时,则执行检测任务
|
|
|
- await RecordPhotoCaptureAsync(procedure, robotCoord, true, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
|
|
|
- return (true,cc, 0, 0, 0);
|
|
|
- }
|
|
|
|
|
|
// 3. 获取视觉输出结果
|
|
|
LogHelper.WriteLogInfo(Lang.开始获取视觉输出结果);
|
|
|
//获取相机校准
|
|
|
- var calib = _calibrationService.GetCalibration(procedure.CalibrationId);
|
|
|
- string points = (string)(outputCollection["Point"].Value);
|
|
|
- string[] strpoints = points.Split(';');
|
|
|
- //先将pos按照逗号进行分隔,拿到数组
|
|
|
- var posParts = strpoints[0].Split(',');
|
|
|
- double _pixel_x = double.Parse(posParts[0]);
|
|
|
- double _pixel_y = double.Parse(posParts[1]);
|
|
|
- double _pixel_u = double.Parse(posParts[2]);
|
|
|
- //转换点位-像素转换成机器人绝对坐标
|
|
|
- var calibResult = _calibrationService.ConvertPixelToPosition((_pixel_x, _pixel_y, _pixel_u), robotCoord, calib, RobotBrand.XYZ_Platform);
|
|
|
- if (!calibResult.IsSucceed)
|
|
|
- {
|
|
|
- await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { _pixel_x, _pixel_y, _pixel_u }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
|
|
|
- return (false,cc, 0, 0, 0);
|
|
|
- }
|
|
|
- await RecordPhotoCaptureAsync(procedure, robotCoord, true, new double[] { _pixel_x, _pixel_y, _pixel_u }, new double[] { calibResult.X, calibResult.Y, calibResult.U }, string.Empty, positionIndex, remark);
|
|
|
- return (true,cc, calibResult.X, calibResult.Y, calibResult.U);
|
|
|
+ result = (string)(outputCollection["Point"].Value);
|
|
|
+ return (true, result);
|
|
|
}
|
|
|
SendTaskMessage(Lang.多次拍照失败, MessageLevel.Alarm);
|
|
|
- await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
|
|
|
- return (false, cc, 0, 0, 0);
|
|
|
+ return (false, result);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- LogHelper.WriteLogError(Lang.执行相机取图并获取单点位时出错, ex);
|
|
|
- await RecordPhotoCaptureAsync(procedure, robotCoord, false, new double[] { 0, 0, 0 }, new double[] { 0, 0, 0 }, string.Empty, positionIndex, remark);
|
|
|
- return (false, cc, 0, 0, 0);
|
|
|
+ return (false, "");
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
- if (systemConfig.IsBasePartOpenLight)
|
|
|
- {
|
|
|
- if (positionIndex == num)
|
|
|
- {
|
|
|
- await TurnOffLightAfterPhoto(procedure);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- await TurnOffLightAfterPhoto(procedure);
|
|
|
- }
|
|
|
-
|
|
|
+ await TurnOffLightAfterPhoto(procedure);
|
|
|
}
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 记录拍照结果数据至数据库
|
|
|
/// </summary>
|