From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点
---
CellStepSender/TcpClientTool3.cs | 81 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 81 insertions(+), 0 deletions(-)
diff --git a/CellStepSender/TcpClientTool3.cs b/CellStepSender/TcpClientTool3.cs
new file mode 100644
index 0000000..993c28b
--- /dev/null
+++ b/CellStepSender/TcpClientTool3.cs
@@ -0,0 +1,81 @@
+锘縰sing System;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+
+namespace CellStepSender
+{
+ public class TcpClientTool3
+ {
+ private string _ip;
+ private int _port;
+ private bool _isConnected = false; // 鏄惁杩炴帴
+ private Socket _clientSocket; // 濂楁帴瀛�
+
+ public event EventHandler<string> ExecuteMessageChanged;
+
+ public TcpClientTool3(string ip, int port)
+ {
+ this._ip = ip;
+ this._port = port;
+ }
+
+ public void Connect()
+ {
+ try
+ {
+ _clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ IPAddress ipaddress = IPAddress.Parse(this._ip);
+ IPEndPoint endpoint = new IPEndPoint(ipaddress, _port);
+ _clientSocket.Connect(endpoint);
+ _isConnected = true;
+ }
+ catch (Exception ex)
+ {
+ _clientSocket.Dispose();
+ _isConnected = false;
+ throw ex;
+ }
+ }
+
+ public void Disconnect()
+ {
+ _clientSocket.Dispose();
+ }
+
+ public void Send(string data)
+ {
+ byte[] arrClientSendMsg = Encoding.UTF8.GetBytes(data);
+ lock (this)
+ {
+ _clientSocket.Send(arrClientSendMsg);
+ }
+ }
+
+ public bool SendStep(
+ string ip, int port,
+ int ovenIndex, int cellIndex, string step, string value, string limitUp,
+ string limitDown, string unit, string result, string updateTime, out string errorMsg)
+ {
+
+ errorMsg = null;
+ try
+ {
+ if (!_isConnected)
+ {
+ errorMsg = "Not Connected";
+ return false;
+ }
+
+ string msg = $"{ovenIndex};{cellIndex};{step},{value},{limitUp},{limitDown},{unit},{result},{updateTime}\n";
+ Send(msg);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ errorMsg = ex.Message;
+ return false;
+ }
+ }
+ }
+}
--
Gitblit v1.9.1