| | |
| | | /// <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); |