You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
4.9 KiB
C#
122 lines
4.9 KiB
C#
using HalconDotNet;
|
|
using Rs.Controls;
|
|
using Rs.Framework;
|
|
using Rs.Motion.Base.Config;
|
|
using Rs.MotionPlat.Commom;
|
|
using Rs.MotionPlat.Flow;
|
|
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 Rs.MotionPlat
|
|
{
|
|
public partial class TrayLocationConfig : BaseForm
|
|
{
|
|
string m_trayname = "";
|
|
public TrayLocationConfig(string trayname)
|
|
{
|
|
InitializeComponent();
|
|
m_trayname = trayname;
|
|
cameraTemplate1.ItemName = m_trayname;
|
|
//cameraTemplate1.SetFindShapeMode( EFindShapeMode.SelfDefine );
|
|
// cameraTemplate1.FindShapeEvent += CameraTemplate1_FindShapeEvent;
|
|
}
|
|
|
|
private void CameraTemplate1_FindShapeEvent(ChoiceTech.Halcon.Control.HWindow_Final arg1, HalconDotNet.HObject arg2)
|
|
{
|
|
/*
|
|
gen_rectangle1 (Rectangle, Row1, Column1, Row2, Column2)
|
|
reduce_domain (Image21212121, Rectangle, ImageReduced)
|
|
threshold (ImageReduced, Region, 0, 100)
|
|
connection (Region, ConnectedRegions)
|
|
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 3000, 4000)
|
|
select_shape (SelectedRegions, SelectedRegions1, 'circularity', 'and', 0.8, 1)
|
|
smallest_circle (SelectedRegions1, Row, Column, Radius)
|
|
gen_circle (Circle, Row, Column, Radius)
|
|
*/
|
|
HOperatorSet.GenRectangle1(out HObject rectSearch, 502, 291, 982, 785);
|
|
HOperatorSet.ReduceDomain(arg2, rectSearch, out HObject imageReduced);
|
|
HOperatorSet.Threshold(imageReduced, out HObject region, 0, 100);
|
|
HOperatorSet.Connection(region, out HObject connectRegion);
|
|
if(connectRegion.IsInitialized()&&connectRegion.CountObj()>0)
|
|
{
|
|
HOperatorSet.SelectShape(connectRegion, out HObject select1Regions, "area","and", 3000, 4000);
|
|
HOperatorSet.SelectShape(select1Regions, out HObject select2Regions, "circularity", "and", 0.8, 1);
|
|
HOperatorSet.SmallestCircle(select2Regions,out HTuple circleRow,out HTuple circleColumn,out HTuple circleRadius);
|
|
if(circleRadius.Length>0 && circleRadius.DArr.Length==1)
|
|
{
|
|
HOperatorSet.GenCrossContourXld(out HObject cross, circleRow, circleColumn, 20, 0);
|
|
arg1.DispObj(cross, "green");
|
|
}
|
|
}
|
|
}
|
|
|
|
public TrayLocationConfig()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void TrayLocationRecipe_Load(object sender, EventArgs e)
|
|
{
|
|
PositionHelper.BindPosition(groupBox5);
|
|
PositionHelper.BindPosition(groupBox1);
|
|
PositionHelper.BindPosition(groupBox2);
|
|
PositionHelper.BindPosition(groupBox3);
|
|
PositionHelper.BindPosition(groupBox4);
|
|
PositionHelper.BindPosition(groupBox6);
|
|
|
|
//txtTrayEmpty1CenterX.Text = SysConfigParam.GetValue<string>("Tray"+ m_trayname + txtTrayEmpty1CenterX.Name.Replace("txt", ""));
|
|
//txtTrayEmpty1CenterY.Text = SysConfigParam.GetValue<string>("Tray" + m_trayname + txtTrayEmpty1CenterY.Name.Replace("txt", ""));
|
|
}
|
|
|
|
private void BtnTeach_Click(object sender, EventArgs e)
|
|
{
|
|
PositionHelper.Teach(this, sender);
|
|
//Button btnTeach = (Button)sender;
|
|
//string name = btnTeach.Name.Replace("btnTeach", "");
|
|
//string txtname = "txt" + name;
|
|
//string varName =name;
|
|
//Control txt = ControlManager.FindControl(this, txtname);
|
|
//if(txt != null)
|
|
//{
|
|
// string axisName=txt.Tag.ToString();
|
|
// double targetPos = Ops.GetCurPosition(axisName);
|
|
// txt.Text = targetPos.ToString("0.000");
|
|
// SysConfigParam.Update(varName, targetPos.ToString());
|
|
//}
|
|
}
|
|
|
|
private void btnMove_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
PositionHelper.Move2This(this, sender);
|
|
|
|
|
|
//Button btnTeach = (Button)sender;
|
|
//string name = btnTeach.Name.Replace("btnMove", "");
|
|
//string txtname = "txt" + name;
|
|
//string varName = name;
|
|
//Control txt = ControlManager.FindControl(this, txtname);
|
|
//if (txt != null)
|
|
//{
|
|
// string axisName = txt.Tag.ToString();
|
|
// AxisControl.GetAxis(axisName).MovePos(double.Parse(txt.Text), 4);
|
|
// //double targetPos = Ops.GetCurPosition(axisName);
|
|
// //txt.Text = targetPos.ToString("0.000");
|
|
// //SysConfigParam.Update(varName, targetPos.ToString());
|
|
//}
|
|
}
|
|
|
|
public void txtSysParam_KeyUp(object sender, KeyEventArgs e)
|
|
{
|
|
UpdateSysParam((TextBox)sender);
|
|
}
|
|
}
|
|
}
|