public void Add(TimePacketBuilder packetBuilder) { try { if (packetBuilder != null && packetBuilder.DataLength > 0) { TimePacket packet = packetBuilder.ToTimePacket(); m_Packets.Add(packet); UpdateTables(packet); } } catch { } }
public void Add( TimePacketBuilder packetBuilder ) { try { if ( packetBuilder != null && packetBuilder.DataLength > 0 ) { TimePacket packet = packetBuilder.ToTimePacket(); m_Packets.Add( packet ); UpdateTables( packet ); } } catch { } }
public void Load(StreamReader reader) { Clear(); string line; TimePacketBuilder packetBuilder = null; while ((line = reader.ReadLine()) != null) { try { line = line.Trim().ToLower(); if (line == "") { continue; } if (line.StartsWith("packet -")) { string[] bytes = line.Substring(8).Trim().Split(' '); foreach (string s in bytes) { byte b = Byte.Parse(s, System.Globalization.NumberStyles.HexNumber); packetBuilder.AddData(b); } continue; } if (line.StartsWith("time -")) { string time = line.Substring(6).Trim(); packetBuilder.Time = DateTime.Parse(time); continue; } bool def; try { Int32.Parse(line.Substring(0, 4), System.Globalization.NumberStyles.HexNumber); def = true; } catch { def = false; } if (def && line[4] == ':') { if (line.StartsWith("0000") && packetBuilder.DataLength != 0) { Add(packetBuilder); packetBuilder = new TimePacketBuilder(); } string[] bytes = line.Substring(5, 3 * 0x10).Trim().Split(' '); foreach (string s in bytes) { byte b = Byte.Parse(s, System.Globalization.NumberStyles.HexNumber); packetBuilder.AddData(b); } continue; } if (line.IndexOf("send") >= 0 || line.IndexOf("client -> server") >= 0 || line.IndexOf("client->server") >= 0) { Add(packetBuilder); packetBuilder = new TimePacketBuilder(); packetBuilder.Send = true; string[] tmp = line.Replace("-", "").Split(); foreach (string s in tmp) { try { packetBuilder.Time = DateTime.Parse(s); break; } catch { } } continue; } if (line.IndexOf("recv") >= 0 || line.IndexOf("receive") >= 0 || line.IndexOf("server -> client") >= 0 || line.IndexOf("server->client") >= 0) { Add(packetBuilder); packetBuilder = new TimePacketBuilder(); packetBuilder.Send = false; string[] tmp = line.Replace("-", "").Split(); foreach (string s in tmp) { try { packetBuilder.Time = DateTime.Parse(s); break; } catch { } } continue; } if (line.IndexOf("client") >= 0) { Add(packetBuilder); packetBuilder = new TimePacketBuilder(); packetBuilder.Send = true; string[] tmp = line.Replace("-", "").Split(); foreach (string s in tmp) { try { packetBuilder.Time = DateTime.Parse(s); break; } catch { } } continue; } if (line.IndexOf("server") >= 0) { Add(packetBuilder); packetBuilder = new TimePacketBuilder(); packetBuilder.Send = false; string[] tmp = line.Replace("-", "").Split(); foreach (string s in tmp) { try { packetBuilder.Time = DateTime.Parse(s); break; } catch { } } continue; } } catch { } } Add(packetBuilder); }
public void Load( StreamReader reader ) { Clear(); string line; TimePacketBuilder packetBuilder = null; while ( (line = reader.ReadLine()) != null ) { try { line = line.Trim().ToLower(); if ( line == "" ) continue; if ( line.StartsWith( "packet -" ) ) { string[] bytes = line.Substring( 8 ).Trim().Split( ' ' ); foreach ( string s in bytes ) { byte b = Byte.Parse( s, System.Globalization.NumberStyles.HexNumber ); packetBuilder.AddData( b ); } continue; } if ( line.StartsWith( "time -" ) ) { string time = line.Substring( 6 ).Trim(); packetBuilder.Time = DateTime.Parse( time ); continue; } bool def; try { Int32.Parse( line.Substring( 0, 4 ), System.Globalization.NumberStyles.HexNumber ); def = true; } catch { def = false; } if ( def && line[4] == ':' ) { if ( line.StartsWith( "0000" ) && packetBuilder.DataLength != 0 ) { Add( packetBuilder ); packetBuilder = new TimePacketBuilder(); } string[] bytes = line.Substring( 5, 3*0x10 ).Trim().Split( ' ' ); foreach ( string s in bytes ) { byte b = Byte.Parse( s, System.Globalization.NumberStyles.HexNumber ); packetBuilder.AddData( b ); } continue; } if ( line.IndexOf( "send" ) >= 0 || line.IndexOf( "client -> server" ) >= 0 || line.IndexOf( "client->server" ) >= 0 ) { Add( packetBuilder ); packetBuilder = new TimePacketBuilder(); packetBuilder.Send = true; string[] tmp = line.Replace( "-", "" ).Split(); foreach ( string s in tmp ) { try { packetBuilder.Time = DateTime.Parse( s ); break; } catch { } } continue; } if ( line.IndexOf( "recv" ) >= 0 || line.IndexOf( "receive" ) >= 0 || line.IndexOf( "server -> client" ) >= 0 || line.IndexOf( "server->client" ) >= 0 ) { Add( packetBuilder ); packetBuilder = new TimePacketBuilder(); packetBuilder.Send = false; string[] tmp = line.Replace( "-", "" ).Split(); foreach ( string s in tmp ) { try { packetBuilder.Time = DateTime.Parse( s ); break; } catch { } } continue; } if ( line.IndexOf( "client" ) >= 0 ) { Add( packetBuilder ); packetBuilder = new TimePacketBuilder(); packetBuilder.Send = true; string[] tmp = line.Replace( "-", "" ).Split(); foreach ( string s in tmp ) { try { packetBuilder.Time = DateTime.Parse( s ); break; } catch { } } continue; } if ( line.IndexOf( "server" ) >= 0 ) { Add( packetBuilder ); packetBuilder = new TimePacketBuilder(); packetBuilder.Send = false; string[] tmp = line.Replace( "-", "" ).Split(); foreach ( string s in tmp ) { try { packetBuilder.Time = DateTime.Parse( s ); break; } catch { } } continue; } } catch { } } Add( packetBuilder ); }