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
{
///
/// 测试治具真空吸检测流程
///
public class TestFixtureVacSuctionCheckFlow
{
List hasProductSlots = new List();
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}");
});
}
///
/// 等待检测结果
///
///
public List WaitResult()
{
checkFinishedSingle.WaitOne();
return hasProductSlots;
}
}
}