领胜LDS 键盘AOI检测项目
板卡回原点配置迁移到初始配置轴配置中
板卡回原点配置区分运动方向和捕捉方向,限制捕捉原点方向
3个文件已修改
102 ■■■■ 已修改文件
src/Bro.Common.Model/Model/MotionCardRelated.cs 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Device.GTSCard/GTSCardDriver.cs 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.M071.Process/M071Process.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Bro.Common.Model/Model/MotionCardRelated.cs
@@ -86,6 +86,13 @@
        //[Description("IsUseWarning:是否启用报警")]
        //public bool IsUseWarning { get; set; } = false;
        [Category("原点配置")]
        [DisplayName("回原点参数")]
        [Description("回原点参数")]
        [TypeConverter(typeof(ComplexObjectConvert))]
        [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))]
        public GoHomePara GoHomePara { get; set; } = new GoHomePara();
        [Category("暂停配置")]
        [DisplayName("是否启用立即暂停")]
        [Description("IsImmediatePause:是否启用立即暂停")]
@@ -154,25 +161,19 @@
        [Category("回原点参数")]
        [DisplayName("回原点方式")]
        [Description("HomeMode:回原点方式 (HOME_MODE_LIMIT = 10; HOME_MODE_LIMIT_HOME = 11; HOME_MODE_LIMIT_INDEX = 12; HOME_MODE_LIMIT_HOME_INDEX = 13;HOME_MODE_HOME = 20;HOME_MODE_HOME_INDEX = 22;HOME_MODE_INDEX = 30;")]
        public short HomeMode { get; set; } = 11;
        [Category("回原点参数")]
        [DisplayName("回原点方向")]
        [Description("HomeDir:1 正向,-1 负向")]
        public short HomeDir { get; set; } = 1;
        public short HomeMode { get; set; } = 11;
        [Category("回原点参数")]
        [DisplayName("边缘")]
        [Description("edge:边缘")]
        public short Edge { get; set; } = 0;
        [Category("回原点参数")]
        [Category("回原点速度")]
        [DisplayName("回原点最低速度")]
        [Description("LowVelocity:速度,为0时表示不修改当前设置")]
        public double LowVelocity { get; set; } = 50;
        [Category("回原点参数")]
        [Category("回原点速度")]
        [DisplayName("回原点最高速度")]
        [Description("HighVelocity:速度,为0时表示不修改当前设置")]
        public double HighVelocity { get; set; } = 50;
@@ -182,16 +183,30 @@
        //[Description("SearchHomeDistance:搜索距离")]
        //public int SearchHomeDistance { get; set; } = 9999999;
        [Category("回原点参数")]
        [Category("回原点偏移")]
        [DisplayName("偏移距离")]
        [Description("HomeOffset:偏移距离")]
        public int HomeOffset { get; set; } = 0;
        [Category("回原点参数")]
        [Category("回原点偏移")]
        [DisplayName("跳过步长")]
        [Description("EscapeStep:跳过步长")]
        public int EscapeStep { get; set; } = 1000;
        [Category("回原点方向")]
        [DisplayName("起始运动方向")]
        [Description("回原点时,轴的初始运动方向:true 正向,false 负向")]
        public bool IsHomeDirPositive { get; set; } = true;
        [Category("回原点方向")]
        [DisplayName("原点捕捉方向")]
        [Description("捕捉原点时,轴的运动方向:true 正向,false 负向")]
        public bool IsCaptureDirPositive { get; set; } = true;
        [Category("回原点超时")]
        [DisplayName("回原点超时")]
        [Description("回原点超时,单位秒")]
        public int GoHomeTimeOut { get; set; } = 60;
    }
    /// <summary>
@@ -352,12 +367,12 @@
        //}
        //private GoHomePara goHomePara = new GoHomePara();
        [Category("运动配置")]
        [DisplayName("回原点参数")]
        [Description("GoHomePara:速度参数")]
        [TypeConverter(typeof(ComplexObjectConvert))]
        [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))]
        public GoHomePara GoHomePara { get; set; } = new GoHomePara();
        //[Category("运动配置")]
        //[DisplayName("回原点参数")]
        //[Description("GoHomePara:速度参数")]
        //[TypeConverter(typeof(ComplexObjectConvert))]
        //[Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))]
        //public GoHomePara GoHomePara { get; set; } = new GoHomePara();
        //{
        //    get => goHomePara;
        //    set
src/Bro.Device.GTSCard/GTSCardDriver.cs
@@ -888,7 +888,11 @@
        {
            try
            {
                StartCapture:
                var goHomePara = IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == movingOption.AxisIndex).GoHomePara;
                bool homeDirection = goHomePara.IsHomeDirPositive;
                bool isRightLimitReached = false;
            StartCapture:
                PositionReset(movingOption.AxisIndex, 1);
                ClearStatus(movingOption.AxisIndex, 1);
@@ -907,24 +911,24 @@
                // 设置点位模式运动参数
                sRtn = GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, (short)movingOption.AxisIndex, ref trapPrm);
                // 设置点位模式目标速度,即回原点速度
                sRtn = GTSCardAPI.GT_SetVel((short)IConfig.CardNum, (short)movingOption.AxisIndex, movingOption.GoHomePara.HighVelocity);
                sRtn = GTSCardAPI.GT_SetVel((short)IConfig.CardNum, (short)movingOption.AxisIndex, goHomePara.HighVelocity);
                // 设置点位模式目标位置,即原点搜索距离
                sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, movingOption.GoHomePara.HomeDir == 1 ? 99999999 : -99999999);
                sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, homeDirection ? 99999999 : -99999999);
                // 启动运动
                sRtn = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (movingOption.AxisIndex - 1));
                int repeatTime = 1000;
                int repeatTime = goHomePara.GoHomeTimeOut * 1000;
                short capture;
                int pos;
                uint clk;//时钟参数
                do
                {
                    Thread.Sleep(20);
                    Thread.Sleep(IConfig.MonitorInterval);
                    // 读取捕获状态
                    GTSCardAPI.GT_GetCaptureStatus((short)IConfig.CardNum, (short)movingOption.AxisIndex, out capture, out pos, 1, out clk);
                    isStop = IsStop((short)movingOption.AxisIndex);
                    repeatTime--;
                    repeatTime -= IConfig.MonitorInterval;
                } while (!(isStop || capture == 1 || repeatTime <= 0));
                if (repeatTime <= 0)
@@ -941,7 +945,22 @@
                    if (((axisStatus.AxisStatus & 0x20) != 0) || ((axisStatus.AxisStatus & 0x40) != 0))
                    {
                        movingOption.GoHomePara.HomeDir = (short)(movingOption.GoHomePara.HomeDir == 1 ? -1 : 1);
                        //movingOption.GoHomePara.HomeDir = (short)(movingOption.GoHomePara.HomeDir == 1 ? -1 : 1);
                        //正限位
                        if ((axisStatus.AxisStatus & 0x20) != 0 && !goHomePara.IsCaptureDirPositive)
                        {
                            isRightLimitReached = true;
                        }
                        //负限位
                        if ((axisStatus.AxisStatus & 0x40) != 0 && goHomePara.IsCaptureDirPositive)
                        {
                            isRightLimitReached = true;
                        }
                        homeDirection = !homeDirection;
                        goto StartCapture;
                    }
@@ -950,12 +969,18 @@
                if (capture == 1)
                {
                    if (!isRightLimitReached)
                    {
                        capture = 0;
                        goto StartCapture;
                    }
                    //先stop
                    MoveStop((short)movingOption.AxisIndex, 0);
                    ClearStatus((short)movingOption.AxisIndex, 1);
                    //已经捕获到Home才可以回零 阶段2
                    // 运动到"捕获位置+偏移量"
                    sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, pos + movingOption.GoHomePara.HomeOffset);
                    sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, pos + goHomePara.HomeOffset);
                    // 在运动状态下更新目标位置
                    sRtn = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (movingOption.AxisIndex - 1));
                    isStop = false;
src/Bro.M071.Process/M071Process.cs
@@ -272,7 +272,7 @@
                          return;
                      }
                      RunImageHandle(camera, s.CameraOp.OpConfig, set, s.Id, s.Name, pMeasure.Measurements);
                      RunImageHandle(s.CameraOp.OpConfig, set, s.Id, s.Name, pMeasure.Measurements);
                  });
            BarCode = "";
@@ -1027,7 +1027,7 @@
        }
        #endregion
        private async void RunImageHandle(CameraBase camera, IOperationConfig opConfig, IImageSet imgSet, string snapshotId, string snapshotName, List<MeasurementUnit> measureList)
        private async void RunImageHandle(IOperationConfig opConfig, IImageSet imgSet, string snapshotId, string snapshotName, List<MeasurementUnit> measureList)
        {
            await Task.Run(() =>
             {
@@ -1095,7 +1095,10 @@
                     HOperatorSet.SelectObj(images, out HObject image, i);
                     string fileName = Path.Combine(dir, $"{i}.tif");
                     image.ConvertHObjectToHImage().WriteImage("tiff", 0, fileName);
                     using (HImage temp = image.ConvertHObjectToHImage())
                     {
                         temp.WriteImage("tiff", 0, fileName);
                     }
                     keys.Where(u => u.ImageSeq == i).ToList().ForEach(k =>
                         {
@@ -1113,6 +1116,7 @@
                                 _halconToolDict[keyToolKey].InputImageDic["INPUT_Image"] = image;
                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_X"] = scanParam.Resolution_X / 1000000.0;
                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_Z"] = scanParam.Resolution_Z / 1000000.0;
                                 _halconToolDict[keyToolKey].InputTupleDic["INPUT_ImageId"] = $"{k.AliasName}_{DateTime.Now.ToString("HHmmssfff")}.tif";
                                 if (!_halconToolDict[keyToolKey].RunProcedure(out string error))
                                 {
                                     LogAsync(DateTime.Now, $"{k.AliasName}检测算法异常,{error}", "");
@@ -1144,7 +1148,7 @@
                             });
                         });
                     //image.Dispose();
                     image.Dispose();
                 }
                 //);