using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace M423project { //检测状态,初始为未检测 public enum MeasureState { OK, NG, UNKNOWN, NA } /// /// 检测长宽结果类型 /// public struct MeasureSize { public double Length, Width, CellWidth; //分别为长、宽、格子宽度 public MeasureState Result; public MeasureState LengthResult; public MeasureState WidthResult; public override string ToString() { return string.Format("L:{0:F4} W:{1:F4} CW:{2:F4} R:{3:F4}", Length, Width, CellWidth, Result); } } /// /// 检测高度结果类型 /// public struct MeasureHeight { public double Height, CellHeight; //分别为高度、格子高度 public MeasureState HeightResult; public MeasureState CellHeightResult; public override string ToString() { return string.Format("H:{0:F4} CH:{1:F4} R:{2}", Height, CellHeight, HeightResult); } } /// /// 测量结果,包含产品代码、尺寸(长、宽)、高度 /// public class ProductMeasureResult { public MeasureSize measureSize; public MeasureHeight measureHeight; public MeasureState productNoResult; private string productNo; public int DetectID { get; set; } public string ProductNo { get { return productNo; } set { productNo = value; } } public DateTime DetectTime { get; set; } public int PlateID { get; set; } public string ProductNoResult { get { return productNoResult.ToString(); } set { productNoResult = (MeasureState)Enum.Parse(typeof(MeasureState), value); } } public double Height { get { return measureHeight.Height; } set { measureHeight.Height = value; } } public double CellHeight { get { return measureHeight.CellHeight; } set { measureHeight.CellHeight = value; } } public string HeightResult { get { return measureHeight.HeightResult.ToString(); } set { measureHeight.HeightResult = (MeasureState)Enum.Parse(typeof(MeasureState), value); } } public string CellHeightResult { get { return measureHeight.CellHeightResult.ToString(); } set { measureHeight.CellHeightResult = (MeasureState)Enum.Parse(typeof(MeasureState), value); } } public double Length { get { return measureSize.Length; } set { measureSize.Length = value; } } public string LengthResult { get { return measureSize.LengthResult.ToString(); } set { measureSize.LengthResult = (MeasureState)Enum.Parse(typeof(MeasureState), value); } } public double Width { get { return measureSize.Width; } set { measureSize.Width = value; } } public string WidthResult { get { return measureSize.WidthResult.ToString(); } set { measureSize.WidthResult = (MeasureState)Enum.Parse(typeof(MeasureState), value); } } //public double CellWidth { get { return measureSize.CellWidth; } set { measureSize.CellWidth = value; } } //public string SizeResult //{ // get { return measureSize.Result.ToString(); } // set { measureSize.Result = (MeasureState)Enum.Parse(typeof(MeasureState), value); } // } /// /// 是否是抽檢數據 /// public bool IsSpotCheck { get; set; } public string ProductResult { get; set; } public ProductMeasureResult(string _productNo, int _detectID) { productNo = _productNo; DetectID = _detectID; measureSize.Result = MeasureState.UNKNOWN; measureSize.LengthResult = MeasureState.UNKNOWN; measureSize.WidthResult = MeasureState.UNKNOWN; measureSize.CellWidth = 0; measureSize.Length = 0; measureSize.Width = 0; measureHeight.HeightResult = MeasureState.UNKNOWN; measureHeight.CellHeight = 0; measureHeight.Height = 0; measureHeight.CellHeight = 0; measureHeight.CellHeightResult = MeasureState.UNKNOWN; productNoResult = MeasureState.UNKNOWN; DetectTime = DateTime.Now; ProductResult = MeasureState.UNKNOWN.ToString(); PlateID = 0; } public override string ToString() { return string.Format("{0} L:{1:F4},W:{2:F4}, CW:{3:F4}, R:{4} H:{5:F4},CH:{6:F4}, R:{7}", productNo, measureSize.Length, measureSize.Width, measureSize.CellWidth, measureSize.Result, measureHeight.Height, measureHeight.CellHeight, measureHeight.HeightResult); } } [Serializable] public class MeasureResultTTL { public int ProductQuntity { get; set; } public int PassQuntity { get; set; } public int FailQuntity { get; set; } public int EmptyQuantity { get; set; } public string PassRate { get { double v = 0.0; if (ProductQuntity != 0) v = (double)PassQuntity / (double)(ProductQuntity - EmptyQuantity); return string.Format("{0:P2}", v); } } public int HeightPassQuntity { get; set; } public int HeightFailQuntity { get; set; } public int SizePassQuantity { get; set; } public int SizeFailQuantity { get; set; } public int ProductNoFailQuantity { get; set; } public void Clear() { ProductQuntity = 0; PassQuntity = 0; FailQuntity = 0; HeightPassQuntity = 0; HeightFailQuntity = 0; SizePassQuantity = 0; SizeFailQuantity = 0; ProductNoFailQuantity = 0; EmptyQuantity = 0; } public MeasureResultTTL() { Clear(); } public override string ToString() { return string.Format("检测产品总数:{0}, 合格数:{1}, 不合格数:{2}, 合格率:{3};其中高度合格数为{4},不合格数为{5}, 尺寸合格数为{6}, 不合格数为{7})", ProductQuntity, PassQuntity, FailQuntity, PassRate, HeightPassQuntity, HeightFailQuntity, SizePassQuantity, SizeFailQuantity); } } }