Exemple #1
0
        public void Update(EventsArgs.OnSessionStatisticsEventArgs es)
        {
            AllowedUploadSlots       = es.AllowedUploadSlots;
            DhtDownloadRate          = es.DhtDownloadRate;
            DhtGlobalNodes           = es.DhtGlobalNodes;
            DhtNodes                 = es.DhtNodes;
            DhtNodeCache             = es.DhtNodeCache;
            DhtTorrents              = es.DhtTorrents;
            DhtTotalAllocations      = es.DhtTotalAllocations;
            DhtUploadRate            = es.DhtUploadRate;
            DiskReadQueue            = es.DiskReadQueue;
            DiskWriteQueue           = es.DiskWriteQueue;
            DownloadRate             = es.DownloadRate;
            DownBandwidthBytesQueue  = es.DownBandwidthBytesQueue;
            DownBandwidthQueue       = es.DownBandwidthQueue;
            HasIncomingConnections   = es.HasIncomingConnections;
            IpOverheadDownloadRate   = es.IpOverheadDownloadRate;
            IpOverheadUploadRate     = es.IpOverheadUploadRate;
            NumPeers                 = es.NumPeers;
            NumUnchoked              = es.NumUnchoked;
            OptimisticUnchokeCounter = es.OptimisticUnchokeCounter;
            PayloadDownloadRate      = es.PayloadDownloadRate;
            PayloadUploadRate        = es.PayloadUploadRate;
            PeerlistSize             = es.PeerlistSize;
            TotalDhtDownload         = es.TotalDhtDownload;
            TotalDhtUpload           = es.TotalDhtUpload;
            TotalDownload            = es.TotalDownload;
            TotalFailedBytes         = es.TotalFailedBytes;
            TotalIpOverheadDownload  = es.TotalIpOverheadDownload;
            TotalIpOverheadUpload    = es.TotalIpOverheadUpload;
            TotalPayloadDownload     = es.TotalPayloadDownload;
            TotalPayloadUpload       = es.TotalPayloadUpload;
            TotalRedundantBytes      = es.TotalRedundantBytes;
            TotalTrackerDownload     = es.TotalTrackerDownload;
            TotalTrackerUpload       = es.TotalTrackerUpload;
            TotalUpload              = es.TotalUpload;
            TrackerDownloadRate      = es.TrackerDownloadRate;
            TrackerUploadRate        = es.TrackerUploadRate;
            UnchokeCounter           = es.UnchokeCounter;
            UploadRate               = es.UploadRate;
            UpBandwidthBytesQueue    = es.UpBandwidthBytesQueue;
            UpBandwidthQueue         = es.UpBandwidthQueue;

            var now = DateTime.Now;

            DownloadChartValues.Add(new MeasureModel
            {
                DateTime = now,
                Value    = DownloadRate
            });

            UploadChartValues.Add(new MeasureModel
            {
                DateTime = now,
                Value    = UploadRate
            });

            SetAxisLimits(now);

            //lets only use the last 30 values
            if (DownloadChartValues.Count > 30)
            {
                DownloadChartValues.RemoveAt(0);
            }
            if (UploadChartValues.Count > 30)
            {
                UploadChartValues.RemoveAt(0);
            }
        }
        public void Update(Core.SessionStatus ss)
        {
            //AllowedUploadSlots = ss.allowed_upload_slots;
            //DhtDownloadRate = ss.dht_download_rate;
            //DhtGlobalNodes = ss.dht_global_nodes;
            //DhtNodes = ss.dht_nodes;
            //DhtNodeCache = ss.dht_node_cache;
            //DhtTorrents = ss.dht_torrents;
            //DhtTotalAllocations = ss.dht_total_allocations;
            //DhtUploadRate = ss.dht_upload_rate;
            //DiskReadQueue = ss.disk_read_queue;
            //DiskWriteQueue = ss.disk_write_queue;
            DownloadRate = ss.download_rate;
            //DownBandwidthBytesQueue = ss.down_bandwidth_bytes_queue;
            //DownBandwidthQueue = ss.down_bandwidth_queue;
            //HasIncomingConnections = ss.has_incoming_connections;
            //IpOverheadDownloadRate = ss.ip_overhead_download_rate;
            //IpOverheadUploadRate = ss.ip_overhead_upload_rate;
            NumPeers = ss.num_peers;
            //NumUnchoked = ss.num_unchoked;
            //OptimisticUnchokeCounter = ss.optimistic_unchoke_counter;
            //PayloadDownloadRate = ss.payload_download_rate;
            //PayloadUploadRate = ss.payload_upload_rate;
            //PeerlistSize = ss.peerlist_size;
            //TotalDhtDownload = ss.total_dht_download;
            //TotalDhtUpload = ss.total_dht_upload;
            TotalDownload = ss.total_download;
            //TotalFailedBytes = ss.total_failed_bytes;
            //TotalIpOverheadDownload = ss.total_ip_overhead_download;
            //TotalIpOverheadUpload = ss.total_ip_overhead_upload;
            //TotalPayloadDownload = ss.total_payload_download;
            //TotalPayloadUpload = ss.total_payload_upload;
            //TotalRedundantBytes = ss.total_redundant_bytes;
            //TotalTrackerDownload = ss.total_tracker_download;
            //TotalTrackerUpload = ss.total_tracker_upload;
            TotalUpload = ss.total_upload;
            //TrackerDownloadRate = ss.tracker_download_rate;
            //TrackerUploadRate = ss.tracker_upload_rate;
            //UnchokeCounter = ss.unchoke_counter;
            UploadRate = ss.upload_rate;
            //UpBandwidthBytesQueue = ss.up_bandwidth_bytes_queue;
            //UpBandwidthQueue = ss.up_bandwidth_queue;
            MaxDownloadRate   = ss.download_rate;
            AngularGaugeValue = (ss.download_rate.Megabytes().Megabytes / Math.Pow(10, 6)) * 8;

            var now = DateTime.Now;

            if ((now - LastUpdate).Seconds > 5)
            {
                DownloadChartValues.Add(new MeasureModel
                {
                    DateTime = now,
                    Value    = DownloadRate
                });

                UploadChartValues.Add(new MeasureModel
                {
                    DateTime = now,
                    Value    = UploadRate
                });

                SetAxisLimits(now);

                //lets only use the last 360 values
                if (DownloadChartValues.Count > 361)
                {
                    DownloadChartValues.RemoveAt(0);
                }
                if (UploadChartValues.Count > 361)
                {
                    UploadChartValues.RemoveAt(0);
                }

                DownloadXAxisMin = DownloadChartValues.Last().DateTime.Ticks - TimeSpan.FromMinutes(30).Ticks;
                UploadXAxisMin   = UploadChartValues.Last().DateTime.Ticks - TimeSpan.FromMinutes(30).Ticks;

                LastUpdate = now;
            }
        }