public override byte[] GetData() { byte[] dataFieldData = FDataField.GetData(); FLength = (byte)dataFieldData.Length; FCheckSum = (byte)(StartByte.Value + FMeterType.Value + FAddress.Value.Sum(0, FAddress.Length) + FControl.Value + FLength.Value + dataFieldData.Sum(0, dataFieldData.Length)); return(base.GetData()); }
/// <summary> /// 设置数据 /// </summary> /// <param name="data"></param> /// <param name="startIndex"></param> /// <param name="len"></param> public override void SetData(byte[] data, int startIndex, int len) { if (!IsProtocolCommon(data, startIndex, len, DataFieldsNamespace)) { throw new Exception("字节数组不符合645协议"); } base.SetData(data, startIndex, len); byte[] dataFieldData = FDataField.GetData(); DataField df = Tools.CreateInstance <DataField>(AssemblyName, DataFieldsNamespace, string.Format(DataFieldNameFormat, FControl.Value.ToString("X2"))); if (df != null) { df.SetData(dataFieldData); FDataField = df; } }