public NSTraceHeader ReadHeader() { var header = new NSTraceHeader(); // ignore one header line file.ReadLine(); // number of nodes var line = file.ReadLine(); var regex = new Regex(".+ ([0-9]+)", RegexOptions.IgnoreCase); header.NumNodes = int.Parse(regex.Match(line).Groups[1].Value); // number of sinks line = file.ReadLine(); regex = new Regex(".+ ([0-9]+)", RegexOptions.IgnoreCase); header.NumSinks = int.Parse(regex.Match(line).Groups[1].Value); // number of publishers line = file.ReadLine(); regex = new Regex(".+ ([0-9]+)", RegexOptions.IgnoreCase); header.NumPublishers = int.Parse(regex.Match(line).Groups[1].Value); // simulation duration line = file.ReadLine(); regex = new Regex(".+ ([0-9]+)", RegexOptions.IgnoreCase); header.Duration = int.Parse(regex.Match(line).Groups[1].Value); // initial energy of nodes line = file.ReadLine(); regex = new Regex(".+ ([0-9]+)", RegexOptions.IgnoreCase); header.InitialEnergy = int.Parse(regex.Match(line).Groups[1].Value); // initial energy of nodes line = file.ReadLine(); regex = new Regex(".+ ([0-9]+)", RegexOptions.IgnoreCase); header.MaxIFQLen = int.Parse(regex.Match(line).Groups[1].Value); file.ReadLine(); return(header); }
public NSTraceHeader ReadHeader() { var header = new NSTraceHeader(); // ignore one header line file.ReadLine(); // number of nodes var line = file.ReadLine(); var regex = new Regex(".+ ([0-9]+)", RegexOptions.IgnoreCase); header.NumNodes = int.Parse(regex.Match(line).Groups[1].Value); // number of sinks line = file.ReadLine(); regex = new Regex(".+ ([0-9]+)", RegexOptions.IgnoreCase); header.NumSinks = int.Parse(regex.Match(line).Groups[1].Value); // number of publishers line = file.ReadLine(); regex = new Regex(".+ ([0-9]+)", RegexOptions.IgnoreCase); header.NumPublishers = int.Parse(regex.Match(line).Groups[1].Value); // simulation duration line = file.ReadLine(); regex = new Regex(".+ ([0-9]+)", RegexOptions.IgnoreCase); header.Duration = int.Parse(regex.Match(line).Groups[1].Value); // initial energy of nodes line = file.ReadLine(); regex = new Regex(".+ ([0-9]+)", RegexOptions.IgnoreCase); header.InitialEnergy = int.Parse(regex.Match(line).Groups[1].Value); // initial energy of nodes line = file.ReadLine(); regex = new Regex(".+ ([0-9]+)", RegexOptions.IgnoreCase); header.MaxIFQLen = int.Parse(regex.Match(line).Groups[1].Value); file.ReadLine(); return header; }