private void AddFilterTrace(FilterTrace filterTrace) { // Check filters if (DoesTracePassFilters(filterTrace, FilterInclude.Include) && DoesTracePassFilters(filterTrace, FilterInclude.Exclude)) { // cull traces if (maxTraces > 0) { while (lvTraces.Items.Count >= maxTraces) { lvTraces.Items.RemoveAt(0); } } // Create a new row. ListViewItem item = new ListViewItem(filterTrace.DeviceId.ToString()); for (int i = 1; i < lvTraces.Columns.Count; i++) { switch (i) { case 1: item.SubItems.Add(filterTrace.TypeToStr()); break; case 2: item.SubItems.Add(filterTrace.GetTimestampDelta(prevTrace).ToString()); break; case 3: if (filterTrace.Buffer != null) { item.SubItems.Add(filterTrace.Buffer.Length.ToString()); } else { item.SubItems.Add(Convert.ToString(0)); } break; case 4: item.SubItems.Add(filterTrace.BufToHex()); break; case 5: item.SubItems.Add(filterTrace.BufToChars()); break; } } lvTraces.TopItem = lvTraces.Items.Add(item); prevTrace = filterTrace; } }
public BUSDOG_TIMESTAMP GetTimestampDelta(FilterTrace prevTrace) { BUSDOG_TIMESTAMP delta = new BUSDOG_TIMESTAMP(); if (prevTrace.Timestamp.Seconds > 0 || prevTrace.Timestamp.USec > 0) { delta.Seconds = Timestamp.Seconds - prevTrace.Timestamp.Seconds; delta.USec = Timestamp.USec - prevTrace.Timestamp.USec; if (delta.USec < 0) { delta.USec = 1000000 + delta.USec; } } return(delta); }
private void btnClearTraces_Click(object sender, EventArgs e) { lvTraces.Items.Clear(); prevTrace = new FilterTrace(); }
private bool DoesTracePassFilters(FilterTrace filterTrace, FilterInclude include) { List<FilterMatch> filters; if (include == FilterInclude.Include) filters = filterControl.IncludeFilters; else filters = filterControl.ExcludeFilters; if (filters.Count == 0) return true; bool check = true; foreach (FilterMatch filter in filters) { switch (filter.FilterType) { case FilterType.Length: switch (filter.LengthMatch) { case LengthMatch.GreaterThen: check = filterTrace.Buffer.Length > filter.Length; break; case LengthMatch.LessThen: check = filterTrace.Buffer.Length < filter.Length; break; case LengthMatch.EqualTo: check = filterTrace.Buffer.Length == filter.Length; break; } break; case FilterType.Hex: check = filterTrace.BufToHex().Contains(filter.Filter); break; case FilterType.Ascii: check = filterTrace.BufToChars().Contains(filter.Filter); break; } if (include == FilterInclude.Include) { if (check) return true; else continue; } else { if (check) return false; else continue; } } if (include == FilterInclude.Include) return false; else return true; }
private void AddFilterTrace(FilterTrace filterTrace) { // Check filters if (DoesTracePassFilters(filterTrace, FilterInclude.Include) && DoesTracePassFilters(filterTrace, FilterInclude.Exclude)) { // cull traces if (maxTraces > 0) { while (lvTraces.Items.Count >= maxTraces) lvTraces.Items.RemoveAt(0); } // Create a new row. ListViewItem item = new ListViewItem(filterTrace.DeviceId.ToString()); for (int i = 1; i < lvTraces.Columns.Count; i++) { switch (i) { case 1: item.SubItems.Add(filterTrace.TypeToStr()); break; case 2: item.SubItems.Add(filterTrace.GetTimestampDelta(prevTrace).ToString()); break; case 3: if (filterTrace.Buffer != null) item.SubItems.Add(filterTrace.Buffer.Length.ToString()); else item.SubItems.Add(Convert.ToString(0)); break; case 4: item.SubItems.Add(filterTrace.BufToHex()); break; case 5: item.SubItems.Add(filterTrace.BufToChars()); break; } } lvTraces.TopItem = lvTraces.Items.Add(item); prevTrace = filterTrace; } }
public BUSDOG_TIMESTAMP GetTimestampDelta(FilterTrace prevTrace) { BUSDOG_TIMESTAMP delta = new BUSDOG_TIMESTAMP(); if (prevTrace.Timestamp.Seconds > 0 || prevTrace.Timestamp.USec > 0) { delta.Seconds = Timestamp.Seconds - prevTrace.Timestamp.Seconds; delta.USec = Timestamp.USec - prevTrace.Timestamp.USec; if (delta.USec < 0) delta.USec = 1000000 + delta.USec; } return delta; }
private bool DoesTracePassFilters(FilterTrace filterTrace, FilterInclude include) { List <FilterMatch> filters; if (include == FilterInclude.Include) { filters = filterControl.IncludeFilters; } else { filters = filterControl.ExcludeFilters; } if (filters.Count == 0) { return(true); } bool check = true; foreach (FilterMatch filter in filters) { switch (filter.FilterType) { case FilterType.Length: switch (filter.LengthMatch) { case LengthMatch.GreaterThen: check = filterTrace.Buffer.Length > filter.Length; break; case LengthMatch.LessThen: check = filterTrace.Buffer.Length < filter.Length; break; case LengthMatch.EqualTo: check = filterTrace.Buffer.Length == filter.Length; break; } break; case FilterType.Hex: check = filterTrace.BufToHex().Contains(filter.Filter); break; case FilterType.Ascii: check = filterTrace.BufToChars().Contains(filter.Filter); break; } if (include == FilterInclude.Include) { if (check) { return(true); } else { continue; } } else { if (check) { return(false); } else { continue; } } } if (include == FilterInclude.Include) { return(false); } else { return(true); } }