优化三点定位流程

master
lhiven 1 year ago
parent 53fd323880
commit 74aedf0a52

@ -60,112 +60,6 @@ namespace Rs.MotionPlat.Commom
} }
return null; return null;
} }
/// <summary>
/// 获取异常料盘的点位
/// </summary>
/// <param name="recipeName"></param>
/// <param name="trayName"></param>
/// <param name="slotIndex"></param>
/// <param name="pointType"></param>
/// <returns></returns>
public static SlotPoint GetExceptionTrayPoint(int slotIndex)
{
string key = $"{GlobalVar.CurRecipe}-ExceptiontTray-{slotIndex}";
if (trayPoints.ContainsKey(key))
{
return trayPoints[key];
}
return null;
}
/// <summary>
/// 获取测试治具测高的点位
/// </summary>
/// <param name="recipeName"></param>
/// <param name="trayName"></param>
/// <param name="slotIndex"></param>
/// <param name="pointType"></param>
/// <returns></returns>
public static SlotPoint GetTestFixtureTrayCheckHeighPoint(int slotIndex)
{
string key = $"{GlobalVar.CurRecipe}-CheckHeightTestTray-{slotIndex}";
if (trayPoints.ContainsKey(key))
{
return trayPoints[key];
}
return null;
}
/// <summary>
/// 获取周转盘测高的点位
/// </summary>
/// <param name="recipeName"></param>
/// <param name="trayName"></param>
/// <param name="slotIndex"></param>
/// <param name="pointType"></param>
/// <returns></returns>
public static SlotPoint GetTurnoverTrayCheckHeighPoint(int slotIndex)
{
string key = $"{GlobalVar.CurRecipe}-CheckHeightTurnover-{slotIndex}";
if (trayPoints.ContainsKey(key))
{
return trayPoints[key];
}
return null;
}
/// <summary>
/// 获取周转盘强力吸嘴的点位
/// </summary>
/// <param name="recipeName"></param>
/// <param name="trayName"></param>
/// <param name="slotIndex"></param>
/// <param name="pointType"></param>
/// <returns></returns>
public static SlotPoint GetTurnoverTrayForceNozzlePoint(int slotIndex)
{
string key = $"{GlobalVar.CurRecipe}-ForceNozzleTurnover-{slotIndex}";
if (trayPoints.ContainsKey(key))
{
return trayPoints[key];
}
return null;
}
/// <summary>
/// 获取周转盘强力吸嘴的点位
/// </summary>
/// <param name="recipeName"></param>
/// <param name="trayName"></param>
/// <param name="slotIndex"></param>
/// <param name="pointType"></param>
/// <returns></returns>
public static SlotPoint GetExceptiontTrayPoint(int slotIndex)
{
string key = $"{GlobalVar.CurRecipe}-ExceptiontTray-{slotIndex}";
if (trayPoints.ContainsKey(key))
{
return trayPoints[key];
}
return null;
}
public static SlotPoint GetDistToNozzle1(int nozzleIndex)
{
//先获取相机的中心位置
SlotPoint point = new SlotPoint();
double nozzle1ToCameraCenterX = SysConfigParam.GetValue<double>("InkpadX") - SysConfigParam.GetValue<double>("CameraInkpadX");
double nozzle1ToCameraCenterY = SysConfigParam.GetValue<double>("InkpadY") - SysConfigParam.GetValue<double>("CameraInkpadY");
//再加上指定吸嘴到吸嘴1的距离
double distToNozzle1X = SysConfigParam.GetValue<double>($"Nozzle{nozzleIndex}CenterX") - SysConfigParam.GetValue<double>($"Nozzle1CenterX");
double distToNozzle1Y = SysConfigParam.GetValue<double>($"Nozzle{nozzleIndex}CenterY") - SysConfigParam.GetValue<double>($"Nozzle1CenterY");
point.X = nozzle1ToCameraCenterX + distToNozzle1X;
point.Y = nozzle1ToCameraCenterY + distToNozzle1Y;
return point;
}
} }
} }

@ -134,5 +134,10 @@ namespace Rs.MotionPlat.Flow
/// TakeTrayX运动异常报警 /// TakeTrayX运动异常报警
/// </summary> /// </summary>
public const int TakeTrayX = 1026; public const int TakeTrayX = 1026;
/// <summary>
/// 料盘定位失败
/// </summary>
public const int = 1027;
} }
} }

@ -263,7 +263,7 @@ namespace Rs.MotionPlat.Flow
curTakeNozzle = NozzleManager.GetIdelNozzle(); curTakeNozzle = NozzleManager.GetIdelNozzle();
if (curTakeNozzle != null) if (curTakeNozzle != null)
{ {
targetPosition = NozzleManager.GotoTraySlot(ETrayType.Grr, curTakeSlot.Index, curTakeNozzle.NozzleIndex); targetPosition = NozzleManager.GetToTraySlot(ETrayType.Grr, curTakeSlot.Index, curTakeNozzle.NozzleIndex);
if(curTakeNozzle != null) if(curTakeNozzle != null)
{ {
targetPosition.X += vResult.OffsetX; targetPosition.X += vResult.OffsetX;
@ -768,7 +768,7 @@ namespace Rs.MotionPlat.Flow
if (curDumpSlot != null) if (curDumpSlot != null)
{ {
targetPosition = NozzleManager.GotoTraySlot(ETrayType.Grr, curDumpSlot.Index, curDumpNozzle.NozzleIndex); targetPosition = NozzleManager.GetToTraySlot(ETrayType.Grr, curDumpSlot.Index, curDumpNozzle.NozzleIndex);
////获取点位 ////获取点位
//SlotPoint slotPoint = TrayPointManager.GetSlotPoint(ETrayType.Ng, curDumpSlot.Index); //SlotPoint slotPoint = TrayPointManager.GetSlotPoint(ETrayType.Ng, curDumpSlot.Index);
//targetPosition.X = slotPoint.X + GlobalVar.Nozzle1ToCameraCenterOffsetX + NozzleManager.GetNozzleOffsetX(curDumpNozzle.NozzleIndex); //targetPosition.X = slotPoint.X + GlobalVar.Nozzle1ToCameraCenterOffsetX + NozzleManager.GetNozzleOffsetX(curDumpNozzle.NozzleIndex);

@ -3,6 +3,7 @@ using Rs.DataAccess;
using Rs.Framework; using Rs.Framework;
using Rs.Motion; using Rs.Motion;
using Rs.MotionPlat.Commom; using Rs.MotionPlat.Commom;
using Rs.MotionPlat.Entitys;
using Rs.MotionPlat.Flow.Common; using Rs.MotionPlat.Flow.Common;
using Rs.MotionPlat.Vision; using Rs.MotionPlat.Vision;
using System; using System;
@ -42,6 +43,8 @@ namespace Rs.MotionPlat.Flow.NormalFlow
string logInfo = string.Empty; string logInfo = string.Empty;
VisionResult vr = new VisionResult(); VisionResult vr = new VisionResult();
List<VisionResult> vResult = new List<VisionResult>(); List<VisionResult> vResult = new List<VisionResult>();
AlarmEntity alarmEntity=new AlarmEntity();
/// <summary> /// <summary>
/// 三点定位(左上/右上/左下) /// 三点定位(左上/右上/左下)
/// </summary> /// </summary>
@ -59,7 +62,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
{ {
return; return;
} }
Task.Run(() => { //Task.Run(() => {
while (!finished) while (!finished)
{ {
if(stop) if(stop)
@ -99,7 +102,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
} }
else else
{ {
step = EThreePointLocationFlowStep.;
} }
} }
break; break;
@ -121,12 +124,21 @@ namespace Rs.MotionPlat.Flow.NormalFlow
CalcTrayRunPoint(trayType); CalcTrayRunPoint(trayType);
TrayRunPointManager.LoadPoint(); TrayRunPointManager.LoadPoint();
finished = true; finished = true;
Msgbox.ShowDialog(EButtonType.Ok, "Three point location finished");
}
}
else
{
alarmEntity = AlarmCollection.Get(AlarmConstID.);
if (alarmEntity != null)
{
Msgbox.ShowDialog(alarmEntity, EButtonType.Retry);
} }
} }
break; break;
} }
} }
}); //});
} }
private void PrintXY1Y2CurrentPos(string prefixLog) private void PrintXY1Y2CurrentPos(string prefixLog)
@ -203,8 +215,8 @@ namespace Rs.MotionPlat.Flow.NormalFlow
{ {
for (int col = 1; col <= 16; col++) for (int col = 1; col <= 16; col++)
{ {
double x = y1 + (row - 1) * bigSpaceY + (col - 1) * smallSpaceX; double x = x1 + (row - 1) * bigSpaceX + (col - 1) * smallSpaceX;
double y = x1 + (col - 1) * bigSpaceX + (row - 1) * smallSpaceY; double y = y1 + (col - 1) * bigSpaceY + (row - 1) * smallSpaceY;
string insertSql = $"insert into trayrunpoints(trayid,recipename,trayname,slotindex,x,y) values(1,'{GlobalVar.CurRecipe}','{trayType}',{index},{x},{y})"; string insertSql = $"insert into trayrunpoints(trayid,recipename,trayname,slotindex,x,y) values(1,'{GlobalVar.CurRecipe}','{trayType}',{index},{x},{y})";
rowAffectNum = db.ExecuteNonQuery(insertSql); rowAffectNum = db.ExecuteNonQuery(insertSql);

@ -474,7 +474,7 @@ namespace Rs.MotionPlat.Commom
/// <param name="slotIndex"></param> /// <param name="slotIndex"></param>
/// <param name="nozzleIndex"></param> /// <param name="nozzleIndex"></param>
/// <returns></returns> /// <returns></returns>
public static TargetPosition GotoTraySlot(ETrayType trayType,int slotIndex,int nozzleIndex) public static TargetPosition GetToTraySlot(ETrayType trayType,int slotIndex,int nozzleIndex)
{ {
TargetPosition targetPosition=new TargetPosition(); TargetPosition targetPosition=new TargetPosition();
SlotPoint curTakeSlotPoint = TrayPointManager.GetSlotPoint(trayType, slotIndex); SlotPoint curTakeSlotPoint = TrayPointManager.GetSlotPoint(trayType, slotIndex);

@ -45,6 +45,12 @@ namespace Rs.MotionPlat.Recipe
} }
private void BindPoints() private void BindPoints()
{
BindBasePoint();
BindRunPoint();
}
void BindBasePoint()
{ {
string querySql = $"select * from TrayPoints where trayname='{m_trayName}' and recipename='{GlobalVar.CurRecipe}' order by slotindex"; string querySql = $"select * from TrayPoints where trayname='{m_trayName}' and recipename='{GlobalVar.CurRecipe}' order by slotindex";
DataTable dtRunPoints = db.GetDataTable(querySql); DataTable dtRunPoints = db.GetDataTable(querySql);
@ -52,10 +58,12 @@ namespace Rs.MotionPlat.Recipe
{ {
dgvBasePoints.DataSource = dtRunPoints; dgvBasePoints.DataSource = dtRunPoints;
} }
}
void BindRunPoint()
querySql = $"select * from TrayRunPoints where trayname='{m_trayName}' and recipename='{GlobalVar.CurRecipe}' order by slotindex"; {
dtRunPoints = db.GetDataTable(querySql); string querySql = $"select * from TrayRunPoints where trayname='{m_trayName}' and recipename='{GlobalVar.CurRecipe}' order by slotindex";
DataTable dtRunPoints = db.GetDataTable(querySql);
if (ObjectHelper.IsNotNullorEmpty(dtRunPoints)) if (ObjectHelper.IsNotNullorEmpty(dtRunPoints))
{ {
dgvRunPoints.DataSource = dtRunPoints; dgvRunPoints.DataSource = dtRunPoints;
@ -166,7 +174,7 @@ namespace Rs.MotionPlat.Recipe
if(selectedSlot!=null) if(selectedSlot!=null)
{ {
int nozzleIndex = 0; int nozzleIndex = 0;
string querySql = $"select * from TrayPoints where trayid={dt.Rows[0]["id"]} and slotindex={selectedSlot.Index}"; string querySql = $"select * from TrayRunPoints where trayid={dt.Rows[0]["id"]} and slotindex={selectedSlot.Index}";
DataTable dtGoPosition = db.GetDataTable(querySql); DataTable dtGoPosition = db.GetDataTable(querySql);
if(ObjectHelper.IsNotNullorEmpty(dtGoPosition)) if(ObjectHelper.IsNotNullorEmpty(dtGoPosition))
{ {
@ -177,14 +185,10 @@ namespace Rs.MotionPlat.Recipe
if (parentMenu.Text.IndexOf("Nozzle") >= 0) if (parentMenu.Text.IndexOf("Nozzle") >= 0)
{ {
nozzleIndex = int.Parse(parentMenu.Text.Replace("Nozzle", "").Replace("GO", "")); nozzleIndex = int.Parse(parentMenu.Text.Replace("Nozzle", "").Replace("GO", ""));
SlotPoint dist = TrayPointManager.GetDistToNozzle1(nozzleIndex); //SlotPoint dist = TrayPointManager.GetDistToNozzle1(nozzleIndex);
targetX += dist.X;
targetY += dist.Y; targetX += NozzleManager.GetNozzleToCameraOffsetX(nozzleIndex);
} targetY += NozzleManager.GetNozzleToCameraOffsetY2(nozzleIndex);
if(subMenu.Text=="GrabPos")
{
targetX += GlobalVar.StockTakePictureOffsetX;
targetY += GlobalVar.StockTakePictureOffsetY;
} }
DialogResult dr = Msg.ShowQuestion($"Are you sure to move loadx to {targetX},loady to {targetY}?"); DialogResult dr = Msg.ShowQuestion($"Are you sure to move loadx to {targetX},loady to {targetY}?");
if(dr== DialogResult.OK) if(dr== DialogResult.OK)
@ -410,6 +414,7 @@ namespace Rs.MotionPlat.Recipe
{ {
ThreePointLocationFlow.Instance.Location(ETrayType.Ok); ThreePointLocationFlow.Instance.Location(ETrayType.Ok);
} }
BindPoints();
}); });
} }
} }

Loading…
Cancel
Save