protected PluginEntryVM(PluginPackageInfoCR plugin, LoadProgress load) { Plugin = plugin; Plugin.PropertyChanged += Plugin_PropertyChanged; // Filter the dict to remove empty entries FilteredSupportedAlgorithms = new Dictionary <string, List <string> >(); foreach (var kvp in Plugin.SupportedDevicesAlgorithms) { if (kvp.Value == null || kvp.Value.Count <= 0) { continue; } FilteredSupportedAlgorithms[kvp.Key] = kvp.Value; } Load = load; Load.PropertyChanged += Install_PropertyChanged; Progress = new Progress <Tuple <PluginInstallProgressState, int> >(status => { var(state, progress) = status; string statusText = GetStateProgressText(state, progress); Load.IsInstalling = state < PluginInstallProgressState.FailedDownloadingPlugin; Load.Report((statusText, progress)); }); MinerPluginsManager.InstallAddProgress(plugin.PluginUUID, Progress); }
private void Button_Click_Remove(object sender, RoutedEventArgs e) { _vm.IsUserActionRequired = false; AcceptedPlugins.Remove(_vm.PluginUUID); MinerPluginsManager.RemovePlugin(_vm.PluginUUID); OnAcceptOrDecline?.Invoke(sender, e); }
private void CheckBox_Use3rdPartyMiners_CheckedChanged(object sender, EventArgs e) { if (!_isInitFinished) { return; } if (checkBox_Use3rdPartyMiners.Checked) { // Show TOS Form tos = new Form_3rdParty_TOS(); tos.ShowDialog(this); checkBox_Use3rdPartyMiners.Checked = ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.YES; } else { ConfigManager.GeneralConfig.Use3rdPartyMiners = Use3rdPartyMiners.NO; } // update logic var is3rdPartyEnabled = ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.YES; checkBox_RunEthlargement.Enabled = Helpers.IsElevated && is3rdPartyEnabled; EthlargementIntegratedPlugin.Instance.ServiceEnabled = ConfigManager.GeneralConfig.UseEthlargement && Helpers.IsElevated && is3rdPartyEnabled; // re-init update plugins MinerPluginsManager.InitIntegratedPlugins(); }
private void Form_MinerPlugins_FormClosing(object sender, FormClosingEventArgs e) { foreach (var kvp in _pluginInfoDetailControls) { var pluginUUID = kvp.Key; var pluginControlPair = kvp.Value; MinerPluginsManager.InstallRemoveProgress(pluginUUID, pluginControlPair.Progress); } }
private async Task BenchmarkPluginAlgorithm(/*PluginAlgorithm algo*/) { var algo = (PluginAlgorithm)_currentAlgorithm; var plugin = MinerPluginsManager.GetPluginWithUuid(algo.BaseAlgo.MinerID); var miner = plugin.CreateMiner(); miner.InitMiningPairs(new List <(BaseDevice, CommonAlgorithm.Algorithm)> { (Device.PluginDevice, algo.BaseAlgo) });
protected PluginEntryVM(PluginPackageInfoCR plugin, LoadProgress load) { Plugin = plugin; // Filter the dict to remove empty entries FilteredSupportedAlgorithms = new Dictionary <string, List <string> >(); foreach (var kvp in Plugin.SupportedDevicesAlgorithms) { if (kvp.Value == null || kvp.Value.Count <= 0) { continue; } FilteredSupportedAlgorithms[kvp.Key] = kvp.Value; } Load = load; Load.PropertyChanged += Install_PropertyChanged; Progress = new Progress <Tuple <PluginInstallProgressState, int> >(status => { var(state, progress) = status; string statusText; switch (state) { case PluginInstallProgressState.Pending: statusText = Tr("Pending Install"); break; case PluginInstallProgressState.DownloadingMiner: statusText = Tr("Downloading Miner: {0} %", $"{progress:F2}"); break; case PluginInstallProgressState.DownloadingPlugin: statusText = Tr("Downloading Plugin: {0} %", $"{progress:F2}"); break; case PluginInstallProgressState.ExtractingMiner: statusText = Tr("Extracting Miner: {0} %", $"{progress:F2}"); break; case PluginInstallProgressState.ExtractingPlugin: statusText = Tr("Extracting Plugin: {0} %", $"{progress:F2}"); break; default: statusText = Tr("Pending Install"); break; } Load.IsInstalling = state < PluginInstallProgressState.FailedDownloadingPlugin; Load.Report((statusText, progress)); }); MinerPluginsManager.InstallAddProgress(plugin.PluginUUID, Progress); }
public async Task ConfirmInstallOrUpdatePlugin() { if (Load.IsInstalling) { return; } await MinerPluginsManager.DownloadAndInstall(Plugin.PluginUUID, Progress); CommonInstallOnPropertyChanged(); }
public async Task UninstallPlugin() { if (Load.IsInstalling) { return; } if (!Plugin.Installed) { return; } await MinerPluginsManager.RemovePlugin(Plugin.PluginUUID); CommonInstallOnPropertyChanged(); }
private static bool CheckPluginCanGroup(MiningPair a, MiningPair b) { var pluginA = (device : a.Device.PluginDevice, algorithm : ((PluginAlgorithm)a.Algorithm).BaseAlgo); var pluginB = (device : b.Device.PluginDevice, algorithm : ((PluginAlgorithm)b.Algorithm).BaseAlgo); if (pluginA.algorithm.MinerID != pluginB.algorithm.MinerID) { return(false); } var plugin = MinerPluginsManager.GetPluginWithUuid(pluginA.algorithm.MinerID); // TODO can plugin be null? var canGroup = plugin.CanGroup(pluginA, pluginB); return(canGroup); }
public async Task InstallOrUpdatePlugin() { if (Load.IsInstalling) { return; } if (Plugin.Installed && !Plugin.HasNewerVersion) { return; } //if (Plugin.HasNewerVersion) return; await MinerPluginsManager.DownloadAndInstall(Plugin.PluginUUID, Progress, CancellationToken.None); CommonInstallOnPropertyChanged(); }
public static bool ShouldGroup(MiningPair a, MiningPair b) { if (a.Algorithm.MinerID != b.Algorithm.MinerID) { return(false); } var plugin = MinerPluginsManager.GetPluginWithUuid(a.Algorithm.MinerID); if (plugin == null) { return(false); } var canGroup = plugin.CanGroup(a, b); return(canGroup); }
public static Miner CreateMinerForMining(List <MiningPair> miningPairs, string groupKey) { var pair = miningPairs.FirstOrDefault(); if (pair == null || pair.Algorithm == null) { return(null); } var algorithm = pair.Algorithm; var plugin = MinerPluginsManager.GetPluginWithUuid(algorithm.MinerID); if (plugin != null) { return(new Miner(plugin, miningPairs, groupKey)); } return(null); }
public async Task InstallRemovePlugin() { if (Load.IsInstalling) { return; } if (Plugin.Installed) { MinerPluginsManager.RemovePlugin(Plugin.PluginUUID); } else { await MinerPluginsManager.DownloadAndInstall(Plugin.PluginUUID, Progress); } OnPropertyChanged(nameof(InstallString)); }
private async Task BenchmarkPluginAlgorithm(PluginAlgorithm algo) { var plugin = MinerPluginsManager.GetPluginWithUuid(algo.BaseAlgo.MinerID); var miner = plugin.CreateMiner(); var miningPair = new MinerPlugin.MiningPair { Device = Device.BaseDevice, Algorithm = algo.BaseAlgo }; // check ethlargement var miningPairs = new List <MinerPlugin.MiningPair> { miningPair }; EthlargementIntegratedPlugin.Instance.Start(miningPairs); miner.InitMiningPairs(miningPairs); // fill service since the benchmark might be online. DemoUser.BTC must be used miner.InitMiningLocationAndUsername(StratumService.SelectedServiceLocation, DemoUser.BTC); _powerHelper.Start(); var result = await miner.StartBenchmark(_stopBenchmark.Token, _performanceType); //EthlargementIntegratedPlugin.Instance.Stop(miningPairs); // TODO check stopping var power = _powerHelper.Stop(); if (result.Success || result.AlgorithmTypeSpeeds?.Count > 0) { var ids = result.AlgorithmTypeSpeeds.Select(ats => ats.AlgorithmType).ToList(); var speeds = result.AlgorithmTypeSpeeds.Select(ats => ats.Speed).ToList(); algo.Speeds = speeds; algo.PowerUsage = power; // set status to empty string it will return speed algo.ClearBenchmarkPending(); BenchmarkManager.SetCurrentStatus(Device, algo, ""); } else { // add new failed list _benchmarkFailedAlgo.Add(algo.AlgorithmName); BenchmarkManager.SetCurrentStatus(Device, algo, result.ErrorMessage); } }
public static void UpdateFirewallRules() { try { var fileName = Paths.AppRootPath("FirewallRules.exe"); var startInfo = new ProcessStartInfo { FileName = fileName, //Arguments = $"{Directory.GetCurrentDirectory()} update miner_plugins", Arguments = $"{Paths.Root} update miner_plugins", Verb = "runas", UseShellExecute = true, CreateNoWindow = true }; startInfo.WindowStyle = ProcessWindowStyle.Hidden; // used for hidden window using (var setFirewallRulesProcess = new Process { StartInfo = startInfo }) { setFirewallRulesProcess.Start(); setFirewallRulesProcess?.WaitForExit(10 * 1000); if (setFirewallRulesProcess?.ExitCode != 0) { Logger.Info("NICEHASH", "setFirewallRulesProcess returned error code: " + setFirewallRulesProcess.ExitCode); } else { Logger.Info("NICEHASH", "setFirewallRulesProcess all OK"); var installedPlugins = MinerPluginsManager.GetPluginUUIDsAndVersionsList(); _pluginsUUIDsWithVersions = installedPlugins; InternalConfigs.WriteFileSettings(_firewallRulesAddedFilePath, _pluginsUUIDsWithVersions); } } } catch (Exception ex) { Logger.Error("NICEHASH", $"SetFirewallRules error: {ex.Message}"); } }
private async void OnButtonInstallRemoveClick(object sender, string pluginUUID) { if (_pluginInfoDetails.ContainsKey(pluginUUID) == false) { return; } var pluginInfoControlsPair = _pluginInfoDetails[pluginUUID]; var pluginPackageInfo = MinerPluginsManager.Plugins[pluginUUID]; try { // remove if installed if (pluginPackageInfo.Installed) { MinerPluginsManager.Remove(pluginUUID); //flowLayoutPanelPluginsLV.Controls.Remove(pluginInfoItem); var pluginInfoItem = pluginInfoControlsPair.Item; pluginInfoItem.StatusText = "Removed"; var pluginInfoDetails = pluginInfoControlsPair.Details; pluginInfoDetails.StatusText = ""; } else if (pluginPackageInfo.Installed == false) { await InstallOrUpdateAsync(pluginInfoControlsPair, pluginUUID); } } catch (Exception e) { } finally { setPluginInfoItem(pluginInfoControlsPair.Item, pluginPackageInfo); setPluginInfoDetails(pluginInfoControlsPair.Details, pluginPackageInfo); } }
private async Task InstallOrUpdateAsync(PluginControlPair pluginInfoControlsPair, string pluginUUID) { var pluginInfoItem = pluginInfoControlsPair.Item; var pluginInfoDetails = pluginInfoControlsPair.Details; // update var cancelInstall = new CancellationTokenSource(); var pluginPackageInfo = MinerPluginsManager.Plugins[pluginUUID]; try { AddActiveTask(pluginUUID); pluginInfoItem.OnButtonCancel = (s, e) => cancelInstall.Cancel(); pluginInfoItem.SwapInstallRemoveButtonWithCancelButton(true); pluginInfoItem.ProgressBarVisible = true; pluginInfoItem.StatusVisible = true; //pluginInfoItem.ButtonUpdateEnabled = false; pluginInfoDetails.OnButtonCancel = (s, e) => cancelInstall.Cancel(); pluginInfoDetails.SwapInstallRemoveButtonWithCancelButton(true); pluginInfoDetails.ProgressBarVisible = true; pluginInfoDetails.StatusVisible = true; pluginInfoItem.StatusText = "Pending Install"; pluginInfoDetails.StatusText = "Pending Install"; var downloadAndInstallUpdate = new Progress <Tuple <ProgressState, int> >(statePerc => { var state = statePerc.Item1; var progress = statePerc.Item2; var statusText = ""; switch (state) { case ProgressState.DownloadingMiner: statusText = $"Downloading Miner: {progress} %"; break; case ProgressState.DownloadingPlugin: statusText = $"Downloading Plugin: {progress} %"; break; case ProgressState.ExtractingMiner: statusText = $"Extracting Miner: {progress} %"; break; case ProgressState.ExtractingPlugin: statusText = $"Extracting Plugin: {progress} %"; break; } // SafeInvoke is not needed inside a Progress //FormHelpers.SafeInvoke(pluginInfoItem, () => { pluginInfoItem.StatusText = statusText; pluginInfoItem.ProgressBarValue = progress; //}); //FormHelpers.SafeInvoke(pluginInfoDetails, () => { pluginInfoDetails.StatusText = statusText; pluginInfoDetails.ProgressBarValue = progress; //}); }); await MinerPluginsManager.DownloadAndInstall(pluginPackageInfo, downloadAndInstallUpdate, cancelInstall.Token); } catch (Exception e) { } finally { pluginInfoItem.ProgressBarVisible = false; pluginInfoDetails.ProgressBarVisible = false; pluginInfoItem.SwapInstallRemoveButtonWithCancelButton(false); pluginInfoDetails.SwapInstallRemoveButtonWithCancelButton(false); setPluginInfoItem(pluginInfoItem, pluginPackageInfo); setPluginInfoDetails(pluginInfoDetails, pluginPackageInfo); RemoveActiveTask(pluginUUID); } }
private void FormShown(object sender, EventArgs e) { // TODO blocking make it async MinerPluginsManager.CrossReferenceInstalledWithOnline(); var rankedUUIDs = MinerPluginsManager.RankedPlugins.Select(plugin => plugin.PluginUUID).ToList(); // update existing that are not in a task var ignoreActive = GetActiveTasks(); foreach (var controlsPair in _pluginInfoDetails.Values) { var uuid = controlsPair.Item.PluginUUID; if (ignoreActive.Contains(uuid)) { continue; } var plugin = MinerPluginsManager.Plugins[uuid]; setPluginInfoItem(controlsPair.Item, plugin); setPluginInfoDetails(controlsPair.Details, plugin); } var newPlugins = MinerPluginsManager.RankedPlugins.Where(plugin => _pluginInfoDetails.ContainsKey(plugin.PluginUUID) == false).ToList(); var lastSingleItemRow = rankedUUIDs.Count % 2 == 1; // create and add new plugins foreach (var plugin in newPlugins) { var controlsPair = new PluginControlPair { Item = new PluginInfoItem(), Details = CreatePluginInfoDetails() }; // add control pairs _pluginInfoDetails.Add(plugin.PluginUUID, controlsPair); Controls.Add(controlsPair.Details); setPluginInfoItem(controlsPair.Item, plugin); setPluginInfoDetails(controlsPair.Details, plugin); } // get row count var rowsNeeded = rankedUUIDs.Count / 2 + rankedUUIDs.Count % 2; var rowsAdded = flowLayoutPanelPluginsLV.Controls.Count; // we have new rows if (rowsAdded < rowsNeeded) { for (int add = 0; add < rowsNeeded - rowsAdded; add++) { var pluginRowItem = new PluginInfoItemRow(); flowLayoutPanelPluginsLV.Controls.Add(pluginRowItem); } } // we have too many else if (rowsAdded > rowsNeeded) { var toRemoveCount = rowsAdded - rowsNeeded; for (int remove = 0; remove < toRemoveCount; remove++) { var lastIndex = flowLayoutPanelPluginsLV.Controls.Count - 1; var lastRow = flowLayoutPanelPluginsLV.Controls[lastIndex] as PluginInfoItemRow; if (lastRow != null) { lastRow.RemovePluginInfoItem1(); lastRow.RemovePluginInfoItem2(); } flowLayoutPanelPluginsLV.Controls.RemoveAt(lastIndex); } } for (int item = 0; item < rankedUUIDs.Count; item++) { var uuid = rankedUUIDs[item]; var rowIndex = (item / 2); var isFirst = (item % 2) == 0; var controlsPair = _pluginInfoDetails[uuid]; var row = flowLayoutPanelPluginsLV.Controls[rowIndex] as PluginInfoItemRow; if (row == null) { continue; } if (isFirst) { row.SetPluginInfoItem1(controlsPair.Item); } else { row.SetPluginInfoItem2(controlsPair.Item); } } if (lastSingleItemRow) { var lastIndex = flowLayoutPanelPluginsLV.Controls.Count - 1; var lastRow = flowLayoutPanelPluginsLV.Controls[lastIndex] as PluginInfoItemRow; if (lastRow != null) { lastRow.RemovePluginInfoItem2(); } } }
public MinerFromPlugin(string pluginUUID) : base(pluginUUID) { var plugin = MinerPluginsManager.GetPluginWithUuid(pluginUUID); _miner = plugin.CreateMiner(); }
public static bool IsFirewallRulesOutdated() { var installedPlugins = MinerPluginsManager.GetPluginUUIDsAndVersionsList(); return(installedPlugins.Except(_pluginsUUIDsWithVersions).Count() > 0); }
private IProgress <Tuple <PluginInstallProgressState, int> > CreateProgressForPluginControlPair(PluginControlPair pluginInfoControlsPair) { var pluginInfoItem = pluginInfoControlsPair.Item; var pluginInfoDetails = pluginInfoControlsPair.Details; var downloadAndInstallUpdate = new Progress <Tuple <PluginInstallProgressState, int> >(statePerc => { var state = statePerc.Item1; var progress = statePerc.Item2; var statusText = ""; switch (state) { case PluginInstallProgressState.Pending: statusText = Tr("Pending Install"); break; case PluginInstallProgressState.DownloadingMiner: statusText = Tr("Downloading Miner: {0} %", $"{progress:F2}"); break; case PluginInstallProgressState.DownloadingPlugin: statusText = Tr("Downloading Plugin: {0} %", $"{progress:F2}"); break; case PluginInstallProgressState.ExtractingMiner: statusText = Tr("Extracting Miner: {0} %", $"{progress:F2}"); break; case PluginInstallProgressState.ExtractingPlugin: statusText = Tr("Extracting Plugin: {0} %", $"{progress:F2}"); break; default: statusText = Tr("Pending Install"); break; } pluginInfoItem.StatusText = statusText; pluginInfoItem.ProgressBarValue = progress; pluginInfoDetails.StatusText = statusText; pluginInfoDetails.ProgressBarValue = progress; var installing = state < PluginInstallProgressState.FailedDownloadingPlugin; pluginInfoItem.SwapInstallRemoveButtonWithCancelButton(installing); pluginInfoItem.ProgressBarVisible = installing; pluginInfoItem.StatusVisible = installing; pluginInfoDetails.SwapInstallRemoveButtonWithCancelButton(installing); pluginInfoDetails.ProgressBarVisible = installing; pluginInfoDetails.StatusVisible = installing; if (state == PluginInstallProgressState.Success) { var pluginPackageInfo = MinerPluginsManager.GetPluginPackageInfoCR(pluginInfoItem.PluginUUID); setPluginInfoItem(pluginInfoItem, pluginPackageInfo); setPluginInfoDetails(pluginInfoDetails, pluginPackageInfo); } }); return(downloadAndInstallUpdate); }
private async Task InstallOrUpdateAsync(PluginControlPair pluginInfoControlsPair, string pluginUUID) { await MinerPluginsManager.DownloadAndInstall(pluginUUID, pluginInfoControlsPair.Progress); }
private static void InitNhmlDevsPlugins() { //await ComputeDeviceManager.QueryDevicesAsync(null, false); MinerPluginsManager.LoadMinerPlugins(); }
public MinerFromPlugin(string pluginUUID, List <MiningPair> miningPairs, string groupKey) : base(pluginUUID, miningPairs, groupKey) { _plugin = MinerPluginsManager.GetPluginWithUuid(pluginUUID); _miner = _plugin.CreateMiner(); }
protected override void Dispose(bool disposing) { MinerPluginsManager.InstallRemoveProgress(Plugin.PluginUUID, Progress); }