public static CandumpLine Parse(string line) { var ret = new CandumpLine(); // Parse time first var timeMatch = Regex.Match(line, @"\(([0-9|.]*)\)"); // We could extract the time if (timeMatch.Groups.Count == 2) { // extract the time var timeString = timeMatch.Groups[1].Value; ret.Time = DateTimeFromSpecialUnixTime(timeString); } // Now get the interface name assuming the interface is of the form " [v]<can><0-9> " (note the spaces) var interfaceMatch = Regex.Match(line, @" (v?can[0-9]) "); if (interfaceMatch.Groups.Count == 2) { ret.Interface = interfaceMatch.Groups[1].Value; } ret.Message = ParseCandumpMessage(line); return(ret); }
public override IEnumerable <Message> ParseLines(IEnumerable <string> lines, IPluginLineFilterV1 filter = null) { foreach (var line in lines) { var parsedLine = CandumpLine.Parse(line); // If we have a problem with the parsed line, just forget about it if (parsedLine == null) { continue; } // If we've got a filter if (filter != null) { // use it if (filter.ShouldAcceptLine(parsedLine.Message)) { var parsedMessage = parsedLine.Message; yield return(parsedMessage); } else { // This message didn't meet the filter continue; } } else { // no filter, pass it all yield return(parsedLine.Message); } } yield break; }
public static async Task <List <CandumpLine> > ParseStream(Stream s) { var ret = new List <CandumpLine>(); var streamLength = s.Length; using (StreamReader sr = new StreamReader(s)) { while (!sr.EndOfStream) { var progress = ((double)sr.BaseStream.Position / (double)sr.BaseStream.Length) * 100.0d; var currentLineStr = await sr.ReadLineAsync(); var currentLine = CandumpLine.Parse(currentLineStr); Debug.WriteLine(currentLine); ret.Add(currentLine); } } return(ret); }
public static List <CandumpLine> ParseLines(string[] lines, IPluginLineFilterV1 filter = null) { var ret = new List <CandumpLine>(); var pastProgress = 0; for (int i = 0; i < lines.Length; i++) { var curProgress = ((i * 100) / lines.Length); if (curProgress != pastProgress) { pastProgress = curProgress; //Debug.WriteLine(curProgress); } var currentLineStr = lines[i]; var currentLine = CandumpLine.Parse(currentLineStr); if (currentLine.Message != null) { if (filter != null) { if (filter.ShouldAcceptLine(currentLine.Message)) { ret.Add(currentLine); } else { continue; } } else { // we have no filter, accept all ret.Add(currentLine); } } } return(ret); }
public override CAN.Message ParseLine(string line) { return(CandumpLine.Parse(line).Message); }