From 3c4a6cc29a06fb940d21c2bc0ff5bf7125ade771 Mon Sep 17 00:00:00 2001
From: xcd <834800634@qq.com>
Date: 星期四, 02 七月 2020 11:21:38 +0800
Subject: [PATCH] 优化修改

---
 src/Bro.M071.Process/M071Process.cs |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/src/Bro.M071.Process/M071Process.cs b/src/Bro.M071.Process/M071Process.cs
index 2667c4f..61f3aee 100644
--- a/src/Bro.M071.Process/M071Process.cs
+++ b/src/Bro.M071.Process/M071Process.cs
@@ -154,6 +154,8 @@
             }
         }
 
+        List<ProductionMeasurement> productionList = new List<ProductionMeasurement>();
+
         [ProcessMethod("", "StartJob", "寮�濮嬫壂鎻�", InvokeType.TestInvoke)]
         public ProcessResponse StartJob(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice)
         {
@@ -161,6 +163,12 @@
             {
                 throw new ProcessException("鏈緭鍏ヤ骇鍝佹潯鐮侊紝璇峰嬁寮�濮嬫祴閲�");
             }
+
+            //妫�鏌ヤ骇鍝佹斁缃甇K
+
+            //姘旂几鎺ㄥ姩鍘嬫澘绉诲姩鍒颁骇鍝佷笂鏂�
+
+            //鍘嬫澘鍘嬬揣浜у搧
 
             OnMeasureStart?.BeginInvoke(null, null);
 
@@ -175,6 +183,16 @@
                 Barcode = BarCode,
                 Measurements = measurements,
             };
+
+            var existedProduction = productionList.FirstOrDefault(u => u.Barcode == pMeasure.Barcode);
+            if (existedProduction != null)
+            {
+                productionList.Remove(existedProduction);
+                existedProduction.Dispose();
+                existedProduction = null;
+            }
+
+            productionList.Add(pMeasure);
 
             pMeasure.InitialMeasurementsPropertyChanged();
             pMeasure.PropertyChanged += MeasureProduction_PropertyChanged;
@@ -201,10 +219,6 @@
                       if (camera == null)
                           return;
 
-                      //IImageSet imgSet = camera.Snapshot(s.CameraOp.OpConfig);
-                      //if (imgSet == null)
-                      //    return;
-
                       HImage hImage = CollectHImage(camera, s.CameraOp.OpConfig, out string imgSetId);
                       if (string.IsNullOrWhiteSpace(imgSetId))
                       {
@@ -215,6 +229,9 @@
                   });
 
             BarCode = "";
+
+
+
             return new ProcessResponse(true);
         }
 
@@ -294,8 +311,12 @@
                                     }
                                 }
 
+                                LogAsync(DateTime.Now, $"{m.GetDisplayText()}妫�娴嬬粨鏋�", $"{((m.Spec.MeasureResult ?? false) ? "OK" : "NG")}");
+
+                                IShapeElement indicator = null;
+                                pMeasure.ElementList.Add(indicator);
                                 //杈撳嚭鍥惧舰鍩哄厓鍒扮晫闈� todo
-                                OnElementUpdated?.BeginInvoke(null, null, null);
+                                OnElementUpdated?.BeginInvoke(indicator, null, null);
 
                                 SaveKeyImages(pMeasure.Barcode, m);
 
@@ -309,8 +330,6 @@
                         return;
                     }
 
-
-
                     //MES杈撳嚭 todo
 
                     //Excel鎶ヨ〃杈撳嚭 todo
@@ -318,6 +337,8 @@
                     //鏁版嵁搴撲繚瀛� todo
 
                     SaveWholeImage(pMeasure);
+
+                    productionList.RemoveAll(p => p.Barcode == pMeasure.Barcode);
                     pMeasure.Dispose();
                 }
             }

--
Gitblit v1.8.0