From 37acb8358f5602a9013ee29c04a45e33483c2329 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期四, 09 四月 2026 15:21:40 +0800
Subject: [PATCH] fix: 修复PLC字符串解析和任务处理逻辑

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs
index 142601b..cdfdee9 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Communicator/Siemens/SiemensS7Communicator.cs
@@ -242,6 +242,8 @@
                         return plc.Write(address, Convert.ToString(value));
                     case TypeCode.Char:
                         return plc.Write(address, Convert.ToChar(value));
+                    //case TypeCode.arr:
+                    //    return plc.Write(address, Convert.ToChar(value));
                     default:
                         if (value is int[])
                         {
@@ -673,6 +675,21 @@
                 case SiemensDBDataType.DataType_Char:
 
                     break;
+
+                case SiemensDBDataType.DataType_ByteArray:
+                    {
+                        byte[] writeVal;
+                        try
+                        {
+                            writeVal = Encoding.UTF8.GetBytes(value.ToString());
+                        }
+                        catch (Exception ex)
+                        {
+                            throw new CommunicationException(string.Format(CommunicationExceptionMessage.TypeConvertError, dataType, address, value, ex.Message), CommunicationErrorType.TypeError, innerException: ex);
+                        }
+                        obj = GetResult(Write(address, writeVal), address, writeVal);
+                    }
+                    break;
                 default:
                     throw new CommunicationException(string.Format(CommunicationExceptionMessage.DataTypeErrorException, dataType, address), CommunicationErrorType.TypeError);
             }

--
Gitblit v1.9.3