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.
223 lines
8.7 KiB
C#
223 lines
8.7 KiB
C#
using Rs.Controls;
|
|
using Rs.DataAccess;
|
|
using Rs.Framework;
|
|
using Rs.Motion;
|
|
using Rs.MotionPlat.AuxiliaryEquipment;
|
|
using Rs.MotionPlat.Commom;
|
|
using Rs.MotionPlat.Flow;
|
|
using Rs.MotionPlat.Flow.SubFlow;
|
|
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;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button;
|
|
|
|
namespace Rs.MotionPlat.Recipe
|
|
{
|
|
public partial class TestFixtureTrayCheckHeight : BaseForm
|
|
{
|
|
SqliteHelper db = new SqliteHelper();
|
|
DataTable dt = new DataTable();
|
|
TraySlot selectedSlot;
|
|
|
|
|
|
public TestFixtureTrayCheckHeight()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void btnCreateMatrix_Click(object sender, EventArgs e)
|
|
{
|
|
string deleteSql = $"delete from traypoints where recipename='{GlobalVar.CurRecipe}' and trayname='{dt.Rows[0]["trayname"]}'";
|
|
db.ExecuteNonQuery(deleteSql);
|
|
int rowNum = int.Parse(dt.Rows[0]["rowNum"].ToString());
|
|
int colNum = int.Parse(dt.Rows[0]["ColumnNum"].ToString()); ;
|
|
int index = 1;
|
|
for (int i = 0; i < rowNum; i++)
|
|
{
|
|
for (int j = 0; j < colNum; j++)
|
|
{
|
|
double xRun = double.Parse(dt.Rows[0]["MarkX1"].ToString()) + (j * double.Parse(dt.Rows[0]["SlotOffsetDistX"].ToString()));
|
|
double yRun = double.Parse(dt.Rows[0]["MarkY1"].ToString()) + (i * double.Parse(dt.Rows[0]["SlotOffsetDistY"].ToString()));
|
|
string insertRunSql = $"insert into TrayPoints(trayid,recipename,trayname,slotindex,x,y) values({dt.Rows[0]["id"]},'{GlobalVar.CurRecipe}', '{dt.Rows[0]["TrayName"]}',{index},{xRun},{yRun})";
|
|
db.ExecuteNonQuery(insertRunSql);
|
|
index++;
|
|
}
|
|
}
|
|
BindPoints();
|
|
}
|
|
|
|
private void BindPoints()
|
|
{
|
|
string querySql = $"select * from normaltray where recipename='{GlobalVar.CurRecipe}' and trayname='CheckHeightTestTray'";
|
|
dt = db.GetDataTable(querySql);
|
|
if (ObjectHelper.IsNotNullorEmpty(dt))
|
|
{
|
|
txtMarkX1.Text = dt.Rows[0]["MarkX1"].ToString();
|
|
txtMarkY1.Text = dt.Rows[0]["MarkY1"].ToString();
|
|
|
|
txtSlotOffsetDistX.Text = dt.Rows[0]["SlotOffsetDistX"].ToString();
|
|
txtSlotOffsetDistY.Text = dt.Rows[0]["SlotOffsetDistY"].ToString();
|
|
}
|
|
querySql = $"select * from TrayPoints where trayname='{dt.Rows[0]["TrayName"]}'";
|
|
DataTable dtRunPoints = db.GetDataTable(querySql);
|
|
if (ObjectHelper.IsNotNullorEmpty(dtRunPoints))
|
|
{
|
|
dgvRunPoints.DataSource = dtRunPoints;
|
|
}
|
|
|
|
}
|
|
|
|
private void TestFixtureTrayCheckHeight_Load(object sender, EventArgs e)
|
|
{
|
|
PositionHelper.BindPosition(groupBox4);
|
|
dgvRunPoints.AutoGenerateColumns = false;
|
|
BindPoints();
|
|
LoadSysParam(groupBox1);
|
|
PositionHelper.BindSinglePosition(txtTestFixtureTrayOffsetHeight);
|
|
}
|
|
|
|
private void rsTray1_SlotClickEvent(Controls.TraySlot arg1, MouseEventArgs arg2)
|
|
{
|
|
selectedSlot = arg1;
|
|
contextMenuStrip1.Show(MousePosition.X, MousePosition.Y);
|
|
}
|
|
|
|
private void moveToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
if (selectedSlot != null)
|
|
{
|
|
string querySql = $"select * from TrayPoints where trayid={dt.Rows[0]["id"]} and slotindex={selectedSlot.Index}";
|
|
DataTable dtGoPosition = db.GetDataTable(querySql);
|
|
if (ObjectHelper.IsNotNullorEmpty(dtGoPosition))
|
|
{
|
|
double targetX = double.Parse(dtGoPosition.Rows[0]["X"].ToString());
|
|
double targetY = double.Parse(dtGoPosition.Rows[0]["Y"].ToString());
|
|
DialogResult dr = Msg.ShowQuestion($"Are you sure to move turnoverx to {targetX},turnovery to {targetY}?");
|
|
if (dr == DialogResult.OK)
|
|
{
|
|
Motion.ErrorCode errCode = AxisControl.GetAxis("TurnoverX").MovePos(targetX, 4);
|
|
if (errCode > Motion.ErrorCode.Ok)
|
|
{
|
|
Msg.ShowError($"axis TurnoverX move fail,ret={errCode}");
|
|
return;
|
|
}
|
|
errCode = AxisControl.GetAxis("TurnoverY").MovePos(targetY, 4);
|
|
if (errCode > Motion.ErrorCode.Ok)
|
|
{
|
|
Msg.ShowError($"axis TurnoverY move fail,ret={errCode}");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void btnTeach_Click(object sender, EventArgs e)
|
|
{
|
|
Button btnTeach = (Button)sender;
|
|
string name = btnTeach.Name.Replace("btnTeach", "");
|
|
Control txt = ControlManager.FindControl(groupBox1, "txt" + name);
|
|
if (txt != null)
|
|
{
|
|
double pos = Ops.GetCurPosition(txt.Tag.ToString());
|
|
txt.Text = pos.ToString("0.000");
|
|
if (ObjectHelper.IsNotNullorEmpty(dt))
|
|
{
|
|
string updateSql = $"update NormalTray set {txt.Name.Replace("txt", "")}={pos} where recipename='{GlobalVar.CurRecipe}' and trayname='{dt.Rows[0]["trayname"]}'";
|
|
if (db.ExecuteNonQuery(updateSql) > 0)
|
|
{
|
|
BindPoints();
|
|
Msg.ShowInfo("teach point ok!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void btnMove_Click(object sender, EventArgs e)
|
|
{
|
|
Button btnTeach = (Button)sender;
|
|
string name = btnTeach.Name.Replace("btnMove", "");
|
|
Control txt = ControlManager.FindControl(groupBox1, "txt" + name);
|
|
if (txt != null)
|
|
{
|
|
double targetPos = double.Parse(txt.Text);
|
|
DialogResult dr = Msg.ShowQuestion($"are you sure to move axis {txt.Tag} to postion at:{targetPos}?");
|
|
if (dr == DialogResult.OK)
|
|
{
|
|
Motion.ErrorCode errCode = AxisControl.GetAxis(txt.Tag.ToString()).MovePos(targetPos, 4);
|
|
if (errCode != Motion.ErrorCode.Ok)
|
|
{
|
|
Msg.ShowError($"axis {txt.Tag.ToString()} move fail {errCode}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void btnSavePoint_Click(object sender, EventArgs e)
|
|
{
|
|
Button button = (Button)sender;
|
|
string name = button.Name.Replace("btnSave", "");
|
|
Control txt = ControlManager.FindControl(this, "txt" + name);
|
|
if (txt != null)
|
|
{
|
|
if (ObjectHelper.IsNotNullorEmpty(dt))
|
|
{
|
|
string updateSql = $"update NormalTray set {name}={txt.Text} where id={dt.Rows[0]["id"]}";
|
|
if (db.ExecuteNonQuery(updateSql) > 0)
|
|
{
|
|
Msg.ShowInfo("save ok!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void txtTestFixtureCheckBaseHeight_KeyUp(object sender, KeyEventArgs e)
|
|
{
|
|
UpdateSysParam(txtTestFixtureTrayOffsetHeight);
|
|
}
|
|
|
|
private void btnTestHeight_Click(object sender, EventArgs e)
|
|
{
|
|
double val = DeviceFactory.checkHeightDev.Read();
|
|
if(val!=AlarmConstID.NG)
|
|
{
|
|
|
|
lblTestValue.Text = DeviceFactory.checkHeightDev.Read().ToString("0.000");
|
|
//lblSubValue.Text = (double.Parse(lblTestValue.Text) - double.Parse(txtTestFixtureTrayOffsetHeight.Text)).ToString("0.000");
|
|
}
|
|
else
|
|
{
|
|
Msg.ShowError("测高失败");
|
|
}
|
|
}
|
|
|
|
private void txtTestFixtureTrayTestHeightOffsetX_KeyUp(object sender, KeyEventArgs e)
|
|
{
|
|
UpdateSysParam(txtTestFixtureTrayTestHeightOffsetX);
|
|
}
|
|
|
|
private void testHeightToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
if (selectedSlot != null)
|
|
{
|
|
TestHeightResult thr = LaserFlow.Instance.HasProduct(ETrayType.Test, selectedSlot.Index);
|
|
if(thr!=null&&thr.HasProduct)
|
|
{
|
|
Msg.ShowInfo("has product");
|
|
}
|
|
else
|
|
{
|
|
Msg.ShowInfo("hasn't product");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|