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.
235 lines
12 KiB
C#
235 lines
12 KiB
C#
using Rs.Controls;
|
|
using Rs.Framework;
|
|
using Rs.Motion;
|
|
using Rs.MotionPlat.Commom;
|
|
using Rs.MotionPlat.Entitys;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using static Rs.MotionPlat.Commom.SchedulingMessageBox;
|
|
|
|
namespace Rs.MotionPlat.Flow.SubFlow
|
|
{
|
|
enum EDischargeDumpFlowStep
|
|
{
|
|
到放料位下方,
|
|
等待到放料位下方,
|
|
到放料关破真空位,
|
|
等待到放料关破真空位,
|
|
周转盘放料位真空检测,
|
|
放料完成抬起,
|
|
等待放料完成抬起
|
|
}
|
|
/// <summary>
|
|
/// 排料头取料失败后把产品重新放回穴位流程
|
|
/// </summary>
|
|
public class DischargeDumpFlow
|
|
{
|
|
private static DischargeDumpFlow instance;
|
|
public static DischargeDumpFlow Instance
|
|
{
|
|
get
|
|
{
|
|
if(instance==null)
|
|
instance = new DischargeDumpFlow();
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private string logInfo = string.Empty;
|
|
private EDischargeDumpFlowStep step = EDischargeDumpFlowStep.到放料位下方;
|
|
//private double targetPos = 0.0;
|
|
ErrorCode errCode = ErrorCode.Ok;
|
|
bool finished = true;
|
|
AlarmEntity alarmEntity = null;
|
|
TargetPosition targetPosition = new TargetPosition();
|
|
|
|
public void Start(TurnoverType trayType, int nozzleIndex,int toIndex)
|
|
{
|
|
if(finished)
|
|
{
|
|
finished= false;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
step = EDischargeDumpFlowStep.到放料位下方;
|
|
while (!finished)
|
|
{
|
|
if (MachineManage.Instance.MachineStatus== EMachineStatus.Stop)
|
|
{
|
|
Thread.Sleep(10);
|
|
continue;
|
|
}
|
|
switch (step)
|
|
{
|
|
case EDischargeDumpFlowStep.到放料位下方:
|
|
logInfo = GetClassName()+$"{nozzleIndex}号排料吸嘴到放料位下方";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
if (trayType == TurnoverType.Turnover)
|
|
{
|
|
///*打开周转盘真空吸*/
|
|
VacManager.TurnoverTrayVacSuction(EVacOperator.Open, false, toIndex + 1);
|
|
targetPosition.Z = SysConfigParam.GetValue<double>($"TurnoverNozzle{nozzleIndex}TakeHeight");
|
|
}
|
|
else
|
|
{
|
|
targetPosition.Z = SysConfigParam.GetValue<double>($"TrayNozzle{nozzleIndex}TakeHeight") + 1;
|
|
}
|
|
errCode = AxisControl.GetAxis($"NozzleZ{nozzleIndex}").MovePos(targetPosition.Z, GlobalVar.WholeSpeed);
|
|
if (errCode == ErrorCode.Ok || GlobalVar.VirtualAxis)
|
|
{
|
|
VirtualAxisSleep();
|
|
step = EDischargeDumpFlowStep.等待到放料位下方;
|
|
}
|
|
else
|
|
{
|
|
alarmEntity = AlarmCollection.Get($"NozzleZ{nozzleIndex}运动异常").Transform(errCode.ToString());
|
|
AlarmMessageBox.ShowDialog(alarmEntity, ETipButton.Ok, null);
|
|
//PromptMessageBox.ShowAxisAlarmDialog($"NozzleZ{nozzleIndex}", errCode);
|
|
}
|
|
break;
|
|
case EDischargeDumpFlowStep.等待到放料位下方:
|
|
if (Ops.IsStop($"NozzleZ{nozzleIndex}") || GlobalVar.VirtualAxis)
|
|
{
|
|
logInfo = GetClassName() + $"{nozzleIndex}号排料吸嘴已运动到放料位下方";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
if (trayType == TurnoverType.Turnover)
|
|
{
|
|
///*打开周转盘真空吸*/
|
|
//logInfo = GetClassName() + $"打开周转盘{toIndex + 1}号穴位真空吸";
|
|
//MessageQueue.Instance.Insert(logInfo);
|
|
//Ops.On($"周转盘{toIndex + 1}号穴位真空吸");
|
|
//Thread.Sleep(GlobalVar.TurnoverTrayOpenVacSuctionDelaytime);
|
|
/*关闭排料吸嘴真空吸*/
|
|
//logInfo = GetClassName() + $"关闭{nozzleIndex}号排料吸嘴真空吸";
|
|
//MessageQueue.Instance.Insert(logInfo);
|
|
//Ops.Off($"{nozzleIndex}号吸嘴真空吸电磁阀");//关闭真空
|
|
//Thread.Sleep(GlobalVar.LoadNozzleCloseVacSuctionDelaytime);
|
|
VacManager.DischargeVacSuction(EVacOperator.Close, true, nozzleIndex);
|
|
|
|
/*打开排料吸嘴真空破*/
|
|
//logInfo = GetClassName() + $"打开{nozzleIndex}号排料吸嘴真空破";
|
|
//MessageQueue.Instance.Insert(logInfo);
|
|
//Ops.On($"{nozzleIndex}号吸嘴真空破电磁阀");
|
|
//Thread.Sleep(GlobalVar.LoadNozzleOpenVacBreakDelaytime);
|
|
VacManager.DischargeVacBreak(EVacOperator.Open, true, nozzleIndex);
|
|
/*关闭排料吸嘴真空破*/
|
|
VacManager.DischargeVacBreak(EVacOperator.Close, false, nozzleIndex);
|
|
step = EDischargeDumpFlowStep.放料完成抬起;
|
|
}
|
|
else
|
|
{
|
|
/*关闭排料吸嘴真空吸*/
|
|
//logInfo = GetClassName() + $"关闭{nozzleIndex}号排料吸嘴真空吸";
|
|
//MessageQueue.Instance.Insert(logInfo);
|
|
//Ops.Off($"{nozzleIndex}号吸嘴真空吸电磁阀");
|
|
//Thread.Sleep(GlobalVar.LoadNozzleCloseVacSuctionDelaytime);
|
|
VacManager.DischargeVacSuction(EVacOperator.Close, true, nozzleIndex);
|
|
/*关闭排料吸嘴真空吸*/
|
|
//logInfo = GetClassName() + $"打开{nozzleIndex}号排料吸嘴真空破";
|
|
//MessageQueue.Instance.Insert(logInfo);
|
|
//Ops.On($"{nozzleIndex}号吸嘴真空破电磁阀");
|
|
//Thread.Sleep(GlobalVar.LoadNozzleOpenVacBreakDelaytime);
|
|
VacManager.DischargeVacBreak(EVacOperator.Open, true, nozzleIndex);
|
|
/*关闭排料吸嘴真空吸*/
|
|
//logInfo = GetClassName() + $"关闭{nozzleIndex}号排料吸嘴真空破";
|
|
//MessageQueue.Instance.Insert(logInfo);
|
|
//Ops.Off($"{nozzleIndex}号吸嘴真空破电磁阀");
|
|
//Thread.Sleep(GlobalVar.LoadNozzleCloseVacBreakDelaytime);
|
|
VacManager.DischargeVacBreak(EVacOperator.Close, false, nozzleIndex);
|
|
step = EDischargeDumpFlowStep.放料完成抬起;
|
|
}
|
|
}
|
|
break;
|
|
//case EDischargeDumpFlowStep.到放料关破真空位:
|
|
// targetPos = SysConfigParam.GetValue<double>($"TurnoverNozzle{nozzleIndex}TakeHeight");
|
|
// errCode = AxisControl.GetAxis($"NozzleZ{nozzleIndex}").MovePos(targetPos + 1, GlobalVar.WholeSpeed);
|
|
// if (errCode == ErrorCode.Ok || GlobalVar.VirtualAxis)
|
|
// {
|
|
// logInfo = GetClassName() + $"{nozzleIndex}号排料吸嘴周转盘放料完成,准备微微抬起";
|
|
// MessageQueue.Instance.Insert(logInfo);
|
|
// step = EDischargeDumpFlowStep.等待到放料关破真空位;
|
|
// }
|
|
// else
|
|
// {
|
|
// MsgBox.ShowAxisAlarmDialog($"NozzleZ{nozzleIndex}", errCode);
|
|
// }
|
|
// break;
|
|
//case EDischargeDumpFlowStep.等待到放料关破真空位:
|
|
// if (Ops.IsStop($"NozzleZ{nozzleIndex}") || GlobalVar.VirtualAxis)
|
|
// {
|
|
// /*关闭排料吸嘴真空破*/
|
|
// //Ops.Off($"{nozzleIndex}号吸嘴真空破电磁阀");
|
|
// //Thread.Sleep(GlobalVar.LoadNozzleCloseVacBreakDelaytime);
|
|
// //logInfo = GetClassName() + $"{nozzleIndex}号排料吸嘴微微抬起后关闭破真空";
|
|
// //MessageQueue.Instance.Insert(logInfo);
|
|
// VacManager.DischargeVacBreak(EVacOperator.Close, false, nozzleIndex);
|
|
// step = EDischargeDumpFlowStep.放料完成抬起;
|
|
// }
|
|
// break;
|
|
case EDischargeDumpFlowStep.放料完成抬起:
|
|
errCode = AxisControl.GetAxis($"NozzleZ{nozzleIndex}").MovePos(0, GlobalVar.WholeSpeed);
|
|
if (errCode == ErrorCode.Ok || GlobalVar.VirtualAxis)
|
|
{
|
|
if (GlobalVar.VirtualAxis)
|
|
{
|
|
Thread.Sleep(GlobalVar.VirtualAxisMoveTime);
|
|
}
|
|
logInfo = GetClassName() + $"{nozzleIndex}号排料吸嘴放料完成抬起";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
step = EDischargeDumpFlowStep.等待放料完成抬起;
|
|
}
|
|
else
|
|
{
|
|
//PromptMessageBox.ShowAxisAlarmDialog($"NozzleZ{nozzleIndex}", errCode);
|
|
alarmEntity = AlarmCollection.Get($"NozzleZ{nozzleIndex}运动异常").Transform(errCode.ToString());
|
|
AlarmMessageBox.ShowDialog(alarmEntity, ETipButton.Ok, null);
|
|
}
|
|
break;
|
|
case EDischargeDumpFlowStep.等待放料完成抬起:
|
|
if (Ops.IsStop($"NozzleZ{nozzleIndex}") || GlobalVar.VirtualAxis)
|
|
{
|
|
if(trayType== TurnoverType.Turnover)
|
|
{
|
|
//在这里检测一下周转盘的真空
|
|
if(Ops.IsOn($"周转盘{toIndex + 1}号穴位真空吸检测"))
|
|
{
|
|
LogHelper.Debug(GetClassName()+$"周转盘{toIndex + 1}号穴位真空吸检测 OK");
|
|
}
|
|
else
|
|
{
|
|
LogHelper.Debug(GetClassName()+$"周转盘{toIndex + 1}号穴位真空吸检测 NG");
|
|
}
|
|
}
|
|
logInfo = GetClassName()+ $"{nozzleIndex}号排料吸嘴放料完成已抬起";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
finished = true;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 如果是虚拟轴,则模拟等待一下
|
|
/// </summary>
|
|
private void VirtualAxisSleep()
|
|
{
|
|
if (GlobalVar.VirtualAxis)
|
|
{
|
|
Thread.Sleep(GlobalVar.VirtualAxisMoveTime);
|
|
}
|
|
}
|
|
|
|
public string GetClassName()
|
|
{
|
|
return "DischargeDumpFlow-";
|
|
}
|
|
}
|
|
}
|