wanshenmean
6 天以前 fe2a1e74780259605cd230e6f9c629c3dd7fdf15
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/DeviceBase/DeviceCommand.cs
@@ -23,6 +23,7 @@
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core.LogHelper;
namespace WIDESEAWCS_QuartzJob.DeviceBase
{
@@ -162,7 +163,12 @@
                        if (dataLength - 2 != Content[index])
                        {
                            throw new Exception($"读取PLC字符串定义长度【{Content[index]}】与对象【{GetType().Name}】属性【{propertyInfo.Name}】特性定义字符串长度【{dataLength}】不一致");
                            //throw new Exception($"读取PLC字符串定义长度【{Content[index]}】与对象【{GetType().Name}】属性【{propertyInfo.Name}】特性定义字符串长度【{dataLength}】不一致");
                            //QuartzLogger.Debug($"读取PLC字符串定义长度【{Content[index]}】与对象【{GetType().Name}】属性【{propertyInfo.Name}】特性定义字符串长度【{dataLength}】不一致");
                            propertyInfo.SetValue(this, Encoding.Default.GetString(Content, index, dataLength).Trim().Replace("\0", "").Replace("\\u000","").Trim());
                            index += dataLength;
                            break;
                        }
                        if (Content[index + 1] > Content.Length - index - 2)
@@ -170,7 +176,8 @@
                            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: