diff --git a/Rs.Motion/GugaoPulse/GugaoPulseAxis.cs b/Rs.Motion/GugaoPulse/GugaoPulseAxis.cs index f4f27a3..a590acd 100644 --- a/Rs.Motion/GugaoPulse/GugaoPulseAxis.cs +++ b/Rs.Motion/GugaoPulse/GugaoPulseAxis.cs @@ -1739,7 +1739,7 @@ namespace Rs.Motion.GugaoPulse public override ErrorCode ComparePulse(ushort channel,bool dp=true) { - + // LogHelper.Debug($"ComparePulse:{channel},{dp}"); //apiResult = mc_pulse.GT_2DComparePulse((short)Config.CardId, (short)(channel - 1), 1, 0, (short)Config.HcmpPulseWidth); short value = (short)channel; if (value != 0) @@ -1747,13 +1747,19 @@ namespace Rs.Motion.GugaoPulse value = (short)(1 << (channel - 1)); } - ClearCompare(channel); + //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) { LogHelper.Debug($"{apiResult} = mc_pulse.GT_ComparePulse({(short)Config.CardId}, {(short)(1 << (channel - 1))}, {(short)(dp ? 1 : 0)}, {(short)Config.HcmpPulseWidth});"); return ErrorCode.Fail; } + else + { + LogHelper.Debug($"{apiResult} = mc_pulse.GT_ComparePulse({(short)Config.CardId}, {(short)(1 << (channel - 1))}, {(short)(dp ? 1 : 0)}, {(short)Config.HcmpPulseWidth});"); + } return ErrorCode.Ok; } diff --git a/Rs.Motion/GugaoPulse/GugaoPulseCardManager.cs b/Rs.Motion/GugaoPulse/GugaoPulseCardManager.cs index 288a9b9..60202a7 100644 --- a/Rs.Motion/GugaoPulse/GugaoPulseCardManager.cs +++ b/Rs.Motion/GugaoPulse/GugaoPulseCardManager.cs @@ -12,6 +12,7 @@ using System.IO; using System.Linq; using System.Net.NetworkInformation; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace Rs.Motion.GugaoPulse @@ -110,7 +111,7 @@ namespace Rs.Motion.GugaoPulse //card.Init(); //cardDic.Add(ushort.Parse(row["cardid"].ToString()), card); //打开运动控制卡 - apiResult = mc_pulse.GT_Open(short.Parse(row["cardid"].ToString()), 0, 1); + apiResult = mc_pulse.GT_Open(short.Parse(row["cardid"].ToString()), 0, 0); if (apiResult != 0) { MessageQueue.Instance.Warn($"mc_pulse.GT_Open({short.Parse(row["cardid"].ToString())}, 0, 1);ret={apiResult}"); @@ -118,9 +119,10 @@ namespace Rs.Motion.GugaoPulse } else { + //加载配置文件 short cardid = short.Parse(row["cardid"].ToString()); - if(File.Exists($"gugao{cardid}.cfg")) + if (File.Exists($"gugao{cardid}.cfg")) { apiResult = mc_pulse.GT_LoadConfig(short.Parse(row["cardid"].ToString()), $"gugao{cardid}.cfg"); LogHelper.Debug($"加载固高配置文件gugao{cardid},ret={apiResult}"); @@ -128,13 +130,17 @@ namespace Rs.Motion.GugaoPulse MessageQueue.Instance.Insert($"mc_pulse.GT_Open({short.Parse(row["cardid"].ToString())}, 0, 1);ret={apiResult}"); } //清楚报警和限位 - apiResult = mc_pulse.GT_ClrSts(0, 1, 8); + apiResult = mc_pulse.GT_ClrSts(short.Parse(row["cardid"].ToString()), 1, 8); if (apiResult != 0) { return ErrorCode.Fail; } + else + { + LogHelper.Debug($"{apiResult} = mc_pulse.GT_ClrSts({short.Parse(row["cardid"].ToString())}, 1, 8);"); + } short value = 32767 * 5 / 10; - apiResult = mc_pulse.GT_SetDac(0, 11, ref value, 1); + apiResult = mc_pulse.GT_SetDac(short.Parse(row["cardid"].ToString()), 11, ref value, 1); MessageQueue.Instance.Insert($"GT_SetDac ret={apiResult}"); } }