| | |
| | | // 2.板卡运动 |
| | | if (CurrentState == DeviceState.DSOpen) |
| | | { |
| | | responseMessage = MoveToPoint(operationSet.MotionOperationCollection); |
| | | responseMessage = MoveToPoint(new MotionOperationCollection() { MovingOps = operationSet.MovingOps }); |
| | | if (!responseMessage.Result) |
| | | { |
| | | return responseMessage; |
| | |
| | | { |
| | | List<short> resultCode = new List<short>() { 0 }; |
| | | GTSCardAPI.TTrapPrm trapprm = new GTSCardAPI.TTrapPrm(); |
| | | resultCode.Add(GTSCardAPI.GT_PrfTrap((short)IConfig.CardNum, (short)optionPara.AxisIndex)); |
| | | resultCode.Add(GTSCardAPI.GT_GetTrapPrm((short)IConfig.CardNum, (short)optionPara.AxisIndex, out trapprm)); |
| | | 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; |
| | | trapprm.acc = optionPara.VelocityPara.Acc != 0 ? optionPara.VelocityPara.Acc : 1; |
| | | trapprm.dec = optionPara.VelocityPara.Dec != 0 ? optionPara.VelocityPara.Dec : 1; |
| | | |
| | | resultCode.Add(GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, (short)optionPara.AxisIndex, ref trapprm)); |
| | | resultCode.Add(GTSCardAPI.GT_SetVel((short)IConfig.CardNum, (short)optionPara.AxisIndex, optionPara.VelocityPara.Velocity * IConfig.AxisVelocityRatio)); |
| | | resultCode.Add(GTSCardAPI.GT_SetTrapPrm((short)IConfig.CardNum, axisIndex, ref trapprm)); |
| | | resultCode.Add(GTSCardAPI.GT_SetVel((short)IConfig.CardNum, axisIndex, optionPara.VelocityPara.Velocity * IConfig.AxisVelocityRatio)); |
| | | |
| | | var resultOK = resultCode.All(u => u == (short)GTSRetCode.GRCRunOK); |
| | | if (!resultOK) |
| | |
| | | public override async Task<bool> SingleAxisMoving(MovingOption optionPara) |
| | | { |
| | | return await Task.Run(() => |
| | | { |
| | | { |
| | | axisImmediatePauseHandleDict[optionPara.AxisIndex].WaitOne(); |
| | | bool isSuccessAndStop = false; |
| | | try |
| | |
| | | { |
| | | throw new Exception("轴" + axisNum + "获取规划位置异常,错误码:" + ret); |
| | | } |
| | | position = prfpos / IConfig.AxisVelocityRatio; |
| | | var AxisRatio = IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == axisNum) == null ? 1 : IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == axisNum).AxisRatio; |
| | | position = prfpos / AxisRatio; |
| | | return position; |
| | | } |
| | | |
| | |
| | | { |
| | | throw new Exception("轴" + axisNum + "获取目标位置异常,错误码:" + ret); |
| | | } |
| | | position = pPos / IConfig.AxisVelocityRatio; |
| | | var AxisRatio = IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == axisNum) == null ? 1 : IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == axisNum).AxisRatio; |
| | | position = pPos / AxisRatio; |
| | | return position; |
| | | } |
| | | } |
| | |
| | | /// 获取规划速度 |
| | | /// </summary> |
| | | /// <param name="axisNum">Axis number</param> |
| | | /// <returns></returns> |
| | | /// <returns>速度脉冲</returns> |
| | | public double GetPrfVelocity(int axisNum) |
| | | { |
| | | double prfVel = 0; |
| | |
| | | { |
| | | throw new Exception("轴" + axisNum + "获取规划速度异常,错误码:" + ret); |
| | | } |
| | | prfVel = prfVel / IConfig.AxisVelocityRatio; |
| | | return prfVel; |
| | | } |
| | | |
| | |
| | | /// 获取当前速度 |
| | | /// </summary> |
| | | /// <param name="axisNum">Axis number</param> |
| | | /// <returns></returns> |
| | | /// <returns>速度脉冲</returns> |
| | | public double GetVelocity(int axisNum) |
| | | { |
| | | double vel = 0; |
| | |
| | | { |
| | | throw new Exception("轴" + axisNum + "获取当前速度异常,错误码:" + ret); |
| | | } |
| | | vel = vel / IConfig.AxisVelocityRatio; |
| | | return vel; |
| | | } |
| | | |
| | |
| | | int currentPosition = (int)GetPosition(optionPara.AxisIndex); |
| | | int dPosition = optionPara.Destination + currentPosition; |
| | | int timeout = optionPara.MovingTimeout; |
| | | var AxisRatio = IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == optionPara.AxisIndex) == null ? 1 : IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == optionPara.AxisIndex).AxisRatio; |
| | | while (CurrentState == DeviceState.DSOpen) |
| | | { |
| | | //设置 运动参数 |
| | | isSuccessSetAxisParam = SetAxisParam(optionPara); |
| | | ret = GTSCardAPI.GT_SetPrfPos((short)IConfig.CardNum, (short)optionPara.AxisIndex, (int)(dPosition * IConfig.AxisVelocityRatio));// 设置规划位置 |
| | | ret = GTSCardAPI.GT_SetPrfPos((short)IConfig.CardNum, (short)optionPara.AxisIndex, (int)(dPosition * AxisRatio));// 设置规划位置 |
| | | ret = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (optionPara.AxisIndex - 1));//更新运动 |
| | | |
| | | if (ret != (short)GTSRetCode.GRCRunOK) |
| | |
| | | short ret = 0; |
| | | bool isSuccessSetAxisParam = false; |
| | | int timeout = optionPara.MovingTimeout; |
| | | while (CurrentState == DeviceState.DSOpen&&!_isPause) |
| | | var AxisRatio = IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == optionPara.AxisIndex) == null ? 1 : IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == optionPara.AxisIndex).AxisRatio; |
| | | while (CurrentState == DeviceState.DSOpen && !_isPause) |
| | | { |
| | | //设置 运动参数 |
| | | isSuccessSetAxisParam = SetAxisParam(optionPara); |
| | | ret = GTSCardAPI.GT_SetPrfPos((short)IConfig.CardNum, (short)optionPara.AxisIndex, (int)(optionPara.Destination * IConfig.AxisVelocityRatio));// 设置规划位置 |
| | | ret = GTSCardAPI.GT_SetPrfPos((short)IConfig.CardNum, (short)optionPara.AxisIndex, (int)(optionPara.Destination * AxisRatio));// 设置规划位置 |
| | | ret = GTSCardAPI.GT_Update((short)IConfig.CardNum, 1 << (optionPara.AxisIndex - 1));//更新运动 |
| | | |
| | | if (ret != (short)GTSRetCode.GRCRunOK) |
| | |
| | | |
| | | public override void OnMethodInvoked(IAsyncResult ar) |
| | | { |
| | | MotionCardMonitorSet monitorSet = ar.AsyncState as MotionCardMonitorSet; |
| | | ProcessResponse resValues = monitorSet.Response; |
| | | if (resValues.ResultValue == (int)ReplyValue.IGNORE) |
| | | { |
| | | return; |
| | | } |
| | | //MotionCardMonitorSet monitorSet = ar.AsyncState as MotionCardMonitorSet; |
| | | //ProcessResponse resValues = monitorSet.Response; |
| | | //if (resValues.ResultValue == (int)ReplyValue.IGNORE) |
| | | //{ |
| | | // return; |
| | | //} |
| | | |
| | | Stopwatch sw = new Stopwatch(); |
| | | sw.Start(); |
| | | // 将指定IOItem写入板卡 |
| | | foreach (var replyIOData in monitorSet.ReplyIODatas) |
| | | { |
| | | //写入IO输出 |
| | | if (replyIOData.IOType == IOType.OUTPUT) |
| | | { |
| | | GTSCardAPI.GT_SetDoBit((short)IConfig.CardNum, GTSCardAPI.MC_GPI, (short)replyIOData.IONum, (short)replyIOData.Value); |
| | | } |
| | | // in只读不能写 |
| | | } |
| | | sw.Stop(); |
| | | LogAsync(DateTime.Now, $"{Name}反馈完成,耗时{sw.ElapsedMilliseconds}ms", $"{resValues.GetDisplayText()}"); |
| | | //Stopwatch sw = new Stopwatch(); |
| | | //sw.Start(); |
| | | //// 将指定IOItem写入板卡 |
| | | //foreach (var replyIOData in monitorSet.ReplyIODatas) |
| | | //{ |
| | | // //写入IO输出 |
| | | // if (replyIOData.IOType == IOType.OUTPUT) |
| | | // { |
| | | // GTSCardAPI.GT_SetDoBit((short)IConfig.CardNum, GTSCardAPI.MC_GPI, (short)replyIOData.IONum, (short)replyIOData.Value); |
| | | // } |
| | | // // in只读不能写 |
| | | //} |
| | | //sw.Stop(); |
| | | //LogAsync(DateTime.Now, $"{Name}反馈完成,耗时{sw.ElapsedMilliseconds}ms", $"{resValues.GetDisplayText()}"); |
| | | } |
| | | |
| | | protected void MonitorCheckAndInvoke(List<IOItem> tempNew, List<IOItem> tempOld) |