|
|
|
|
using HighWayIot.TouchSocket;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.Remoting.Channels;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using TouchSocket.Sockets;
|
|
|
|
|
|
|
|
|
|
namespace RFIDSocket
|
|
|
|
|
{
|
|
|
|
|
public partial class RFIDSocket : Form
|
|
|
|
|
{
|
|
|
|
|
private static TcpServer Server = TcpServer.Instance;
|
|
|
|
|
|
|
|
|
|
private static DataAnalysis RFIDData = DataAnalysis.Instance;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string Port = "1234";
|
|
|
|
|
string IP = "127.0.0.1";
|
|
|
|
|
|
|
|
|
|
public RFIDSocket()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
InitAction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitAction()
|
|
|
|
|
{
|
|
|
|
|
if (Server.State != ServerState.Running)
|
|
|
|
|
{
|
|
|
|
|
MonitorState.Text = "关";
|
|
|
|
|
MonitorState.BackColor = Color.Yellow;
|
|
|
|
|
}
|
|
|
|
|
else if (Server.State == ServerState.Running)
|
|
|
|
|
{
|
|
|
|
|
MonitorState.Text = "开";
|
|
|
|
|
MonitorState.BackColor = Color.LightGreen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Port = PortText.Text;
|
|
|
|
|
IP = IPText.Text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MonitorOnOff_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Server.State != ServerState.Running)
|
|
|
|
|
{
|
|
|
|
|
if (Server.ServerStart(IP, Port))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("监听服务启动成功!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("监听服务启动失败!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (Server.State == ServerState.Running)
|
|
|
|
|
{
|
|
|
|
|
if (Server.ServerStop())
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("监听服务关闭成功!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("监听服务关闭失败!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetPort_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Port = PortText.Text;
|
|
|
|
|
IP = IPText.Text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TableTimer_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Server.State != ServerState.Running)
|
|
|
|
|
{
|
|
|
|
|
MonitorOnOff.Text = "启动监听";
|
|
|
|
|
MonitorState.Text = "关";
|
|
|
|
|
MonitorState.BackColor = Color.Yellow;
|
|
|
|
|
}
|
|
|
|
|
else if (Server.State == ServerState.Running)
|
|
|
|
|
{
|
|
|
|
|
MonitorOnOff.Text = "关闭监听";
|
|
|
|
|
MonitorState.Text = "开";
|
|
|
|
|
MonitorState.BackColor = Color.LightGreen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RFIDData.GetData();
|
|
|
|
|
|
|
|
|
|
CotentData.DataSource = RFIDData.rFIDContents;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RFIDSocket_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Server.State == ServerState.Running)
|
|
|
|
|
{
|
|
|
|
|
if (!Server.ServerStop())
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("监听服务关闭失败! 请成功关闭后再退出");
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
}
|
|
|
|
|
if (!Server.ServerDispose())
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("监听服务释放失败! 请再次尝试退出");
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|