patrick
2019-12-10 1c4426810c71eead57084be8a18ade8d314dd8c4
src/A032.Process/ProcessConfig.cs
@@ -1,26 +1,23 @@
using Autofac;
using Bro.Common.Base;
using 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("设备配置")]
@@ -71,6 +68,10 @@
        [Editor(typeof(OperationConfigBindEditor), typeof(UITypeEditor))]
        public Dictionary<string, IOperationConfig> ProcessOpConfigDict { get; set; } = new Dictionary<string, IOperationConfig>();
        [Category("操作配置")]
        [Description("操作超时设置,单位min")]
        public int OperationTimeout { get; set; } = 10;
        //[Category("监听和操作配置")]
        //[Description("监听操作配置集合")]
        //[TypeConverter(typeof(CollectionCountConvert))]
@@ -102,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("是否做CSV文件输出")]
        [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
@@ -123,9 +126,9 @@
        //[Editor(typeof(ComplexCollectionEditor<WarningSet>), typeof(UITypeEditor))]
        //public List<WarningSet> WarningSets { get; set; } = new List<WarningSet>();
        [Category("PLC相关配置")]
        [Description("产品出列时是否有确认动作。true:有确认动作,确认后产品出列;false:没有确认动作,查询时产品出列")]
        public bool IsConfirmWhenProductionDone { get; set; } = false;
        //[Category("PLC相关配置")]
        //[Description("产品出列时是否有确认动作。true:有确认动作,确认后产品出列;false:没有确认动作,查询时产品出列")]
        //public bool IsConfirmWhenProductionDone { get; set; } = false;
        [Category("NG图片保存配置")]
        [Description("NG图片保存目录")]
@@ -137,6 +140,7 @@
        //[Description("是否采用外部算子。true:采用外部算子,false:使用内部算法")]
        //public bool IsUsingExternalAlgorithem { get; set; } = true;
        #region A032
        [Category("路径相关")]
        [Description("路径节点配置")]
        [TypeConverter(typeof(CollectionCountConvert))]
@@ -149,19 +153,25 @@
        [Editor(typeof(ComplexCollectionEditor<PositionVisionConfig>), typeof(UITypeEditor))]
        public List<PositionVisionConfig> VisionConfigCollection { get; set; } = new List<PositionVisionConfig>();
        /// <summary>
        /// 空Tray上料阈值,AGV上的空tray数量不大于该数值时,AGV可以执行空Tray上料任务
        /// </summary>
        [Category("阈值设置")]
        [Description("空Tray上料阈值,AGV上的空tray数量不大于该数值时,AGV可以执行空Tray上料任务")]
        public int AGV_EmptyTrayThreshold { get; set; } = 0;
        [Category("视觉配置")]
        [Description("是否启用视觉引导")]
        public bool IsEnableVisionGuide { get; set; } = false;
        /// <summary>
        /// 满Tray下料阈值,AGV上的满tray数量不小于该数值时,AGV可以执行满Tray下料任务
        /// </summary>
        [Category("阈值设置")]
        [Description("满Tray下料阈值,AGV上的满tray数量不小于该数值时,AGV可以执行满Tray下料任务")]
        public int AGV_FullTrayThreshold { get; set; } = 10;
        [Category("视觉配置")]
        [Description("视觉引导次数")]
        public int VisionGuideTimes { get; set; } = 2;
        [Category("设备参数配置")]
        [Description("光源开关索引配置")]
        public int LightOutputIndex { get; set; }
        [Category("设备参数配置")]
        [Description("AGV满载满Tray/空Tray数量")]
        public int AGVAvailableTrayNums { get; set; } = 6;
        [Category("设备参数配置")]
        [Description("默认等待任务轮数。当某些条件不满足当前任务执行前提,当前任务会等待若干任务数后执行")]
        public int DefaultWaitShift { get; set; } = 3;
        /// <summary>
        /// 产线忙时拍照确认等待间隔,以秒为单位
@@ -179,11 +189,43 @@
        [Category("阈值设置")]
        [Description("机台压机满Tray数量")]
        public int Machine_FullTrayNum { get; set; }
        public int Machine_FullTrayNum { get; set; } = 6;
        [Category("阈值设置")]
        [Description("机台压机空Tray数量")]
        public int Machine_EmptyTrayNum { get; set; }
        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)]
@@ -233,4 +275,23 @@
        public virtual bool IsDBSave { get; set; } = false;
        #endregion
    }
    [Device("OperationTest", "测试方法配置", DeviceAttributeType.OperationConfig)]
    public class OperationTestConfig : OperationConfigBase
    {
        //[Category("测试配置")]
        //[Description("方法类型")]
        //public TaskType TaskType { get; set; } = TaskType.LoadEmptyTrayToAGV;
        [Category("测试配置")]
        [Description("方法信息")]
        [TypeConverter(typeof(ComplexObjectConvert))]
        [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))]
        public TrayTask TaskInfo { get; set; } = new TrayTask();
        [Category("测试配置")]
        [Description("执行AGV设备")]
        [TypeConverter(typeof(AGVDeviceConverter))]
        public string AGVId { get; set; }
    }
}