private void UpdateTrace(Trace trace) { var lineSeries = new List <StairStepSeries>(trace.ChannelCount * 2); lineSeries.AddRange(GetLineSeriesForHost(trace, Host.A)); lineSeries.AddRange(GetLineSeriesForHost(trace, Host.B)); var model = new PlotModel(); foreach (var serie in lineSeries) { model.Series.Add(serie); } Plot.Model = model; //model.Series[1].IsVisible }
private static IEnumerable <StairStepSeries> GetLineSeriesForHost(Trace trace, Host host) { var res = new List <StairStepSeries>(trace.ChannelCount * 2); for (var i = 0; i < trace.ChannelCount * 2; i++) { var channelId = i / 2; var type = i % 2 == 0 ? "Recv" : "Xmit"; res.Add(new StairStepSeries() { Smooth = true, MarkerType = MarkerType.Diamond, Title = $@"{host}[{channelId}] {type}" }); } foreach (var itemChannel in trace.GetLastTraceItemChannelsFor(host)) { for (var i = 0; i < trace.ChannelCount; i++) { if (itemChannel.PreviousTime == long.MinValue) { continue; } var channel = itemChannel.Channels[i]; var time0 = (itemChannel.PreviousTime - trace.FirstTime) / (double)Stopwatch.Frequency; var time1 = (itemChannel.Time - trace.FirstTime) / (double)Stopwatch.Frequency; res[i * 2].Points.Add(new DataPoint(time0, channel.RecvPositionSpeedKbps)); res[i * 2].Points.Add(new DataPoint(time1, channel.RecvPositionSpeedKbps)); res[i * 2 + 1].Points.Add(new DataPoint(time0, channel.XmitPositionSpeedKbps)); res[i * 2 + 1].Points.Add(new DataPoint(time1, channel.XmitPositionSpeedKbps)); Console.WriteLine($@"{host}ch[{channel}]: {time0} {time1} -> {channel.RecvPositionSpeedKbps}"); } } return(res); }