wanshenmean
2026-03-17 737dec3c384f394fd6f9849b4480b697d1ba35d5
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/DeviceBase/DeviceCommand.cs
@@ -160,17 +160,18 @@
                    case TypeCode.String:
                        ushort dataLength = CheckStringAttribute(propertyInfo);
                        if (dataLength - 2 != Content[index])
                        {
                            throw new Exception($"读取PLC字符串定义长度【{Content[index]}】与对象【{GetType().Name}】属性【{propertyInfo.Name}】特性定义字符串长度【{dataLength}】不一致");
                        }
                        //if (dataLength - 2 != Content[index])
                        //{
                        //    throw new Exception($"读取PLC字符串定义长度【{Content[index]}】与对象【{GetType().Name}】属性【{propertyInfo.Name}】特性定义字符串长度【{dataLength}】不一致");
                        //}
                        if (Content[index + 1] > Content.Length - index - 2)
                        {
                            throw new Exception($"读取PLC字符串实际长度【{Content[index + 1]}】超出当前byte数组长度,索引:【{index}】,字符串起始索引:【{index + 2}】,数组长度:【{Content.Length}】,解析长度:【{Content.Length - index - 2}】");
                        }
                        //if (Content[index + 1] > Content.Length - index - 2)
                        //{
                        //    throw new Exception($"读取PLC字符串实际长度【{Content[index + 1]}】超出当前byte数组长度,索引:【{index}】,字符串起始索引:【{index + 2}】,数组长度:【{Content.Length}】,解析长度:【{Content.Length - index - 2}】");
                        //}
                        propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index + 2, Content[index + 1]));
                        // propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index + 2, Content[index + 1] > 0 ? Content[index + 1] : dataLength - 2));
                        propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index, dataLength - 2));
                        index += dataLength;
                        break;
                    default: