Esempio n. 1
0
        private int SetupConfigurationDevices(Xgminer.Data.Configuration.Miner minerConfiguration, DeviceKind deviceKinds, IList <Engine.Data.Configuration.Device> deviceConfigurations)
        {
            int deviceCount = 0;

            for (int i = 0; i < deviceConfigurations.Count; i++)
            {
                Engine.Data.Configuration.Device enabledConfiguration = deviceConfigurations[i];

                Xgminer.Data.Device device = devices.SingleOrDefault(d => d.Equals(enabledConfiguration));

                if ((deviceKinds & device.Kind) == 0)
                {
                    continue;
                }

                deviceCount++;

                //don't actually add stratum device as a device index
                if (device.Kind != DeviceKind.PXY)
                {
                    minerConfiguration.DeviceDescriptors.Add(device);
                }
                else
                {
                    //only enable the stratum proxy if these devices contain the PXY device
                    minerConfiguration.StratumProxy            = engineConfiguration.XgminerConfiguration.StratumProxy;
                    minerConfiguration.StratumProxyPort        = engineConfiguration.XgminerConfiguration.StratumProxyPort;
                    minerConfiguration.StratumProxyStratumPort = engineConfiguration.XgminerConfiguration.StratumProxyStratumPort;
                }
            }
            return(deviceCount);
        }
Esempio n. 2
0
 public void ApplyDeviceConfigurationModels(List <Engine.Data.Configuration.Device> deviceConfigurations, List <Engine.Data.Configuration.Coin> coinConfigurations)
 {
     foreach (DeviceViewModel deviceViewModel in Devices)
     {
         Engine.Data.Configuration.Device deviceConfiguration = deviceConfigurations.SingleOrDefault(dc => dc.Equals(deviceViewModel));
         if (deviceConfiguration != null)
         {
             deviceViewModel.Enabled = deviceConfiguration.Enabled;
             if (String.IsNullOrEmpty(deviceConfiguration.CoinSymbol))
             {
                 deviceViewModel.Coin = null;
             }
             else
             {
                 Engine.Data.Configuration.Coin coinConfiguration = coinConfigurations.SingleOrDefault(
                     cc => cc.CryptoCoin.Symbol.Equals(deviceConfiguration.CoinSymbol, StringComparison.OrdinalIgnoreCase));
                 if (coinConfiguration != null)
                 {
                     deviceViewModel.Coin = coinConfiguration.CryptoCoin;
                 }
             }
         }
         else
         {
             deviceViewModel.Enabled = true;
             Engine.Data.Configuration.Coin coinConfiguration = coinConfigurations.SingleOrDefault(
                 cc => cc.CryptoCoin.Symbol.Equals(KnownCoins.BitcoinSymbol, StringComparison.OrdinalIgnoreCase));
             if (coinConfiguration != null)
             {
                 deviceViewModel.Coin = coinConfiguration.CryptoCoin;
             }
         }
     }
 }
        public static List <Engine.Data.Configuration.Device> ToModelObjects(this List <Remoting.Data.Transfer.Configuration.Device> transferObjects)
        {
            List <Engine.Data.Configuration.Device> modelObjects = new List <Engine.Data.Configuration.Device>();

            foreach (Remoting.Data.Transfer.Configuration.Device transferConfig in transferObjects)
            {
                Engine.Data.Configuration.Device modelObject = ObjectCopier.CloneObject <Remoting.Data.Transfer.Configuration.Device, Engine.Data.Configuration.Device>(transferConfig);
                modelObjects.Add(modelObject);
            }

            return(modelObjects);
        }
        public void ApplyDeviceConfigurationModels(List <Engine.Data.Configuration.Device> deviceConfigurations, List <Engine.Data.Configuration.Coin> coinConfigurations)
        {
            foreach (DeviceViewModel deviceViewModel in Devices.Where(d => d.Kind != DeviceKind.NET))
            {
                Engine.Data.Configuration.Device deviceConfiguration = deviceConfigurations.SingleOrDefault(dc => dc.Equals(deviceViewModel));
                if (deviceConfiguration != null)
                {
                    deviceViewModel.Enabled = deviceConfiguration.Enabled;
                    if (String.IsNullOrEmpty(deviceConfiguration.CoinSymbol))
                    {
                        deviceViewModel.Coin = null;
                    }
                    else
                    {
                        Engine.Data.Configuration.Coin coinConfiguration = coinConfigurations.SingleOrDefault(
                            cc => cc.CryptoCoin.Symbol.Equals(deviceConfiguration.CoinSymbol, StringComparison.OrdinalIgnoreCase));
                        if (coinConfiguration != null)
                        {
                            deviceViewModel.Coin = coinConfiguration.CryptoCoin;
                        }
                    }
                }
                else
                {
                    deviceViewModel.Enabled = true;

                    Engine.Data.Configuration.Coin btcConfiguration = coinConfigurations.SingleOrDefault(
                        cc => cc.CryptoCoin.Symbol.Equals(KnownCoins.BitcoinSymbol, StringComparison.OrdinalIgnoreCase));
                    Engine.Data.Configuration.Coin ltcConfiguration = coinConfigurations.SingleOrDefault(
                        cc => cc.CryptoCoin.Symbol.Equals(KnownCoins.LitecoinSymbol, StringComparison.OrdinalIgnoreCase));

                    if (deviceViewModel.SupportsAlgorithm(CoinAlgorithm.Scrypt) && (ltcConfiguration != null))
                    {
                        deviceViewModel.Coin = ltcConfiguration.CryptoCoin;
                    }
                    else if (deviceViewModel.SupportsAlgorithm(CoinAlgorithm.SHA256) && (btcConfiguration != null))
                    {
                        deviceViewModel.Coin = btcConfiguration.CryptoCoin;
                    }
                }
            }
        }
Esempio n. 5
0
        private int SetupConfigurationDevices(Xgminer.Data.Configuration.Miner minerConfiguration, DeviceKind deviceKind, IList <Engine.Data.Configuration.Device> deviceConfigurations)
        {
            int deviceCount = 0;

            for (int i = 0; i < deviceConfigurations.Count; i++)
            {
                Engine.Data.Configuration.Device enabledConfiguration = deviceConfigurations[i];

                Xgminer.Data.Device device = devices.SingleOrDefault(d => d.Equals(enabledConfiguration));

                if (deviceKind != device.Kind)
                {
                    continue;
                }

                deviceCount++;

                minerConfiguration.DeviceDescriptors.Add(device);
            }
            return(deviceCount);
        }
Esempio n. 6
0
        private static bool DeviceConfigurationsDiffer(List <Engine.Data.Configuration.Device> configuration1, List <Engine.Data.Configuration.Device> configuration2)
        {
            bool configDifferent = configuration1.Count != configuration2.Count;

            if (!configDifferent)
            {
                for (int i = 0; i < configuration1.Count; i++)
                {
                    Engine.Data.Configuration.Device entry1 = configuration1[i];
                    Engine.Data.Configuration.Device entry2 = configuration2[i];

                    configDifferent = (!entry1.CoinSymbol.Equals(entry2.CoinSymbol) ||
                                       (entry1.Kind != entry2.Kind) ||
                                       (entry1.Driver != entry2.Driver) ||
                                       (entry1.Path != entry2.Path));
                    if (configDifferent)
                    {
                        break;
                    }
                }
            }

            return(configDifferent);
        }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 8
0
        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();
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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;
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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();
        }
Esempio n. 13
0
        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;
        }
Esempio n. 14
0
        //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);
                }
            }
        }
Esempio n. 15
0
        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;
        }
Esempio n. 16
0
        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();
        }
Esempio n. 17
0
        //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);
                }
            }
        }
Esempio n. 18
0
        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);
        }