From 9211ec11c112e18cd99e77f889a01110a70031ce Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期一, 24 十一月 2025 17:47:15 +0800
Subject: [PATCH] 优化项目结构

---
 CellStepSender/StepSender.cs                   |   69 ++++++
 S7Driver/S7Driver.csproj                       |   52 +++++
 S7Driver/PLCS7Driver.cs                        |  122 ++++++++++++
 CellStepSender/CellStepSender.csproj           |   49 ++++
 SimpleUtil/DIOController/DIOController.csproj  |    3 
 CellStepSender/TcpClientTool.cs                |  104 ++++++++++
 S7Driver/Properties/AssemblyInfo.cs            |   33 +++
 WPFProject/WPFProject.csproj                   |   10 +
 Plugin.TsExecution/TsExecution.xaml.cs         |    4 
 CellStepSender/Properties/AssemblyInfo.cs      |   33 +++
 HMI.AlermInfoManage/HMI.AlarmInfoManage.csproj |    7 
 ModBusTcpController/ModBusTcpController.csproj |    4 
 Plugin.TsExecution/SingleControl.xaml          |    4 
 WPFProject/WPFProject.sln                      |   28 ++
 HMI.AlermInfoManage/AlarmInfoManage.xaml.cs    |   59 +++--
 15 files changed, 552 insertions(+), 29 deletions(-)

diff --git a/CellStepSender/CellStepSender.csproj b/CellStepSender/CellStepSender.csproj
new file mode 100644
index 0000000..7bb8947
--- /dev/null
+++ b/CellStepSender/CellStepSender.csproj
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{84EDEAC7-6763-46CD-B098-0B508AAA705F}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>CellStepSender</RootNamespace>
+    <AssemblyName>CellStepSender</AssemblyName>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="StepSender.cs" />
+    <Compile Include="TcpClientTool.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>
\ No newline at end of file
diff --git a/CellStepSender/Properties/AssemblyInfo.cs b/CellStepSender/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..136a4b8
--- /dev/null
+++ b/CellStepSender/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+锘縰sing System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 鏈夊叧绋嬪簭闆嗙殑涓�鑸俊鎭敱浠ヤ笅
+// 鎺у埗銆傛洿鏀硅繖浜涚壒鎬у�煎彲淇敼
+// 涓庣▼搴忛泦鍏宠仈鐨勪俊鎭��
+[assembly: AssemblyTitle("CellStepSender")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CellStepSender")]
+[assembly: AssemblyCopyright("Copyright 漏  2025")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 灏� ComVisible 璁剧疆涓� false 浼氫娇姝ょ▼搴忛泦涓殑绫诲瀷
+//瀵� COM 缁勪欢涓嶅彲瑙併�傚鏋滈渶瑕佷粠 COM 璁块棶姝ょ▼搴忛泦涓殑绫诲瀷
+//璇峰皢姝ょ被鍨嬬殑 ComVisible 鐗规�ц缃负 true銆�
+[assembly: ComVisible(false)]
+
+// 濡傛灉姝ら」鐩悜 COM 鍏紑锛屽垯涓嬪垪 GUID 鐢ㄤ簬绫诲瀷搴撶殑 ID
+[assembly: Guid("84edeac7-6763-46cd-b098-0b508aaa705f")]
+
+// 绋嬪簭闆嗙殑鐗堟湰淇℃伅鐢变笅鍒楀洓涓�肩粍鎴�: 
+//
+//      涓荤増鏈�
+//      娆$増鏈�
+//      鐢熸垚鍙�
+//      淇鍙�
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/CellStepSender/StepSender.cs b/CellStepSender/StepSender.cs
new file mode 100644
index 0000000..6ca40d1
--- /dev/null
+++ b/CellStepSender/StepSender.cs
@@ -0,0 +1,69 @@
+锘縰sing System;
+using System.Threading;
+
+namespace CellStepSender
+{
+    internal class StepSender
+    {
+        /// <summary>
+        /// 鍙戦�佹祴璇曟暟鎹�
+        /// </summary>
+        /// <param name="ip">IP</param>
+        /// <param name="port">绔彛</param>
+        /// <param name="ovenIndex">鐐変笅鏍�</param>
+        /// <param name="cellIndex">绌翠綅涓嬫爣</param>
+        /// <param name="step">娴嬭瘯椤�</param>
+        /// <param name="value">娴嬭瘯鍊�</param>
+        /// <param name="limitUp">涓婇檺</param>
+        /// <param name="limitDown">涓嬮檺</param>
+        /// <param name="unit">鍗曚綅</param>
+        /// <param name="result">娴嬭瘯缁撴灉</param>
+        /// <param name="updateTime">娴嬭瘯鏃堕棿</param>
+        /// <param name="errorMsg">寮傚父淇℃伅</param>
+        /// <returns>鏄惁鍙戦�佹垚鍔�</returns>
+        public static 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;
+            TcpClientTool client = null;
+            try
+            {
+                client = new TcpClientTool(ip, port);
+                string res = null;
+                client.ExecuteMessageChanged += (sender, data) =>
+                {
+                    res = data;
+                };
+                client.Connect();
+
+                string msg = $"{ovenIndex};{cellIndex};{step},{value},{limitUp},{limitDown},{unit},{result},{updateTime}\n";
+                client.Send(msg);
+
+                int time = 1;
+                while (res == null && time <= 50)
+                {
+                    Thread.Sleep(100);
+                    time++;
+                }
+                if (res == null)
+                {
+                    errorMsg = "Time Out";
+                }
+                return res == "1";
+
+            }
+            catch (Exception ex)
+            {
+                errorMsg = ex.Message;
+                return false;
+            }
+            finally
+            {
+                client?.Disconnect();
+            }
+        }
+    }
+}
diff --git a/CellStepSender/TcpClientTool.cs b/CellStepSender/TcpClientTool.cs
new file mode 100644
index 0000000..fb485a9
--- /dev/null
+++ b/CellStepSender/TcpClientTool.cs
@@ -0,0 +1,104 @@
+锘縰sing System;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading;
+
+namespace CellStepSender
+{
+    public class TcpClientTool
+    {
+        private string _ip;
+        private int _port;
+        private bool _isConnected = false; // 鏄惁杩炴帴
+        private Socket _clientSocket; // 濂楁帴瀛�
+        private Thread _receiveThread = null; // 鎺ユ敹绾跨▼
+        private volatile bool needRecieve = true;
+
+        public event EventHandler<string> ExecuteMessageChanged;
+
+        public TcpClientTool(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;
+                _receiveThread = new Thread(Received);
+                _receiveThread.IsBackground = true;
+                _receiveThread.Start();
+            }
+            catch (Exception ex)
+            {
+                needRecieve = false;
+                _receiveThread?.Abort();
+                _receiveThread = null;
+                _clientSocket.Close();
+                _isConnected = false;
+                throw ex;
+            }
+        }
+
+        public void Disconnect()
+        {
+            needRecieve = false;
+            _clientSocket.Close();
+            _receiveThread?.Abort();
+            _receiveThread = null;
+            _isConnected = false;
+        }
+
+        public void Send(string data)
+        {
+            byte[] arrClientSendMsg = Encoding.UTF8.GetBytes(data);
+            _clientSocket.Send(arrClientSendMsg);
+        }
+
+        public void Received()
+        {
+            //while (needRecieve)
+            //{
+            //    byte[] arrRecMsg = new byte[1024 * 1024];
+            //    int length = _clientSocket.Receive(arrRecMsg);
+            //    string strRecMsg = Encoding.UTF8.GetString(arrRecMsg, 0, length);
+            //    ExecuteMessageChanged?.Invoke(this, strRecMsg);
+            //    Thread.Sleep(100);
+            //}
+        }
+
+
+        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;
+            }
+        }
+    }
+}
diff --git a/HMI.AlermInfoManage/AlarmInfoManage.xaml.cs b/HMI.AlermInfoManage/AlarmInfoManage.xaml.cs
index 1cf4db1..4a3ae83 100644
--- a/HMI.AlermInfoManage/AlarmInfoManage.xaml.cs
+++ b/HMI.AlermInfoManage/AlarmInfoManage.xaml.cs
@@ -1,5 +1,4 @@
-锘縰sing ConnectionUtil;
-using HMI.AlarmInfoManage.Entity;
+锘縰sing HMI.AlarmInfoManage.Entity;
 using HMI.Base;
 using HMI.Core.Api;
 using HMI.Core.Setting;
@@ -7,9 +6,7 @@
 using HMI.UI.Util;
 using HMI.Util;
 using Microsoft.Win32;
-using OPCConnection;
-using Sharp7;
-using SimensDriver;
+using S7Driver;
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
@@ -31,14 +28,11 @@
         private string markPath;
         private string alarmTextPath;
 
-        private string opcIP = "127.0.0.1";
-        private int opcPort = 6543;
-        private int localPort = 18888;
+        
         private volatile bool isClosing = false;
 
 
         private string dbPath;
-        private Simens plc = new Simens();
 
         private bool isHaveAlarm;
         private bool isNewAlarm;
@@ -71,7 +65,12 @@
         /// </summary>
         private MSMQHelper alarmRefershToMain = new MSMQHelper("LTHMI_Alarm_Rrfresh");
 
-        private SCADAApi lTSCADAApi = new OPCClient();
+        //private string opcIP = "127.0.0.1";
+        //private int opcPort = 6543;
+        //private int localPort = 18888;
+        //private SCADAApi lTSCADAApi = new OPCClient();
+
+        private PLCS7Driver pLCS7Driver;
 
         /// <summary>
         /// 鎶ヨ
@@ -187,6 +186,7 @@
         {
             DataContext = this;
             systemSetting = SystemSetting.Instance;
+            pLCS7Driver = new PLCS7Driver(systemSetting.PlcIp, systemSetting.PlcPort);
             InitializeComponent();
         }
 
@@ -222,13 +222,21 @@
                 Interval = 1000,
             };
             MonitorTimer.Elapsed += MonitorTimer_Elapsed;
-            if (!lTSCADAApi.Connect2(opcIP, opcPort, localPort, out string errMsg))
+            //if (!lTSCADAApi.Connect2(opcIP, opcPort, localPort, out string errMsg))
+            //{
+            //}
+            //else
+            //{
+            //    this.MonitorTimer.Start();
+            //}
+
+            if (pLCS7Driver.Connect(out string errMSg))
             {
-                //MsgBoxHelper.Error(this, errMsg);
+                this.MonitorTimer.Start();
             }
             else
             {
-                this.MonitorTimer.Start();
+                log.Error($"PLC Driver Connect Error. {errMSg}");
             }
 
             PcTimer = new Timer
@@ -641,15 +649,16 @@
             {
                 this.MonitorTimer.Enabled = false;
 
-                if (!lTSCADAApi.IsConnected(out string errMsg))
-                {
-                    log.Warn($"OPCServer Connection Error. {errMsg}");
-                    if (!lTSCADAApi.Connect2(opcIP, opcPort, localPort, out errMsg))
-                    {
-                        log.Warn($"OPCServer Try ReConnection Error. {errMsg}");
-                        return;
-                    }
-                }
+                /// 妫�鏌ヨ繛鎺�
+                //if (!lTSCADAApi.IsConnected(out string errMsg))
+                //{
+                //    log.Warn($"OPCServer Connection Error. {errMsg}");
+                //    if (!lTSCADAApi.Connect2(opcIP, opcPort, localPort, out errMsg))
+                //    {
+                //        log.Warn($"OPCServer Try ReConnection Error. {errMsg}");
+                //        return;
+                //    }
+                //}
 
                 isHaveAlarm = false;
                 List<AlarmText> cache = new List<AlarmText>();
@@ -681,9 +690,10 @@
 
                 foreach (var key in BlockMap.Keys)
                 {
-                    if (lTSCADAApi.DoFctReadSingle(key, out string alarmCode, out errMsg) && BlockMap[key].ContainsKey(alarmCode))
+                    if (pLCS7Driver.ReadShort(key, out short alarmVal, out string errMsg) && BlockMap[key].ContainsKey(alarmVal.ToString()))
                     {
                         //if(BlockReadCache.ContainsKey(key) && alarmCode)
+                        var alarmCode = alarmVal.ToString();
                         isHaveAlarm = true;
                         var text = BlockMap[key][alarmCode];
                         var newAlarm = new AlarmText
@@ -707,8 +717,9 @@
                 foreach (var item in markAlarmSetting)
                 {
                     var name = $"{item.DBAddress}.{item.StartAddress}";
-                    if (lTSCADAApi.DoFctReadSingle(name, out string alarmCode, out errMsg) && alarmCode != "0")
+                    if (pLCS7Driver.ReadShort(name, out short alarmVal, out string errMsg) && alarmVal != 0)
                     {
+                        var alarmCode = alarmVal.ToString();
                         isHaveAlarm = true;
                         var newAlarm = new AlarmText
                         {
diff --git a/HMI.AlermInfoManage/HMI.AlarmInfoManage.csproj b/HMI.AlermInfoManage/HMI.AlarmInfoManage.csproj
index 5d76130..d2db9a1 100644
--- a/HMI.AlermInfoManage/HMI.AlarmInfoManage.csproj
+++ b/HMI.AlermInfoManage/HMI.AlarmInfoManage.csproj
@@ -74,9 +74,6 @@
     <Reference Include="Panuon.WPF.UI, Version=1.3.0.2, Culture=neutral, processorArchitecture=MSIL">
       <HintPath>..\WPFProject\packages\Panuon.WPF.UI.1.3.0.2\lib\net472\Panuon.WPF.UI.dll</HintPath>
     </Reference>
-    <Reference Include="SimensDriver">
-      <HintPath>..\Libs\SimensDriver.dll</HintPath>
-    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Configuration" />
     <Reference Include="System.Data" />
@@ -163,6 +160,10 @@
     </None>
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\S7Driver\S7Driver.csproj">
+      <Project>{628ef12b-9ed2-4b20-950f-dc3ecc3fd15f}</Project>
+      <Name>S7Driver</Name>
+    </ProjectReference>
     <ProjectReference Include="..\ConnectionUtil\ConnectionUtil.csproj">
       <Project>{d0806fa6-3f6d-4304-81b8-ead9da7cb5b2}</Project>
       <Name>ConnectionUtil</Name>
diff --git a/ModBusTcpController/ModBusTcpController.csproj b/ModBusTcpController/ModBusTcpController.csproj
index 1693e3e..5915a10 100644
--- a/ModBusTcpController/ModBusTcpController.csproj
+++ b/ModBusTcpController/ModBusTcpController.csproj
@@ -31,6 +31,10 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="HslCommunication, Version=12.0.3.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\Libs\HslCommunication.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xml.Linq" />
diff --git a/Plugin.TsExecution/SingleControl.xaml b/Plugin.TsExecution/SingleControl.xaml
index ff6a19b..de1842d 100644
--- a/Plugin.TsExecution/SingleControl.xaml
+++ b/Plugin.TsExecution/SingleControl.xaml
@@ -29,14 +29,14 @@
                 <Setter Property="VerticalContentAlignment" Value="Center"/>
                 <Setter Property="Padding" Value="5"/>
                 <Setter Property="FontSize" Value="{Binding ActualWidth,ElementName=control,
-Converter={StaticResource fc}, ConverterParameter='20,1093,20'}"/>
+Converter={StaticResource fc}, ConverterParameter='25,1093'}"/>
             </Style>
             <Style TargetType="TextBlock" x:Key="baseText">
                 <Setter Property="HorizontalAlignment" Value="Left"/>
                 <Setter Property="VerticalAlignment" Value="Center"/>
                 <Setter Property="Padding" Value="0,0,2,0"/>
                 <Setter Property="FontSize" Value="{Binding ActualWidth,ElementName=control,
-Converter={StaticResource fc}, ConverterParameter='20,1093,20'}"/>
+Converter={StaticResource fc}, ConverterParameter='25,1093'}"/>
             </Style>
             <Brush x:Key="passedColor">#beed00</Brush>
         </ResourceDictionary>
diff --git a/Plugin.TsExecution/TsExecution.xaml.cs b/Plugin.TsExecution/TsExecution.xaml.cs
index da56cd3..2b498b2 100644
--- a/Plugin.TsExecution/TsExecution.xaml.cs
+++ b/Plugin.TsExecution/TsExecution.xaml.cs
@@ -533,6 +533,10 @@
             {
                 panel.Columns = 1;
             }
+            else if (tsSockets.Count > 0 && (tsSockets.Count % 3) == 0)
+            {
+                panel.Columns = 3;
+            }
             else
             {
                 panel.Columns = 2;
diff --git a/S7Driver/PLCS7Driver.cs b/S7Driver/PLCS7Driver.cs
new file mode 100644
index 0000000..6b666e3
--- /dev/null
+++ b/S7Driver/PLCS7Driver.cs
@@ -0,0 +1,122 @@
+锘縰sing HslCommunication.Core.Pipe;
+using HslCommunication.Profinet.Siemens;
+using System;
+
+namespace S7Driver
+{
+    public class PLCS7Driver : IDisposable
+    {
+        private SiemensS7Net client;
+        private string Ip;
+        private int Port;
+
+        public PLCS7Driver(string ip, int port)
+        {
+            this.Ip = ip;
+            this.Port = port;
+        }
+
+        public bool Connect(out string errMsg)
+        {
+            try
+            {
+                client = new SiemensS7Net(SiemensPLCS.S1500);
+                PipeTcpNet pipeTcpNet = new PipeTcpNet(Ip, Port);
+                pipeTcpNet.ConnectTimeOut = 5000;
+                pipeTcpNet.ReceiveTimeOut = 10000;
+                client.CommunicationPipe = pipeTcpNet;
+                var or = client.ConnectServer();
+                errMsg = or.Message;
+                return or.IsSuccess;
+            }
+            catch (Exception ex)
+            {
+                errMsg = ex.Message;
+                return false;
+            }
+        }
+
+        public bool DisConnect(out string errMsg)
+        {
+            try
+            {
+                if (client == null)
+                {
+                    errMsg = "鏈繛鎺�";
+                    return false;
+                }
+                var or = client.ConnectClose();
+                errMsg = or.Message;
+                return or.IsSuccess;
+            }
+            catch (Exception ex)
+            {
+                errMsg = ex.Message;
+                return false;
+            }
+        }
+
+        public void Dispose()
+        {
+            client?.Dispose();
+        }
+
+        public bool Simens_S7_ReadBool(int DB, int StartAdd, int Pos)
+        {
+            var or = client.ReadBool($"DB{DB}.DBX{StartAdd}.{Pos}");
+            return or.Content;
+        }
+
+        public void Simens_S7_WriteBool(int DB, int StartAdd, int Pos, bool Val)
+        {
+            var or = client.Write($"DB{DB}.DBX{StartAdd}.{Pos}", Val);
+            return;
+        }
+
+        public int Simens_S7_ReadInt(int DB, int StartAdd, int Length)
+        {
+            var or = client.ReadInt16($"DB{DB}.DBW{StartAdd}");
+            return or.Content;
+        }
+
+        public void Simens_S7_WriteInt(int DB, int StartAdd, short Val)
+        {
+            client.Write($"DB{DB}.DBW{StartAdd}", Val);
+        }
+
+        public float Simens_S7_ReadReal(int DB, int StartAdd, int Length)
+        {
+            var or = client.ReadFloat($"DB{DB}.DBW{StartAdd}");
+            return or.Content;
+        }
+
+        public void Simens_S7_WriteReal(int DB, int StartAdd, float Val)
+        {
+            client.Write($"DB{DB}.DBW{StartAdd}", Val);
+        }
+
+        public bool ReadShort(string address, out short value, out string errMsg)
+        {
+            value = 0;
+            errMsg = null;
+            try
+            {
+                var or = client.ReadInt16(address);
+                if (or.IsSuccess)
+                {
+                    value = or.Content;
+                }
+                else
+                {
+                    errMsg = or.Message;
+                }
+                return or.IsSuccess;
+            }
+            catch (Exception e)
+            {
+                errMsg = e.Message;
+                return false;
+            }
+        }
+    }
+}
diff --git a/S7Driver/Properties/AssemblyInfo.cs b/S7Driver/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..aa2b394
--- /dev/null
+++ b/S7Driver/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+锘縰sing System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 鏈夊叧绋嬪簭闆嗙殑涓�鑸俊鎭敱浠ヤ笅
+// 鎺у埗銆傛洿鏀硅繖浜涚壒鎬у�煎彲淇敼
+// 涓庣▼搴忛泦鍏宠仈鐨勪俊鎭��
+[assembly: AssemblyTitle("S7Driver")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("S7Driver")]
+[assembly: AssemblyCopyright("Copyright 漏  2025")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 灏� ComVisible 璁剧疆涓� false 浼氫娇姝ょ▼搴忛泦涓殑绫诲瀷
+//瀵� COM 缁勪欢涓嶅彲瑙併�傚鏋滈渶瑕佷粠 COM 璁块棶姝ょ▼搴忛泦涓殑绫诲瀷
+//璇峰皢姝ょ被鍨嬬殑 ComVisible 鐗规�ц缃负 true銆�
+[assembly: ComVisible(false)]
+
+// 濡傛灉姝ら」鐩悜 COM 鍏紑锛屽垯涓嬪垪 GUID 鐢ㄤ簬绫诲瀷搴撶殑 ID
+[assembly: Guid("628ef12b-9ed2-4b20-950f-dc3ecc3fd15f")]
+
+// 绋嬪簭闆嗙殑鐗堟湰淇℃伅鐢变笅鍒楀洓涓�肩粍鎴�: 
+//
+//      涓荤増鏈�
+//      娆$増鏈�
+//      鐢熸垚鍙�
+//      淇鍙�
+//
+[assembly: AssemblyVersion("1.0.0.4")]
+[assembly: AssemblyFileVersion("1.0.0.4")]
diff --git a/S7Driver/S7Driver.csproj b/S7Driver/S7Driver.csproj
new file mode 100644
index 0000000..e7ccfa9
--- /dev/null
+++ b/S7Driver/S7Driver.csproj
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>S7Driver</RootNamespace>
+    <AssemblyName>S7Driver</AssemblyName>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="HslCommunication, Version=12.0.3.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\Libs\HslCommunication.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="PLCS7Driver.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>
\ No newline at end of file
diff --git a/SimpleUtil/DIOController/DIOController.csproj b/SimpleUtil/DIOController/DIOController.csproj
index 82431c8..b88e917 100644
--- a/SimpleUtil/DIOController/DIOController.csproj
+++ b/SimpleUtil/DIOController/DIOController.csproj
@@ -31,6 +31,9 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="HslCommunication">
+      <HintPath>..\..\Libs\HslCommunication.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xml.Linq" />
diff --git a/WPFProject/WPFProject.csproj b/WPFProject/WPFProject.csproj
index 57b3353..7880d4c 100644
--- a/WPFProject/WPFProject.csproj
+++ b/WPFProject/WPFProject.csproj
@@ -444,6 +444,14 @@
     <None Include="App.config" />
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\HMI.Old\Plugin_TestResult\CellStepSender\CellStepSender.csproj">
+      <Project>{84edeac7-6763-46cd-b098-0b508aaa705f}</Project>
+      <Name>CellStepSender</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\S7Driver\S7Driver.csproj">
+      <Project>{628ef12b-9ed2-4b20-950f-dc3ecc3fd15f}</Project>
+      <Name>S7Driver</Name>
+    </ProjectReference>
     <ProjectReference Include="..\HMI.AlermInfoManage\HMI.AlarmInfoManage.csproj">
       <Project>{945c2577-4558-45e3-891a-096cb3047304}</Project>
       <Name>HMI.AlarmInfoManage</Name>
@@ -561,11 +569,13 @@
 move /y "$(TargeDir)HMI.Util.dll" $(TargeDir)Libs\HMI.Util.dll"
 move /y "$(TargeDir)ConnectionUtil.dll" $(TargeDir)Libs\ConnectionUtil.dll"
 move /y "$(TargeDir)HMI.StdControl.dll" $(TargeDir)Libs\HMI.StdControl.dll"
+move /y "$(TargeDir)S7Driver.dll" $(TargeDir)Libs\S7Driver.dll"
 
 move /y "$(TargeDir)HMI.LogUtil.dll" $(TargeDir)Api\HMI.LogUtil.dll"
 move /y "$(TargeDir)HMI.SerialData.Util.dll" $(TargeDir)Api\HMI.SerialData.Util.dll"
 move /y "$(TargeDir)HMI.Simple.Util.dll" $(TargeDir)Api\HMI.Simple.Util.dll"
 move /y "$(TargeDir)HMI.Util.Base.dll" $(TargeDir)Api\HMI.Util.Base.dll"
+move /y "$(TargeDir)CellStepSender.dll" $(TargeDir)Api\CellStepSender.dll"
 
 move /y "$(TargeDir)HMI.AlarmInfoManage.dll" $(TargeDir)Plugin\HMI.AlarmInfoManage.dll"
 move /y "$(TargeDir)HMI.DataViewer.dll" $(TargeDir)Plugin\HMI.DataViewer.dll"
diff --git a/WPFProject/WPFProject.sln b/WPFProject/WPFProject.sln
index d920a5c..17e2350 100644
--- a/WPFProject/WPFProject.sln
+++ b/WPFProject/WPFProject.sln
@@ -71,6 +71,10 @@
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HMI.StdControl", "..\HMI.StdControl\HMI.StdControl.csproj", "{7A066856-182F-4435-B648-E9FB91AFF657}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S7Driver", "..\S7Driver\S7Driver.csproj", "{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CellStepSender", "..\CellStepSender\CellStepSender.csproj", "{84EDEAC7-6763-46CD-B098-0B508AAA705F}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -477,6 +481,30 @@
 		{7A066856-182F-4435-B648-E9FB91AFF657}.Release|x64.Build.0 = Release|Any CPU
 		{7A066856-182F-4435-B648-E9FB91AFF657}.Release|x86.ActiveCfg = Release|Any CPU
 		{7A066856-182F-4435-B648-E9FB91AFF657}.Release|x86.Build.0 = Release|Any CPU
+		{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}.Debug|x64.Build.0 = Debug|Any CPU
+		{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}.Debug|x86.Build.0 = Debug|Any CPU
+		{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}.Release|Any CPU.Build.0 = Release|Any CPU
+		{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}.Release|x64.ActiveCfg = Release|Any CPU
+		{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}.Release|x64.Build.0 = Release|Any CPU
+		{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}.Release|x86.ActiveCfg = Release|Any CPU
+		{628EF12B-9ED2-4B20-950F-DC3ECC3FD15F}.Release|x86.Build.0 = Release|Any CPU
+		{84EDEAC7-6763-46CD-B098-0B508AAA705F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{84EDEAC7-6763-46CD-B098-0B508AAA705F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{84EDEAC7-6763-46CD-B098-0B508AAA705F}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{84EDEAC7-6763-46CD-B098-0B508AAA705F}.Debug|x64.Build.0 = Debug|Any CPU
+		{84EDEAC7-6763-46CD-B098-0B508AAA705F}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{84EDEAC7-6763-46CD-B098-0B508AAA705F}.Debug|x86.Build.0 = Debug|Any CPU
+		{84EDEAC7-6763-46CD-B098-0B508AAA705F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{84EDEAC7-6763-46CD-B098-0B508AAA705F}.Release|Any CPU.Build.0 = Release|Any CPU
+		{84EDEAC7-6763-46CD-B098-0B508AAA705F}.Release|x64.ActiveCfg = Release|Any CPU
+		{84EDEAC7-6763-46CD-B098-0B508AAA705F}.Release|x64.Build.0 = Release|Any CPU
+		{84EDEAC7-6763-46CD-B098-0B508AAA705F}.Release|x86.ActiveCfg = Release|Any CPU
+		{84EDEAC7-6763-46CD-B098-0B508AAA705F}.Release|x86.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

--
Gitblit v1.9.1