public static bool StartInitialize(IMainFormRatesComunication mainFormRatesComunication, string miningLocation, string worker, string btcAdress) { _curMiningSession = new MiningSession(ComputeDeviceManager.Avaliable.AllAvaliableDevices, mainFormRatesComunication, miningLocation, worker, btcAdress); return(_curMiningSession.IsMiningEnabled); }
public MiningSession(List <ComputeDevice> devices, IMainFormRatesComunication mainFormRatesComunication, string miningLocation, string worker, string btcAdress) { // init fixed _mainFormRatesComunication = mainFormRatesComunication; _miningLocation = miningLocation; _btcAdress = btcAdress; _worker = worker; // initial settup _miningDevices = GroupSetupUtils.GetMiningDevices(devices, true); if (_miningDevices.Count > 0) { GroupSetupUtils.AvarageSpeeds(_miningDevices); } // 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 = 1 * 1000 * 60; // every minute //// check worker stats //_checkWorkerStats = new Timer(); //_checkWorkerStats.Elapsed += _checkWorkerStats_Elapsed; //_checkWorkerStats.Interval = 2 * 1000 * 60; // every 2 minutes check, miners have to mine 5 minutes to take into account // assume profitable IsProfitable = true; // assume we have internet IsConnectedToInternet = true; if (IsMiningEnabled) { _preventSleepTimer.Start(); _internetCheckTimer.Start(); //_checkWorkerStats.Start(); } IsMiningRegardlesOfProfit = ConfigManager.GeneralConfig.MinimumProfit == 0; }
public MiningSession(List <ComputeDevice> devices, IMainFormRatesComunication mainFormRatesComunication, string miningLocation, string worker, string btcAdress) { // init fixed _mainFormRatesComunication = mainFormRatesComunication; _miningLocation = miningLocation; _switchingManager = new AlgorithmSwitchingManager(); _switchingManager.SmaCheck += SwichMostProfitableGroupUpMethod; _btcAdress = btcAdress; _worker = worker; // initial settup _miningDevices = GroupSetupUtils.GetMiningDevices(devices, true); if (_miningDevices.Count > 0) { GroupSetupUtils.AvarageSpeeds(_miningDevices); } // 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 = 1 * 1000 * 60; // every minute // assume profitable _isProfitable = true; // assume we have internet _isConnectedToInternet = true; if (IsMiningEnabled) { _preventSleepTimer.Start(); _internetCheckTimer.Start(); } _switchingManager.Start(); _isMiningRegardlesOfProfit = ConfigManager.GeneralConfig.MinimumProfit == 0; }
public MiningSession(List<ComputeDevice> devices, IMainFormRatesComunication mainFormRatesComunication, string miningLocation, string worker, string btcAdress) { // init fixed _mainFormRatesComunication = mainFormRatesComunication; _miningLocation = miningLocation; _btcAdress = btcAdress; _worker = worker; // initial settup _miningDevices = GroupSetupUtils.GetMiningDevices(devices, true); if (_miningDevices.Count > 0) { GroupSetupUtils.AvarageSpeeds(_miningDevices); } // 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 * 1; // every minute // assume profitable IsProfitable = true; // assume we have internet IsConnectedToInternet = true; if (IsMiningEnabled) { _preventSleepTimer.Start(); _internetCheckTimer.Start(); } IsMiningRegardlesOfProfit = ConfigManager.GeneralConfig.MinimumProfit == 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; }
public static bool StartInitialize(IMainFormRatesComunication mainFormRatesComunication, string miningLocation, string worker, string btcAdress) { CurMiningSession = new MiningSession(ComputeDeviceManager.Avaliable.AllAvaliableDevices, mainFormRatesComunication, miningLocation, worker, btcAdress); return CurMiningSession.IsMiningEnabled; }
public bool StartInitialize(IMainFormRatesComunication mainFormRatesComunication, string miningLocation, string worker, string btcAdress) { _mainFormRatesComunication = mainFormRatesComunication; _miningLocation = miningLocation; _worker = worker; _btcAdress = btcAdress; if (_worker.Length > 0) { _workerBtcStringWorker = _btcAdress + "." + _worker; } else { _workerBtcStringWorker = _btcAdress; } _perDeviceSpeedDictionary = GetEnabledDeviceTypeSpeeds(); //_groupedDevicesMiners = new Dictionary<GroupedDevices, GroupMiners>(); _groupedDevicesMiners = new Dictionary <string, GroupMiners>(); _enabledDevices = new List <ComputeDevice>(); _currentAllGroupedDevices = new AllGroupedDevices(); // assume profitable IsProfitable = true; // this checks if there are enabled devices and enabled algorithms bool isMiningEnabled = false; foreach (var cdev in ComputeDevice.AllAvaliableDevices) { if (cdev.Enabled) { _enabledDevices.Add(cdev); // check if in CPU group and add the saved CPU miners if (cdev.DeviceGroupType == DeviceGroupType.CPU) { GroupedDevices gdevs = new GroupedDevices(); gdevs.Add(cdev.UUID); cpuminer miner = _cpuMiners[cdev.Group]; CpuGroupMiner cpuGroupMiner = new CpuGroupMiner(gdevs, miner); _groupedDevicesMiners.Add(CalcGroupedDevicesKey(gdevs), cpuGroupMiner); } // check if any algorithm enabled if (!isMiningEnabled) { foreach (var algorithm in cdev.DeviceBenchmarkConfig.AlgorithmSettings) { if (!algorithm.Value.Skip) { isMiningEnabled = true; break; } } } } } if (isMiningEnabled) { _preventSleepTimer.Start(); } IsCurrentlyIdle = !isMiningEnabled; return(isMiningEnabled); }
public bool StartInitialize(IMainFormRatesComunication mainFormRatesComunication, string miningLocation, string worker, string btcAdress) { _mainFormRatesComunication = mainFormRatesComunication; _miningLocation = miningLocation; _worker = worker; _btcAdress = btcAdress; if (_worker.Length > 0) { _workerBtcStringWorker = _btcAdress + "." + _worker; } else { _workerBtcStringWorker = _btcAdress; } _perDeviceSpeedDictionary = GetEnabledDeviceTypeSpeeds(); //_groupedDevicesMiners = new Dictionary<GroupedDevices, GroupMiners>(); _groupedDevicesMiners = new Dictionary <string, GroupMiners>(); _enabledDevices = new List <ComputeDevice>(); _currentAllGroupedDevices = new AllGroupedDevices(); // assume profitable IsProfitable = true; // assume we have internet IsConnectedToInternet = true; // this checks if there are enabled devices and enabled algorithms bool isMiningEnabled = false; foreach (var cdev in ComputeDevice.AllAvaliableDevices) { if (cdev.Enabled) { _enabledDevices.Add(cdev); // check if any algorithm enabled if (!isMiningEnabled) { foreach (var algorithm in cdev.DeviceBenchmarkConfig.AlgorithmSettings) { if (!algorithm.Value.Skip) { isMiningEnabled = true; break; } } } } } if (isMiningEnabled) { _preventSleepTimer.Start(); _internetCheckTimer.Start(); } IsCurrentlyIdle = !isMiningEnabled; return(isMiningEnabled); }