private void BuildDmaVisuals() { List<DmaPacket> queue = new List<DmaPacket>(); DateTime lastEndTime = DateTime.MinValue; foreach (DmaPacket packet in trace.GetDmaPackets()) { // Three cases: // 1. We have a queue already, and the new packet's start time is less than // the current queue's ending time. Add it to the queue for later processing // 2. We have a queue already, and the new packet's start time is after last // ending time in queue. Process the full queue, then start a new one with this item // 3. The queue is empty, just start one with this if (queue.Count != 0) { if (packet.Start < lastEndTime) { queue.Add(packet); if (packet.End > lastEndTime) { lastEndTime = packet.End; } } else { // // Flush the queue // // first item gets a full visual in one piece DmaPacketVisual visual = new DmaPacketVisual(); visual.Packet = queue[0]; visual.StartTime = visual.Packet.Start; visual.EndTime = visual.Packet.End; visual.Height = 0; dmaVisuals.Add(visual); // the remainder queue up & split up based on previous end times for (int i = 1; i < queue.Count; ++i) { int height = i; DateTime start = queue[i].Start; for (int j = 0; j <= i; ++j) { visual = new DmaPacketVisual(); visual.Packet = queue[i]; visual.StartTime = start; visual.EndTime = queue[j].End; visual.Height = height; Debug.Assert(height >= 0); height--; start = visual.EndTime; dmaVisuals.Add(visual); } } queue.Clear(); queue.Add(packet); lastEndTime = packet.End; } } else { queue.Add(packet); lastEndTime = packet.End; } } }
private void BuildDmaVisuals() { List <DmaPacket> queue = new List <DmaPacket>(); DateTime lastEndTime = DateTime.MinValue; foreach (DmaPacket packet in trace.GetDmaPackets()) { // Three cases: // 1. We have a queue already, and the new packet's start time is less than // the current queue's ending time. Add it to the queue for later processing // 2. We have a queue already, and the new packet's start time is after last // ending time in queue. Process the full queue, then start a new one with this item // 3. The queue is empty, just start one with this if (queue.Count != 0) { if (packet.Start < lastEndTime) { queue.Add(packet); if (packet.End > lastEndTime) { lastEndTime = packet.End; } } else { // // Flush the queue // // first item gets a full visual in one piece DmaPacketVisual visual = new DmaPacketVisual(); visual.Packet = queue[0]; visual.StartTime = visual.Packet.Start; visual.EndTime = visual.Packet.End; visual.Height = 0; dmaVisuals.Add(visual); // the remainder queue up & split up based on previous end times for (int i = 1; i < queue.Count; ++i) { int height = i; DateTime start = queue[i].Start; for (int j = 0; j <= i; ++j) { visual = new DmaPacketVisual(); visual.Packet = queue[i]; visual.StartTime = start; visual.EndTime = queue[j].End; visual.Height = height; Debug.Assert(height >= 0); height--; start = visual.EndTime; dmaVisuals.Add(visual); } } queue.Clear(); queue.Add(packet); lastEndTime = packet.End; } } else { queue.Add(packet); lastEndTime = packet.End; } } }