Exemplo n.º 1
0
        public void LoadDataAsync(DateTime startUtc, TimeSpan timeSpan, double requestedDensity, Action <IEnumerable <SummaryData> > callback)
        {
            var worker = new System.ComponentModel.BackgroundWorker();

            worker.DoWork += (s, e) =>
            {
                lock (this.padlock)
                {
                    SummaryData initialPoint;
                    var         data = this.allKnownSummaryData.Value.Where(p => p.TimestampUtc >= startUtc).ToList();
                    if (data.Count == 0)
                    {
                        initialPoint = new SummaryData()
                        {
                            TimestampUtc = startUtc.AddSeconds(-1) + timeSpan,
                            TotalKiloHashesAverage5Sec = 1.0 / 10000
                        };

                        data.Add(initialPoint);
                    }
                    else
                    {
                        this.EnsureFixedDensity(data, startUtc, timeSpan, requestedDensity);
                    }

                    this.PrefixPadData(data, startUtc, timeSpan.TotalMilliseconds / Math.Max(requestedDensity, 100));

                    callback(data.OrderBy(p => p.TimestampUtc).ToList());
                }
            };

            worker.RunWorkerAsync();
        }
Exemplo n.º 2
0
        private void PerformSummaryNotification(string json)
        {
            SummaryData data;

            if (string.IsNullOrEmpty(json))
            {
                data = new SummaryData()
                {
                    TimestampUtc               = DateTime.UtcNow,
                    TotalHardwareErrors        = 0,
                    TotalKiloHashesAverage5Sec = 1 / 10000,
                    TotalStale = 0
                };
            }
            else
            {
                var    d       = JsonConvert.DeserializeObject <dynamic>(json);
                JArray summary = d.SUMMARY;

                data = new SummaryData()
                {
                    TimestampUtc               = DateTime.UtcNow,
                    TotalHardwareErrors        = summary.Select(s => (int)s["Hardware Errors"]).Sum(),
                    TotalKiloHashesAverage5Sec = Math.Max(summary.Select(s => (double)s["MHS 5s"]).Sum() * 1000, 1 / 10000),
                    TotalStale = summary.Select(s => (int)s["Stale"]).Sum()
                };
            }

            this.Summary(this, new SummaryEventArgs()
            {
                Summary = data
            });
        }
Exemplo n.º 3
0
 public void Add(SummaryData summaryData)
 {
     this.allKnownSummaryData.Value.Add(summaryData);
     this.unsavedData = true;
 }
Exemplo n.º 4
0
        private void PerformSummaryNotification(string json)
        {
            SummaryData data;

            if (string.IsNullOrEmpty(json))
            {
                data = new SummaryData()
                {
                    TimestampUtc = DateTime.UtcNow,
                    TotalHardwareErrors = 0,
                    TotalKiloHashesAverage5Sec = 1 /10000,
                    TotalStale = 0
                };
            }
            else
            {
                var d = JsonConvert.DeserializeObject<dynamic>(json);
                JArray summary = d.SUMMARY;

                data = new SummaryData()
                {
                    TimestampUtc = DateTime.UtcNow,
                    TotalHardwareErrors = summary.Select(s => (int)s["Hardware Errors"]).Sum(),
                    TotalKiloHashesAverage5Sec = Math.Max(summary.Select(s => (double)s["MHS 5s"]).Sum() * 1000, 1 / 10000),
                    TotalStale = summary.Select(s => (int)s["Stale"]).Sum()
                };
            }

            this.Summary(this, new SummaryEventArgs() { Summary = data });
        }
Exemplo n.º 5
0
        private void UpdateSummaryData(SummaryData summaryData)
        {
            TrimToGraphRange(this.DataPointsHashRate, this.SelectedGraphTimeSpan.Span);

            // add the data point to our series if it will actually result in an additional pixel, this prevents the graph from getting overloaded with too many
            // data points even if the UI stays open for long periods of time (for example, a new point every 10 seconds at 7d time range - that would result
            // in a very high density that would impact performance while not actually showing any additional detail on the screen)
            var dataPoint = new DataPoint() { TimeLocal = summaryData.TimestampUtc.ToLocalTime(), Value = summaryData.TotalKiloHashesAverage5Sec };
            var minimumGap = TimeSpan.FromMilliseconds(this.SelectedGraphTimeSpan.Span.TotalMilliseconds / Math.Max(this.GraphWidth, InitialWindowWidth));
            if (this.DataPointsHashRate.Count == 0 || (dataPoint.TimeLocal - this.DataPointsHashRate.Last().TimeLocal) >= minimumGap)
            {
                PerformFlatLineFix(this.DataPointsHashRate, dataPoint);

                this.DataPointsHashRate.Add(dataPoint);
            }

            // inform the data manager about the new point (regardless of display density logic)
            if (this.summaryDataManager != null)
            {
                this.summaryDataManager.Add(summaryData);
            }

            this.ApplicationTitle = string.Format("Mining Controller ({0:0.#} KH/s)", summaryData.TotalKiloHashesAverage5Sec);
        }