Example #1
0
        private static void Save()
        {
            try
            {
                var win = Application.Top.Subviews[0].Subviews[0].Subviews;

                GGMC.DebugLogs = true;

                GGMC.StratumServer = (win[1] as TextField).Text.ToString();
                GGMC.StratumPort   = int.Parse((win[3] as TextField).Text.ToString());
                GGMC.Login         = (win[5] as TextField).Text.ToString();
                GGMC.Password      = (win[7] as TextField).Text.ToString();

                int gid = 0;
                for (int g = 0; g < 6; g++)
                {
                    int  start   = g * 5 + 8;
                    bool enabled = (win[start + 1] as CheckBox).Checked;

                    if (enabled)
                    {
                        GPU gpu = new GPU()
                        {
                            GPUID    = gid++,
                            DeviceID = int.Parse((win[start + 4] as TextField).Text.ToString()),
                            Type     = (win[start + 2] as RadioGroup).Selected == 0 ? GPUtype.CUDA : GPUtype.AMDCL
                        };
                        GGMC.GPUs.Add(gpu);
                    }
                }

                File.WriteAllText(GGMCFile, SerializeObject(GGMC));

                Application.Top.Running = false;
            }
            catch (Exception ex)
            {
                MessageBox.ErrorQuery(50, 5, "Error", ex.Message, "Ok");
                Logger.Log(LogType.FatalError, "Error while saving config.", ex);
            }
        }
Example #2
0
        public TrimDriver(GPU gpu)
        {
            this.gpu      = gpu;
            StatusMessage = "Idle";

            ocl = Process.Start(new ProcessStartInfo()
            {
                FileName               = "OCLacka.exe",  // platform devID mode(0) port(13430)
                Arguments              = string.Format("{0} {1} {2} {3}", gpu.Type == GPUtype.CUDA ? "NVIDIA" : "AMD", gpu.DeviceID, 0, gpu.GPUID + 13430),
                CreateNoWindow         = true,
                RedirectStandardError  = true,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true,
                StandardErrorEncoding  = Encoding.ASCII,
                StandardOutputEncoding = Encoding.ASCII,
                UseShellExecute        = false
            });

            ocl.ErrorDataReceived  += (sender, e) => { LogError(e.Data, gpu); };
            ocl.OutputDataReceived += (sender, e) => { LogStd(e.Data, gpu); };
            ocl.BeginOutputReadLine();
            ocl.BeginErrorReadLine();

            Task.Delay(3000).Wait();

            if (ocl.HasExited)
            {
                Status        = TrimmerState.Error;
                StatusMessage = "Instacrash";
                return;
            }

            try
            {
                bridge   = new TcpClient("127.0.0.1", gpu.GPUID + 13430);
                stream   = bridge.GetStream();
                reader   = new StreamReader(stream);
                listener = Task.Factory.StartNew(() => { Listen(); });
            }
            catch
            {
                Status        = TrimmerState.Error;
                StatusMessage = "TCP Con Failed";
                return;
            }

            Task.Delay(1000).Wait();

            if (bridge != null && bridge.Connected)
            {
                if (Status == TrimmerState.Ready && !ocl.HasExited)
                {
                    Task.Factory.StartNew(() => { TrimmingLoop(); }, TaskCreationOptions.LongRunning);
                }
                else
                {
                    Status        = TrimmerState.Error;
                    StatusMessage = ocl.HasExited ?  "Trimmer Exit" : "Trimmer !Ready";
                }
            }
            else
            {
                Status        = TrimmerState.Error;
                StatusMessage = "TCP Con Discn";
            }
        }
Example #3
0
 private void LogError(string data, GPU gpu)
 {
     Console.WriteLine(data);
 }