private void EndBenchmark()
        {
            Invoke((MethodInvoker) delegate
            {
                _benchmarkingTimer.Stop();
                InBenchmark = false;
                Ethlargement.Stop();
                Helpers.ConsolePrint("FormBenchmark", "EndBenchmark() benchmark routine finished");

                //CopyBenchmarks();

                BenchmarkStoppedGuiSettings();
                // check if all ok
                if (!_hasFailedAlgorithms && StartMining == false)
                {
                    MessageBox.Show(
                        International.GetText("FormBenchmark_Benchmark_Finish_Succes_MsgBox_Msg"),
                        International.GetText("FormBenchmark_Benchmark_Finish_MsgBox_Title"),
                        MessageBoxButtons.OK);
                }
                else if (StartMining == false)
                {
                    var result = MessageBox.Show(
                        International.GetText("FormBenchmark_Benchmark_Finish_Fail_MsgBox_Msg"),
                        International.GetText("FormBenchmark_Benchmark_Finish_MsgBox_Title"),
                        MessageBoxButtons.RetryCancel);

                    if (result == DialogResult.Retry)
                    {
                        StartButonClick();
                        return;
                    }

                    // get unbenchmarked from criteria and disable
                    CalcBenchmarkDevicesAlgorithmQueue();
                    foreach (var deviceAlgoQueue in _benchmarkDevicesAlgorithmQueue)
                    {
                        foreach (var algorithm in deviceAlgoQueue.Item2)
                        {
                            algorithm.Enabled = false;
                        }
                    }
                }

                if (ExitWhenFinished || StartMining)
                {
                    Close();
                }
            });
        }
        private void EndBenchmark()
        {
            Invoke((MethodInvoker) delegate
            {
                _benchmarkingTimer.Stop();
                InBenchmark = false;
                Ethlargement.Stop();
                Helpers.ConsolePrint("FormBenchmark", "EndBenchmark() benchmark routine finished");

                //CopyBenchmarks();

                BenchmarkStoppedGuiSettings();
                // check if all ok
                if (!_hasFailedAlgorithms && StartMining == false)
                {
                    MessageBox.Show(
                        Translations.Tr("All benchmarks have been successful"),
                        Translations.Tr("Benchmark finished report"),
                        MessageBoxButtons.OK);
                }
                else if (StartMining == false)
                {
                    var result = MessageBox.Show(
                        Translations.Tr("Not all benchmarks finished successfully. Retry to re-run the benchmark process against unbenchmarked algos or Cancel to disable unbenchmarked algorithms."),
                        Translations.Tr("Benchmark finished report"),
                        MessageBoxButtons.RetryCancel);

                    if (result == DialogResult.Retry)
                    {
                        StartButonClick();
                        return;
                    }

                    // get unbenchmarked from criteria and disable
                    CalcBenchmarkDevicesAlgorithmQueue();
                    foreach (var deviceAlgoQueue in _benchmarkDevicesAlgorithmQueue)
                    {
                        foreach (var algorithm in deviceAlgoQueue.Item2)
                        {
                            algorithm.Enabled = false;
                        }
                    }
                }

                if (ExitWhenFinished || StartMining)
                {
                    Close();
                }
            });
        }
예제 #3
0
        protected virtual Process BenchmarkStartProcess(string commandLine)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Helpers.ConsolePrint(MinerTag(), "Starting benchmark: " + commandLine);

            var benchmarkHandle = new Process
            {
                StartInfo =
                {
                    FileName = MiningSetup.MinerPath
                }
            };


            // sgminer quickfix
            if (this is Sgminer)
            {
                BenchmarkProcessPath = "cmd / " + benchmarkHandle.StartInfo.FileName;
                benchmarkHandle.StartInfo.FileName = "cmd";
            }
            else
            {
                BenchmarkProcessPath = benchmarkHandle.StartInfo.FileName;
                Helpers.ConsolePrint(MinerTag(), "Using miner: " + benchmarkHandle.StartInfo.FileName);
                benchmarkHandle.StartInfo.WorkingDirectory = WorkingDirectory;
            }

            // set sys variables
            if (MinersSettingsManager.MinerSystemVariables.ContainsKey(Path))
            {
                foreach (var kvp in MinersSettingsManager.MinerSystemVariables[Path])
                {
                    var envName  = kvp.Key;
                    var envValue = kvp.Value;
                    benchmarkHandle.StartInfo.EnvironmentVariables[envName] = envValue;
                }
            }

            benchmarkHandle.StartInfo.Arguments              = commandLine;
            benchmarkHandle.StartInfo.UseShellExecute        = false;
            benchmarkHandle.StartInfo.RedirectStandardError  = true;
            benchmarkHandle.StartInfo.RedirectStandardOutput = true;
            benchmarkHandle.StartInfo.CreateNoWindow         = true;
            benchmarkHandle.OutputDataReceived += BenchmarkOutputErrorDataReceived;
            benchmarkHandle.ErrorDataReceived  += BenchmarkOutputErrorDataReceived;
            benchmarkHandle.Exited             += BenchmarkHandle_Exited;

            Ethlargement.CheckAndStart(MiningSetup);

            if (!benchmarkHandle.Start())
            {
                return(null);
            }

            _currentPidData = new MinerPidData
            {
                MinerBinPath = benchmarkHandle.StartInfo.FileName,
                Pid          = benchmarkHandle.Id
            };
            _allPidData.Add(_currentPidData);

            return(benchmarkHandle);
        }
예제 #4
0
        protected virtual NiceHashProcess _Start()
        {
            // never start when ended
            if (_isEnded)
            {
                return(null);
            }

            PreviousTotalMH = 0.0;
            if (LastCommandLine.Length == 0)
            {
                return(null);
            }

            Ethlargement.CheckAndStart(MiningSetup);

            var P = new NiceHashProcess();

            if (WorkingDirectory.Length > 1)
            {
                P.StartInfo.WorkingDirectory = WorkingDirectory;
            }

            if (MinersSettingsManager.MinerSystemVariables.ContainsKey(Path))
            {
                foreach (var kvp in MinersSettingsManager.MinerSystemVariables[Path])
                {
                    var envName  = kvp.Key;
                    var envValue = kvp.Value;
                    P.StartInfo.EnvironmentVariables[envName] = envValue;
                }
            }

            P.StartInfo.FileName = Path;
            P.ExitEvent          = Miner_Exited;

            P.StartInfo.Arguments = LastCommandLine;
            if (IsNeverHideMiningWindow)
            {
                P.StartInfo.CreateNoWindow = false;
                if (ConfigManager.GeneralConfig.HideMiningWindows || ConfigManager.GeneralConfig.MinimizeMiningWindows)
                {
                    P.StartInfo.WindowStyle     = ProcessWindowStyle.Minimized;
                    P.StartInfo.UseShellExecute = true;
                }
            }
            else
            {
                P.StartInfo.CreateNoWindow = ConfigManager.GeneralConfig.HideMiningWindows;
            }

            P.StartInfo.UseShellExecute = false;

            try
            {
                if (P.Start())
                {
                    IsRunning = true;

                    _currentPidData = new MinerPidData
                    {
                        MinerBinPath = P.StartInfo.FileName,
                        Pid          = P.Id
                    };
                    _allPidData.Add(_currentPidData);

                    Helpers.ConsolePrint(MinerTag(), "Starting miner " + ProcessTag() + " " + LastCommandLine);

                    StartCoolDownTimerChecker();

                    return(P);
                }

                Helpers.ConsolePrint(MinerTag(), "NOT STARTED " + ProcessTag() + " " + LastCommandLine);
                return(null);
            }
            catch (Exception ex)
            {
                Helpers.ConsolePrint(MinerTag(), ProcessTag() + " _Start: " + ex.Message);
                return(null);
            }
        }