From 3e9ec6a39eef7dff503625520f8857ca931b6189 Mon Sep 17 00:00:00 2001 From: lhiven Date: Wed, 11 Dec 2024 14:20:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BA=E9=AB=98=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E6=AF=94=E8=BE=83=E5=87=BD=E6=95=B0=EF=BC=8C=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E4=BA=8C=E7=BB=B4=E8=A7=A6=E5=8F=91=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E7=BB=B4=E6=A8=A1=E5=BC=8F=E8=A7=A6=E5=8F=91=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=812=E8=B7=AF=E9=AB=98=E9=80=9FIO=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.Motion/GugaoPulse/GugaoPulseAxis.cs | 48 ++++++++++++++++---------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/Rs.Motion/GugaoPulse/GugaoPulseAxis.cs b/Rs.Motion/GugaoPulse/GugaoPulseAxis.cs index a81ef71..d8300a7 100644 --- a/Rs.Motion/GugaoPulse/GugaoPulseAxis.cs +++ b/Rs.Motion/GugaoPulse/GugaoPulseAxis.cs @@ -1642,8 +1642,8 @@ namespace Rs.Motion.GugaoPulse public override ErrorCode SetPosCompare(ushort channel, double[] postions) { - apiResult = mc_pulse.GT_2DCompareStop((short)Config.CardId, (short)(channel - 1)); - if(apiResult!=0) + ErrorCode errCode = ClearCompare(channel); + if(errCode > ErrorCode.Ok) { LogHelper.Debug($"{apiResult} = mc_pulse.GT_2DCompareStop({(short)Config.CardId}, {(short)(channel - 1)});"); return ErrorCode.Fail; @@ -1744,11 +1744,11 @@ namespace Rs.Motion.GugaoPulse { _pStatus = 0; _pCount = 0; - apiResult = mc_pulse.GT_CompareStatus((short)Config.CardId, out _pStatus, out _pCount); - if(apiResult!= 0) - { - return ErrorCode.Fail; - } + //apiResult = mc_pulse.GT_CompareStatus((short)Config.CardId, out _pStatus, out _pCount); + //if(apiResult!= 0) + //{ + // return ErrorCode.Fail; + //} return ErrorCode.Ok; } @@ -1762,31 +1762,43 @@ namespace Rs.Motion.GugaoPulse value = (short)(1 << (channel - 1)); } - //ClearCompare(channel); - apiResult = mc_pulse.GT_CompareStop((short)Config.CardId); - LogHelper.Debug($"{apiResult} = mc_pulse.GT_CompareStop({(short)Config.CardId});"); - apiResult = mc_pulse.GT_ComparePulse((short)Config.CardId, (short)(1 << (channel - 1)), (short)(dp ? 1 : 0), (short)Config.HcmpPulseWidth); - if (apiResult != 0) + ClearCompare(channel); + apiResult = mc_pulse.GT_2DCompareMode((short)Config.CardId, (short)(channel - 1), mc_pulse.COMPARE2D_MODE_1D); + if(apiResult!=0) { - LogHelper.Debug($"{apiResult} = mc_pulse.GT_ComparePulse({(short)Config.CardId}, {(short)(1 << (channel - 1))}, {(short)(dp ? 1 : 0)}, {(short)Config.HcmpPulseWidth});"); - return ErrorCode.Fail; + LogHelper.Debug($"{apiResult} = mc_pulse.GT_2DCompareMode({(short)Config.CardId}, {(short)(channel - 1)}, {mc_pulse.COMPARE2D_MODE_1D});"); } else { - LogHelper.Debug($"{apiResult} = mc_pulse.GT_ComparePulse({(short)Config.CardId}, {(short)(1 << (channel - 1))}, {(short)(dp ? 1 : 0)}, {(short)Config.HcmpPulseWidth});"); + apiResult = mc_pulse.GT_2DComparePulse((short)Config.CardMc, (short)(channel - 1), 1, (short)(dp ? 1 : 0), (short)Config.HcmpPulseWidth); + //apiResult = mc_pulse.GT_ComparePulse((short)Config.CardId, (short)(1 << (channel - 1)), (short)(dp ? 1 : 0), (short)Config.HcmpPulseWidth); + if (apiResult != 0) + { + LogHelper.Debug($"{apiResult} = mc_pulse.GT_2DComparePulse({(short)Config.CardId}, {(short)(channel - 1)}, 1,{(short)(dp ? 1 : 0)}, {(short)Config.HcmpPulseWidth});"); + return ErrorCode.Fail; + } } + return ErrorCode.Ok; } public override ErrorCode ClearCompare(ushort uChannel) { - apiResult = mc_pulse.GT_2DCompareStop((short)Config.CardId,(short)(uChannel-1)); - //apiResult = mc_pulse.GT_CompareStop((short)Config.CardId); + apiResult = mc_pulse.GT_2DCompareStop((short)Config.CardId, (short)(uChannel - 1)); if (apiResult != 0) { - LogHelper.Debug($"{apiResult} = mc_pulse.GT_2DCompareStop({(short)Config.CardId},{(short)(uChannel-1)});"); + LogHelper.Debug($"{apiResult} = mc_pulse.GT_2DCompareStop({(short)Config.CardId},{(short)(uChannel - 1)});"); return ErrorCode.Fail; } + else + { + apiResult = mc_pulse.GT_2DCompareClear((short)Config.CardId, (short)(uChannel - 1)); + if (apiResult != 0) + { + LogHelper.Debug($"{apiResult} = mc_pulse.GT_2DCompareClear({(short)Config.CardId},{(short)(uChannel - 1)});"); + return ErrorCode.Fail; + } + } return ErrorCode.Ok; }