You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.9 KiB
C#
75 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Mesnac.Communication;
|
|
|
|
namespace SocketProcess
|
|
{
|
|
public class SocketHelper
|
|
{
|
|
public delegate void RecieveDelegate(string info);
|
|
public RecieveDelegate ReceiveEvent;
|
|
DataHandler dh;
|
|
|
|
public SocketHelper()
|
|
{
|
|
SocketClient.Instance.OnMsgReceived += RecieveDataHandle;
|
|
SocketClient.Instance.OnSended += SendDataDelegate;
|
|
dh = new DataHandler();
|
|
dh.recieveEvent += SocketManager;
|
|
}
|
|
void RecieveDataHandle(string Msg)
|
|
{
|
|
dh.DataAnylysis(Msg);
|
|
}
|
|
|
|
private void SocketManager(string EPC)
|
|
{
|
|
//发送设置过滤此EPC
|
|
string frame=dh.FrameConbine(EPC,RfidWorkType.setFlatEpc);
|
|
Send(frame);
|
|
//看看是否和上次一样
|
|
if (Entity.WorkStation.Instance.workTray!=null&&EPC == Entity.WorkStation.Instance.workTray.RfidNum)
|
|
{
|
|
return;
|
|
}
|
|
if (ReceiveEvent != null)
|
|
ReceiveEvent(EPC);
|
|
}
|
|
void SendDataDelegate(bool sendSuccess)
|
|
{
|
|
if (sendSuccess)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发送数据
|
|
/// </summary>
|
|
/// <param name="Msg"></param>
|
|
public void Send(string Msg)
|
|
{
|
|
SocketClient.Instance.Send(Msg);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 连接
|
|
/// </summary>
|
|
public void Connect(object send)
|
|
{
|
|
SocketClient.Instance.Connect();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 断开连接
|
|
/// </summary>
|
|
public void DisConnect()
|
|
{
|
|
SocketClient.Instance.Disconnect();
|
|
SocketClient.Instance.StopListenThread();
|
|
}
|
|
}
|
|
}
|