Exemplo n.º 1
0
        private void minerOutputReceived(MinerOutputMessage msg)
        {
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                if (MinerOutputString.Count > 100)
                {
                    MinerOutputString.RemoveAt(0);
                }

                MinerOutputString.Add(msg.OutputText);
                if (msg.IsError)
                {
                    if (msg.Exception != null)
                    {
                        Log.InsertError(msg.OutputText, msg.Exception);
                    }
                    else
                    {
                        Log.InsertError(msg.OutputText);
                    }
                }
                else
                {
                    if (SelectedMinerSettings == null || SelectedMinerSettings.IsLogging)
                    {
                        Log.InsertDebug(msg.OutputText);
                    }
                }
            });
        }
Exemplo n.º 2
0
        private void minerOutputReceived(MinerOutputMessage msg)
        {
            if (!string.IsNullOrEmpty(msg.OutputText))
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    if (msg.OutputText.Contains("use pool"))
                    {
                        var tmpUrl  = string.Empty;
                        var tmpPort = 0;

                        int startIndex = msg.OutputText.IndexOf("pool ") + 5;
                        tmpUrl         = msg.OutputText.Substring(startIndex);
                        tmpPort        = Convert.ToInt32(tmpUrl.Substring(tmpUrl.IndexOf(":") + 1, tmpUrl.IndexOf(" ") - tmpUrl.IndexOf(":")));
                        tmpUrl         = tmpUrl.Substring(0, tmpUrl.IndexOf(":"));

                        Messenger.Default.Send(new ActivePoolMessage()
                        {
                            IsActiveCPUPool = true, IsActiveGPUPool = false, URL = tmpUrl, Port = tmpPort
                        });
                    }

                    if (MinerOutputString.Count > 100)
                    {
                        MinerOutputString.RemoveAt(0);
                    }

                    MinerOutputString.Add(msg.OutputText.Replace('\r', ' '));
                    if (msg.IsError)
                    {
                        if (msg.Exception != null)
                        {
                            Log.InsertError(msg.OutputText, msg.Exception);
                        }
                        else
                        {
                            Log.InsertError(msg.OutputText);
                        }
                    }
                    else
                    {
                        if (SelectedMinerSettings == null || SelectedMinerSettings.IsLogging)
                        {
                            Log.InsertDebug(msg.OutputText);
                        }
                    }
                });
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// A miner program elindítása a megadott paraméterekkel.
        /// </summary>
        private void startMining(int window)
        {
            if (OpenCLDevices != null && !SelectedMinerSettings.ApplicationMode.Equals(ApplicationMode.Silent) &&
                !StartMiningButtonContent.Equals("Stop", StringComparison.InvariantCultureIgnoreCase))
            {
                GpuParameterHandler.WriteParameters(OpenCLDevices);
            }

            if (Devices.Count > 0)
            {
                Messenger.Default.Send <MinerOutputMessage>(new MinerOutputMessage()
                {
                    OutputText = "The following devices are initialized:"
                });

                foreach (var item in Devices)
                {
                    Messenger.Default.Send <MinerOutputMessage>(new MinerOutputMessage()
                    {
                        OutputText = $"{item.Name} [w: {item.WorkSize}, i: {item.Intensity}, t: {item.Threads}]", IsError = true
                    });
                }
            }

            if (SelectedMinerSettings.IsCPUMiningEnabled && Utils.CheckInstallation() != CheckDetails.Installed)
            {
                if (Utils.InstallMiners() != InstallDetail.Installed)
                {
                    MessageBoxResult mResult = MessageBox.Show(String.Format("Simple Miner is corrupted, may the antivirus application blocked it. \nIf you already add it as an exception in your antivirus application, please try to download the miner again.\nWould you like to navigate to Simple Miner download page?"), "Miner error", MessageBoxButton.YesNo, MessageBoxImage.Stop);
                    if (mResult == MessageBoxResult.No)
                    {
                        return;
                    }
                    else
                    {
                        Process.Start(Consts.MinerDownload);
                        return;
                    }
                }
            }

            //talán csökkenti a memória fragmentációt
            GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
            GC.Collect();
            if (IsIdle)
            {
                _minerProcesses.Clear();
                MinerOutputString.Clear();
                saveMinerSettings();

                if (OpenCLDevices != null && OpenCLDevices.Any(x => x.IsEnabled)) //videokártya indítása
                {
                    //if (IsAdministrator)
                    //{
                    //    var exeMinerManager = new ExeManager(Consts.ApplicationPath, Consts.ToolExeFileName);
                    //    exeMinerManager.ExecuteResource("disable \"*VEN_1002&DEV_6*\"");
                    //    Thread.Sleep(1000);
                    //    exeMinerManager.ExecuteResource("enable \"*VEN_1002&DEV_6*\"");
                    //}
                    ThreadPool.QueueUserWorkItem(delegate
                    {
                        var mp = new MinerProcess()
                        {
                            Algorithm = (int)SupportedAlgos.CryptoNight, Devices = OpenCLDevices, MinerType = MinerType.GPU, Settings = SelectedMinerSettings
                        };
                        if (mp.InitalizeMiner(Pools.Where(x => x.IsGPUPool && (x.IsMain || x.IsFailOver)).ToList()))
                        {
                            mp.StartMiner();
                            _minerProcesses.Add(mp);
                        }
                        else
                        {
                            return;
                        }
                    });
                }

                if (SelectedMinerSettings.IsCPUMiningEnabled) //proci indítása
                {
                    var mp = new MinerProcess()
                    {
                        Algorithm = (int)SupportedAlgos.CryptoNight, Devices = OpenCLDevices, MinerType = MinerType.CPU, Settings = SelectedMinerSettings
                    };

                    if (mp.InitalizeMiner(Pools.Where(x => x.IsCPUPool && (x.IsMain || x.IsFailOver)).ToList()))
                    {
                        mp.StartMiner();
                        _minerProcesses.Add(mp);
                    }
                    else
                    {
                        return;
                    }
                }

                IsIdle = false;
            }
            else
            {
                _minerProcesses.ForEach(x => x.StopMiner());
                IsIdle = true;

                if (!isCountDown)
                {
                    Messenger.Default.Send(new MinerOutputMessage()
                    {
                        OutputText = "Mining finished!"
                    });
                }
            }
            RaisePropertyChanged(nameof(IsIdle));
            RaisePropertyChanged(nameof(StartMiningButtonContent));
            RaisePropertyChanged(nameof(IsEnabledCPUThreadAuto));
        }