优化日志记录,和料仓下方取料延时

master
lhiven 1 year ago
parent 248847d446
commit a79838a581

@ -222,13 +222,13 @@ namespace Rs.MotionPlat.Flow
} }
break; break;
case EDischargeFlowStep.: case EDischargeFlowStep.:
ProductLocationFlow.Instance.Grab(takeSlotIndex, GetClassName()); ProductLocationFlow.Instance.Grab(takeSlotIndex);
ProductLocationResult[] results = OneGrabSixteenManager.Instance.GetResults(); ProductLocationResult[] results = OneGrabSixteenManager.Instance.GetResults();
if(results!=null) if(results!=null)
{ {
foreach (ProductLocationResult item in results) foreach (ProductLocationResult item in results)
{ {
if(item.Result!= EOneGrabSixteenResult.Ok) if(item.Result== EOneGrabSixteenResult.Slant)
{ {
//凡是定位失败的,需要定位重拍 //凡是定位失败的,需要定位重拍
ProductLocationResult vr = FixedGrabProductFlow.Instance.Grab(ETrayType.Grr, item.SlotIndex); ProductLocationResult vr = FixedGrabProductFlow.Instance.Grab(ETrayType.Grr, item.SlotIndex);
@ -269,7 +269,18 @@ namespace Rs.MotionPlat.Flow
//治具换料 //治具换料
case EDischargeFlowStep.: case EDischargeFlowStep.:
//先去第一个治具拍照位上方等待 //先去第一个治具拍照位上方等待
if(TestFixtureManager.Instance.GetTestFixture(lastFixtureIndex+1).Product==null)
{
targetPosition = FixtureManager.GetFixtureGrabPos(lastFixtureIndex + 1); targetPosition = FixtureManager.GetFixtureGrabPos(lastFixtureIndex + 1);
}
else
{
targetPosition = NozzleManager.GetNozzleToFixturePos(lastFixtureIndex + 1, NozzleManager.GetIdelNozzle().NozzleIndex);
targetPosition.X += TestFixtureManager.Instance.GetTestFixture(lastFixtureIndex + 1).PlaceProductOffsetX;
targetPosition.Y2 += TestFixtureManager.Instance.GetTestFixture(lastFixtureIndex + 1).PlaceProductOffsetY;
}
if(GroupAxisMove.XY1Y2MovePos(targetPosition, GlobalVar.WholeSpeed)) if(GroupAxisMove.XY1Y2MovePos(targetPosition, GlobalVar.WholeSpeed))
{ {
AxisPosPrint.PrintXY1Y2TargetPos("到治具放料缓冲位,", targetPosition, GetClassName()); AxisPosPrint.PrintXY1Y2TargetPos("到治具放料缓冲位,", targetPosition, GetClassName());
@ -351,7 +362,7 @@ namespace Rs.MotionPlat.Flow
else else
{ {
int num = TestFixtureManager.Instance.GetHaveProductFixtureList().Count(); int num = TestFixtureManager.Instance.GetHaveProductFixtureList().Count();
if(GlobalVar.Clear && ((num==0) ||(NozzleManager.GetIdelNozzle() == null))) if(GlobalVar.Clear && NozzleManager.GetToTestNozzle()==null && ((num==0) ||(NozzleManager.GetIdelNozzle() == null)))
{ {
flowStep = EDischargeFlowStep.; flowStep = EDischargeFlowStep.;
} }

@ -83,8 +83,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
targetPos.Y2 = sp.Y; targetPos.Y2 = sp.Y;
if (GroupAxisMove.XY1Y2MovePos(targetPos, GlobalVar.WholeSpeed)) if (GroupAxisMove.XY1Y2MovePos(targetPos, GlobalVar.WholeSpeed))
{ {
logInfo = $"到拍照位,tloadx:{targetPos.X},tloady1:{targetPos.Y1},tloady2:{targetPos.Y2}"; AxisPosPrint.PrintXY1Y2TargetPos("到拍照位,", targetPos, GetClassName());
MessageQueue.Instance.Insert(logInfo);
step = EThreePointLocationFlowStep.; step = EThreePointLocationFlowStep.;
} }
} }
@ -93,11 +92,10 @@ namespace Rs.MotionPlat.Flow.NormalFlow
case EThreePointLocationFlowStep.: case EThreePointLocationFlowStep.:
if (Ops.IsStop("LoadX", "LoadY1", "LoadY2") || GlobalVar.VirtualAxis) if (Ops.IsStop("LoadX", "LoadY1", "LoadY2") || GlobalVar.VirtualAxis)
{ {
PrintXY1Y2CurrentPos("轴XY1Y2已停止运动,"); AxisPosPrint.PrintXY1Y2CurrentPos("轴XY1Y2已停止运动,", GetClassName());
if (AxisArrived.LoadXY1Y2IsArrived(targetPos.X, targetPos.Y1, targetPos.Y2)) if (AxisArrived.LoadXY1Y2IsArrived(targetPos.X, targetPos.Y1, targetPos.Y2))
{ {
logInfo = $"已运动到拍照位,cloadx:{Ops.GetCurPosition(AxisControl.LoadX)},cloady1:{Ops.GetCurPosition(AxisControl.LoadY1)},cloady2:{Ops.GetCurPosition(AxisControl.LoadY2)}"; AxisPosPrint.PrintXY1Y2CurrentPos("已运动到拍照位,", GetClassName());
MessageQueue.Instance.Insert(logInfo);
step = EThreePointLocationFlowStep.; step = EThreePointLocationFlowStep.;
} }
else else
@ -127,7 +125,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow
{ {
vResult.Add(vr); vResult.Add(vr);
//在这里先打印拍照结果 //在这里先打印拍照结果
logInfo = JsonConvert.SerializeObject(vr); logInfo = GetClassName()+ JsonConvert.SerializeObject(vr);
MessageQueue.Instance.Insert(logInfo); MessageQueue.Instance.Insert(logInfo);
points.RemoveAt(0); points.RemoveAt(0);
if (points.Count > 0) if (points.Count > 0)
@ -158,11 +156,6 @@ namespace Rs.MotionPlat.Flow.NormalFlow
//}); //});
} }
private void PrintXY1Y2CurrentPos(string prefixLog)
{
LogHelper.Debug(GetClassName() + $"{prefixLog}当前位置:cx:{Ops.GetCurPosition(AxisControl.LoadX)},cy1:{Ops.GetCurPosition(AxisControl.LoadY1)},cy2:{Ops.GetCurPosition(AxisControl.LoadY2)}");
}
private string GetClassName() private string GetClassName()
{ {
return "ThreePointLocation-"; return "ThreePointLocation-";

@ -193,6 +193,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
case EFixturePlaceFlowStep.2: case EFixturePlaceFlowStep.2:
if (Ops.IsStop($"NozzleZ{curNozzle.NozzleIndex}")) if (Ops.IsStop($"NozzleZ{curNozzle.NozzleIndex}"))
{ {
Thread.Sleep(100);
logInfo = GetClassName() + $"已运动到治具{curFixture.Index}放料位下方2"; logInfo = GetClassName() + $"已运动到治具{curFixture.Index}放料位下方2";
MessageQueue.Instance.Insert(logInfo); MessageQueue.Instance.Insert(logInfo);
if (GlobalVar.RunSpace) if (GlobalVar.RunSpace)

@ -145,6 +145,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
case EFixtureTakeFlowStep.2: case EFixtureTakeFlowStep.2:
if (Ops.IsStop($"NozzleZ{curNozzle.NozzleIndex}")) if (Ops.IsStop($"NozzleZ{curNozzle.NozzleIndex}"))
{ {
Thread.Sleep(100);
logInfo = GetClassName() + $"已运动到治具{curFixture.Index}取料位下方2"; logInfo = GetClassName() + $"已运动到治具{curFixture.Index}取料位下方2";
MessageQueue.Instance.Insert(logInfo); MessageQueue.Instance.Insert(logInfo);
if (GlobalVar.RunSpace) if (GlobalVar.RunSpace)

@ -43,7 +43,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
} }
} }
public void Grab(int slotIndex,string className) public void Grab(int slotIndex)
{ {
if (finished) if (finished)
finished = false; finished = false;
@ -70,9 +70,9 @@ namespace Rs.MotionPlat.Flow.SubFlow
targetPosition.X = sp.X; targetPosition.X = sp.X;
targetPosition.Y1 = GlobalVar.StockSideY1; targetPosition.Y1 = GlobalVar.StockSideY1;
targetPosition.Y2 = sp.Y - 30; targetPosition.Y2 = sp.Y - 30;
if (GroupAxisMove.XY1Y2MovePos(targetPosition,GlobalVar.FlyCameraSpeed)) if (GroupAxisMove.XY1Y2MovePos(targetPosition,GlobalVar.WholeSpeed))
{ {
AxisPosPrint.PrintXY1Y2TargetPos("到料仓拍照位上方", targetPosition, className); AxisPosPrint.PrintXY1Y2TargetPos("到料仓拍照位上方", targetPosition, GetClassName());
flowStep = EProductLocationFlowStep.; flowStep = EProductLocationFlowStep.;
} }
} }
@ -81,7 +81,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
case EProductLocationFlowStep.: case EProductLocationFlowStep.:
if (Ops.IsStop("LoadX", "LoadY1", "LoadY2")) if (Ops.IsStop("LoadX", "LoadY1", "LoadY2"))
{ {
AxisPosPrint.PrintXY1Y2CurrentPos("轴loadx,loady1,loady2已停止运动,",className); AxisPosPrint.PrintXY1Y2CurrentPos("轴loadx,loady1,loady2已停止运动,", GetClassName());
if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2)) if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2))
{ {
SlotPoint sp = TrayPointManager.GetSlotPoint(ETrayType.Input, grabStartSlot.Index); SlotPoint sp = TrayPointManager.GetSlotPoint(ETrayType.Input, grabStartSlot.Index);
@ -92,12 +92,12 @@ namespace Rs.MotionPlat.Flow.SubFlow
triggerPos[i] = sp.Y + (i * 5); triggerPos[i] = sp.Y + (i * 5);
} }
AxisControl.LoadY2.SetPosCompare(1, triggerPos); AxisControl.LoadY2.SetPosCompare(1, triggerPos);
AxisPosPrint.PrintXY1Y2CurrentPos("已运动到料仓拍照位上方", className); AxisPosPrint.PrintXY1Y2CurrentPos("已运动到料仓拍照位上方", GetClassName());
flowStep = EProductLocationFlowStep.; flowStep = EProductLocationFlowStep.;
} }
else else
{ {
logInfo = $"{className} 轴不在目标位置,重新运动一次"; logInfo = $"{GetClassName()} 轴不在目标位置,重新运动一次";
MessageQueue.Instance.Warn(logInfo); MessageQueue.Instance.Warn(logInfo);
flowStep = EProductLocationFlowStep.; flowStep = EProductLocationFlowStep.;
} }
@ -115,7 +115,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
targetPosition.Y2 = sp.Y + 2; targetPosition.Y2 = sp.Y + 2;
if (GroupAxisMove.XY1Y2MovePos(targetPosition,GlobalVar.FlyCameraSpeed)) if (GroupAxisMove.XY1Y2MovePos(targetPosition,GlobalVar.FlyCameraSpeed))
{ {
AxisPosPrint.PrintXY1Y2TargetPos("到料仓拍照结束位,", targetPosition, className); AxisPosPrint.PrintXY1Y2TargetPos("到料仓拍照结束位,", targetPosition, GetClassName());
flowStep = EProductLocationFlowStep.; flowStep = EProductLocationFlowStep.;
} }
} }
@ -124,15 +124,15 @@ namespace Rs.MotionPlat.Flow.SubFlow
case EProductLocationFlowStep.: case EProductLocationFlowStep.:
if (Ops.IsStop("LoadX", "LoadY1", "LoadY2")) if (Ops.IsStop("LoadX", "LoadY1", "LoadY2"))
{ {
AxisPosPrint.PrintXY1Y2CurrentPos("轴loadx,loady1,loady2已停止运动,",className); AxisPosPrint.PrintXY1Y2CurrentPos("轴loadx,loady1,loady2已停止运动,", GetClassName());
if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2)) if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2))
{ {
AxisPosPrint.PrintXY1Y2CurrentPos("已运动到料仓拍照结束位,", className); AxisPosPrint.PrintXY1Y2CurrentPos("已运动到料仓拍照结束位,", GetClassName());
flowStep = EProductLocationFlowStep.; flowStep = EProductLocationFlowStep.;
} }
else else
{ {
logInfo = $"{className} 轴不在目标位置,重新运动一次"; logInfo = $"{GetClassName()} 轴不在目标位置,重新运动一次";
MessageQueue.Instance.Warn(logInfo); MessageQueue.Instance.Warn(logInfo);
flowStep = EProductLocationFlowStep.; flowStep = EProductLocationFlowStep.;
} }
@ -154,5 +154,10 @@ namespace Rs.MotionPlat.Flow.SubFlow
} }
} }
} }
private string GetClassName()
{
return "ProductLocationFlow-";
}
} }
} }

@ -129,7 +129,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
case EStockTakeFlowStep.: case EStockTakeFlowStep.:
if (Ops.IsStop($"NozzleZ{curNozzle.NozzleIndex}")) if (Ops.IsStop($"NozzleZ{curNozzle.NozzleIndex}"))
{ {
//Thread.Sleep(5000); Thread.Sleep(200);
logInfo = $"{GetClassName()} 已运动到料仓取料位下方"; logInfo = $"{GetClassName()} 已运动到料仓取料位下方";
MessageQueue.Instance.Insert(logInfo); MessageQueue.Instance.Insert(logInfo);
if (!GlobalVar.RunSpace) if (!GlobalVar.RunSpace)
@ -164,7 +164,7 @@ namespace Rs.MotionPlat.Flow.SubFlow
//curNozzle.Status = ENozzleStatus.ToUnload; //curNozzle.Status = ENozzleStatus.ToUnload;
GlobalTray.NozzleTray.ChangeStatus(curNozzle.NozzleIndex, ESlotStatus.Have); GlobalTray.NozzleTray.ChangeStatus(curNozzle.NozzleIndex, ESlotStatus.Have);
GlobalTray.InputTray.ChangeStatus(waitTakeProductSlot.Index, ESlotStatus.NotHave); GlobalTray.InputTray.ChangeStatus(waitTakeProductSlot.Index, ESlotStatus.NotHave);
logInfo = $"{GetClassName()} from r{waitTakeProductSlot.Row}c{waitTakeProductSlot.Column} 产品:{curNozzle.Product.SN}被吸嘴{curNozzle.NozzleIndex}取料完成,"; logInfo = $"{GetClassName()} from r{waitTakeProductSlot.Row+1}c{waitTakeProductSlot.Column+1} 穴位索引:{waitTakeProductSlot.Index} 产品:{curNozzle.Product.SN}被吸嘴{curNozzle.NozzleIndex}取料完成,";
MessageQueue.Instance.Insert(logInfo); MessageQueue.Instance.Insert(logInfo);
//flowStep = EStockTakeFlowStep.判断是否需要从料仓取料; //flowStep = EStockTakeFlowStep.判断是否需要从料仓取料;
finished = true; finished = true;

@ -36,10 +36,10 @@ namespace Rs.MotionPlat.Vision
else else
{ {
data = Encoding.ASCII.GetString(reciveBuffer.ToArray()); data = Encoding.ASCII.GetString(reciveBuffer.ToArray());
MessageQueue.Instance.Insert(data); //MessageQueue.Instance.Insert(data);
if (data == "M,0") if (data == "M,0")
{ {
MessageQueue.Instance.Insert("视觉收到拍照指令"); //MessageQueue.Instance.Insert("视觉收到拍照指令");
} }
else if(data=="C,0") else if(data=="C,0")
{ {
@ -176,6 +176,7 @@ namespace Rs.MotionPlat.Vision
reciveData = true; reciveData = true;
if (len > 0) if (len > 0)
{ {
MessageQueue.Instance.Insert($" <<< M;");
if (visionGrabEvent.WaitOne(timeout)) if (visionGrabEvent.WaitOne(timeout))
{ {
reciveData = false; reciveData = false;

Loading…
Cancel
Save