protected override void VerifyAdditionalLengthInfo(byte length) { if (length != 0) { throw BufferFieldException.WrongValue("AdditionalInfoLength", 0, length); } _additionalInfoFields = new AdditionalInformationField[0]; }
protected override void VerifyMessageCode(CemiMessageCode messageCode) { if (messageCode != CemiMessageCode.LDATA_REQ && messageCode != CemiMessageCode.LDATA_CON && messageCode != CemiMessageCode.LDATA_IND) { throw BufferFieldException.WrongValue("MessageCode", "LDATA*", messageCode.ToString()); } }
private void SetInfo(byte[] data) { _infoLength = data[0]; if (_infoLength != data.Length - 1) { throw BufferFieldException.WrongValue("AdditionalInfo - Data", data.Length - 1, _infoLength); } VerifyLength(_infoType, _infoLength); _information = new byte[_infoLength]; Array.Copy(data, 1, _information, 0, _infoLength); }
private void ParseType(IndividualEndianessBinaryReader br) { var infotype = br.ReadByte(); if (Enum.IsDefined(typeof(AdditionalInfoType), infotype)) { _infoType = (AdditionalInfoType)infotype; } else { throw BufferFieldException.TypeUnknown("AdditionalInfoType", infotype); } }
private void VerifyLength(AdditionalInfoType type, int length) { if (type == AdditionalInfoType.RFFASTACK || type == AdditionalInfoType.MANUFACTURER) { // TODO: Add checking of correct length // requires some calcs } else { if (length != TypeSizes[type]) { throw BufferFieldException.WrongValue($"AdditionalInfo ({type}) length", TypeSizes[type], length); } } }