예제 #1
0
        private Process StartMinerProcess(string arguments, bool redirectOutput,
                                          bool ensureProcessStarts = false, string reason = "")
        {
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName       = minerConfiguration.ExecutablePath;
            startInfo.WindowStyle    = ProcessWindowStyle.Hidden;
            startInfo.CreateNoWindow = true;

            startInfo.Arguments = arguments;
            if (minerConfiguration.DisableGpu)
            {
                startInfo.Arguments = startInfo.Arguments + " --disable-gpu";

                if (minerConfiguration.MinerBackend == MinerBackend.Cgminer)
                {
                    //otherwise it still requires OpenCL.dll - not an issue with bfgminer
                    if (OSVersionPlatform.GetConcretePlatform() == PlatformID.Unix)
                    {
                        startInfo.FileName = startInfo.FileName + "-nogpu";
                    }
                    else
                    {
                        startInfo.FileName = minerConfiguration.ExecutablePath.Replace("cgminer.exe", "cgminer-nogpu.exe");
                    }
                }
            }

            startInfo.UseShellExecute        = false;
            startInfo.RedirectStandardOutput = redirectOutput;

            if (LogLaunch != null)
            {
                LogLaunchArgs args = new LogLaunchArgs();

                args.DateTime       = DateTime.Now;
                args.ExecutablePath = startInfo.FileName;
                args.Arguments      = startInfo.Arguments;
                args.Reason         = reason;
                args.CoinName       = minerConfiguration.CoinName;

                LogLaunch(this, args);
            }

            Process process = StartProcessAndCheckResponse(startInfo);

            if (ensureProcessStarts)
            {
                //store the returned process
                process = EnsureProcessStarts(process, startInfo);
            }

            if (!process.HasExited)
            {
                process.PriorityClass = minerConfiguration.Priority;
            }

            return(process);
        }
예제 #2
0
        private Process StartMinerProcess(string arguments, bool redirectOutput,
                                          bool ensureProcessStarts = false, string reason = "", bool startProcess = true)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName         = minerConfiguration.ExecutablePath;
            startInfo.WorkingDirectory = Path.GetDirectoryName(startInfo.FileName); //so miners can find kernels
            startInfo.WindowStyle      = ProcessWindowStyle.Hidden;
            startInfo.CreateNoWindow   = true;

            startInfo.Arguments = arguments.Trim();

            if (minerConfiguration.DisableGpu)
            {
                startInfo.Arguments = String.Format("{0} {1}", startInfo.Arguments, MinerParameter.ScanSerialOpenCLNoAuto);
            }

            startInfo.UseShellExecute        = false;
            startInfo.RedirectStandardOutput = redirectOutput;

            if (LogLaunch != null)
            {
                LogLaunchArgs args = new LogLaunchArgs();

                args.DateTime       = DateTime.Now;
                args.ExecutablePath = startInfo.FileName;
                args.Arguments      = startInfo.Arguments;
                args.Reason         = reason;
                args.CoinName       = minerConfiguration.CoinName;

                LogLaunch(this, args);
            }

            //requiest UTF-8 encoding so that characters from bfgminer are read
            startInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;

            Process process = StartProcessAndCheckResponse(startInfo, startProcess);

            if (startProcess)
            {
                if (ensureProcessStarts)
                {
                    //store the returned process
                    process = EnsureProcessStarts(process, startInfo);
                }

                if (!process.HasExited)
                {
                    process.PriorityClass = minerConfiguration.Priority;
                }
            }

            return(process);
        }
예제 #3
0
        private Process StartMinerProcess(string arguments, bool redirectOutput, 
            bool ensureProcessStarts = false, string reason = "", bool startProcess = true)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo();
            
            startInfo.FileName = minerConfiguration.ExecutablePath;
            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            startInfo.CreateNoWindow = true;

            startInfo.Arguments = arguments.Trim();
            if (minerConfiguration.DisableGpu)
            {
                startInfo.Arguments = String.Format("{0} {1}", startInfo.Arguments, MinerParameter.ScanSerialOpenCLNoAuto);
            }

            startInfo.UseShellExecute = false;
            startInfo.RedirectStandardOutput = redirectOutput;

            if (LogLaunch != null)
            {
                LogLaunchArgs args = new LogLaunchArgs();

                args.DateTime = DateTime.Now;
                args.ExecutablePath = startInfo.FileName;
                args.Arguments = startInfo.Arguments;
                args.Reason = reason;
                args.CoinName = minerConfiguration.CoinName;

                LogLaunch(this, args);
            }

            //requiest UTF-8 encoding so that characters from bfgminer are read 
            startInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
            
            Process process = StartProcessAndCheckResponse(startInfo, startProcess);
            
            if (startProcess)
            {
                if (ensureProcessStarts)
                    //store the returned process
                    process = EnsureProcessStarts(process, startInfo);
                
                if (!process.HasExited)
                    process.PriorityClass = minerConfiguration.Priority;
            }

            return process;
        }
예제 #4
0
파일: Miner.cs 프로젝트: nwfella/MultiMiner
        private Process StartMinerProcess(string arguments, bool redirectOutput, 
            bool ensureProcessStarts = false, string reason = "", bool startProcess = true)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName = minerConfiguration.ExecutablePath;
            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            startInfo.CreateNoWindow = true;

            startInfo.Arguments = arguments.Trim();
            if (minerConfiguration.DisableGpu)
            {
                startInfo.Arguments = startInfo.Arguments + " --disable-gpu";

                if (minerConfiguration.MinerBackend == MinerBackend.Cgminer)
                {
                    //otherwise it still requires OpenCL.dll - not an issue with bfgminer
                    if (OSVersionPlatform.GetConcretePlatform() == PlatformID.Unix)
                        startInfo.FileName = startInfo.FileName + "-nogpu";
                    else
                        startInfo.FileName = minerConfiguration.ExecutablePath.Replace("cgminer.exe", "cgminer-nogpu.exe");
                }
            }

            startInfo.UseShellExecute = false;
            startInfo.RedirectStandardOutput = redirectOutput;

            if (LogLaunch != null)
            {
                LogLaunchArgs args = new LogLaunchArgs();

                args.DateTime = DateTime.Now;
                args.ExecutablePath = startInfo.FileName;
                args.Arguments = startInfo.Arguments;
                args.Reason = reason;
                args.CoinName = minerConfiguration.CoinName;

                LogLaunch(this, args);
            }

            Process process = StartProcessAndCheckResponse(startInfo, startProcess);

            if (startProcess)
            {
                if (ensureProcessStarts)
                    //store the returned process
                    process = EnsureProcessStarts(process, startInfo);

                if (!process.HasExited)
                    process.PriorityClass = minerConfiguration.Priority;
            }

            return process;
        }
예제 #5
0
 private void LogProcessLaunchToFile(LogLaunchArgs ea)
 {
     const string logFileName = "ProcessLog.json";
     LogObjectToFile(ea, logFileName);
 }
예제 #6
0
        private void LogProcessLaunch(object sender, LogLaunchArgs ea)
        {
            logLaunchArgsBindingSource.Position = logLaunchArgsBindingSource.Add(ea);

            while (logLaunchArgsBindingSource.Count > 1000)
                logLaunchArgsBindingSource.RemoveAt(0);

            LogProcessLaunchToFile(ea);
        }
예제 #7
0
        private void LogProcessLaunch(object sender, LogLaunchArgs ea)
        {
            //remove then add so BindingList position is on latest entry
            while (LogLaunchEntries.Count > MaxLogEntriesOnScreen)
                LogLaunchEntries.RemoveAt(0);
            LogLaunchEntries.Add(ea);

            LogProcessLaunchToFile(ea);
        }
예제 #8
0
        private static void LaunchLoggedMiner(LogLaunchArgs args)
        {
            string arguments = args.Arguments;
            arguments = arguments.Replace("-T -q", String.Empty).Trim();

            ProcessStartInfo startInfo = new ProcessStartInfo(args.ExecutablePath, arguments)
            {
                WorkingDirectory = Path.GetDirectoryName(args.ExecutablePath)
            };
            Process.Start(startInfo);
        }