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 Rs.MotionPlat.Entitys.Trays;
|
|
using Rs.MotionPlat.Flow.Common;
|
|
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 EFiberWarningPressFlowStep
|
|
{
|
|
到测试放料位上方,
|
|
等待运动到测试放料位上方,
|
|
到测试放料位下方1,
|
|
等待运动到到测试放料位下方1,
|
|
到测试放料位下方2,
|
|
等待运动到到测试放料位下方2,
|
|
测试位下压完成抬起,
|
|
等待测试位下压完成抬起
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// 当光纤报警时,主动去压一次
|
|
/// </summary>
|
|
public class FiberWarningPressFlow
|
|
{
|
|
private static FiberWarningPressFlow instance;
|
|
public static FiberWarningPressFlow Instance
|
|
{
|
|
get
|
|
{
|
|
if (instance == null)
|
|
instance = new FiberWarningPressFlow();
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private string logInfo = string.Empty;
|
|
private EFiberWarningPressFlowStep step = EFiberWarningPressFlowStep.到测试放料位上方;
|
|
//private double targetPos = 0.0;
|
|
ErrorCode errCode = ErrorCode.Ok;
|
|
bool finished = true;
|
|
TargetPosition targetPosition = new TargetPosition();
|
|
AlarmEntity alarmEntity = null;
|
|
|
|
/// <summary>
|
|
/// 当出现光纤异常时,下嘴下压一次
|
|
/// </summary>
|
|
public void Press()
|
|
{
|
|
if (finished)
|
|
{
|
|
finished = false;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
step = EFiberWarningPressFlowStep.到测试放料位上方;
|
|
while (!finished)
|
|
{
|
|
if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop)
|
|
{
|
|
Thread.Sleep(10);
|
|
continue;
|
|
}
|
|
switch (step)
|
|
{
|
|
case EFiberWarningPressFlowStep.到测试放料位上方:
|
|
targetPosition.X = SysConfigParam.GetValue<double>("PressTakeX");
|
|
targetPosition.Y = SysConfigParam.GetValue<double>("PressTakeY");
|
|
errCode = AxisControl.TurnoverX.MovePos(targetPosition.X, GlobalVar.WholeSpeed);
|
|
if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis)
|
|
{
|
|
errCode = AxisControl.TurnoverY.MovePos(targetPosition.Y, GlobalVar.WholeSpeed);
|
|
if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis)
|
|
{
|
|
if (GlobalVar.VirtualAxis)
|
|
{
|
|
Thread.Sleep(GlobalVar.VirtualAxisMoveTime);
|
|
}
|
|
logInfo = GetClassName() + $"到测试放料位上方";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
step = EFiberWarningPressFlowStep.等待运动到测试放料位上方;
|
|
}
|
|
else
|
|
{
|
|
//PromptMessageBox.ShowAxisAlarmDialog(AxisControl.TurnoverY, errCode);
|
|
alarmEntity = AlarmCollection.Get(AlarmConstID.TurnoverY运动异常).Transform(errCode.ToString());
|
|
AlarmMessageBox.ShowDialog(alarmEntity, ETipButton.Ok, null);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//PromptMessageBox.ShowAxisAlarmDialog(AxisControl.TurnoverX, errCode);
|
|
alarmEntity = AlarmCollection.Get(AlarmConstID.TurnoverX运动异常).Transform(errCode.ToString());
|
|
AlarmMessageBox.ShowDialog(alarmEntity, ETipButton.Ok, null);
|
|
}
|
|
break;
|
|
case EFiberWarningPressFlowStep.等待运动到测试放料位上方:
|
|
if (Ops.IsStop(AxisControl.TurnoverX, AxisControl.TurnoverY) || GlobalVar.VirtualAxis)
|
|
{
|
|
if(AxisArrived.TurnoverXYIsInTargetPos(targetPosition.X,targetPosition.Y))
|
|
{
|
|
logInfo = GetClassName() + $"已运动到测试放料位上方";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
step = EFiberWarningPressFlowStep.到测试放料位下方1;
|
|
}
|
|
else
|
|
{
|
|
step = EFiberWarningPressFlowStep.到测试放料位上方;
|
|
}
|
|
}
|
|
break;
|
|
case EFiberWarningPressFlowStep.到测试放料位下方1:
|
|
targetPosition.TurnoverZ= SysConfigParam.GetValue<double>("PressDumpZ") + GlobalVar.SocketTrayDumpOneSpeedOffsetHeight;
|
|
errCode = AxisControl.TurnoverZ.MovePos(targetPosition.TurnoverZ, GlobalVar.WholeSpeed);
|
|
if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis)
|
|
{
|
|
if (GlobalVar.VirtualAxis)
|
|
{
|
|
Thread.Sleep(GlobalVar.VirtualAxisMoveTime);
|
|
}
|
|
logInfo = GetClassName() + $"到测试放料位下方1";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
step = EFiberWarningPressFlowStep.等待运动到到测试放料位下方1;
|
|
}
|
|
else
|
|
{
|
|
//PromptMessageBox.ShowAxisAlarmDialog(AxisControl.TurnoverZ, errCode);
|
|
alarmEntity = AlarmCollection.Get(AlarmConstID.TurnoverZ运动异常).Transform(errCode.ToString());
|
|
AlarmMessageBox.ShowDialog(alarmEntity, ETipButton.Ok, null);
|
|
}
|
|
break;
|
|
case EFiberWarningPressFlowStep.等待运动到到测试放料位下方1:
|
|
if (Ops.IsStop(AxisControl.TurnoverZ) || GlobalVar.VirtualAxis)
|
|
{
|
|
if(AxisArrived.TurnoverZIsInTargetPos(targetPosition.TurnoverZ))
|
|
{
|
|
logInfo = GetClassName() + $"已运动到到测试放料位下方1 TurnoverZ at:{Ops.GetCurPosition(AxisAlias.TurnoverZ)}";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
step = EFiberWarningPressFlowStep.到测试放料位下方2;
|
|
}
|
|
else
|
|
{
|
|
step = EFiberWarningPressFlowStep.到测试放料位下方1;
|
|
}
|
|
}
|
|
break;
|
|
case EFiberWarningPressFlowStep.到测试放料位下方2:
|
|
targetPosition.TurnoverZ = SysConfigParam.GetValue<double>("PressDumpZ");
|
|
errCode = AxisControl.TurnoverZ.MovePos(targetPosition.TurnoverZ, GlobalVar.SocketTrayDumpOneSpeed);
|
|
if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis)
|
|
{
|
|
if (GlobalVar.VirtualAxis)
|
|
{
|
|
Thread.Sleep(GlobalVar.VirtualAxisMoveTime);
|
|
}
|
|
logInfo = GetClassName() + $"到测试放料位下方2";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
step = EFiberWarningPressFlowStep.等待运动到到测试放料位下方2;
|
|
}
|
|
else
|
|
{
|
|
//PromptMessageBox.ShowAxisAlarmDialog(AxisControl.TurnoverZ, errCode);
|
|
alarmEntity = AlarmCollection.Get(AlarmConstID.TurnoverZ运动异常).Transform(errCode.ToString());
|
|
AlarmMessageBox.ShowDialog(alarmEntity, ETipButton.Ok, null);
|
|
}
|
|
break;
|
|
case EFiberWarningPressFlowStep.等待运动到到测试放料位下方2:
|
|
if (Ops.IsStop(AxisControl.TurnoverZ) || GlobalVar.VirtualAxis)
|
|
{
|
|
if(AxisArrived.TurnoverZIsInTargetPos(targetPosition.TurnoverZ))
|
|
{
|
|
logInfo = GetClassName() + $"已运动到测试放料位下方2";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
Thread.Sleep(500);
|
|
step = EFiberWarningPressFlowStep.测试位下压完成抬起;
|
|
}
|
|
}
|
|
break;
|
|
case EFiberWarningPressFlowStep.测试位下压完成抬起:
|
|
targetPosition.TurnoverZ = SysConfigParam.GetValue<double>("PressSafeZ");
|
|
errCode = AxisControl.TurnoverZ.MovePos(targetPosition.TurnoverZ, GlobalVar.WholeSpeed);
|
|
if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis)
|
|
{
|
|
if (GlobalVar.VirtualAxis)
|
|
{
|
|
Thread.Sleep(GlobalVar.VirtualAxisMoveTime);
|
|
}
|
|
logInfo = GetClassName() + $"测试位下压完成抬起";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
step = EFiberWarningPressFlowStep.等待测试位下压完成抬起;
|
|
}
|
|
else
|
|
{
|
|
//PromptMessageBox.ShowAxisAlarmDialog(AxisControl.TurnoverZ, errCode);
|
|
alarmEntity = AlarmCollection.Get(AlarmConstID.TurnoverZ运动异常).Transform(errCode.ToString());
|
|
AlarmMessageBox.ShowDialog(alarmEntity, ETipButton.Ok, null);
|
|
}
|
|
break;
|
|
case EFiberWarningPressFlowStep.等待测试位下压完成抬起:
|
|
if (Ops.IsStop(AxisControl.TurnoverZ) || GlobalVar.VirtualAxis)
|
|
{
|
|
if(AxisArrived.TurnoverZIsInTargetPos(targetPosition.TurnoverZ))
|
|
{
|
|
logInfo = GetClassName() + $"测试位下压完成抬起完成";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
finished = true;
|
|
}
|
|
else
|
|
{
|
|
step = EFiberWarningPressFlowStep.测试位下压完成抬起;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
private string GetClassName()
|
|
{
|
|
return "FiberWarningPressFlow-";
|
|
}
|
|
}
|
|
}
|