예제 #1
0
        private void StartupTimer_Tick(object sender, EventArgs e)
        {
            StartupTimer.Stop();
            StartupTimer = null;

            // get all CPUs
            CPUs = CPUID.GetPhysicalProcessorCount();

            // get all cores (including virtual - HT can benefit mining)
            int ThreadsPerCPU = CPUID.GetVirtualCoresCount() / CPUs;

            if (!Helpers.InternalCheckIsWow64() && !Config.ConfigData.AutoStartMining)
            {
                MessageBox.Show(International.GetText("form1_msgbox_CPUMining64bitMsg"),
                                International.GetText("Warning_with_Exclamation"),
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CPUs = 0;
            }

            if (ThreadsPerCPU * CPUs > 64)
            {
                MessageBox.Show(International.GetText("form1_msgbox_CPUMining64CoresMsg"),
                                International.GetText("Warning_with_Exclamation"),
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CPUs = 0;
            }

            int ThreadsPerCPUMask = ThreadsPerCPU;

            ThreadsPerCPU -= Config.ConfigData.LessThreads;
            if (ThreadsPerCPU < 1)
            {
                MessageBox.Show(International.GetText("form1_msgbox_CPUMiningLessThreadMsg"),
                                International.GetText("Warning_with_Exclamation"),
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CPUs = 0;
            }

            Miners = new Miner[CPUs + 4];

            if (CPUs == 1)
            {
                Miners[0] = new cpuminer(0, ThreadsPerCPU, 0);
            }
            else
            {
                for (int i = 0; i < CPUs; i++)
                {
                    Miners[i] = new cpuminer(i, ThreadsPerCPU, CPUID.CreateAffinityMask(i, ThreadsPerCPUMask));
                }
            }

            LoadingScreen.LoadText.Text = International.GetText("form1_loadtext_NVIDIA5X");
            IncreaseLoadCounter();

            Miners[CPUs] = new ccminer_sp();

            LoadingScreen.LoadText.Text = International.GetText("form1_loadtext_NVIDIA3X");
            IncreaseLoadCounter();

            Miners[CPUs + 1] = new ccminer_tpruvot();

            LoadingScreen.LoadText.Text = International.GetText("form1_loadtext_NVIDIA2X");
            IncreaseLoadCounter();

            Miners[CPUs + 2] = new ccminer_tpruvot_sm21();

            LoadingScreen.LoadText.Text = International.GetText("form1_loadtext_AMD");
            IncreaseLoadCounter();

            Miners[CPUs + 3] = new sgminer();

            // Auto uncheck CPU if any GPU is found
            for (int i = 0; i < CPUs; i++)
            {
                try
                {
                    if ((Miners[CPUs + 0].CDevs.Count > 0 || Miners[CPUs + 1].CDevs.Count > 0 ||
                         Miners[CPUs + 2].CDevs.Count > 0 || Miners[CPUs + 3].CDevs.Count > 0) && i < CPUs)
                    {
                        Miners[i].CDevs[0].Enabled = false;
                    }
                }
                catch { }
            }

            LoadingScreen.LoadText.Text = International.GetText("form1_loadtext_SaveConfig");
            IncreaseLoadCounter();

            for (int i = 0; i < Miners.Length; i++)
            {
                if (Config.ConfigData.Groups.Length > i)
                {
                    Miners[i].ExtraLaunchParameters         = Config.ConfigData.Groups[i].ExtraLaunchParameters;
                    Miners[i].UsePassword                   = Config.ConfigData.Groups[i].UsePassword;
                    Miners[i].MinimumProfit                 = Config.ConfigData.Groups[i].MinimumProfit;
                    Miners[i].DaggerHashimotoGenerateDevice = Config.ConfigData.Groups[i].DaggerHashimotoGenerateDevice;
                    if (Config.ConfigData.Groups[i].APIBindPort > 0)
                    {
                        Miners[i].APIPort = Config.ConfigData.Groups[i].APIBindPort;
                    }
                    for (int z = 0; z < Config.ConfigData.Groups[i].Algorithms.Length && z < Miners[i].SupportedAlgorithms.Length; z++)
                    {
                        Miners[i].SupportedAlgorithms[z].BenchmarkSpeed        = Config.ConfigData.Groups[i].Algorithms[z].BenchmarkSpeed;
                        Miners[i].SupportedAlgorithms[z].ExtraLaunchParameters = Config.ConfigData.Groups[i].Algorithms[z].ExtraLaunchParameters;
                        Miners[i].SupportedAlgorithms[z].UsePassword           = Config.ConfigData.Groups[i].Algorithms[z].UsePassword;
                        Miners[i].SupportedAlgorithms[z].Skip = Config.ConfigData.Groups[i].Algorithms[z].Skip;

                        Miners[i].SupportedAlgorithms[z].DisabledDevice = new bool[Miners[i].CDevs.Count];
                        if (Config.ConfigData.Groups[i].Algorithms[z].DisabledDevices != null)
                        {
                            if (Config.ConfigData.Groups[i].Algorithms[z].DisabledDevices.Length < Miners[i].CDevs.Count)
                            {
                                for (int j = 0; j < Config.ConfigData.Groups[i].Algorithms[z].DisabledDevices.Length; j++)
                                {
                                    Miners[i].SupportedAlgorithms[z].DisabledDevice[j] = Config.ConfigData.Groups[i].Algorithms[z].DisabledDevices[j];
                                }
                                for (int j = Config.ConfigData.Groups[i].Algorithms[z].DisabledDevices.Length; j < Miners[i].CDevs.Count; j++)
                                {
                                    Miners[i].SupportedAlgorithms[z].DisabledDevice[j] = false;
                                }
                            }
                            else
                            {
                                for (int j = 0; j < Miners[i].CDevs.Count; j++)
                                {
                                    Miners[i].SupportedAlgorithms[z].DisabledDevice[j] = Config.ConfigData.Groups[i].Algorithms[z].DisabledDevices[j];
                                }
                            }
                        }
                        else
                        {
                            Miners[i].GetDisabledDevicePerAlgo();
                        }
                    }
                }
                else
                {
                    Miners[i].GetDisabledDevicePerAlgo();
                }
                for (int k = 0; k < Miners[i].CDevs.Count; k++)
                {
                    ComputeDevice D = Miners[i].CDevs[k];
                    if (Config.ConfigData.Groups.Length > i)
                    {
                        D.Enabled = true;
                        for (int z = 0; z < Config.ConfigData.Groups[i].DisabledDevices.Length; z++)
                        {
                            if (Config.ConfigData.Groups[i].DisabledDevices[z] == k)
                            {
                                D.Enabled = false;
                                break;
                            }
                        }
                    }
                    ListViewItem lvi = new ListViewItem();
                    lvi.SubItems.Add(D.Vendor);
                    lvi.SubItems.Add(D.Name);
                    lvi.Checked = D.Enabled;
                    lvi.Tag     = D;
                    listViewDevices.Items.Add(lvi);
                }
            }

            Config.RebuildGroups();

            LoadingScreen.LoadText.Text = International.GetText("form1_loadtext_CheckLatestVersion");
            IncreaseLoadCounter();

            MinerStatsCheck          = new Timer();
            MinerStatsCheck.Tick    += MinerStatsCheck_Tick;
            MinerStatsCheck.Interval = Config.ConfigData.MinerAPIQueryInterval * 1000;

            SMAMinerCheck          = new Timer();
            SMAMinerCheck.Tick    += SMAMinerCheck_Tick;
            SMAMinerCheck.Interval = Config.ConfigData.SwitchMinSecondsFixed * 1000 + R.Next(Config.ConfigData.SwitchMinSecondsDynamic * 1000);
            if (Miners[CPUs + 3].CDevs.Count > 0)
            {
                SMAMinerCheck.Interval = (Config.ConfigData.SwitchMinSecondsAMD + Config.ConfigData.SwitchMinSecondsFixed) * 1000 + R.Next(Config.ConfigData.SwitchMinSecondsDynamic * 1000);
            }

            UpdateCheck          = new Timer();
            UpdateCheck.Tick    += UpdateCheck_Tick;
            UpdateCheck.Interval = 1000 * 3600; // every 1 hour
            UpdateCheck.Start();
            UpdateCheck_Tick(null, null);

            LoadingScreen.LoadText.Text = International.GetText("form1_loadtext_GetNiceHashSMA");
            IncreaseLoadCounter();

            SMACheck          = new Timer();
            SMACheck.Tick    += SMACheck_Tick;
            SMACheck.Interval = 60 * 1000; // every 60 seconds
            SMACheck.Start();
            SMACheck_Tick(null, null);

            LoadingScreen.LoadText.Text = International.GetText("form1_loadtext_GetBTCRate");
            IncreaseLoadCounter();

            BitcoinExchangeCheck          = new Timer();
            BitcoinExchangeCheck.Tick    += BitcoinExchangeCheck_Tick;
            BitcoinExchangeCheck.Interval = 1000 * 3601; // every 1 hour and 1 second
            BitcoinExchangeCheck.Start();
            BitcoinExchangeCheck_Tick(null, null);

            LoadingScreen.LoadText.Text = International.GetText("form1_loadtext_GetNiceHashBalance");
            IncreaseLoadCounter();

            BalanceCheck          = new Timer();
            BalanceCheck.Tick    += BalanceCheck_Tick;
            BalanceCheck.Interval = 61 * 1000; // every 61 seconds
            BalanceCheck.Start();
            BalanceCheck_Tick(null, null);

            LoadingScreen.LoadText.Text = International.GetText("form1_loadtext_SetEnvironmentVariable");
            IncreaseLoadCounter();

            SetEnvironmentVariables();

            IncreaseLoadCounter();
            LoadingScreen.LoadText.Text = International.GetText("form1_loadtext_SetWindowsErrorReporting");
            Helpers.DisableWindowsErrorReporting(Config.ConfigData.DisableWindowsErrorReporting);

            IncreaseLoadCounter();
            if (Config.ConfigData.NVIDIAP0State)
            {
                LoadingScreen.LoadText.Text = International.GetText("form1_loadtext_NVIDIAP0State");
                try
                {
                    ProcessStartInfo psi = new ProcessStartInfo();
                    psi.FileName        = "nvidiasetp0state.exe";
                    psi.Verb            = "runas";
                    psi.UseShellExecute = true;
                    psi.CreateNoWindow  = true;
                    Process p = Process.Start(psi);
                    p.WaitForExit();
                    if (p.ExitCode != 0)
                    {
                        Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state returned error code: " + p.ExitCode.ToString());
                    }
                    else
                    {
                        Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state all OK");
                    }
                }
                catch (Exception ex)
                {
                    Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state error: " + ex.Message);
                }
            }

            IncreaseLoadCounter();
        }
예제 #2
0
        private void StartupTimer_Tick(object sender, EventArgs e)
        {
            StartupTimer.Stop();
            StartupTimer = null;

            // get all CPUs
            int CPUs = CPUID.GetPhysicalProcessorCount();

            // get all cores (including virtual - HT can benefit mining)
            int ThreadsPerCPU = CPUID.GetVirtualCoresCount() / CPUs;

            if (!Helpers.InternalCheckIsWow64() && !Config.ConfigData.AutoStartMining)
            {
                MessageBox.Show("NiceHash Miner works only on 64 bit version of OS for CPU mining. CPU mining will be disabled.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CPUs = 0;
            }

            if (ThreadsPerCPU * CPUs > 64)
            {
                MessageBox.Show("NiceHash Miner does not support more than 64 virtual cores. CPU mining will be disabled.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CPUs = 0;
            }

            int ThreadsPerCPUMask = ThreadsPerCPU;

            ThreadsPerCPU -= Config.ConfigData.LessThreads;
            if (ThreadsPerCPU < 1)
            {
                MessageBox.Show("LessThreads greater than number of threads per CPU. CPU mining will be disabled.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CPUs = 0;
            }

            Miners = new Miner[CPUs + 4];

            if (CPUs == 1)
            {
                Miners[0] = new cpuminer(0, ThreadsPerCPU, 0);
            }
            else
            {
                for (int i = 0; i < CPUs; i++)
                {
                    Miners[i] = new cpuminer(i, ThreadsPerCPU, CPUID.CreateAffinityMask(i, ThreadsPerCPUMask));
                }
            }

            LoadingScreen.LoadText.Text = "Querying NVIDIA5.x devices...";
            IncreaseLoadCounter();

            Miners[CPUs] = new ccminer_sp();

            LoadingScreen.LoadText.Text = "Querying NVIDIA3.x devices...";
            IncreaseLoadCounter();

            Miners[CPUs + 1] = new ccminer_tpruvot();

            LoadingScreen.LoadText.Text = "Querying NVIDIA2.1 devices...";
            IncreaseLoadCounter();

            Miners[CPUs + 2] = new ccminer_tpruvot_sm21();

            LoadingScreen.LoadText.Text = "Querying AMD OpenCL devices...";
            IncreaseLoadCounter();

            Miners[CPUs + 3] = new sgminer();

            LoadingScreen.LoadText.Text = "Saving config...";
            IncreaseLoadCounter();

            for (int i = 0; i < Miners.Length; i++)
            {
                if (Config.ConfigData.Groups.Length > i)
                {
                    Miners[i].ExtraLaunchParameters = Config.ConfigData.Groups[i].ExtraLaunchParameters;
                    Miners[i].UsePassword           = Config.ConfigData.Groups[i].UsePassword;
                    if (Config.ConfigData.Groups[i].APIBindPort > 0)
                    {
                        Miners[i].APIPort = Config.ConfigData.Groups[i].APIBindPort;
                    }
                    for (int z = 0; z < Config.ConfigData.Groups[i].Algorithms.Length && z < Miners[i].SupportedAlgorithms.Length; z++)
                    {
                        Miners[i].SupportedAlgorithms[z].BenchmarkSpeed        = Config.ConfigData.Groups[i].Algorithms[z].BenchmarkSpeed;
                        Miners[i].SupportedAlgorithms[z].ExtraLaunchParameters = Config.ConfigData.Groups[i].Algorithms[z].ExtraLaunchParameters;
                        Miners[i].SupportedAlgorithms[z].UsePassword           = Config.ConfigData.Groups[i].Algorithms[z].UsePassword;
                        Miners[i].SupportedAlgorithms[z].Skip = Config.ConfigData.Groups[i].Algorithms[z].Skip;
                    }
                }
                for (int k = 0; k < Miners[i].CDevs.Count; k++)
                {
                    ComputeDevice D = Miners[i].CDevs[k];
                    if (Config.ConfigData.Groups.Length > i)
                    {
                        for (int z = 0; z < Config.ConfigData.Groups[i].DisabledDevices.Length; z++)
                        {
                            if (Config.ConfigData.Groups[i].DisabledDevices[z] == k)
                            {
                                D.Enabled = false;
                                break;
                            }
                        }
                    }
                    ListViewItem lvi = new ListViewItem();
                    lvi.SubItems.Add(D.Vendor);
                    lvi.SubItems.Add(D.Name);
                    lvi.Checked = D.Enabled;
                    lvi.Tag     = D;
                    listView1.Items.Add(lvi);
                }
            }

            Config.RebuildGroups();

            LoadingScreen.LoadText.Text = "Checking for latest version...";
            IncreaseLoadCounter();

            MinerStatsCheck          = new Timer();
            MinerStatsCheck.Tick    += MinerStatsCheck_Tick;
            MinerStatsCheck.Interval = Config.ConfigData.MinerAPIQueryInterval * 1000;

            SMAMinerCheck          = new Timer();
            SMAMinerCheck.Tick    += SMAMinerCheck_Tick;
            SMAMinerCheck.Interval = Config.ConfigData.SwitchMinSecondsFixed * 1000 + R.Next(Config.ConfigData.SwitchMinSecondsDynamic * 1000);

            UpdateCheck          = new Timer();
            UpdateCheck.Tick    += UpdateCheck_Tick;
            UpdateCheck.Interval = 1000 * 3600; // every 1 hour
            UpdateCheck.Start();
            UpdateCheck_Tick(null, null);

            LoadingScreen.LoadText.Text = "Getting NiceHash SMA information...";
            IncreaseLoadCounter();

            SMACheck          = new Timer();
            SMACheck.Tick    += SMACheck_Tick;
            SMACheck.Interval = 60 * 1000; // every 60 seconds
            SMACheck.Start();
            SMACheck_Tick(null, null);

            LoadingScreen.LoadText.Text = "Getting Bitcoin exchange rate...";
            IncreaseLoadCounter();

            BitcoinExchangeCheck          = new Timer();
            BitcoinExchangeCheck.Tick    += BitcoinExchangeCheck_Tick;
            BitcoinExchangeCheck.Interval = 1000 * 3601; // every 1 hour and 1 second
            BitcoinExchangeCheck.Start();
            BitcoinExchangeCheck_Tick(null, null);

            LoadingScreen.LoadText.Text = "Getting NiceHash balance...";
            IncreaseLoadCounter();

            BalanceCheck          = new Timer();
            BalanceCheck.Tick    += BalanceCheck_Tick;
            BalanceCheck.Interval = 61 * 1000; // every 61 seconds
            BalanceCheck.Start();
            BalanceCheck_Tick(null, null);

            LoadingScreen.LoadText.Text = "Setting environment variables...";
            IncreaseLoadCounter();

            SetEnvironmentVariables();

            IncreaseLoadCounter();
        }
예제 #3
0
        private void StartupTimer_Tick(object sender, EventArgs e)
        {
            StartupTimer.Stop();
            StartupTimer = null;

            // get all CPUs
            int CPUs = CPUID.GetPhysicalProcessorCount();

            // get all cores (including virtual - HT can benefit mining)
            int ThreadsPerCPU = CPUID.GetVirtualCoresCount() / CPUs;

            if (!Helpers.InternalCheckIsWow64() && !Config.ConfigData.AutoStartMining)
            {
                MessageBox.Show("NiceHash Miner works only on 64 bit version of OS for CPU mining. CPU mining will be disabled.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CPUs = 0;
            }

            if (ThreadsPerCPU * CPUs > 64)
            {
                MessageBox.Show("NiceHash Miner does not support more than 64 virtual cores. CPU mining will be disabled.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CPUs = 0;
            }

            int ThreadsPerCPUMask = ThreadsPerCPU;
            ThreadsPerCPU -= Config.ConfigData.LessThreads;
            if (ThreadsPerCPU < 1)
            {
                MessageBox.Show("LessThreads greater than number of threads per CPU. CPU mining will be disabled.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CPUs = 0;
            }

            Miners = new Miner[CPUs + 4];

            if (CPUs == 1)
                Miners[0] = new cpuminer(0, ThreadsPerCPU, 0);
            else
            {
                for (int i = 0; i < CPUs; i++)
                    Miners[i] = new cpuminer(i, ThreadsPerCPU, CPUID.CreateAffinityMask(i, ThreadsPerCPUMask));
            }

            LoadingScreen.LoadText.Text = "Querying NVIDIA5.x devices...";
            IncreaseLoadCounter();

            Miners[CPUs] = new ccminer_sp();

            LoadingScreen.LoadText.Text = "Querying NVIDIA3.x devices...";
            IncreaseLoadCounter();

            Miners[CPUs + 1] = new ccminer_tpruvot();

            LoadingScreen.LoadText.Text = "Querying NVIDIA2.1 devices...";
            IncreaseLoadCounter();

            Miners[CPUs + 2] = new ccminer_tpruvot_sm21();

            LoadingScreen.LoadText.Text = "Querying AMD OpenCL devices...";
            IncreaseLoadCounter();

            Miners[CPUs + 3] = new sgminer();

            LoadingScreen.LoadText.Text = "Saving config...";
            IncreaseLoadCounter();

            for (int i = 0; i < Miners.Length; i++)
            {
                if (Config.ConfigData.Groups.Length > i)
                {
                    Miners[i].ExtraLaunchParameters = Config.ConfigData.Groups[i].ExtraLaunchParameters;
                    Miners[i].UsePassword = Config.ConfigData.Groups[i].UsePassword;
                    if (Config.ConfigData.Groups[i].APIBindPort > 0)
                        Miners[i].APIPort = Config.ConfigData.Groups[i].APIBindPort;
                    for (int z = 0; z < Config.ConfigData.Groups[i].Algorithms.Length && z < Miners[i].SupportedAlgorithms.Length; z++)
                    {
                        Miners[i].SupportedAlgorithms[z].BenchmarkSpeed = Config.ConfigData.Groups[i].Algorithms[z].BenchmarkSpeed;
                        Miners[i].SupportedAlgorithms[z].ExtraLaunchParameters = Config.ConfigData.Groups[i].Algorithms[z].ExtraLaunchParameters;
                        Miners[i].SupportedAlgorithms[z].UsePassword = Config.ConfigData.Groups[i].Algorithms[z].UsePassword;
                        Miners[i].SupportedAlgorithms[z].Skip = Config.ConfigData.Groups[i].Algorithms[z].Skip;
                    }
                }
                for (int k = 0; k < Miners[i].CDevs.Count; k++)
                {
                    ComputeDevice D = Miners[i].CDevs[k];
                    if (Config.ConfigData.Groups.Length > i)
                    {
                        for (int z = 0; z < Config.ConfigData.Groups[i].DisabledDevices.Length; z++)
                        {
                            if (Config.ConfigData.Groups[i].DisabledDevices[z] == k)
                            {
                                D.Enabled = false;
                                break;
                            }
                        }
                    }
                    ListViewItem lvi = new ListViewItem();
                    lvi.SubItems.Add(D.Vendor);
                    lvi.SubItems.Add(D.Name);
                    lvi.Checked = D.Enabled;
                    lvi.Tag = D;
                    listView1.Items.Add(lvi);
                }
            }

            Config.RebuildGroups();

            LoadingScreen.LoadText.Text = "Checking for latest version...";
            IncreaseLoadCounter();

            MinerStatsCheck = new Timer();
            MinerStatsCheck.Tick += MinerStatsCheck_Tick;
            MinerStatsCheck.Interval = Config.ConfigData.MinerAPIQueryInterval * 1000;

            SMAMinerCheck = new Timer();
            SMAMinerCheck.Tick += SMAMinerCheck_Tick;
            SMAMinerCheck.Interval = Config.ConfigData.SwitchMinSecondsFixed * 1000 + R.Next(Config.ConfigData.SwitchMinSecondsDynamic * 1000);

            UpdateCheck = new Timer();
            UpdateCheck.Tick += UpdateCheck_Tick;
            UpdateCheck.Interval = 1000 * 3600; // every 1 hour
            UpdateCheck.Start();
            UpdateCheck_Tick(null, null);

            LoadingScreen.LoadText.Text = "Getting NiceHash SMA information...";
            IncreaseLoadCounter();

            SMACheck = new Timer();
            SMACheck.Tick += SMACheck_Tick;
            SMACheck.Interval = 60 * 1000; // every 60 seconds
            SMACheck.Start();
            SMACheck_Tick(null, null);

            LoadingScreen.LoadText.Text = "Getting Bitcoin exchange rate...";
            IncreaseLoadCounter();

            BitcoinExchangeCheck = new Timer();
            BitcoinExchangeCheck.Tick += BitcoinExchangeCheck_Tick;
            BitcoinExchangeCheck.Interval = 1000 * 3601; // every 1 hour and 1 second
            BitcoinExchangeCheck.Start();
            BitcoinExchangeCheck_Tick(null, null);

            LoadingScreen.LoadText.Text = "Getting NiceHash balance...";
            IncreaseLoadCounter();

            BalanceCheck = new Timer();
            BalanceCheck.Tick += BalanceCheck_Tick;
            BalanceCheck.Interval = 61 * 1000; // every 61 seconds
            BalanceCheck.Start();
            BalanceCheck_Tick(null, null);

            IncreaseLoadCounter();
        }