コード例 #1
0
        public void UpdateTrafficList(Traffic traffic)
        {
            long maxSpeedValue = 0;

            inboundPoints.Clear();
            outboundPoints.Clear();

            lock (logList)
            {
                if (traffic != null)
                {
                    this.traffic = traffic;
                    #region Add to trafficLogList
                    TrafficLog previous = logList.Last.Value;
                    TrafficLog current  = new TrafficLog(
                        new Traffic(traffic),
                        new Traffic(traffic, previous.total)
                        );
                    logList.AddLast(current);

                    while (logList.Count > trafficLogSize)
                    {
                        logList.RemoveFirst();
                    }
                    while (logList.Count < trafficLogSize)
                    {
                        logList.AddFirst(new TrafficLog());
                    }
                    #endregion
                }

                lastLog = logList.Last.Value;
                foreach (TrafficLog item in logList)
                {
                    inboundPoints.Add(item.speed.inbound);
                    outboundPoints.Add(item.speed.outbound);

                    maxSpeedValue = Math.Max(maxSpeedValue,
                                             Math.Max(item.speed.inbound, item.speed.outbound)
                                             );
                }
            }

            maxSpeed = new FormattedSize(maxSpeedValue);

            for (int i = 0; i < inboundPoints.Count; i++)
            {
                inboundPoints[i]  /= maxSpeed.scale;
                outboundPoints[i] /= maxSpeed.scale;
            }

            if (TrafficChart.InvokeRequired)
            {
                TrafficChart.Invoke(new Action(UpdateTrafficChart));
            }
            else
            {
                UpdateTrafficChart();
            }
        }
コード例 #2
0
        private void UpdateTrafficList()
        {
            lock (trafficLogList)
            {
                TrafficLog previous = trafficLogList.Last.Value;
                TrafficLog current  = new TrafficLog(
                    new Traffic(rawTrafficStatistics),
                    new Traffic(rawTrafficStatistics, previous.raw)
                    );
                trafficLogList.AddLast(current);

                while (trafficLogList.Count > trafficLogSize)
                {
                    trafficLogList.RemoveFirst();
                }
                while (trafficLogList.Count < trafficLogSize)
                {
                    trafficLogList.AddFirst(new TrafficLog());
                }
            }
        }