From aeae986de8bed7dbae02d3632cda82f291fff0ec Mon Sep 17 00:00:00 2001 From: wells <123> Date: 星期六, 11 七月 2020 16:59:04 +0800 Subject: [PATCH] 固高板卡配置输出ProcessException --- src/Bro.Device.GTSCard/GTSCardDriver.cs | 74 ++++++++++++++++++++++--------------- 1 files changed, 44 insertions(+), 30 deletions(-) diff --git a/src/Bro.Device.GTSCard/GTSCardDriver.cs b/src/Bro.Device.GTSCard/GTSCardDriver.cs index 85c4e5f..a09fda2 100644 --- a/src/Bro.Device.GTSCard/GTSCardDriver.cs +++ b/src/Bro.Device.GTSCard/GTSCardDriver.cs @@ -269,7 +269,7 @@ ClearStatus(1, IConfig.AxisSettings.FindAll(u => u.IsAxisEnabled).Count); if (res != (short)GTSRetCode.GRCRunOK) { - throw new Exception("鏉垮崱杞藉叆閰嶇疆鏂囦欢寮傚父锛岄敊璇爜锛�" + res); + throw new ProcessException("鏉垮崱杞藉叆閰嶇疆鏂囦欢寮傚父锛岄敊璇爜锛�" + res); } } @@ -377,7 +377,7 @@ var resultOK = resultCode.All(u => u == (short)GTSRetCode.GRCRunOK); if (!resultOK) { - throw new Exception("杞�" + optionPara.AxisIndex + "璁剧疆鍙傛暟寮傚父锛岄敊璇爜锛�" + string.Join(",", resultCode)); + throw new ProcessException("杞�" + optionPara.AxisIndex + "璁剧疆鍙傛暟寮傚父锛岄敊璇爜锛�" + string.Join(",", resultCode)); } return resultOK; } @@ -461,7 +461,7 @@ var ret = GTSCardAPI.GT_GetPrfPos((short)IConfig.CardNum, (short)axisNum, out prfpos, 1, out pclock); if (ret != (short)GTSRetCode.GRCRunOK) { - throw new Exception("杞�" + axisNum + "鑾峰彇瑙勫垝浣嶇疆寮傚父锛岄敊璇爜锛�" + ret); + throw new ProcessException("杞�" + axisNum + "鑾峰彇瑙勫垝浣嶇疆寮傚父锛岄敊璇爜锛�" + ret); } //var AxisRatio = IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == axisNum) == null ? 1 : IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == axisNum).AxisRatio; position = prfpos; @@ -482,7 +482,7 @@ var ret = GTSCardAPI.GT_GetPrfPos((short)IConfig.CardNum, (short)axisNum, out pPos, 1, out uint pclock); if (ret != (short)GTSRetCode.GRCRunOK) { - throw new Exception("杞�" + axisNum + "鑾峰彇鐩爣浣嶇疆寮傚父锛岄敊璇爜锛�" + ret); + throw new ProcessException("杞�" + axisNum + "鑾峰彇鐩爣浣嶇疆寮傚父锛岄敊璇爜锛�" + ret); } //var AxisRatio = IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == axisNum) == null ? 1 : IConfig.AxisSettings.FirstOrDefault(u => u.AxisIndex == axisNum).AxisRatio; position = pPos; @@ -502,7 +502,7 @@ var ret = GTSCardAPI.GT_GetPrfVel((short)IConfig.CardNum, (short)axisNum, out prfVel, 1, out pclock); if (ret != (short)GTSRetCode.GRCRunOK) { - throw new Exception("杞�" + axisNum + "鑾峰彇瑙勫垝閫熷害寮傚父锛岄敊璇爜锛�" + ret); + throw new ProcessException("杞�" + axisNum + "鑾峰彇瑙勫垝閫熷害寮傚父锛岄敊璇爜锛�" + ret); } return prfVel; } @@ -518,7 +518,7 @@ var ret = GTSCardAPI.GT_GetVel((short)IConfig.CardNum, (short)axisNum, out vel); if (ret != (short)GTSRetCode.GRCRunOK) { - throw new Exception("杞�" + axisNum + "鑾峰彇褰撳墠閫熷害寮傚父锛岄敊璇爜锛�" + ret); + throw new ProcessException("杞�" + axisNum + "鑾峰彇褰撳墠閫熷害寮傚父锛岄敊璇爜锛�" + ret); } return vel; } @@ -576,7 +576,7 @@ if (_isResetting) { LogAsync(DateTime.Now, "澶嶄綅杩囩▼寮傚父", "杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄥ浣嶈繃绋嬩腑杩愬姩"); - throw new Exception("杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄥ浣嶈繃绋嬩腑杩愬姩"); + throw new ProcessException("杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄥ浣嶈繃绋嬩腑杩愬姩"); } int repeatTime = 30; @@ -595,7 +595,7 @@ if (CurrentState != EnumHelper.DeviceState.DSOpen) { LogAsync(DateTime.Now, "闈炴甯哥姸鎬佸紓甯�", "杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄩ潪姝e父鐘舵�佽繍鍔�"); - throw new Exception("杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄩ潪姝e父鐘舵�佽繍鍔�", null); + throw new ProcessException("杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄩ潪姝e父鐘舵�佽繍鍔�", null); } LogAsync(DateTime.Now, "杞�" + optionPara.AxisIndex + "寮�濮嬭繍鍔�", "鐩爣鍧愭爣锛�" + optionPara.Destination); @@ -609,7 +609,7 @@ { //璁剧疆 杩愬姩鍙傛暟 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) @@ -657,7 +657,7 @@ if (_isResetting) { LogAsync(DateTime.Now, "澶嶄綅杩囩▼寮傚父", "杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄥ浣嶈繃绋嬩腑杩愬姩"); - throw new Exception("杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄥ浣嶈繃绋嬩腑杩愬姩"); + throw new ProcessException("杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄥ浣嶈繃绋嬩腑杩愬姩"); } int repeatTime = 30; while (CurrentState != EnumHelper.DeviceState.DSOpen && repeatTime > 0) @@ -674,7 +674,7 @@ if (CurrentState != EnumHelper.DeviceState.DSOpen) { LogAsync(DateTime.Now, "闈炴甯哥姸鎬佸紓甯�", "杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄩ潪姝e父鐘舵�佽繍鍔�"); - throw new Exception("杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄩ潪姝e父鐘舵�佽繍鍔�", null); + throw new ProcessException("杞�" + optionPara.AxisIndex + "璇曞浘鍦ㄩ潪姝e父鐘舵�佽繍鍔�", null); } LogAsync(DateTime.Now, "杞�" + optionPara.AxisIndex + "寮�濮嬭繍鍔�", "鐩爣鍧愭爣锛�" + optionPara.Destination); short ret = 0; @@ -685,7 +685,7 @@ { //璁剧疆 杩愬姩鍙傛暟 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) @@ -738,7 +738,7 @@ if (ret != (short)GTSRetCode.GRCRunOK) { LogAsync(DateTime.Now, "杞�" + axisNum + "杩愬姩鍋滄寮傚父", "閿欒鐮侊細" + ret); - throw new Exception("杞�" + axisNum + "杩愬姩鍋滄寮傚父锛岄敊璇爜锛�" + ret); + throw new ProcessException("杞�" + axisNum + "杩愬姩鍋滄寮傚父锛岄敊璇爜锛�" + ret); } else { @@ -863,29 +863,42 @@ 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 ProcessException($"杩愬姩杞磠movingOption.AxisIndex} 锛屽洖鍘熺偣瓒呮椂寮傚父"); + } + if (isStop && capture != 1) + { + + ClearStatus((short)movingOption.AxisIndex, 1); + throw new ProcessException($"杩愬姩杞磠movingOption.AxisIndex} 锛屽洖鍘熺偣瓒呮椂寮傚父"); + } + + if (capture == 1) + { + //鍏坰top + MoveStop((short)movingOption.AxisIndex, 0); + ClearStatus((short)movingOption.AxisIndex, 1); //宸茬粡鎹曡幏鍒癏ome鎵嶅彲浠ュ洖闆� 闃舵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 { @@ -893,6 +906,7 @@ isStop = IsStop((short)movingOption.AxisIndex); repeatTime--; } while (!isStop && repeatTime > 0); + PositionReset(movingOption.AxisIndex, 1); return (sRtn == (short)GTSRetCode.GRCRunOK) && isStop; } return false; -- Gitblit v1.8.0