From 3322022068ab818912d6f5d9e5eb31f51cc639c2 Mon Sep 17 00:00:00 2001 From: patrick.xu <patrick.xu@broconcentric.com> Date: 星期四, 24 二月 2022 09:12:30 +0800 Subject: [PATCH] 添加配置文件的DataShift2 --- src/Bro.M071.Process/M071Models.cs | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 160 insertions(+), 6 deletions(-) diff --git a/src/Bro.M071.Process/M071Models.cs b/src/Bro.M071.Process/M071Models.cs index f2c588f..6459031 100644 --- a/src/Bro.M071.Process/M071Models.cs +++ b/src/Bro.M071.Process/M071Models.cs @@ -17,6 +17,41 @@ 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)] @@ -48,6 +83,15 @@ [Description("妫�娴嬬畻娉曡矾寰�")] [Editor(typeof(FileDialogEditor), typeof(UITypeEditor))] public string AlgorithemPath { get; set; } + + [Category("涓婁紶NG浠g爜")] + [Description("涓婁紶NG浠g爜")] + public string NGCode { get; set; } + + [Category("鏄剧ず閰嶇疆")] + [Description("鏄剧ず鍖哄煙澶у皬")] + [DisplayName("鏍囩澶у皬")] + public Size DisplayRect { get; set; } } public class KeyResult : IComplexDisplay @@ -169,6 +213,13 @@ public string KeyResultId { get; set; } #endregion + [Category("琛ュ伩閰嶇疆")] + [DisplayName("鍗曢敭琛ュ伩")] + [Description("鍗曢敭琛ュ伩")] + [TypeConverter(typeof(CollectionCountConvert))] + [Editor(typeof(ComplexCollectionEditor<KeyCompensation>), typeof(UITypeEditor))] + public List<KeyCompensation> KeyCompensationCollection { get; set; } = new List<KeyCompensation>(); + #region 妫�娴嬬浉鍏冲瓧娈� public Dictionary<string, double> KeyValues = null; //public SnapshotPoint SnapshotPoint = null; @@ -178,7 +229,22 @@ 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() @@ -201,6 +267,24 @@ } } + public class KeyCompensation : IComplexDisplay + { + [Category("鍗曢敭琛ュ伩")] + [DisplayName("鍗曢敭缁撴灉")] + [Description("閽堝鍗曢敭鐨勬煇涓�椤圭粨鏋滃仛琛ュ伩锛屼竴鑸负Z1,Z2,Z3,Z4,B1,B2")] + public string KeyResult { get; set; } + + [Category("鍗曢敭琛ュ伩")] + [DisplayName("琛ュ伩鍊�")] + [Description("鍗曢敭缁撴灉琛ュ伩鍊�")] + public float Compensation { get; set; } + + public string GetDisplayText() + { + return $"{KeyResult} {Compensation}"; + } + } + public class ProductionMeasurement : INotifyPropertyChanged, IDisposable { public string Barcode; @@ -220,8 +304,8 @@ { Measurements?.ForEach(m => m?.Dispose()); Measurements = null; - - Barcode = null; + ElementList = null; + //Barcode = null; GC.Collect(); } @@ -267,7 +351,7 @@ #region 鏄剧ず [Browsable(false)] - public Rectangle DisplayLocation { get; set; } = new Rectangle(); + public Rectangle DisplayLocation { get; set; } = new Rectangle(10, 10, 100, 100); #endregion #region 妫�娴嬬粨鏋� @@ -304,6 +388,44 @@ 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; } } @@ -354,10 +476,9 @@ public void Dispose() { - SpinWait wait = new SpinWait(); while (ImageSaveStatus != 0) { - wait.SpinOnce(); + Thread.Sleep(10); } KeyImages?.ForEach(i => @@ -377,6 +498,8 @@ if (valuePairs == null || valuePairs.Count == 0) { IsDone = false; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsDone")); + return; } foreach (KeyValuePair<string, double> pair in valuePairs) @@ -398,6 +521,37 @@ } } } + + 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 KeyCodeMap : IComplexDisplay + { + [Category("閿悕鏄犲皠閰嶇疆")] + [Description("閿悕")] + [TypeConverter(typeof(KeyNameDictConverter))] + public string Key { get; set; } + + [Category("閿悕鏄犲皠閰嶇疆")] + [Description("涓婁紶瀵瑰簲閿唬鐮丆ode")] + public string KeyCode { get; set; } + + public string GetDisplayText() + { + return $"{Key}--{KeyCode}"; + } } //public class NoticedDictionary<T1, T2> : Dictionary<T1, T2>, INotifyPropertyChanged -- Gitblit v1.8.0