From 6caff8e3b06535a9652a791454135cf0e6ac110e Mon Sep 17 00:00:00 2001 From: kingno <30263@KINGNO> Date: 星期一, 23 六月 2025 09:59:46 +0800 Subject: [PATCH] 新增篮具码,界面 --- libs/PFW/Bro.Common.Model.dll | 0 libs/PFW/Bro.UI.Main.dll | 0 src/Bro.M141.Process/UI/BasketCodeUI.Designer.cs | 121 +++++++++++ src/Bro.M141.Process/M141Config.cs | 44 +++ src/Bro.M141.Process/Bro.M141.Process.csproj | 1 src/Bro.M141.Process/M141Process.cs | 81 +++++-- src/Bro.M141.Process/UI/UIPrinter.Designer.cs | 36 +- src/Bro.M141.Process/UI/BasketCodeUI.resx | 6 /dev/null | 45 ---- src/Bro.M141_AOI1.Process/AOI1Process.cs | 30 ++ src/Bro.M135.Common/ProductModel.cs | 40 +++ src/Bro.M141.Process/UI/BasketCodeUI.cs | 72 ++++++ src/Bro.M141.Process/M141Process_Mysql.cs | 147 ++++++++++++ 13 files changed, 521 insertions(+), 102 deletions(-) diff --git a/libs/PFW/Bro.Common.Model.dll b/libs/PFW/Bro.Common.Model.dll index 97be8b4..7299abf 100644 --- a/libs/PFW/Bro.Common.Model.dll +++ b/libs/PFW/Bro.Common.Model.dll Binary files differ diff --git a/libs/PFW/Bro.UI.Main.dll b/libs/PFW/Bro.UI.Main.dll index 8f63e91..758a703 100644 --- a/libs/PFW/Bro.UI.Main.dll +++ b/libs/PFW/Bro.UI.Main.dll Binary files differ diff --git a/src/Bro.M135.Common/ProductModel.cs b/src/Bro.M135.Common/ProductModel.cs index 5017521..6737e19 100644 --- a/src/Bro.M135.Common/ProductModel.cs +++ b/src/Bro.M135.Common/ProductModel.cs @@ -76,7 +76,12 @@ public bool IsPreStationOK { get; set; } = false; + [JsonIgnore] public List<string> ImagePaths { get; set; } = new List<string>(); + + public List<Netdefectdetail> Netdefectdetails = new List<Netdefectdetail>(); + + public List<double> Centermatrix { get; set; } = new List<double>(); public DateTime? EndTime { get; set; } = null; @@ -424,7 +429,7 @@ #endregion #region PositionCheckTimes - public void InitialPositionCheckList(string positionName, List<int> checkTimes,string stationName) + public void InitialPositionCheckList(string positionName, List<int> checkTimes, string stationName) { lock (_checkResultLock) { @@ -493,4 +498,37 @@ TimeoutTimer = null; } } + + + + public class Netdefectdetail + { + public string name { get; set; } + + public double centerX { get; set; } + public double centerY { get; set; } + + + + + public static double GetDistance(double x1, double y1, double x2, double y2) + { + double dx = x2 - x1; + double dy = y2 - y1; + return Math.Sqrt(dx * dx + dy * dy); + } + public static bool operator ==(Netdefectdetail a, Netdefectdetail b) + { + if (GetDistance(a.centerX, a.centerY, b.centerX, b.centerY) < 50) + { + return true; + } + return false; + } + + public static bool operator !=(Netdefectdetail a, Netdefectdetail b) + { + return !(a == b); + } + } } diff --git a/src/Bro.M141.Process/Bro.M141.Process.csproj b/src/Bro.M141.Process/Bro.M141.Process.csproj index 2407a98..e050bca 100644 --- a/src/Bro.M141.Process/Bro.M141.Process.csproj +++ b/src/Bro.M141.Process/Bro.M141.Process.csproj @@ -15,6 +15,7 @@ <Exec Command="Copy $(SolutionDir)libs\PFW $(OutDir)
Copy $(SolutionDir)libs\SafetyDog $(OutDir)
Copy $(SolutionDir)libs\Nuget $(OutDir)
Copy $(SolutionDir)libs\halcon12 $(OutDir)
Copy $(SolutionDir)libs\HikCamera $(OutDir)
Copy $(SolutionDir)libs\IKAPCamera $(OutDir)
Copy $(SolutionDir)libs\InsCamera $(OutDir)
Copy $(SolutionDir)libs\WebServiceDll $(OutDir)" /> </Target> + <!--<ItemGroup> <Compile Include="M141Process_Mysql.cs" /> </ItemGroup>--> diff --git a/src/Bro.M141.Process/M141Config.cs b/src/Bro.M141.Process/M141Config.cs index 3eb2a41..ad9ed79 100644 --- a/src/Bro.M141.Process/M141Config.cs +++ b/src/Bro.M141.Process/M141Config.cs @@ -19,17 +19,18 @@ { 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>(); - - - - - @@ -72,10 +73,41 @@ [Category("妫�娴嬪紓甯告寚绀�")] [Description("閫夋嫨鏌愪釜Spec锛屽叾琛ㄧず妫�娴嬭繃绋嬩腑寮傚父")] [DisplayName("寮傚父鎸囩ず鏍囧噯")] - [TypeConverter(typeof(SpecCodeSelectorConverter))] + [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("浣嶇疆搴﹁缃�")] [Description("浜у搧娴嬮噺鐐逛綅闆嗗悎")] [DisplayName("浜у搧娴嬮噺鐐逛綅闆嗗悎")] diff --git a/src/Bro.M141.Process/M141Process.cs b/src/Bro.M141.Process/M141Process.cs index a68780c..3302e67 100644 --- a/src/Bro.M141.Process/M141Process.cs +++ b/src/Bro.M141.Process/M141Process.cs @@ -17,6 +17,7 @@ using ScottPlot.Drawing.Colormaps; using Sunny.UI; using Sunny.UI.Win32; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Drawing.Imaging; @@ -52,7 +53,15 @@ //volatile int _productIndex = 0; - M141Process_Mysql mysqlhelper = new M141Process_Mysql(); + public M141Process_Mysql mysqlhelper = new M141Process_Mysql(); + + public event Action RerefreshBasketcodeUI; + + public void RerefreshBasketcode() + { + RerefreshBasketcodeUI?.Invoke(); + } + public override void InitialProcessMethods() @@ -111,7 +120,7 @@ _positionSpecHeads.Clear(); mysqlhelper.IniDBIP(M141Config.IPforall); - + RerefreshBasketcode(); } @@ -496,33 +505,58 @@ throw new Exception($"浜у搧{string.Join(",", pidList)}妫�娴媨measureBind.GetDisplayText()}鏈兘鑾峰彇鍥剧墖瀵硅薄"); } + RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedMonitorId, resultList); + RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedCombineMethodId, resultList); + //妫�娴嬮『搴� ML->鑷畾涔夋娴� if (!string.IsNullOrWhiteSpace(measureBind.DetectionId)) { string detectionName = (ML.InitialConfig as MLInitialConfigBase).DetectionConfigs.FirstOrDefault(u => u.Id == measureBind.DetectionId)?.Name; - //List<string> pidList2 = new List<string>();//pidList.Select(u => u.Split('_')[u.Split('_').Length - 1]).ToList(); - //Dictionary<string, string> dicpid = new Dictionary<string, string>(); - //for (int i = 0; i < pidList.Count; i++) - //{ - // var tem = pidList[i].Split('_')[pidList[i].Split('_').Length - 1]; - // pidList2.Add(tem); - // dicpid[tem] = pidList[i]; - //} + List<DetectResult> detectResults = ML?.RunMLDetectionSync(imgSet, pidList, measureBind.DetectionId, false, null, null, "", products[0].ImagePaths); - //var c=products[0].ImagePaths; - List<DetectResult> detectResults = ML?.RunMLDetectionSync(imgSet, pidList, measureBind.DetectionId,false,null,null,"", products[0].ImagePaths); + + + if (measureBind.WorkPosition == "P1" && M141Config.StationCode == "S5" && detectResults.GetDefectDescList().Count == 0) + { + var defecttem = detectResults.SelectMany(u => u.NetResults.SelectMany(m => m.DetectDetails)).Where(u => u.NetName == M141Config.defectname).ToList(); + List<Netdefectdetail> Netdefectdetails = mysqlhelper.GetNetdefectdetails(products[0].SEQUENCE); + + LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{products[0].SN} 杩涘叆S3S5妫�娴� S3鏁版嵁{Netdefectdetails.Count} S5鏁版嵁{defecttem.Count}"); + + int num = 0; + foreach (var item1 in defecttem) + { + double x1 = item1.Rect.Point_LU.X + item1.Rect.Width / 2.0; + double y1 = item1.Rect.Point_LU.Y + item1.Rect.Height / 2.0; + num++; + //HOperatorSet.AffineTransPoint2d(new HTuple(products[0].Centermatrix.ToArray()), x1, y1, out HTuple qx, out HTuple qy); + //HOperatorSet.ProjectiveTransPixel(new HTuple(products[0].Centermatrix.ToArray()), x1, y1, out HTuple qx, out HTuple qy); + + LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{products[0].SN}鍘熷潗鏍噞num} {x1},{y1}"); + HOperatorSet.ProjectiveTransPixel(new HTuple(products[0].Centermatrix.ToArray()), x1, y1, out HTuple qx, out HTuple qy); + LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{products[0].SN}鏂板潗鏍噞num} {qx},{qy}"); + + + Netdefectdetail temc = new Netdefectdetail() + { + centerX = qx, + centerY = qy, + name = M141Config.defectname, + }; + if (Netdefectdetails.Any(u => u == temc)) + { + item1.IsAbandoned = false; + item1.FinalResult = ResultState.NG; + LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"浜у搧{products[0].PID}_{products[0].SEQUENCE}宸ヤ綅{measureBind.WorkPosition} S3S5缁勫悎妫�娴嬫鍑虹己闄�:{item1.NetName}"); + break; + } + } + } + List<DetectResult> ngResults = new List<DetectResult>(); - - - //for (int i = 0; i < detectResults.Count; i++) - //{ - // detectResults[i].PID = dicpid[detectResults[i].PID]; - //} - - detectResults.GroupBy(u => u.PID).ToList().ForEach(u => { if (u.ToList().Count > 0 && u.ToList().Any(m => m.ResultState != EnumHelper.ResultState.OK)) @@ -540,8 +574,7 @@ detectResults.AddRange(ngResults); resultList.AddRange(detectResults); } - RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedMonitorId, resultList); - RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedCombineMethodId, resultList); + } catch (Exception ex) { @@ -1130,7 +1163,7 @@ if (positionSet.IsLastPosition) { UpdateProductResultAsync(p); - mysqlhelper.NewForAll(p, M141Config.StationCode); + mysqlhelper.NewForAll(p, M141Config.StationCode, M141Config.defectname); if (M141Config.IsfinDevice) { SummaryAllprodata(p); @@ -1207,7 +1240,7 @@ newp.Details.AddRange(item.Details); } } - LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"AllDeviceProductRecord浠庢暟鎹簱鑾峰彇鍒版暟鎹畕p.SEQUENCE} plist鏁伴噺{plist.Count} Details鏁伴噺{newp.Details.Count}"); + //LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"AllDeviceProductRecord浠庢暟鎹簱鑾峰彇鍒版暟鎹畕p.SEQUENCE} plist鏁伴噺{plist.Count} Details鏁伴噺{newp.Details.Count}"); //newp.Details.AddRange(p.Details); diff --git a/src/Bro.M141.Process/M141Process_Mysql.cs b/src/Bro.M141.Process/M141Process_Mysql.cs index 00d7bee..865db24 100644 --- a/src/Bro.M141.Process/M141Process_Mysql.cs +++ b/src/Bro.M141.Process/M141Process_Mysql.cs @@ -2,6 +2,7 @@ using Bro.Common.Interface; using Bro.Common.Model; using Bro.M135.Common; +using HalconDotNet; using MySql.Data.MySqlClient; using Newtonsoft.Json; using Sunny.UI; @@ -13,6 +14,8 @@ using System.Threading.Tasks; using Windows.Globalization.PhoneNumberFormatting; using Windows.Media.Ocr; +using static Bro.Common.Helper.EnumHelper; +using static NPOI.HSSF.Util.HSSFColor; using static Org.BouncyCastle.Math.EC.ECCurve; using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView; @@ -186,7 +189,7 @@ } } - public void NewForAll(ProductModel pro, string devicestr) + public void NewForAll(ProductModel pro, string devicestr, string netname) { Task.Run(() => { @@ -196,20 +199,70 @@ //string destr = "delete from forall where id not in (select id from (select id from forall order BY id desc limit 1000) as subquery)"; //Operatoremysql(destr, connStrAll); - if (pro.Details != null) + if (string.IsNullOrEmpty(netname) /*|| devicestr != "S3" */) { - foreach (var item in pro.Details) + if (pro.Details != null) { - if (item != null) + foreach (var item in pro.Details) { - var defects = item.ResultList.GetDefectDescList(); - var ngSpecCodes = item.SpecList.Where(u => u.MeasureResult != true).Select(u => u.Code); - defects.AddRange(ngSpecCodes); - item.DefectList.AddRange(defects.Distinct()); - item.DefectList = item.DefectList.Distinct().ToList(); + if (item != null) + { + var defects = item.ResultList.GetDefectDescList(); + var ngSpecCodes = item.SpecList.Where(u => u.MeasureResult != true).Select(u => u.Code); + defects.AddRange(ngSpecCodes); + item.DefectList.AddRange(defects.Distinct()); + item.DefectList = item.DefectList.Distinct().ToList(); + } + } } } + else + { + List<Netdefectdetail> allnetdetail = new List<Netdefectdetail>(); + if (pro.Details != null) + { + foreach (var item in pro.Details) + { + if (item != null) + { + var defects = item.ResultList.GetDefectDescList(); + var ngSpecCodes = item.SpecList.Where(u => u.MeasureResult != true).Select(u => u.Code); + defects.AddRange(ngSpecCodes); + item.DefectList.AddRange(defects.Distinct()); + item.DefectList = item.DefectList.Distinct().ToList(); + + var defecttem = item.ResultList.SelectMany(u => u.AllNetResults.SelectMany(m => m.DetectDetails)).Where(u => u.ClassName == netname).ToList(); + + //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"{netname}涓暟{defecttem.Count}"); + + int num = 0; + foreach (var item1 in defecttem) + { + double x1 = item1.Rect.Point_LU.X + item1.Rect.Width / 2.0; + double y1 = item1.Rect.Point_LU.Y + item1.Rect.Height / 2.0; + num++; + //HOperatorSet.AffineTransPoint2d(new HTuple(pro.Centermatrix.ToArray()), x1, y1, out HTuple qx, out HTuple qy); + + CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"sql {pro.SN}鍘熷潗鏍噞num} {x1},{y1}"); + HOperatorSet.ProjectiveTransPixel(new HTuple(pro.Centermatrix.ToArray()), x1, y1, out HTuple qx, out HTuple qy); + CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"sql {pro.SN}鏂板潗鏍噞num} {qx},{qy}"); + + Netdefectdetail temc = new Netdefectdetail() + { + centerX = qx, + centerY = qy, + name = netname, + }; + allnetdetail.Add(temc); + } + } + } + + pro.Netdefectdetails = allnetdetail; + } + } + string strtem = "select * from forall where plcnum='" + pro.SEQUENCE + "' and device='" + devicestr + "' "; @@ -282,6 +335,31 @@ return null; } + + public List<Netdefectdetail> GetNetdefectdetails(string plcnum) + { + try + { + string mysqlstr = $"select data from forall where plcnum='{plcnum}' && device='S3' order by id desc limit 1"; + string str = selectmysql(mysqlstr, connStrAll); + if (string.IsNullOrEmpty(str)) + { + return null; + } + else + { + ProductModel p = null; + p = JsonConvert.DeserializeObject<ProductModel>(str, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }); + return p.Netdefectdetails; + } + } + catch (Exception e) + { + CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴揻orlocal鑾峰彇瀵硅薄寮傚父 {e.ToString()}"); + } + return null; + } + public string Getbasketcode(string plcnum, out string sn) { sn = "Noread"; @@ -322,7 +400,9 @@ List<ProductModel> plist = new List<ProductModel>(); for (int i = 0; i < dt.Rows.Count; i++) { - ProductModel p = JsonConvert.DeserializeObject<ProductModel>(dt.Rows[i][0].ToString(), new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }); + string strjson = dt.Rows[i][0].ToString(); + strjson = strjson.Replace(@"\", @"\\"); + ProductModel p = JsonConvert.DeserializeObject<ProductModel>(strjson, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }); //JsonConvert.DeserializeObject<IProcessConfig>(_configBackupStr, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }); plist.Add(p); @@ -338,5 +418,52 @@ } + + public DataTable getBasketCode() + { + try + { + string mysqlstr = $"select id,code,time from basketcode order by id desc limit 200"; + var dt = selectdt(mysqlstr, connStrAll); + if (dt == null) + { + return null; + } + else + { + return dt; + } + } + catch (Exception e) + { + CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴揻orall鏁版嵁寮傚父 {e.ToString()}"); + } + return null; + + + + } + + + public void NewBasketcode(string code) + { + try + { + string mysqlstr = $"insert into basketcode(code,time) values('{code}','{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')"; + if (Operatoremysql(mysqlstr, connStrAll)) + { + CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鏁版嵁搴揵asketcode鎻掑叆鏁版嵁鎴愬姛"); + } + else + { + CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"鏁版嵁搴揵asketcode鎻掑叆鏁版嵁寮傚け璐� {mysqlstr}"); + } + } + catch (Exception e) + { + CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴揵asketcode鎻掑叆鏁版嵁寮傚父 {e.ToString()}"); + } + } + } } diff --git a/src/Bro.M141.Process/UI/BasketCodeUI.Designer.cs b/src/Bro.M141.Process/UI/BasketCodeUI.Designer.cs new file mode 100644 index 0000000..df501a8 --- /dev/null +++ b/src/Bro.M141.Process/UI/BasketCodeUI.Designer.cs @@ -0,0 +1,121 @@ +锘縩amespace Bro.M141.Process +{ + partial class BasketCodeUI + { + /// <summary> + /// 蹇呴渶鐨勮璁″櫒鍙橀噺銆� + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// 娓呯悊鎵�鏈夋鍦ㄤ娇鐢ㄧ殑璧勬簮銆� + /// </summary> + /// <param name="disposing">濡傛灉搴旈噴鏀炬墭绠¤祫婧愶紝涓� true锛涘惁鍒欎负 false銆�</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 缁勪欢璁捐鍣ㄧ敓鎴愮殑浠g爜 + + /// <summary> + /// 璁捐鍣ㄦ敮鎸佹墍闇�鐨勬柟娉� - 涓嶈淇敼 + /// 浣跨敤浠g爜缂栬緫鍣ㄤ慨鏀规鏂规硶鐨勫唴瀹广�� + /// </summary> + private void InitializeComponent() + { + DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); + DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle(); + DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle(); + DataGridViewCellStyle dataGridViewCellStyle4 = new DataGridViewCellStyle(); + Codesdataview = new Sunny.UI.UIDataGridView(); + Column5 = new DataGridViewTextBoxColumn(); + Column6 = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)Codesdataview).BeginInit(); + SuspendLayout(); + // + // Codesdataview + // + Codesdataview.AllowUserToAddRows = false; + Codesdataview.AllowUserToDeleteRows = false; + dataGridViewCellStyle1.BackColor = Color.FromArgb(235, 243, 255); + Codesdataview.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + Codesdataview.BackgroundColor = Color.White; + Codesdataview.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; + dataGridViewCellStyle2.Alignment = DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = Color.FromArgb(80, 160, 255); + dataGridViewCellStyle2.Font = new Font("寰蒋闆呴粦", 12F, FontStyle.Regular, GraphicsUnit.Point); + dataGridViewCellStyle2.ForeColor = Color.White; + dataGridViewCellStyle2.SelectionBackColor = SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = DataGridViewTriState.True; + Codesdataview.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + Codesdataview.ColumnHeadersHeight = 32; + Codesdataview.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + Codesdataview.Columns.AddRange(new DataGridViewColumn[] { Column5, Column6 }); + Codesdataview.Dock = DockStyle.Fill; + Codesdataview.EnableHeadersVisualStyles = false; + Codesdataview.Font = new Font("寰蒋闆呴粦", 12F, FontStyle.Regular, GraphicsUnit.Point); + Codesdataview.GridColor = Color.FromArgb(80, 160, 255); + Codesdataview.Location = new Point(0, 0); + Codesdataview.Name = "Codesdataview"; + Codesdataview.ReadOnly = true; + dataGridViewCellStyle3.Alignment = DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.BackColor = Color.FromArgb(235, 243, 255); + dataGridViewCellStyle3.Font = new Font("寰蒋闆呴粦", 12F, FontStyle.Regular, GraphicsUnit.Point); + dataGridViewCellStyle3.ForeColor = Color.FromArgb(48, 48, 48); + dataGridViewCellStyle3.SelectionBackColor = Color.FromArgb(80, 160, 255); + dataGridViewCellStyle3.SelectionForeColor = Color.White; + dataGridViewCellStyle3.WrapMode = DataGridViewTriState.True; + Codesdataview.RowHeadersDefaultCellStyle = dataGridViewCellStyle3; + Codesdataview.RowHeadersWidth = 51; + Codesdataview.RowHeight = 25; + dataGridViewCellStyle4.BackColor = Color.White; + Codesdataview.RowsDefaultCellStyle = dataGridViewCellStyle4; + Codesdataview.RowTemplate.Height = 25; + Codesdataview.SelectedIndex = -1; + Codesdataview.ShowGridLine = true; + Codesdataview.Size = new Size(887, 576); + Codesdataview.TabIndex = 4; + // + // Column5 + // + Column5.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + Column5.DataPropertyName = "code"; + Column5.HeaderText = "绡叿鐮�"; + Column5.MinimumWidth = 6; + Column5.Name = "Column5"; + Column5.ReadOnly = true; + // + // Column6 + // + Column6.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + Column6.DataPropertyName = "time"; + Column6.HeaderText = "璇荤爜鏃堕棿"; + Column6.MinimumWidth = 6; + Column6.Name = "Column6"; + Column6.ReadOnly = true; + // + // BasketCodeUI + // + AutoScaleDimensions = new SizeF(6F, 13F); + AutoScaleMode = AutoScaleMode.Font; + Controls.Add(Codesdataview); + Margin = new Padding(2); + Name = "BasketCodeUI"; + Size = new Size(887, 576); + ((System.ComponentModel.ISupportInitialize)Codesdataview).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Sunny.UI.UIDataGridView Codesdataview; + private DataGridViewTextBoxColumn Column5; + private DataGridViewTextBoxColumn Column6; + } +} diff --git a/src/Bro.M141.Process/UI/BasketCodeUI.cs b/src/Bro.M141.Process/UI/BasketCodeUI.cs new file mode 100644 index 0000000..1524f25 --- /dev/null +++ b/src/Bro.M141.Process/UI/BasketCodeUI.cs @@ -0,0 +1,72 @@ +锘縰sing Bro.Common.Helper; +using Bro.UI.Model.Winform; +using NPOI.SS.Formula.Functions; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Drawing.Printing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Bro.M141.Process +{ + [MenuNode("绡叿鐮佺晫闈�", "绡叿鐮佺晫闈�", 2, EnumHelper.TopMenu.SystemInfo, MenuNodeType.Form)] + public partial class BasketCodeUI : MenuFormBase + { + public BasketCodeUI() + { + InitializeComponent(); + } + M141Config Config141 => Process.IConfig as M141Config; + M141Process Process141 => Process as M141Process; + + public override void OnProcessUpdated() + { + base.OnProcessUpdated(); + + Process141.RerefreshBasketcodeUI += RerefreshUI; + RerefreshUI(); + } + + + M141Process_Mysql mysqlhelper = new M141Process_Mysql(); + + public void RerefreshUI() + { + mysqlhelper.IniDBIP(Config141.IPforall); + DataTable dt = mysqlhelper.getBasketCode(); + List<codedata> codes = new List<codedata>(); + + if (dt != null) + { + for (int i = 0; i < dt.Rows.Count; i++) + { + codes.Add(new codedata + { + code = dt.Rows[i][1].ToString(), + time = dt.Rows[i][2].ToString(), + }); + } + } + + this.Invoke(()=> + { + Codesdataview.DataSource = codes; + Codesdataview.Refresh(); + }); + } + + + public class codedata + { + public string code { get; set; } + public string time { get; set; } + } + + + } +} diff --git a/src/Bro.M141.Process/UI/UI.resx b/src/Bro.M141.Process/UI/BasketCodeUI.resx similarity index 93% rename from src/Bro.M141.Process/UI/UI.resx rename to src/Bro.M141.Process/UI/BasketCodeUI.resx index 8b2ff64..4051115 100644 --- a/src/Bro.M141.Process/UI/UI.resx +++ b/src/Bro.M141.Process/UI/BasketCodeUI.resx @@ -117,4 +117,10 @@ <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> + <metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> + <metadata name="Column6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>True</value> + </metadata> </root> \ No newline at end of file diff --git a/src/Bro.M141.Process/UI/UI.Designer.cs b/src/Bro.M141.Process/UI/UI.Designer.cs deleted file mode 100644 index 9c8ce57..0000000 --- a/src/Bro.M141.Process/UI/UI.Designer.cs +++ /dev/null @@ -1,92 +0,0 @@ -锘縩amespace Bro.M141.Process -{ - partial class ProUI - { - /// <summary> - /// 蹇呴渶鐨勮璁″櫒鍙橀噺銆� - /// </summary> - private System.ComponentModel.IContainer components = null; - - /// <summary> - /// 娓呯悊鎵�鏈夋鍦ㄤ娇鐢ㄧ殑璧勬簮銆� - /// </summary> - /// <param name="disposing">濡傛灉搴旈噴鏀炬墭绠¤祫婧愶紝涓� true锛涘惁鍒欎负 false銆�</param> - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region 缁勪欢璁捐鍣ㄧ敓鎴愮殑浠g爜 - - /// <summary> - /// 璁捐鍣ㄦ敮鎸佹墍闇�鐨勬柟娉� - 涓嶈淇敼 - /// 浣跨敤浠g爜缂栬緫鍣ㄤ慨鏀规鏂规硶鐨勫唴瀹广�� - /// </summary> - private void InitializeComponent() - { - button1 = new Button(); - textBox1 = new TextBox(); - label1 = new Label(); - button2 = new Button(); - SuspendLayout(); - // - // button1 - // - button1.Location = new Point(210, 69); - button1.Name = "button1"; - button1.Size = new Size(78, 28); - button1.TabIndex = 1; - button1.Text = "瀵煎嚭妯℃澘"; - button1.UseVisualStyleBackColor = true; - // - // textBox1 - // - textBox1.Location = new Point(114, 30); - textBox1.Name = "textBox1"; - textBox1.Size = new Size(174, 23); - textBox1.TabIndex = 2; - // - // label1 - // - label1.AutoSize = true; - label1.Location = new Point(28, 33); - label1.Name = "label1"; - label1.Size = new Size(80, 17); - label1.TabIndex = 3; - label1.Text = "鐐逛綅鏂囦欢璺緞"; - // - // button2 - // - button2.Location = new Point(114, 69); - button2.Name = "button2"; - button2.Size = new Size(78, 28); - button2.TabIndex = 4; - button2.Text = "瀵煎叆"; - button2.UseVisualStyleBackColor = true; - // - // ProUI - // - AutoScaleDimensions = new SizeF(7F, 17F); - AutoScaleMode = AutoScaleMode.Font; - Controls.Add(button2); - Controls.Add(label1); - Controls.Add(textBox1); - Controls.Add(button1); - Margin = new Padding(2, 3, 2, 3); - Name = "ProUI"; - Size = new Size(321, 321); - ResumeLayout(false); - PerformLayout(); - } - - #endregion - private Button button1; - private TextBox textBox1; - private Label label1; - private Button button2; - } -} diff --git a/src/Bro.M141.Process/UI/UI.cs b/src/Bro.M141.Process/UI/UI.cs deleted file mode 100644 index 3f0436d..0000000 --- a/src/Bro.M141.Process/UI/UI.cs +++ /dev/null @@ -1,45 +0,0 @@ -锘� -using Bro.Common.Helper; -using Bro.Common.Interface; -using Bro.UI.Model.Winform; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace Bro.M141.Process -{ - //[MenuNode("ProductStatus", "浜у搧妫�娴嬬姸鎬佹樉绀虹晫闈�1", 1, EnumHelper.TopMenu.SystemInfo, MenuNodeType.Form)] - public partial class ProUI : MenuFormBase - - //public partial class ProUI : UserControl - { - M141Config Config141 => Process.IConfig as M141Config; - M141Process Process141 => Process as M141Process; - - - public ProUI() - { - InitializeComponent(); - } - - - public override void OnProcessUpdated() - { - base.OnProcessUpdated(); - } - - - public void UpdateProductResult(List<string> data) - { - - } - - - } -} diff --git a/src/Bro.M141.Process/UI/UIPrinter.Designer.cs b/src/Bro.M141.Process/UI/UIPrinter.Designer.cs index aed4ac6..65db655 100644 --- a/src/Bro.M141.Process/UI/UIPrinter.Designer.cs +++ b/src/Bro.M141.Process/UI/UIPrinter.Designer.cs @@ -38,9 +38,10 @@ // // button2 // - button2.Location = new Point(180, 90); + button2.Location = new Point(154, 69); + button2.Margin = new Padding(3, 2, 3, 2); button2.Name = "button2"; - button2.Size = new Size(108, 60); + button2.Size = new Size(93, 46); button2.TabIndex = 1; button2.Text = "棰勮"; button2.UseVisualStyleBackColor = true; @@ -48,9 +49,10 @@ // // button1 // - button1.Location = new Point(32, 90); + button1.Location = new Point(27, 69); + button1.Margin = new Padding(3, 2, 3, 2); button1.Name = "button1"; - button1.Size = new Size(108, 60); + button1.Size = new Size(93, 46); button1.TabIndex = 2; button1.Text = "鎵撳嵃"; button1.UseVisualStyleBackColor = true; @@ -58,26 +60,27 @@ // // textBox1 // - textBox1.Location = new Point(125, 38); + textBox1.Location = new Point(96, 26); + textBox1.Margin = new Padding(3, 2, 3, 2); textBox1.Name = "textBox1"; - textBox1.Size = new Size(175, 23); + textBox1.Size = new Size(151, 21); textBox1.TabIndex = 3; // // label1 // label1.AutoSize = true; - label1.Location = new Point(52, 38); + label1.Location = new Point(27, 29); label1.Name = "label1"; - label1.Size = new Size(56, 17); + label1.Size = new Size(55, 13); label1.TabIndex = 4; label1.Text = "鎵撳嵃鍐呭"; // // button3 // - button3.Location = new Point(32, 218); - button3.Margin = new Padding(2, 2, 2, 2); + button3.Location = new Point(27, 167); + button3.Margin = new Padding(2); button3.Name = "button3"; - button3.Size = new Size(81, 43); + button3.Size = new Size(69, 33); button3.TabIndex = 5; button3.Text = "鑾峰彇鐘舵��"; button3.UseVisualStyleBackColor = true; @@ -85,14 +88,15 @@ // // textBox2 // - textBox2.Location = new Point(32, 266); + textBox2.Location = new Point(27, 221); + textBox2.Margin = new Padding(3, 2, 3, 2); textBox2.Name = "textBox2"; - textBox2.Size = new Size(313, 23); + textBox2.Size = new Size(269, 21); textBox2.TabIndex = 6; // // UIPrinter // - AutoScaleDimensions = new SizeF(7F, 17F); + AutoScaleDimensions = new SizeF(6F, 13F); AutoScaleMode = AutoScaleMode.Font; Controls.Add(textBox2); Controls.Add(button3); @@ -100,9 +104,9 @@ Controls.Add(textBox1); Controls.Add(button1); Controls.Add(button2); - Margin = new Padding(2, 3, 2, 3); + Margin = new Padding(2, 2, 2, 2); Name = "UIPrinter"; - Size = new Size(356, 362); + Size = new Size(305, 277); ResumeLayout(false); PerformLayout(); } diff --git a/src/Bro.M141_AOI1.Process/AOI1Process.cs b/src/Bro.M141_AOI1.Process/AOI1Process.cs index fe5e0fe..9b8a134 100644 --- a/src/Bro.M141_AOI1.Process/AOI1Process.cs +++ b/src/Bro.M141_AOI1.Process/AOI1Process.cs @@ -199,6 +199,10 @@ Plc1.WriteSingleAddress(1514, 1, out _); ConfigAOI1.basketcode = barcode; LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鑾峰彇鍒版爮鍏风爜涓簕barcode}"); + + mysqlhelper.NewBasketcode(barcode); + RerefreshBasketcode(); + } } @@ -391,8 +395,34 @@ } + [ProcessMethod("ImageCheck", "GetMatrix", "鑾峰彇鐭╅樀", InvokeType.TestInvoke)] + public ResponseMessage GetMatrix(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) + { + ResponseMessage msg = new ResponseMessage(); + if (config is IImageCheckOperationConfig opConfig) + { + var tool = GetHalconTool(null, "", opConfig.AlgorithemPath); + var ret = tool.RunProcedure(null, new Dictionary<string, HalconDotNet.HObject>() { { "INPUT_Image", opConfig.ImageSet.HImage } }, new List<string>() { "OUTPUT_Results" }, null); + if (ret == null) + { + LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鑴氭湰{opConfig.AlgorithemPath}杩愯寮傚父锛岃繑鍥炲�间负null"); + } + else if (!ret.Item1) + { + LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鑴氭湰{opConfig.AlgorithemPath}杩愯寮傚父锛寋ret.Item4}"); + } + else + { + List<double> datas = ret.Item2["OUTPUT_Results"].HTupleToDouble(); + opConfig.Products[0].Centermatrix = datas; + LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"浜у搧{opConfig.Products[0].PID}鐭╅樀鑾峰彇涓� {string.Join(',', datas)}"); + } + } + return msg; + } + } } -- Gitblit v1.8.0