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.

110 lines
3.2 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Rs.Controls;
using Rs.Framework;
using Rs.MotionPlat.Commom;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rs.MotionPlat.Flow
{
public class SafeControl
{
private SafeControl() { }
private static SafeControl instance;
public static SafeControl Instance
{
get
{
if (instance == null)
{
instance = new SafeControl();
}
return instance;
}
}
public void Init()
{
if (AxisControl.LoadX != null)
AxisControl.LoadX.FunSafeCheck += LoadX_FunSafeCheck;
if (AxisControl.LoadY != null)
AxisControl.LoadY.FunSafeCheck += LoadY_FunSafeCheck;
if (AxisControl.TurnoverY != null)
AxisControl.TurnoverY.FunSafeCheck += TurnoverY_FunSafeCheck;
}
private bool TurnoverY_FunSafeCheck()
{
if (SysConfigParam.GetValue<bool>("CheckSafeEnable"))
{
AxisControl.PressZ.GetOrgStatus(out bool bOrg);
if (!bOrg)
return false;
AxisControl.TurnoverZ.GetOrgStatus(out bOrg);
if (!bOrg)
return false;
}
return true;
}
private bool LoadY_FunSafeCheck()
{
if(SysConfigParam.GetValue<bool>("CheckSafeEnable"))
{
bool bOnOrg = false;
for (int i = 1; i < 3; i++)
{
AxisControl.GetAxis($"NozzleZ{i}").GetOrgStatus(out bOnOrg);
if (!bOnOrg)
{
MessageQueue.Instance.Warn($"NozzleZ{i} is hasn't org signal");
return false;
}
}
}
return true;
}
private bool LoadX_FunSafeCheck()
{
if (SysConfigParam.GetValue<bool>("CheckSafeEnable"))
{
bool bOnOrg = false;
for (int i = 1; i < 3; i ++)
{
AxisControl.GetAxis($"NozzleZ{i}").GetOrgStatus(out bOnOrg);
if (!bOnOrg)
{
MessageQueue.Instance.Warn($"NozzleZ{i} hasn't org signal");
return false;
}
}
}
return true;
}
/// <summary>
/// 检测排料Y轴是否可以到周转盘
/// </summary>
/// <returns></returns>
private bool CanGoTurnoverTray()
{
//获取周转Y轴的位置当排料Y轴去周转盘的时候检测是否安全
double turnoverYPos = Ops.GetCurPosition("TurnoverY");
if (turnoverYPos - SysConfigParam.GetValue<double>("PressY") < -1)
return false;
return true;
}
public bool XYCanMove()
{
if (!CanGoTurnoverTray())
return false;
return true;
}
}
}