From 2edc3c54ba7a42d5e9bb9120b9881d418e6bd408 Mon Sep 17 00:00:00 2001 From: patrick.xu <patrick.xu@broconcentric.com> Date: 星期五, 13 八月 2021 09:38:29 +0800 Subject: [PATCH] 1. GTS回原点修改,避免来回 2. 添加单键测量结果补偿 3. 部分条件限制,日志修改 4. 来料检debug,添加退出条件判断 --- src/Bro.Device.GTSCard/GTSCardDriver.cs | 86 +++++++++++++++++++++++++++++------------- 1 files changed, 59 insertions(+), 27 deletions(-) diff --git a/src/Bro.Device.GTSCard/GTSCardDriver.cs b/src/Bro.Device.GTSCard/GTSCardDriver.cs index dbea577..14b4c25 100644 --- a/src/Bro.Device.GTSCard/GTSCardDriver.cs +++ b/src/Bro.Device.GTSCard/GTSCardDriver.cs @@ -312,7 +312,6 @@ } } - public override bool AllAxisOn() { List<Task<bool>> taskList = new List<Task<bool>>(); ; @@ -387,7 +386,7 @@ responseMessage.Result = resultList.All(u => u == true); if (!responseMessage.Result) { - responseMessage.Message = $"鐐逛綅杩愬姩寮傚父"; + responseMessage.Message = $"鐐逛綅杩愬姩寮傚父,杩愬姩缁撴灉锛歿string.Join(" ", resultList.Select(u => u ? "1" : "0"))}"; } } return responseMessage; @@ -400,24 +399,28 @@ /// <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) { @@ -427,9 +430,10 @@ 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); @@ -646,7 +650,9 @@ if (CurrentState != EnumHelper.DeviceState.DSOpen) { LogAsync(DateTime.Now, "闈炴甯哥姸鎬佸紓甯�", "杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄩ潪姝e父鐘舵�佽繍鍔�"); - throw new ProcessException("杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄩ潪姝e父鐘舵�佽繍鍔�", null); + + return false; + //throw new ProcessException("杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄩ潪姝e父鐘舵�佽繍鍔�", null); } LogAsync(DateTime.Now, "杞�" + optionPara.AxisIndex + "寮�濮嬭繍鍔�", "鐩爣鍧愭爣锛�" + optionPara.Destination); @@ -725,8 +731,11 @@ if (CurrentState != EnumHelper.DeviceState.DSOpen) { LogAsync(DateTime.Now, "闈炴甯哥姸鎬佸紓甯�", "杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄩ潪姝e父鐘舵�佽繍鍔�"); - throw new ProcessException("杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄩ潪姝e父鐘舵�佽繍鍔�", null); + + return false; + //throw new ProcessException("杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄩ潪姝e父鐘舵�佽繍鍔�", null); } + LogAsync(DateTime.Now, "杞�" + optionPara.AxisIndex + "寮�濮嬭繍鍔�", "鐩爣鍧愭爣锛�" + optionPara.Destination); short ret = 0; bool isSuccessSetAxisParam = false; @@ -760,7 +769,14 @@ 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) { @@ -783,7 +799,8 @@ bool isStop = false; if (option == 1) { - StateChange(EnumHelper.DeviceState.DSExcept); + //StateChange(EnumHelper.DeviceState.DSExcept); + LogAsync(DateTime.Now, "鎬ュ仠鍋滄", ""); } var ret = GTSCardAPI.GT_Stop((short)IConfig.CardNum, 1 << (axisNum - 1), option); if (ret != (short)GTSRetCode.GRCRunOK) @@ -981,18 +998,26 @@ capture = 0; //姝i檺浣� - 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}鏋侀檺浣嶇疆鎹㈠悜", ""); } @@ -1044,6 +1069,10 @@ AllMoveStop(true); OnExceptionOccured?.Invoke(DateTime.Now, ex); return false; + } + finally + { + } } @@ -1224,7 +1253,9 @@ } }); - _positionWait.SpinOnce(); + Task.Delay(100).Wait(); + + //_positionWait.SpinOnce(); } catch (Exception ex) { @@ -1261,7 +1292,8 @@ } }); - _statusWait.SpinOnce(); + Thread.Sleep(10); + //Task.Delay(10).Wait(); } catch (Exception ex) { -- Gitblit v1.8.0