using Autofac; using Bro.Common.Base; using Bro.Common.Helper; using Bro.Common.Interface; using Bro.Common.Model; 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 { #region 设备配置 [Category("设备配置")] [Description("PLC配置")] [TypeConverter(typeof(CollectionCountConvert))] [Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] public List PLCConfigCollection { get; set; } = new List(); [Category("设备配置")] [Description("机器人配置")] [TypeConverter(typeof(CollectionCountConvert))] [Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] public List RobotConfigCollection { get; set; } = new List(); [Category("设备配置")] [Description("AGV配置")] [TypeConverter(typeof(CollectionCountConvert))] [Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] public List AGVConfigCollection { get; set; } = new List(); [Category("设备配置")] [Description("相机配置")] [TypeConverter(typeof(CollectionCountConvert))] [Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] public List CameraConfigCollection { get; set; } = new List(); #endregion #region 操作配置 //[Category("操作配置")] //[Description("PLC监听配置")] //[TypeConverter(typeof(CollectionCountConvert))] //[Editor(typeof(MonitorSetBindEditor), typeof(UITypeEditor))] //public Dictionary PLCMonitorSet { get; set; } = new Dictionary(); ///// ///// 操作配置的字典集合 ///// Key:MethodCode,Value:操作配置 ///// //[Category("操作配置")] //[Description("操作配置集合")] //[TypeConverter(typeof(CollectionCountConvert))] //[Editor(typeof(OperationConfigBindEditor), typeof(UITypeEditor))] //public Dictionary ProcessOpConfigDict { get; set; } = new Dictionary(); //[Category("监听和操作配置")] //[Description("监听操作配置集合")] //[TypeConverter(typeof(CollectionCountConvert))] //[Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] //public List MonitorSetCollection { get; set; } = new List(); #endregion #region 全局配置 [Category("全局配置")] [Description("是否采用离线图片")] public virtual bool IsImageOffline { get; set; } = false; [Category("Demo模式")] [Description("是否测试模式 测试模式下始终反馈OK信号")] public virtual bool IsDemoMode { get; set; } = false; //[Category("Demo模式")] //[Description("测试模式下程序启动时反馈1至该地址,非测试模式反馈0")] //public int DemoReplayAddress { get; set; } #endregion #region 日志和CSV配置 [Category("日志配置")] [Description("是否启用日志")] public bool IsLogEnabled { get; set; } = false; [Category("日志配置")] [Description("日志文件夹路径")] [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))] public string LogPath { get; set; } [Category("日志配置")] [Description("GRR日志文件夹路径")] [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))] public string GRRLogPath { get; set; } [Category("CSV文件配置")] [Description("是否做CSV文件输出")] public bool IsCSVOutput { get; set; } = false; [Category("CSV文件配置")] [Description("CSV输出文件夹路径")] [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))] public string CSVFilePath { get; set; } #endregion //[Category("PLC相关配置")] //[Description("警报配置列表")] //[TypeConverter(typeof(CollectionCountConvert))] //[Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] //public List WarningSets { get; set; } = new List(); [Category("PLC相关配置")] [Description("产品出列时是否有确认动作。true:有确认动作,确认后产品出列;false:没有确认动作,查询时产品出列")] public bool IsConfirmWhenProductionDone { get; set; } = false; [Category("NG图片保存配置")] [Description("NG图片保存目录")] [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))] [Browsable(false)] public string NGImageFolderPath { get; set; } //[Category("算法配置")] //[Description("是否采用外部算子。true:采用外部算子,false:使用内部算法")] //public bool IsUsingExternalAlgorithem { get; set; } = true; [Category("路径相关")] [Description("路径节点配置")] [TypeConverter(typeof(CollectionCountConvert))] [Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] public List PositionCollection { get; set; } = new List(); [Category("路径相关")] [Description("各位置标定矩阵")] [TypeConverter(typeof(CollectionCountConvert))] [Editor(typeof(ComplexCollectionEditor), typeof(UITypeEditor))] public List MatrixCollection { get; set; } = new List(); #region Ignore [Browsable(false)] [JsonIgnore] public List CTStatistic { get; set; } [Browsable(false)] [JsonIgnore] public bool IsUseMountCorrectionLimit { get; set; } [Browsable(false)] [JsonIgnore] public List MountCorrectionRanges { get; set; } [Category("全局配置")] [Description("超时时间设置,单位为毫秒")] [Browsable(false)] public int TimeOut { get; set; } = 9999; //[Category("全局配置")] //[Description("空闲时间设置,当机器空闲时间超过该值,认为机器开始空闲,单位为秒")] //public int IdleTimeThreshold { get; set; } = 60; [Category("全局配置")] [Description("站点代码 例如S1")] [ReadOnly(true)] [Browsable(false)] [JsonIgnore] public virtual string StationCode { get; set; } [Category("全局配置")] [Description("站点序号,从1开始")] [Browsable(false)] [JsonIgnore] public virtual int SequenceIndex { get; set; } [Category("全局配置")] [Description("是否做过站检查")] [Browsable(false)] [JsonIgnore] public virtual bool IsCheckPrePass { get; set; } = false; [Category("全局配置")] [Description("是否数据库保存")] [Browsable(false)] [JsonIgnore] public virtual bool IsDBSave { get; set; } = false; #endregion } public class PathPosition : IComplexDisplay { [Category("导航路径")] [Description("路径节点代码")] public string PositionCode { get; set; } [Category("导航路径")] [Description("路径节点描述")] public string Description { get; set; } public string GetDisplayText() { return $"{PositionCode}-{Description}"; } } public class PositionMatrix : IComplexDisplay { [Category("位置矩阵")] [Description("位置代码")] [TypeConverter(typeof(PositionCodeConverter))] public string PositionCode { get; set; } [Category("位置矩阵")] [Description("该位置标定矩阵")] [TypeConverter(typeof(SimpleCollectionConvert))] public List Matrix { get; set; } = new List(); 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(); config.PositionCollection.ForEach(p => { _hash[p.PositionCode] = $"{p.PositionCode}-{p.Description}"; }); } } } }