| | |
| | | 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; |
| | | |
| | |
| | | { |
| | | 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("每行列数")] |
| | |
| | | public bool Isreadbasketcode { get; set; } = false; |
| | | |
| | | |
| | | //[Category("数据库配置")] |
| | | //[Description("是否为终点设备")] |
| | | //[DisplayName("是否为终点设备")] |
| | | //public bool IsfinDevice { 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; |
| | | |
| | | |
| | | } |
| | |
| | | return $"{(IsEnabled ? "" : "禁用")} 工位 {PositionName} 交互触发值:{TriggerValue}"; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | 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 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 |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | 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 |
| | | { |