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(); }