| | |
| | | |
| | | namespace Bro.M071.Process |
| | | { |
| | | public class KeyLocation : IComplexDisplay |
| | | { |
| | | [Category("键名配置")] |
| | | [Description("单键键名")] |
| | | [TypeConverter(typeof(KeyNameDictConverter))] |
| | | public string Key { get; set; } |
| | | |
| | | [Category("默认配置")] |
| | | [Description("是否默认尺寸配置")] |
| | | public bool IsDefault { get; set; } = false; |
| | | |
| | | //[Category("位置配置")] |
| | | //[Description("单键在键盘平面图上的位置显示")] |
| | | //public RectangleF KeyRect { get; set; } = new RectangleF(0, 0, 0, 0); |
| | | |
| | | [Category("位置配置")] |
| | | [Description("单键左上角坐标")] |
| | | [TypeConverter(typeof(ComplexObjectConvert))] |
| | | [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))] |
| | | public CustomizedPoint KeyPosition { get; set; } = new CustomizedPoint(); |
| | | |
| | | [Category("位置配置")] |
| | | [Description("单键尺寸")] |
| | | public SizeF KeySize { get; set; } = new SizeF(); |
| | | |
| | | [Category("位置配置")] |
| | | [Description("单键之后间隙位置")] |
| | | public SizeF IntervalSize { get; set; } = new SizeF(); |
| | | |
| | | public string GetDisplayText() |
| | | { |
| | | return $"{(IsDefault ? "Default" : Key)}:{KeyPosition.X},{KeyPosition.Y},{KeySize.Width},{KeySize.Height}"; |
| | | } |
| | | } |
| | | |
| | | |
| | | public class KeyAlgorithem : IComplexDisplay |
| | | { |
| | | [Browsable(false)] |
| | |
| | | [Description("检测算法路径")] |
| | | [Editor(typeof(FileDialogEditor), typeof(UITypeEditor))] |
| | | public string AlgorithemPath { get; set; } |
| | | |
| | | [Category("显示配置")] |
| | | [Description("显示区域大小")] |
| | | [DisplayName("标签大小")] |
| | | public Size DisplayRect { get; set; } |
| | | } |
| | | |
| | | public class KeyResult : IComplexDisplay |
| | |
| | | |
| | | public string GetDisplayText() |
| | | { |
| | | return $"{AliasName}"; |
| | | string snapShot = "未指定"; |
| | | |
| | | using (var scope = GlobalVar.Container.BeginLifetimeScope()) |
| | | { |
| | | var config = scope.Resolve<IProcessConfig>(); |
| | | if (config != null) |
| | | { |
| | | var snapshotPoint = (config as M071Config).SnapshotPointCollection.FirstOrDefault(u => u.Id == SnapshotPointId); |
| | | if (snapshotPoint != null) |
| | | { |
| | | snapShot = snapshotPoint.Name; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return $"{AliasName}-{snapShot}-{ImageSeq}"; |
| | | } |
| | | |
| | | public List<string> GetHalconToolPathList() |
| | |
| | | public class ProductionMeasurement : INotifyPropertyChanged, IDisposable |
| | | { |
| | | public string Barcode; |
| | | public string PResult; |
| | | |
| | | public List<MeasurementUnit> Measurements = new List<MeasurementUnit>(); |
| | | |
| | |
| | | { |
| | | Measurements?.ForEach(m => m?.Dispose()); |
| | | Measurements = null; |
| | | |
| | | ElementList = null; |
| | | Barcode = null; |
| | | GC.Collect(); |
| | | } |
| | |
| | | |
| | | #region 显示 |
| | | [Browsable(false)] |
| | | public Rectangle DisplayLocation { get; set; } = new Rectangle(); |
| | | public Rectangle DisplayLocation { get; set; } = new Rectangle(10, 10, 100, 100); |
| | | #endregion |
| | | |
| | | #region 检测结果 |
| | |
| | | private void K_PropertyChanged(object sender, PropertyChangedEventArgs e) |
| | | { |
| | | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("KeyUnitCollection")); |
| | | } |
| | | |
| | | public MeasurementUnit Copy() |
| | | { |
| | | MeasurementUnit mUnit = new MeasurementUnit(); |
| | | |
| | | mUnit.Id = this.Id; |
| | | mUnit.Name = this.Name; |
| | | if (string.IsNullOrWhiteSpace(mUnit.Name)) |
| | | { |
| | | mUnit.Name = string.Join("-", KeyUnitCollection.Select(u => u.GetDisplayText())); |
| | | } |
| | | |
| | | mUnit.IsEnabled = this.IsEnabled; |
| | | mUnit.MeasureType = this.MeasureType; |
| | | |
| | | mUnit.DisplayLocation = new Rectangle(this.DisplayLocation.Location, this.DisplayLocation.Size); |
| | | |
| | | if (this.Spec == null) |
| | | { |
| | | mUnit.Spec = null; |
| | | } |
| | | else |
| | | { |
| | | mUnit.Spec = new MeasureType(); |
| | | mUnit.Spec.Code = this.Spec.Code; |
| | | mUnit.Spec.AlgorithemPath = this.Spec.AlgorithemPath; |
| | | mUnit.Spec.StandardValue = this.Spec.StandardValue; |
| | | mUnit.Spec.Tolrenance_Positive = this.Spec.Tolrenance_Positive; |
| | | mUnit.Spec.Tolrenance_Negative = this.Spec.Tolrenance_Negative; |
| | | } |
| | | |
| | | this.KeyUnitCollection.ForEach(k => |
| | | { |
| | | mUnit.KeyUnitCollection.Add(k.Copy()); |
| | | }); |
| | | |
| | | return mUnit; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | public void Dispose() |
| | | { |
| | | SpinWait wait = new SpinWait(); |
| | | while (ImageSaveStatus != 0) |
| | | { |
| | | wait.SpinOnce(); |
| | | Thread.Sleep(10); |
| | | } |
| | | |
| | | KeyImages?.ForEach(i => |
| | |
| | | if (valuePairs == null || valuePairs.Count == 0) |
| | | { |
| | | IsDone = false; |
| | | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsDone")); |
| | | return; |
| | | } |
| | | |
| | | foreach (KeyValuePair<string, double> pair in valuePairs) |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | public KeyUnitBind Copy() |
| | | { |
| | | KeyUnitBind clone = new KeyUnitBind(); |
| | | clone.Key = this.Key; |
| | | clone.KeyResultId = this.KeyResultId; |
| | | |
| | | this.MeasureValueDict.Keys.ToList().ForEach(k => |
| | | { |
| | | clone.MeasureValueDict[k] = null; |
| | | }); |
| | | |
| | | return clone; |
| | | } |
| | | } |
| | | |
| | | //public class NoticedDictionary<T1, T2> : Dictionary<T1, T2>, INotifyPropertyChanged |