From 7f699a115d555d68c6b9fb658ee7db1a3e47c841 Mon Sep 17 00:00:00 2001 From: kingno <30263@KINGNO> Date: 星期二, 17 六月 2025 13:04:32 +0800 Subject: [PATCH] Revert "双击圆点出图" --- src/Bro.M141.Process/M141Config.cs | 227 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 222 insertions(+), 5 deletions(-) diff --git a/src/Bro.M141.Process/M141Config.cs b/src/Bro.M141.Process/M141Config.cs index 1cd2cdd..5602e23 100644 --- a/src/Bro.M141.Process/M141Config.cs +++ b/src/Bro.M141.Process/M141Config.cs @@ -6,9 +6,11 @@ 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; @@ -16,10 +18,19 @@ { 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("姣忚鍒楁暟")] @@ -125,10 +136,18 @@ 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; } @@ -192,6 +211,137 @@ 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"; // 璁剧疆鏂囦欢杩囨护鍣紝鍙樉绀篊SV鏂囦欢 + 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; + } + + + + + + + } + + + + + @@ -412,6 +562,43 @@ } + 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; + } + } @@ -585,7 +772,7 @@ string filePath = ""; if (saveFileDialog.ShowDialog() == DialogResult.OK) { - filePath = saveFileDialog.FileName; // 鑾峰彇鐢ㄦ埛閫夋嫨鐨勬枃浠惰矾寰� + filePath = saveFileDialog.FileName; // 鑾峰彇鐢ㄦ埛閫夋嫨鐨勬枃浠惰矾寰� } else { @@ -612,6 +799,36 @@ } } + + 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 { -- Gitblit v1.8.0