using DH.Devices.Vision; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static OpenCvSharp.AgastFeatureDetector; namespace DHSoftware { public class productModel { } /// /// 产品结果数据 /// public class ProductData : IDisposable { /// /// 物件编号 /// public readonly uint PieceNumber; public readonly string DetYime; public double Distance = 0; public string Id { get; set; } = "P" + DateTime.Now.ToString("HHmmssfff"); public string BatchNO { get; set; } public DateTime? ResultTime { get; set; } = null; public DateTime CreateTime { get; set; } = DateTime.Now; public DateTime? BlowOutTime { get; set; } = null; public List ResultCollection { get; set; } = new List(); object _resultLock = new object(); public ResultState ProductResult { get; set; } public string ProductLabelCategory { get; set; } public string ProductLabel { get; set; } // public List DiskPositions { get; set; } = new List(); // public List TriggerSettings { get; set; } // public List TriggerSettings { get; set; } /// /// 存放的是工位存放的图片和相机ID和相机数量 /// // public List ModuleProductDatas { get; set; } = new List(); // volatile ITriggerSet CurTrigger = null; public int CurAxisNum = -1; public int CurStartPosition = -1; public int NextTriggerAxisNum = -1; private object _inferenceLock = new object(); private volatile int InferenceLeft = -1; private CountdownEvent _countdownEvent; public bool IsA2B { get; set; } = false; public ProductData(uint pieceNumber) { PieceNumber = pieceNumber; } //双转盘模组 public ProductData( string batchNO, uint pieceNumber, int inferenceLeft = -1) : this(pieceNumber) { InferenceLeft = inferenceLeft; _countdownEvent = new CountdownEvent(inferenceLeft); BatchNO = batchNO; } public void InferenceOne() { //lock (_inferenceLock) //{ // Interlocked.Decrement(ref InferenceLeft); //} _countdownEvent.Signal(); } public bool InferenceFinished() { //lock (_inferenceLock) //{ // return 0 == InferenceLeft; //} return _countdownEvent.CurrentCount == 0; // 判断计数器是否为 0 } object _compareLock = new object(); object _curTriggerLock = new object(); /// /// 将该料设为TBD /// private void SetToTBD() { //检测数量不足TBD ProductResult = ResultState.B_NG; ProductLabelCategory = ResultState.B_NG.GetEnumDescription(); // ProductLabel = ResultState.ShortageTBD.GetEnumDescription(); } public ProductData GetProductData() { ProductData p = new ProductData(PieceNumber) { Id = Id, BatchNO = BatchNO, ResultTime = ResultTime, BlowOutTime = BlowOutTime, ProductResult = ProductResult, ProductLabelCategory = ProductLabelCategory, ProductLabel = ProductLabel, }; return p; } public void Dispose() { } } }