/// <summary> /// Unpacks the field from the message /// </summary> /// <param name = "msg">byte[] of the full message</param> /// <param name = "offset">offset indicating the start of the field</param> /// <returns>new offset in message to start unpacking the next field</returns> public int Unpack(byte[] msg, int offset) { int newOffset; Value = _fieldDescriptor.Unpack(FieldNumber, msg, offset, out newOffset); return(newOffset); }
public int Unpack(byte[] msg, int offset) { offset += 7; // 0xf0 + length byte[] bitmap = new byte[2]; bitmap[0] = msg[offset]; bitmap[1] = msg[offset + 1]; offset += 2; List <Field> setFields = GetFieldsFrom(bitmap); foreach (var field in setFields) { IFieldDescriptor fieldDesc = GetFieldDescriptor(field); int newOffset; var data = fieldDesc.Unpack((int)field, msg, offset, out newOffset); this.Add(field, data); offset = newOffset; } return(offset); }
/// <summary> /// Unpack the field from the message /// </summary> /// <param name = "fieldNumber">field number</param> /// <param name = "data">message data to unpack from</param> /// <param name = "offset">offset in the message to start</param> /// <param name = "newOffset">offset at the end of the field for the next field</param> /// <returns>valud of the field</returns> public string Unpack(int fieldNumber, byte[] data, int offset, out int newOffset) { return(_decoratedFieldDescriptor.Unpack(fieldNumber, data, offset, out newOffset)); }