板卡回原点配置迁移到初始配置轴配置中
板卡回原点配置区分运动方向和捕捉方向,限制捕捉原点方向
| | |
| | | //[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:是否启用立即暂停")] |
| | |
| | | [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; |
| | |
| | | //[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> |
| | |
| | | //} |
| | | |
| | | //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 |
| | |
| | | { |
| | | 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); |
| | |
| | | // 设置点位模式运动参数 |
| | | 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) |
| | |
| | | |
| | | 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; |
| | | } |
| | | |
| | |
| | | |
| | | 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; |
| | |
| | | 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 = ""; |
| | |
| | | } |
| | | #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(() => |
| | | { |
| | |
| | | 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 => |
| | | { |
| | |
| | | _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}", ""); |
| | |
| | | }); |
| | | }); |
| | | |
| | | //image.Dispose(); |
| | | image.Dispose(); |
| | | } |
| | | //); |
| | | |