using Autofac;
|
using Bro.Common.Helper;
|
using Bro.Common.Interface;
|
using Bro.Common.Model;
|
using System.ComponentModel;
|
using System.Drawing.Design;
|
|
namespace Bro.M141.Process
|
{
|
public class CheckPoint : IComplexDisplay
|
{
|
[Browsable(false)]
|
public string Id { get; set; } = Guid.NewGuid().ToString();
|
|
[Category("检测点位")]
|
[Description("点位名称")]
|
[DisplayName("点位名称")]
|
public string Name { get; set; } = "";
|
|
[Category("检测点位")]
|
[Description("点位坐标,检测点位的运动坐标")]
|
[DisplayName("点位坐标")]
|
[TypeConverter(typeof(ExpandableObjectConverter))]
|
public CustomizedPoint PointPosition { get; set; } = new CustomizedPoint();
|
|
[Category("检测点位")]
|
[Description("点位坐标,检测点位的Z轴坐标")]
|
[DisplayName("点位坐标Z")]
|
public double PointZ { get; set; }
|
|
[Category("标定设置")]
|
[Description("该检测点位的标定矩阵,图像UV坐标转换为大板坐标系XY的标定矩阵")]
|
[DisplayName("点位标定矩阵")]
|
[TypeConverter(typeof(SimpleCollectionConvert<double>))]
|
[Editor(typeof(SimpleCollectionEditor<double>), typeof(UITypeEditor))]
|
public List<double> Matrix { get; set; } = new List<double>();
|
|
[Category("启用配置")]
|
[Description("true:启用该点位 false:禁用该点位")]
|
[DisplayName("点位启用标志")]
|
public bool IsEnabled { get; set; } = true;
|
|
public string GetDisplayText()
|
{
|
return $"{(IsEnabled ? "" : "禁用 ")}{Name} {PointPosition.GetDisplayText()}";
|
}
|
}
|
|
public enum ContourEdge
|
{
|
X,
|
Y
|
}
|
public class ContourPoint : CustomizedPoint
|
{
|
[Category("点位名称")]
|
[Description("点位名称")]
|
[DisplayName("点位名称")]
|
public string Name { get; set; } = "";
|
|
[Category("轮廓选择")]
|
[Description("轮廓选择。选择X边,表示计算时以X坐标为基准,计算Y数值。选择Y边,表示计算时以Y坐标为基准,计算X数值")]
|
[DisplayName("轮廓选择")]
|
public ContourEdge ContourEdge { get; set; } = ContourEdge.X;
|
|
[Browsable(false)]
|
public double ActualX { get; set; } = -999;
|
|
[Browsable(false)]
|
public double ActualY { get; set; } = -999;
|
|
public ContourPoint Copy()
|
{
|
ContourPoint point = new ContourPoint();
|
|
point.Name = Name;
|
point.X = X;
|
point.Y = Y;
|
point.ContourEdge = this.ContourEdge;
|
|
point.ActualX = ActualX;
|
point.ActualY = ActualY;
|
|
return point;
|
}
|
|
[Browsable(false)]
|
public double Error { get; set; } = 0;
|
public void CalculateError(bool isBySingleEdge)
|
{
|
if (isBySingleEdge)
|
{
|
if (ContourEdge == ContourEdge.X)
|
{
|
Error = Math.Abs(ActualY - Y);
|
}
|
else
|
{
|
Error = Math.Abs(ActualX - X);
|
}
|
}
|
else
|
{
|
Error = Math.Sqrt(Math.Pow(ActualX - X, 2) + Math.Pow(ActualY - Y, 2));
|
}
|
}
|
|
public override string GetDisplayText()
|
{
|
return $"{Name} {X.ToString("f3")}:{Y.ToString("f3")} {ContourEdge.ToString()}基准";
|
}
|
}
|
|
public class MeasureItemBind : IComplexDisplay, IHalconToolPath
|
{
|
[Category("检测标准")]
|
[DisplayName("\t检测名称")]
|
[Description("检测名称 填写检测名称内容,不填写时沿用SPEC的名称")]
|
public string FAIName { get; set; }
|
|
[Category("检测标准")]
|
[DisplayName("\t检测标准")]
|
[Description("检测标准选择")]
|
[TypeConverter(typeof(SpecCodeSelectorConverter))]
|
public string SpecCode { get; set; }
|
|
[Category("算法配置")]
|
[DisplayName("算法路径")]
|
[Description("算法路径")]
|
[Editor(typeof(FileDialogEditor), typeof(UITypeEditor))]
|
public string AlgorithemPath { get; set; }
|
|
[Category("检测点位")]
|
[DisplayName("\t检测点位集合")]
|
[Description("该检测项所涉及的所有检测点位集合")]
|
[TypeConverter(typeof(ComplexObjectConvert))]
|
[Editor(typeof(ComplexCollectionEditor<MeasurePointSelector>), typeof(UITypeEditor))]
|
public List<MeasurePointSelector> MeasurePointNameCollection { get; set; } = new List<MeasurePointSelector>();
|
|
[Category("检测项分配")]
|
[Description("是否将检测项需求分配到各个检测点位,true:每个检测点位都执行该检测项需求 false:所有检测点位作为一个整体执行检测需求")]
|
[DisplayName("点位分配检测项")]
|
public bool IsSubscribeSpecForPoints { get; set; } = false;
|
|
public string GetDisplayText()
|
{
|
return $"{FAIName} {SpecCode} {string.Join(",", MeasurePointNameCollection.Select(u => u.GetDisplayText()))} {AlgorithemPath}";
|
}
|
|
public List<string> GetHalconToolPathList()
|
{
|
return new List<string>() { AlgorithemPath };
|
}
|
}
|
|
public class MeasurePointSelector : IComplexDisplay
|
{
|
[Category("检测点位")]
|
[Description("检测点位")]
|
[DisplayName("检测点位")]
|
[TypeConverter(typeof(MeasurePointNameSelectorConvertor))]
|
public string MeasurePointName { get; set; } = "";
|
|
public string GetDisplayText()
|
{
|
return $"{MeasurePointName}";
|
}
|
}
|
|
public class MeasurePointNameSelectorConvertor : ComboBoxItemTypeConvert
|
{
|
public override Dictionary<string, string> GetConvertDict(ITypeDescriptorContext context)
|
{
|
Dictionary<string, string> dict = new Dictionary<string, string>();
|
|
using (var scope = GlobalVar.Container.BeginLifetimeScope())
|
{
|
var config = scope.Resolve<IProcessConfig>();
|
if (config is M141Config iConfig)
|
{
|
iConfig.MeasurePointCollection.ForEach(u =>
|
{
|
dict[u.Name] = u.Name;
|
});
|
}
|
}
|
dict[""] = "未指定";
|
|
return dict;
|
}
|
}
|
}
|