From da0da2d1238555c4ff488dbaaae1371ba4cf6827 Mon Sep 17 00:00:00 2001
From: wells.liu <wells.liu@broconcentric.com>
Date: 星期四, 09 七月 2020 17:22:51 +0800
Subject: [PATCH] Merge branch 'master' of http://gitblit.broconcentric.com:8088/r/M071

---
 src/Bro.Device.GTSCard/GTSCardDriver.cs               |   11 
 src/Bro.Common.Model/Helper/PropertyConvertHelper.cs  |    3 
 src/Bro.Common.Device/DeviceBase/MotionCardBase.cs    |  137 +++++++++++-
 src/Bro.Device.Gocator/Bro.Device.Gocator.csproj      |    6 
 src/Bro.Common.Model/Base/DeviceConfigBase.cs         |    4 
 src/Bro.Common.Model/Bro.Common.Model.csproj          |    1 
 src/Bro.Common.Model/Forms/FrmDeviceOpConfigEditor.cs |    1 
 src/Bro.Common.Model/Interface/IOperationConfig.cs    |    5 
 src/Bro.Process/ProcessControl.cs                     |    5 
 src/Bro.Common.Device/DeviceBase/CameraBase.cs        |    7 
 src/Bro.Process/ProcessControl_Calibration.cs         |    9 
 src/Bro.M071.Process/M071Process.cs                   |   31 +-
 src/Bro.Device.Gocator/GocatorDriver.cs               |   14 +
 src/Bro.Common.Model/Model/LaserScanParam.cs          |   21 ++
 src/Bro.Device.Gocator/packages.config                |    4 
 src/Bro.Common.Model/Model/MotionCardRelated.cs       |  314 ++++++++++++++++++------------
 16 files changed, 403 insertions(+), 170 deletions(-)

diff --git a/src/Bro.Common.Device/DeviceBase/CameraBase.cs b/src/Bro.Common.Device/DeviceBase/CameraBase.cs
index 440c7d0..42d1be2 100644
--- a/src/Bro.Common.Device/DeviceBase/CameraBase.cs
+++ b/src/Bro.Common.Device/DeviceBase/CameraBase.cs
@@ -848,6 +848,11 @@
         bool IsAddtionalSaved { get; set; }
 
         event Action<ImageSet> OnImageSetTimeout;
+
+        /// <summary>
+        /// 搴忓垪鍖栨搷浣滅殑鍥惧儚淇℃伅
+        /// </summary>
+        string ImageData { get; set; }
     }
 
     public class ImageSet : IImageSet
@@ -887,6 +892,8 @@
 
         public object SaveLock { get; set; } = new object();
 
+        public virtual string ImageData { get; set; }
+
         public event Action<ImageSet> OnImageSetTimeout;
         private Timer autoDisposeTimer = null;
 
diff --git a/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs b/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs
index a6d2849..1ff6cd5 100644
--- a/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs
+++ b/src/Bro.Common.Device/DeviceBase/MotionCardBase.cs
@@ -190,13 +190,48 @@
         [Category("鏉垮崱鎿嶄綔")]
         [Description("鏉垮崱鎿嶄綔閰嶇疆鍩虹被闆嗗悎锛屼緷娆℃墽琛�")]
         [TypeConverter(typeof(CollectionCountConvert))]
-        [Editor(typeof(ComplexCollectionEditor<MotionCardOperationSet>), typeof(UITypeEditor))]
+        [Editor(typeof(MotionCardOperationSetEditor), typeof(UITypeEditor))]
         public List<MotionCardOperationSet> OperationCollection { get; set; } = new List<MotionCardOperationSet>();
 
         public string GetDisplayText()
         {
+            //OperationCollection.ForEach(o =>
+            //{
+            //    o.MotionCardId = DeviceId;
+            //});
+
             return string.Join(" ", OperationCollection.Select(u => u.GetDisplayText()));
         }
+    }
+
+    public class MotionCardOperationSetEditor : ComplexCollectionEditor<MotionCardOperationSet>
+    {
+        public MotionCardOperationSetEditor(Type type) : base(type) { }
+
+        IOperationConfig opConfig = null;
+        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
+        {
+            if (context.Instance is IOperationConfig config && value is List<MotionCardOperationSet> setList)
+            {
+                opConfig = config;
+                setList.ForEach(set => set.MotionCardId = opConfig.DeviceId);
+            }
+
+            return base.EditValue(context, provider, value);
+        }
+
+        protected override object CreateInstance(Type itemType)
+        {
+            object obj = base.CreateInstance(itemType);
+
+            if (obj is MotionCardOperationSet set)
+            {
+                set.MotionCardId = opConfig?.DeviceId;
+            }
+
+            return obj;
+        }
+
     }
 
     [Device("MotionOperationSet", "杩愬姩鎿嶄綔閰嶇疆鍩虹被", EnumHelper.DeviceAttributeType.OperationConfig)]
@@ -230,18 +265,21 @@
         [DisplayName("IO纭瓒呮椂")]
         public int IOConfirmTimeout { get; set; } = 0;
 
-        //[Category("鏉垮崱杩愬姩閰嶇疆")]
-        //[DisplayName("杩愬姩閰嶇疆闆嗗悎")]
-        //[Description("MovingOps锛氳繍鍔ㄩ厤缃泦鍚�")]
-        //[TypeConverter(typeof(CollectionCountConvert))]
-        //[Editor(typeof(ComplexCollectionEditor<MovingOption>), typeof(UITypeEditor))]
-        //public List<MovingOption> MovingOps { get; set; } = new List<MovingOption>();
         [Category("鏉垮崱杩愬姩閰嶇疆")]
         [DisplayName("杩愬姩閰嶇疆闆嗗悎")]
         [Description("MovingOps锛氳繍鍔ㄩ厤缃泦鍚�")]
-        [TypeConverter(typeof(ComplexObjectConvert))]
-        [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))]
-        public MotionOperationCollection MotionOperationCollection { get; set; } = new MotionOperationCollection();
+        [TypeConverter(typeof(CollectionCountConvert))]
+        [Editor(typeof(MovingOpsCollectionEditor), typeof(UITypeEditor))]
+        public List<MovingOption> MovingOps { get; set; } = new List<MovingOption>();
+
+        public string MotionCardId = "";
+
+        //[Category("鏉垮崱杩愬姩閰嶇疆")]
+        //[DisplayName("杩愬姩閰嶇疆闆嗗悎")]
+        //[Description("MovingOps锛氳繍鍔ㄩ厤缃泦鍚�")]
+        //[TypeConverter(typeof(ComplexObjectConvert))]
+        //[Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))]
+        //public MotionOperationCollection MotionOperationCollection { get; set; } = new MotionOperationCollection();
 
 
         public string GetDisplayText()
@@ -276,14 +314,15 @@
             }
 
             string moving = "";
-            //MovingOps.ForEach(i =>
-            //{
-            //    moving += i.GetDisplayText() + " ";
-            //});
-            //if (moving != "")
-            //{
-            //    moving = " 杩愬姩锛�" + moving;
-            //}
+            MovingOps.ForEach(i =>
+            {
+                moving += i.GetDisplayText() + " ";
+            });
+
+            if (moving != "")
+            {
+                moving = " 杩愬姩锛�" + moving;
+            }
 
             return (preCheck + output + confirm + moving).Trim();
         }
@@ -444,4 +483,66 @@
         //}
     }
 
+    public class MovingOpsCollectionEditor : ComplexCollectionEditor<MovingOption>
+    {
+        public MovingOpsCollectionEditor(Type type) : base(type)
+        {
+        }
+
+        MotionCardBase motionCard = null;
+        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
+        {
+            if (context.Instance is MotionCardOperationSet set)
+            {
+                if (!string.IsNullOrWhiteSpace(set.MotionCardId))
+                {
+                    using (var scope = GlobalVar.Container.BeginLifetimeScope())
+                    {
+                        var deviceList = scope.Resolve<List<IDevice>>();
+                        if (deviceList != null)
+                        {
+                            motionCard = deviceList.FirstOrDefault(u => u.Id == set.MotionCardId) as MotionCardBase;
+                        }
+                    }
+                }
+
+                if (motionCard != null && value is List<MovingOption> ops)
+                {
+                    ops.ForEach(o => o.SetAxisSetting(motionCard.IConfig.AxisSettings));
+                }
+            }
+
+            return base.EditValue(context, provider, value);
+        }
+
+        protected override object SetItems(object editValue, object[] value)
+        {
+            Array.ForEach(value, v =>
+             {
+                 if (v is MovingOption op && motionCard != null)
+                 {
+                     op.SetAxisSetting(motionCard.IConfig.AxisSettings);
+                 }
+             });
+
+            return base.SetItems(editValue, value);
+        }
+        ///// <summary> 
+        ///// 闄愬埗涓�娆¢�変竴涓疄渚� 
+        ///// </summary> 
+        ///// <returns></returns> 
+        //protected override bool CanSelectMultipleInstances()
+        //{
+        //    return false;
+        //}
+        ///// <summary> 
+        ///// 鎸囧畾鍒涘缓鐨勫璞$被鍨� 
+        ///// </summary> 
+        ///// <returns></returns> 
+        //protected override Type CreateCollectionItemType()
+        //{
+        //    return typeof(MovingOption);
+        //}
+    }
+
 }
diff --git a/src/Bro.Common.Model/Base/DeviceConfigBase.cs b/src/Bro.Common.Model/Base/DeviceConfigBase.cs
index d6c3658..9c45926 100644
--- a/src/Bro.Common.Model/Base/DeviceConfigBase.cs
+++ b/src/Bro.Common.Model/Base/DeviceConfigBase.cs
@@ -43,6 +43,10 @@
         [Browsable(false)]
         [JsonIgnore]
         public virtual string DeviceId { get; set; } = "";
+
+        [Browsable(false)]
+        [JsonIgnore]
+        public virtual string OutputData { get; set; } = "";
     }
 
     public class InitialConfigBase : IInitialConfig
diff --git a/src/Bro.Common.Model/Bro.Common.Model.csproj b/src/Bro.Common.Model/Bro.Common.Model.csproj
index a66632a..f20a16a 100644
--- a/src/Bro.Common.Model/Bro.Common.Model.csproj
+++ b/src/Bro.Common.Model/Bro.Common.Model.csproj
@@ -151,6 +151,7 @@
     <Compile Include="Model\CustomizedPoint.cs" />
     <Compile Include="Model\CustomizedRectangle.cs" />
     <Compile Include="Model\DeviceOpBind.cs" />
+    <Compile Include="Model\LaserScanParam.cs" />
     <Compile Include="Model\ModbusFrame.cs" />
     <Compile Include="Model\MonitorSet.cs" />
     <Compile Include="Model\MotionCardRelated.cs" />
diff --git a/src/Bro.Common.Model/Forms/FrmDeviceOpConfigEditor.cs b/src/Bro.Common.Model/Forms/FrmDeviceOpConfigEditor.cs
index bb4b9a7..d17062c 100644
--- a/src/Bro.Common.Model/Forms/FrmDeviceOpConfigEditor.cs
+++ b/src/Bro.Common.Model/Forms/FrmDeviceOpConfigEditor.cs
@@ -120,6 +120,7 @@
         {
             Bind.Device = cboDevice.SelectedValue.ToString();
             Bind.OpConfig = propGrid.SelectedObject as IOperationConfig;
+            Bind.OpConfig.DeviceId = Bind.Device;
             this.DialogResult = DialogResult.OK;
         }
 
diff --git a/src/Bro.Common.Model/Helper/PropertyConvertHelper.cs b/src/Bro.Common.Model/Helper/PropertyConvertHelper.cs
index b802a92..ab855ea 100644
--- a/src/Bro.Common.Model/Helper/PropertyConvertHelper.cs
+++ b/src/Bro.Common.Model/Helper/PropertyConvertHelper.cs
@@ -679,7 +679,8 @@
                 TextBox tbox = new TextBox
                 {
                     Dock = DockStyle.Fill,
-                    Multiline = true
+                    Multiline = true,
+                    ScrollBars = ScrollBars.Both,
                 };
                 form.Controls.Add(tbox);
 
diff --git a/src/Bro.Common.Model/Interface/IOperationConfig.cs b/src/Bro.Common.Model/Interface/IOperationConfig.cs
index 9a70cf6..25d8fa6 100644
--- a/src/Bro.Common.Model/Interface/IOperationConfig.cs
+++ b/src/Bro.Common.Model/Interface/IOperationConfig.cs
@@ -31,5 +31,10 @@
         /// 璋冪敤璇ユ搷浣滈厤缃殑璁惧Id
         /// </summary>
         string DeviceId { get; set; }
+
+        /// <summary>
+        /// 鎿嶄綔鎵ц鍚庨儴鍒嗚緭鍑虹粨鏋滐紝鐩墠鎷熼噰鐢ㄥ簭鍒楀寲鍚庣殑瀛楃涓叉柟寮忎繚瀛�
+        /// </summary>
+        string OutputData { get; set; }
     }
 }
diff --git a/src/Bro.Common.Model/Model/LaserScanParam.cs b/src/Bro.Common.Model/Model/LaserScanParam.cs
new file mode 100644
index 0000000..a7eb899
--- /dev/null
+++ b/src/Bro.Common.Model/Model/LaserScanParam.cs
@@ -0,0 +1,21 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Bro.Common.Model
+{
+    public class LaserScanParam
+    {
+        public int Resolution_X { get; set; }
+        public int Resolution_Y { get; set; }
+        public int Resolution_Z { get; set; }
+
+        public int Offset_X { get; set; }
+        public int Offset_Y { get; set; }
+        public int Offset_Z { get; set; }
+
+        public int Angle_Z { get; set; }
+    }
+}
diff --git a/src/Bro.Common.Model/Model/MotionCardRelated.cs b/src/Bro.Common.Model/Model/MotionCardRelated.cs
index 6342b0a..7083a14 100644
--- a/src/Bro.Common.Model/Model/MotionCardRelated.cs
+++ b/src/Bro.Common.Model/Model/MotionCardRelated.cs
@@ -1,9 +1,11 @@
 锘縰sing Bro.Common.Helper;
 using Newtonsoft.Json;
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Drawing.Design;
+using System.Globalization;
 using System.Linq;
 using System.Text;
 using System.Threading;
@@ -241,115 +243,129 @@
     /// <summary>
     /// 杩愬姩瀵硅薄
     /// </summary>
-    public class MovingOption : INotifyPropertyChanged, IComplexDisplay
+    public class MovingOption : IComplexDisplay
     {
-        private int axisIndex = 0;
         [Category("杩愬姩閰嶇疆")]
         [DisplayName("杩愬姩杞寸储寮�")]
         [Description("AxisIndex锛氳繍鍔ㄨ酱绱㈠紩")]
         [TypeConverter(typeof(AxisIndexConvert))]
+        public string AxisIndexStr { get; set; } = "0";
+
+        [Browsable(false)]
+        [JsonIgnore]
         public int AxisIndex
         {
-            get => axisIndex;
-            set
-            {
-                if (axisIndex != value)
-                {
-                    axisIndex = value;
-                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("AxisIndex"));
-                }
-                axisIndex = value;
-            }
+            get => int.Parse(AxisIndexStr);
+            set => AxisIndexStr = value.ToString();
         }
 
-        private MotionMode moveMode = MotionMode.Normal;
+        //private int axisIndex = 0;
+        //[Category("杩愬姩閰嶇疆")]
+        //[DisplayName("杩愬姩杞寸储寮�")]
+        //[Description("AxisIndex锛氳繍鍔ㄨ酱绱㈠紩")]
+        //[TypeConverter(typeof(AxisIndexConvert))]
+        //public int AxisIndex { get; set; }
+        //{
+        //    get => axisIndex;
+        //    set
+        //    {
+        //        if (axisIndex != value)
+        //        {
+        //            axisIndex = value;
+        //            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("AxisIndex"));
+        //        }
+        //        axisIndex = value;
+        //    }
+        //}
+
+        //private MotionMode moveMode = MotionMode.Normal;
         [Category("杩愬姩閰嶇疆")]
         [DisplayName("杩愬姩妯″紡")]
         [Description("MoveMode锛氳繍鍔ㄦā寮�")]
-        public MotionMode MoveMode
-        {
-            get => moveMode;
-            set
-            {
-                if (moveMode != value)
-                {
-                    moveMode = value;
-                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("MoveMode"));
-                }
+        public MotionMode MoveMode { get; set; } = MotionMode.Normal;
+        //{
+        //    get => moveMode;
+        //    set
+        //    {
+        //        if (moveMode != value)
+        //        {
+        //            moveMode = value;
+        //            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("MoveMode"));
+        //        }
 
-                moveMode = value;
-            }
-        }
+        //        moveMode = value;
+        //    }
+        //}
 
-        private bool isAbsolute = true;
+        //private bool isAbsolute = true;
         [Category("杩愬姩閰嶇疆")]
         [DisplayName("鏄惁缁濆杩愬姩")]
         [Description("IsAbsolute锛氭槸鍚︾粷瀵硅繍鍔�")]
-        public bool IsAbsolute
-        {
-            get => isAbsolute;
-            set
-            {
-                if (isAbsolute != value)
-                {
-                    isAbsolute = value;
-                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsAbsolute"));
-                }
+        public bool IsAbsolute { get; set; } = true;
+        //{
+        //    get => isAbsolute;
+        //    set
+        //    {
+        //        if (isAbsolute != value)
+        //        {
+        //            isAbsolute = value;
+        //            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsAbsolute"));
+        //        }
 
-                isAbsolute = value;
-            }
-        }
+        //        isAbsolute = value;
+        //    }
+        //}
 
-        private int destination = 0;
+        //private int destination = 0;
         [Category("杩愬姩閰嶇疆")]
         [DisplayName("鐩殑鍦�")]
         [Description("Destination锛氱洰鐨勫湴")]
-        public int Destination
-        {
-            get => destination;
-            set
-            {
-                if (destination != value)
-                {
-                    destination = value;
-                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Destination"));
-                }
+        public int Destination { get; set; }
+        //{
+        //    get => destination;
+        //    set
+        //    {
+        //        if (destination != value)
+        //        {
+        //            destination = value;
+        //            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Destination"));
+        //        }
 
-                destination = value;
-            }
-        }
+        //        destination = value;
+        //    }
+        //}
 
-        private VelocityPara velocityPara = new VelocityPara();
+        //private VelocityPara velocityPara = new VelocityPara();
         [Category("杩愬姩閰嶇疆")]
         [DisplayName("閫熷害鍙傛暟")]
         [Description("VelocityPara锛氶�熷害鍙傛暟")]
         [TypeConverter(typeof(ComplexObjectConvert))]
         [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))]
-        public VelocityPara VelocityPara
-        {
-            get => velocityPara;
-            set
-            {
-                velocityPara = value;
-                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("VelocityPara"));
-            }
-        }
+        public VelocityPara VelocityPara { get; set; } = new VelocityPara();
+        //{
+        //    get => velocityPara;
+        //    set
+        //    {
+        //        velocityPara = value;
+        //        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("VelocityPara"));
+        //    }
+        //}
 
-        private GoHomePara goHomePara = new GoHomePara();
+        //private GoHomePara goHomePara = new GoHomePara();
         [Category("杩愬姩閰嶇疆")]
         [DisplayName("鍥炲師鐐瑰弬鏁�")]
         [Description("GoHomePara锛氶�熷害鍙傛暟")]
         [TypeConverter(typeof(ComplexObjectConvert))]
         [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))]
-        public GoHomePara GoHomePara
-        {
-            get => goHomePara;
-            set
-            {
-                goHomePara = value;
-                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("GoHomePara"));
-            }
-        }
+        public GoHomePara GoHomePara { get; set; } = new GoHomePara();
+        //{
+        //    get => goHomePara;
+        //    set
+        //    {
+        //        goHomePara = value;
+        //        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("GoHomePara"));
+        //    }
+        //}
 
         [Category("鏉垮崱杩愬姩閰嶇疆")]
         [Description("瓒呮椂璁剧疆锛屽崟浣嶏細ms")]
@@ -357,6 +373,7 @@
         public int MovingTimeout { get; set; } = 0;
 
         internal List<AxisSetting> _axisSettingList = new List<AxisSetting>();
+
         public void SetAxisSetting(List<AxisSetting> settings)
         {
             if (settings != null)
@@ -365,7 +382,7 @@
 
         public string GetDisplayText()
         {
-            string axisName = AxisIndex.ToString();
+            string axisName = AxisIndexStr;
             var axisSet = _axisSettingList.FirstOrDefault(a => a.AxisIndex == AxisIndex);
             if (axisSet != null)
             {
@@ -373,70 +390,113 @@
             }
             return axisName + "," + MoveMode.ToString() + "," + (IsAbsolute ? "Abs" : "Rel") + "," + Destination;
         }
-        public event PropertyChangedEventHandler PropertyChanged;
+        //public event PropertyChangedEventHandler PropertyChanged;
     }
 
-    public class AxisIndexConvert : TypeConverter
+    public class AxisIndexConvert : ComboBoxItemTypeConvert
     {
-        Dictionary<int, string> _indexNameDict = new Dictionary<int, string>();
-
-        public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
+        public override Hashtable GetConvertHash(ITypeDescriptorContext context)
         {
-            return true;
-        }
-
-        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
-        {
-            MovingOption mo = context.Instance as MovingOption;
-
-            _indexNameDict = mo._axisSettingList.ToDictionary(a => a.AxisIndex, a => a.AxisIndex + "-" + a.AxisName);
-
-            return new StandardValuesCollection(_indexNameDict.Keys);
-        }
-
-        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
-        {
-            if (sourceType == typeof(string))
+            Hashtable table = new Hashtable();
+            if (context.Instance is MovingOption op)
             {
-                return true;
-            }
-            return base.CanConvertFrom(context, sourceType);
-        }
-
-        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object v)
-        {
-            if (v is string)
-            {
-                foreach (var indexName in _indexNameDict)
+                op._axisSettingList.ForEach(a =>
                 {
-                    if (indexName.Value == v.ToString())
-                    {
-                        return indexName.Key;
-                    }
-                }
-                return Convert.ToInt32(v);
+                    table[a.AxisIndex.ToString()] = a.AxisName;
+                });
             }
-            return base.ConvertFrom(context, culture, v);
+
+            return table;
         }
 
-        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object v, Type destinationType)
-        {
-            if (destinationType == typeof(string))
-            {
-                if (_indexNameDict.ContainsKey(Convert.ToInt32(v)))
-                {
-                    return _indexNameDict[Convert.ToInt32(v)];
-                }
-            }
-            return base.ConvertTo(context, culture, v, destinationType);
-        }
+        //public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+        //{
+        //    bool flag = base.CanConvertFrom(context, sourceType);
+        //    return flag;
+        //}
 
-        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
-        {
-            return false;
-        }
+        //public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
+        //{
+        //    return base.CanConvertTo(context, destinationType);
+        //}
+
+        //public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object v)
+        //{
+        //    //if (string.IsNullOrWhiteSpace(v.ToString()))
+        //    //{
+        //    //    return 0;
+        //    //}
+
+        //    return base.ConvertFrom(context, culture, Convert.ToInt32(v));
+        //}
+
+        //public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object v, Type destinationType)
+        //{
+        //    return base.ConvertTo(context, culture, v, destinationType);
+        //}
     }
 
+    //public class AxisIndexConvert : TypeConverter
+    //{
+    //    Dictionary<int, string> _indexNameDict = new Dictionary<int, string>();
+
+    //    public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
+    //    {
+    //        return true;
+    //    }
+
+    //    public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
+    //    {
+    //        MovingOption mo = context.Instance as MovingOption;
+
+    //        _indexNameDict = mo._axisSettingList.ToDictionary(a => a.AxisIndex, a => a.AxisIndex + "-" + a.AxisName);
+
+    //        return new StandardValuesCollection(_indexNameDict.Keys);
+    //    }
+
+    //    public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+    //    {
+    //        if (sourceType == typeof(string))
+    //        {
+    //            return true;
+    //        }
+    //        return base.CanConvertFrom(context, sourceType);
+    //    }
+
+    //    public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object v)
+    //    {
+    //        if (v is string)
+    //        {
+    //            foreach (var indexName in _indexNameDict)
+    //            {
+    //                if (indexName.Value == v.ToString())
+    //                {
+    //                    return indexName.Key;
+    //                }
+    //            }
+    //            return Convert.ToInt32(v);
+    //        }
+    //        return base.ConvertFrom(context, culture, v);
+    //    }
+
+    //    public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object v, Type destinationType)
+    //    {
+    //        if (destinationType == typeof(string))
+    //        {
+    //            if (_indexNameDict.ContainsKey(Convert.ToInt32(v)))
+    //            {
+    //                return _indexNameDict[Convert.ToInt32(v)];
+    //            }
+    //        }
+    //        return base.ConvertTo(context, culture, v, destinationType);
+    //    }
+
+    //    public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
+    //    {
+    //        return false;
+    //    }
+    //}
+
     public class AxisConflictSet : IComplexDisplay
     {
         [Category("1.杞村啿绐佹潯浠�")]
diff --git a/src/Bro.Device.GTSCard/GTSCardDriver.cs b/src/Bro.Device.GTSCard/GTSCardDriver.cs
index 2d3d26e..ed10b08 100644
--- a/src/Bro.Device.GTSCard/GTSCardDriver.cs
+++ b/src/Bro.Device.GTSCard/GTSCardDriver.cs
@@ -162,7 +162,7 @@
             // 2.鏉垮崱杩愬姩
             if (CurrentState == DeviceState.DSOpen)
             {
-                responseMessage = MoveToPoint(operationSet.MotionOperationCollection);
+                responseMessage = MoveToPoint(new MotionOperationCollection() { MovingOps = operationSet.MovingOps });
                 if (!responseMessage.Result)
                 {
                     return responseMessage;
@@ -362,14 +362,15 @@
         {
             List<short> resultCode = new List<short>() { 0 };
             GTSCardAPI.TTrapPrm trapprm = new GTSCardAPI.TTrapPrm();
-            resultCode.Add(GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, (short)optionPara.AxisIndex));
-            resultCode.Add(GTSCardAPI.GT_GetTrapPrm((short)IConfig.CardNum, (short)optionPara.AxisIndex, out trapprm));
+            short axisIndex = short.Parse(optionPara.AxisIndexStr);
+            resultCode.Add(GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, axisIndex));
+            resultCode.Add(GTSCardAPI.GT_GetTrapPrm((short)IConfig.CardNum, axisIndex, out trapprm));
             trapprm.smoothTime = 1;
             trapprm.acc = optionPara.VelocityPara.Acc != 0 ? optionPara.VelocityPara.Acc : 1;
             trapprm.dec = optionPara.VelocityPara.Dec != 0 ? optionPara.VelocityPara.Dec : 1;
 
-            resultCode.Add(GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, (short)optionPara.AxisIndex, ref trapprm));
-            resultCode.Add(GTSCardAPI.GT_SetVel((short)IConfig.CardNum, (short)optionPara.AxisIndex, optionPara.VelocityPara.Velocity * IConfig.AxisVelocityRatio));
+            resultCode.Add(GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, axisIndex, ref trapprm));
+            resultCode.Add(GTSCardAPI.GT_SetVel((short)IConfig.CardNum, axisIndex, optionPara.VelocityPara.Velocity * IConfig.AxisVelocityRatio));
 
             var resultOK = resultCode.All(u => u == (short)GTSRetCode.GRCRunOK);
             if (!resultOK)
diff --git a/src/Bro.Device.Gocator/Bro.Device.Gocator.csproj b/src/Bro.Device.Gocator/Bro.Device.Gocator.csproj
index 43038f3..bdebec3 100644
--- a/src/Bro.Device.Gocator/Bro.Device.Gocator.csproj
+++ b/src/Bro.Device.Gocator/Bro.Device.Gocator.csproj
@@ -65,6 +65,9 @@
     <Reference Include="kApiNet">
       <HintPath>..\..\libs\gocator\kApiNet.dll</HintPath>
     </Reference>
+    <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Drawing" />
@@ -109,5 +112,8 @@
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
   </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>
\ No newline at end of file
diff --git a/src/Bro.Device.Gocator/GocatorDriver.cs b/src/Bro.Device.Gocator/GocatorDriver.cs
index 2a659df..8e0bef5 100644
--- a/src/Bro.Device.Gocator/GocatorDriver.cs
+++ b/src/Bro.Device.Gocator/GocatorDriver.cs
@@ -1,11 +1,13 @@
 锘縰sing Bro.Common.Base;
 using Bro.Common.Helper;
 using Bro.Common.Interface;
+using Bro.Common.Model;
 using HalconDotNet;
 using Lmi3d.GoSdk;
 using Lmi3d.GoSdk.Messages;
 using Lmi3d.Zen;
 using Lmi3d.Zen.Io;
+using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
 using System.Drawing;
@@ -114,6 +116,18 @@
                                 imgSet.HImage_2 = new HImage();
                                 imgSet.HImage_2.GenImage1("uint2", (int)width, zoomHeight, zoomPtr);
 
+                                LaserScanParam para = new LaserScanParam()
+                                {
+                                    Resolution_X = surfaceMsg.XResolution,
+                                    Resolution_Y = surfaceMsg.YResolution,
+                                    Resolution_Z = surfaceMsg.ZResolution,
+                                    Offset_X = surfaceMsg.XOffset,
+                                    Offset_Y = surfaceMsg.YOffset,
+                                    Offset_Z = surfaceMsg.ZOffset,
+                                    Angle_Z = surfaceMsg.ZAngle,
+                                };
+                                imgSet.ImageData = JsonConvert.SerializeObject(para);
+
                                 //imgSet.HImage_2 = imgSet.HImage_2.ZoomImageSize((int)width, zoomHeight, "constant");
                             }
 
diff --git a/src/Bro.Device.Gocator/packages.config b/src/Bro.Device.Gocator/packages.config
new file mode 100644
index 0000000..07e3593
--- /dev/null
+++ b/src/Bro.Device.Gocator/packages.config
@@ -0,0 +1,4 @@
+锘�<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net452" />
+</packages>
\ No newline at end of file
diff --git a/src/Bro.M071.Process/M071Process.cs b/src/Bro.M071.Process/M071Process.cs
index 1dea3b9..6b0702d 100644
--- a/src/Bro.M071.Process/M071Process.cs
+++ b/src/Bro.M071.Process/M071Process.cs
@@ -7,6 +7,7 @@
 using Bro.M071.Model.Model;
 using Bro.Process;
 using HalconDotNet;
+using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -221,11 +222,10 @@
                       if (camera == null)
                           return;
 
-                      string imgSetId = "";
-                      HImage hImage = null;
+                      IImageSet set = null;
                       try
                       {
-                          hImage = CollectHImage(camera, s.CameraOp.OpConfig, out imgSetId);
+                          set = CollectHImage(camera, s.CameraOp.OpConfig);
                       }
                       catch (ProcessException pEx)
                       {
@@ -233,12 +233,12 @@
                           throw pEx;
                       }
 
-                      if (string.IsNullOrWhiteSpace(imgSetId))
+                      if (set == null)
                       {
                           return;
                       }
 
-                      RunImageHandle(camera, s.CameraOp.OpConfig, hImage, s.Id, s.Name, pMeasure.Measurements);
+                      RunImageHandle(camera, s.CameraOp.OpConfig, set, s.Id, s.Name, pMeasure.Measurements);
                   });
 
             BarCode = "";
@@ -348,7 +348,7 @@
 
                                 IShapeElement indicator = null;
                                 pMeasure.ElementList.Add(indicator);
-                                //杈撳嚭鍥惧舰鍩哄厓鍒扮晫闈� todo
+                                //杈撳嚭鍥惧舰鍩哄厓鍒扮晫闈� 
                                 OnElementUpdated?.BeginInvoke(indicator, null, null);
 
                                 SaveKeyImages(pMeasure.Barcode, m);
@@ -617,7 +617,7 @@
         }
         #endregion
 
-        private async void RunImageHandle(CameraBase camera, IOperationConfig opConfig, HImage hImage, string snapshotId, string snapshotName, List<MeasurementUnit> measureList)
+        private async void RunImageHandle(CameraBase camera, IOperationConfig opConfig, IImageSet imgSet, string snapshotId, string snapshotName, List<MeasurementUnit> measureList)
         {
             await Task.Run(() =>
              {
@@ -625,7 +625,8 @@
                  var keyBindCollection = measureList.SelectMany(u => u.KeyUnitCollection).Where(u => keys.Any(k => k.Key == u.Key)).ToList();
 
                  string toolKey = (opConfig as CameraOprerationConfigBase).AlgorithemPath;
-                 HObject images = hImage;
+                 HObject images = imgSet.HImage;
+                 LaserScanParam scanParam = JsonConvert.DeserializeObject<LaserScanParam>(imgSet.ImageData);
 
                  if (!string.IsNullOrWhiteSpace(toolKey))
                  {
@@ -637,7 +638,7 @@
                          return;
                      }
 
-                     _halconToolDict[toolKey].InputImageDic["INPUT_Image"] = hImage;
+                     _halconToolDict[toolKey].InputImageDic["INPUT_Image"] = imgSet.HImage;
                      if (!_halconToolDict[toolKey].RunProcedure(out string error))
                      {
                          LogAsync(DateTime.Now, $"{snapshotName}鍙栧浘绠楁硶寮傚父锛寋error}", "");
@@ -685,6 +686,8 @@
                              else
                              {
                                  _halconToolDict[keyToolKey].InputImageDic["INPUT_Image"] = image;
+                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_X"] = scanParam.Resolution_X;
+                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_Z"] = scanParam.Resolution_Z;
                                  if (!_halconToolDict[keyToolKey].RunProcedure(out string error))
                                  {
                                      LogAsync(DateTime.Now, $"{k.AliasName}妫�娴嬬畻娉曞紓甯革紝{error}", "");
@@ -717,11 +720,11 @@
                      image.Dispose();
                  });
 
-                 if (count.I != 1)
-                 {
-                     hImage?.Dispose();
-                     hImage = null;
-                 }
+                 //if (count.I != 1)
+                 //{
+                 //    hImage?.Dispose();
+                 //    hImage = null;
+                 //}
              });
         }
         #endregion
diff --git a/src/Bro.Process/ProcessControl.cs b/src/Bro.Process/ProcessControl.cs
index 948b3c0..afbc38d 100644
--- a/src/Bro.Process/ProcessControl.cs
+++ b/src/Bro.Process/ProcessControl.cs
@@ -626,7 +626,7 @@
         #endregion
 
         #region 鍥惧儚澶勭悊
-        protected HImage CollectHImage(CameraBase camera, IOperationConfig opConfig, out string imgSetId, [CallerMemberName]string methodCode = "")
+        protected IImageSet CollectHImage(CameraBase camera, IOperationConfig opConfig, [CallerMemberName]string methodCode = "")
         {
             IImageSet set = null;
 
@@ -675,8 +675,7 @@
                 TimeRecordCSV(DateTime.Now, camera.Name, methodCode + "閲囧浘", (int)sw.ElapsedMilliseconds);
             }
 
-            imgSetId = set?.Id;
-            return set.HImage;
+            return set;
         }
 
         protected async void CameraUpdateImage(CameraBase camera, Bitmap image, string setId)
diff --git a/src/Bro.Process/ProcessControl_Calibration.cs b/src/Bro.Process/ProcessControl_Calibration.cs
index 9463056..1d7a0e4 100644
--- a/src/Bro.Process/ProcessControl_Calibration.cs
+++ b/src/Bro.Process/ProcessControl_Calibration.cs
@@ -107,7 +107,12 @@
         {
             //string imgSetId = "";
             List<IShapeElement> pointList = new List<IShapeElement>();
-            using (HObject hImage = CollectHImage(camera, config.CameraOpConfig, out string imgSetId))
+
+            IImageSet set = CollectHImage(camera, config.CameraOpConfig);
+            if (set == null)
+                return;
+
+            using (HObject hImage = set.HImage)
             {
                 var tool = GetHalconTool(config.CameraOpConfig);
 
@@ -125,7 +130,7 @@
                     pointList.Add(new PointIndicator((float)xList[i], (float)yList[i]));
                 }
 
-                camera.SaveFitImage(pointList, imgSetId);
+                camera.SaveFitImage(pointList, set.Id);
             }
 
             config.Results[sequence - 1].ImageMarkPoint = new CustomizedPoint((pointList[0] as PointIndicator).Center);

--
Gitblit v1.8.0