From 2ad4cf6d588bd9bc446e8bde2a916c17aec3dad6 Mon Sep 17 00:00:00 2001 From: Gokiburi <Gokiburi@DESKTOP-9ITC11L> Date: 星期二, 17 六月 2025 11:49:48 +0800 Subject: [PATCH] 增加离线测试功能 --- src/Bro.M141.Process/M141Config.cs | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 100 insertions(+), 5 deletions(-) diff --git a/src/Bro.M141.Process/M141Config.cs b/src/Bro.M141.Process/M141Config.cs index d403b81..3eb2a41 100644 --- a/src/Bro.M141.Process/M141Config.cs +++ b/src/Bro.M141.Process/M141Config.cs @@ -13,6 +13,7 @@ using System.Drawing.Printing; using System.Reflection; using System.Windows.Forms.Design; +using static Bro.Common.Helper.EnumHelper; namespace Bro.M141.Process { @@ -26,11 +27,17 @@ public List<Printer> Printers { get; set; } = new List<Printer>(); + + + + + [Category("浜у搧鏄剧ず鐣岄潰閰嶇疆")] [Description("瀛椾綋澶у皬")] [DisplayName("瀛椾綋澶у皬")] public int FontSize_p { get; set; } = 15; + [Category("浜у搧鏄剧ず鐣岄潰閰嶇疆")] [Description("姣忚鍒楁暟")] @@ -237,16 +244,13 @@ [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 + public class PLCAlarmDetails : IComplexDisplay, IImportFromFileInEditor { [Category("閰嶇疆")] [DisplayName("棣栧湴鍧�")] @@ -271,6 +275,74 @@ { 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; + } + + + + + + } @@ -298,6 +370,11 @@ [DisplayName("鍥惧儚绱㈠紩")] [Description("搴斿鍗曟妫�娴嬮」闇�瑕佸娆℃媿鐓ф椂锛岃褰曞浘鐗囩殑绱㈠紩鍙凤紝浠�0寮�濮�")] public int ImageIndex { get; set; } = 0; + + [Category("鍚敤閰嶇疆")] + [DisplayName("鍥哄畾妫�娴嬮」")] + [Description("true锛氳妫�娴嬮」鏄浐瀹氭娴嬮」鐩紝蹇呴』鎵ц false锛氳妫�娴嬫槸鍙彉妫�娴嬮」鐩紝娴佺▼涓喅瀹氭槸鍚︽娴嬶紝榛樿涓嶆娴�")] + public bool IsFixed { get; set; } = true; [Category("鍙栧儚璁剧疆")] [DisplayName("鐩告満閫夋嫨")] @@ -357,7 +434,10 @@ [DisplayName("OK鍥剧墖淇濆瓨寮�鍏�")] public bool OKImageSwitch { get; set; } = false; - + [Category("鍥剧墖淇濆瓨璁剧疆")] + [Description("璇ョ珯妫�娴嬪浘鐗囦繚瀛樻椂锛屼繚瀛樼殑鍥剧墖椤哄簭鍚庣紑")] + [DisplayName("鍥剧墖淇濆瓨椤哄簭鍚庣紑")] + public string ImageSaveSeq { get; set; } = "1"; public string GetDisplayText() { @@ -842,6 +922,21 @@ } + [Device("OfflineDemo", "绂荤嚎娴嬭瘯", DeviceAttributeType.OperationConfig)] + public class OfflineDemoOperationConfig : OperationConfigBase + { + [Category("鍥剧墖鐩綍")] + [Description("鍥剧墖鐩綍")] + [DisplayName("鍥剧墖鐩綍")] + [Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))] + public string ImageFolder { get; set; } + + [Category("鍚姩閰嶇疆")] + [Description("true锛氬惎鍔ㄧ绾挎祴璇� false锛氬仠姝㈢绾挎祴璇�")] + [DisplayName("娴嬭瘯寮�鍏�")] + public bool IsStart { get; set; } = true; + } + public class RealTimeAdjustDataDetail : IComplexDisplay { [Category("鐐逛綅璁剧疆")] -- Gitblit v1.8.0