增加最后一盘料功能

master
lhiven 1 year ago
parent 7b2efbbb8a
commit 8ba233a930

@ -133,7 +133,8 @@ namespace Rs.MotionPlat.Flow.Camera
ImageProcess.ClearManualTrigger();
HikCamera.Instance.SetTrigger(cameraName, ETriggerMode.Manual);
HikCamera.Instance.SetGain(cameraName, 5);
HikCamera.Instance.SetExposure(cameraName, GlobalVar.UpCameraExposureTime);
HikCamera.Instance.SetGain(cameraName, GlobalVar.UpCameraGain);
AxisControl.LoadX.ComparePulse(2, false);
//LightName = SysConfigParam.GetValue<string>(cameraName + "LightName");
//if (!string.IsNullOrEmpty(LightName))

@ -130,10 +130,6 @@ namespace Rs.MotionPlat.Flow
/// </summary>
private int undoTaskNum = 0;
int scanNum = 0;
/// <summary>
/// 料仓是否可以上料
/// </summary>
private bool stockCanLoadFlag = true;
public override void Run()
{
@ -212,54 +208,63 @@ namespace Rs.MotionPlat.Flow
}
else
{
if(stockCanLoadFlag)
//上料完成后判断是否时最后一盘料
//while (true)
{
logInfo = GetClassName() + $"{curTask.FromType.ToString()}盘无料,准备切换料盘";
MessageQueue.Instance.Insert(logInfo);
TakeTrayFlow.Instance.Take(ETrayType.Input, ETrayType.Empty1,
() =>
if (Ops.IsOff("2号料仓缺盘光电检测"))
{
logInfo = "Input料仓最后一盘料请确认是否继续上料?";
msgBox = MsgBox.ShowDialog(111, logInfo, (ETipButton.Yes | ETipButton.No),new Dictionary<ETipButton, string>() { { ETipButton.Yes, "是|Yes" },{ETipButton.No, "结束上料|EndInput" } });
if (msgBox.Button == ETipButton.Yes)
{
Task.Run(() =>
{
StockManager.Instance.GetStock(ETrayType.Input).Load(EStockTrayLoadMode.Whole, null);
});
}, null,
() =>
flowStep = EDischargeFlowStep.;
}
else
{
Task.Run(() =>
//结束上料
TestCenter.Instance.EndInput();
LoadAndUnloadTask.Instance.ClearUndoTask();
if (NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload).Count > 0)
{
StockManager.Instance.GetStock(ETrayType.Empty1).Unload(EStockTrayUnLoadMode.Whole, null);
});
});
StockManager.Instance.GetStock(ETrayType.Input).WaitFinished();
//上料完成后判断是否时最后一盘料
Task.Run(() => {
while (true)
{
if (Ops.IsOn(""))
flowStep = EDischargeFlowStep.;
}
else
{
stockCanLoadFlag = false;
logInfo = "Input料仓最后一盘料请确认是否继续上料?";
msgBox = MsgBox.ShowDialog(111, logInfo, ETipButton.Yes | ETipButton.No);
if (msgBox.Button == ETipButton.Yes)
if (LoadAndUnloadTask.Instance.GetUnDealedTask().Count > 0)
{
//继续上料,这时需要继续检测料仓是否有料
StockTrayToTurnoverTray = !StockTrayToTurnoverTray;
flowStep = EDischargeFlowStep.;
}
else
{
//点击了最后一盘料
break;
flowStep = EDischargeFlowStep.;
}
}
else
{
stockCanLoadFlag = true;
break;
}
break;
}
});
}
else
{
logInfo = GetClassName() + $"{curTask.FromType.ToString()}盘无料,准备切换料盘";
MessageQueue.Instance.Insert(logInfo);
TakeTrayFlow.Instance.Take(ETrayType.Input, ETrayType.Empty1,
() =>
{
Task.Run(() =>
{
StockManager.Instance.GetStock(ETrayType.Input).Load(EStockTrayLoadMode.Whole, null);
});
}, null,
() =>
{
Task.Run(() =>
{
StockManager.Instance.GetStock(ETrayType.Empty1).Unload(EStockTrayUnLoadMode.Whole, null);
});
});
StockManager.Instance.GetStock(ETrayType.Input).WaitFinished();
}
}
break;
}
}

@ -29,17 +29,17 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
this.panelEx1 = new Rs.Controls.PanelEx();
this.panel4 = new System.Windows.Forms.Panel();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.btnCheck = new System.Windows.Forms.Button();
this.txtStockTrayHaveOrNotGrayMax = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.btnGrab = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.btnDrawRegion = new System.Windows.Forms.Button();
this.btnSaveRegion = new System.Windows.Forms.Button();
@ -101,6 +101,7 @@
this.takeProductToolStripMenuItem8 = new System.Windows.Forms.ToolStripMenuItem();
this.dumpProductToolStripMenuItem8 = new System.Windows.Forms.ToolStripMenuItem();
this.moveToolStripMenuItem8 = new System.Windows.Forms.ToolStripMenuItem();
this.lblProductCheckResult = new System.Windows.Forms.Label();
this.panelEx1.SuspendLayout();
this.panel4.SuspendLayout();
this.groupBox4.SuspendLayout();
@ -135,9 +136,10 @@
//
// groupBox4
//
this.groupBox4.Controls.Add(this.lblProductCheckResult);
this.groupBox4.Controls.Add(this.btnCheck);
this.groupBox4.Controls.Add(this.txtStockTrayHaveOrNotGrayMax);
this.groupBox4.Controls.Add(this.button1);
this.groupBox4.Controls.Add(this.btnGrab);
this.groupBox4.Controls.Add(this.label1);
this.groupBox4.Controls.Add(this.btnDrawRegion);
this.groupBox4.Controls.Add(this.btnSaveRegion);
@ -185,19 +187,19 @@
this.txtStockTrayHaveOrNotGrayMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.txtStockTrayHaveOrNotGrayMax.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtSysParam_KeyUp);
//
// button1
// btnGrab
//
this.button1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
this.button1.FlatAppearance.BorderColor = System.Drawing.Color.White;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.ForeColor = System.Drawing.Color.White;
this.button1.Location = new System.Drawing.Point(22, 53);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(103, 36);
this.button1.TabIndex = 8;
this.button1.Text = "相机取图";
this.button1.UseVisualStyleBackColor = false;
this.button1.Click += new System.EventHandler(this.btnCheck_Click);
this.btnGrab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
this.btnGrab.FlatAppearance.BorderColor = System.Drawing.Color.White;
this.btnGrab.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnGrab.ForeColor = System.Drawing.Color.White;
this.btnGrab.Location = new System.Drawing.Point(22, 53);
this.btnGrab.Name = "btnGrab";
this.btnGrab.Size = new System.Drawing.Size(103, 36);
this.btnGrab.TabIndex = 8;
this.btnGrab.Text = "相机取图";
this.btnGrab.UseVisualStyleBackColor = false;
this.btnGrab.Click += new System.EventHandler(this.btnGrab_Click);
//
// label1
//
@ -381,9 +383,9 @@
this.dgvBasePoints.AllowUserToDeleteRows = false;
this.dgvBasePoints.AllowUserToResizeColumns = false;
this.dgvBasePoints.AllowUserToResizeRows = false;
dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
dataGridViewCellStyle6.ForeColor = System.Drawing.Color.White;
this.dgvBasePoints.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6;
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
dataGridViewCellStyle1.ForeColor = System.Drawing.Color.White;
this.dgvBasePoints.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
this.dgvBasePoints.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dgvBasePoints.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(16)))), ((int)(((byte)(36)))));
this.dgvBasePoints.ColumnHeadersHeight = 30;
@ -399,14 +401,14 @@
this.dgvBasePoints.MultiSelect = false;
this.dgvBasePoints.Name = "dgvBasePoints";
this.dgvBasePoints.ReadOnly = true;
dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle10.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(16)))), ((int)(((byte)(36)))));
dataGridViewCellStyle10.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle10.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle10.SelectionBackColor = System.Drawing.Color.White;
dataGridViewCellStyle10.SelectionForeColor = System.Drawing.Color.White;
dataGridViewCellStyle10.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dgvBasePoints.RowHeadersDefaultCellStyle = dataGridViewCellStyle10;
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(16)))), ((int)(((byte)(36)))));
dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle5.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.White;
dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White;
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dgvBasePoints.RowHeadersDefaultCellStyle = dataGridViewCellStyle5;
this.dgvBasePoints.RowHeadersVisible = false;
this.dgvBasePoints.RowHeadersWidth = 30;
this.dgvBasePoints.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
@ -428,8 +430,8 @@
// X
//
this.X.DataPropertyName = "X";
dataGridViewCellStyle7.Format = "0.000";
this.X.DefaultCellStyle = dataGridViewCellStyle7;
dataGridViewCellStyle2.Format = "0.000";
this.X.DefaultCellStyle = dataGridViewCellStyle2;
this.X.FillWeight = 35F;
this.X.HeaderText = "X";
this.X.Name = "X";
@ -438,8 +440,8 @@
// Y
//
this.Y.DataPropertyName = "Y";
dataGridViewCellStyle8.Format = "0.000";
this.Y.DefaultCellStyle = dataGridViewCellStyle8;
dataGridViewCellStyle3.Format = "0.000";
this.Y.DefaultCellStyle = dataGridViewCellStyle3;
this.Y.FillWeight = 35F;
this.Y.HeaderText = "Y";
this.Y.Name = "Y";
@ -448,10 +450,10 @@
// Move
//
this.Move.ActiveLinkColor = System.Drawing.Color.White;
dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle9.BackColor = System.Drawing.Color.Silver;
dataGridViewCellStyle9.ForeColor = System.Drawing.Color.White;
this.Move.DefaultCellStyle = dataGridViewCellStyle9;
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle4.BackColor = System.Drawing.Color.Silver;
dataGridViewCellStyle4.ForeColor = System.Drawing.Color.White;
this.Move.DefaultCellStyle = dataGridViewCellStyle4;
this.Move.FillWeight = 20F;
this.Move.HeaderText = "Move";
this.Move.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline;
@ -787,6 +789,16 @@
this.moveToolStripMenuItem8.Size = new System.Drawing.Size(156, 22);
this.moveToolStripMenuItem8.Text = "Move";
//
// lblProductCheckResult
//
this.lblProductCheckResult.BackColor = System.Drawing.Color.Red;
this.lblProductCheckResult.Location = new System.Drawing.Point(134, 366);
this.lblProductCheckResult.Name = "lblProductCheckResult";
this.lblProductCheckResult.Size = new System.Drawing.Size(129, 44);
this.lblProductCheckResult.TabIndex = 52;
this.lblProductCheckResult.Text = "无";
this.lblProductCheckResult.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// StockTrayHaveOrNot
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@ -863,7 +875,7 @@
private System.Windows.Forms.ToolStripMenuItem dumpProductToolStripMenuItem8;
private System.Windows.Forms.ToolStripMenuItem moveToolStripMenuItem8;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button btnGrab;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.TextBox txtStockTrayHaveOrNotGrayMax;
private System.Windows.Forms.Label label1;
@ -882,5 +894,6 @@
private System.Windows.Forms.DataGridViewTextBoxColumn X;
private System.Windows.Forms.DataGridViewTextBoxColumn Y;
private System.Windows.Forms.DataGridViewLinkColumn Move;
private System.Windows.Forms.Label lblProductCheckResult;
}
}

@ -1,5 +1,7 @@
using HalconDotNet;
using NPOI.SS.Formula.PTG;
using NPOI.SS.UserModel;
using Rs.Camera;
using Rs.Controls;
using Rs.DataAccess;
using Rs.Framework;
@ -136,13 +138,27 @@ namespace Rs.MotionPlat.Recipe
{
hWindow_Final1.ClearWindow();
hWindow_Final1.HobjectToHimage(showImage);
hWindow_Final1.DispObj(searchRegion);
HOperatorSet.ReduceDomain(showImage, searchRegion, out HObject imageReduced);
HOperatorSet.Threshold(imageReduced,out HObject resultRegion,GlobalVar.StockTrayHaveOrNotGrayMin,GlobalVar.StockTrayHaveOrNotGrayMax);
HOperatorSet.AreaCenter(resultRegion,out HTuple area,out HTuple row,out HTuple col);
HOperatorSet.SetDraw(winHandle, "fill");
hWindow_Final1.DispObj(resultRegion, "red");
lblCheckResult.Text = area.D.ToString("0.00");
if (area.D > GlobalVar.TurnoverTrayHaveOrNotGrayArea)
{
lblProductCheckResult.BackColor = Color.Green;
lblProductCheckResult.Text = "有产品";
}
else
{
lblProductCheckResult.BackColor = Color.Red;
lblProductCheckResult.Text = "无产品";
}
}
//Task.Run(() =>
//{
// Invoke(new Action(() => {
@ -206,5 +222,26 @@ namespace Rs.MotionPlat.Recipe
Msg.ShowInfo("please select region");
}
}
private void btnGrab_Click(object sender, EventArgs e)
{
string cameraName = "upCamera";
ImageProcess.ClearManualTrigger();
HikCamera.Instance.SetTrigger(cameraName, ETriggerMode.Manual);
HikCamera.Instance.SetExposure(cameraName, GlobalVar.UpCameraExposureTime);
HikCamera.Instance.SetGain(cameraName, GlobalVar.UpCameraGain);
AxisControl.LoadX.ComparePulse(2, false);
bool cameraOk = ImageProcess.manualTriggerEvent.WaitOne(3000);
if (cameraOk)
{
HObject image = ImageProcess.GetManualImage();
if (cameraName == SysConfigParam.GetValue<string>("UpCameraName"))
{
HOperatorSet.RotateImage(image, out showImage, SysConfigParam.GetValue<double>("UpCameraRotate"), "constant");
}
hWindow_Final1.HobjectToHimage(showImage);
}
}
}
}

@ -29,11 +29,11 @@
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
this.panelEx1 = new Rs.Controls.PanelEx();
this.panelEx2 = new Rs.Controls.PanelEx();
this.panel4 = new System.Windows.Forms.Panel();
@ -41,7 +41,7 @@
this.lblProductCheckResult = new System.Windows.Forms.Label();
this.btnCheck = new System.Windows.Forms.Button();
this.txtTurnoverTrayHaveOrNotGrayMax = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.btnGrab = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.btnDrawRegion = new System.Windows.Forms.Button();
this.btnSaveRegion = new System.Windows.Forms.Button();
@ -114,7 +114,7 @@
this.groupBox4.Controls.Add(this.lblProductCheckResult);
this.groupBox4.Controls.Add(this.btnCheck);
this.groupBox4.Controls.Add(this.txtTurnoverTrayHaveOrNotGrayMax);
this.groupBox4.Controls.Add(this.button1);
this.groupBox4.Controls.Add(this.btnGrab);
this.groupBox4.Controls.Add(this.label1);
this.groupBox4.Controls.Add(this.btnDrawRegion);
this.groupBox4.Controls.Add(this.btnSaveRegion);
@ -172,18 +172,19 @@
this.txtTurnoverTrayHaveOrNotGrayMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.txtTurnoverTrayHaveOrNotGrayMax.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtSysParam_KeyUp);
//
// button1
// btnGrab
//
this.button1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
this.button1.FlatAppearance.BorderColor = System.Drawing.Color.White;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.ForeColor = System.Drawing.Color.White;
this.button1.Location = new System.Drawing.Point(22, 53);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(103, 36);
this.button1.TabIndex = 8;
this.button1.Text = "相机取图";
this.button1.UseVisualStyleBackColor = false;
this.btnGrab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
this.btnGrab.FlatAppearance.BorderColor = System.Drawing.Color.White;
this.btnGrab.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnGrab.ForeColor = System.Drawing.Color.White;
this.btnGrab.Location = new System.Drawing.Point(22, 53);
this.btnGrab.Name = "btnGrab";
this.btnGrab.Size = new System.Drawing.Size(103, 36);
this.btnGrab.TabIndex = 8;
this.btnGrab.Text = "相机取图";
this.btnGrab.UseVisualStyleBackColor = false;
this.btnGrab.Click += new System.EventHandler(this.btnGrab_Click);
//
// label1
//
@ -367,9 +368,9 @@
this.dgvBasePoints.AllowUserToDeleteRows = false;
this.dgvBasePoints.AllowUserToResizeColumns = false;
this.dgvBasePoints.AllowUserToResizeRows = false;
dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
dataGridViewCellStyle1.ForeColor = System.Drawing.Color.White;
this.dgvBasePoints.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(56)))), ((int)(((byte)(56)))), ((int)(((byte)(56)))));
dataGridViewCellStyle6.ForeColor = System.Drawing.Color.White;
this.dgvBasePoints.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6;
this.dgvBasePoints.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dgvBasePoints.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(16)))), ((int)(((byte)(36)))));
this.dgvBasePoints.ColumnHeadersHeight = 30;
@ -385,14 +386,14 @@
this.dgvBasePoints.MultiSelect = false;
this.dgvBasePoints.Name = "dgvBasePoints";
this.dgvBasePoints.ReadOnly = true;
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(16)))), ((int)(((byte)(36)))));
dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle5.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.White;
dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White;
dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dgvBasePoints.RowHeadersDefaultCellStyle = dataGridViewCellStyle5;
dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle10.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(11)))), ((int)(((byte)(16)))), ((int)(((byte)(36)))));
dataGridViewCellStyle10.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle10.ForeColor = System.Drawing.Color.White;
dataGridViewCellStyle10.SelectionBackColor = System.Drawing.Color.White;
dataGridViewCellStyle10.SelectionForeColor = System.Drawing.Color.White;
dataGridViewCellStyle10.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dgvBasePoints.RowHeadersDefaultCellStyle = dataGridViewCellStyle10;
this.dgvBasePoints.RowHeadersVisible = false;
this.dgvBasePoints.RowHeadersWidth = 30;
this.dgvBasePoints.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
@ -414,8 +415,8 @@
// X
//
this.X.DataPropertyName = "X";
dataGridViewCellStyle2.Format = "0.000";
this.X.DefaultCellStyle = dataGridViewCellStyle2;
dataGridViewCellStyle7.Format = "0.000";
this.X.DefaultCellStyle = dataGridViewCellStyle7;
this.X.FillWeight = 35F;
this.X.HeaderText = "X";
this.X.Name = "X";
@ -424,8 +425,8 @@
// Y
//
this.Y.DataPropertyName = "Y";
dataGridViewCellStyle3.Format = "0.000";
this.Y.DefaultCellStyle = dataGridViewCellStyle3;
dataGridViewCellStyle8.Format = "0.000";
this.Y.DefaultCellStyle = dataGridViewCellStyle8;
this.Y.FillWeight = 35F;
this.Y.HeaderText = "Y";
this.Y.Name = "Y";
@ -434,10 +435,10 @@
// Move
//
this.Move.ActiveLinkColor = System.Drawing.Color.White;
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle4.BackColor = System.Drawing.Color.Silver;
dataGridViewCellStyle4.ForeColor = System.Drawing.Color.White;
this.Move.DefaultCellStyle = dataGridViewCellStyle4;
dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle9.BackColor = System.Drawing.Color.Silver;
dataGridViewCellStyle9.ForeColor = System.Drawing.Color.White;
this.Move.DefaultCellStyle = dataGridViewCellStyle9;
this.Move.FillWeight = 20F;
this.Move.HeaderText = "Move";
this.Move.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline;
@ -558,7 +559,7 @@
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Button btnCheck;
private System.Windows.Forms.TextBox txtTurnoverTrayHaveOrNotGrayMax;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button btnGrab;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnDrawRegion;
private System.Windows.Forms.Button btnSaveRegion;

@ -1,4 +1,6 @@
using HalconDotNet;
using ChoiceTech.Halcon.Control;
using HalconDotNet;
using Rs.Camera;
using Rs.Controls;
using Rs.DataAccess;
using Rs.Framework;
@ -51,20 +53,20 @@ namespace Rs.MotionPlat.Recipe
BindPoints();
PositionHelper.BindPosition(groupBox4, "int");
string filePath = Path.Combine(dirPth, "default.bmp");
HOperatorSet.ReadImage(out showImage, filePath);
hWindow_Final1.HobjectToHimage(showImage);
if (File.Exists(Path.Combine(dirPth, "搜索区域.reg")))
if(File.Exists(filePath))
{
//把区域都出来
HOperatorSet.ReadRegion(out searchRegion, Path.Combine(dirPth, "搜索区域.reg"));
//show region
HOperatorSet.SetDraw(winHandle, "margin");
HOperatorSet.SetColor(winHandle, "green");
hWindow_Final1.DispObj(searchRegion, "green");
HOperatorSet.ReadImage(out showImage, filePath);
hWindow_Final1.HobjectToHimage(showImage);
if (File.Exists(Path.Combine(dirPth, "搜索区域.reg")))
{
//把区域都出来
HOperatorSet.ReadRegion(out searchRegion, Path.Combine(dirPth, "搜索区域.reg"));
//show region
HOperatorSet.SetDraw(winHandle, "margin");
HOperatorSet.SetColor(winHandle, "green");
hWindow_Final1.DispObj(searchRegion, "green");
}
}
}
private void rsTray1_SlotClickEvent(TraySlot arg1, MouseEventArgs arg2)
@ -140,6 +142,10 @@ namespace Rs.MotionPlat.Recipe
if (searchRegion != null && searchRegion.IsInitialized())
{
if(!Directory.Exists(dirPth))
{
Directory.CreateDirectory(dirPth);
}
HOperatorSet.WriteImage(showImage, "bmp", 0, Path.Combine(dirPth, "default.bmp"));
HOperatorSet.WriteRegion(searchRegion, Path.Combine(dirPth, "搜索区域.reg"));
Msg.ShowInfo("save success!!!");
@ -175,5 +181,26 @@ namespace Rs.MotionPlat.Recipe
}
}
}
private void btnGrab_Click(object sender, EventArgs e)
{
string cameraName = "upCamera";
ImageProcess.ClearManualTrigger();
HikCamera.Instance.SetTrigger(cameraName, ETriggerMode.Manual);
HikCamera.Instance.SetExposure(cameraName, GlobalVar.UpCameraExposureTime);
HikCamera.Instance.SetGain(cameraName, GlobalVar.UpCameraGain);
AxisControl.LoadX.ComparePulse(2, false);
bool cameraOk = ImageProcess.manualTriggerEvent.WaitOne(3000);
if (cameraOk)
{
HObject image = ImageProcess.GetManualImage();
if (cameraName == SysConfigParam.GetValue<string>("UpCameraName"))
{
HOperatorSet.RotateImage(image, out showImage, SysConfigParam.GetValue<double>("UpCameraRotate"), "constant");
}
hWindow_Final1.HobjectToHimage(showImage);
}
}
}
}

Loading…
Cancel
Save