Пример #1
0
        /// <summary>
        /// Collect stats from EWBF and post to API
        /// </summary>
        public override async void ReportStatsAsyc(Guid accountId, string workerName)
        {
            try
            {
                // Call RPC and get response
                EWBFTemplate ewbfTemplate = await GetRPCResponse();

                if (ewbfTemplate == null)
                {
                    return;
                }

                // Map response to BPM Statistics object
                MinerMonitorStat minerMonitorStat = new MinerMonitorStat();
                minerMonitorStat = MapRPCResponse(accountId, workerName, ewbfTemplate);

                if (minerMonitorStat == null)
                {
                    return;
                }

                System.Threading.Thread.Sleep(8000);
                PostMinerMonitorStat(accountId, workerName, minerMonitorStat);
            }
            catch (Exception e)
            {
                NLogProcessing.LogError(e, "Error reporting stats for EWBF");
            }
        }
Пример #2
0
        /// <summary>
        /// Map EWBF response to BPM statistics objects
        /// </summary>
        /// <param name="ewbfTemplate"></param>
        /// <returns></returns>
        private MinerMonitorStat MapRPCResponse(Guid accountId, string workerName, EWBFTemplate ewbfTemplate)
        {
            try
            {
                // Create new Miner monitor stats object
                MinerMonitorStat minerMonitorStat = new MinerMonitorStat();
                minerMonitorStat.AccountGuid   = accountId;
                minerMonitorStat.WorkerName    = workerName;
                minerMonitorStat.CoinType      = this.CoinType;
                minerMonitorStat.MinerBaseType = MinerBaseType;

                if (ewbfTemplate.result.Count > 0)
                {
                    List <GPUMonitorStat> gpuMonitorStatList = new List <GPUMonitorStat>();

                    foreach (EWBFOBjectTemplate ewbfOBjectTemplate in ewbfTemplate.result)
                    {
                        // Create new GPU monitor stats object and map values
                        GPUMonitorStat gpuMonitorStat = new GPUMonitorStat
                        {
                            AccountGuid  = accountId,
                            WorkerName   = workerName,
                            CoinType     = this.CoinType,
                            GPUID        = ewbfOBjectTemplate.gpuid,
                            HashRate     = ewbfOBjectTemplate.speed_sps,
                            FanSpeed     = 0,
                            Temp         = (short)ewbfOBjectTemplate.temperature,
                            Power        = (short)ewbfOBjectTemplate.gpu_power_usage,
                            HardwareType = Hardware
                        };

                        // Sum up power and hashrate
                        minerMonitorStat.Power    += (short)ewbfOBjectTemplate.gpu_power_usage;
                        minerMonitorStat.HashRate += ewbfOBjectTemplate.speed_sps;

                        // Add GPU stats to list
                        gpuMonitorStatList.Add(gpuMonitorStat);
                    }

                    // Set list of GPU monitor stats
                    minerMonitorStat.GPUMonitorStatList = gpuMonitorStatList;
                }

                return(minerMonitorStat);
            }
            catch (Exception e)
            {
                NLogProcessing.LogError(e, "Error mapping RPC Response for EWBF miner");

                return(null);
            }
        }