From b0a4c47dd74bc41c5df3bab6ddd8de7bcc6a52b0 Mon Sep 17 00:00:00 2001
From: patrick <patrick.xu@broconcentric.com>
Date: 星期五, 06 十二月 2019 18:35:42 +0800
Subject: [PATCH] 1. 重新整理项目,按照A034模式,将设备异步操作修改为类同步操作。使用任务队列来存储和分配任务。

---
 src/A032.Process/ProcessConfig.cs |  185 ++++++++++++++++++++++++++++++----------------
 1 files changed, 121 insertions(+), 64 deletions(-)

diff --git a/src/A032.Process/ProcessConfig.cs b/src/A032.Process/ProcessConfig.cs
index 3640397..f71d683 100644
--- a/src/A032.Process/ProcessConfig.cs
+++ b/src/A032.Process/ProcessConfig.cs
@@ -3,6 +3,7 @@
 using Bro.Common.Helper;
 using Bro.Common.Interface;
 using Bro.Common.Model;
+using Bro.Common.Model.Interface;
 using Bro.Device.AuboRobot;
 using Bro.Device.HikCamera;
 using Bro.Device.OmronFins;
@@ -20,7 +21,7 @@
 
 namespace A032.Process
 {
-    public class ProcessConfig : IStationConfig
+    public class ProcessConfig : IStationConfig, IHalconToolPath
     {
         #region 璁惧閰嶇疆
         [Category("璁惧閰嶇疆")]
@@ -46,6 +47,12 @@
         [TypeConverter(typeof(CollectionCountConvert))]
         [Editor(typeof(ComplexCollectionEditor<HikCameraInitialConfig>), typeof(UITypeEditor))]
         public List<HikCameraInitialConfig> CameraConfigCollection { get; set; } = new List<HikCameraInitialConfig>();
+
+        [Category("璁惧閰嶇疆")]
+        [Description("AGV灏忚溅璁惧缁戝畾閰嶇疆锛岄厤缃粦瀹氱殑AGV锛屾満鍣ㄤ汉鍜岀浉鏈轰俊鎭�")]
+        [TypeConverter(typeof(CollectionCountConvert))]
+        [Editor(typeof(ComplexCollectionEditor<AGVBindUnit>), typeof(UITypeEditor))]
+        public List<AGVBindUnit> AGVBindCollection { get; set; } = new List<AGVBindUnit>();
         #endregion
 
         #region 鎿嶄綔閰嶇疆
@@ -55,15 +62,19 @@
         //[Editor(typeof(MonitorSetBindEditor), typeof(UITypeEditor))]
         //public Dictionary<string, MonitorSet> PLCMonitorSet { get; set; } = new Dictionary<string, MonitorSet>();
 
-        ///// <summary>
-        ///// 鎿嶄綔閰嶇疆鐨勫瓧鍏搁泦鍚�
-        ///// Key锛歁ethodCode锛孷alue锛氭搷浣滈厤缃�
-        ///// </summary>
-        //[Category("鎿嶄綔閰嶇疆")]
-        //[Description("鎿嶄綔閰嶇疆闆嗗悎")]
-        //[TypeConverter(typeof(CollectionCountConvert))]
-        //[Editor(typeof(OperationConfigBindEditor), typeof(UITypeEditor))]
-        //public Dictionary<string, IOperationConfig> ProcessOpConfigDict { get; set; } = new Dictionary<string, IOperationConfig>();
+        /// <summary>
+        /// 鎿嶄綔閰嶇疆鐨勫瓧鍏搁泦鍚�
+        /// Key锛歁ethodCode锛孷alue锛氭搷浣滈厤缃�
+        /// </summary>
+        [Category("鎿嶄綔閰嶇疆")]
+        [Description("榛樿鎿嶄綔閰嶇疆闆嗗悎")]
+        [TypeConverter(typeof(CollectionCountConvert))]
+        [Editor(typeof(OperationConfigBindEditor), typeof(UITypeEditor))]
+        public Dictionary<string, IOperationConfig> ProcessOpConfigDict { get; set; } = new Dictionary<string, IOperationConfig>();
+
+        [Category("鎿嶄綔閰嶇疆")]
+        [Description("鎿嶄綔瓒呮椂璁剧疆锛屽崟浣峬in")]
+        public int OperationTimeout { get; set; } = 10;
 
         //[Category("鐩戝惉鍜屾搷浣滈厤缃�")]
         //[Description("鐩戝惉鎿嶄綔閰嶇疆闆嗗悎")]
@@ -96,18 +107,20 @@
         [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
         public string LogPath { get; set; }
 
-        [Category("鏃ュ織閰嶇疆")]
-        [Description("GRR鏃ュ織鏂囦欢澶硅矾寰�")]
-        [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
-        public string GRRLogPath { get; set; }
+        //[Category("鏃ュ織閰嶇疆")]
+        //[Description("GRR鏃ュ織鏂囦欢澶硅矾寰�")]
+        //[Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
+        //public string GRRLogPath { get; set; }
 
         [Category("CSV鏂囦欢閰嶇疆")]
         [Description("鏄惁鍋欳SV鏂囦欢杈撳嚭")]
+        [Browsable(false)]
         public bool IsCSVOutput { get; set; } = false;
 
         [Category("CSV鏂囦欢閰嶇疆")]
         [Description("CSV杈撳嚭鏂囦欢澶硅矾寰�")]
         [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
+        [Browsable(false)]
         public string CSVFilePath { get; set; }
         #endregion
 
@@ -117,9 +130,9 @@
         //[Editor(typeof(ComplexCollectionEditor<WarningSet>), typeof(UITypeEditor))]
         //public List<WarningSet> WarningSets { get; set; } = new List<WarningSet>();
 
-        [Category("PLC鐩稿叧閰嶇疆")]
-        [Description("浜у搧鍑哄垪鏃舵槸鍚︽湁纭鍔ㄤ綔銆倀rue锛氭湁纭鍔ㄤ綔锛岀‘璁ゅ悗浜у搧鍑哄垪锛沠alse锛氭病鏈夌‘璁ゅ姩浣滐紝鏌ヨ鏃朵骇鍝佸嚭鍒�")]
-        public bool IsConfirmWhenProductionDone { get; set; } = false;
+        //[Category("PLC鐩稿叧閰嶇疆")]
+        //[Description("浜у搧鍑哄垪鏃舵槸鍚︽湁纭鍔ㄤ綔銆倀rue锛氭湁纭鍔ㄤ綔锛岀‘璁ゅ悗浜у搧鍑哄垪锛沠alse锛氭病鏈夌‘璁ゅ姩浣滐紝鏌ヨ鏃朵骇鍝佸嚭鍒�")]
+        //public bool IsConfirmWhenProductionDone { get; set; } = false;
 
         [Category("NG鍥剧墖淇濆瓨閰嶇疆")]
         [Description("NG鍥剧墖淇濆瓨鐩綍")]
@@ -131,6 +144,7 @@
         //[Description("鏄惁閲囩敤澶栭儴绠楀瓙銆倀rue锛氶噰鐢ㄥ閮ㄧ畻瀛愶紝false锛氫娇鐢ㄥ唴閮ㄧ畻娉�")]
         //public bool IsUsingExternalAlgorithem { get; set; } = true;
 
+        #region A032
         [Category("璺緞鐩稿叧")]
         [Description("璺緞鑺傜偣閰嶇疆")]
         [TypeConverter(typeof(CollectionCountConvert))]
@@ -140,8 +154,82 @@
         [Category("璺緞鐩稿叧")]
         [Description("鍚勪綅缃爣瀹氱煩闃�")]
         [TypeConverter(typeof(CollectionCountConvert))]
-        [Editor(typeof(ComplexCollectionEditor<PositionMatrix>), typeof(UITypeEditor))]
-        public List<PositionMatrix> MatrixCollection { get; set; } = new List<PositionMatrix>();
+        [Editor(typeof(ComplexCollectionEditor<PositionVisionConfig>), typeof(UITypeEditor))]
+        public List<PositionVisionConfig> VisionConfigCollection { get; set; } = new List<PositionVisionConfig>();
+
+        [Category("瑙嗚閰嶇疆")]
+        [Description("鏄惁鍚敤瑙嗚寮曞")]
+        public bool IsEnableVisionGuide { get; set; } = false;
+
+        [Category("瑙嗚閰嶇疆")]
+        [Description("瑙嗚寮曞娆℃暟")]
+        public int VisionGuideTimes { get; set; } = 2;
+
+        [Category("璁惧鍙傛暟閰嶇疆")]
+        [Description("鍏夋簮寮�鍏崇储寮曢厤缃�")]
+        public int LightOutputIndex { get; set; }
+
+        [Category("璁惧鍙傛暟閰嶇疆")]
+        [Description("AGV婊¤浇婊ray/绌篢ray鏁伴噺")]
+        public int AGVAvailableTrayNums { get; set; } = 6;
+
+        [Category("璁惧鍙傛暟閰嶇疆")]
+        [Description("榛樿绛夊緟浠诲姟杞暟銆傚綋鏌愪簺鏉′欢涓嶆弧瓒冲綋鍓嶄换鍔℃墽琛屽墠鎻愶紝褰撳墠浠诲姟浼氱瓑寰呰嫢骞蹭换鍔℃暟鍚庢墽琛�")]
+        public int DefaultWaitShift { get; set; } = 3;
+
+        /// <summary>
+        /// 浜х嚎蹇欐椂鎷嶇収纭绛夊緟闂撮殧锛屼互绉掍负鍗曚綅
+        /// </summary>
+        [Category("闃堝�艰缃�")]
+        [Description("浜х嚎蹇欐椂鎷嶇収纭绛夊緟闂撮殧锛屼互绉掍负鍗曚綅")]
+        public int LineBusyWaitInterval { get; set; } = 60;
+
+        /// <summary>
+        /// 浜х嚎蹇欐椂鎷嶇収閲嶈瘯娆℃暟
+        /// </summary>
+        [Category("闃堝�艰缃�")]
+        [Description("浜х嚎蹇欐椂鎷嶇収閲嶈瘯娆℃暟")]
+        public int LineBusyRetryTimes { get; set; } = 10;
+
+        [Category("闃堝�艰缃�")]
+        [Description("鏈哄彴鍘嬫満婊ray鏁伴噺")]
+        public int Machine_FullTrayNum { get; set; } = 6;
+
+        [Category("闃堝�艰缃�")]
+        [Description("鏈哄彴鍘嬫満绌篢ray鏁伴噺")]
+        public int Machine_EmptyTrayNum { get; set; } = 6;
+        #endregion
+
+        #region IHalconToolPath
+        public List<string> GetHalconToolPathList()
+        {
+            List<string> list = new List<string>();
+
+            ProcessOpConfigDict.Values.ToList().ForEach(c =>
+            {
+                if (c is IHalconToolPath)
+                {
+                    list.AddRange((c as IHalconToolPath).GetHalconToolPathList());
+                }
+            });
+
+            this.GetType().GetProperties().ToList().ForEach(p =>
+            {
+                var pValue = p.GetValue(this);
+
+                if (pValue is IHalconToolPath)
+                {
+                    list.AddRange((pValue as IHalconToolPath).GetHalconToolPathList());
+                }
+                else if (pValue is IEnumerable<IHalconToolPath>)
+                {
+                    list.AddRange((pValue as IEnumerable<IHalconToolPath>).SelectMany(u => u.GetHalconToolPathList()));
+                }
+            });
+
+            return list.Distinct().ToList();
+        }
+        #endregion
 
         #region Ignore
         [Browsable(false)]
@@ -192,53 +280,22 @@
         #endregion
     }
 
-    public class PathPosition : IComplexDisplay
+    [Device("OperationTest", "娴嬭瘯鏂规硶閰嶇疆", DeviceAttributeType.OperationConfig)]
+    public class OperationTestConfig : OperationConfigBase
     {
-        [Category("瀵艰埅璺緞")]
-        [Description("璺緞鑺傜偣浠g爜")]
-        public string PositionCode { get; set; }
+        //[Category("娴嬭瘯閰嶇疆")]
+        //[Description("鏂规硶绫诲瀷")]
+        //public TaskType TaskType { get; set; } = TaskType.LoadEmptyTrayToAGV;
 
-        [Category("瀵艰埅璺緞")]
-        [Description("璺緞鑺傜偣鎻忚堪")]
-        public string Description { get; set; }
+        [Category("娴嬭瘯閰嶇疆")]
+        [Description("鏂规硶淇℃伅")]
+        [TypeConverter(typeof(ComplexObjectConvert))]
+        [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))]
+        public TrayTask TaskInfo { get; set; } = new TrayTask();
 
-        public string GetDisplayText()
-        {
-            return $"{PositionCode}-{Description}";
-        }
-    }
-
-    public class PositionMatrix : IComplexDisplay
-    {
-        [Category("浣嶇疆鐭╅樀")]
-        [Description("浣嶇疆浠g爜")]
-        [TypeConverter(typeof(PositionCodeConverter))]
-        public string PositionCode { get; set; }
-
-        [Category("浣嶇疆鐭╅樀")]
-        [Description("璇ヤ綅缃爣瀹氱煩闃�")]
-        [TypeConverter(typeof(SimpleCollectionConvert<double>))]
-        public List<double> Matrix { get; set; } = new List<double>();
-
-        public string GetDisplayText()
-        {
-            return $"{PositionCode}:{string.Join(",", Matrix)}";
-        }
-    }
-
-    public class PositionCodeConverter : ComboBoxItemTypeConvert
-    {
-        public override void GetConvertHash()
-        {
-            using (var scope = GlobalVar.Container.BeginLifetimeScope())
-            {
-                var config = scope.Resolve<ProcessConfig>();
-
-                config.PositionCollection.ForEach(p =>
-                {
-                    _hash[p.PositionCode] = $"{p.PositionCode}-{p.Description}";
-                });
-            }
-        }
+        [Category("娴嬭瘯閰嶇疆")]
+        [Description("鎵цAGV璁惧")]
+        [TypeConverter(typeof(AGVDeviceConverter))]
+        public string AGVId { get; set; }
     }
 }

--
Gitblit v1.8.0