Example #1
0
        private CoinConfiguration CoinConfigurationForDevice(Device device)
        {
            //get the actual device configuration, text in the ListViewItem may be unsaved
            DeviceConfiguration deviceConfiguration = engineConfiguration.DeviceConfigurations.SingleOrDefault(dc => dc.Equals(device));
            if (deviceConfiguration == null)
                return null;

            string itemCoinSymbol = deviceConfiguration.CoinSymbol;

            List<CoinConfiguration> configurations;
            if (miningEngine.Mining)
                configurations = this.miningCoinConfigurations;
            else
                configurations = engineConfiguration.CoinConfigurations;

            CoinConfiguration coinConfiguration = configurations.SingleOrDefault(c => c.Coin.Symbol.Equals(itemCoinSymbol, StringComparison.OrdinalIgnoreCase));
            return coinConfiguration;
        }
Example #2
0
        private List<Device> GetDevices()
        {
            MinerConfiguration minerConfiguration = new MinerConfiguration();

            minerConfiguration.MinerBackend = engineConfiguration.XgminerConfiguration.MinerBackend;
            minerConfiguration.ExecutablePath = MinerPath.GetPathToInstalledMiner(minerConfiguration.MinerBackend);
            minerConfiguration.ErupterDriver = engineConfiguration.XgminerConfiguration.ErupterDriver;

            minerConfiguration.DisableGpu = engineConfiguration.XgminerConfiguration.DisableGpu;

            Miner miner = new Miner(minerConfiguration);

            List<Device> detectedDevices = miner.ListDevices();

            if ((engineConfiguration.XgminerConfiguration.MinerBackend == MinerBackend.Bfgminer) &&
                engineConfiguration.XgminerConfiguration.StratumProxy)
            {
                Device proxyDevice = new Device();
                proxyDevice.Kind = DeviceKind.PXY;
                proxyDevice.Driver = "proxy";
                proxyDevice.Name = "Stratum Proxy";
                proxyDevice.Identifier = "PXY";
                proxyDevice.DeviceIndex = detectedDevices.Count;
                detectedDevices.Add(proxyDevice);
            }

            //sort GPUs first - the output of -d? changed with bfgminer 3.3.0
            detectedDevices.Sort((d1, d2) =>
                {
                    int result = 0;

                    result = d1.Kind.CompareTo(d2.Kind);
                    if (result == 0)
                        result = d1.DeviceIndex.CompareTo(d2.DeviceIndex);

                    return result;
                });

            return detectedDevices;
        }
Example #3
0
        public void InspectDetails(Device device, CoinConfiguration coinConfiguration, CoinInformation coinInformation,
            List<DeviceInformationResponse> deviceInformation, PoolInformationResponse poolInformation,
            List<DeviceDetailsResponse> deviceDetails, bool showWorkUtility)
        {
            this.deviceDetails = deviceDetails;
            this.deviceInformation = deviceInformation;

            noDetailsPanel.Visible = false;
            double hashrate = deviceInformation.Sum(di => di.AverageHashrate);
            double currentRate = deviceInformation.Sum(di => di.CurrentHashrate);

            hashrateLabel.Text = hashrate.ToHashrateString();
            currentRateLabel.Text = currentRate.ToHashrateString();

            workersGridView.Visible = (device.Kind == DeviceKind.PXY) &&
                (deviceInformation.Count > 0);
            workersTitleLabel.Visible = workersGridView.Visible;

            //Internet or Coin API could be down
            if (coinInformation != null)
            {
            }

            //device may not be configured
            if (coinConfiguration != null)
                cryptoCoinBindingSource.DataSource = coinConfiguration.Coin;
            else
                cryptoCoinBindingSource.DataSource = new CryptoCoin();

            deviceInformationResponseBindingSource.DataSource = deviceInformation;

            //may not be hashing yet
            if (deviceDetails != null)
                deviceDetailsResponseBindingSource.DataSource = deviceDetails;
            else
                deviceDetailsResponseBindingSource.DataSource = new DeviceDetailsResponse();

            deviceBindingSource.DataSource = device;

            switch (device.Kind)
            {
                case DeviceKind.CPU:
                    pictureBox1.Image = imageList1.Images[3];
                    break;
                case DeviceKind.GPU:
                    pictureBox1.Image = imageList1.Images[0];
                    break;
                case DeviceKind.USB:
                    pictureBox1.Image = imageList1.Images[1];
                    break;
                case DeviceKind.PXY:
                    pictureBox1.Image = imageList1.Images[2];
                    break;
            }

            nameLabel.Width = this.Width - nameLabel.Left - closeDetailsButton.Width;

            acceptedLabel.Text = deviceInformation.Sum(d => d.AcceptedShares).ToString();
            rejectedLabel.Text = deviceInformation.Sum(d => d.RejectedShares).ToString();
            errorsLabel.Text = deviceInformation.Sum(d => d.HardwareErrors).ToString();

            if (showWorkUtility)
            {
                utilityLabel.Text = deviceInformation.Sum(d => d.WorkUtility).ToString();
                utilityDataGridViewTextBoxColumn.DataPropertyName = "WorkUtility";
            }
            else
            {
                utilityLabel.Text = deviceInformation.Sum(d => d.Utility).ToString();
                utilityDataGridViewTextBoxColumn.DataPropertyName = "Utility";
            }
            utilityPrefixLabel.Text = showWorkUtility ? "Work utility:" : "Utility:";

            DeviceInformationResponse deviceInfo = (DeviceInformationResponse)deviceInformationResponseBindingSource.Current;
            if (deviceInfo != null)
            {
                if (deviceInfo.Temperature > 0)
                    tempLabel.Text = deviceInfo.Temperature + "°";
                else
                    tempLabel.Text = String.Empty;

                if (deviceInfo.FanPercent > 0)
                    fanLabel.Text = deviceInfo.FanPercent + "%";
                else
                    fanLabel.Text = String.Empty;
            }
            else
            {
                tempLabel.Text = String.Empty;
                fanLabel.Text = String.Empty;
            }

            UpdateColumnVisibility();

            //may not be hashing yet
            if (poolInformation != null)
                poolInformationResponseBindingSource.DataSource = poolInformation;
            else
                poolInformationResponseBindingSource.DataSource = new PoolInformationResponse();
        }
Example #4
0
        public DeviceViewModel ApplyDeviceInformationResponseModel(Device deviceModel, DeviceInformationResponse deviceInformationResponseModel)
        {
            DeviceViewModel deviceViewModel = Devices.SingleOrDefault(d => d.Equals(deviceModel));
            if (deviceViewModel != null)
            {
                if (deviceModel.Kind == DeviceKind.PXY)
                {
                    deviceViewModel.PoolIndex = deviceInformationResponseModel.PoolIndex;

                    //we will get multiple deviceInformationResponseModels for the same deviceModel in the case of a Stratum Proxy
                    //bfgminer will report back for each Proxy Worker, but we only show a single entry in the ViewModel that rolls
                    //up the stats for individual Proxy Workers
                    deviceViewModel.AverageHashrate += deviceInformationResponseModel.AverageHashrate;
                    deviceViewModel.CurrentHashrate += deviceInformationResponseModel.AverageHashrate;
                    deviceViewModel.AcceptedShares += deviceInformationResponseModel.AcceptedShares;
                    deviceViewModel.RejectedShares += deviceInformationResponseModel.RejectedShares;
                    deviceViewModel.HardwareErrors += deviceInformationResponseModel.HardwareErrors;
                    deviceViewModel.Utility += deviceInformationResponseModel.Utility;
                    deviceViewModel.WorkUtility += deviceInformationResponseModel.WorkUtility;
                    deviceViewModel.RejectedSharesPercent += deviceInformationResponseModel.RejectedSharesPercent;
                    deviceViewModel.HardwareErrorsPercent += deviceInformationResponseModel.HardwareErrorsPercent;

                    //now add as a worker
                    DeviceViewModel workerViewModel = new DeviceViewModel();
                    ObjectCopier.CopyObject(deviceInformationResponseModel, workerViewModel, "Name", "Kind");
                    deviceViewModel.Workers.Add(workerViewModel);
                }
                else
                {
                    ObjectCopier.CopyObject(deviceInformationResponseModel, deviceViewModel, "Name", "Kind");
                }
            }
            return deviceViewModel;
        }