From edc408b6a1c09d7432369d22fcdfc6de924fe308 Mon Sep 17 00:00:00 2001 From: lhiven Date: Wed, 30 Oct 2024 08:35:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BA=E9=AB=98=E8=84=89=E5=86=B2=E5=8D=A1?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8E=9F=E5=9C=B0=E5=9C=A8=E9=AB=98=E9=80=9F?= =?UTF-8?q?=E5=8F=A3=E8=BE=93=E5=87=BA=E8=84=89=E5=86=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.Motion/GugaoPulse/GugaoPulseAxis.cs | 10 ++++++++-- Rs.Motion/GugaoPulse/GugaoPulseCardManager.cs | 14 ++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) 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}"); } }