ShaftControlCodes/src/BRS.Process/ProcessConfig.cs
2023-03-31 11:06:56 +08:00

336 lines
12 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BRS.Common.Base;
using BRS.Common.Model.Helper;
using BRS.Common.Interface;
using BRS.Common.Model;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Runtime.CompilerServices;
using static BRS.Common.Model.Helper.EnumHelper;
using XKRS.Device.TCPSever;
namespace BRS.Process
{
[BRS.Common.Model.Helper.Process("", EnumHelper.DeviceAttributeType.InitialConfig)]
public class ProcessConfigBase : IProcessConfig
{
[Category("站点配置")]
[DisplayName("站点名称")]
[Description("站点名称")]
public string StationCode { get; set; }
#region
[Browsable(false)]
[Category("项目配置")]
[Description("相机配置")]
[DisplayName("相机配置")]
[TypeConverter(typeof(CollectionCountConvert))]
[Editor(typeof(InitialConfigCollectionEditor<CameraInitialConfigBase>), typeof(UITypeEditor))]
public List<IInitialConfig> CameraConfigCollection { get; set; } = new List<IInitialConfig>();
[Category("设备配置")]
[Description("PLC配置")]
[DisplayName("PLC配置")]
[TypeConverter(typeof(CollectionCountConvert))]
[Editor(typeof(InitialConfigCollectionEditor<PLCInitialConfigBase>), typeof(UITypeEditor))]
public List<IInitialConfig> PLCConfigCollection { get; set; } = new List<IInitialConfig>();
//[Category("设备配置")]
//[Description("机械臂配置")]
//[DisplayName("机械臂配置")]
//[TypeConverter(typeof(CollectionCountConvert))]
//[Editor(typeof(InitialConfigCollectionEditor<RobotInitialConfigBase>), typeof(UITypeEditor))]
//public List<IInitialConfig> RobotConfigCollection { get; set; } = new List<IInitialConfig>();
[Category("设备配置")]
[Description("川崎机械臂配置")]
[DisplayName("川崎机械臂配置")]
[TypeConverter(typeof(CollectionCountConvert))]
[Editor(typeof(InitialConfigCollectionEditor<KawasakiTCPSeverRobotConfig>), typeof(UITypeEditor))]
public List<IInitialConfig> KawasakiRobotConfigCollection { get; set; } = new List<IInitialConfig>();
[Category("项目配置")]
[Description("检测配置")]
[DisplayName("检测配置")]
[TypeConverter(typeof(CollectionCountConvert))]
[Editor(typeof(InitialConfigCollectionEditor<InitialConfigBase>), typeof(UITypeEditor))]
public List<IInitialConfig> DeviceConfigs { get; set; } = new List<IInitialConfig>();
//[Category("设备配置")]
//[Description("过图配置")]
//[DisplayName("过图配置")]
//[TypeConverter(typeof(CollectionCountConvert))]
//[Editor(typeof(InitialConfigCollectionEditor<InitialConfigBase>), typeof(UITypeEditor))]
//public List<IInitialConfig> DeviceConfigs4 { get; set; } = new List<IInitialConfig>();
//[Category("设备配置")]
//[Description("JYDAM配置")]
//[DisplayName("JYDAM配置")]
//[TypeConverter(typeof(CollectionCountConvert))]
//[Editor(typeof(InitialConfigCollectionEditor<JYDAMInitialConfig>), typeof(UITypeEditor))]
//public List<IInitialConfig> JYDAMConfigCollection { get; set; } = new List<IInitialConfig>();
#endregion
// [Category("站点配置")]
// [DisplayName("站点名称")]
// [Description("站点名称")]
// public string StationCode111 { get; set; }
//[Category("全局配置")]
//[DisplayName("深度学习标注软件路径")]
//[Description("深度学习标注软件路径")]
//[Editor(typeof(ExeFileDialogEditor), typeof(UITypeEditor))]
//public string LabelMarkerPath { get; set; }
/*[Category("全局配置")]
[Description("正常运行模式:产品+检测+结果交互Debug调试模式产品+检测+固定结果Demo模式取像+固定结果(无检测)")]
[DisplayName("运行模式")]
public RunMode RunMode { get; set; }*/
//[Category("全局配置")]
//[DisplayName("视觉初始化图片")]
//[Description("视觉初始化图片:用于初始化时halcon预热")]
//[Editor(typeof(FileDialogEditor), typeof(UITypeEditor))]
//public string ImgPath { get; set; }
//[Category("离线模式")]
//[DisplayName("启用离线模式")]
//[Description("是否使用离线图片 true离线图片 false在线图片")]
//public bool IsImageOffline { get; set; }
//[Category("离线模式")]
//[DisplayName("图片来源路径")]
//[Description("离线检测图片路径,只有启用离线检测时才生效。")]
//[Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
//public string OfflineImagesDir { get; set; } = "";
[Category("日志配置")]
[Description("是否启用日志记录")]
[DisplayName("启用日志")]
public bool IsLogEnabled { get; set; }
private LogLevel defaultLogLevel = LogLevel.Information;
[Category("日志配置")]
[Description("默认日志级别。辅助-->详细-->信息-->动作-->错误-->警报-->异常")]
[DisplayName("日志保存级别")]
[TypeConverter(typeof(EnumDescriptionConverter<LogLevel>))]
public LogLevel DefaultLogLevel
{
get => defaultLogLevel;
set => Set(ref defaultLogLevel, value);
}
[Category("日志配置")]
[Description("是否启用CSV数据记录")]
[DisplayName("启用CSV")]
public bool IsCSVOutputEnabled { get; set; }
//[Category("日志配置")]
//[Description("是否启用动作时间记录CSV数据")]
//[DisplayName("启用时间CSV")]
//public bool IsEnableTimeRecordCSV { get; set; }
[Category("日志配置")]
[Description("日志文件夹路径")]
[DisplayName("日志文件夹路径")]
[Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
public string LogPath { get; set; } = "";
#if false
/// <summary>
/// 过图配置
/// </summary>
[Category("过图配置")]
[Description("检测任务列表")]
[DisplayName("检测任务列表")]
public bool IsSelectPic { get; set; }
//private LogLevel defaultLogLevel = LogLevel.Information;
[Category("过图配置")]
[Description("图片文件夹路径配置")]
[DisplayName("图片文件夹路径配置")]
[Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
public string SelectPICImagesDir { get; set; } = "";
//public LogLevel DefaultLogLevel
//{
// get => defaultLogLevel;
// set => Set(ref defaultLogLevel, value);
//}
[Category("过图配置")]
[Description("是否裁剪")]
[DisplayName("是否裁剪")]
public bool IsSelectCut { get; set; }
//[Category("日志配置")]
//[Description("是否启用动作时间记录CSV数据")]
//[DisplayName("启用时间CSV")]
//public bool IsEnableTimeRecordCSV { get; set; }
[Category("过图配置")]
[Description("裁剪图片保存路径配置")]
[DisplayName("裁剪图片保存路径配置")]
[Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
public string CutSelectPicPath { get; set; } = "";
#endif
//0726
//[Category("操作配置")]
//[Description("默认操作配置集合")]
//[DisplayName("默认操作配置")]
//[TypeConverter(typeof(CollectionCountConvert))]
//[Editor(typeof(ComplexCollectionEditor<MonitorSetBase>), typeof(UITypeEditor))]
//public List<IMonitorSet> MonitorSetCollection { get; set; } = new List<IMonitorSet>();
//[Category("OEE配置")]
//[Description("空闲时间判断阈值单位s。该时间段内没有产品产出认为进入待机时间")]
//[DisplayName("待机阈值")]
//public int IdleTimeThreshold { get; set; } = 10;
//[Category("OEE配置")]
//[Description("理想UPH单位pcs/hr")]
//[DisplayName("理想UPH")]
//public int IdealUPH { get; set; } = 6000;
//[Category("OEE配置")]
//[Description("true:保存OEE原始数据包括产出运行时间分布")]
//[DisplayName("OEE原始数据保存")]
//public bool Is_OEEData_Saved { get; set; } = false;
/// <summary>
/// 获取所有设备初始化配置对象,流程中要使用的设备,必须在此处添加并返回。
/// </summary>
/// <returns>返回所有设备初始化配置对象</returns>
public virtual List<IInitialConfig> GetAllDeviceInitialConfigs()
{
List<IInitialConfig> configs = new List<IInitialConfig>();
configs.AddRange(CameraConfigCollection);
configs.AddRange(PLCConfigCollection);
configs.AddRange(DeviceConfigs);
//configs.AddRange(RobotConfigCollection);
return configs;
}
public List<IMonitorSet> GetAllMonitorSet()
{
List<IMonitorSet> list = new List<IMonitorSet>();
//0726
// list.AddRange(MonitorSetCollection);
GetType().GetProperties().ToList().ForEach(p =>
{
var pValue = p.GetValue(this);
if (pValue is IMonitorConfig msCollection)
{
list.AddRange(msCollection.GetAllMonitorSet());
}
else if (pValue is IList enumList)
{
foreach (var temp in enumList)
{
if (temp is IMonitorConfig tempCollection)
{
list.AddRange(tempCollection.GetAllMonitorSet());
}
}
}
});
return list;
}
#region IPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
public virtual void Set<T>(ref T field, T newValue, [CallerMemberName] string propName = null)
{
if (!field.Equals(newValue))
{
field = newValue;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
}
}
public List<string> GetHalconToolPathList()
{
List<string> list = new List<string>();
GetType().GetProperties().ToList().ForEach(p =>
{
var pValue = p.GetValue(this);
if (pValue is IHalconToolPath hPath)
{
list.AddRange(hPath.GetHalconToolPathList());
}
else if (pValue is IList enumList)
{
foreach (var temp in enumList)
{
if (temp is IHalconToolPath tPath)
{
list.AddRange(tPath.GetHalconToolPathList());
}
}
}
});
return list.Distinct().ToList();
}
#endregion
}
[Device("SequenceDeviceOp", "设备连续操作配置", DeviceAttributeType.OperationConfig)]
public class SequenceDeviceOpConfig : OperationConfigBase
{
[Category("设备操作配置")]
[Description("操作重复次数")]
[DisplayName("操作重复次数")]
public int RepeatTime { get; set; } = 1;
[Category("设备操作配置")]
[Description("设备操作集合")]
[TypeConverter(typeof(CollectionCountConvert))]
[Editor(typeof(ComplexCollectionEditor<DeviceOpBind>), typeof(UITypeEditor))]
[DisplayName("设备操作集合")]
public List<DeviceOpBind> DeviceOpCollection { get; set; } = new List<DeviceOpBind>();
}
}