コード例 #1
0
 protected void Restart()
 {
     if (_isEnded)
     {
         return;
     }
     Helpers.ConsolePrint(MinerTag(), ProcessTag() + " Restarting miner..");
     Stop(MinerStopType.END);  // stop miner first
     Thread.Sleep(ConfigManager.GeneralConfig.MinerRestartDelayMS);
     ProcessHandle = _Start(); // start with old command line
 }
コード例 #2
0
        protected override NiceHashProcess _Start()
        {
            NiceHashProcess P = base._Start();

            if (AffinityMask != 0 && P != null)
            {
                CPUID.AdjustAffinity(P.Id, AffinityMask);
            }

            return(P);
        }
コード例 #3
0
        virtual protected NiceHashProcess _Start()
        {
            PreviousTotalMH = 0.0;
            if (LastCommandLine.Length == 0)
            {
                return(null);
            }

            NiceHashProcess P = new NiceHashProcess();

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

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

            P.StartInfo.Arguments       = LastCommandLine;
            P.StartInfo.CreateNoWindow  = ConfigManager.Instance.GeneralConfig.HideMiningWindows;
            P.StartInfo.UseShellExecute = false;

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

                    _currentPidData = new MinerPID_Data();
                    _currentPidData.minerBinPath = P.StartInfo.FileName;
                    _currentPidData.PID          = P.Id;
                    _allPidData.Add(_currentPidData);

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

                    StartCoolDownTimerChecker();
                    isEnded = false;

                    return(P);
                }
                else
                {
                    Helpers.ConsolePrint(MinerTAG(), "NOT STARTED " + ProcessTag() + " " + LastCommandLine);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " _Start: " + ex.Message);
                return(null);
            }
        }
コード例 #4
0
        protected void Stop_cpu_ccminer_sgminer_nheqminer(MinerStopType willswitch)
        {
            if (IsRunning)
            {
                Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " Shutting down miner");
            }
            if (ProcessHandle != null)
            {
                //try { ProcessHandle.Kill(); } catch { }
                try { ProcessHandle.SendCtrlC((uint)Process.GetCurrentProcess().Id); } catch { }
                ProcessHandle.Close();
                ProcessHandle = null;

                // sgminer needs to be removed and kill by PID
                //if (IsKillAllUsedMinerProcs) KillAllUsedMinerProcesses();
            }
        }
コード例 #5
0
        virtual public void Stop(bool willswitch)
        {
            if (willswitch && AlgoNameIs("daggerhashimoto"))
            {
                // daggerhashimoto - we only "pause" mining
                Helpers.ConsolePrint(MinerDeviceName, "Pausing ethminer..");
                ethminerLink.StopMining();
                return;
            }

            Helpers.ConsolePrint(MinerDeviceName, "Shutting down miner");

            if (ProcessHandle != null)
            {
                try { ProcessHandle.Kill(); }
                catch { }
                ProcessHandle.Close();
                ProcessHandle = null;

                if (MinerDeviceName == "AMD_OpenCL")
                {
                    KillSGMiner();
                }
            }

            if (!willswitch && ethminerProcess != null)
            {
                try { ethminerProcess.Kill(); }
                catch { }
                ethminerProcess.Close();
                ethminerProcess = null;
            }

            StartingUpDelay = false;
            PreviousTotalMH = 0.0;
            NotProfitable   = true;
            //IsRunning = false;
            //CurrentAlgo = -1;
        }
コード例 #6
0
ファイル: Miner.cs プロジェクト: theLosers106/NiceHashMiner
        virtual public void Stop()
        {
            if (ProcessHandle != null)
            {
                Helpers.ConsolePrint(MinerDeviceName, "Shutting down miner");
                try { ProcessHandle.Kill(); }
                catch { }
                ProcessHandle.Close();
                ProcessHandle   = null;
                StartingUpDelay = false;
                PreviousTotalMH = 0.0;

                if (AlgoNameIs("daggerhashimoto"))
                {
                    ER.Stop();
                }
                else if (MinerDeviceName == "AMD_OpenCL")
                {
                    KillSGMiner();
                }
            }
        }
コード例 #7
0
        protected void Stop_cpu_ccminer_sgminer_nheqminer(MinerStopType willswitch)
        {
            if (IsRunning)
            {
                Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " Shutting down miner");
            }
            if (willswitch != MinerStopType.FORCE_END)
            {
                ChangeToNextAvaliablePort();
            }
            if (ProcessHandle != null)
            {
                try { ProcessHandle.Kill(); } catch { }
                ProcessHandle.Close();
                ProcessHandle = null;

                // sgminer needs to be removed and kill by PID
                if (DeviceType == DeviceType.AMD)
                {
                    KillAllUsedMinerProcesses();
                }
            }
        }
コード例 #8
0
        virtual protected NiceHashProcess _Start()
        {
            // never start when ended
            if (isEnded)
            {
                return(null);
            }

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

            NiceHashProcess P = new NiceHashProcess();

            if (WorkingDirectory.Length > 1)
            {
                P.StartInfo.WorkingDirectory = WorkingDirectory;
            }
            if (MinersSettingsManager.MinerSystemVariables.ContainsKey(Path))
            {
                foreach (var kvp in MinersSettingsManager.MinerSystemVariables[Path])
                {
                    string envName  = kvp.Key;
                    string 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 MinerPID_Data();
                    _currentPidData.minerBinPath = P.StartInfo.FileName;
                    _currentPidData.PID          = P.Id;
                    _allPidData.Add(_currentPidData);

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

                    StartCoolDownTimerChecker();

                    return(P);
                }
                else
                {
                    Helpers.ConsolePrint(MinerTAG(), "NOT STARTED " + ProcessTag() + " " + LastCommandLine);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " _Start: " + ex.Message);
                return(null);
            }
        }
コード例 #9
0
        virtual protected NiceHashProcess _Start()
        {
            // check if dagger already running
            if (AlgoNameIs("daggerhashimoto") && ethminerProcess != null)
            {
                Helpers.ConsolePrint(MinerDeviceName, "Resuming ethminer..");
                ethminerLink.StartMining();
                IsRunning = true;
                return(null);
            }

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

            NiceHashProcess P = new NiceHashProcess();

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

            NumRetries = Config.ConfigData.MinerAPIGraceSeconds / Config.ConfigData.MinerAPIQueryInterval;
            if (this is sgminer && !AlgoNameIs("daggerhashimoto"))
            {
                NumRetries = (Config.ConfigData.MinerAPIGraceSeconds + Config.ConfigData.MinerAPIGraceSecondsAMD) / Config.ConfigData.MinerAPIQueryInterval;
            }

            if (AlgoNameIs("daggerhashimoto"))
            {
                ethminerLink         = new ethminerAPI((this is sgminer) ? Config.ConfigData.ethminerAPIPortAMD : Config.ConfigData.ethminerAPIPortNvidia);
                P.StartInfo.FileName = Ethereum.EtherMinerPath;
                P.ExitEvent          = ethMiner_Exited;
            }
            else
            {
                P.StartInfo.FileName = Path;
                P.ExitEvent          = Miner_Exited;
            }

            P.StartInfo.Arguments       = LastCommandLine;
            P.StartInfo.CreateNoWindow  = Config.ConfigData.HideMiningWindows;
            P.StartInfo.UseShellExecute = false;

            Helpers.ConsolePrint(MinerDeviceName, "Starting miner (" + P.StartInfo.FileName + "): " + LastCommandLine);

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

                    if (AlgoNameIs("daggerhashimoto"))
                    {
                        ethminerProcess = P;
                        return(null);
                    }
                    return(P);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Helpers.ConsolePrint(MinerDeviceName, "_Start: " + ex.Message);
                return(null);
            }
        }