From c6265b1f32a6c6c4e4dd478efe27d23e7d825859 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 12 十一月 2025 16:40:25 +0800
Subject: [PATCH] 优化任务逻辑,新增API支持动态货位更新重构任务处理逻辑,支持基于区域的任务分配,优化货位状态更新,减少重复代码 更新项目路径和文档路径,反映文件结构调整。  新增 UpdateStartLocationInfo和RequestLocationAPI 方法,支持动态更新货位信息。

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs |   69 +++++++++++++++++++++++++++++-----
 1 files changed, 59 insertions(+), 10 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs"
index c40e063..6af06f5 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs"
@@ -70,6 +70,12 @@
         private ILogNet _logNet;
 
         private bool _isPing = true;
+
+        /// <summary>
+        /// 鏄惁鍦ㄥ啓鍏ユ暟鎹悗璇诲彇鏁版嵁纭銆�
+        /// </summary>
+        public override bool IsReadAfterWrite { get; set; } = true;
+
         #endregion Private Member
 
         #region Public Member
@@ -239,30 +245,48 @@
             }
         }
 
-        private object Read(string address, TypeCode typeCode)
+        private object Read(string address, TypeCode typeCode, ushort length = 1)
         {
             try
             {
                 switch (typeCode)
                 {
                     case TypeCode.Int32:
-                        return (int)GetContent(plc.ReadInt32(address), address);
+                        if (length > 1)
+                            return (int[])GetContent(plc.ReadInt32(address, length), address);
+                        else
+                            return (int)GetContent(plc.ReadInt32(address), address);
                     case TypeCode.UInt32:
-                        return (uint)GetContent(plc.ReadUInt32(address), address);
+                        if (length > 1)
+                            return (uint[])GetContent(plc.ReadUInt32(address, length), address);
+                        else
+                            return (uint)GetContent(plc.ReadUInt32(address), address);
                     case TypeCode.Int16:
-                        return (short)GetContent(plc.ReadInt16(address), address);
+                        if (length > 1)
+                            return (short[])GetContent(plc.ReadInt16(address, length), address);
+                        else
+                            return (short)GetContent(plc.ReadInt16(address), address);
                     case TypeCode.UInt16:
-                        return (ushort)GetContent(plc.ReadUInt16(address), address);
+                        if (length > 1)
+                            return (ushort[])GetContent(plc.ReadUInt16(address, length), address);
+                        else
+                            return (ushort)GetContent(plc.ReadUInt16(address), address);
                     case TypeCode.Single:
-                        return (float)GetContent(plc.ReadFloat(address), address);
+                        if (length > 1)
+                            return (float[])GetContent(plc.ReadFloat(address, length), address);
+                        else
+                            return (float)GetContent(plc.ReadFloat(address), address);
                     case TypeCode.Boolean:
-                        return (bool)GetContent(plc.ReadBool(address), address);
+                        if (length > 1)
+                            return (bool[])GetContent(plc.ReadBool(address, length), address);
+                        else
+                            return (bool)GetContent(plc.ReadBool(address), address);
                     case TypeCode.Byte:
-                        return (byte)GetContent(plc.ReadByte(address), address);
+                        return (byte[])GetContent(plc.Read(address, length), address);
                     case TypeCode.String:
-                        return (string)GetContent(plc.ReadString(address), address);
+                        return (string)GetContent(plc.ReadString(address, length), address);
                     case TypeCode.Char:
-                        return (char)GetContent(plc.ReadByte(address), address);
+                        return (char[])GetContent(plc.Read(address, length), address);
                     default:
                         throw new CommunicationException(string.Format(CommunicationExceptionMessage.DataTypeErrorException, typeCode.ToString(), address), CommunicationErrorType.TypeError);
                 }
@@ -391,6 +415,19 @@
         }
 
         /// <summary>
+        /// 浠嶱LC璇诲彇鏁版嵁銆�
+        /// </summary>
+        /// <typeparam name="T">璇诲彇鏁版嵁鐨勭被鍨嬫硾鍨嬨��</typeparam>
+        /// <param name="address">婧愬湴鍧�锛屽叿浣撴牸寮忓彇鍐充簬浣跨敤鐨勫伐涓氬崗璁��</param>
+        /// <param name="length">璇诲彇鐨勯暱搴︺��</param>
+        /// <returns>璇诲彇鍒扮殑鏁版嵁锛屽鏋滆鍙栧け璐ュ垯鍙兘杩斿洖null鎴栨姏鍑哄紓甯搞��</returns>
+        public override T[] Read<T>(string address, ushort length)
+        {
+            Type type = typeof(T);
+            return (T[])Read(address, Type.GetTypeCode(type), length);
+        }
+
+        /// <summary>
         /// 浠嶱LC璇诲彇鏁版嵁杩斿洖object銆�
         /// </summary>
         /// <param name="address">婧愬湴鍧�锛屽叿浣撴牸寮忓彇鍐充簬浣跨敤鐨勫伐涓氬崗璁��</param>
@@ -446,6 +483,18 @@
             return GetResult(Write(address, value), address, value);
         }
 
+        /// <summary>
+        /// 鍚慞LC鍐欏叆鏁版嵁銆�  
+        /// </summary>
+        /// <typeparam name="T">鍐欏叆鏁版嵁鐨勭被鍨嬫硾鍨嬨��</typeparam>
+        /// <param name="address">婧愬湴鍧�锛屽叿浣撴牸寮忓彇鍐充簬浣跨敤鐨勫伐涓氬崗璁��</param>
+        /// <param name="values">瑕佸啓鍏ョ殑鏁版嵁銆�</param>
+        /// <returns>濡傛灉鍐欏叆鎴愬姛鍒欒繑鍥瀟rue锛屽惁鍒欐姏鍑哄紓甯搞��</returns>
+        public override bool Write<T>(string address, T[] values)
+        {
+            return GetResult(Write(address, values), address, values);
+        }
+
         public override bool WriteNoRead<T>(string address, T value)
         {
             OperateResult operate= Write(address, value);

--
Gitblit v1.9.3