From 33d3d91a48214f41a50874f8146d7940df26170a Mon Sep 17 00:00:00 2001 From: lhiven <2366881222@qq.com> Date: Tue, 26 Dec 2023 07:10:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BD=93=E5=91=A8=E8=BD=AC?= =?UTF-8?q?=E7=9B=98=E7=A9=B4=E4=BD=8D=E4=B8=AD=E6=B2=A1=E6=9C=89=E7=85=A7?= =?UTF-8?q?=E7=89=87=E6=97=B6=E6=98=BE=E7=A4=BA=E9=BB=98=E8=AE=A4=E5=9B=BE?= =?UTF-8?q?=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.SkyLine/FormMain.cs | 211 +++++++++++++++++++++----------- Rs.SkyLine/FormMain.designer.cs | 84 ++++++------- Rs.SkyLine/FormMain.resx | 6 - 3 files changed, 183 insertions(+), 118 deletions(-) diff --git a/Rs.SkyLine/FormMain.cs b/Rs.SkyLine/FormMain.cs index 64e298d..bbfddee 100644 --- a/Rs.SkyLine/FormMain.cs +++ b/Rs.SkyLine/FormMain.cs @@ -33,6 +33,7 @@ namespace Rs.MotionPlat { public partial class FormMain : BaseForm { + HObject defaultImage = new HObject(); public FormMain() { InitializeComponent(); @@ -178,88 +179,158 @@ namespace Rs.MotionPlat private void FormMain_Load(object sender, EventArgs e) { - SqliteHelper db = new SqliteHelper(); - string querySql = "select * from NormalTray"; - DataTable dt=db.GetDataTable(querySql); - if(dt!=null&&dt.Rows.Count>0) - { - DataRow dr = dt.AsEnumerable().Where(r => r.Field("TrayName") == "Empty1").First(); - if(dr!=null) - { - trayEmpty1.ColumnNum = int.Parse(dr["ColumnNum"].ToString()); - trayEmpty1.RowNum = int.Parse(dr["RowNum"].ToString()); - } + //SqliteHelper db = new SqliteHelper(); + //string querySql = "select * from NormalTray"; + //DataTable dt=db.GetDataTable(querySql); + //if(dt!=null&&dt.Rows.Count>0) + //{ + // DataRow dr = dt.AsEnumerable().Where(r => r.Field("TrayName") == "Empty1").First(); + // if(dr!=null) + // { + // trayEmpty1.ColumnNum = int.Parse(dr["ColumnNum"].ToString()); + // trayEmpty1.RowNum = int.Parse(dr["RowNum"].ToString()); + // } - dr = dt.AsEnumerable().Where(r => r.Field("TrayName") == "Input").First(); - if (dr != null) - { - trayInput.ColumnNum = int.Parse(dr["ColumnNum"].ToString()); - trayInput.RowNum = int.Parse(dr["RowNum"].ToString()); - } + // dr = dt.AsEnumerable().Where(r => r.Field("TrayName") == "Input").First(); + // if (dr != null) + // { + // trayInput.ColumnNum = int.Parse(dr["ColumnNum"].ToString()); + // trayInput.RowNum = int.Parse(dr["RowNum"].ToString()); + // } - dr = dt.AsEnumerable().Where(r => r.Field("TrayName") == "Ok").First(); - if (dr != null) - { - trayOk.ColumnNum = int.Parse(dr["ColumnNum"].ToString()); - trayOk.RowNum = int.Parse(dr["RowNum"].ToString()); - } + // dr = dt.AsEnumerable().Where(r => r.Field("TrayName") == "Ok").First(); + // if (dr != null) + // { + // trayOk.ColumnNum = int.Parse(dr["ColumnNum"].ToString()); + // trayOk.RowNum = int.Parse(dr["RowNum"].ToString()); + // } - dr = dt.AsEnumerable().Where(r => r.Field("TrayName") == "Ng").First(); - if (dr != null) - { - trayNg.ColumnNum = int.Parse(dr["ColumnNum"].ToString()); - trayNg.RowNum = int.Parse(dr["RowNum"].ToString()); - } + // dr = dt.AsEnumerable().Where(r => r.Field("TrayName") == "Ng").First(); + // if (dr != null) + // { + // trayNg.ColumnNum = int.Parse(dr["ColumnNum"].ToString()); + // trayNg.RowNum = int.Parse(dr["RowNum"].ToString()); + // } - dr = dt.AsEnumerable().Where(r => r.Field("TrayName") == "Multi").First(); - if (dr != null) - { - trayMulti.ColumnNum = int.Parse(dr["ColumnNum"].ToString()); - trayMulti.RowNum = int.Parse(dr["RowNum"].ToString()); - } + // dr = dt.AsEnumerable().Where(r => r.Field("TrayName") == "Multi").First(); + // if (dr != null) + // { + // trayMulti.ColumnNum = int.Parse(dr["ColumnNum"].ToString()); + // trayMulti.RowNum = int.Parse(dr["RowNum"].ToString()); + // } - dr = dt.AsEnumerable().Where(r => r.Field("TrayName") == "Empty2").First(); - if (dr != null) - { - trayEmpty2.ColumnNum = int.Parse(dr["ColumnNum"].ToString()); - trayEmpty2.RowNum = int.Parse(dr["RowNum"].ToString()); - } - } + // dr = dt.AsEnumerable().Where(r => r.Field("TrayName") == "Empty2").First(); + // if (dr != null) + // { + // trayEmpty2.ColumnNum = int.Parse(dr["ColumnNum"].ToString()); + // trayEmpty2.RowNum = int.Parse(dr["RowNum"].ToString()); + // } + //} - timer1.Interval = 500; - timer1.Enabled = true; - DischargeFlow.Instance.OnMatchResult += Instance_OnMatchResult; - DischargeFlow.Instance.OnUpCameraGrabResult += Instance_OnUpCameraGrabResult; - trayTurnover.ItemName = "Turnover"; - trayEmpty1.ItemName = "Empty1"; - trayInput.ItemName = "Input"; - trayOk.ItemName = "Ok"; - trayNg.ItemName = "Ng"; - trayMulti.ItemName = "Multi"; - trayEmpty2.ItemName = "Empty2"; + //timer1.Interval = 500; + //timer1.Enabled = true; + //DischargeFlow.Instance.OnMatchResult += Instance_OnMatchResult; + //DischargeFlow.Instance.OnUpCameraGrabResult += Instance_OnUpCameraGrabResult; + //DischargeFlow.Instance.OnShowGrabResult += Instance_OnShowGrabResult; + //trayTurnover.ItemName = "Turnover"; + //trayEmpty1.ItemName = "Empty1"; + //trayInput.ItemName = "Input"; + //trayOk.ItemName = "Ok"; + //trayNg.ItemName = "Ng"; + //trayMulti.ItemName = "Multi"; + //trayEmpty2.ItemName = "Empty2"; - trayEmpty1.InitSlotStatus = ESlotStatus.Null; - trayInput.InitSlotStatus = ESlotStatus.Null; - trayOk.InitSlotStatus = ESlotStatus.Null; - trayNg.InitSlotStatus = ESlotStatus.Null; - trayMulti.InitSlotStatus = ESlotStatus.Null; - trayEmpty2.InitSlotStatus = ESlotStatus.Null; + //trayEmpty1.InitSlotStatus = ESlotStatus.Null; + //trayInput.InitSlotStatus = ESlotStatus.Null; + //trayOk.InitSlotStatus = ESlotStatus.Null; + //trayNg.InitSlotStatus = ESlotStatus.Null; + //trayMulti.InitSlotStatus = ESlotStatus.Null; + //trayEmpty2.InitSlotStatus = ESlotStatus.Null; - GlobalTray.Empty1Tray = trayEmpty1; - GlobalTray.InputTray = trayInput; - GlobalTray.OkTary= trayOk; - GlobalTray.NgTray= trayNg; - GlobalTray.MultiTray = trayMulti; - GlobalTray.Empty2Tray = trayEmpty2; - GlobalTray.TurnoverTray = trayTurnover; - GlobalTray.TestTray = trayTest; - //StockManager.Instance.Start(); - LoadStockStatus(); + //GlobalTray.Empty1Tray = trayEmpty1; + //GlobalTray.InputTray = trayInput; + //GlobalTray.OkTary= trayOk; + //GlobalTray.NgTray= trayNg; + //GlobalTray.MultiTray = trayMulti; + //GlobalTray.Empty2Tray = trayEmpty2; + //GlobalTray.TurnoverTray = trayTurnover; + //GlobalTray.TestTray = trayTest; + ////StockManager.Instance.Start(); + //LoadStockStatus(); + HOperatorSet.ReadImage(out defaultImage, "default.bmp"); } - + private void Instance_OnShowGrabResult(VisionResult matchResult, bool arg2) + { + + HWindow_Final hwin = null; + switch (matchResult.SlotIndex) + { + case 1: hwin = hwin_turnoverSlot1; break; + case 2: hwin = hwin_turnoverSlot2; break; + case 3: hwin = hwin_turnoverSlot3; break; + case 4: hwin = hwin_turnoverSlot4; break; + case 5: hwin = hwin_turnoverSlot5; break; + case 6: hwin = hwin_turnoverSlot6; break; + case 7: hwin = hwin_turnoverSlot7; break; + case 8: hwin = hwin_turnoverSlot8; break; + case 9: hwin = hwin_turnoverSlot9; break; + case 10: hwin = hwin_turnoverSlot10; break; + case 11: hwin = hwin_turnoverSlot11; break; + case 12: hwin = hwin_turnoverSlot12; break; + case 13: hwin = hwin_turnoverSlot13; break; + case 14: hwin = hwin_turnoverSlot14; break; + case 15: hwin = hwin_turnoverSlot15; break; + case 16: hwin = hwin_turnoverSlot16; break; + case 17: hwin = hwin_turnoverSlot17; break; + case 18: hwin = hwin_turnoverSlot18; break; + case 19: hwin = hwin_turnoverSlot19; break; + case 20: hwin = hwin_turnoverSlot20; break; + case 21: hwin = hwin_turnoverSlot21; break; + case 22: hwin = hwin_turnoverSlot22; break; + case 23: hwin = hwin_turnoverSlot23; break; + case 24: hwin = hwin_turnoverSlot24; break; + case 25: hwin = hwin_turnoverSlot25; break; + case 26: hwin = hwin_turnoverSlot26; break; + case 27: hwin = hwin_turnoverSlot27; break; + case 28: hwin = hwin_turnoverSlot28; break; + case 29: hwin = hwin_turnoverSlot29; break; + case 30: hwin = hwin_turnoverSlot30; break; + case 31: hwin = hwin_turnoverSlot31; break; + case 32: hwin = hwin_turnoverSlot32; break; + default: + break; + } + if (hwin != null) + { + hwin.ClearWindow(); + if (arg2) + { + if (matchResult.ScanBarCodeOK) + { + hwin.HobjectToHimage(matchResult.SourceImage); + HalconTool.DispMessage(hwin.hWindowControl.HalconWindow, $"sn:{matchResult.SN}", 20, 20, "green"); + //HalconTool.DispMessage(hwin.hWindowControl.HalconWindow, $"x:{matchResult.OffsetX}", 200, 20, "green"); + //HalconTool.DispMessage(hwin.hWindowControl.HalconWindow, $"y:{matchResult.OffsetY}", 400, 20, "green"); + //HalconTool.DispMessage(hwin.hWindowControl.HalconWindow, $"r:{matchResult.OffsetR}", 600, 20, "green"); + } + else + { + hwin.HobjectToHimage(matchResult.SourceImage); + HalconTool.DispMessage(hwin.hWindowControl.HalconWindow, "NG", 20, 20, "red"); + } + } + else + { + //加载默认图片 + hwin.HobjectToHimage(defaultImage); + HalconTool.DispMessage(hwin.hWindowControl.HalconWindow, "no product", 20, 20, "red"); + } + } + + } private void btnWholeHome_Load(object sender, EventArgs e) { diff --git a/Rs.SkyLine/FormMain.designer.cs b/Rs.SkyLine/FormMain.designer.cs index e6052b7..33f3d7f 100644 --- a/Rs.SkyLine/FormMain.designer.cs +++ b/Rs.SkyLine/FormMain.designer.cs @@ -29,8 +29,8 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.timer1 = new System.Windows.Forms.Timer(this.components); this.panel1 = new System.Windows.Forms.Panel(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); @@ -155,10 +155,10 @@ this.groupBox34 = new System.Windows.Forms.GroupBox(); this.hwin_turnoverSlot32 = new ChoiceTech.Halcon.Control.HWindow_Final(); this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); - this.groupBox29 = new System.Windows.Forms.GroupBox(); - this.hWindow_Final2 = new ChoiceTech.Halcon.Control.HWindow_Final(); this.groupBox30 = new System.Windows.Forms.GroupBox(); this.hWindow_Final3 = new ChoiceTech.Halcon.Control.HWindow_Final(); + this.groupBox29 = new System.Windows.Forms.GroupBox(); + this.hWindow_Final2 = new ChoiceTech.Halcon.Control.HWindow_Final(); this.groupBox35 = new System.Windows.Forms.GroupBox(); this.hWindow_Final4 = new ChoiceTech.Halcon.Control.HWindow_Final(); this.panel1.SuspendLayout(); @@ -225,8 +225,8 @@ this.groupBox33.SuspendLayout(); this.groupBox34.SuspendLayout(); this.tableLayoutPanel4.SuspendLayout(); - this.groupBox29.SuspendLayout(); this.groupBox30.SuspendLayout(); + this.groupBox29.SuspendLayout(); this.groupBox35.SuspendLayout(); this.SuspendLayout(); // @@ -277,14 +277,14 @@ this.dgv_errinfo.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dgv_errinfo.BackgroundColor = System.Drawing.SystemColors.ActiveCaptionText; this.dgv_errinfo.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.Red; - dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle3.ForeColor = System.Drawing.Color.White; - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgv_errinfo.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.Red; + dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.White; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgv_errinfo.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dgv_errinfo.ColumnHeadersHeight = 30; this.dgv_errinfo.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dataGridViewTextBoxColumn1, @@ -362,8 +362,8 @@ // Time // this.Time.DataPropertyName = "Time"; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.Red; - this.Time.DefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.Red; + this.Time.DefaultCellStyle = dataGridViewCellStyle2; this.Time.FillWeight = 25F; this.Time.HeaderText = "Time"; this.Time.MinimumWidth = 6; @@ -2075,32 +2075,6 @@ this.tableLayoutPanel4.Size = new System.Drawing.Size(777, 167); this.tableLayoutPanel4.TabIndex = 0; // - // groupBox29 - // - this.groupBox29.Controls.Add(this.hWindow_Final2); - this.groupBox29.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox29.ForeColor = System.Drawing.Color.White; - this.groupBox29.Location = new System.Drawing.Point(197, 3); - this.groupBox29.Name = "groupBox29"; - this.groupBox29.Size = new System.Drawing.Size(91, 161); - this.groupBox29.TabIndex = 1; - this.groupBox29.TabStop = false; - this.groupBox29.Text = "中转盘有无"; - // - // hWindow_Final2 - // - this.hWindow_Final2.BackColor = System.Drawing.Color.Transparent; - this.hWindow_Final2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.hWindow_Final2.Dock = System.Windows.Forms.DockStyle.Fill; - this.hWindow_Final2.DrawModel = false; - this.hWindow_Final2.ForeColor = System.Drawing.Color.White; - this.hWindow_Final2.Image = null; - this.hWindow_Final2.Location = new System.Drawing.Point(3, 17); - this.hWindow_Final2.Margin = new System.Windows.Forms.Padding(4); - this.hWindow_Final2.Name = "hWindow_Final2"; - this.hWindow_Final2.Size = new System.Drawing.Size(85, 141); - this.hWindow_Final2.TabIndex = 13; - // // groupBox30 // this.groupBox30.Controls.Add(this.hWindow_Final3); @@ -2127,6 +2101,32 @@ this.hWindow_Final3.Size = new System.Drawing.Size(85, 141); this.hWindow_Final3.TabIndex = 13; // + // groupBox29 + // + this.groupBox29.Controls.Add(this.hWindow_Final2); + this.groupBox29.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox29.ForeColor = System.Drawing.Color.White; + this.groupBox29.Location = new System.Drawing.Point(197, 3); + this.groupBox29.Name = "groupBox29"; + this.groupBox29.Size = new System.Drawing.Size(91, 161); + this.groupBox29.TabIndex = 1; + this.groupBox29.TabStop = false; + this.groupBox29.Text = "中转盘有无"; + // + // hWindow_Final2 + // + this.hWindow_Final2.BackColor = System.Drawing.Color.Transparent; + this.hWindow_Final2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.hWindow_Final2.Dock = System.Windows.Forms.DockStyle.Fill; + this.hWindow_Final2.DrawModel = false; + this.hWindow_Final2.ForeColor = System.Drawing.Color.White; + this.hWindow_Final2.Image = null; + this.hWindow_Final2.Location = new System.Drawing.Point(3, 17); + this.hWindow_Final2.Margin = new System.Windows.Forms.Padding(4); + this.hWindow_Final2.Name = "hWindow_Final2"; + this.hWindow_Final2.Size = new System.Drawing.Size(85, 141); + this.hWindow_Final2.TabIndex = 13; + // // groupBox35 // this.groupBox35.Controls.Add(this.hWindow_Final4); @@ -2228,8 +2228,8 @@ this.groupBox33.ResumeLayout(false); this.groupBox34.ResumeLayout(false); this.tableLayoutPanel4.ResumeLayout(false); - this.groupBox29.ResumeLayout(false); this.groupBox30.ResumeLayout(false); + this.groupBox29.ResumeLayout(false); this.groupBox35.ResumeLayout(false); this.ResumeLayout(false); diff --git a/Rs.SkyLine/FormMain.resx b/Rs.SkyLine/FormMain.resx index 3ebdccf..5c02318 100644 --- a/Rs.SkyLine/FormMain.resx +++ b/Rs.SkyLine/FormMain.resx @@ -132,10 +132,4 @@ True - - True - - - True - \ No newline at end of file