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.

120 lines
4.8 KiB
C#

11 months ago
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
{
/// <summary>
/// 周转模组回安全位
/// </summary>
public class TransitModuleSafePosFlow: GoSafePosFlow
{
private TransitModuleSafePosFlow() { }
private static TransitModuleSafePosFlow instance;
public static TransitModuleSafePosFlow Instance
{
get
{
if (instance == null)
instance = new TransitModuleSafePosFlow();
return instance;
}
}
/// <summary>
/// 排料头回安全位
/// </summary>
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<double>("TurnoverTakeX");
targetPosY = SysConfigParam.GetValue<double>("PressY");
break;
case EExceptionSafePos.SocketFrom9ToSixteen:
targetPosX = SysConfigParam.GetValue<double>("Socket9_16ExceptionX");
//targetPosX = TrayPointManager.GetExceptiontTrayPoint(2).X;
targetPosY = SysConfigParam.GetValue<double>("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<double>("TurnoverTakeX");
targetPosY = SysConfigParam.GetValue<double>("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 + "-";
}
}
}