Commit e6c70111 authored by 潘栩锋's avatar 潘栩锋 🚴

添加 TimeOutEvent 事件

parent d67c4e95
......@@ -43,9 +43,9 @@ namespace GeneralGommunication
/// <summary>
/// 有数据需要发送
/// </summary>
public event SendDataEventHander SendMsgEvent;
public event SendDataEventHandler SendMsgEvent;
public event TimeOutEventHandler TimeOutEvent;
......@@ -125,6 +125,8 @@ namespace GeneralGommunication
{
//已经重试了3次,放弃
ResetMsg();
//连接断开
TimeOutEvent?.Invoke(this);
return;
}
else
......@@ -140,6 +142,9 @@ namespace GeneralGommunication
//IsConnected = true;
csm.IncRec(recBuf.Count());
List<byte[]> packs = new List<byte[]>();
lock (currPack)
{
for (int i = 0; i < recBuf.Count(); i++)
{
if (recBuf[i] == 0x7e)
......@@ -149,16 +154,18 @@ namespace GeneralGommunication
if (currPack.Count > 0)
{
var pack = currPack.ToArray();
ParsePack(pack);
packs.Add(pack);
currPack.Clear();
csm.IncPack(1);
}
}
currPack.Add(recBuf[i]);
}
}
//OnPoll_TimeOut();
for (int i = 0; i < packs.Count(); i++) {
ParsePack(packs[i]);
}
}
......
......@@ -28,7 +28,7 @@ namespace GeneralGommunication
/// <summary>
/// 有数据需要发送
/// </summary>
event SendDataEventHander SendMsgEvent;
event SendDataEventHandler SendMsgEvent;
#region 模块运行接口
......
......@@ -21,7 +21,7 @@ namespace GeneralGommunication
/// <summary>
/// 有数据需要发送
/// </summary>
event SendDataEventHander SendMsgEvent;
event SendDataEventHandler SendMsgEvent;
/// <summary>
/// 设备连接状态改变
......
......@@ -37,7 +37,7 @@ namespace GeneralGommunication
/// <summary>
/// 有数据需要发送
/// </summary>
public event SendDataEventHander SendMsgEvent;
public event SendDataEventHandler SendMsgEvent;
public event DeviceConnectEventHander DeviceConnectEvent;
......
......@@ -36,7 +36,7 @@ namespace GeneralGommunication
/// <summary>
/// 有数据需要发送
/// </summary>
public event SendDataEventHander SendMsgEvent;
public event SendDataEventHandler SendMsgEvent;
/// <summary>
/// 对于全部 有返回的函数调用,都使用Dispatcher,使线程同步
......
......@@ -101,5 +101,8 @@ namespace GeneralGommunication
public string errMsg;
}
public delegate void SendDataEventHander(object sender, byte[] data);
public delegate void SendDataEventHandler(object sender, byte[] data);
public delegate void TimeOutEventHandler(object sender);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment