From cdf12e1954c78e187b142c7d7a460ec7387067f7 Mon Sep 17 00:00:00 2001
From: xcd <834800634@qq.com>
Date: 星期五, 10 七月 2020 15:17:57 +0800
Subject: [PATCH] 配置变动和界面显示联动

---
 src/Bro.M071.Process/M071Process.cs |   38 ++++++++++++++++++++++----------------
 1 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/src/Bro.M071.Process/M071Process.cs b/src/Bro.M071.Process/M071Process.cs
index 1dea3b9..a7ce147 100644
--- a/src/Bro.M071.Process/M071Process.cs
+++ b/src/Bro.M071.Process/M071Process.cs
@@ -7,6 +7,7 @@
 using Bro.M071.Model.Model;
 using Bro.Process;
 using HalconDotNet;
+using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -221,11 +222,10 @@
                       if (camera == null)
                           return;
 
-                      string imgSetId = "";
-                      HImage hImage = null;
+                      IImageSet set = null;
                       try
                       {
-                          hImage = CollectHImage(camera, s.CameraOp.OpConfig, out imgSetId);
+                          set = CollectHImage(camera, s.CameraOp.OpConfig);
                       }
                       catch (ProcessException pEx)
                       {
@@ -233,12 +233,12 @@
                           throw pEx;
                       }
 
-                      if (string.IsNullOrWhiteSpace(imgSetId))
+                      if (set == null)
                       {
                           return;
                       }
 
-                      RunImageHandle(camera, s.CameraOp.OpConfig, hImage, s.Id, s.Name, pMeasure.Measurements);
+                      RunImageHandle(camera, s.CameraOp.OpConfig, set, s.Id, s.Name, pMeasure.Measurements);
                   });
 
             BarCode = "";
@@ -348,7 +348,7 @@
 
                                 IShapeElement indicator = null;
                                 pMeasure.ElementList.Add(indicator);
-                                //杈撳嚭鍥惧舰鍩哄厓鍒扮晫闈� todo
+                                //杈撳嚭鍥惧舰鍩哄厓鍒扮晫闈� 
                                 OnElementUpdated?.BeginInvoke(indicator, null, null);
 
                                 SaveKeyImages(pMeasure.Barcode, m);
@@ -378,6 +378,9 @@
                 var measurementUnitResultAndKeyUnitDataSet = GetMeasurementUnitResultAndKeyUnitData(pMeasure);
 
                 //MES杈撳嚭 todo
+                if (Config.IsEnableMESUpload)
+                { 
+                }
 
                 //Excel鎶ヨ〃杈撳嚭 锛堝崟涓骇鍝佺殑excel瀵煎嚭锛�
                 ExportProductionExcel(measurementUnitResultAndKeyUnitDataSet);
@@ -460,7 +463,7 @@
                     measurementUnitResult.ProductionMeasurementRecordsId = productionMeasurementRecords.ID;
                     measurementUnitResult.MeasurementName = MeasurementUnitResult.Name;
                     measurementUnitResult.MeasurementType = MeasurementUnitResult.MeasureType;
-                    measurementUnitResult.MeasurementValue = "";
+                    measurementUnitResult.MeasurementValue = MeasurementUnitResult.Spec.ActualValue.ToString();
                     measurementUnitResult.MeasurementResult = MeasurementUnitResult.Spec.MeasureResult.Value ? "OK" : "NG";
 
                     measurementUnitResults.Add(measurementUnitResult);
@@ -521,7 +524,7 @@
                 excelExportDto.WorksheetDataTable[excelExportDto.Worksheets[1]] = ExcelExportHelper.ListToDataTable(measurementUnitResultAndKeyUnitDataSet.MeasurementUnitResultList, measurementUnitResultColumns); ;
 
                 byte[] filecontent = ExcelExportHelper.ExportExcel(excelExportDto, false);
-                string dir = Path.Combine(Config.ImageSaveFolder, DateTime.Now.ToString("yyyyMMdd"));
+                string dir = Path.Combine(Config.LogPath, DateTime.Now.ToString("yyyyMMdd"));
                 if (!Directory.Exists(dir))
                 {
                     Directory.CreateDirectory(dir);
@@ -617,7 +620,7 @@
         }
         #endregion
 
-        private async void RunImageHandle(CameraBase camera, IOperationConfig opConfig, HImage hImage, string snapshotId, string snapshotName, List<MeasurementUnit> measureList)
+        private async void RunImageHandle(CameraBase camera, IOperationConfig opConfig, IImageSet imgSet, string snapshotId, string snapshotName, List<MeasurementUnit> measureList)
         {
             await Task.Run(() =>
              {
@@ -625,7 +628,8 @@
                  var keyBindCollection = measureList.SelectMany(u => u.KeyUnitCollection).Where(u => keys.Any(k => k.Key == u.Key)).ToList();
 
                  string toolKey = (opConfig as CameraOprerationConfigBase).AlgorithemPath;
-                 HObject images = hImage;
+                 HObject images = imgSet.HImage;
+                 LaserScanParam scanParam = JsonConvert.DeserializeObject<LaserScanParam>(imgSet.ImageData);
 
                  if (!string.IsNullOrWhiteSpace(toolKey))
                  {
@@ -637,7 +641,7 @@
                          return;
                      }
 
-                     _halconToolDict[toolKey].InputImageDic["INPUT_Image"] = hImage;
+                     _halconToolDict[toolKey].InputImageDic["INPUT_Image"] = imgSet.HImage;
                      if (!_halconToolDict[toolKey].RunProcedure(out string error))
                      {
                          LogAsync(DateTime.Now, $"{snapshotName}鍙栧浘绠楁硶寮傚父锛寋error}", "");
@@ -685,6 +689,8 @@
                              else
                              {
                                  _halconToolDict[keyToolKey].InputImageDic["INPUT_Image"] = image;
+                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_X"] = scanParam.Resolution_X;
+                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_Z"] = scanParam.Resolution_Z;
                                  if (!_halconToolDict[keyToolKey].RunProcedure(out string error))
                                  {
                                      LogAsync(DateTime.Now, $"{k.AliasName}妫�娴嬬畻娉曞紓甯革紝{error}", "");
@@ -717,11 +723,11 @@
                      image.Dispose();
                  });
 
-                 if (count.I != 1)
-                 {
-                     hImage?.Dispose();
-                     hImage = null;
-                 }
+                 //if (count.I != 1)
+                 //{
+                 //    hImage?.Dispose();
+                 //    hImage = null;
+                 //}
              });
         }
         #endregion

--
Gitblit v1.8.0