using Rs.Controls;
using Rs.Framework;
using Rs.Motion;
using Rs.MotionPlat.Commom;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Rs.MotionPlat.Flow.SafePosFlow
{
///
/// 周转模组回安全位
///
public class TransitModuleSafePosFlow: GoSafePosFlow
{
private TransitModuleSafePosFlow() { }
private static TransitModuleSafePosFlow instance;
public static TransitModuleSafePosFlow Instance
{
get
{
if (instance == null)
instance = new TransitModuleSafePosFlow();
return instance;
}
}
///
/// 排料头回安全位
///
public override void GoSafePostion(EExceptionSafePos ePos= EExceptionSafePos.Socket)
{
if (finished)
{
taskFinishedEvent.Reset();
finished = false;
}
else
{
MessageQueue.Instance.Warn("检测到回安全位还未完成");
return;
}
double targetPosX = 0.0;
double targetPosY = 0.0;
step = EGoSafePosFlowStep.到安全位;
while (true && !finished)
{
if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop)
{
Thread.Sleep(10);
continue;
}
switch (step)
{
case EGoSafePosFlowStep.到安全位:
switch (ePos)
{
case EExceptionSafePos.Socket:
targetPosX = SysConfigParam.GetValue("TurnoverTakeX");
targetPosY = SysConfigParam.GetValue("PressY");
break;
case EExceptionSafePos.SocketFrom9ToSixteen:
targetPosX = SysConfigParam.GetValue("Socket9_16ExceptionX");
//targetPosX = TrayPointManager.GetExceptiontTrayPoint(2).X;
targetPosY = SysConfigParam.GetValue("Socket9_16ExceptionY");
break;
case EExceptionSafePos.TransitNozzle:
targetPosX = GlobalVar.TransitNozzleExceptionSafePosX;
targetPosY = GlobalVar.TransitNozzleExceptionSafePosY;
break;
case EExceptionSafePos.TurnoverTray:
//targetPosX = GlobalVar.TransitModuleTurnoverTrayExceptionSafePosX;
//targetPosY = GlobalVar.TransitModuleTurnoverTrayExceptionSafePosY;
targetPosX = SysConfigParam.GetValue("TurnoverTakeX");
targetPosY = SysConfigParam.GetValue("PressY");
break;
default:
break;
}
errCode = AxisControl.TurnoverY.MovePos(targetPosY, GlobalVar.WholeSpeed);
if (errCode == ErrorCode.Ok || GlobalVar.VirtualAxis)
{
if (GlobalVar.VirtualAxis)
{
Thread.Sleep(GlobalVar.VirtualAxisMoveTime);
}
logInfo = GetClassName() + $"到安全位";
MessageQueue.Instance.Insert(logInfo);
step = EGoSafePosFlowStep.等待运动到安全位;
}
else
{
PromptMessageBox.ShowAxisAlarmDialog(AxisControl.TurnoverY, errCode);
}
break;
case EGoSafePosFlowStep.等待运动到安全位:
if (Ops.IsStop("TurnoverX", "TurnoverY") || GlobalVar.VirtualAxis)
{
logInfo = GetClassName()+ $"已运动到安全位";
MessageQueue.Instance.Insert(logInfo);
finished = true;
taskFinishedEvent.Set();
}
break;
default:
break;
}
Thread.Sleep(10);
}
}
public string GetClassName()
{
return this.GetType().Name + "-";
}
}
}