From e237cac7c33abccca4e673b8e4cb753a900e9b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Fri, 5 Apr 2024 15:50:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B2=E5=8F=A3=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionSystem/Untils/MFSerialInfo.cs | 52 +++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/ProductionSystem/Untils/MFSerialInfo.cs b/ProductionSystem/Untils/MFSerialInfo.cs index 2169746..8254b57 100644 --- a/ProductionSystem/Untils/MFSerialInfo.cs +++ b/ProductionSystem/Untils/MFSerialInfo.cs @@ -1,25 +1,69 @@ using System; +using System.Collections.Generic; +using System.Threading; using NewLife.Log; using NewLife.Threading; namespace ProductionSystem.Untils { - public class MFSerialInfo: IDisposable + public class MfSerialInfo: IDisposable { TimerX _timer; private MFSerial _mfser; + + public byte Entrance { get; set; } + public byte Export { get; set; } public Action MsgFunc { get; set; } - public MFSerialInfo(MFSerial mfser) + public MfSerialInfo() { - _mfser = mfser; - _timer = new TimerX(DoBackup, mfser, 200, 500) { Async = true }; + _mfser =new MFSerial(); + _timer = new TimerX(DoBackup, _mfser, 200, 500) { Async = true }; + + + } + + private string _data; + + public MfSerialInfo (byte entrance, byte export):this() + { + this.Entrance = entrance; + this.Export = export; + + _mfser.SetLinSet(); + // + _mfser.SetId(new List() + { + entrance, + export + }); + + } + + /// + /// 发送几次数据 + /// + /// + /// + public void SendMsg(string data,int num=3) + { + _mfser.SendMsg(Entrance,data); + Thread.Sleep(500); + for (int i = 0; i < num; i++) + { + _mfser.SendLinMasterSend(Export); + Thread.Sleep(100); + } + + } + + public void Dispose() {