/// <summary> /// Calculate 24 Hour Average Hashrate /// </summary> /// <param name="MinerMonitorStatList"></param> private void Calculate24HourAverageHashrate(List <MinerMonitorStat> MinerMonitorStatList) { Hashrate24HourAverage = HashrateFormatter.Format(MinerMonitorStatList.FirstOrDefault().CoinType, MinerMonitorStatList.Average(x => x.HashRate)); // Notify UI of change OnPropertyChanged("Hashrate24HourAverage"); }
/// <summary> /// Group stats by coin to show details /// </summary> /// <param name="minerMonitorStatList"></param> private void GetMinerMonitoringSumGrouped(List <MinerMonitorStat> minerMonitorStatList) { // Populate properties for UI binding // Group stats by coin to show details List <MinerMonitorStat> minerMonitorStatListGrouped = minerMonitorStatList .Where(x => x.CoinType != CoinType.UNDEFINED) .GroupBy(l => l.CoinType) .Select(cl => new MinerMonitorStat { CoinLogo = cl.First().CoinLogo, CoinType = cl.First().CoinType, CountStats = cl.Count(), HashRate = cl.Sum(c => c.HashRate), Power = cl.Sum(c => c.Power) }).ToList(); // Format the hashrate of each grouped sum of hashrate per cointype foreach (MinerMonitorStat minerMonitorStat in minerMonitorStatListGrouped) { minerMonitorStat.DisplayHashRate = HashrateFormatter.Format(minerMonitorStat.CoinType, minerMonitorStat.HashRate); } MinerMonitorStatListGrouped = new ObservableCollection <MinerMonitorStat>(minerMonitorStatListGrouped.OrderBy(x => x.CoinType.ToString()).ToList()); // Notify UI of change OnPropertyChanged("MinerMonitorStatListGrouped"); }
/// <summary> /// Load list of miner monitor stats /// </summary> public void InitMonitorMining() { try { if (Application.Current.Properties["AccountID"] != null && WorkerName != null) { // Load list of miner monitor stats MinerMonitorStatsAPI minerMonitorStatsAPI = new MinerMonitorStatsAPI(); ObservableCollection <MinerMonitorStat> MinerMonitorStatList = minerMonitorStatsAPI.GetMinerMonitorStats(); // Filter list by worker MinerMonitorStat = MinerMonitorStatList.Where(x => x.WorkerName == WorkerName && x.CoinType == CoinType).OrderBy(y => y.Created).FirstOrDefault(); if (MinerMonitorStat != null) { // Calculate Efficiency if (MinerMonitorStat.Power <= 0 || MinerMonitorStat.HashRate <= 0) { Efficiency = "0"; } else { Efficiency = String.Format("{0}/W", HashrateFormatter.Format(MinerMonitorStat.CoinType, (MinerMonitorStat.HashRate / MinerMonitorStat.Power))); } // Notify UI of change OnPropertyChanged("MinerMonitorStat"); OnPropertyChanged("Efficiency"); } } } catch (Exception e) { ShowError(string.Format("Error loading monitor data: {0}", e.Message)); } }
/// <summary> /// Load list of miner monitor stats /// </summary> public void InitMonitorMining24Hour() { try { if (Application.Current.Properties["AccountID"] != null && WorkerName != null) { // Load list of miner monitor stats MinerMonitorStatsAPI minerMonitorStatsAPI = new MinerMonitorStatsAPI(); MinerMonitorStatList24Hour = minerMonitorStatsAPI.GetMinerMonitorStats24Hour(); // LineChart data ChartValuesHashRate = new ChartValues <DateTimePoint>(); ChartValuesPower = new ChartValues <DateTimePoint>(); // Filter list by worker List <MinerMonitorStat> MinerMonitorStatListFiltered = new List <MinerMonitorStat>(); MinerMonitorStatListFiltered = MinerMonitorStatList24Hour.Where(x => x.WorkerName == WorkerName && x.CoinType == CoinType).OrderBy(y => y.Created).ToList(); // Calculate average values and display if (MinerMonitorStatListFiltered.Count > 0) { Calculate24HourAverageHashrate(MinerMonitorStatListFiltered); Calculate24HourAveragePower(MinerMonitorStatListFiltered); } else { Hashrate24HourAverage = "0"; Power24HourAverage = "0"; } // Populate series to be graphed foreach (MinerMonitorStat minerMonitorStat in MinerMonitorStatListFiltered) { DateTimePoint dateTimePoint = new DateTimePoint(); // HashRate dateTimePoint.DateTime = minerMonitorStat.Created.ToLocalTime(); dateTimePoint.Value = HashrateFormatter.FormatNumeric(minerMonitorStat.CoinType, minerMonitorStat.HashRate); ChartValuesHashRate.Add(dateTimePoint); // Power DateTimePoint dateTimePointPower = new DateTimePoint(); dateTimePointPower.DateTime = minerMonitorStat.Created.ToLocalTime(); dateTimePointPower.Value = minerMonitorStat.Power; ChartValuesPower.Add(dateTimePointPower); } // Backfill lists as needed WorkerChartDataBackFill chartDataBackFill = new WorkerChartDataBackFill(); ChartValuesHashRate = chartDataBackFill.BackFillList(ChartValuesHashRate); ChartValuesPower = chartDataBackFill.BackFillList(ChartValuesPower); // Axis label formats XFormatter = val => new DateTime((long)val).ToString(); YFormatter = val => val.ToString(); // Notify UI of change OnPropertyChanged("ChartValuesHashRate"); OnPropertyChanged("ChartValuesPower"); } } catch (Exception e) { ShowError(string.Format("Error loading monitor data: {0}", e.Message)); } }