@ -18,8 +18,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
{
到 拍 照 位 ,
等 待 到 拍 照 位 ,
通 知 相 机 拍 照 ,
处 理 拍 照 结 果
相 机 拍 照 处 理
}
public class ThreePointLocationFlow
{
@ -96,7 +95,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
{
logInfo = $"已运动到拍照位,cloadx:{Ops.GetCurPosition(AxisControl.LoadX)},cloady1:{Ops.GetCurPosition(AxisControl.LoadY1)},cloady2:{Ops.GetCurPosition(AxisControl.LoadY2)}" ;
MessageQueue . Instance . Insert ( logInfo ) ;
step = EThreePointLocationFlowStep . 通知 相机 拍 照 ;
step = EThreePointLocationFlowStep . 相机 拍 照 处 理 ;
}
else
{
@ -104,62 +103,25 @@ namespace Rs.MotionPlat.Flow.NormalFlow
}
}
break ;
case EThreePointLocationFlowStep . 通知 相机 拍 照 :
case EThreePointLocationFlowStep . 相机 拍 照 处 理 :
vr = VisionHelper . Grab ( Vision . EVisionScene . TrayLocation ) ;
if ( vr ! = null & & vr . Result )
{
vResult . Add ( vr ) ;
step = EThreePointLocationFlowStep . 处 理 拍 照 结 果 ;
}
break ;
case EThreePointLocationFlowStep . 处 理 拍 照 结 果 :
//在这里先打印拍照结果
logInfo = JsonConvert . SerializeObject ( vr ) ;
MessageQueue . Instance . Insert ( logInfo ) ;
points . RemoveAt ( 0 ) ;
if ( points . Count > 0 )
{
step = EThreePointLocationFlowStep . 到 拍 照 位 ;
}
else
{
string deleteSql = $"delete from trayrunpoints where recipeName='{GlobalVar.CurRecipe}' and trayname='{trayType}'" ;
SqliteHelper db = new SqliteHelper ( ) ;
int rowAffectNum = db . ExecuteNonQuery ( deleteSql ) ;
double x1 = TrayPointManager . GetSlotPoint ( trayType , 1 ) . X + vResult [ 0 ] . OffsetX ;
double y1 = TrayPointManager . GetSlotPoint ( trayType , 1 ) . Y + vResult [ 0 ] . OffsetY ;
double x2 = TrayPointManager . GetSlotPoint ( trayType , 16 ) . X + vResult [ 1 ] . OffsetX ;
double y2 = TrayPointManager . GetSlotPoint ( trayType , 16 ) . Y + vResult [ 1 ] . OffsetY ;
double x3 = TrayPointManager . GetSlotPoint ( trayType , 241 ) . X + vResult [ 2 ] . OffsetX ;
double y3 = TrayPointManager . GetSlotPoint ( trayType , 241 ) . Y + vResult [ 2 ] . OffsetY ;
double bigSpaceX = ( x2 - x1 ) / 15 ;
double smallSapceY = ( y2 - y1 ) / 15 ;
double bigSpaceY = ( y3 - y1 ) / 15 ;
double smallSpaceX = ( x3 - x1 ) / 15 ;
int index = 1 ;
for ( int row = 1 ; row < = 16 ; row + + )
//在这里先打印拍照结果
logInfo = JsonConvert . SerializeObject ( vr ) ;
MessageQueue . Instance . Insert ( logInfo ) ;
points . RemoveAt ( 0 ) ;
if ( points . Count > 0 )
{
for ( int col = 1 ; col < = 16 ; col + + )
{
double x = x1 + ( col - 1 ) * bigSpaceX + ( row - 1 ) * smallSpaceX ;
double y = y1 + ( row - 1 ) * bigSpaceY + ( col - 1 ) * smallSapceY ;
string insertSql = $"insert into trayrunpoints(trayid,recipename,trayname,slotindex,x,y) values(1,'{GlobalVar.CurRecipe}','{trayType}',{index},{x},{y})" ;
rowAffectNum = db . ExecuteNonQuery ( insertSql ) ;
index + + ;
}
step = EThreePointLocationFlowStep . 到 拍 照 位 ;
}
else
{
CalcTrayRunPoint ( trayType ) ;
TrayRunPointManager . LoadPoint ( ) ;
finished = true ;
}
TrayRunPointManager . LoadPoint ( ) ;
finished = true ;
//Msg.ShowInfo("三点定位完成");
//points = new List<int>() { 1, 16, 241 };
//step = EThreePointLocationFlowStep.到拍照位;
}
break ;
}
@ -176,5 +138,81 @@ namespace Rs.MotionPlat.Flow.NormalFlow
{
return "ThreePointLocation-" ;
}
/// <summary>
/// 生成三点定位数据
/// </summary>
/// <param name="trayType"></param>
private void CalcTrayRunPoint ( ETrayType trayType )
{
if ( false )
{
string deleteSql = $"delete from trayrunpoints where recipeName='{GlobalVar.CurRecipe}' and trayname='{trayType}'" ;
SqliteHelper db = new SqliteHelper ( ) ;
int rowAffectNum = db . ExecuteNonQuery ( deleteSql ) ;
double x1 = TrayPointManager . GetSlotPoint ( trayType , 1 ) . X + vResult [ 0 ] . OffsetX ;
double y1 = TrayPointManager . GetSlotPoint ( trayType , 1 ) . Y + vResult [ 0 ] . OffsetY ;
double x2 = TrayPointManager . GetSlotPoint ( trayType , 16 ) . X + vResult [ 1 ] . OffsetX ;
double y2 = TrayPointManager . GetSlotPoint ( trayType , 16 ) . Y + vResult [ 1 ] . OffsetY ;
double x3 = TrayPointManager . GetSlotPoint ( trayType , 241 ) . X + vResult [ 2 ] . OffsetX ;
double y3 = TrayPointManager . GetSlotPoint ( trayType , 241 ) . Y + vResult [ 2 ] . OffsetY ;
double bigSpaceX = ( x2 - x1 ) / 15 ;
double smallSapceY = ( y2 - y1 ) / 15 ;
double bigSpaceY = ( y3 - y1 ) / 15 ;
double smallSpaceX = ( x3 - x1 ) / 15 ;
int index = 1 ;
for ( int row = 1 ; row < = 16 ; row + + )
{
for ( int col = 1 ; col < = 16 ; col + + )
{
double x = x1 + ( col - 1 ) * bigSpaceX + ( row - 1 ) * smallSpaceX ;
double y = y1 + ( row - 1 ) * bigSpaceY + ( col - 1 ) * smallSapceY ;
string insertSql = $"insert into trayrunpoints(trayid,recipename,trayname,slotindex,x,y) values(1,'{GlobalVar.CurRecipe}','{trayType}',{index},{x},{y})" ;
rowAffectNum = db . ExecuteNonQuery ( insertSql ) ;
index + + ;
}
}
}
else
{
string deleteSql = $"delete from trayrunpoints where recipeName='{GlobalVar.CurRecipe}' and trayname='{trayType}'" ;
SqliteHelper db = new SqliteHelper ( ) ;
int rowAffectNum = db . ExecuteNonQuery ( deleteSql ) ;
double x1 = TrayPointManager . GetSlotPoint ( trayType , 1 ) . X + vResult [ 0 ] . OffsetX ;
double y1 = TrayPointManager . GetSlotPoint ( trayType , 1 ) . Y + vResult [ 0 ] . OffsetY ;
double x2 = TrayPointManager . GetSlotPoint ( trayType , 16 ) . X + vResult [ 1 ] . OffsetX ;
double y2 = TrayPointManager . GetSlotPoint ( trayType , 16 ) . Y + vResult [ 1 ] . OffsetY ;
double x3 = TrayPointManager . GetSlotPoint ( trayType , 241 ) . X + vResult [ 2 ] . OffsetX ;
double y3 = TrayPointManager . GetSlotPoint ( trayType , 241 ) . Y + vResult [ 2 ] . OffsetY ;
double bigSpaceX = ( x3 - x1 ) / 15 ;
double smallSpaceY = ( y3 - y1 ) / 15 ;
double bigSpaceY = ( y2 - y1 ) / 15 ;
double smallSpaceX = ( x2 - x1 ) / 15 ;
int index = 1 ;
for ( int row = 1 ; row < = 16 ; row + + )
{
for ( int col = 1 ; col < = 16 ; col + + )
{
double x = y1 + ( row - 1 ) * bigSpaceY + ( col - 1 ) * smallSpaceX ;
double y = x1 + ( col - 1 ) * bigSpaceX + ( row - 1 ) * smallSpaceY ;
string insertSql = $"insert into trayrunpoints(trayid,recipename,trayname,slotindex,x,y) values(1,'{GlobalVar.CurRecipe}','{trayType}',{index},{x},{y})" ;
rowAffectNum = db . ExecuteNonQuery ( insertSql ) ;
index + + ;
}
}
}
}
}
}