static void Main(string[] argv) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; //Console.OutputEncoding = System.Text.Encoding.Unicode; // #0 set this first so data parsing will work correctly Globals.JsonSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore, Culture = CultureInfo.InvariantCulture }; // #1 first initialize config ConfigManager.InitializeConfig(); // #2 check if multiple instances are allowed bool startProgram = true; if (ConfigManager.GeneralConfig.AllowMultipleInstances == false) { try { Process current = Process.GetCurrentProcess(); foreach (Process process in Process.GetProcessesByName(current.ProcessName)) { if (process.Id != current.Id) { startProgram = false; } } } catch { } } if (startProgram) { if (ConfigManager.GeneralConfig.LogToFile) { Logger.ConfigureWithFile(); } if (ConfigManager.GeneralConfig.DebugConsole) { Helpers.AllocConsole(); } // init active display currency after config load ExchangeRateAPI.ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency; // #2 then parse args var commandLineArgs = new CommandLineParser(argv); Helpers.ConsolePrint("NICEHASH", "Starting up NiceHashMiner v" + Application.ProductVersion); bool tosChecked = ConfigManager.GeneralConfig.agreedWithTOS == Globals.CURRENT_TOS_VER; if (!tosChecked || !ConfigManager.GeneralConfigIsFileExist() && !commandLineArgs.IsLang) { Helpers.ConsolePrint("NICEHASH", "No config file found. Running NiceHash Miner for the first time. Choosing a default language."); Application.Run(new Form_ChooseLanguage()); } // Init languages International.Initialize(ConfigManager.GeneralConfig.Language); if (commandLineArgs.IsLang) { Helpers.ConsolePrint("NICEHASH", "Language is overwritten by command line parameter (-lang)."); International.Initialize(commandLineArgs.LangValue); ConfigManager.GeneralConfig.Language = commandLineArgs.LangValue; } // check WMI if (Helpers.IsWMIEnabled()) { if (ConfigManager.GeneralConfig.agreedWithTOS == Globals.CURRENT_TOS_VER) { Application.Run(new Form_Main()); } } else { MessageBox.Show(International.GetText("Program_WMI_Error_Text"), International.GetText("Program_WMI_Error_Title"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
// This is a single shot _benchmarkTimer private void StartupTimer_Tick(object sender, EventArgs e) { StartupTimer.Stop(); StartupTimer = null; // Internals Init // TODO add loading step MinersSettingsManager.Init(); if (!Helpers.Is45NetOrHigher()) { MessageBox.Show(International.GetText("NET45_Not_Installed_msg"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); this.Close(); return; } if (!Helpers.Is64BitOperatingSystem) { MessageBox.Show(International.GetText("Form_Main_x64_Support_Only"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); this.Close(); return; } // 3rdparty miners check scope #1 { // check if setting set if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.NOT_SET) { // Show TOS Form tos = new Form_3rdParty_TOS(); tos.ShowDialog(this); } } // Query Avaliable ComputeDevices ComputeDeviceManager.Query.QueryDevices(LoadingScreen); _isDeviceDetectionInitialized = true; ///////////////////////////////////////////// /////// from here on we have our devices and Miners initialized ConfigManager.AfterDeviceQueryInitialization(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SaveConfig")); // All devices settup should be initialized in AllDevices devicesListViewEnableControl1.ResetComputeDevices(ComputeDeviceManager.Avaliable.AllAvaliableDevices); // set properties after devicesListViewEnableControl1.SaveToGeneralConfig = true; LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_CheckLatestVersion")); MinerStatsCheck = new Timer(); MinerStatsCheck.Tick += MinerStatsCheck_Tick; MinerStatsCheck.Interval = ConfigManager.GeneralConfig.MinerAPIQueryInterval * 1000; SMAMinerCheck = new Timer(); SMAMinerCheck.Tick += SMAMinerCheck_Tick; SMAMinerCheck.Interval = ConfigManager.GeneralConfig.SwitchMinSecondsFixed * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); if (ComputeDeviceManager.Group.ContainsAMD_GPUs) { SMAMinerCheck.Interval = (ConfigManager.GeneralConfig.SwitchMinSecondsAMD + ConfigManager.GeneralConfig.SwitchMinSecondsFixed) * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); } LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetNiceHashSMA")); // Init ws connection NiceHashStats.OnBalanceUpdate += BalanceCallback; NiceHashStats.OnSMAUpdate += SMACallback; NiceHashStats.OnVersionUpdate += VersionUpdateCallback; NiceHashStats.OnConnectionLost += ConnectionLostCallback; NiceHashStats.OnConnectionEstablished += ConnectionEstablishedCallback; NiceHashStats.OnVersionBurn += VersionBurnCallback; NiceHashStats.StartConnection(Links.NHM_Socket_Address); // increase timeout if (Globals.IsFirstNetworkCheckTimeout) { while (!Helpers.WebRequestTestGoogle() && Globals.FirstNetworkCheckTimeoutTries > 0) { --Globals.FirstNetworkCheckTimeoutTries; } } LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetBTCRate")); BitcoinExchangeCheck = new Timer(); BitcoinExchangeCheck.Tick += BitcoinExchangeCheck_Tick; BitcoinExchangeCheck.Interval = 1000 * 3601; // every 1 hour and 1 second BitcoinExchangeCheck.Start(); BitcoinExchangeCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetEnvironmentVariable")); Helpers.SetDefaultEnvironmentVariables(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetWindowsErrorReporting")); Helpers.DisableWindowsErrorReporting(ConfigManager.GeneralConfig.DisableWindowsErrorReporting); LoadingScreen.IncreaseLoadCounter(); if (ConfigManager.GeneralConfig.NVIDIAP0State) { LoadingScreen.SetInfoMsg(International.GetText("Form_Main_loadtext_NVIDIAP0State")); Helpers.SetNvidiaP0State(); } LoadingScreen.FinishLoad(); bool runVCRed = !MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit; // standard miners check scope { // check if download needed if (!MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit) { Form_Loading downloadUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.StandardDlSetup)); SetChildFormCenter(downloadUnzipForm); downloadUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMinersBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit = false; ConfigManager.GeneralConfigFileCommit(); Process PHandle = new Process(); PHandle.StartInfo.FileName = Application.ExecutablePath; PHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit) { // all good ConfigManager.GeneralConfig.DownloadInit = true; ConfigManager.GeneralConfigFileCommit(); } } // 3rdparty miners check scope #2 { // check if download needed if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.YES) { if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit() && !ConfigManager.GeneralConfig.DownloadInit3rdParty) { Form_Loading download3rdPartyUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.ThirdPartyDlSetup)); SetChildFormCenter(download3rdPartyUnzipForm); download3rdPartyUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit3rdParty = false; ConfigManager.GeneralConfigFileCommit(); Process PHandle = new Process(); PHandle.StartInfo.FileName = Application.ExecutablePath; PHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit3rdParty) { // all good ConfigManager.GeneralConfig.DownloadInit3rdParty = true; ConfigManager.GeneralConfigFileCommit(); } } } if (runVCRed) { Helpers.InstallVcRedist(); } if (ConfigManager.GeneralConfig.AutoStartMining) { // well this is started manually as we want it to start at runtime IsManuallyStarted = true; if (StartMining(true) != StartMiningReturnType.StartMining) { IsManuallyStarted = false; StopMining(); } } }
private string FormatPayingOutput(double paying) { string ret = ""; if (ConfigManager.GeneralConfig.AutoScaleBTCValues && paying < 0.1) { ret = (paying * 1000 * factorTimeUnit).ToString("F5", CultureInfo.InvariantCulture) + " mBTC/" + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()); } else { ret = (paying * factorTimeUnit).ToString("F6", CultureInfo.InvariantCulture) + " BTC/" + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()); } return(ret); }
static void Main(string[] argv) { // Set working directory to exe var pathSet = false; var path = Path.GetDirectoryName(Application.ExecutablePath); if (path != null) { Environment.CurrentDirectory = path; pathSet = true; } // Add common folder to path for launched processes var pathVar = Environment.GetEnvironmentVariable("PATH"); pathVar += ";" + Path.Combine(Environment.CurrentDirectory, "common"); Environment.SetEnvironmentVariable("PATH", pathVar); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; //Console.OutputEncoding = System.Text.Encoding.Unicode; // #0 set this first so data parsing will work correctly Globals.JsonSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore, Culture = CultureInfo.InvariantCulture }; // #1 first initialize config ConfigManager.InitializeConfig(); // #2 check if multiple instances are allowed var startProgram = true; if (ConfigManager.GeneralConfig.AllowMultipleInstances == false) { try { var current = Process.GetCurrentProcess(); foreach (var process in Process.GetProcessesByName(current.ProcessName)) { if (process.Id != current.Id) { startProgram = false; } } } catch { } } if (startProgram) { if (ConfigManager.GeneralConfig.LogToFile) { Logger.ConfigureWithFile(); } if (ConfigManager.GeneralConfig.DebugConsole) { PInvokeHelpers.AllocConsole(); } //** /* * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 4) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (File.Exists("internals\\MinerOptionPackage_glg.json")) * File.Delete("internals\\MinerOptionPackage_glg.json"); * * if (File.Exists("internals\\MinerOptionPackage_ClaymoreDual.json")) * File.Delete("internals\\MinerOptionPackage_ClaymoreDual.json"); * * if (File.Exists("bin\\ccminer_klaust\\ccminer.exe")) * File.Delete("bin\\ccminer_klaust\\ccminer.exe"); * ConfigManager.GeneralConfig.ForkFixVersion = 4; * } * * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 4.1) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (File.Exists("internals\\MinerOptionPackage_ClaymoreDual.json")) * File.Delete("internals\\MinerOptionPackage_ClaymoreDual.json"); * * ConfigManager.GeneralConfig.ForkFixVersion = 4.1; * } * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 5) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (File.Exists("bin\\xmrig\\xmrig.exe")) * File.Delete("bin\\xmrig\\xmrig.exe"); * * ConfigManager.GeneralConfig.ForkFixVersion = 5; * } * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 6) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (File.Exists("bin\\xmrig\\xmrig.exe")) * File.Delete("bin\\xmrig\\xmrig.exe"); * * ConfigManager.GeneralConfig.ForkFixVersion = 6; * } * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 7) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (Directory.Exists("internals")) * Directory.Delete("internals", true); * * ConfigManager.GeneralConfig.ForkFixVersion = 7; * } * * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 8) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (Directory.Exists("internals")) * Directory.Delete("internals", true); * * ConfigManager.GeneralConfig.ForkFixVersion = 8; * } * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 8.2) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (Directory.Exists("internals")) * Directory.Delete("internals", true); * * ConfigManager.GeneralConfig.ForkFixVersion = 8.2; * } * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 9) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (Directory.Exists("internals")) * Directory.Delete("internals", true); * * if (File.Exists("bin\\xmrig\\xmrig.exe")) * File.Delete("bin\\xmrig\\xmrig.exe"); * * ConfigManager.GeneralConfig.ForkFixVersion = 9; * } * * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 9.1) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (Directory.Exists("internals")) * Directory.Delete("internals", true); * * if (File.Exists("bin\\xmrig\\xmrig.exe")) * File.Delete("bin\\xmrig\\xmrig.exe"); * * if (File.Exists("bin_3rdparty\\t-rex\\t-rex.exe")) * File.Delete("bin_3rdparty\\t-rex\\t-rex.exe"); * * ConfigManager.GeneralConfig.ForkFixVersion = 9.1; * } * * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 9.2) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (Directory.Exists("internals")) * Directory.Delete("internals", true); * * if (File.Exists("bin\\xmrig\\xmrig.exe")) * File.Delete("bin\\xmrig\\xmrig.exe"); * * if (File.Exists("bin_3rdparty\\t-rex\\t-rex.exe")) * File.Delete("bin_3rdparty\\t-rex\\t-rex.exe"); * * ConfigManager.GeneralConfig.ForkFixVersion = 9.2; * } * * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 9.3) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (Directory.Exists("internals")) * Directory.Delete("internals", true); * * if (File.Exists("bin\\xmrig\\xmrig.exe")) * File.Delete("bin\\xmrig\\xmrig.exe"); * * if (File.Exists("bin_3rdparty\\t-rex\\t-rex.exe")) * File.Delete("bin_3rdparty\\t-rex\\t-rex.exe"); * * ConfigManager.GeneralConfig.ForkFixVersion = 9.3; * } * * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 10) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (Directory.Exists("internals")) * Directory.Delete("internals", true); * * if (File.Exists("bin\\xmrig\\xmrig.exe")) * File.Delete("bin\\xmrig\\xmrig.exe"); * * if (File.Exists("bin_3rdparty\\t-rex\\t-rex.exe")) * File.Delete("bin_3rdparty\\t-rex\\t-rex.exe"); * * ConfigManager.GeneralConfig.ForkFixVersion = 10; * } * * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 11) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (Directory.Exists("internals")) * Directory.Delete("internals", true); * * if (File.Exists("bin\\xmrig\\xmrig.exe")) * File.Delete("bin\\xmrig\\xmrig.exe"); * * if (File.Exists("bin_3rdparty\\t-rex\\t-rex.exe")) * File.Delete("bin_3rdparty\\t-rex\\t-rex.exe"); * * ConfigManager.GeneralConfig.ForkFixVersion = 11; * } * * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 11.1) * { * Helpers.ConsolePrint("NICEHASH", "Old version"); * if (Directory.Exists("internals")) * Directory.Delete("internals", true); * * if (File.Exists("bin_3rdparty\\t-rex\\t-rex.exe")) * File.Delete("bin_3rdparty\\t-rex\\t-rex.exe"); * * ConfigManager.GeneralConfig.ForkFixVersion = 11.1; * } */ if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 11.2) { Helpers.ConsolePrint("NICEHASH", "Old version"); if (Directory.Exists("internals")) { Directory.Delete("internals", true); } ConfigManager.GeneralConfig.ForkFixVersion = 11.2; } if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 12) { Helpers.ConsolePrint("NICEHASH", "Old version"); if (Directory.Exists("internals")) { Directory.Delete("internals", true); } ConfigManager.GeneralConfig.ForkFixVersion = 12; } if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 12.1) { Helpers.ConsolePrint("NICEHASH", "Old version"); if (Directory.Exists("internals")) { Directory.Delete("internals", true); } ConfigManager.GeneralConfig.ForkFixVersion = 12.1; } if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 13) { Helpers.ConsolePrint("NICEHASH", "Old version"); if (Directory.Exists("internals")) { Directory.Delete("internals", true); } ConfigManager.GeneralConfig.ForkFixVersion = 13; } if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 13.1) { Helpers.ConsolePrint("NICEHASH", "Old version"); if (Directory.Exists("internals")) { Directory.Delete("internals", true); } ConfigManager.GeneralConfig.ForkFixVersion = 13.1; } if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 14) { Helpers.ConsolePrint("NICEHASH", "Old version"); if (Directory.Exists("internals")) { Directory.Delete("internals", true); } ConfigManager.GeneralConfig.ForkFixVersion = 14.0; } //** Thread.Sleep(500); // init active display currency after config load ExchangeRateApi.ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency; // #2 then parse args var commandLineArgs = new CommandLineParser(argv); Helpers.ConsolePrint("NICEHASH", "Starting up NiceHashMiner v" + Application.ProductVersion); if (!pathSet) { Helpers.ConsolePrint("NICEHASH", "Path not set to executable"); } var tosChecked = ConfigManager.GeneralConfig.agreedWithTOS == Globals.CurrentTosVer; if (!tosChecked || !ConfigManager.GeneralConfigIsFileExist() && !commandLineArgs.IsLang) { Helpers.ConsolePrint("NICEHASH", "No config file found. Running NiceHash Miner Legacy for the first time. Choosing a default language."); Application.Run(new Form_ChooseLanguage()); } // Init languages International.Initialize(ConfigManager.GeneralConfig.Language); if (commandLineArgs.IsLang) { Helpers.ConsolePrint("NICEHASH", "Language is overwritten by command line parameter (-lang)."); International.Initialize(commandLineArgs.LangValue); ConfigManager.GeneralConfig.Language = commandLineArgs.LangValue; } // check WMI if (Helpers.IsWmiEnabled()) { if (ConfigManager.GeneralConfig.agreedWithTOS == Globals.CurrentTosVer) { Application.Run(new Form_Main()); } } else { MessageBox.Show(International.GetText("Program_WMI_Error_Text"), International.GetText("Program_WMI_Error_Title"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void InitLocalization() { MessageBoxManager.Unregister(); MessageBoxManager.Yes = International.GetText("Global_Yes"); MessageBoxManager.No = International.GetText("Global_No"); MessageBoxManager.OK = International.GetText("Global_OK"); MessageBoxManager.Cancel = International.GetText("Global_Cancel"); MessageBoxManager.Retry = International.GetText("Global_Retry"); MessageBoxManager.Register(); labelServiceLocation.Text = International.GetText("Service_Location") + ":"; { int i = 0; foreach (string loc in Globals.MiningLocation) { comboBoxLocation.Items[i++] = International.GetText("LocationName_" + loc); } } labelBitcoinAddress.Text = International.GetText("BitcoinAddress") + ":"; labelWorkerName.Text = International.GetText("WorkerName") + ":"; linkLabelCheckStats.Text = International.GetText("Form_Main_check_stats"); linkLabelChooseBTCWallet.Text = International.GetText("Form_Main_choose_bitcoin_wallet"); toolStripStatusLabelGlobalRateText.Text = International.GetText("Form_Main_global_rate") + ":"; toolStripStatusLabelBTCDayText.Text = "BTC/" + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()); toolStripStatusLabelBalanceText.Text = (ExchangeRateAPI.ActiveDisplayCurrency + "/") + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()) + " " + International.GetText("Form_Main_balance") + ":"; devicesListViewEnableControl1.InitLocale(); buttonBenchmark.Text = International.GetText("Form_Main_benchmark"); buttonSettings.Text = International.GetText("Form_Main_settings"); buttonStartMining.Text = International.GetText("Form_Main_start"); buttonStopMining.Text = International.GetText("Form_Main_stop"); buttonHelp.Text = International.GetText("Form_Main_help"); label_NotProfitable.Text = International.GetText("Form_Main_MINING_NOT_PROFITABLE"); groupBox1.Text = International.GetText("Form_Main_Group_Device_Rates"); }
public void AddRateInfo(string groupName, string deviceStringInfo, APIData iAPIData, double paying, bool isApiGetException) { string ApiGetExceptionString = isApiGetException ? "**" : ""; string speedString = Helpers.FormatSpeedOutput(iAPIData.Speed) + iAPIData.AlgorithmName + ApiGetExceptionString; string rateBTCString = FormatPayingOutput(paying); string rateCurrencyString = CurrencyConverter.CurrencyConverter.ConvertToActiveCurrency(paying * Globals.BitcoinRate).ToString("F2", CultureInfo.InvariantCulture) + String.Format(" {0}/", ConfigManager.Instance.GeneralConfig.DisplayCurrency) + International.GetText("Day"); ((GroupProfitControl)flowLayoutPanelRates.Controls[flowLayoutPanelRatesIndex++]) .UpdateProfitStats(groupName, deviceStringInfo, speedString, rateBTCString, rateCurrencyString); UpdateGlobalRate(); }
private void InitLocalization() { MessageBoxManager.Unregister(); MessageBoxManager.Yes = International.GetText("Global_Yes"); MessageBoxManager.No = International.GetText("Global_No"); MessageBoxManager.OK = International.GetText("Global_OK"); MessageBoxManager.Register(); labelServiceLocation.Text = International.GetText("Service_Location") + ":"; labelBitcoinAddress.Text = International.GetText("BitcoinAddress") + ":"; labelWorkerName.Text = International.GetText("WorkerName") + ":"; linkLabelVisitUs.Text = International.GetText("Form_Main_visit_us"); linkLabelCheckStats.Text = International.GetText("Form_Main_check_stats"); linkLabelChooseBTCWallet.Text = International.GetText("Form_Main_choose_bitcoin_wallet"); // these strings are no longer used, check and use them as base string rateString = International.GetText("Rate") + ":"; string ratesBTCInitialString = "0.00000000 BTC/" + International.GetText("Day"); string ratesDollarInitialString = String.Format("0.00 {0}/", ConfigManager.Instance.GeneralConfig.DisplayCurrency) + International.GetText("Day"); toolStripStatusLabelGlobalRateText.Text = International.GetText("Form_Main_global_rate") + ":"; toolStripStatusLabelBTCDayText.Text = "BTC/" + International.GetText("Day"); toolStripStatusLabelBalanceText.Text = (ConfigManager.Instance.GeneralConfig.DisplayCurrency + "/") + International.GetText("Day") + " " + International.GetText("Form_Main_balance") + ":"; devicesListViewEnableControl1.InitLocale(); buttonBenchmark.Text = International.GetText("Form_Main_benchmark"); buttonSettings.Text = International.GetText("Form_Main_settings"); buttonStartMining.Text = International.GetText("Form_Main_start"); buttonStopMining.Text = International.GetText("Form_Main_stop"); label_NotProfitable.Text = International.GetText("Form_Main_MINING_NOT_PROFITABLE"); groupBox1.Text = International.GetText("Form_Main_Group_Device_Rates"); }
public void SetBenchmarkPending() { IsBenchmarkPending = true; BenchmarkStatus = International.GetText("Algorithm_Waiting_Benchmark"); }
private void InitLocalization() { MessageBoxManager.Unregister(); MessageBoxManager.Yes = International.GetText("Global_Yes"); MessageBoxManager.No = International.GetText("Global_No"); MessageBoxManager.OK = International.GetText("Global_OK"); MessageBoxManager.Register(); labelServiceLocation.Text = International.GetText("Service_Location") + ":"; labelBitcoinAddress.Text = International.GetText("BitcoinAddress") + ":"; labelWorkerName.Text = International.GetText("WorkerName") + ":"; linkLabelVisitUs.Text = International.GetText("Form_Main_visit_us"); linkLabelCheckStats.Text = International.GetText("Form_Main_check_stats"); linkLabelChooseBTCWallet.Text = International.GetText("Form_Main_choose_bitcoin_wallet"); toolStripStatusLabelGlobalRateText.Text = International.GetText("Form_Main_global_rate") + ":"; toolStripStatusLabelBTCDayText.Text = "BTC/" + International.GetText("Day"); toolStripStatusLabelBalanceText.Text = (ExchangeRateAPI.ActiveDisplayCurrency + "/") + International.GetText("Day") + " " + International.GetText("Form_Main_balance") + ":"; devicesListViewEnableControl1.InitLocale(); buttonBenchmark.Text = International.GetText("Form_Main_benchmark"); buttonSettings.Text = International.GetText("Form_Main_settings"); buttonStartMining.Text = International.GetText("Form_Main_start"); buttonStopMining.Text = International.GetText("Form_Main_stop"); label_NotProfitable.Text = International.GetText("Form_Main_MINING_NOT_PROFITABLE"); groupBox1.Text = International.GetText("Form_Main_Group_Device_Rates"); }
protected virtual string GetFinalBenchmarkString() { return(BenchmarkSignalTimedout && !TimeoutStandard ? International.GetText("Benchmark_Timedout") : International.GetText("Benchmark_Terminated")); }
private void InitiateBenchmark() { if (listView1.Items.Count > index) { ListViewItem lvi = listView1.Items[index]; index++; if (!lvi.Checked) { InitiateBenchmark(); return; } Miner m = lvi.Tag as Miner; int i = (int)lvi.SubItems[2].Tag; //lvi.SubItems[3].Text = "Please wait..."; inBenchmark = true; CurrentlyBenchmarking = m; if (m is cpuminer) { Time = Config.ConfigData.BenchmarkTimeLimitsCPU[TimeIndex]; lvi.SubItems[3].Text = String.Format(International.GetText("form2_listView_WaitSeconds"), Time); } else if (m is ccminer) { Time = Config.ConfigData.BenchmarkTimeLimitsNVIDIA[TimeIndex]; if (lvi.SubItems[2].Text.Equals("daggerhashimoto")) { lvi.SubItems[3].Text = International.GetText("form2_listView_WaitForEth"); } else { lvi.SubItems[3].Text = String.Format(International.GetText("form2_listView_WaitSeconds"), Time); } } else { Time = Config.ConfigData.BenchmarkTimeLimitsAMD[TimeIndex] / 60; // add an aditional minute if second is not 0 if (DateTime.Now.Second != 0) { Time += 1; } if (lvi.SubItems[2].Text.Equals("daggerhashimoto")) { lvi.SubItems[3].Text = International.GetText("form2_listView_WaitForEth"); } else { lvi.SubItems[3].Text = String.Format(International.GetText("form2_listView_WaitMinutes"), Time); } } m.BenchmarkStart(i, Time, BenchmarkCompleted, lvi); } else { // average all cpu benchmarks if (Globals.Miners[0] is cpuminer) { Helpers.ConsolePrint("BENCHMARK", "Calculating average CPU speeds:"); double[] Speeds = new double[Globals.Miners[0].SupportedAlgorithms.Length]; int[] MTaken = new int[Globals.Miners[0].SupportedAlgorithms.Length]; foreach (ListViewItem lvi in listView1.Items) { if (lvi.Tag is cpuminer) { Miner m = lvi.Tag as Miner; int i = (int)lvi.SubItems[2].Tag; if (m.SupportedAlgorithms[i].BenchmarkSpeed > 0) { Speeds[i] += m.SupportedAlgorithms[i].BenchmarkSpeed; MTaken[i]++; } } } for (int i = 0; i < Speeds.Length; i++) { if (MTaken[i] > 0) { Speeds[i] /= MTaken[i]; } Helpers.ConsolePrint("BENCHMARK", Globals.Miners[0].SupportedAlgorithms[i].NiceHashName + " average speed: " + Globals.Miners[0].PrintSpeed(Speeds[i])); foreach (Miner m in Globals.Miners) { if (m is cpuminer) { m.SupportedAlgorithms[i].BenchmarkSpeed = Speeds[i]; } } } } foreach (ListViewItem lvi in listView1.Items) { Miner m = lvi.Tag as Miner; int i = (int)lvi.SubItems[2].Tag; lvi.SubItems[3].Text = m.PrintSpeed(m.SupportedAlgorithms[i].BenchmarkSpeed); } Config.RebuildGroups(); buttonStartBenchmark.Enabled = true; buttonStopBenchmark.Enabled = false; buttonReset.Enabled = true; buttonClose.Enabled = true; buttonCheckProfitability.Enabled = true; buttonSubmitHardware.Enabled = true; } }
private void BenchmarkBtn_Click(object sender, EventArgs e) { if (InBenchmark) { mm.BenchmarkSignalQuit = true; InBenchmark = false; index = 9999; return; } bool DeviceChecked = false; string DeviceName = ""; for (int i = 0; i < DevicesListView.Items.Count; i++) { if (DevicesListView.Items[i].Selected) { DeviceChecked = true; Int32.TryParse(DevicesListView.Items[i].SubItems[2].Text, out DeviceChecked_Index); mm = DevicesListView.Items[i].Tag as Miner; DeviceName = DevicesListView.Items[i].SubItems[1].Text; } } if (!DeviceChecked) { MessageBox.Show(International.GetText("SubmitResultDialog_NoDeviceCheckedMsg"), International.GetText("SubmitResultDialog_NoDeviceCheckedTitle"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } InBenchmark = true; DevicesListView.Enabled = false; CloseBtn.Enabled = false; StartStopBtn.Text = International.GetText("SubmitResultDialog_StopBtn"); LabelProgressPercentage.Text = "0.00%"; index = 0; Helpers.ConsolePrint("SubmitResultDialog", "Number of Devices: " + mm.CDevs.Count); if (mm.CDevs.Count == 1 && mm.CountBenchmarkedAlgos() != 0) { DialogResult result = MessageBox.Show(International.GetText("SubmitResultDialog_UsePreviousBenchmarkedValueMsg"), International.GetText("SubmitResultDialog_UsePreviousBenchmarkedValueTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) { index = 9999; } } // Temporarily disable the other ComputeDevices in the same Group for (int i = 0; i < mm.CDevs.Count; i++) { if (mm.CDevs[i].ID != DeviceChecked_Index) { mm.CDevs[i].Enabled = false; } else { mm.CDevs[i].Enabled = true; } } BenchmarkProgressBar.Maximum = mm.SupportedAlgorithms.Length; // Parse GPU name Helpers.ConsolePrint("SubmitResultDialog", "Old DeviceName: " + DeviceName); if (DeviceName.Contains("GeForce") || DeviceName.Contains("GTX") || DeviceName.Contains("GT")) { string [] DeviceNameSplit = DeviceName.Split(' '); for (int i = 0; i < DeviceNameSplit.Length; i++) { Helpers.ConsolePrint("DEBUG", "DeviceNameSplit[" + i + "]: " + DeviceNameSplit[i]); if (DeviceNameSplit[i].Equals("GT") || DeviceNameSplit[i].Equals("GTX")) { if ((i + 2) <= DeviceNameSplit.Length) { DeviceName = "NVIDIA " + DeviceNameSplit[i] + DeviceNameSplit[i + 1]; for (int j = i + 2; j < DeviceNameSplit.Length; j++) { DeviceName += " " + DeviceNameSplit[j]; } break; } } } } Helpers.ConsolePrint("SubmitResultDialog", "New DeviceName: " + DeviceName); url = "https://www.nicehash.com/?p=calc&name=" + DeviceName; InitiateBenchmark(); }
private void InitiateBenchmark() { int algoIndex = index; index++; if (algoIndex < mm.SupportedAlgorithms.Length) { if (!mm.SupportedAlgorithms[algoIndex].Skip) { if (mm is cpuminer) { Time = Config.ConfigData.BenchmarkTimeLimitsCPU[TimeIndex]; } else if (mm is ccminer) { Time = Config.ConfigData.BenchmarkTimeLimitsNVIDIA[TimeIndex]; } else { Time = Config.ConfigData.BenchmarkTimeLimitsAMD[TimeIndex] / 60; // add an aditional minute if second is not 0 if (DateTime.Now.Second != 0) { Time += 1; } } CurrentAlgoName = mm.SupportedAlgorithms[algoIndex].NiceHashName; UpdateProgressBar(false); mm.BenchmarkStart(algoIndex, Time, BenchmarkCompleted, DevicesListView.Items[DeviceChecked_Index].Tag); } else { UpdateProgressBar(true); InitiateBenchmark(); } } else { for (int i = 0; i < mm.SupportedAlgorithms.Length; i++) { if (!mm.SupportedAlgorithms[i].Skip) { int id = mm.SupportedAlgorithms[i].NiceHashID; url += "&speed" + id + "=" + (mm.SupportedAlgorithms[i].BenchmarkSpeed / div[id]).ToString("F2", System.Globalization.CultureInfo.InvariantCulture); } } InBenchmark = false; DevicesListView.Enabled = true; CloseBtn.Enabled = true; StartStopBtn.Text = International.GetText("SubmitResultDialog_StartBtn"); BenchmarkProgressBar.Value = 0; LabelProgressPercentage.Text = International.GetText("SubmitResultDialog_LabelProgressPercentageCompleted"); if (mm.BenchmarkSignalQuit) { LabelProgressPercentage.Text = International.GetText("SubmitResultDialog_LabelProgressPercentageStopped"); return; } url += "&nhmver=" + Application.ProductVersion.ToString(); // Add version info url += "&cost=1&power=1"; // Set default power and cost to 1 System.Diagnostics.Process.Start(url); } }
public MinerFileNotFoundDialog(string MinerDeviceName, string Path) { InitializeComponent(); DisableDetection = false; this.Text = International.GetText("MinerFileNotFoundDialog_title"); linkLabelError.Text = String.Format(International.GetText("MinerFileNotFoundDialog_linkLabelError"), MinerDeviceName, Path, International.GetText("MinerFileNotFoundDialog_link")); linkLabelError.LinkArea = new LinkArea(this.linkLabelError.Text.IndexOf(International.GetText("MinerFileNotFoundDialog_link")), International.GetText("MinerFileNotFoundDialog_link").Length); chkBoxDisableDetection.Text = International.GetText("MinerFileNotFoundDialog_chkBoxDisableDetection"); buttonOK.Text = International.GetText("Global_OK"); }
private void buttonStartMining_Click(object sender, EventArgs e) { if (textBoxBTCAddress.Text.Equals("")) { DialogResult result = MessageBox.Show(International.GetText("form1_DemoModeMsg"), International.GetText("form1_DemoModeTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.Yes) { DemoMode = true; labelDemoMode.Visible = true; labelDemoMode.Text = International.GetText("form1_DemoModeLabel"); textBoxBTCAddress.Text = "34HKWdzLxWBduUfJE9JxaFhoXnfC6gmePG"; } else { return; } } else if (!VerifyMiningAddress(true)) { return; } if (NiceHashData == null) { MessageBox.Show(International.GetText("form1_msgbox_NullNiceHashDataMsg"), International.GetText("Error_with_Exclamation"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Check if the user has run benchmark first foreach (Miner m in Miners) { if (m.EnabledDeviceCount() == 0) { continue; } if (m.CountBenchmarkedAlgos() == 0) { DialogResult result = MessageBox.Show(String.Format(International.GetText("form1_msgbox_HaveNotBenchmarkedMsg"), m.MinerDeviceName), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.Yes) { if (!(m is cpuminer)) { // quick and ugly way to prevent GPUs from starting on extremely unprofitable x11 m.SupportedAlgorithms[13].BenchmarkSpeed = 1; } break; } if (result == System.Windows.Forms.DialogResult.No) { DemoMode = false; labelDemoMode.Visible = false; textBoxBTCAddress.Text = ""; Config.ConfigData.BitcoinAddress = ""; Config.Commit(); return; } } } textBoxBTCAddress.Enabled = false; textBoxWorkerName.Enabled = false; comboBoxLocation.Enabled = false; buttonBenchmark.Enabled = false; buttonStartMining.Enabled = false; buttonSettings.Enabled = false; listViewDevices.Enabled = false; buttonStopMining.Enabled = true; Config.ConfigData.BitcoinAddress = textBoxBTCAddress.Text.Trim(); Config.ConfigData.WorkerName = textBoxWorkerName.Text.Trim(); Config.ConfigData.ServiceLocation = comboBoxLocation.SelectedIndex; if (!DemoMode) { Config.Commit(); } SMAMinerCheck.Interval = 100; SMAMinerCheck.Start(); //SMAMinerCheck_Tick(null, null); MinerStatsCheck.Start(); }
private void InitMainConfigGUIData() { if (ConfigManager.GeneralConfig.ServiceLocation >= 0 && ConfigManager.GeneralConfig.ServiceLocation < Globals.MiningLocation.Length) { comboBoxLocation.SelectedIndex = ConfigManager.GeneralConfig.ServiceLocation; } else { comboBoxLocation.SelectedIndex = 0; } textBoxBTCAddress.Text = ConfigManager.GeneralConfig.BitcoinAddress; textBoxFullWorkerName.Text = ConfigManager.GeneralConfig.FullWorkerName; if (textBoxFullWorkerName.Text.Length > 15) { textBoxWorkerName.Text = textBoxFullWorkerName.Text.Substring(textBoxFullWorkerName.Text.Length - 15, 15); } else { textBoxWorkerName.Text = textBoxFullWorkerName.Text; } ShowWarningNiceHashData = true; DemoMode = false; // init active display currency after config load ExchangeRateAPI.ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency; toolStripStatusLabelBalanceDollarValue.Text = "(" + ExchangeRateAPI.ActiveDisplayCurrency + ")"; toolStripStatusLabelBalanceText.Text = (ExchangeRateAPI.ActiveDisplayCurrency + "/") + International.GetText("Day") + " " + International.GetText("Form_Main_balance") + ":"; BalanceCheck_Tick(null, null); // update currency changes if (_isDeviceDetectionInitialized) { devicesListViewEnableControl1.ResetComputeDevices(ComputeDeviceManager.Avaliable.AllAvaliableDevices); } }
// This is a single shot _benchmarkTimer private void StartupTimer_Tick(object sender, EventArgs e) { StartupTimer.Stop(); StartupTimer = null; if (!Helpers.Is45NetOrHigher()) { MessageBox.Show(International.GetText("NET45_Not_Intsalled_msg"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); this.Close(); return; } if (!Helpers.InternalCheckIsWow64()) { MessageBox.Show(International.GetText("Form_Main_x64_Support_Only"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); this.Close(); return; } // Query Avaliable ComputeDevices ComputeDeviceQueryManager.Instance.QueryDevices(LoadingScreen); _isDeviceDetectionInitialized = true; ///////////////////////////////////////////// /////// from here on we have our devices and Miners initialized ConfigManager.Instance.AfterDeviceQueryInitialization(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SaveConfig")); // All devices settup should be initialized in AllDevices devicesListViewEnableControl1.ResetComputeDevices(ComputeDevice.AllAvaliableDevices); // set properties after devicesListViewEnableControl1.AutoSaveChange = true; devicesListViewEnableControl1.SaveToGeneralConfig = true; LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_CheckLatestVersion")); MinerStatsCheck = new Timer(); MinerStatsCheck.Tick += MinerStatsCheck_Tick; MinerStatsCheck.Interval = ConfigManager.Instance.GeneralConfig.MinerAPIQueryInterval * 1000; SMAMinerCheck = new Timer(); SMAMinerCheck.Tick += SMAMinerCheck_Tick; SMAMinerCheck.Interval = ConfigManager.Instance.GeneralConfig.SwitchMinSecondsFixed * 1000 + R.Next(ConfigManager.Instance.GeneralConfig.SwitchMinSecondsDynamic * 1000); if (ComputeDeviceGroupManager.Instance.GetGroupCount(DeviceGroupType.AMD_OpenCL) > 0) { SMAMinerCheck.Interval = (ConfigManager.Instance.GeneralConfig.SwitchMinSecondsAMD + ConfigManager.Instance.GeneralConfig.SwitchMinSecondsFixed) * 1000 + R.Next(ConfigManager.Instance.GeneralConfig.SwitchMinSecondsDynamic * 1000); } UpdateCheck = new Timer(); UpdateCheck.Tick += UpdateCheck_Tick; UpdateCheck.Interval = 1000 * 3600; // every 1 hour UpdateCheck.Start(); UpdateCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetNiceHashSMA")); SMACheck = new Timer(); SMACheck.Tick += SMACheck_Tick; SMACheck.Interval = 60 * 1000; // every 60 seconds SMACheck.Start(); // increase timeout if (Globals.IsFirstNetworkCheckTimeout) { while (!Helpers.WebRequestTestGoogle() && Globals.FirstNetworkCheckTimeoutTries > 0) { --Globals.FirstNetworkCheckTimeoutTries; } } SMACheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetBTCRate")); BitcoinExchangeCheck = new Timer(); BitcoinExchangeCheck.Tick += BitcoinExchangeCheck_Tick; BitcoinExchangeCheck.Interval = 1000 * 3601; // every 1 hour and 1 second BitcoinExchangeCheck.Start(); BitcoinExchangeCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetNiceHashBalance")); BalanceCheck = new Timer(); BalanceCheck.Tick += BalanceCheck_Tick; BalanceCheck.Interval = 61 * 1000; // every 61 seconds BalanceCheck.Start(); BalanceCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetEnvironmentVariable")); SetEnvironmentVariables(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetWindowsErrorReporting")); Helpers.DisableWindowsErrorReporting(ConfigManager.Instance.GeneralConfig.DisableWindowsErrorReporting); LoadingScreen.IncreaseLoadCounter(); if (ConfigManager.Instance.GeneralConfig.NVIDIAP0State) { LoadingScreen.SetInfoMsg(International.GetText("Form_Main_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); } } LoadingScreen.FinishLoad(); // check if download needed if (!MinersDownloadManager.Instance.IsMinersBinsInit() && !ConfigManager.Instance.GeneralConfig.DownloadInit) { _downloadUnzipForm = new Form_Loading(); SetChildFormCenter(_downloadUnzipForm); _downloadUnzipForm.ShowDialog(); } // check if files are mising if (!MinersDownloadManager.Instance.IsMinersBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.Instance.GeneralConfig.DownloadInit = false; ConfigManager.Instance.GeneralConfig.Commit(); Process PHandle = new Process(); PHandle.StartInfo.FileName = Application.ExecutablePath; PHandle.Start(); Close(); return; } } // no bots please if (ConfigManager.Instance.GeneralConfig.hwidLoadFromFile && !ConfigManager.Instance.GeneralConfig.hwidOK) { var result = MessageBox.Show("NiceHash Miner has detected change of hardware ID. If you did not download and install NiceHash Miner, your computer may be compromised. In that case, we suggest you to install an antivirus program or reinstall your Windows.\r\n\r\nContinue with NiceHash Miner?", //International.GetText("Form_Main_msgbox_anti_botnet_msgbox"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.No) { Close(); return; } else { // users agrees he installed it so commit changes ConfigManager.Instance.GeneralConfig.Commit(); } } else { if (ConfigManager.Instance.GeneralConfig.AutoStartMining) { buttonStartMining_Click(null, null); } } }
// This is a single shot _benchmarkTimer private void StartupTimer_Tick(object sender, EventArgs e) { StartupTimer.Stop(); StartupTimer = null; // Internals Init // TODO add loading step MinersSettingsManager.Init(); if (!Helpers.InternalCheckIsWow64()) { MessageBox.Show(International.GetText("Form_Main_x64_Support_Only"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); this.Close(); return; } // 3rdparty miners check scope #1 { // check if setting set if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.NOT_SET) { // Show TOS Form tos = new Form_3rdParty_TOS(); tos.ShowDialog(this); } } // Query Avaliable ComputeDevices ComputeDeviceManager.Query.QueryDevices(LoadingScreen); _isDeviceDetectionInitialized = true; ///////////////////////////////////////////// /////// from here on we have our devices and Miners initialized ConfigManager.AfterDeviceQueryInitialization(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SaveConfig")); // All devices settup should be initialized in AllDevices devicesListViewEnableControl1.ResetComputeDevices(ComputeDeviceManager.Avaliable.AllAvaliableDevices); // set properties after devicesListViewEnableControl1.SaveToGeneralConfig = true; LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_CheckLatestVersion")); MinerStatsCheck = new Timer(); MinerStatsCheck.Tick += MinerStatsCheck_Tick; MinerStatsCheck.Interval = ConfigManager.GeneralConfig.MinerAPIQueryInterval * 1000; SMAMinerCheck = new Timer(); SMAMinerCheck.Tick += SMAMinerCheck_Tick; SMAMinerCheck.Interval = ConfigManager.GeneralConfig.SwitchMinSecondsFixed * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); if (ComputeDeviceManager.Group.ContainsAMD_GPUs) { SMAMinerCheck.Interval = (ConfigManager.GeneralConfig.SwitchMinSecondsAMD + ConfigManager.GeneralConfig.SwitchMinSecondsFixed) * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); } UpdateCheck = new Timer(); UpdateCheck.Tick += UpdateCheck_Tick; UpdateCheck.Interval = 1000 * 3600; // every 1 hour UpdateCheck.Start(); UpdateCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetNiceHashSMA")); SMACheck = new SystemTimer(); SMACheck.Elapsed += SMACheck_Tick; SMACheck.Interval = 60 * 1000 * 2; // every 2 minutes SMACheck.Start(); // increase timeout if (Globals.IsFirstNetworkCheckTimeout) { while (!Helpers.WebRequestTestGoogle() && Globals.FirstNetworkCheckTimeoutTries > 0) { --Globals.FirstNetworkCheckTimeoutTries; } } SMACheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetBTCRate")); BitcoinExchangeCheck = new Timer(); BitcoinExchangeCheck.Tick += BitcoinExchangeCheck_Tick; BitcoinExchangeCheck.Interval = 1000 * 3601; // every 1 hour and 1 second BitcoinExchangeCheck.Start(); BitcoinExchangeCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetNiceHashBalance")); BalanceCheck = new Timer(); BalanceCheck.Tick += BalanceCheck_Tick; BalanceCheck.Interval = 61 * 1000 * 5; // every ~5 minutes BalanceCheck.Start(); BalanceCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetEnvironmentVariable")); Helpers.SetDefaultEnvironmentVariables(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetWindowsErrorReporting")); Helpers.DisableWindowsErrorReporting(ConfigManager.GeneralConfig.DisableWindowsErrorReporting); LoadingScreen.IncreaseLoadCounter(); if (ConfigManager.GeneralConfig.NVIDIAP0State) { LoadingScreen.SetInfoMsg(International.GetText("Form_Main_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); } } LoadingScreen.FinishLoad(); bool runVCRed = !MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit; // standard miners check scope { // check if download needed if (!MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit) { Form_Loading downloadUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.StandardDlSetup)); SetChildFormCenter(downloadUnzipForm); downloadUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMinersBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit = false; ConfigManager.GeneralConfigFileCommit(); Process PHandle = new Process(); PHandle.StartInfo.FileName = Application.ExecutablePath; PHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit) { // all good ConfigManager.GeneralConfig.DownloadInit = true; ConfigManager.GeneralConfigFileCommit(); } } // 3rdparty miners check scope #2 { // check if download needed if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.YES) { if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit() && !ConfigManager.GeneralConfig.DownloadInit3rdParty) { Form_Loading download3rdPartyUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.ThirdPartyDlSetup)); SetChildFormCenter(download3rdPartyUnzipForm); download3rdPartyUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit3rdParty = false; ConfigManager.GeneralConfigFileCommit(); Process PHandle = new Process(); PHandle.StartInfo.FileName = Application.ExecutablePath; PHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit3rdParty) { // all good ConfigManager.GeneralConfig.DownloadInit3rdParty = true; ConfigManager.GeneralConfigFileCommit(); } } } if (runVCRed) { Helpers.InstallVcRedist(); } // no bots please if (ConfigManager.GeneralConfigHwidLoadFromFile() && !ConfigManager.GeneralConfigHwidOK()) { var result = MessageBox.Show("NiceHash Miner has detected change of hardware ID. If you did not download and install NiceHash Miner, your computer may be compromised. In that case, we suggest you to install an antivirus program or reinstall your Windows.\r\n\r\nContinue with NiceHash Miner?", //International.GetText("Form_Main_msgbox_anti_botnet_msgbox"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.No) { Close(); return; } else { // users agrees he installed it so commit changes ConfigManager.GeneralConfigFileCommit(); } } else { if (ConfigManager.GeneralConfig.AutoStartMining) { // well this is started manually as we want it to start at runtime IsManuallyStarted = true; if (StartMining(true) != StartMiningReturnType.StartMining) { IsManuallyStarted = false; StopMining(); } } } }
private void buttonStartMining_Click(object sender, EventArgs e) { if (textBoxBTCAddress.Text.Equals("")) { DialogResult result = MessageBox.Show(International.GetText("Form_Main_DemoModeMsg"), International.GetText("Form_Main_DemoModeTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.Yes) { DemoMode = true; labelDemoMode.Visible = true; labelDemoMode.Text = International.GetText("Form_Main_DemoModeLabel"); //textBoxBTCAddress.Text = "34HKWdzLxWBduUfJE9JxaFhoXnfC6gmePG"; } else { return; } } else if (!VerifyMiningAddress(true)) { return; } if (Globals.NiceHashData == null) { MessageBox.Show(International.GetText("Form_Main_msgbox_NullNiceHashDataMsg"), International.GetText("Error_with_Exclamation"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // first value is a boolean if initialized or not var tuplePair = DeviceBenchmarkConfigManager.Instance.IsEnabledBenchmarksInitialized(); bool isBenchInit = tuplePair.Item1; Dictionary <string, List <AlgorithmType> > nonBenchmarkedPerDevice = tuplePair.Item2; // Check if the user has run benchmark first if (!isBenchInit) { DialogResult result = MessageBox.Show(International.GetText("EnabledUnbenchmarkedAlgorithmsWarning"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.Yes) { SMACheck.Stop(); List <ComputeDevice> enabledDevices = new List <ComputeDevice>(); HashSet <string> deviceNames = new HashSet <string>(); foreach (var cdev in ComputeDevice.AllAvaliableDevices) { if (cdev.Enabled && !deviceNames.Contains(cdev.Name)) { deviceNames.Add(cdev.Name); enabledDevices.Add(cdev); } } BenchmarkForm = new Form_Benchmark( BenchmarkPerformanceType.Standard, true); SetChildFormCenter(BenchmarkForm); BenchmarkForm.ShowDialog(); BenchmarkForm = null; InitMainConfigGUIData(); SMACheck.Start(); } else if (result == System.Windows.Forms.DialogResult.No) { // check devices without benchmarks foreach (var cdev in ComputeDevice.AllAvaliableDevices) { bool Enabled = false; foreach (var algo in cdev.DeviceBenchmarkConfig.AlgorithmSettings) { if (algo.Value.BenchmarkSpeed > 0) { Enabled = true; break; } } cdev.ComputeDeviceEnabledOption.IsEnabled = Enabled; } } else { return; } } textBoxBTCAddress.Enabled = false; textBoxWorkerName.Enabled = false; comboBoxLocation.Enabled = false; buttonBenchmark.Enabled = false; buttonStartMining.Enabled = false; buttonSettings.Enabled = false; devicesListViewEnableControl1.IsMining = true; buttonStopMining.Enabled = true; ConfigManager.Instance.GeneralConfig.BitcoinAddress = textBoxBTCAddress.Text.Trim(); ConfigManager.Instance.GeneralConfig.WorkerName = textBoxWorkerName.Text.Trim(); ConfigManager.Instance.GeneralConfig.ServiceLocation = comboBoxLocation.SelectedIndex; InitFlowPanelStart(); ClearRatesALL(); var btcAdress = DemoMode ? Globals.DemoUser : textBoxBTCAddress.Text.Trim(); var isMining = MinersManager.Instance.StartInitialize(this, Globals.MiningLocation[comboBoxLocation.SelectedIndex], textBoxWorkerName.Text.Trim(), btcAdress); if (!DemoMode) { ConfigManager.Instance.GeneralConfig.Commit(); } SMAMinerCheck.Interval = 100; SMAMinerCheck.Start(); //SMAMinerCheck_Tick(null, null); MinerStatsCheck.Start(); }
public void AddRateInfo(string groupName, string deviceStringInfo, APIData iAPIData, double paying, bool isApiGetException) { string ApiGetExceptionString = isApiGetException ? "**" : ""; string speedString = Helpers.FormatDualSpeedOutput(iAPIData.Speed, iAPIData.SecondarySpeed) + iAPIData.AlgorithmName + ApiGetExceptionString; if (iAPIData.AlgorithmID == AlgorithmType.Equihash) { speedString = speedString.Replace("H/s", "Sols/s"); } string rateBTCString = FormatPayingOutput(paying); string rateCurrencyString = ExchangeRateAPI.ConvertToActiveCurrency(paying * Globals.BitcoinUSDRate).ToString("F2", CultureInfo.InvariantCulture) + String.Format(" {0}/", ExchangeRateAPI.ActiveDisplayCurrency) + International.GetText("Day"); ((GroupProfitControl)flowLayoutPanelRates.Controls[flowLayoutPanelRatesIndex++]) .UpdateProfitStats(groupName, deviceStringInfo, speedString, rateBTCString, rateCurrencyString); UpdateGlobalRate(); }
private string FormatPayingOutput(double paying) { string ret = ""; if (ConfigManager.Instance.GeneralConfig.AutoScaleBTCValues && paying < 0.1) { ret = (paying * 1000).ToString("F7", CultureInfo.InvariantCulture) + " mBTC/" + International.GetText("Day"); } else { ret = paying.ToString("F8", CultureInfo.InvariantCulture) + " BTC/" + International.GetText("Day"); } return(ret); }
private StartMiningReturnType StartMining(bool showWarnings) { if (textBoxBTCAddress.Text.Equals("")) { if (showWarnings) { var result = MessageBox.Show(International.GetText("Form_Main_DemoModeMsg"), International.GetText("Form_Main_DemoModeTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { _demoMode = true; labelDemoMode.Visible = true; labelDemoMode.Text = International.GetText("Form_Main_DemoModeLabel"); } else { return(StartMiningReturnType.IgnoreMsg); } } else { return(StartMiningReturnType.IgnoreMsg); } } else if (!VerifyMiningAddress(true)) { return(StartMiningReturnType.IgnoreMsg); } var hasData = NHSmaData.HasData; if (!showWarnings) { for (var i = 0; i < 10; i++) { if (hasData) { break; } Thread.Sleep(1000); hasData = NHSmaData.HasData; Helpers.ConsolePrint("NICEHASH", $"After {i}s has data: {hasData}"); } } if (!hasData) { Helpers.ConsolePrint("NICEHASH", "No data received within timeout"); if (showWarnings) { MessageBox.Show(International.GetText("Form_Main_msgbox_NullNiceHashDataMsg"), International.GetText("Error_with_Exclamation"), MessageBoxButtons.OK, MessageBoxIcon.Error); } return(StartMiningReturnType.IgnoreMsg); } // Check if there are unbenchmakred algorithms var isBenchInit = true; foreach (var cdev in ComputeDeviceManager.Available.Devices) { if (cdev.Enabled) { if (cdev.GetAlgorithmSettings().Where(algo => algo.Enabled).Any(algo => algo.BenchmarkSpeed == 0)) { isBenchInit = false; } } } // Check if the user has run benchmark first if (!isBenchInit) { var result = DialogResult.No; if (showWarnings) { result = MessageBox.Show(International.GetText("EnabledUnbenchmarkedAlgorithmsWarning"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); } if (result == DialogResult.Yes) { _benchmarkForm = new Form_Benchmark( BenchmarkPerformanceType.Standard, true); SetChildFormCenter(_benchmarkForm); _benchmarkForm.ShowDialog(); _benchmarkForm = null; InitMainConfigGuiData(); } else if (result == DialogResult.No) { // check devices without benchmarks foreach (var cdev in ComputeDeviceManager.Available.Devices) { if (cdev.Enabled) { var enabled = cdev.GetAlgorithmSettings().Any(algo => algo.BenchmarkSpeed > 0); cdev.Enabled = enabled; } } } else { return(StartMiningReturnType.IgnoreMsg); } } textBoxBTCAddress.Enabled = false; textBoxWorkerName.Enabled = false; comboBoxLocation.Enabled = false; buttonBenchmark.Enabled = false; buttonStartMining.Enabled = false; buttonSettings.Enabled = false; devicesListViewEnableControl1.IsMining = true; buttonStopMining.Enabled = true; // Disable profitable notification on start _isNotProfitable = false; ConfigManager.GeneralConfig.BitcoinAddress = textBoxBTCAddress.Text.Trim(); ConfigManager.GeneralConfig.WorkerName = textBoxWorkerName.Text.Trim(); ConfigManager.GeneralConfig.ServiceLocation = comboBoxLocation.SelectedIndex; InitFlowPanelStart(); ClearRatesAll(); var btcAdress = _demoMode ? Globals.DemoUser : textBoxBTCAddress.Text.Trim(); var isMining = MinersManager.StartInitialize(this, Globals.MiningLocation[comboBoxLocation.SelectedIndex], textBoxWorkerName.Text.Trim(), btcAdress); if (!_demoMode) { ConfigManager.GeneralConfigFileCommit(); } //_isSmaUpdated = true; // Always check profits on mining start //_smaMinerCheck.Interval = 100; //_smaMinerCheck.Start(); _minerStatsCheck.Start(); if (ConfigManager.GeneralConfig.RunScriptOnCUDA_GPU_Lost) { _computeDevicesCheckTimer = new SystemTimer(); _computeDevicesCheckTimer.Elapsed += ComputeDevicesCheckTimer_Tick; _computeDevicesCheckTimer.Interval = 60000; _computeDevicesCheckTimer.Start(); } return(isMining ? StartMiningReturnType.StartMining : StartMiningReturnType.ShowNoMining); }
virtual protected void BenchmarkThreadRoutine(object CommandLine) { Thread.Sleep(ConfigManager.Instance.GeneralConfig.MinerRestartDelayMS); BenchmarkSignalQuit = false; BenchmarkSignalHanged = false; BenchmarkSignalFinnished = false; BenchmarkException = null; try { Helpers.ConsolePrint("BENCHMARK", "Benchmark starts"); BenchmarkHandle = BenchmarkStartProcess((string)CommandLine); BenchmarkThreadRoutineStartSettup(); // wait a little longer then the benchmark routine if exit false throw //var timeoutTime = BenchmarkTimeoutInSeconds(BenchmarkTimeInSeconds); //var exitSucces = BenchmarkHandle.WaitForExit(timeoutTime * 1000); // don't use wait for it breaks everything BenchmarkProcessStatus = BenchmarkProcessStatus.Running; BenchmarkHandle.WaitForExit(); if (BenchmarkSignalTimedout) { throw new Exception("Benchmark timedout"); } if (BenchmarkException != null) { throw BenchmarkException; } if (BenchmarkSignalQuit) { throw new Exception("Termined by user request"); } if (BenchmarkSignalHanged) { throw new Exception("SGMiner is not responding"); } if (BenchmarkSignalFinnished) { //break; } } catch (Exception ex) { BenchmarkAlgorithm.BenchmarkSpeed = 0; Helpers.ConsolePrint(MinerTAG(), "Benchmark Exception: " + ex.Message); if (BenchmarkComunicator != null && !OnBenchmarkCompleteCalled) { OnBenchmarkCompleteCalled = true; BenchmarkComunicator.OnBenchmarkComplete(false, BenchmarkSignalTimedout ? International.GetText("Benchmark_Timedout") : International.GetText("Benchmark_Terminated")); } } finally { BenchmarkProcessStatus = BenchmarkProcessStatus.Success; Helpers.ConsolePrint("BENCHMARK", "Final Speed: " + Helpers.FormatSpeedOutput(BenchmarkAlgorithm.BenchmarkSpeed)); Helpers.ConsolePrint("BENCHMARK", "Benchmark ends"); if (BenchmarkComunicator != null && !OnBenchmarkCompleteCalled) { OnBenchmarkCompleteCalled = true; BenchmarkComunicator.OnBenchmarkComplete(true, "Success"); } } }
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(); }
private void InitMainConfigGUIData() { if (ConfigManager.GeneralConfig.ServiceLocation >= 0 && ConfigManager.GeneralConfig.ServiceLocation < Globals.MiningLocation.Length) { comboBoxLocation.SelectedIndex = ConfigManager.GeneralConfig.ServiceLocation; } else { comboBoxLocation.SelectedIndex = 0; } textBoxBTCAddress.Text = ConfigManager.GeneralConfig.BitcoinAddress; textBoxWorkerName.Text = ConfigManager.GeneralConfig.WorkerName; ShowWarningNiceHashData = true; DemoMode = false; // init active display currency after config load ExchangeRateAPI.ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency; // init factor for Time Unit switch (ConfigManager.GeneralConfig.TimeUnit) { case TimeUnitType.Hour: factorTimeUnit = 1.0 / 24.0; break; case TimeUnitType.Day: factorTimeUnit = 1; break; case TimeUnitType.Week: factorTimeUnit = 7; break; case TimeUnitType.Month: factorTimeUnit = 30; break; case TimeUnitType.Year: factorTimeUnit = 365; break; } toolStripStatusLabelBalanceDollarValue.Text = "(" + ExchangeRateAPI.ActiveDisplayCurrency + ")"; toolStripStatusLabelBalanceText.Text = (ExchangeRateAPI.ActiveDisplayCurrency + "/") + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()) + " " + International.GetText("Form_Main_balance") + ":"; BalanceCallback(null, null); // update currency changes if (_isDeviceDetectionInitialized) { devicesListViewEnableControl1.ResetComputeDevices(ComputeDeviceManager.Avaliable.AllAvaliableDevices); } }
public Form1(bool ss) { InitializeComponent(); MessageBoxManager.Yes = International.GetText("Global_Yes"); MessageBoxManager.No = International.GetText("Global_No"); MessageBoxManager.OK = International.GetText("Global_OK"); MessageBoxManager.Register(); labelServiceLocation.Text = International.GetText("Service_Location") + ":"; labelBitcoinAddress.Text = International.GetText("BitcoinAddress") + ":"; labelWorkerName.Text = International.GetText("WorkerName") + ":"; linkLabelVisitUs.Text = International.GetText("form1_visit_us"); linkLabelCheckStats.Text = International.GetText("form1_check_stats"); linkLabelChooseBTCWallet.Text = International.GetText("form1_choose_bitcoin_wallet"); label_RateCPU.Text = International.GetText("Rate") + ":"; label_RateNVIDIA5X.Text = International.GetText("Rate") + ":"; label_RateNVIDIA3X.Text = International.GetText("Rate") + ":"; label_RateNVIDIA2X.Text = International.GetText("Rate") + ":"; label_RateAMD.Text = International.GetText("Rate") + ":"; label_RateCPUBTC.Text = "0.00000000 BTC/" + International.GetText("Day"); label_RateNVIDIA5XBTC.Text = "0.00000000 BTC/" + International.GetText("Day"); label_RateNVIDIA3XBTC.Text = "0.00000000 BTC/" + International.GetText("Day"); label_RateNVIDIA2XBTC.Text = "0.00000000 BTC/" + International.GetText("Day"); label_RateAMDBTC.Text = "0.00000000 BTC/" + International.GetText("Day"); label_RateCPUDollar.Text = String.Format("0.00 {0}/", !CurrencyConverter.CurrencyConverter.ConverterActive ? "$" : Config.ConfigData.DisplayCurrency) + International.GetText("Day"); label_RateNVIDIA5XDollar.Text = String.Format("0.00 {0}/", !CurrencyConverter.CurrencyConverter.ConverterActive ? "$" : Config.ConfigData.DisplayCurrency) + International.GetText("Day"); label_RateNVIDIA3XDollar.Text = String.Format("0.00 {0}/", !CurrencyConverter.CurrencyConverter.ConverterActive ? "$" : Config.ConfigData.DisplayCurrency) + International.GetText("Day"); label_RateNVIDIA2XDollar.Text = String.Format("0.00 {0}/", !CurrencyConverter.CurrencyConverter.ConverterActive ? "$" : Config.ConfigData.DisplayCurrency) + International.GetText("Day"); label_RateAMDDollar.Text = String.Format("0.00 {0}/", !CurrencyConverter.CurrencyConverter.ConverterActive ? "$" : Config.ConfigData.DisplayCurrency) + International.GetText("Day"); toolStripStatusLabelGlobalRateText.Text = International.GetText("form1_global_rate") + ":"; toolStripStatusLabelBTCDayText.Text = "BTC/" + International.GetText("Day"); toolStripStatusLabelBalanceText.Text = (CurrencyConverter.CurrencyConverter.ConverterActive == false ? "$/" : Config.ConfigData.DisplayCurrency + "/") + International.GetText("Day") + " " + International.GetText("form1_balance") + ":"; listViewDevices.Columns[0].Text = International.GetText("ListView_Enabled"); listViewDevices.Columns[1].Text = International.GetText("ListView_Group"); listViewDevices.Columns[2].Text = International.GetText("ListView_Device"); buttonBenchmark.Text = International.GetText("form1_benchmark"); buttonSettings.Text = International.GetText("form1_settings"); buttonStartMining.Text = International.GetText("form1_start"); buttonStopMining.Text = International.GetText("form1_stop"); if (ss) { Form4 f4 = new Form4(); f4.ShowDialog(); } // Log the computer's amount of Total RAM and Page File Size ManagementObjectCollection moc = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_OperatingSystem").Get(); foreach (ManagementObject mo in moc) { long TotalRam = long.Parse(mo["TotalVisibleMemorySize"].ToString()) / 1024; long PageFileSize = (long.Parse(mo["TotalVirtualMemorySize"].ToString()) / 1024) - TotalRam; Helpers.ConsolePrint("NICEHASH", "Total RAM: " + TotalRam + "MB"); Helpers.ConsolePrint("NICEHASH", "Page File Size: " + PageFileSize + "MB"); } R = new Random((int)DateTime.Now.Ticks); Text += " v" + Application.ProductVersion; if (Config.ConfigData.ServiceLocation >= 0 && Config.ConfigData.ServiceLocation < MiningLocation.Length) { comboBoxLocation.SelectedIndex = Config.ConfigData.ServiceLocation; } else { comboBoxLocation.SelectedIndex = 0; } textBoxBTCAddress.Text = Config.ConfigData.BitcoinAddress; textBoxWorkerName.Text = Config.ConfigData.WorkerName; ShowWarningNiceHashData = true; DemoMode = false; if (CurrencyConverter.CurrencyConverter.ConverterActive) { toolStripStatusLabelBalanceDollarValue.Text = "(" + Config.ConfigData.DisplayCurrency + ")"; } }
public void AddRateInfo(string groupName, string deviceStringInfo, APIData iAPIData, double paying, bool isApiGetException) { string ApiGetExceptionString = isApiGetException ? "**" : ""; string speedString = Helpers.FormatDualSpeedOutput(iAPIData.AlgorithmID, iAPIData.Speed, iAPIData.SecondarySpeed) + iAPIData.AlgorithmName + ApiGetExceptionString; string rateBTCString = FormatPayingOutput(paying); string rateCurrencyString = ExchangeRateAPI.ConvertToActiveCurrency(paying * Globals.BitcoinUSDRate * factorTimeUnit).ToString("F2", CultureInfo.InvariantCulture) + String.Format(" {0}/", ExchangeRateAPI.ActiveDisplayCurrency) + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()); try { // flowLayoutPanelRatesIndex may be OOB, so catch ((GroupProfitControl)flowLayoutPanelRates.Controls[flowLayoutPanelRatesIndex++]) .UpdateProfitStats(groupName, deviceStringInfo, speedString, rateBTCString, rateCurrencyString); } catch { } UpdateGlobalRate(); }
private void SetAMDOpenCLStats(string aname, double speed, double paying) { labelAMDOpenCL_Mining_Speed.Text = FormatSpeedOutput(speed) + aname; label_RateAMDBTC.Text = FormatPayingOutput(paying); label_RateAMDDollar.Text = CurrencyConverter.CurrencyConverter.ConvertToActiveCurrency(paying * BitcoinRate).ToString("F2", CultureInfo.InvariantCulture) + String.Format(" {0}/", !CurrencyConverter.CurrencyConverter.ConverterActive ? "$" : Config.ConfigData.DisplayCurrency) + International.GetText("Day"); UpdateGlobalRate(); }
private StartMiningReturnType StartMining(bool showWarnings) { if (textBoxBTCAddress.Text.Equals("")) { if (showWarnings) { DialogResult result = MessageBox.Show(International.GetText("Form_Main_DemoModeMsg"), International.GetText("Form_Main_DemoModeTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.Yes) { DemoMode = true; labelDemoMode.Visible = true; labelDemoMode.Text = International.GetText("Form_Main_DemoModeLabel"); } else { return(StartMiningReturnType.IgnoreMsg); } } else { return(StartMiningReturnType.IgnoreMsg);; } } else if (!VerifyMiningAddress(true)) { return(StartMiningReturnType.IgnoreMsg); } if (Globals.NiceHashData == null) { if (showWarnings) { MessageBox.Show(International.GetText("Form_Main_msgbox_NullNiceHashDataMsg"), International.GetText("Error_with_Exclamation"), MessageBoxButtons.OK, MessageBoxIcon.Error); } return(StartMiningReturnType.IgnoreMsg); } // Check if there are unbenchmakred algorithms bool isBenchInit = true; bool hasAnyAlgoEnabled = false; foreach (var cdev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) { if (cdev.Enabled) { foreach (var algo in cdev.GetAlgorithmSettings()) { if (algo.Enabled == true) { hasAnyAlgoEnabled = true; if (algo.BenchmarkSpeed == 0) { isBenchInit = false; break; } } } } } // Check if the user has run benchmark first if (!isBenchInit) { DialogResult result = DialogResult.No; if (showWarnings) { result = MessageBox.Show(International.GetText("EnabledUnbenchmarkedAlgorithmsWarning"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); } if (result == System.Windows.Forms.DialogResult.Yes) { BenchmarkForm = new Form_Benchmark( BenchmarkPerformanceType.Standard, true); SetChildFormCenter(BenchmarkForm); BenchmarkForm.ShowDialog(); BenchmarkForm = null; InitMainConfigGUIData(); } else if (result == System.Windows.Forms.DialogResult.No) { // check devices without benchmarks foreach (var cdev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) { if (cdev.Enabled) { bool Enabled = false; foreach (var algo in cdev.GetAlgorithmSettings()) { if (algo.BenchmarkSpeed > 0) { Enabled = true; break; } } cdev.Enabled = Enabled; } } } else { return(StartMiningReturnType.IgnoreMsg); } } textBoxBTCAddress.Enabled = false; textBoxWorkerName.Enabled = false; comboBoxLocation.Enabled = false; buttonBenchmark.Enabled = false; buttonStartMining.Enabled = false; buttonSettings.Enabled = false; devicesListViewEnableControl1.IsMining = true; buttonStopMining.Enabled = true; // Disable profitable notification on start IsNotProfitable = false; ConfigManager.GeneralConfig.BitcoinAddress = textBoxBTCAddress.Text.Trim(); ConfigManager.GeneralConfig.WorkerName = textBoxWorkerName.Text.Trim(); ConfigManager.GeneralConfig.ServiceLocation = comboBoxLocation.SelectedIndex; InitFlowPanelStart(); ClearRatesALL(); var btcAdress = DemoMode ? Globals.DemoUser : textBoxBTCAddress.Text.Trim(); var isMining = MinersManager.StartInitialize(this, Globals.MiningLocation[comboBoxLocation.SelectedIndex], textBoxWorkerName.Text.Trim(), btcAdress); if (!DemoMode) { ConfigManager.GeneralConfigFileCommit(); } isSMAUpdated = true; // Always check profits on mining start SMAMinerCheck.Interval = 100; SMAMinerCheck.Start(); MinerStatsCheck.Start(); if (ConfigManager.GeneralConfig.RunScriptOnCUDA_GPU_Lost) { ComputeDevicesCheckTimer = new SystemTimer(); ComputeDevicesCheckTimer.Elapsed += ComputeDevicesCheckTimer_Tick; ComputeDevicesCheckTimer.Interval = 60000; ComputeDevicesCheckTimer.Start(); } return(isMining ? StartMiningReturnType.StartMining : StartMiningReturnType.ShowNoMining); }
private void UpdateGlobalRate() { double TotalRate = MinersManager.GetTotalRate(); if (ConfigManager.GeneralConfig.AutoScaleBTCValues && TotalRate < 0.1) { toolStripStatusLabelBTCDayText.Text = "mBTC/" + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()); toolStripStatusLabelGlobalRateValue.Text = (TotalRate * 1000 * factorTimeUnit).ToString("F5", CultureInfo.InvariantCulture); } else { toolStripStatusLabelBTCDayText.Text = "BTC/" + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()); toolStripStatusLabelGlobalRateValue.Text = (TotalRate * factorTimeUnit).ToString("F6", CultureInfo.InvariantCulture); } toolStripStatusLabelBTCDayValue.Text = ExchangeRateAPI.ConvertToActiveCurrency((TotalRate * factorTimeUnit * Globals.BitcoinUSDRate)).ToString("F2", CultureInfo.InvariantCulture); toolStripStatusLabelBalanceText.Text = (ExchangeRateAPI.ActiveDisplayCurrency + "/") + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()) + " " + International.GetText("Form_Main_balance") + ":"; }