public TLVGroup FindGroup(int groupTag) { TLVGroup matchTlv = this.TlvGroups.Find(delegate(TLVGroup grp) { return(grp.GroupTag == groupTag); }); return(matchTlv); }
internal static FPUMessage Parse(byte[] bytesRead) { FPUMessage fpuMessage = new FPUMessage(); int index = 0; int len = bytesRead.Length; int lastGrpId = 0; byte[] value; while (true) { try { if (index >= (len)) { break; } //get next tag int currIndex = index + 1; int tag = MessageBuilder.GetTag(bytesRead, index, out index); int tagLength = MessageBuilder.GetLength(bytesRead, index, out index); if (tag == FPUDataTags.ENDOFMSG) { index += tagLength; continue; } value = new byte[tagLength]; Array.Copy(bytesRead, index, value, 0, tagLength); // if it is tag if (index - currIndex == GMPConstants.LEN_DATA_TAG) { TLV tlv = new TLV(tag, tagLength, value); // check there is defined group id before if (lastGrpId > 0) { TLVGroup matchTlv = fpuMessage.FindGroup(lastGrpId); if (matchTlv == null) { matchTlv = new TLVGroup(tag); } matchTlv.Add(tlv); } else { fpuMessage.AddTag(tlv); } index += tagLength; } else { lastGrpId = tag; fpuMessage.AddGroup(new TLVGroup(tag)); } } catch (System.Exception ex) { } } return(fpuMessage); }
public void AddGroup(TLVGroup tlvGroup) { tlvGroups.Add(tlvGroup); }