|
|
|
|
using Rs.Controls;
|
|
|
|
|
using Rs.DataAccess;
|
|
|
|
|
using Rs.Framework;
|
|
|
|
|
using Rs.Motion;
|
|
|
|
|
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.Recipe
|
|
|
|
|
{
|
|
|
|
|
public partial class FixtureTrayExceptionNozzle : BaseForm
|
|
|
|
|
{
|
|
|
|
|
string trayName = "ForceNozzleFixtureTray";
|
|
|
|
|
SqliteHelper db = new SqliteHelper();
|
|
|
|
|
DataTable dt = new DataTable();
|
|
|
|
|
TraySlot selectedSlot;
|
|
|
|
|
public FixtureTrayExceptionNozzle()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void btnCreateMatrix_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string deleteSql = $"delete from traypoints where recipename='{GlobalVar.CurRecipe}' and trayname='{trayName}'";
|
|
|
|
|
if (db.ExecuteNonQuery(deleteSql) >= 0)
|
|
|
|
|
{
|
|
|
|
|
int rowNum = int.Parse(dt.Rows[0]["RowNum"].ToString());
|
|
|
|
|
int colNum = int.Parse(dt.Rows[0]["ColumnNum"].ToString());
|
|
|
|
|
int index = 1;
|
|
|
|
|
double dischargeNozzleX1 = double.Parse(txtMarkX1.Text);
|
|
|
|
|
double dischargeNozzleY1 = double.Parse(txtMarkY1.Text);
|
|
|
|
|
for (int i = 0; i < rowNum; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < colNum; j++)
|
|
|
|
|
{
|
|
|
|
|
double xRun = dischargeNozzleX1 + (j * double.Parse(dt.Rows[0]["SlotOffsetDistX"].ToString()));
|
|
|
|
|
double yRun = dischargeNozzleY1 + (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='{trayName}'";
|
|
|
|
|
dt = db.GetDataTable(querySql);
|
|
|
|
|
if (ObjectHelper.IsNotNullorEmpty(dt))
|
|
|
|
|
{
|
|
|
|
|
txtMarkX1.Text = dt.Rows[0]["MarkX1"].ToString();
|
|
|
|
|
txtMarkY1.Text = dt.Rows[0]["MarkY1"].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 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");
|
|
|
|
|
string updateSql = $"update NormalTray set {txt.Name.Replace("txt", "")}={pos} where recipename='{GlobalVar.CurRecipe}' and trayname='{trayName}'";
|
|
|
|
|
if (db.ExecuteNonQuery(updateSql) > 0)
|
|
|
|
|
{
|
|
|
|
|
BindPoints();
|
|
|
|
|
Msg.ShowInfo("teach point ok!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 txtPoint_KeyUp(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TextBox txtKey = (TextBox)sender;
|
|
|
|
|
if (e.KeyCode == Keys.Enter)
|
|
|
|
|
{
|
|
|
|
|
string key = txtKey.Name.Replace("txt", "");
|
|
|
|
|
string value = txtKey.Text;
|
|
|
|
|
if (SysConfigParam.Update(key, value) > 0)
|
|
|
|
|
{
|
|
|
|
|
Msg.ShowInfo("Save success!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FixtureTrayExceptionNozzle_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
dgvRunPoints.AutoGenerateColumns = false;
|
|
|
|
|
BindPoints();
|
|
|
|
|
LoadSysParam(groupBox4);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|