From 6caa156ba8be9728b4cb67c7c7be326b0316f773 Mon Sep 17 00:00:00 2001
From: wells.liu <wells.liu@broconcentric.com>
Date: 星期四, 09 七月 2020 17:22:44 +0800
Subject: [PATCH] 板卡+数据库保存+excel导出

---
 src/Bro.M071.Process/M071Models.cs |   71 +++++++++++++++++++++++++----------
 1 files changed, 51 insertions(+), 20 deletions(-)

diff --git a/src/Bro.M071.Process/M071Models.cs b/src/Bro.M071.Process/M071Models.cs
index be596b7..f2c588f 100644
--- a/src/Bro.M071.Process/M071Models.cs
+++ b/src/Bro.M071.Process/M071Models.cs
@@ -3,6 +3,7 @@
 using Bro.Common.Helper;
 using Bro.Common.Interface;
 using Bro.Common.Model;
+using HalconDotNet;
 using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
@@ -11,6 +12,7 @@
 using System.Drawing.Design;
 using System.Linq;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 
 namespace Bro.M071.Process
@@ -73,7 +75,7 @@
     {
         public string GetDisplayText()
         {
-            return (IsEnabled ? "" : "绂佺敤 ") + Name + " " + string.Join(" ", Destination.Select(u => u.GetDisplayText())) + " " + CameraOp.GetDisplayText();
+            return (IsEnabled ? "" : "绂佺敤 ") + Name + " " + MotionOp.GetDisplayText() + " " + CameraOp.GetDisplayText();
         }
 
         public List<string> GetHalconToolPathList()
@@ -99,16 +101,22 @@
         [Description("true锛氬惎鐢� false锛氱鐢�")]
         public bool IsEnabled { get; set; } = true;
 
-        [Category("璁惧閰嶇疆")]
-        [Description("杩愬姩璁惧")]
-        [TypeConverter(typeof(DeviceSelectorConverter<IMotion>))]
-        public string MotionDevice { get; set; }
+        //[Category("璁惧閰嶇疆")]
+        //[Description("杩愬姩璁惧")]
+        //[TypeConverter(typeof(DeviceSelectorConverter<IMotion>))]
+        //public string MotionDevice { get; set; }
 
-        [Category("杩愬姩鐐逛綅")]
-        [Description("杩愬姩鐐逛綅")]
+        //[Category("杩愬姩鐐逛綅")]
+        //[Description("杩愬姩鐐逛綅")]
+        //[TypeConverter(typeof(ComplexObjectConvert))]
+        //[Editor(typeof(ComplexCollectionEditor<AxisInfo>), typeof(UITypeEditor))]
+        //public List<AxisInfo> Destination { get; set; } = new List<AxisInfo>();
+
+        [Category("杩愬姩鏈烘瀯閰嶇疆")]
+        [Description("杩愬姩鏈烘瀯閰嶇疆")]
         [TypeConverter(typeof(ComplexObjectConvert))]
-        [Editor(typeof(ComplexCollectionEditor<AxisInfo>), typeof(UITypeEditor))]
-        public List<AxisInfo> Destination { get; set; } = new List<AxisInfo>();
+        [Editor(typeof(IOperationConfigByDeviceEditor), typeof(UITypeEditor))]
+        public DeviceOpBind MotionOp { get; set; } = new DeviceOpBind();
 
         [Category("鐩告満鍜屾搷浣滈厤缃�")]
         [Description("鐩告満鍜屾搷浣滈厤缃�")]
@@ -129,13 +137,13 @@
             get => key;
             set
             {
-                AlignName = key = value;
+                AliasName = key = value;
             }
         }
 
         [Category("閿悕閰嶇疆")]
         [Description("鍒悕")]
-        public string AlignName { get; set; }
+        public string AliasName { get; set; }
 
         [Category("鍚敤璁剧疆")]
         [Description("true锛氬惎鐢� false锛氱鐢�")]
@@ -170,7 +178,7 @@
 
         public string GetDisplayText()
         {
-            return $"{AlignName}";
+            return $"{AliasName}";
         }
 
         public List<string> GetHalconToolPathList()
@@ -195,18 +203,25 @@
 
     public class ProductionMeasurement : INotifyPropertyChanged, IDisposable
     {
-        public string Barcode { get; set; }
+        public string Barcode;
+        public string PResult;
 
-        public List<MeasurementUint> Measurements { get; set; } = new List<MeasurementUint>();
+        public List<MeasurementUnit> Measurements = new List<MeasurementUnit>();
+
+        public List<IShapeElement> ElementList = new List<IShapeElement>();
+
+        public DateTime? StartTime = null;
+
+        public DateTime? EndTime = null;
 
         public event PropertyChangedEventHandler PropertyChanged;
 
         public void Dispose()
         {
-            Barcode = null;
-
             Measurements?.ForEach(m => m?.Dispose());
             Measurements = null;
+
+            Barcode = null;
             GC.Collect();
         }
 
@@ -225,7 +240,7 @@
         }
     }
 
-    public class MeasurementUint : IComplexDisplay, INotifyPropertyChanged, IDisposable
+    public class MeasurementUnit : IComplexDisplay, INotifyPropertyChanged, IDisposable
     {
         public string Id = Guid.NewGuid().ToString();
 
@@ -273,7 +288,7 @@
         {
             if (string.IsNullOrWhiteSpace(Name))
             {
-                return (IsEnabled ? "" : "绂佺敤 ") + string.Join("-", KeyUnitCollection.Select(u => u.GetDisplayText())) + "-" + MeasureType.ToString();
+                return (IsEnabled ? "" : "绂佺敤 ") + string.Join("-", KeyUnitCollection.Select(u => u.GetDisplayText())) + "-" + MeasureType?.ToString();
             }
             else
             {
@@ -302,8 +317,12 @@
         [Category("鍗曢敭閰嶇疆")]
         [Description("鍗曢敭缁撴灉閰嶇疆")]
         [TypeConverter(typeof(KeyUnitResultConverter))]
-        public string KeyResult { get; set; } = "";
+        public string KeyResultId { get; set; } = "";
 
+
+        public List<HImage> KeyImages = new List<HImage>();
+
+        public volatile int ImageSaveStatus = 0;
         //[Browsable(false)]
         //public NoticedDictionary<string, double?> MeasureValueDict { get; set; } = new NoticedDictionary<string, double?>();
 
@@ -328,13 +347,25 @@
         {
             string msg = Key;
 
-            msg += string.IsNullOrWhiteSpace(KeyResult) ? "" : $"-{KeyResult}";
+            msg += string.IsNullOrWhiteSpace(KeyResultId) ? "" : $"-{KeyResultId}";
 
             return msg;
         }
 
         public void Dispose()
         {
+            SpinWait wait = new SpinWait();
+            while (ImageSaveStatus != 0)
+            {
+                wait.SpinOnce();
+            }
+
+            KeyImages?.ForEach(i =>
+            {
+                i?.Dispose();
+                i = null;
+            });
+            KeyImages = null;
             MeasureValueDict = null;
         }
 

--
Gitblit v1.8.0