From c61055ba0d9fe15abc2e52da81ca39fd78c94b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Tue, 16 Apr 2024 15:07:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E5=81=9C=E6=AD=A2=E4=BF=9D?= =?UTF-8?q?=E6=B8=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionSystem/Untils/Tool/UxTool.cs | 20 ++++++++++++---- ProductionSystem/Untils/Tool/Uy.cs | 32 ++++++++++++++++++-------- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/ProductionSystem/Untils/Tool/UxTool.cs b/ProductionSystem/Untils/Tool/UxTool.cs index f4ede11..44f229a 100644 --- a/ProductionSystem/Untils/Tool/UxTool.cs +++ b/ProductionSystem/Untils/Tool/UxTool.cs @@ -99,8 +99,8 @@ namespace ProductionSystem.Untils.Tool } - - public void Send() + + public string GetMsg(int num) { uint seep = uint.Parse((mo * 0.4).ToString()); Write = seep.ToString(); @@ -109,8 +109,13 @@ namespace ProductionSystem.Untils.Tool MFMsgVariable me = new MFMsgVariable(8); me.AddMotoralaLsb(0, 8, seep); - var by = me.GetByteDat(); - var sendMes = by.ToHex(" "); + return me.GetByteDat().ToHex(); + } + + public void Send() + { + + var sendMes = GetMsg(mo); Task.Run(() => { @@ -128,7 +133,12 @@ namespace ProductionSystem.Untils.Tool public void closeSend() { Exit = true; - Thread.Sleep(1000); + var sendMes = GetMsg(0); + for (int i = 0; i < 100; i++) + { + mfSerialInfo.SendMessage(sendMes); + } + Exit = true; Dispose(); } diff --git a/ProductionSystem/Untils/Tool/Uy.cs b/ProductionSystem/Untils/Tool/Uy.cs index 921fce1..bf475a8 100644 --- a/ProductionSystem/Untils/Tool/Uy.cs +++ b/ProductionSystem/Untils/Tool/Uy.cs @@ -105,15 +105,8 @@ namespace ProductionSystem.Untils.Tool public void Send() { - uint seep = uint.Parse((mo * 0.4).ToString()); - Write = seep.ToString(); - XTrace.WriteLine($"水泵Uy 第[{mo}-{com}]个 写入真实速度:{seep}"); - - MFMsgVariable me = new MFMsgVariable(8); - me.AddMotoralaLsb(8, 8, seep); - - var by = me.GetByteDat(); - var sendMes = by.ToHex(" "); + + var sendMes = GetMsg(mo); Task.Run(() => { @@ -125,11 +118,30 @@ namespace ProductionSystem.Untils.Tool } + + public string GetMsg(int num) + { + uint seep = uint.Parse((num * 0.4).ToString()); + Write = seep.ToString(); + XTrace.WriteLine($"水泵Uy 第[{mo}-{com}]个 写入真实速度:{seep}"); + + MFMsgVariable me = new MFMsgVariable(8); + me.AddMotoralaLsb(8, 8, seep); + + var by = me.GetByteDat(); + var sendMes = by.ToHex(" "); + return sendMes; + } public void closeSend() { Exit = true; - Thread.Sleep(1000); + var sendMes = GetMsg(0); + for (int i = 0; i < 100; i++) + { + mfSerialInfo.SendMessage(sendMes); + } + Exit = true; Dispose(); }