From 6f92829951f3ec228b18df8c157239573edd9cb4 Mon Sep 17 00:00:00 2001
From: xcd <834800634@qq.com>
Date: 星期三, 09 九月 2020 15:20:53 +0800
Subject: [PATCH] 1. 取消ImageSet中的HImage释放动作,转移到业务流程中 2. 拆分板卡的IO监听和轴状态,轴位置监听

---
 src/Bro.M071.Process/M071Models.cs |   86 ++++++++++++++++++++++++++++++++++---------
 1 files changed, 68 insertions(+), 18 deletions(-)

diff --git a/src/Bro.M071.Process/M071Models.cs b/src/Bro.M071.Process/M071Models.cs
index d9a40ac..a56f47c 100644
--- a/src/Bro.M071.Process/M071Models.cs
+++ b/src/Bro.M071.Process/M071Models.cs
@@ -17,6 +17,28 @@
 
 namespace Bro.M071.Process
 {
+    public class KeyLocation : IComplexDisplay
+    {
+        [Category("閿悕閰嶇疆")]
+        [Description("鍗曢敭閿悕")]
+        [TypeConverter(typeof(KeyNameDictConverter))]
+        public string Key { get; set; }
+
+        [Category("浣嶇疆閰嶇疆")]
+        [Description("鍗曢敭鍦ㄩ敭鐩樺钩闈㈠浘涓婄殑浣嶇疆鏄剧ず")]
+        public Rectangle KeyRect { get; set; } = new Rectangle();
+
+        [Category("浣嶇疆閰嶇疆")]
+        [Description("鍗曢敭涔嬪悗闂撮殭浣嶇疆")]
+        public Rectangle IntervalRect { get; set; } = new Rectangle();
+
+        public string GetDisplayText()
+        {
+            return $"{Key}:{KeyRect.X},{KeyRect.Y},{KeyRect.Width},{KeyRect.Height}";
+        }
+    }
+
+
     public class KeyAlgorithem : IComplexDisplay
     {
         [Browsable(false)]
@@ -75,7 +97,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()
@@ -101,16 +123,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("鐩告満鍜屾搷浣滈厤缃�")]
@@ -131,13 +159,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锛氱鐢�")]
@@ -172,7 +200,22 @@
 
         public string GetDisplayText()
         {
-            return $"{AlignName}";
+            string snapShot = "鏈寚瀹�";
+
+            using (var scope = GlobalVar.Container.BeginLifetimeScope())
+            {
+                var config = scope.Resolve<IProcessConfig>();
+                if (config != null)
+                {
+                    var snapshotPoint = (config as M071Config).SnapshotPointCollection.FirstOrDefault(u => u.Id == SnapshotPointId);
+                    if (snapshotPoint != null)
+                    {
+                        snapShot = snapshotPoint.Name;
+                    }
+                }
+            }
+
+            return $"{AliasName}-{snapShot}-{ImageSeq}";
         }
 
         public List<string> GetHalconToolPathList()
@@ -198,10 +241,15 @@
     public class ProductionMeasurement : INotifyPropertyChanged, IDisposable
     {
         public string Barcode;
+        public string PResult;
 
-        public List<MeasurementUint> Measurements = 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;
 
@@ -229,7 +277,7 @@
         }
     }
 
-    public class MeasurementUint : IComplexDisplay, INotifyPropertyChanged, IDisposable
+    public class MeasurementUnit : IComplexDisplay, INotifyPropertyChanged, IDisposable
     {
         public string Id = Guid.NewGuid().ToString();
 
@@ -256,7 +304,7 @@
 
         #region 鏄剧ず
         [Browsable(false)]
-        public Rectangle DisplayLocation { get; set; } = new Rectangle();
+        public Rectangle DisplayLocation { get; set; } = new Rectangle(10, 10, 100, 100);
         #endregion
 
         #region 妫�娴嬬粨鏋�
@@ -277,7 +325,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
             {
@@ -306,7 +354,7 @@
         [Category("鍗曢敭閰嶇疆")]
         [Description("鍗曢敭缁撴灉閰嶇疆")]
         [TypeConverter(typeof(KeyUnitResultConverter))]
-        public string KeyResult { get; set; } = "";
+        public string KeyResultId { get; set; } = "";
 
 
         public List<HImage> KeyImages = new List<HImage>();
@@ -336,7 +384,7 @@
         {
             string msg = Key;
 
-            msg += string.IsNullOrWhiteSpace(KeyResult) ? "" : $"-{KeyResult}";
+            msg += string.IsNullOrWhiteSpace(KeyResultId) ? "" : $"-{KeyResultId}";
 
             return msg;
         }
@@ -366,6 +414,8 @@
                 if (valuePairs == null || valuePairs.Count == 0)
                 {
                     IsDone = false;
+                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsDone"));
+                    return;
                 }
 
                 foreach (KeyValuePair<string, double> pair in valuePairs)

--
Gitblit v1.8.0