private void Update(SyncthingConnectionStats stats)
        {
            var    now      = DateTime.UtcNow;
            double earliest = (now - window - epoch).TotalSeconds;

            this.Update(earliest, this.inboundSeries, stats.InBytesPerSecond);
            this.Update(earliest, this.outboundSeries, stats.OutBytesPerSecond);

            this.xAxis.Minimum = earliest;
            this.xAxis.Maximum = (now - epoch).TotalSeconds;

            // This increases the value to the nearest 1024 boundary
            double maxValue = this.inboundSeries.Points.Concat(this.outboundSeries.Points).Max(x => x.Y);
            double roundedMax;

            if (maxValue > minYValue)
            {
                double factor = Math.Pow(1024, (int)Math.Log(maxValue, 1024));
                roundedMax = Math.Ceiling(maxValue / factor) * factor;
            }
            else
            {
                roundedMax = minYValue;
            }

            // Give the graph a little bit of headroom, otherwise the line gets chopped
            this.yAxis.Maximum = roundedMax * 1.05;
            this.MaxYValue     = FormatUtils.BytesToHuman(roundedMax) + "/s";

            if (this.IsActive)
            {
                this.OxyPlotModel.InvalidatePlot(true);
            }
        }
示例#2
0
 private void UpdateConnectionStats(SyncthingConnectionStats connectionStats)
 {
     if (this.syncthingManager.State == SyncthingState.Running)
     {
         this.UpdateConnectionStats(connectionStats.InBytesPerSecond, connectionStats.OutBytesPerSecond);
     }
     else
     {
         this.UpdateConnectionStats(null, null);
     }
 }
示例#3
0
 private void UpdateConnectionStats(SyncthingConnectionStats connectionStats)
 {
     if (connectionStats == null)
     {
         this.InConnectionRate  = "0.0B";
         this.OutConnectionRate = "0.0B";
     }
     else
     {
         this.InConnectionRate  = FormatUtils.BytesToHuman(connectionStats.InBytesPerSecond, 1);
         this.OutConnectionRate = FormatUtils.BytesToHuman(connectionStats.OutBytesPerSecond, 1);
     }
 }