| | |
| | | using Bro.Common.Model; |
| | | using Bro.M135.Common; |
| | | using Bro.Process; |
| | | using Newtonsoft.Json; |
| | | using System.ComponentModel; |
| | | using System.Drawing.Design; |
| | | using System.Drawing.Imaging; |
| | | using System.Drawing.Printing; |
| | | using System.Reflection; |
| | | using System.Windows.Forms.Design; |
| | | using static Bro.Common.Helper.EnumHelper; |
| | | |
| | | namespace Bro.M141.Process |
| | | { |
| | | public class M141Config : ProcessConfigBase |
| | | { |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | [Category("打印机配置")] |
| | | [Description("打印机配置集合")] |
| | | [DisplayName("打印机配置集合")] |
| | | [TypeConverter(typeof(CollectionCountConvert))] |
| | | [Editor(typeof(ComplexCollectionEditor<Printer>), typeof(UITypeEditor))] |
| | | public List<Printer> Printers { get; set; } = new List<Printer>(); |
| | | |
| | | |
| | | |
| | | [Category("产品显示界面配置")] |
| | | [Description("字体大小")] |
| | | [DisplayName("字体大小")] |
| | | public int FontSize_p { get; set; } = 15; |
| | | |
| | | |
| | | [Category("产品显示界面配置")] |
| | | [Description("每行列数")] |
| | |
| | | [Category("检测异常指示")] |
| | | [Description("选择某个Spec,其表示检测过程中异常")] |
| | | [DisplayName("异常指示标准")] |
| | | [TypeConverter(typeof(SpecCodeSelectorConverter))] |
| | | [TypeConverter(typeof(SpecCodeSelectorConverter))] |
| | | public string CheckErrorSpecCode { get; set; } = ""; |
| | | |
| | | |
| | | [Category("特定缺陷配置")] |
| | | [Description("S3和S5共同判断缺陷")] |
| | | [DisplayName("缺陷名称")] |
| | | [TypeConverter(typeof(GlobalDefectNameConverter))] |
| | | public string defectname { get; set; } = ""; |
| | | |
| | | private class GlobalDefectNameConverter : StringConverter |
| | | { |
| | | public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | public override bool GetStandardValuesSupported(ITypeDescriptorContext? context) |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | public override StandardValuesCollection? GetStandardValues(ITypeDescriptorContext? context) |
| | | { |
| | | using (var scope = GlobalVar.Container.BeginLifetimeScope()) |
| | | { |
| | | var config = scope.Resolve<IProcessConfig>(); |
| | | |
| | | return new StandardValuesCollection((config as IDefectSwitcher).DefectSwitchCollection.Select(u => u.DefectName).ToList()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | [Category("位置度设置")] |
| | |
| | | public ImageFormat ImageFormatOK { get; set; } = ImageFormat.Png; |
| | | |
| | | |
| | | |
| | | [Category("数据库配置")] |
| | | [Description("IP")] |
| | | [DisplayName("IP")] |
| | | public string IPforall { get; set; } = "192.168.44.122"; |
| | | |
| | | [Category("数据库配置")] |
| | | [Description("是否为终点设备")] |
| | | [DisplayName("是否为终点设备")] |
| | | public bool IsfinDevice { get; set; } = false; |
| | | |
| | | |
| | | |
| | | |
| | | [Category("栏具条码配置")] |
| | | [Description("当前栏具码")] |
| | | [DisplayName("当前栏具码")] |
| | | public string basketcode { get; set; } = "NoRead"; |
| | | |
| | | [Category("栏具条码配置")] |
| | | [Description("本站是否读取栏具码")] |
| | | [DisplayName("本站是否读取栏具码")] |
| | | public bool Isreadbasketcode { get; set; } = false; |
| | | |
| | | |
| | | [Category("PLC配置")] |
| | | [Description("报警配置")] |
| | | [DisplayName("报警配置")] |
| | | [TypeConverter(typeof(CollectionCountConvert))] |
| | | [Editor(typeof(ComplexCollectionEditor<PLCAlarms>), typeof(UITypeEditor))] |
| | | public List<PLCAlarms> PLCAlarm { get; set; } = new List<PLCAlarms>(); |
| | | |
| | | |
| | | [Category("PLC配置")] |
| | | [Description("心跳地址")] |
| | | [DisplayName("心跳地址")] |
| | | public int heartadd { get; set; } = 1505; |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | public class WorkPositionSet : IComplexDisplay |
| | | { |
| | | [Category("plc地址")] |
| | | [Description("是否取图即完成")] |
| | | [DisplayName("是否取图即完成")] |
| | | public bool ispiccover { get; set; } = false; |
| | | |
| | | |
| | | [Category("plc地址")] |
| | | [Description("完成地址")] |
| | | [DisplayName("完成地址")] |
| | |
| | | |
| | | |
| | | |
| | | public class PLCAlarms : IComplexDisplay |
| | | { |
| | | |
| | | [Category("PLC配置")] |
| | | [DisplayName("plc名称")] |
| | | [Description("plc名称")] |
| | | [TypeConverter(typeof(DeviceIdSelectorConverter<PLCBase>))] |
| | | public string plcname { get; set; } = ""; |
| | | |
| | | |
| | | [Category("PLC配置")] |
| | | [DisplayName("是否启用")] |
| | | [Description("是否启用")] |
| | | public bool isused { get; set; } = true; |
| | | |
| | | |
| | | [Category("报警配置")] |
| | | [Description("报警详情")] |
| | | [DisplayName("报警详情")] |
| | | [TypeConverter(typeof(CollectionCountConvert))] |
| | | [Editor(typeof(ComplexCollectionEditor<PLCAlarmDetails>), typeof(UITypeEditor))] |
| | | public List<PLCAlarmDetails> AlarmDetails { get; set; } = new List<PLCAlarmDetails>(); |
| | | |
| | | public string GetDisplayText() |
| | | { |
| | | return plcname + (isused ? "启用" : "禁用"); |
| | | } |
| | | } |
| | | |
| | | public class PLCAlarmDetails : IComplexDisplay, IImportFromFileInEditor |
| | | { |
| | | [Category("配置")] |
| | | [DisplayName("首地址")] |
| | | [Description("首地址")] |
| | | public int address { get; set; } |
| | | |
| | | [Category("配置")] |
| | | [DisplayName("子地址")] |
| | | [Description("子地址")] |
| | | public int address2 { get; set; } |
| | | |
| | | [Category("配置")] |
| | | [DisplayName("报警名称")] |
| | | [Description("报警名称")] |
| | | public string alarmname { get; set; } = ""; |
| | | |
| | | [Browsable(false)] |
| | | [JsonIgnore] |
| | | public int value { get; set; } = -1; |
| | | |
| | | public string GetDisplayText() |
| | | { |
| | | return alarmname; |
| | | } |
| | | |
| | | |
| | | |
| | | public IImportFromFileInEditor GetImportObject(string data, out string msg) |
| | | { |
| | | msg = ""; |
| | | PLCAlarmDetails ret = new PLCAlarmDetails(); |
| | | try |
| | | { |
| | | var temchar = data.Split(','); |
| | | ret.alarmname = temchar[0]; |
| | | ret.address =Convert.ToInt32(temchar[1]); |
| | | ret.address2 = Convert.ToInt32(temchar[2]); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | |
| | | return ret; |
| | | |
| | | } |
| | | |
| | | public bool ICSVOutput(object o) |
| | | { |
| | | try |
| | | { |
| | | if (o is List<PLCAlarmDetails> Pl) |
| | | { |
| | | SaveFileDialog saveFileDialog = new SaveFileDialog(); |
| | | saveFileDialog.Filter = "CSV files (*.csv)|*.csv"; // 设置文件过滤器,只显示CSV文件 |
| | | saveFileDialog.Title = "Save CSV File"; // 设置对话框标题 |
| | | saveFileDialog.FileName = "PLCAlarms"; // 默认文件名 |
| | | saveFileDialog.DefaultExt = "csv"; // 默认文件扩展名 |
| | | string filePath = ""; |
| | | if (saveFileDialog.ShowDialog() == DialogResult.OK) |
| | | { |
| | | filePath = saveFileDialog.FileName; // 获取用户选择的文件路径 |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | using (StreamWriter writer = new StreamWriter(filePath)) |
| | | { |
| | | // 写入标题行 |
| | | writer.WriteLine("报警名称,首地址,子地址"); |
| | | // 写入数据行 |
| | | foreach (var row in Pl) |
| | | { |
| | | writer.WriteLine($"{row.alarmname},{row.address},{row.address2}"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | public class MeasureBind : IComplexDisplay, IHalconToolPath |
| | | { |
| | |
| | | [DisplayName("图像索引")] |
| | | [Description("应对单次检测项需要多次拍照时,记录图片的索引号,从0开始")] |
| | | public int ImageIndex { get; set; } = 0; |
| | | |
| | | [Category("启用配置")] |
| | | [DisplayName("固定检测项")] |
| | | [Description("true:该检测项是固定检测项目,必须执行 false:该检测是可变检测项目,流程中决定是否检测,默认不检测")] |
| | | public bool IsFixed { get; set; } = true; |
| | | |
| | | [Category("取像设置")] |
| | | [DisplayName("相机选择")] |
| | |
| | | [DisplayName("OK图片保存开关")] |
| | | public bool OKImageSwitch { get; set; } = false; |
| | | |
| | | |
| | | [Category("图片保存设置")] |
| | | [Description("该站检测图片保存时,保存的图片顺序后缀")] |
| | | [DisplayName("图片保存顺序后缀")] |
| | | public string ImageSaveSeq { get; set; } = "1"; |
| | | |
| | | public string GetDisplayText() |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | public class Printer : IComplexDisplay |
| | | { |
| | | [Category("打印机配置")] |
| | | [DisplayName("名称")] |
| | | [Description("名称")] |
| | | [TypeConverter(typeof(DevicePrinter))] |
| | | public string name { get; set; } = ""; |
| | | |
| | | |
| | | [Category("打印机配置")] |
| | | [DisplayName("位置")] |
| | | [Description("位置")] |
| | | public string station { get; set; } |
| | | |
| | | |
| | | [Category("PLC配置")] |
| | | [DisplayName("plc名称")] |
| | | [Description("plc名称")] |
| | | [TypeConverter(typeof(DeviceIdSelectorConverter<PLCBase>))] |
| | | public string plcname { get; set; } |
| | | |
| | | [Category("PLC配置")] |
| | | [DisplayName("状态地址")] |
| | | [Description("状态地址")] |
| | | public int addstate { get; set; } |
| | | |
| | | [Category("PLC配置")] |
| | | [DisplayName("结果地址")] |
| | | [Description("结果地址")] |
| | | public int addresult { get; set; } |
| | | |
| | | |
| | | public string GetDisplayText() |
| | | { |
| | | return name; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | string filePath = ""; |
| | | if (saveFileDialog.ShowDialog() == DialogResult.OK) |
| | | { |
| | | filePath = saveFileDialog.FileName; // 获取用户选择的文件路径 |
| | | filePath = saveFileDialog.FileName; // 获取用户选择的文件路径 |
| | | } |
| | | else |
| | | { |
| | |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | |
| | | public class DevicePrinter : ComboBoxItemTypeConvert |
| | | { |
| | | public override Dictionary<string, string> GetConvertDict(ITypeDescriptorContext context) |
| | | { |
| | | Dictionary<string, string> table = new Dictionary<string, string>(); |
| | | table[""] = "未指定"; |
| | | |
| | | PrintDocument print = new PrintDocument(); |
| | | string sDefault = print.PrinterSettings.PrinterName;//默认打印机名 |
| | | foreach (string sPrint in PrinterSettings.InstalledPrinters)//获取所有打印机名称 |
| | | { |
| | | table[sPrint] = sPrint; |
| | | } |
| | | return table; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | [Device("ImageCheck", "图片检测操作配置", EnumHelper.DeviceAttributeType.OperationConfig)] |
| | | public class ImageCheckOperationConfigBase : OperationConfigBase, IHalconToolPath, IImageCheckOperationConfig |
| | |
| | | } |
| | | |
| | | |
| | | [Device("OfflineDemo", "离线测试", DeviceAttributeType.OperationConfig)] |
| | | public class OfflineDemoOperationConfig : OperationConfigBase |
| | | { |
| | | [Category("图片目录")] |
| | | [Description("图片目录")] |
| | | [DisplayName("图片目录")] |
| | | [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))] |
| | | public string ImageFolder { get; set; } |
| | | |
| | | |
| | | |
| | | [Category("检测功能")] |
| | | [Description("图片在批量测试过程中最终图片结果会存储较慢需要设置延时确保图片不被资源自动释放")] |
| | | [DisplayName("图片存图延时")] |
| | | public int SaveImageTime { get; set; } = 0; |
| | | |
| | | |
| | | |
| | | [Category("检测功能")] |
| | | [Description("true:启动OK测试 false:启动NG测试")] |
| | | [DisplayName("是否测试OK图片")] |
| | | public bool IsOK { get; set; } = true; |
| | | |
| | | } |
| | | |
| | | public class RealTimeAdjustDataDetail : IComplexDisplay |
| | | { |
| | | [Category("点位设置")] |