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.

67 lines
2.2 KiB
C#

using Rs.Framework;
using Rs.MotionPlat.Commom;
using Rs.MotionPlat.Entitys.Trays;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Rs.MotionPlat.Flow.SubFlow
{
/// <summary>
/// 测试治具真空吸检测流程
/// </summary>
public class TestFixtureVacSuctionCheckFlow
{
List<TestTraySlot> hasProductSlots = new List<TestTraySlot>();
private TestFixtureVacSuctionCheckFlow() { }
private static TestFixtureVacSuctionCheckFlow instance;
public static TestFixtureVacSuctionCheckFlow Instance
{
get
{
if (instance == null)
{
instance = new TestFixtureVacSuctionCheckFlow();
}
return instance;
}
}
private ManualResetEvent checkFinishedSingle = new ManualResetEvent(true);
public void Check()
{
Task.Run(() => {
hasProductSlots.Clear();
checkFinishedSingle.Reset();
MessageQueue.Instance.Insert("放料之前用检测测试治具穴位中是否有产品,检测开始");
foreach (var item in TestTrayManager.Instance.GetAll())
{
//先打开真空
VacManager.TestTrayVacSuction(EVacOperator.Open, true, item.Index);
//检测是否真空有效
if(item.HasProduct())
{
hasProductSlots.Add(item);
}
VacManager.TestTrayVacSuction(EVacOperator.Close, true, item.Index);
}
checkFinishedSingle.Set();
MessageQueue.Instance.Insert($"检测测试治具穴位中是否有产品结束 hasProductSlotNum={hasProductSlots.Count}");
});
}
/// <summary>
/// 等待检测结果
/// </summary>
/// <returns></returns>
public List<TestTraySlot> WaitResult()
{
checkFinishedSingle.WaitOne();
return hasProductSlots;
}
}
}