Esempio n. 1
0
 private static string GetDisabledDeviceStatusString(ComputeDevice dev, DeviceMiningStatus status)
 {
     return(status switch
     {
         DeviceMiningStatus.DeviceNull => "Passed Device is NULL",
         DeviceMiningStatus.Disabled => $"DISABLED: {dev.GetFullName()}",
         DeviceMiningStatus.NoEnabledAlgorithms => $"No Enabled Algorithms: {dev.GetFullName()}",
         _ => "Invalid status Passed",
     });
        private void ListViewDevicesTDP_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            _selectedComputeDevice = e.Item.Tag as ComputeDevice;
            if (_selectedComputeDevice == null)
            {
                return;
            }
            var tdpMon = _selectedComputeDevice.DeviceMonitor as ITDP;

            labelSelectedDevice.Text     = _selectedComputeDevice.GetFullName();
            labelSelectedTDPSetting.Text = $"Selected TDP Setting => {tdpMon.SettingType.ToString()}";
            // reset
            label_value_simple.Text     = "";
            label_value_percentage.Text = "";
            label_value_raw.Text        = "";
            textBox_simple.Text         = "";
            textBox_percentage.Text     = "";
            textBox_raw.Text            = "";
        }
Esempio n. 3
0
 public static object[] GetDeviceRowData(ComputeDevice d)
 {
     object[] rowData = { d.Enabled, d.GetFullName() };
     return(rowData);
 }
Esempio n. 4
0
        public MiningSession(List <ComputeDevice> devices,
                             IMainFormRatesComunication mainFormRatesComunication,
                             string miningLocation, string worker, string btcAdress)
        {
            // init fixed
            _mainFormRatesComunication = mainFormRatesComunication;
            _miningLocation            = miningLocation;

            if (worker.Length > 0)
            {
                _workerBtcStringWorker = btcAdress + "." + worker;
            }
            else
            {
                _workerBtcStringWorker = btcAdress;
            }

            // initial settup
            {
                // used for logging
                List <Tuple <ComputeDevice, DeviceMiningStatus> > disabledDevicesStatuses = new List <Tuple <ComputeDevice, DeviceMiningStatus> >();
                // logging and settup
                List <ComputeDevice> enabledDevices = new List <ComputeDevice>();
                // get enabled devices
                {
                    // check passed devices statuses
                    List <Tuple <ComputeDevice, DeviceMiningStatus> > devicesStatuses = new List <Tuple <ComputeDevice, DeviceMiningStatus> >();
                    foreach (var device in devices)
                    {
                        devicesStatuses.Add(getDeviceMiningStatus(device));
                    }
                    // sort device statuses
                    foreach (var deviceStatus in devicesStatuses)
                    {
                        if (deviceStatus.Item2 == DeviceMiningStatus.CanMine)
                        {
                            enabledDevices.Add(deviceStatus.Item1);
                        }
                        else
                        {
                            disabledDevicesStatuses.Add(deviceStatus);
                        }
                    }
                }
                // print statuses
                if (disabledDevicesStatuses.Count > 0)
                {
                    Helpers.ConsolePrint(TAG, "Disabled Devices:");
                    foreach (var deviceStatus in disabledDevicesStatuses)
                    {
                        ComputeDevice      device = deviceStatus.Item1;
                        DeviceMiningStatus status = deviceStatus.Item2;
                        if (status == DeviceMiningStatus.DeviceNull)
                        {
                            Helpers.ConsolePrint(TAG, "Critical Device is NULL");
                        }
                        else if (status == DeviceMiningStatus.Disabled)
                        {
                            Helpers.ConsolePrint(TAG, String.Format("DISABLED ({0})", device.GetFullName()));
                        }
                        else if (status == DeviceMiningStatus.NoEnabledAlgorithms)
                        {
                            Helpers.ConsolePrint(TAG, String.Format("No Enabled Algorithms ({0})", device.GetFullName()));
                        }
                    }
                }
                if (enabledDevices.Count > 0)
                {
                    // print enabled
                    Helpers.ConsolePrint(TAG, "Enabled Devices for Mining session:");
                    foreach (var device in enabledDevices)
                    {
                        Helpers.ConsolePrint(TAG, String.Format("ENABLED ({0})", device.GetFullName()));
                        foreach (var algo in device.DeviceBenchmarkConfig.AlgorithmSettings.Values)
                        {
                            var isEnabled = IsAlgoMiningCapable(algo);
                            Helpers.ConsolePrint(TAG, String.Format("\t\tALGORITHM {0} ({1})",
                                                                    isEnabled ? "ENABLED " : "DISABLED", // ENABLED/DISABLED
                                                                    AlgorithmNiceHashNames.GetName(algo.NiceHashID)));
                        }
                    }
                    // settup mining devices
                    foreach (var device in enabledDevices)
                    {
                        _miningDevices.Add(new MiningDevice(device));
                    }
                }
            }
            if (_miningDevices.Count > 0)
            {
                // calculate avarage speeds, to ensure mining stability
                // device name, algo key, algos refs list
                Dictionary <string,
                            Dictionary <AlgorithmType,
                                        List <MiningAlgorithm> > > avarager = new Dictionary <string, Dictionary <AlgorithmType, List <MiningAlgorithm> > >();
                // init empty avarager
                foreach (var device in _miningDevices)
                {
                    string devName = device.Device.Name;
                    avarager[devName] = new Dictionary <AlgorithmType, List <MiningAlgorithm> >();
                    foreach (var key in AlgorithmNiceHashNames.GetAllAvaliableTypes())
                    {
                        avarager[devName][key] = new List <MiningAlgorithm>();
                    }
                }
                // fill avarager
                foreach (var device in _miningDevices)
                {
                    string devName = device.Device.Name;
                    foreach (var kvp in device.Algorithms)
                    {
                        var             key  = kvp.Key;
                        MiningAlgorithm algo = kvp.Value;
                        avarager[devName][key].Add(algo);
                    }
                }
                // calculate avarages
                foreach (var devDict in avarager.Values)
                {
                    foreach (List <MiningAlgorithm> miningAlgosList in devDict.Values)
                    {
                        // if list not empty calculate avarage
                        if (miningAlgosList.Count > 0)
                        {
                            // calculate avarage
                            double sum = 0;
                            foreach (var algo in miningAlgosList)
                            {
                                sum += algo.AvaragedSpeed;
                            }
                            double avarageSpeed = sum / miningAlgosList.Count;
                            // set avarage
                            foreach (var algo in miningAlgosList)
                            {
                                algo.AvaragedSpeed = avarageSpeed;
                            }
                        }
                    }
                }
            }

            // init timer stuff
            _preventSleepTimer          = new Timer();
            _preventSleepTimer.Elapsed += PreventSleepTimer_Tick;
            // sleep time is minimal 1 minute
            _preventSleepTimer.Interval = 20 * 1000; // leave this interval, it works

            // set internet checking
            _internetCheckTimer          = new Timer();
            _internetCheckTimer.Elapsed += InternetCheckTimer_Tick;
            _internetCheckTimer.Interval = 1000 * 30 * 1; // every minute or 5?? // 1000 * 60 * 1

            _miningStatusCheckTimer          = new Timer();
            _miningStatusCheckTimer.Elapsed += MiningStatusCheckTimer_Tick;
            _miningStatusCheckTimer.Interval = 1000 * 30;

            // assume profitable
            IsProfitable = true;
            // assume we have internet
            IsConnectedToInternet = true;

            if (IsMiningEnabled)
            {
                _preventSleepTimer.Start();
                _internetCheckTimer.Start();
                _miningStatusCheckTimer.Start();
            }

            IsMiningRegardlesOfProfit = ConfigManager.Instance.GeneralConfig.MinimumProfit == 0;
        }