155 lines
3.9 KiB
C#
155 lines
3.9 KiB
C#
using DH.Commons.Base;
|
|
using DH.Commons.Enums;
|
|
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
|
|
{
|
|
}
|
|
/// <summary>
|
|
/// 产品结果数据
|
|
/// </summary>
|
|
public class ProductData : IDisposable
|
|
{
|
|
|
|
/// <summary>
|
|
/// 物件编号
|
|
/// </summary>
|
|
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<DetectStationResult> ResultCollection { get; set; } = new List<DetectStationResult>();
|
|
|
|
object _resultLock = new object();
|
|
|
|
public ResultState ProductResult { get; set; }
|
|
|
|
public string ProductLabelCategory { get; set; }
|
|
|
|
public string ProductLabel { get; set; }
|
|
|
|
// public List<DiskPosition> DiskPositions { get; set; } = new List<DiskPosition>();
|
|
|
|
// public List<ITriggerSet> TriggerSettings { get; set; }
|
|
// public List<ITriggerSet> TriggerSettings { get; set; }
|
|
/// <summary>
|
|
/// 存放的是工位存放的图片和相机ID和相机数量
|
|
/// </summary>
|
|
// public List<ModuleProductData> ModuleProductDatas { get; set; } = new List<ModuleProductData>();
|
|
|
|
// 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();
|
|
|
|
|
|
/// <summary>
|
|
/// 将该料设为TBD
|
|
/// </summary>
|
|
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()
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|