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.
123 lines
4.3 KiB
C#
123 lines
4.3 KiB
C#
using HalconDotNet;
|
|
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 DischargeModuleGoSafePosFlow: GoSafePosFlow
|
|
{
|
|
private static DischargeModuleGoSafePosFlow instance;
|
|
public static DischargeModuleGoSafePosFlow Instance
|
|
{
|
|
get
|
|
{
|
|
if (instance == null)
|
|
instance = new DischargeModuleGoSafePosFlow();
|
|
return instance;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 排料头回安全位
|
|
/// </summary>
|
|
public override void GoSafePostion(EExceptionSafePos ePos = EExceptionSafePos.Socket)
|
|
{
|
|
if (finished)
|
|
{
|
|
taskFinishedEvent.Reset();
|
|
finished = false;
|
|
}
|
|
else {
|
|
MessageQueue.Instance.Warn("检测到回安全位还未结束");
|
|
return;
|
|
}
|
|
step = EGoSafePosFlowStep.到安全位;
|
|
while (true && !finished)
|
|
{
|
|
if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop)
|
|
{
|
|
Thread.Sleep(10);
|
|
continue;
|
|
}
|
|
switch (step)
|
|
{
|
|
case EGoSafePosFlowStep.到安全位:
|
|
errCode = AxisControl.LoadX.MovePos(SysConfigParam.GetValue<double>("LoadXStartPos"), GlobalVar.WholeSpeed);
|
|
if (errCode == ErrorCode.Ok || GlobalVar.VirtualAxis)
|
|
{
|
|
errCode = AxisControl.LoadY.MovePos(SysConfigParam.GetValue<double>("LoadYStartPos"), GlobalVar.WholeSpeed);
|
|
if (errCode == ErrorCode.Ok || GlobalVar.VirtualAxis)
|
|
{
|
|
logInfo = GetClassName() + $"到安全位";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
if (GlobalVar.VirtualAxis)
|
|
{
|
|
Thread.Sleep(GlobalVar.VirtualAxisMoveTime);
|
|
}
|
|
step = EGoSafePosFlowStep.等待运动到安全位;
|
|
}
|
|
else
|
|
{
|
|
PromptMessageBox.ShowAxisAlarmDialog(AxisControl.LoadX, errCode);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
PromptMessageBox.ShowAxisAlarmDialog(AxisControl.LoadY, errCode);
|
|
}
|
|
|
|
break;
|
|
case EGoSafePosFlowStep.等待运动到安全位:
|
|
if (Ops.IsStop("LoadX", "LoadY") || GlobalVar.VirtualAxis)
|
|
{
|
|
logInfo = GetClassName() + $"已运动到安全位";
|
|
MessageQueue.Instance.Insert(logInfo);
|
|
finished = true;
|
|
taskFinishedEvent.Set();
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
Thread.Sleep(10);
|
|
}
|
|
//taskFinishedEvent.WaitOne();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 判断是否在安全位
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool IsInSafePostion()
|
|
{
|
|
double x = SysConfigParam.GetValue<double>("LoadXStartPos");
|
|
double y = SysConfigParam.GetValue<double>("LoadYStartPos");
|
|
if(Math.Abs(Ops.GetCurPosition(AxisControl.LoadX)-x)<0.1 && Math.Abs(Ops.GetCurPosition(AxisControl.LoadY) - y)<0.1)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
public string GetClassName()
|
|
{
|
|
return "DischargeModuleGoSafePosFlow-";
|
|
}
|
|
|
|
public void Wait()
|
|
{
|
|
taskFinishedEvent.WaitOne();
|
|
}
|
|
}
|
|
}
|