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.
250 lines
12 KiB
C#
250 lines
12 KiB
C#
using Rs.Controls;
|
|
using Rs.Framework;
|
|
using Rs.MotionPlat.Commom;
|
|
using Rs.MotionPlat.Entitys;
|
|
using Rs.MotionPlat.Flow.Common;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Rs.MotionPlat.Flow.SubFlow
|
|
{
|
|
enum EFixtureTakeFlowStep
|
|
{
|
|
待触发,
|
|
到治具取料位上方,
|
|
等待到治具取料位上方,
|
|
到治具取料位下方1,
|
|
等待到治具取料位下方1,
|
|
到治具取料位下方2,
|
|
等待到治具取料位下方2,
|
|
治具取料打开真空吸,
|
|
治具取料松开治具夹爪,
|
|
治具取料完成抬起1,
|
|
等待治具取料完成抬起1,
|
|
治具取料完成抬起2,
|
|
等待治具取料完成抬起2,
|
|
治具取料完成真空检测,
|
|
}
|
|
public class FixtureTakeFlow
|
|
{
|
|
bool finished = true;
|
|
EFixtureTakeFlowStep flowStep = EFixtureTakeFlowStep.待触发;
|
|
public FixtureTakeFlow()
|
|
{
|
|
|
|
}
|
|
|
|
private static FixtureTakeFlow instance;
|
|
public static FixtureTakeFlow Instance
|
|
{
|
|
get
|
|
{
|
|
if (instance == null)
|
|
instance = new FixtureTakeFlow();
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
public string GetCurStep()
|
|
{
|
|
return flowStep.ToString();
|
|
}
|
|
|
|
AlarmEntity alarmEntity = new AlarmEntity();
|
|
public void Take(int fixtureIndex,int nozzleIndex=-1,bool btest=false)
|
|
{
|
|
if (finished)
|
|
finished = false;
|
|
else
|
|
return;
|
|
flowStep = EFixtureTakeFlowStep.待触发;
|
|
string logInfo = string.Empty;
|
|
TargetPosition targetPosition = new TargetPosition();
|
|
TestFixture curFixture = TestFixtureManager.Instance.GetTestFixture(fixtureIndex);
|
|
Nozzle curNozzle = null;
|
|
|
|
while (!finished)
|
|
{
|
|
if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop)
|
|
{
|
|
Thread.Sleep(10);
|
|
continue;
|
|
}
|
|
switch (flowStep)
|
|
{
|
|
case EFixtureTakeFlowStep.待触发:
|
|
flowStep = EFixtureTakeFlowStep.到治具取料位上方;
|
|
break;
|
|
case EFixtureTakeFlowStep.到治具取料位上方:
|
|
//先找出要放的吸嘴
|
|
if(nozzleIndex==-1)
|
|
{
|
|
curNozzle = NozzleManager.GetIdelNozzle();
|
|
}
|
|
else
|
|
{
|
|
curNozzle = NozzleManager.GetNozzle(nozzleIndex);
|
|
}
|
|
if (curNozzle != null)
|
|
{
|
|
targetPosition = NozzleManager.GetNozzleToFixturePos(curFixture.Index, curNozzle.NozzleIndex);
|
|
targetPosition.X += curFixture.PlaceProductOffsetX;
|
|
targetPosition.Y2 += curFixture.PlaceProductOffsetY;
|
|
if (GroupAxisMove.XY1Y2MovePos(targetPosition, GlobalVar.WholeSpeed))
|
|
{
|
|
AxisPosPrint.PrintXY1Y2TargetPos($"到治具{curFixture.Index}取料位上方", targetPosition, GetClassName());
|
|
flowStep = EFixtureTakeFlowStep.等待到治具取料位上方;
|
|
}
|
|
}
|
|
break;
|
|
case EFixtureTakeFlowStep.等待到治具取料位上方:
|
|
if (Ops.IsStop("LoadX", "LoadY1", "LoadY2"))
|
|
{
|
|
AxisPosPrint.PrintXY1Y2CurrentPos("轴loadx,loady1,loady2已停止运动,",GetClassName());
|
|
if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2))
|
|
{
|
|
AxisPosPrint.PrintXY1Y2CurrentPos($"已运动到治具{curFixture.Index}取料位上方,", GetClassName());
|
|
flowStep = EFixtureTakeFlowStep.到治具取料位下方1;
|
|
}
|
|
else
|
|
{
|
|
flowStep = EFixtureTakeFlowStep.到治具取料位上方;
|
|
}
|
|
}
|
|
break;
|
|
case EFixtureTakeFlowStep.到治具取料位下方1:
|
|
targetPosition.NozzleZ = NozzleManager.GetFixtureTakeProductPos(curFixture.Index, curNozzle.NozzleIndex);
|
|
if (NozzleManager.Go(curNozzle, targetPosition.NozzleZ, GlobalVar.WholeSpeed))
|
|
{
|
|
logInfo = GetClassName() + $"到治具{curFixture.Index}取料位下方1";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
flowStep = EFixtureTakeFlowStep.等待到治具取料位下方1;
|
|
}
|
|
break;
|
|
case EFixtureTakeFlowStep.等待到治具取料位下方1:
|
|
if (Ops.IsStop($"NozzleZ{curNozzle.NozzleIndex}"))
|
|
{
|
|
logInfo = GetClassName() + $"已运动到治具{curFixture.Index}取料位下方1";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
flowStep = EFixtureTakeFlowStep.到治具取料位下方2;
|
|
}
|
|
break;
|
|
case EFixtureTakeFlowStep.到治具取料位下方2:
|
|
targetPosition.NozzleZ = NozzleManager.GetFixtureTakeProductPos(curFixture.Index, curNozzle.NozzleIndex);
|
|
if (NozzleManager.Go(curNozzle, targetPosition.NozzleZ, GlobalVar.WholeSpeed))
|
|
{
|
|
logInfo = GetClassName() + $"到治具{curFixture.Index}取料位下方2";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
flowStep = EFixtureTakeFlowStep.等待到治具取料位下方2;
|
|
}
|
|
break;
|
|
case EFixtureTakeFlowStep.等待到治具取料位下方2:
|
|
if (Ops.IsStop($"NozzleZ{curNozzle.NozzleIndex}"))
|
|
{
|
|
Thread.Sleep(100);
|
|
logInfo = GetClassName() + $"已运动到治具{curFixture.Index}取料位下方2";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
if (GlobalVar.RunSpace)
|
|
{
|
|
flowStep = EFixtureTakeFlowStep.治具取料完成抬起1;
|
|
}
|
|
else
|
|
{
|
|
//打开真空吸
|
|
curNozzle.VacSuction(EIoOperate.Open, GetClassName());
|
|
//松开夹头
|
|
curFixture.ColletOff(GetClassName());
|
|
flowStep = EFixtureTakeFlowStep.治具取料完成抬起1;
|
|
}
|
|
}
|
|
break;
|
|
case EFixtureTakeFlowStep.治具取料完成抬起1:
|
|
if (NozzleManager.GotoSafePos(curNozzle.NozzleIndex))
|
|
{
|
|
logInfo = GetClassName() + $"治具{curFixture.Index}取料完成抬起1";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
flowStep = EFixtureTakeFlowStep.等待治具取料完成抬起1;
|
|
}
|
|
break;
|
|
case EFixtureTakeFlowStep.等待治具取料完成抬起1:
|
|
if (Ops.IsStop($"NozzleZ{curNozzle.NozzleIndex}"))
|
|
{
|
|
logInfo = GetClassName() + $"治具{curFixture.Index}取料完成已抬起1";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
flowStep = EFixtureTakeFlowStep.治具取料完成抬起2;
|
|
}
|
|
break;
|
|
case EFixtureTakeFlowStep.治具取料完成抬起2:
|
|
if (NozzleManager.GotoSafePos(curNozzle.NozzleIndex))
|
|
{
|
|
logInfo = GetClassName() + $"治具{curFixture.Index}取料完成抬起2";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
flowStep = EFixtureTakeFlowStep.等待治具取料完成抬起2;
|
|
}
|
|
else
|
|
{
|
|
Msg.ShowError($"轴NozzleZ{curNozzle.NozzleIndex}运动异常");
|
|
}
|
|
break;
|
|
case EFixtureTakeFlowStep.等待治具取料完成抬起2:
|
|
if (Ops.IsStop($"NozzleZ{curNozzle.NozzleIndex}"))
|
|
{
|
|
logInfo = GetClassName() + $"治具{curFixture.Index}取料完成已抬起2";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
flowStep = EFixtureTakeFlowStep.治具取料完成真空检测;
|
|
}
|
|
break;
|
|
case EFixtureTakeFlowStep.治具取料完成真空检测:
|
|
if (curNozzle.HasProduct() || GlobalVar.RunSpace)
|
|
{
|
|
if(btest)
|
|
{
|
|
finished = true;
|
|
flowStep = EFixtureTakeFlowStep.待触发;
|
|
}
|
|
else
|
|
{
|
|
logInfo = $"{GetClassName()}治具{curFixture.Index}中产品SN:{curFixture.Product.SN}被吸嘴{curNozzle.NozzleIndex}取出";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
curNozzle.Product = curFixture.Product;
|
|
if (curFixture.Product.Result == "PASS" || curFixture.Product.TestNum == 3)
|
|
{
|
|
curNozzle.Status = ENozzleStatus.ToUnload;
|
|
}
|
|
else
|
|
{
|
|
curNozzle.Status = ENozzleStatus.ToTest;
|
|
}
|
|
curFixture.Clear();
|
|
GlobalTray.NozzleTray.ChangeStatus(curNozzle.NozzleIndex, ESlotStatus.Have);
|
|
finished = true;
|
|
flowStep = EFixtureTakeFlowStep.待触发;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
alarmEntity = AlarmCollection.Get(AlarmConstID.治具取料失败真空报警).Transform(curNozzle.NozzleIndex, curFixture.Index);
|
|
Msgbox.ShowDialog(alarmEntity, EButtonType.Recheck, true);
|
|
//Msgbox.ShowTipDialog(EButtonType.Recheck, $"吸嘴{curNozzle.NozzleIndex}从治具{curFixture.Index}取料时真空检测异常,请处理","vac error",true);
|
|
}
|
|
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
Thread.Sleep(5);
|
|
}
|
|
}
|
|
|
|
string GetClassName()
|
|
{
|
|
return $"{nameof(FixtureTakeFlow)}-";
|
|
}
|
|
}
|
|
}
|