初始化上传
This commit is contained in:
101
常用工具集/Utility/SerialDebug/FileTransmit/BinarySend.cs
Normal file
101
常用工具集/Utility/SerialDebug/FileTransmit/BinarySend.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using XMX.FileTransmit;
|
||||
using System.Threading;
|
||||
|
||||
|
||||
namespace XMX.FileTransmit
|
||||
{
|
||||
public class BinarySend : IFileTramsmit, ITransmitUart
|
||||
{
|
||||
private bool IsStart = false;
|
||||
Thread SendThread;
|
||||
|
||||
private int DelayTime = 10;
|
||||
public BinarySend(int delayTime)
|
||||
{
|
||||
DelayTime = delayTime;
|
||||
}
|
||||
|
||||
|
||||
private void SendThreadHandler()
|
||||
{
|
||||
while (IsStart)
|
||||
{
|
||||
if (SendNextPacket != null)
|
||||
{
|
||||
SendNextPacket(this, null);
|
||||
Thread.Sleep(DelayTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region IFileTramsmit <EFBFBD><EFBFBD>Ա
|
||||
|
||||
public event EventHandler StartSend = null;
|
||||
|
||||
public event EventHandler StartReceive = null;
|
||||
|
||||
public event EventHandler SendNextPacket;
|
||||
|
||||
public event EventHandler ReSendPacket = null;
|
||||
|
||||
public event EventHandler AbortTransmit = null;
|
||||
|
||||
public event EventHandler TransmitTimeOut = null;
|
||||
|
||||
public event EventHandler EndOfTransmit = null;
|
||||
|
||||
public event PacketEventHandler ReceivedPacket = null;
|
||||
|
||||
public void SendPacket(PacketEventArgs packet)
|
||||
{
|
||||
if (SendToUartEvent != null)
|
||||
{
|
||||
SendToUartEvent(null, new SendToUartEventArgs(packet.Packet));
|
||||
}
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
IsStart = true;
|
||||
SendThread = new Thread(new ThreadStart(SendThreadHandler));
|
||||
SendThread.IsBackground = true;
|
||||
SendThread.Start();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
IsStart = false;
|
||||
if (EndOfTransmit!=null)
|
||||
{
|
||||
EndOfTransmit(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void Abort()
|
||||
{
|
||||
IsStart = false;
|
||||
if (AbortTransmit!=null)
|
||||
{
|
||||
AbortTransmit(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITransmitUart <EFBFBD><EFBFBD>Ա
|
||||
|
||||
public event SendToUartEventHandler SendToUartEvent;
|
||||
|
||||
public void ReceivedFromUart(byte[] data)
|
||||
{
|
||||
Console.WriteLine("<22><><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>账<EFBFBD><E8B4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user