Пример #1
0
        public async override Task <ApiData> GetMinerStatsDataAsync()
        {
            var apiDevsResult = await SgminerAPIHelpers.GetApiDevsRootAsync(_apiPort, _logGroup);

            var ad = new ApiData();

            if (apiDevsResult == null)
            {
                return(ad);
            }

            try
            {
                var deviveStats        = apiDevsResult.DEVS;
                var perDeviceSpeedInfo = new Dictionary <string, IReadOnlyList <AlgorithmTypeSpeedPair> >();
                var perDevicePowerInfo = new Dictionary <string, int>();
                var totalSpeed         = 0d;
                var totalPowerUsage    = 0;

                // the devices have ordered ids by -d parameter, so -d 4,2 => 4=0;2=1
                foreach (var kvp in _initOrderMirrorApiOrderUUIDs)
                {
                    var gpuID   = kvp.Key;
                    var gpuUUID = kvp.Value;

                    var deviceStats = deviveStats
                                      .Where(devStat => gpuID == devStat.GPU)
                                      .FirstOrDefault();
                    if (deviceStats == null)
                    {
                        continue;
                    }

                    var speedHS = deviceStats.KHS_av * 1000;
                    totalSpeed += speedHS;
                    perDeviceSpeedInfo.Add(gpuUUID, new List <AlgorithmTypeSpeedPair>()
                    {
                        new AlgorithmTypeSpeedPair(_algorithmType, speedHS * (1 - DevFee * 0.01))
                    });
                    // TODO check PowerUsage API
                }
                ad.AlgorithmSpeedsTotal = new List <AlgorithmTypeSpeedPair> {
                    new AlgorithmTypeSpeedPair(_algorithmType, totalSpeed * (1 - DevFee * 0.01))
                };
                ad.PowerUsageTotal          = totalPowerUsage;
                ad.AlgorithmSpeedsPerDevice = perDeviceSpeedInfo;
                ad.PowerUsagePerDevice      = perDevicePowerInfo;
            }
            catch (Exception e)
            {
                Logger.Error(_logGroup, $"Error occured while getting API stats: {e.Message}");
            }

            return(ad);
        }
Пример #2
0
        public async override Task <ApiData> GetMinerStatsDataAsync()
        {
            var apiDevsResult = await SgminerAPIHelpers.GetApiDevsRootAsync(_apiPort);

            var ad = new ApiData();

            if (apiDevsResult == null)
            {
                return(ad);
            }

            try
            {
                var deviveStats        = apiDevsResult.DEVS;
                var perDeviceSpeedInfo = new List <(string uuid, IReadOnlyList <(AlgorithmType, double)>)>();
                var perDevicePowerInfo = new List <(string, int)>();
                var totalSpeed         = 0d;
                var totalPowerUsage    = 0;

                // the devices have ordered ids by -d parameter, so -d 4,2 => 4=0;2=1
                foreach (var kvp in _initOrderMirrorApiOrderUUIDs)
                {
                    var gpuID   = kvp.Key;
                    var gpuUUID = kvp.Value;

                    var deviceStats = deviveStats
                                      .Where(devStat => gpuID == devStat.GPU)
                                      .FirstOrDefault();
                    if (deviceStats == null)
                    {
                        continue;
                    }

                    var speedHS = deviceStats.KHS_av * 1000;
                    totalSpeed += speedHS;
                    perDeviceSpeedInfo.Add((gpuUUID, new List <(AlgorithmType, double)>()
                    {
                        (_algorithmType, speedHS)
                    }));
                    // TODO check PowerUsage API
                }
                ad.AlgorithmSpeedsTotal = new List <(AlgorithmType, double)> {
                    (_algorithmType, totalSpeed)
                };
                ad.PowerUsageTotal = totalPowerUsage;
            }
            catch (Exception ex)
            {
                //Console.WriteLine($"TeamRedMiner.GetMinerStatsDataAsync exception: {ex.Message}");
                //return null;
            }

            return(ad);
        }