예제 #1
0
        private static void PickTotalSpeed(INTMinerRoot root, string input, IKernelOutput kernelOutput, bool isDual)
        {
            string totalSpeedPattern = kernelOutput.TotalSpeedPattern;

            if (isDual)
            {
                totalSpeedPattern = kernelOutput.DualTotalSpeedPattern;
            }
            if (string.IsNullOrEmpty(totalSpeedPattern))
            {
                return;
            }
            Regex regex = VirtualRoot.GetRegex(totalSpeedPattern);
            Match match = regex.Match(input);

            if (match.Success)
            {
                string totalSpeedText = match.Groups[NTKeyword.TotalSpeedGroupName].Value;
                string totalSpeedUnit = match.Groups[NTKeyword.TotalSpeedUnitGroupName].Value;
                if (string.IsNullOrEmpty(totalSpeedUnit))
                {
                    if (isDual)
                    {
                        totalSpeedUnit = kernelOutput.DualSpeedUnit;
                    }
                    else
                    {
                        totalSpeedUnit = kernelOutput.SpeedUnit;
                    }
                }
                double totalSpeed;
                if (double.TryParse(totalSpeedText, out totalSpeed))
                {
                    double     totalSpeedL = totalSpeed.FromUnitSpeed(totalSpeedUnit);
                    var        now         = DateTime.Now;
                    IGpusSpeed gpuSpeeds   = NTMinerRoot.Instance.GpusSpeed;
                    gpuSpeeds.SetCurrentSpeed(NTMinerRoot.GpuAllId, totalSpeedL, isDual, now);
                    string gpuSpeedPattern = kernelOutput.GpuSpeedPattern;
                    if (isDual)
                    {
                        gpuSpeedPattern = kernelOutput.DualGpuSpeedPattern;
                    }
                    if (string.IsNullOrEmpty(gpuSpeedPattern) && root.GpuSet.Count != 0)
                    {
                        // 平分总算力
                        double gpuSpeedL = totalSpeedL / root.GpuSet.Count;
                        foreach (var item in gpuSpeeds)
                        {
                            if (item.Gpu.Index != NTMinerRoot.GpuAllId)
                            {
                                gpuSpeeds.SetCurrentSpeed(item.Gpu.Index, gpuSpeedL, isDual, now);
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        private static void PickGpuSpeed(string input, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string gpuSpeedPattern = kernelOutput.GpuSpeedPattern;

            if (isDual)
            {
                gpuSpeedPattern = kernelOutput.DualGpuSpeedPattern;
            }
            if (string.IsNullOrEmpty(gpuSpeedPattern))
            {
                return;
            }
            var             now      = DateTime.Now;
            bool            hasGpuId = gpuSpeedPattern.Contains("?<gpu>");
            Regex           regex    = new Regex(gpuSpeedPattern);
            MatchCollection matches  = regex.Matches(input);

            if (matches.Count > 0)
            {
                IGpusSpeed gpuSpeeds = NTMinerRoot.Instance.GpusSpeed;
                for (int i = 0; i < matches.Count; i++)
                {
                    Match  match        = matches[i];
                    string gpuSpeedText = match.Groups["gpuSpeed"].Value;
                    string gpuSpeedUnit = match.Groups["gpuSpeedUnit"].Value;

                    int gpu = i;
                    if (hasGpuId)
                    {
                        string gpuText = match.Groups["gpu"].Value;
                        if (!int.TryParse(gpuText, out gpu))
                        {
                            gpu = i;
                        }
                    }
                    double gpuSpeed;
                    if (double.TryParse(gpuSpeedText, out gpuSpeed))
                    {
                        double gpuSpeedL = gpuSpeed.FromUnitSpeed(gpuSpeedUnit);
                        gpuSpeeds.SetCurrentSpeed(gpu, gpuSpeedL, isDual, now);
                    }
                }
                string totalSpeedPattern = kernelOutput.DualTotalSpeedPattern;
                if (isDual)
                {
                    totalSpeedPattern = kernelOutput.DualTotalSpeedPattern;
                }
                if (string.IsNullOrEmpty(totalSpeedPattern))
                {
                    // 求和分算力
                    double speed = isDual? gpuSpeeds.Where(a => a.Gpu.Index != NTMinerRoot.GpuAllId).Sum(a => a.DualCoinSpeed.Value)
                                         : gpuSpeeds.Where(a => a.Gpu.Index != NTMinerRoot.GpuAllId).Sum(a => a.MainCoinSpeed.Value);
                    gpuSpeeds.SetCurrentSpeed(NTMinerRoot.GpuAllId, speed, isDual, now);
                }
            }
        }
예제 #3
0
        private static void PickTotalSpeed(INTMinerContext context, string line, IKernelOutput kernelOutput, bool isDual)
        {
            string totalSpeedPattern = kernelOutput.TotalSpeedPattern;

            if (isDual)
            {
                totalSpeedPattern = kernelOutput.DualTotalSpeedPattern;
            }
            if (string.IsNullOrEmpty(totalSpeedPattern))
            {
                return;
            }
            Regex regex = VirtualRoot.GetRegex(totalSpeedPattern);
            Match match = regex.Match(line);

            if (match.Success)
            {
                string totalSpeedText = match.Groups[NTKeyword.TotalSpeedGroupName].Value;
                string totalSpeedUnit = match.Groups[NTKeyword.TotalSpeedUnitGroupName].Value;
                if (string.IsNullOrEmpty(totalSpeedUnit))
                {
                    if (isDual)
                    {
                        totalSpeedUnit = kernelOutput.DualSpeedUnit;
                    }
                    else
                    {
                        totalSpeedUnit = kernelOutput.SpeedUnit;
                    }
                }
                if (double.TryParse(totalSpeedText, out double totalSpeed))
                {
                    totalSpeed = totalSpeed.FromUnitSpeed(totalSpeedUnit);
                    var        now       = DateTime.Now;
                    IGpusSpeed gpuSpeeds = NTMinerContext.Instance.GpusSpeed;
                    gpuSpeeds.SetCurrentSpeed(NTMinerContext.GpuAllId, totalSpeed, isDual, now);
                    string gpuSpeedPattern = kernelOutput.GpuSpeedPattern;
                    if (isDual)
                    {
                        gpuSpeedPattern = kernelOutput.DualGpuSpeedPattern;
                    }
                    // 如果没有单卡算力正则则平分总算力作为单卡算力正则
                    if ((string.IsNullOrEmpty(gpuSpeedPattern) || context.GpuSet.Count == 1) && context.GpuSet.Count != 0)
                    {
                        double gpuSpeed = totalSpeed / context.GpuSet.Count;
                        foreach (var item in gpuSpeeds.AsEnumerable())
                        {
                            if (item.Gpu.Index != NTMinerContext.GpuAllId)
                            {
                                gpuSpeeds.SetCurrentSpeed(item.Gpu.Index, gpuSpeed, isDual, now);
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
        private static void PickTotalSpeed(INTMinerRoot root, string input, IKernelOutput kernelOutput, ICoin coin, bool isDual)
        {
            string totalSpeedPattern = kernelOutput.TotalSpeedPattern;

            if (isDual)
            {
                totalSpeedPattern = kernelOutput.DualTotalSpeedPattern;
            }
            if (string.IsNullOrEmpty(totalSpeedPattern))
            {
                return;
            }
            Match match = Regex.Match(input, totalSpeedPattern, RegexOptions.Compiled);

            if (match.Success)
            {
                string totalSpeedText = match.Groups["totalSpeed"].Value;
                string totalSpeedUnit = match.Groups["totalSpeedUnit"].Value;

                double totalSpeed;
                if (double.TryParse(totalSpeedText, out totalSpeed))
                {
                    double     totalSpeedL = totalSpeed.FromUnitSpeed(totalSpeedUnit);
                    var        now         = DateTime.Now;
                    IGpusSpeed gpuSpeeds   = NTMinerRoot.Instance.GpusSpeed;
                    gpuSpeeds.SetCurrentSpeed(NTMinerRoot.GpuAllId, totalSpeedL, isDual, now);
                    string gpuSpeedPattern = kernelOutput.GpuSpeedPattern;
                    if (isDual)
                    {
                        gpuSpeedPattern = kernelOutput.DualGpuSpeedPattern;
                    }
                    if (string.IsNullOrEmpty(gpuSpeedPattern))
                    {
                        // 平分总算力
                        double gpuSpeedL = totalSpeedL / root.GpuSet.Count;
                        foreach (var item in gpuSpeeds)
                        {
                            if (item.Gpu.Index != NTMinerRoot.GpuAllId)
                            {
                                gpuSpeeds.SetCurrentSpeed(item.Gpu.Index, gpuSpeedL, isDual, now);
                            }
                        }
                    }
                }
            }
        }
예제 #5
0
        private static void PickGpuSpeed(INTMinerContext root, IMineContext mineContext, string input, IKernelOutput kernelOutput, bool isDual)
        {
            string gpuSpeedPattern = kernelOutput.GpuSpeedPattern;

            if (isDual)
            {
                gpuSpeedPattern = kernelOutput.DualGpuSpeedPattern;
            }
            if (string.IsNullOrEmpty(gpuSpeedPattern))
            {
                return;
            }
            var             now      = DateTime.Now;
            bool            hasGpuId = gpuSpeedPattern.Contains($"?<{NTKeyword.GpuIndexGroupName}>");
            Regex           regex    = VirtualRoot.GetRegex(gpuSpeedPattern);
            MatchCollection matches  = regex.Matches(input);

            if (matches.Count > 0)
            {
                IGpusSpeed gpuSpeeds = NTMinerContext.Instance.GpusSpeed;
                for (int i = 0; i < matches.Count; i++)
                {
                    Match  match        = matches[i];
                    string gpuSpeedText = match.Groups[NTKeyword.GpuSpeedGroupName].Value;
                    string gpuSpeedUnit = match.Groups[NTKeyword.GpuSpeedUnitGroupName].Value;
                    if (string.IsNullOrEmpty(gpuSpeedUnit))
                    {
                        if (isDual)
                        {
                            gpuSpeedUnit = kernelOutput.DualSpeedUnit;
                        }
                        else
                        {
                            gpuSpeedUnit = kernelOutput.SpeedUnit;
                        }
                    }
                    int gpu = i;
                    if (hasGpuId)
                    {
                        string gpuText = match.Groups[NTKeyword.GpuIndexGroupName].Value;
                        if (!int.TryParse(gpuText, out gpu))
                        {
                            gpu = i;
                        }
                        else
                        {
                            gpu -= kernelOutput.GpuBaseIndex;
                            if (gpu < 0)
                            {
                                continue;
                            }
                        }
                    }
                    if (kernelOutput.IsMapGpuIndex && !string.IsNullOrWhiteSpace(mineContext.KernelInput.DevicesArg))
                    {
                        if (mineContext.UseDevices.Length != 0 && mineContext.UseDevices.Length != root.GpuSet.Count && gpu < mineContext.UseDevices.Length)
                        {
                            gpu = mineContext.UseDevices[gpu];
                        }
                    }
                    if (double.TryParse(gpuSpeedText, out double gpuSpeed))
                    {
                        double gpuSpeedL = gpuSpeed.FromUnitSpeed(gpuSpeedUnit);
                        gpuSpeeds.SetCurrentSpeed(gpu, gpuSpeedL, isDual, now);
                    }
                }
                string totalSpeedPattern = kernelOutput.TotalSpeedPattern;
                if (isDual)
                {
                    totalSpeedPattern = kernelOutput.DualTotalSpeedPattern;
                }
                if (string.IsNullOrEmpty(totalSpeedPattern))
                {
                    // 求和分算力
                    double speed = isDual? gpuSpeeds.AsEnumerable().Where(a => a.Gpu.Index != NTMinerContext.GpuAllId).Sum(a => a.DualCoinSpeed.Value)
                                         : gpuSpeeds.AsEnumerable().Where(a => a.Gpu.Index != NTMinerContext.GpuAllId).Sum(a => a.MainCoinSpeed.Value);
                    gpuSpeeds.SetCurrentSpeed(NTMinerContext.GpuAllId, speed, isDual, now);
                }
            }
        }