protected void StartCoolDownTimerChecker() { if (ConfigManager.GeneralConfig.CoolDownCheckEnabled) { Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " Starting cooldown checker"); if (_cooldownCheckTimer != null && _cooldownCheckTimer.Enabled) { _cooldownCheckTimer.Stop(); } // cool down init _cooldownCheckTimer = new Timer() { Interval = _MIN_CooldownTimeInMilliseconds }; _cooldownCheckTimer.Elapsed += MinerCoolingCheck_Tick; _cooldownCheckTimer.Start(); _currentCooldownTimeInSeconds = _MIN_CooldownTimeInMilliseconds; _currentCooldownTimeInSecondsLeft = _currentCooldownTimeInSeconds; } else { Helpers.ConsolePrint(MinerTAG(), "Cooldown checker disabled"); } _currentMinerReadStatus = MinerAPIReadStatus.NONE; }
/// <summary> /// decrement time for half current half time, if less then min ammend /// </summary> private void CoolDown() { if (_currentCooldownTimeInSeconds > _MIN_CooldownTimeInMilliseconds) { _currentCooldownTimeInSeconds = _MIN_CooldownTimeInMilliseconds; Helpers.ConsolePrint(MinerTAG(), String.Format("{0} Reseting cool time = {1} ms", ProcessTag(), _MIN_CooldownTimeInMilliseconds.ToString())); _currentMinerReadStatus = MinerAPIReadStatus.NONE; } }
protected void StartCoolDownTimerChecker() { Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " Starting cooldown checker"); _cooldownCheckTimer.Start(); _currentCooldownTimeInSeconds = _MIN_CooldownTimeInMilliseconds; _currentCooldownTimeInSecondsLeft = _currentCooldownTimeInSeconds; _currentMinerReadStatus = MinerAPIReadStatus.NONE; _isCooldownCheckTimerAliveCount = 0; }
protected async Task <APIData> GetSummaryCPUAsync(string method = "", bool overrideLoop = false) { APIData ad = new APIData(MiningSetup.CurrentAlgorithmType); try { _currentMinerReadStatus = MinerAPIReadStatus.WAIT; string dataToSend = GetHttpRequestNHMAgentStrin(method); string respStr = await GetAPIDataAsync(APIPort, dataToSend); if (String.IsNullOrEmpty(respStr)) { _currentMinerReadStatus = MinerAPIReadStatus.NETWORK_EXCEPTION; throw new Exception("Response is empty!"); } if (respStr.IndexOf("HTTP/1.1 200 OK") > -1) { respStr = respStr.Substring(respStr.IndexOf(HTTPHeaderDelimiter) + HTTPHeaderDelimiter.Length); } else { throw new Exception("Response not HTTP formed! " + respStr); } dynamic resp = JsonConvert.DeserializeObject(respStr); if (resp != null) { JArray totals = resp.hashrate.total; foreach (var total in totals) { if (total.Value <string>() == null) { continue; } ad.Speed = total.Value <double>(); break; } if (ad.Speed == 0) { _currentMinerReadStatus = MinerAPIReadStatus.READ_SPEED_ZERO; } else { _currentMinerReadStatus = MinerAPIReadStatus.GOT_READ; } } else { throw new Exception($"Response does not contain speed data: {respStr.Trim()}"); } } catch (Exception ex) { Helpers.ConsolePrint(MinerTAG(), ex.Message); } return(ad); }
protected void ScheduleRestart(int ms) { var RestartInMS = ConfigManager.GeneralConfig.MinerRestartDelayMS > ms ? ConfigManager.GeneralConfig.MinerRestartDelayMS : ms; Helpers.ConsolePrint(MinerTAG(), ProcessTag() + String.Format(" Miner_Exited Will restart in {0} ms", RestartInMS)); _currentMinerReadStatus = MinerAPIReadStatus.RESTART; NeedsRestart = true; _currentCooldownTimeInSecondsLeft = RestartInMS; }
/// <summary> /// increment time for half current half time, if more then max set restart /// </summary> private void CoolUp() { _currentCooldownTimeInSeconds *= 2; Helpers.ConsolePrint(MinerTAG(), String.Format("{0} Cooling UP, cool time is {1} ms", ProcessTag(), _currentCooldownTimeInSeconds.ToString())); if (_currentCooldownTimeInSeconds > _MAX_CooldownTimeInMilliseconds) { _currentMinerReadStatus = MinerAPIReadStatus.RESTART; Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " MAX cool time exceeded. RESTARTING"); Restart(); } }
virtual protected void Miner_Exited() { // TODO make miner restart in 5 seconds //Stop(MinerStopType.END, true); var RestartInMS = ConfigManager.GeneralConfig.MinerRestartDelayMS > 5000 ? ConfigManager.GeneralConfig.MinerRestartDelayMS : 5000; Helpers.ConsolePrint(MinerTAG(), ProcessTag() + String.Format(" Miner_Exited Will restart in {0} ms", RestartInMS)); _currentMinerReadStatus = MinerAPIReadStatus.RESTART; NeedsRestart = true; _currentCooldownTimeInSecondsLeft = RestartInMS; }
protected async Task <APIData> GetSummaryCPU_CCMINERAsync() { string resp; // TODO aname string aname = null; APIData ad = new APIData(MiningSetup.CurrentAlgorithmType); string DataToSend = GetHttpRequestNHMAgentStrin("summary"); resp = await GetAPIDataAsync(APIPort, DataToSend); if (resp == null) { Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " summary is null"); _currentMinerReadStatus = MinerAPIReadStatus.NONE; return(null); } try { string[] resps = resp.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < resps.Length; i++) { string[] optval = resps[i].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (optval.Length != 2) { continue; } if (optval[0] == "ALGO") { aname = optval[1]; } else if (optval[0] == "KHS") { ad.Speed = double.Parse(optval[1], CultureInfo.InvariantCulture) * 1000; // HPS } } } catch { Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " Could not read data from API bind port"); _currentMinerReadStatus = MinerAPIReadStatus.NONE; return(null); } _currentMinerReadStatus = MinerAPIReadStatus.GOT_READ; // check if speed zero if (ad.Speed == 0) { _currentMinerReadStatus = MinerAPIReadStatus.READ_SPEED_ZERO; } return(ad); }
protected void ScheduleRestart(int ms) { var RestartInMS = ConfigManager.GeneralConfig.MinerRestartDelayMS > ms ? ConfigManager.GeneralConfig.MinerRestartDelayMS : ms; Helpers.ConsolePrint(MinerTAG(), ProcessTag() + String.Format(" Miner_Exited Will restart in {0} ms", RestartInMS)); if (ConfigManager.GeneralConfig.CoolDownCheckEnabled) { _currentMinerReadStatus = MinerAPIReadStatus.RESTART; NeedsRestart = true; _currentCooldownTimeInSecondsLeft = RestartInMS; } else // directly restart since cooldown checker not running { Thread.Sleep(RestartInMS); Restart(); } }
protected void StartCoolDownTimerChecker() { Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " Starting cooldown checker"); if (_cooldownCheckTimer != null && _cooldownCheckTimer.Enabled) _cooldownCheckTimer.Stop(); // cool down init _cooldownCheckTimer = new Timer() { Interval = _MIN_CooldownTimeInMilliseconds }; _cooldownCheckTimer.Elapsed += MinerCoolingCheck_Tick; _cooldownCheckTimer.Start(); _currentCooldownTimeInSeconds = _MIN_CooldownTimeInMilliseconds; _currentCooldownTimeInSecondsLeft = _currentCooldownTimeInSeconds; _currentMinerReadStatus = MinerAPIReadStatus.NONE; }
protected virtual void Miner_Exited() { // TODO make miner restart in 5 seconds //Stop(MinerStopType.END, true); var RestartInMS = ConfigManager.GeneralConfig.MinerRestartDelayMS > 5000 ? ConfigManager.GeneralConfig.MinerRestartDelayMS : 5000; Helpers.ConsolePrint(MinerTAG(), ProcessTag() + String.Format(" Miner_Exited Will restart in {0} ms", RestartInMS)); _currentMinerReadStatus = MinerAPIReadStatus.RESTART; NeedsRestart = true; _currentCooldownTimeInSecondsLeft = RestartInMS; }
protected APIData GetSummaryCPU_CCMINER() { string resp; // TODO aname string aname = null; APIData ad = new APIData(MiningSetup.CurrentAlgorithmType); resp = GetAPIData(APIPort, "summary"); if (resp == null) { Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " summary is null"); _currentMinerReadStatus = MinerAPIReadStatus.NONE; return null; } try { string[] resps = resp.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < resps.Length; i++) { string[] optval = resps[i].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (optval.Length != 2) continue; if (optval[0] == "ALGO") aname = optval[1]; else if (optval[0] == "KHS") ad.Speed = double.Parse(optval[1], CultureInfo.InvariantCulture) * 1000; // HPS } } catch { Helpers.ConsolePrint(MinerTAG(), ProcessTag() + " Could not read data from API bind port"); _currentMinerReadStatus = MinerAPIReadStatus.NONE; return null; } _currentMinerReadStatus = MinerAPIReadStatus.GOT_READ; // check if speed zero if (ad.Speed == 0) _currentMinerReadStatus = MinerAPIReadStatus.READ_SPEED_ZERO; return ad; }