Exemple #1
0
        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;
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
 public override CAN.Message ParseLine(string line)
 {
     return(CandumpLine.Parse(line).Message);
 }