private static SS27Packet ExtractSS27Packet(TcpPacket tcpPacket) { var ss27Parser = new SS27Parser(); var jruload = tcpPacket.PayloadData; ushort jrulen = BitConverter.ToUInt16(new byte[] { jruload[1], jruload[0] }, 0); var buffer = new byte[jrulen]; Array.Copy(jruload, 2, buffer, 0, jrulen); var ss27 = (SS27Packet)ss27Parser.ParseData(buffer); return(ss27); }
public List <CapturePacket> Import(string path) { var list = new List <CapturePacket>(); string text = File.ReadAllText(path); CapturePacket prev = null; uint sortIndex = 1; var ss27Parser = new SS27Parser(); foreach (Match match in _regex.Matches(text)) { string value = match.Groups["hex"].Value; string hexstring = value.Replace(" ", ""); byte[] bytearray = StringToByteArray(hexstring); var ss27 = (SS27Packet)ss27Parser.ParseData(bytearray); var capturePacket = new CapturePacket(ProtocolType.JRU, ss27.MsgType.ToString(), ss27.DateTime); capturePacket.ParsedData = new ParsedDataSet() { ParsedFields = new List <ParsedField>(ss27.Header) }; capturePacket.No = sortIndex++; capturePacket.SS27Packet = ss27; // add to the chain //if (prev != null) // deviceLog.Previous = prev; //prev = deviceLog; list.Add(capturePacket); } return(list); }