| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public override bool AllAxisOn() |
| | | { |
| | | List<Task<bool>> taskList = new List<Task<bool>>(); ; |
| | |
| | | responseMessage.Result = resultList.All(u => u == true); |
| | | if (!responseMessage.Result) |
| | | { |
| | | responseMessage.Message = $"点位运动异常"; |
| | | responseMessage.Message = $"点位运动异常,运动结果:{string.Join(" ", resultList.Select(u => u ? "1" : "0"))}"; |
| | | } |
| | | } |
| | | return responseMessage; |
| | |
| | | /// <returns></returns> |
| | | private bool SetAxisParam(MovingOption optionPara) |
| | | { |
| | | List<short> resultCode = new List<short>() { 0 }; |
| | | List<short> resultCode = new List<short>(); |
| | | GTSCardAPI.TTrapPrm trapprm = new GTSCardAPI.TTrapPrm(); |
| | | 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; |
| | | |
| | | if (optionPara.VelocityPara.Acc != 0) |
| | | if (optionPara.VelocityPara.Acc != 0 || optionPara.VelocityPara.Dec != 0) |
| | | { |
| | | trapprm.acc = optionPara.VelocityPara.Acc; |
| | | } |
| | | resultCode.Add(GTSCardAPI.GT_GetTrapPrm((short)IConfig.CardNum, axisIndex, out trapprm)); |
| | | trapprm.smoothTime = 1; |
| | | |
| | | if (optionPara.VelocityPara.Dec != 0) |
| | | { |
| | | trapprm.dec = optionPara.VelocityPara.Dec; |
| | | } |
| | | if (optionPara.VelocityPara.Acc != 0) |
| | | { |
| | | trapprm.acc = optionPara.VelocityPara.Acc; |
| | | } |
| | | |
| | | resultCode.Add(GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, axisIndex, ref trapprm)); |
| | | if (optionPara.VelocityPara.Dec != 0) |
| | | { |
| | | trapprm.dec = optionPara.VelocityPara.Dec; |
| | | } |
| | | |
| | | resultCode.Add(GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, axisIndex, ref trapprm)); |
| | | } |
| | | |
| | | if (optionPara.VelocityPara.Velocity != 0) |
| | | { |
| | |
| | | var resultOK = resultCode.All(u => u == (short)GTSRetCode.GRCRunOK); |
| | | if (!resultOK) |
| | | { |
| | | throw new ProcessException("轴" + optionPara.AxisIndex + "设置参数异常,错误码:" + string.Join(",", resultCode)); |
| | | //throw new ProcessException("轴" + optionPara.AxisIndex + "设置参数异常,错误码:" + string.Join(",", resultCode)); |
| | | LogAsync(DateTime.Now, $"轴{optionPara.AxisIndex}设置参数异常,错误码:{string.Join(",", resultCode)}", ""); |
| | | } |
| | | return resultOK; |
| | | return true; |
| | | } |
| | | |
| | | TaskFactory taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.LongRunning); |
| | |
| | | repeatTime--; |
| | | } |
| | | |
| | | return (ret == (short)GTSRetCode.GRCRunOK) && isStop; |
| | | if (repeatTime <= 0) |
| | | { |
| | | LogAsync(DateTime.Now, "轴" + optionPara.AxisIndex + "APS_absolute_move未停止", ""); |
| | | return false; |
| | | } |
| | | |
| | | //return (ret == (short)GTSRetCode.GRCRunOK) && isStop; |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | capture = 0; |
| | | |
| | | //正限位 |
| | | if ((axisStatus.AxisStatus & 0x20) != 0 && !goHomePara.IsCaptureDirPositive) |
| | | if ((axisStatus.AxisStatus & 0x20) != 0) |
| | | { |
| | | isRightLimitReached = true; |
| | | homeDirection = false; |
| | | |
| | | if (!goHomePara.IsCaptureDirPositive) |
| | | { |
| | | isRightLimitReached = true; |
| | | } |
| | | } |
| | | |
| | | //负限位 |
| | | if ((axisStatus.AxisStatus & 0x40) != 0 && goHomePara.IsCaptureDirPositive) |
| | | if ((axisStatus.AxisStatus & 0x40) != 0) |
| | | { |
| | | isRightLimitReached = true; |
| | | } |
| | | homeDirection = true; |
| | | |
| | | homeDirection = !homeDirection; |
| | | if (goHomePara.IsCaptureDirPositive) |
| | | { |
| | | isRightLimitReached = true; |
| | | } |
| | | } |
| | | |
| | | LogAsync(DateTime.Now, $"轴{movingOption.AxisIndex}极限位置换向", ""); |
| | | } |
| | |
| | | AllMoveStop(true); |
| | | OnExceptionOccured?.Invoke(DateTime.Now, ex); |
| | | return false; |
| | | } |
| | | finally |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | }); |
| | | |
| | | _positionWait.SpinOnce(); |
| | | Task.Delay(100).Wait(); |
| | | |
| | | //_positionWait.SpinOnce(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | } |
| | | }); |
| | | |
| | | _statusWait.SpinOnce(); |
| | | Thread.Sleep(10); |
| | | //Task.Delay(10).Wait(); |
| | | } |
| | | catch (Exception ex) |
| | | { |