From 6a4463810e276b62356d77c88509fa6fa7af65cf Mon Sep 17 00:00:00 2001 From: kingno <30263@KINGNO> Date: 星期三, 23 七月 2025 15:46:33 +0800 Subject: [PATCH] mes数据逻辑上传完善,缺陷代码完善,添加S4工位的S2结果上传Plc的通信日志mes优化 --- src/Bro.M141.Process/M141Config.cs | 246 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 241 insertions(+), 5 deletions(-) diff --git a/src/Bro.M141.Process/M141Config.cs b/src/Bro.M141.Process/M141Config.cs index d403b81..6323e49 100644 --- a/src/Bro.M141.Process/M141Config.cs +++ b/src/Bro.M141.Process/M141Config.cs @@ -6,6 +6,7 @@ using Bro.Common.Model; using Bro.M135.Common; using Bro.Process; +using MathNet.Numerics.Distributions; using Newtonsoft.Json; using System.ComponentModel; using System.Drawing.Design; @@ -13,11 +14,15 @@ using System.Drawing.Printing; using System.Reflection; using System.Windows.Forms.Design; +using Windows.Services.Maps; +using static Bro.Common.Helper.EnumHelper; namespace Bro.M141.Process { public class M141Config : ProcessConfigBase { + + [Category("鎵撳嵃鏈洪厤缃�")] [Description("鎵撳嵃鏈洪厤缃泦鍚�")] [DisplayName("鎵撳嵃鏈洪厤缃泦鍚�")] @@ -31,6 +36,7 @@ [Description("瀛椾綋澶у皬")] [DisplayName("瀛椾綋澶у皬")] public int FontSize_p { get; set; } = 15; + [Category("浜у搧鏄剧ず鐣岄潰閰嶇疆")] [Description("姣忚鍒楁暟")] @@ -67,6 +73,37 @@ [DisplayName("寮傚父鎸囩ず鏍囧噯")] [TypeConverter(typeof(SpecCodeSelectorConverter))] public string CheckErrorSpecCode { get; set; } = ""; + + + [Category("鐗瑰畾缂洪櫡閰嶇疆")] + [Description("S3鍜孲5鍏卞悓鍒ゆ柇缂洪櫡")] + [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("浣嶇疆搴﹁缃�")] @@ -130,6 +167,15 @@ [DisplayName("褰撳墠鏍忓叿鐮�")] public string basketcode { get; set; } = "NoRead"; + + + + [Category("鏍忓叿鏉$爜閰嶇疆")] + [Description("褰撳墠宸ュ崟鍙�")] + [DisplayName("褰撳墠宸ュ崟鍙�")] + public string zwoid { get; set; } = ""; + + [Category("鏍忓叿鏉$爜閰嶇疆")] [Description("鏈珯鏄惁璇诲彇鏍忓叿鐮�")] [DisplayName("鏈珯鏄惁璇诲彇鏍忓叿鐮�")] @@ -148,6 +194,86 @@ [Description("蹇冭烦鍦板潃")] [DisplayName("蹇冭烦鍦板潃")] public int heartadd { get; set; } = 1505; + + + + [Category("MES閰嶇疆")] + [Description("鏄惁涓婁紶MES")] + [DisplayName("鏄惁涓婁紶MES")] + public bool ISupMES { get; set; } = false; + + [Category("MES閰嶇疆")] + [Description("鎺ュ彛閫夋嫨,0绡叿鎺ュ彛,1鏁版嵁涓婁紶鎺ュ彛,-1鎵�鏈夋帴鍙�")] + [DisplayName("鎺ュ彛閫夋嫨")] + public int MESchannel { get; set; } = 0; + + + + [Category("MES閰嶇疆")] + [Description("璐﹀彿")] + [DisplayName("璐﹀彿")] + public string zuser { get; set; } = "aoiUser"; + + [Category("MES閰嶇疆")] + [Description("瀵嗙爜")] + [DisplayName("瀵嗙爜")] + public string zpassword { get; set; } = "Chia@aoi"; + + [Category("MES閰嶇疆")] + [Description("IP")] + [DisplayName("Ip")] + public string zIP { get; set; } = "10.2.20.114"; + + [Category("MES閰嶇疆")] + [Description("绔彛鍙�")] + [DisplayName("绔彛鍙�")] + public int zport { get; set; } = 15672; + + + + //[Category("MES閰嶇疆")] + //[Description("澶囩敤鏍忓叿鐮�")] + //[DisplayName("澶囩敤鏍忓叿鐮�")] + //public string basketcode2 { get; set; } = "NoRead"; + + [Category("MES閰嶇疆")] + [Description("numpro")] + [DisplayName("numpro")] + [JsonIgnore] + public int numpro { get; set; } = 0; + + [Category("MES閰嶇疆")] + [Description("mesnum1")] + [DisplayName("mesnum1")] + [JsonIgnore] + public int mesnum1 { get; set; } = 0; + + [Category("MES閰嶇疆")] + [Description("mesnum2")] + [DisplayName("mesnum2")] + [JsonIgnore] + public int mesnum2 { get; set; } = 0; + + [Category("MES閰嶇疆")] + [Description("mesnum3")] + [DisplayName("mesnum3")] + [JsonIgnore] + public int mesnum3 { get; set; } = 0; + + [Category("MES閰嶇疆")] + [Description("mesnum4")] + [DisplayName("mesnum4")] + [JsonIgnore] + public int mesnum4 { get; set; } = 0; + + + + [Category("MES閰嶇疆")] + [Description("plc搴忓彿鍜岀鍏风爜闆嗗悎")] + [DisplayName("plc搴忓彿鍜岀鍏风爜闆嗗悎")] + [TypeConverter(typeof(CollectionCountConvert))] + [Editor(typeof(ComplexCollectionEditor<PlcAndBasketcode>), typeof(UITypeEditor))] + public List<PlcAndBasketcode> PlcAndBasketcodes { get; set; } = new List<PlcAndBasketcode>(); } @@ -237,16 +363,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,10 +394,90 @@ { 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; + } + + + + + + } + public class PlcAndBasketcode + { + [Category("閰嶇疆")] + [Description("搴忓彿")] + [DisplayName("搴忓彿")] + public int id { get; set; } = 0; + [Category("閰嶇疆")] + [Description("鏉$爜")] + [DisplayName("鏉$爜")] + public string code { get; set; } + + } @@ -298,6 +501,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 +565,10 @@ [DisplayName("OK鍥剧墖淇濆瓨寮�鍏�")] public bool OKImageSwitch { get; set; } = false; - + [Category("鍥剧墖淇濆瓨璁剧疆")] + [Description("璇ョ珯妫�娴嬪浘鐗囦繚瀛樻椂锛屼繚瀛樼殑鍥剧墖椤哄簭鍚庣紑")] + [DisplayName("鍥剧墖淇濆瓨椤哄簭鍚庣紑")] + public string ImageSaveSeq { get; set; } = "1"; public string GetDisplayText() { @@ -842,6 +1053,31 @@ } + [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锛氬惎鍔∣K娴嬭瘯 false锛氬惎鍔∟G娴嬭瘯")] + [DisplayName("鏄惁娴嬭瘯OK鍥剧墖")] + public bool IsOK { get; set; } = true; + + } + public class RealTimeAdjustDataDetail : IComplexDisplay { [Category("鐐逛綅璁剧疆")] -- Gitblit v1.8.0