优化固高位置比较函数,改为二维触发的一维模式触发,支持2路高速IO同时触发,

master
lhiven 4 months ago
parent 0f7cf21a98
commit 3e9ec6a39e

@ -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;
}

Loading…
Cancel
Save