//each device needs to have a DeviceConfiguration //this will add any missing ones after populating devices //for instance if the user starts up the app with a new device private void AddMissingDeviceConfigurations() { bool hasBtcConfigured = engineConfiguration.CoinConfigurations.Exists(c => c.Enabled && c.CryptoCoin.Symbol.Equals(KnownCoins.BitcoinSymbol, StringComparison.OrdinalIgnoreCase)); bool hasLtcConfigured = engineConfiguration.CoinConfigurations.Exists(c => c.Enabled && c.CryptoCoin.Symbol.Equals(KnownCoins.LitecoinSymbol, StringComparison.OrdinalIgnoreCase)); foreach (Xgminer.Data.Device device in devices) { Engine.Data.Configuration.Device existingConfiguration = engineConfiguration.DeviceConfigurations.FirstOrDefault( c => (c.Equals(device))); if (existingConfiguration == null) { Engine.Data.Configuration.Device newConfiguration = new Engine.Data.Configuration.Device(); newConfiguration.Assign(device); if (device.SupportsAlgorithm(CoinAlgorithm.Scrypt) && hasLtcConfigured) newConfiguration.CoinSymbol = KnownCoins.LitecoinSymbol; else if (device.SupportsAlgorithm(CoinAlgorithm.SHA256) && hasBtcConfigured) newConfiguration.CoinSymbol = KnownCoins.BitcoinSymbol; newConfiguration.Enabled = true; engineConfiguration.DeviceConfigurations.Add(newConfiguration); } } }
private void SaveViewModelValuesToConfiguration() { engineConfiguration.DeviceConfigurations.Clear(); foreach (Xgminer.Data.Device device in devices) { //don't assume 1-to-1 of Devices and ViewModel.Devices //Devices doesn't include Network Devices DeviceViewModel viewModel = localViewModel.Devices.Single(vm => vm.Equals(device)); //pull this from coin configurations, not known coins, may not be in CoinChoose CryptoCoin coin = viewModel.Coin; Engine.Data.Configuration.Device deviceConfiguration = new Engine.Data.Configuration.Device(); deviceConfiguration.Assign(viewModel); deviceConfiguration.Enabled = viewModel.Enabled; deviceConfiguration.CoinSymbol = coin == null ? string.Empty : coin.Symbol; engineConfiguration.DeviceConfigurations.Add(deviceConfiguration); } }
private void SetAllDevicesToCoinLocally(string coinSymbol, bool disableStrategies) { bool wasMining = miningEngine.Mining; StopMiningLocally(); Engine.Data.Configuration.Coin coinConfiguration = engineConfiguration.CoinConfigurations.SingleOrDefault(c => c.CryptoCoin.Symbol.Equals(coinSymbol)); engineConfiguration.DeviceConfigurations.Clear(); foreach (Xgminer.Data.Device device in devices) { //don't assume 1-to-1 of Devices and ViewModel.Devices //Devices doesn't include Network Devices DeviceViewModel viewModel = localViewModel.Devices.Single(vm => vm.Equals(device)); Engine.Data.Configuration.Device deviceConfiguration = new Engine.Data.Configuration.Device(); deviceConfiguration.Assign(viewModel); if (viewModel.Kind == DeviceKind.NET) { //assume BTC for Network Devices (for now) deviceConfiguration.CoinSymbol = KnownCoins.BitcoinSymbol; deviceConfiguration.Enabled = true; } else if (viewModel.Kind == DeviceKind.PXY) { if (viewModel.SupportsAlgorithm(coinConfiguration.CryptoCoin.Algorithm) && //don't change the Algo a Proxy is mining - don't know what is pointed at it (viewModel.Coin.Algorithm == coinConfiguration.CryptoCoin.Algorithm)) deviceConfiguration.CoinSymbol = coinConfiguration.CryptoCoin.Symbol; else deviceConfiguration.CoinSymbol = viewModel.Coin == null ? String.Empty : viewModel.Coin.Name; deviceConfiguration.Enabled = viewModel.Enabled; } else { if (viewModel.SupportsAlgorithm(coinConfiguration.CryptoCoin.Algorithm)) deviceConfiguration.CoinSymbol = coinConfiguration.CryptoCoin.Symbol; else deviceConfiguration.CoinSymbol = viewModel.Coin == null ? String.Empty : viewModel.Coin.Name; deviceConfiguration.Enabled = viewModel.Enabled; } engineConfiguration.DeviceConfigurations.Add(deviceConfiguration); } localViewModel.ApplyDeviceConfigurationModels(engineConfiguration.DeviceConfigurations, engineConfiguration.CoinConfigurations); engineConfiguration.SaveDeviceConfigurations(); RefreshListViewFromViewModel(); AutoSizeListViewColumns(); if (wasMining) { bool wasAutoMining = engineConfiguration.StrategyConfiguration.AutomaticallyMineCoins; if (wasAutoMining) EnableMiningStrategies(false); StartMiningLocally(); //only re-enable if they were enabled before if (!disableStrategies && wasAutoMining) EnableMiningStrategies(true); } else { if (disableStrategies) EnableMiningStrategies(false); //so the Start button becomes enabled if we now have a valid config UpdateMiningButtons(); } RefreshStrategiesCountdown(); }
private List <Engine.Data.Configuration.Device> CreateDeviceConfigurationForProfitableCoins(List <CoinInformation> allProfitableCoins, List <CoinInformation> sha256ProfitableCoins, List <CoinInformation> scryptProfitableCoins) { List <Engine.Data.Configuration.Device> newConfiguration = new List <Engine.Data.Configuration.Device>(); CoinInformation profitableCoin = null; int comboAlgoIterator = 0; int sha256Iterator = 0; int scryptIterator = 0; for (int i = 0; i < devices.Count; i++) { Xgminer.Data.Device device = devices[i]; //there should be a 1-to-1 relationship of devices and device configurations Engine.Data.Configuration.Device existingConfiguration = engineConfiguration.DeviceConfigurations[i]; if (existingConfiguration.Enabled) { profitableCoin = null; if (device.Kind == DeviceKind.PXY) { Data.Configuration.Coin existingCoinConfig = engineConfiguration.CoinConfigurations.Single(cc => cc.CryptoCoin.Symbol.Equals(existingConfiguration.CoinSymbol, StringComparison.OrdinalIgnoreCase)); //keep Proxies on the same algo - don't know what is pointed at them if (existingCoinConfig.CryptoCoin.Algorithm == CoinAlgorithm.Scrypt) { profitableCoin = ChooseCoinFromList(scryptProfitableCoins, scryptIterator); scryptIterator++; } else { profitableCoin = ChooseCoinFromList(sha256ProfitableCoins, sha256Iterator); sha256Iterator++; } } else if (device.SupportsAlgorithm(CoinAlgorithm.Scrypt) && !device.SupportsAlgorithm(CoinAlgorithm.SHA256)) { //scrypt only profitableCoin = ChooseCoinFromList(scryptProfitableCoins, scryptIterator); scryptIterator++; } else if (device.SupportsAlgorithm(CoinAlgorithm.Scrypt) && device.SupportsAlgorithm(CoinAlgorithm.SHA256)) { //sha256 or scrypt profitableCoin = ChooseCoinFromList(allProfitableCoins, comboAlgoIterator); comboAlgoIterator++; } else if (sha256ProfitableCoins.Count > 0) { //sha256 only profitableCoin = ChooseCoinFromList(sha256ProfitableCoins, sha256Iterator); sha256Iterator++; } if (comboAlgoIterator >= allProfitableCoins.Count()) { comboAlgoIterator = 0; } if (sha256Iterator >= sha256ProfitableCoins.Count()) { sha256Iterator = 0; } if (scryptIterator >= scryptProfitableCoins.Count()) { scryptIterator = 0; } Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device(); configEntry.Assign(device); configEntry.CoinSymbol = profitableCoin == null ? string.Empty : profitableCoin.Symbol; newConfiguration.Add(configEntry); } else { Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device(); configEntry.Assign(device); configEntry.CoinSymbol = existingConfiguration.CoinSymbol; configEntry.Enabled = false; newConfiguration.Add(configEntry); } } return(newConfiguration); }
private void ConfigureDevicesForNewUser() { Engine.Data.Configuration.Coin coinConfiguration = engineConfiguration.CoinConfigurations.Single(); for (int i = 0; i < devices.Count; i++) { Engine.Data.Configuration.Device deviceConfiguration = new Engine.Data.Configuration.Device() { CoinSymbol = coinConfiguration.CryptoCoin.Symbol, Enabled = true }; deviceConfiguration.Assign(devices[i]); engineConfiguration.DeviceConfigurations.Add(deviceConfiguration); } engineConfiguration.SaveDeviceConfigurations(); UpdateMiningButtons(); }
private List <Engine.Data.Configuration.Device> CreateDeviceConfigurationForProfitableCoins(List <CoinInformation> allProfitableCoins, List <CoinInformation> sha256ProfitableCoins) { List <Engine.Data.Configuration.Device> newConfiguration = new List <Engine.Data.Configuration.Device>(); CoinInformation profitableCoin = null; int gpuIterator = 0; int amuIterator = 0; for (int i = 0; i < devices.Count; i++) { Xgminer.Data.Device device = devices[i]; //there should be a 1-to-1 relationship of devices and device configurations Engine.Data.Configuration.Device existingConfiguration = engineConfiguration.DeviceConfigurations[i]; if (existingConfiguration.Enabled) { profitableCoin = null; if (device.Kind == DeviceKind.GPU) { //sha256 or scrypt profitableCoin = ChooseCoinFromList(allProfitableCoins, gpuIterator); gpuIterator++; if (gpuIterator >= allProfitableCoins.Count()) { gpuIterator = 0; } } else if (sha256ProfitableCoins.Count > 0) { //sha256 only profitableCoin = ChooseCoinFromList(sha256ProfitableCoins, amuIterator); amuIterator++; if (amuIterator >= sha256ProfitableCoins.Count()) { amuIterator = 0; } } Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device(); configEntry.Assign(device); configEntry.CoinSymbol = profitableCoin == null ? string.Empty : profitableCoin.Symbol; newConfiguration.Add(configEntry); } else { Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device(); configEntry.Assign(device); configEntry.CoinSymbol = existingConfiguration.CoinSymbol; configEntry.Enabled = false; newConfiguration.Add(configEntry); } } return(newConfiguration); }
private List<Engine.Data.Configuration.Device> CreateDeviceConfigurationForProfitableCoins(List<CoinInformation> allProfitableCoins, List<CoinInformation> sha256ProfitableCoins) { List<Engine.Data.Configuration.Device> newConfiguration = new List<Engine.Data.Configuration.Device>(); CoinInformation profitableCoin = null; int gpuIterator = 0; int amuIterator = 0; for (int i = 0; i < devices.Count; i++) { Xgminer.Data.Device device = devices[i]; //there should be a 1-to-1 relationship of devices and device configurations Engine.Data.Configuration.Device existingConfiguration = engineConfiguration.DeviceConfigurations[i]; if (existingConfiguration.Enabled) { profitableCoin = null; if (device.Kind == DeviceKind.GPU) { //sha256 or scrypt profitableCoin = ChooseCoinFromList(allProfitableCoins, gpuIterator); gpuIterator++; if (gpuIterator >= allProfitableCoins.Count()) gpuIterator = 0; } else if (sha256ProfitableCoins.Count > 0) { //sha256 only profitableCoin = ChooseCoinFromList(sha256ProfitableCoins, amuIterator); amuIterator++; if (amuIterator >= sha256ProfitableCoins.Count()) amuIterator = 0; } Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device(); configEntry.Assign(device); configEntry.CoinSymbol = profitableCoin == null ? string.Empty : profitableCoin.Symbol; newConfiguration.Add(configEntry); } else { Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device(); configEntry.Assign(device); configEntry.CoinSymbol = existingConfiguration.CoinSymbol; configEntry.Enabled = false; newConfiguration.Add(configEntry); } } return newConfiguration; }
private void SetAllDevicesToCoinLocally(string coinSymbol) { bool wasMining = miningEngine.Mining; StopMiningLocally(); Engine.Data.Configuration.Coin coinConfiguration = engineConfiguration.CoinConfigurations.SingleOrDefault(c => c.CryptoCoin.Symbol.Equals(coinSymbol)); engineConfiguration.DeviceConfigurations.Clear(); foreach (Xgminer.Data.Device device in devices) { //don't assume 1-to-1 of Devices and ViewModel.Devices //Devices doesn't include Network Devices DeviceViewModel viewModel = localViewModel.Devices.Single(vm => vm.Equals(device)); Engine.Data.Configuration.Device deviceConfiguration = new Engine.Data.Configuration.Device(); deviceConfiguration.Assign(viewModel); if (viewModel.Kind == DeviceKind.NET) { //assume BTC for Network Devices (for now) deviceConfiguration.CoinSymbol = NetworkDeviceCoinSymbol; deviceConfiguration.Enabled = true; } else { if (viewModel.SupportsAlgorithm(coinConfiguration.CryptoCoin.Algorithm)) deviceConfiguration.CoinSymbol = coinConfiguration.CryptoCoin.Symbol; else deviceConfiguration.CoinSymbol = viewModel.Coin == null ? String.Empty : viewModel.Coin.Name; deviceConfiguration.Enabled = viewModel.Enabled; } engineConfiguration.DeviceConfigurations.Add(deviceConfiguration); } localViewModel.ApplyDeviceConfigurationModels(engineConfiguration.DeviceConfigurations, engineConfiguration.CoinConfigurations); engineConfiguration.StrategyConfiguration.AutomaticallyMineCoins = false; engineConfiguration.SaveDeviceConfigurations(); engineConfiguration.SaveStrategyConfiguration(); RefreshListViewFromViewModel(); AutoSizeListViewColumns(); if (wasMining) StartMiningLocally(); else //so the Start button becomes enabled if we now have a valid config UpdateMiningButtons(); }
private List<Engine.Data.Configuration.Device> CreateDeviceConfigurationForProfitableCoins(List<CoinInformation> allProfitableCoins, List<CoinInformation> sha256ProfitableCoins, List<CoinInformation> scryptProfitableCoins) { List<Engine.Data.Configuration.Device> newConfiguration = new List<Engine.Data.Configuration.Device>(); CoinInformation profitableCoin = null; int comboAlgoIterator = 0; int sha256Iterator = 0; int scryptIterator = 0; for (int i = 0; i < devices.Count; i++) { Xgminer.Data.Device device = devices[i]; //there should be a 1-to-1 relationship of devices and device configurations Engine.Data.Configuration.Device existingConfiguration = engineConfiguration.DeviceConfigurations[i]; if (existingConfiguration.Enabled) { profitableCoin = null; if (device.SupportsAlgorithm(CoinAlgorithm.Scrypt) && !device.SupportsAlgorithm(CoinAlgorithm.SHA256)) { //scrypt only profitableCoin = ChooseCoinFromList(scryptProfitableCoins, scryptIterator); scryptIterator++; if (scryptIterator >= scryptProfitableCoins.Count()) scryptIterator = 0; } else if (device.SupportsAlgorithm(CoinAlgorithm.Scrypt) && device.SupportsAlgorithm(CoinAlgorithm.SHA256)) { //sha256 or scrypt profitableCoin = ChooseCoinFromList(allProfitableCoins, comboAlgoIterator); comboAlgoIterator++; if (comboAlgoIterator >= allProfitableCoins.Count()) comboAlgoIterator = 0; } else if (sha256ProfitableCoins.Count > 0) { //sha256 only profitableCoin = ChooseCoinFromList(sha256ProfitableCoins, sha256Iterator); sha256Iterator++; if (sha256Iterator >= sha256ProfitableCoins.Count()) sha256Iterator = 0; } Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device(); configEntry.Assign(device); configEntry.CoinSymbol = profitableCoin == null ? string.Empty : profitableCoin.Symbol; newConfiguration.Add(configEntry); } else { Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device(); configEntry.Assign(device); configEntry.CoinSymbol = existingConfiguration.CoinSymbol; configEntry.Enabled = false; newConfiguration.Add(configEntry); } } return newConfiguration; }
//each device needs to have a DeviceConfiguration //this will add any missing ones after populating devices //for instance if the user starts up the app with a new device private void AddMissingDeviceConfigurations() { const string btcSymbol = KnownCoins.BitcoinSymbol; bool hasBtcConfigured = engineConfiguration.CoinConfigurations.Exists(c => c.Enabled && c.CryptoCoin.Symbol.Equals(btcSymbol, StringComparison.OrdinalIgnoreCase)); foreach (Xgminer.Data.Device device in devices) { Engine.Data.Configuration.Device existingConfiguration = engineConfiguration.DeviceConfigurations.FirstOrDefault( c => (c.Equals(device))); if (existingConfiguration == null) { Engine.Data.Configuration.Device newConfiguration = new Engine.Data.Configuration.Device(); newConfiguration.Assign(device); //if the user has BTC configured, default to that if (hasBtcConfigured) newConfiguration.CoinSymbol = btcSymbol; newConfiguration.Enabled = true; engineConfiguration.DeviceConfigurations.Add(newConfiguration); } } }
private List<Engine.Data.Configuration.Device> CreateDeviceConfigurationForProfitableCoins(List<CoinInformation> allProfitableCoins, List<CoinInformation> sha256ProfitableCoins, List<CoinInformation> scryptProfitableCoins) { List<Engine.Data.Configuration.Device> newConfiguration = new List<Engine.Data.Configuration.Device>(); CoinInformation profitableCoin = null; int comboAlgoIterator = 0; int sha256Iterator = 0; int scryptIterator = 0; for (int i = 0; i < devices.Count; i++) { Xgminer.Data.Device device = devices[i]; //there should be a 1-to-1 relationship of devices and device configurations Engine.Data.Configuration.Device existingConfiguration = engineConfiguration.DeviceConfigurations[i]; if (existingConfiguration.Enabled) { profitableCoin = null; if (device.Kind == DeviceKind.PXY) { Data.Configuration.Coin existingCoinConfig = engineConfiguration.CoinConfigurations.Single(cc => cc.CryptoCoin.Symbol.Equals(existingConfiguration.CoinSymbol, StringComparison.OrdinalIgnoreCase)); //keep Proxies on the same algo - don't know what is pointed at them if (existingCoinConfig.CryptoCoin.Algorithm == CoinAlgorithm.Scrypt) { profitableCoin = ChooseCoinFromList(scryptProfitableCoins, scryptIterator); scryptIterator++; } else { profitableCoin = ChooseCoinFromList(sha256ProfitableCoins, sha256Iterator); sha256Iterator++; } } else if (device.SupportsAlgorithm(CoinAlgorithm.Scrypt) && !device.SupportsAlgorithm(CoinAlgorithm.SHA256)) { //scrypt only profitableCoin = ChooseCoinFromList(scryptProfitableCoins, scryptIterator); scryptIterator++; } else if (device.SupportsAlgorithm(CoinAlgorithm.Scrypt) && device.SupportsAlgorithm(CoinAlgorithm.SHA256)) { //sha256 or scrypt profitableCoin = ChooseCoinFromList(allProfitableCoins, comboAlgoIterator); comboAlgoIterator++; } else if (sha256ProfitableCoins.Count > 0) { //sha256 only profitableCoin = ChooseCoinFromList(sha256ProfitableCoins, sha256Iterator); sha256Iterator++; } if (comboAlgoIterator >= allProfitableCoins.Count()) comboAlgoIterator = 0; if (sha256Iterator >= sha256ProfitableCoins.Count()) sha256Iterator = 0; if (scryptIterator >= scryptProfitableCoins.Count()) scryptIterator = 0; Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device(); configEntry.Assign(device); configEntry.CoinSymbol = profitableCoin == null ? string.Empty : profitableCoin.Symbol; newConfiguration.Add(configEntry); } else { Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device(); configEntry.Assign(device); configEntry.CoinSymbol = existingConfiguration.CoinSymbol; configEntry.Enabled = false; newConfiguration.Add(configEntry); } } return newConfiguration; }
private List <Engine.Data.Configuration.Device> CreateDeviceConfigurationForProfitableCoins(List <CoinInformation> allProfitableCoins, List <CoinInformation> sha256ProfitableCoins, List <CoinInformation> scryptProfitableCoins) { List <Engine.Data.Configuration.Device> newConfiguration = new List <Engine.Data.Configuration.Device>(); CoinInformation profitableCoin = null; int comboAlgoIterator = 0; int sha256Iterator = 0; int scryptIterator = 0; for (int i = 0; i < devices.Count; i++) { Xgminer.Data.Device device = devices[i]; //there should be a 1-to-1 relationship of devices and device configurations Engine.Data.Configuration.Device existingConfiguration = engineConfiguration.DeviceConfigurations[i]; if (existingConfiguration.Enabled) { profitableCoin = null; if (device.SupportsAlgorithm(CoinAlgorithm.Scrypt) && !device.SupportsAlgorithm(CoinAlgorithm.SHA256)) { //scrypt only profitableCoin = ChooseCoinFromList(scryptProfitableCoins, scryptIterator); scryptIterator++; if (scryptIterator >= scryptProfitableCoins.Count()) { scryptIterator = 0; } } else if (device.SupportsAlgorithm(CoinAlgorithm.Scrypt) && device.SupportsAlgorithm(CoinAlgorithm.SHA256)) { //sha256 or scrypt profitableCoin = ChooseCoinFromList(allProfitableCoins, comboAlgoIterator); comboAlgoIterator++; if (comboAlgoIterator >= allProfitableCoins.Count()) { comboAlgoIterator = 0; } } else if (sha256ProfitableCoins.Count > 0) { //sha256 only profitableCoin = ChooseCoinFromList(sha256ProfitableCoins, sha256Iterator); sha256Iterator++; if (sha256Iterator >= sha256ProfitableCoins.Count()) { sha256Iterator = 0; } } Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device(); configEntry.Assign(device); configEntry.CoinSymbol = profitableCoin == null ? string.Empty : profitableCoin.Symbol; newConfiguration.Add(configEntry); } else { Engine.Data.Configuration.Device configEntry = new Engine.Data.Configuration.Device(); configEntry.Assign(device); configEntry.CoinSymbol = existingConfiguration.CoinSymbol; configEntry.Enabled = false; newConfiguration.Add(configEntry); } } return(newConfiguration); }