From 1c4426810c71eead57084be8a18ade8d314dd8c4 Mon Sep 17 00:00:00 2001 From: patrick <patrick.xu@broconcentric.com> Date: 星期二, 10 十二月 2019 14:24:31 +0800 Subject: [PATCH] 1. 重构项目 --- src/A032.Process/ProcessConfig.cs | 191 ++++++++++++++++++++++++++++++----------------- 1 files changed, 122 insertions(+), 69 deletions(-) diff --git a/src/A032.Process/ProcessConfig.cs b/src/A032.Process/ProcessConfig.cs index 3640397..afe171a 100644 --- a/src/A032.Process/ProcessConfig.cs +++ b/src/A032.Process/ProcessConfig.cs @@ -1,26 +1,23 @@ -锘縰sing Autofac; -using Bro.Common.Base; +锘縰sing Bro.Common.Base; 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; using Bro.Device.SeerAGV; using Bro.Device.Station; using Newtonsoft.Json; -using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing.Design; using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Bro.Common.Helper.EnumHelper; namespace A032.Process { - public class ProcessConfig : IStationConfig + public class ProcessConfig : IStationConfig, IHalconToolPath { #region 璁惧閰嶇疆 [Category("璁惧閰嶇疆")] @@ -46,6 +43,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 +58,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 +103,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 +126,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 +140,7 @@ //[Description("鏄惁閲囩敤澶栭儴绠楀瓙銆倀rue锛氶噰鐢ㄥ閮ㄧ畻瀛愶紝false锛氫娇鐢ㄥ唴閮ㄧ畻娉�")] //public bool IsUsingExternalAlgorithem { get; set; } = true; + #region A032 [Category("璺緞鐩稿叧")] [Description("璺緞鑺傜偣閰嶇疆")] [TypeConverter(typeof(CollectionCountConvert))] @@ -140,8 +150,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 +276,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