| | |
| | | { |
| | | //设置 运动参数 |
| | | isSuccessSetAxisParam = SetAxisParam(optionPara); |
| | | ret = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)optionPara.AxisIndex, (int)(dPosition * AxisRatio));// 设置目的位置 |
| | | ret = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)optionPara.AxisIndex, (int)(dPosition));// 设置目的位置 |
| | | ret = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (optionPara.AxisIndex - 1));//更新运动 |
| | | |
| | | if (ret != (short)GTSRetCode.GRCRunOK) |
| | |
| | | { |
| | | //设置 运动参数 |
| | | isSuccessSetAxisParam = SetAxisParam(optionPara); |
| | | ret = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)optionPara.AxisIndex, (int)(optionPara.Destination * AxisRatio));// 设置目标位置 |
| | | ret = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)optionPara.AxisIndex, (int)(optionPara.Destination));// 设置目标位置 |
| | | ret = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (optionPara.AxisIndex - 1));//更新运动 |
| | | |
| | | if (ret != (short)GTSRetCode.GRCRunOK) |
| | |
| | | sRtn = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (movingOption.AxisIndex - 1)); |
| | | |
| | | int repeatTime = 1000; |
| | | short capture; |
| | | int pos; |
| | | uint clk;//时钟参数 |
| | | do |
| | | { |
| | | Thread.Sleep(20); |
| | | isStop = IsStop((short)movingOption.AxisIndex); |
| | | repeatTime--; |
| | | } while (!isStop && repeatTime > 0); |
| | | |
| | | if (isStop) |
| | | { |
| | | short capture; |
| | | int pos; |
| | | uint clk;//时钟参数 |
| | | // 读取捕获状态 |
| | | GTSCardAPI.GT_GetCaptureStatus((short)IConfig.CardNum, (short)movingOption.AxisIndex, out capture, out pos, 1, out clk); |
| | | isStop = IsStop((short)movingOption.AxisIndex); |
| | | repeatTime--; |
| | | } while (!(isStop || capture == 1 || repeatTime <= 0)); |
| | | |
| | | if (repeatTime <= 0) |
| | | { |
| | | MoveStop((short)movingOption.AxisIndex, 0); |
| | | throw new Exception($"运动轴{movingOption.AxisIndex} ,回原点超时异常"); |
| | | } |
| | | if (isStop && capture != 1) |
| | | { |
| | | |
| | | ClearStatus((short)movingOption.AxisIndex, 1); |
| | | throw new Exception($"运动轴{movingOption.AxisIndex} ,回原点超时异常"); |
| | | } |
| | | |
| | | if (capture == 1) |
| | | { |
| | | //先stop |
| | | MoveStop((short)movingOption.AxisIndex, 0); |
| | | ClearStatus((short)movingOption.AxisIndex, 1); |
| | | //已经捕获到Home才可以回零 阶段2 |
| | | if (capture == 1) |
| | | { |
| | | // 运动到"捕获位置+偏移量" |
| | | sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, pos + movingOption.GoHomePara.HomeOffset); |
| | | // 在运动状态下更新目标位置 |
| | | sRtn = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (movingOption.AxisIndex - 1)); |
| | | isStop = false; |
| | | } |
| | | // 运动到"捕获位置+偏移量" |
| | | sRtn = GTSCardAPI.GT_SetPos((short)IConfig.CardNum, (short)movingOption.AxisIndex, pos + movingOption.GoHomePara.HomeOffset); |
| | | // 在运动状态下更新目标位置 |
| | | sRtn = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (movingOption.AxisIndex - 1)); |
| | | isStop = false; |
| | | |
| | | repeatTime = 1000; |
| | | do |
| | | { |
| | |
| | | isStop = IsStop((short)movingOption.AxisIndex); |
| | | repeatTime--; |
| | | } while (!isStop && repeatTime > 0); |
| | | PositionReset(movingOption.AxisIndex, 1); |
| | | return (sRtn == (short)GTSRetCode.GRCRunOK) && isStop; |
| | | } |
| | | return false; |