public bool AddMinerScript(IMinerProgram program, IMiner miner) { bool toSave = false; foreach (MinerData item in Miners) { if (item.Id == miner.Id) { //identified the miner foreach (MinerScript script in item.MinerScripts) { if (script.ProgramType == program.Type) { script.BATfile = program.BATFILE; script.BATCopied = program.BATCopied; script.AutomaticScriptGeneration = program.AutomaticScriptGeneration; toSave = true; } } if (toSave == false) { MinerScript script = new MinerScript(); script.ProgramType = program.Type; script.BATfile = program.BATFILE; script.BATCopied = program.BATCopied; script.AutomaticScriptGeneration = program.AutomaticScriptGeneration; item.MinerScripts.Add(script); toSave = true; } } } return(toSave); }
public void SetRunningState(IMinerProgram program, MinerProgramState state) { int count = MinerPrograms.Count; if (state != MinerProgramState.Running) { m_MinerRunningHash.Remove(program.Type); } else { m_MinerRunningHash.Add(program.Type); } if (m_MinerRunningHash.Count == 0) { MinerState = MinerProgramState.Stopped; } else if (m_MinerRunningHash.Count < ActualMinerPrograms.Count) { MinerState = MinerProgramState.PartiallyRunning; } else if (m_MinerRunningHash.Count == ActualMinerPrograms.Count) { MinerState = MinerProgramState.Running; } else { MinerState = MinerProgramState.Stopping;//ideally it shudnt com here } //if its not running or partiallyrunning then check if its downloading. if so then set it if (MinerState == MinerProgramState.Stopped && state == MinerProgramState.Downloading) { MinerState = MinerProgramState.Downloading; } Factory.Instance.ViewObject.UpDateMinerState(); }
private void btnSave_Click(object sender, EventArgs e) { DisableEdit(); if (m_currentButton != null) { IMinerProgram prog = m_ButtonToMiner[m_currentButton.Name] as IMinerProgram; prog.ModifyScript(txtScriptArea.Text); } }
private void btnDefault_Click(object sender, EventArgs e) { if (m_currentButton != null) { IMinerProgram prog = m_ButtonToMiner[m_currentButton.Name] as IMinerProgram; string script = prog.GenerateScript(); txtScriptArea.Text = script; DisableEdit(); } }
public override void SetupMiner(bool minerCreation) { ActualMinerPrograms.Clear(); MinerPrograms.Clear(); m_MinerProgsHash.Clear(); IMinerProgram prog = new ClaymoreCNAmd(MainCoin, DualMining, DualCoin, Name, this); MinerPrograms.Add(prog); IMinerProgram prog2 = new CCMiner(MainCoin, DualMining, DualCoin, Name, this); MinerPrograms.Add(prog2); IMinerProgram prog3 = new ClaymoreCNCpu(MainCoin, DualMining, DualCoin, Name, this); MinerPrograms.Add(prog3); m_MinerProgsHash.Add(prog.GPUType, prog); m_MinerProgsHash.Add(prog2.GPUType, prog2); m_MinerProgsHash.Add(CardMake.CPU, prog3); if (!minerCreation && (MinerGpuType & 1) > 0) //nvidia supported only if manually added { IMinerProgram program = m_MinerProgsHash[CardMake.Nvidia] as IMinerProgram; if (prog != null) { program.Enabled = true; ActualMinerPrograms.Add(program); } } if ((MinerGpuType & 2) > 0) { IMinerProgram program = m_MinerProgsHash[CardMake.Amd] as IMinerProgram; if (prog != null) { program.Enabled = true; ActualMinerPrograms.Add(program); } } //Add CPU miner in 2 condition //1. User explicitely asked to add //2. During creation of miner, there was no GPU miner available if ((MinerGpuType & 4) > 0 || (minerCreation && ActualMinerPrograms.Count == 0)) { //To know why 2 shits are used, refer MinerBase::ChangeGPUType. So 0 shift is 1, 1 shift is 2 and 2 shift is 4 MinerGpuType = MinerGpuType | (1 << 2); IMinerProgram program = m_MinerProgsHash[CardMake.CPU] as IMinerProgram; if (prog != null) { program.Enabled = true; ActualMinerPrograms.Add(program); } } }
public void AddMinerScript(IMinerProgram program, IMiner miner) { try { if (Data.AddMinerScript(program, miner)) { Save(); } } catch (Exception e) { } }
public void AddMinerProgram(IMinerProgram program) { try { if (Data.AddMinerProgram(program)) { Save(); } } catch (Exception e) { } }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { if (m_currentButton != null) { IMinerProgram prog = m_ButtonToMiner[m_currentButton.Name] as IMinerProgram; Process.Start(prog.STATS_LINK_HTML); } } catch (Exception se) { } }
public void UpdateUI() { if (EditingInProgress) { return; } if (m_currentButton != null) { IMinerProgram prog = m_ButtonToMiner[m_currentButton.Name] as IMinerProgram; string script = prog.Script; txtScriptArea.Text = script; DisableEdit(); } }
public void UpdateUI() { try { if (m_currentButton != null) { IMinerProgram prog = m_ButtonToMiner[m_currentButton.Name] as IMinerProgram; string script = prog.OutputReader.NextLog; logBrowser.DocumentText = script; } } catch (Exception e) { } }
public void ChangeGPUType(IMinerProgram prog) { int gpuType = MinerGpuType; if (prog.GPUType == CardMake.Nvidia) { gpuType = gpuType ^ (1 << 0); } if (prog.GPUType == CardMake.Amd) { gpuType = gpuType ^ (1 << 1); } MinerGpuType = gpuType; SetupMiner(); Factory.Instance.Model.AddMiner(this); }
public override void SetupMiner(bool minerCreation) { ActualMinerPrograms.Clear(); MinerPrograms.Clear(); m_MinerProgsHash.Clear(); IMinerProgram prog = new CCMiner(MainCoin, DualMining, DualCoin, Name, this); MinerPrograms.Add(prog); //IMinerProgram prog2 = new NSGMiner(MainCoin, DualMining, DualCoin, Name, this); //MinerPrograms.Add(prog2); m_MinerProgsHash.Add(prog.GPUType, prog); //m_MinerProgsHash.Add(prog2.GPUType, prog2); if (MinerGpuType == 3) { foreach (IMinerProgram item in MinerPrograms) { item.Enabled = true; ActualMinerPrograms.Add(item); } } else if (MinerGpuType == 1) { IMinerProgram program = m_MinerProgsHash[CardMake.Nvidia] as IMinerProgram; if (prog != null) { program.Enabled = true; ActualMinerPrograms.Add(program); } } else if (MinerGpuType == 2) { IMinerProgram program = m_MinerProgsHash[CardMake.Amd] as IMinerProgram; if (prog != null) { program.Enabled = true; ActualMinerPrograms.Add(program); } } }
void chkBox_Click(object sender, EventArgs e) { try { CheckBox chk = sender as CheckBox; if (chk != null) { IMinerProgram prog = m_CheckBoxToMiner[chk.Name] as IMinerProgram; if (prog != null) { Miner.ChangeGPUType(prog); } } } catch (Exception ee) { } }
public bool AddMinerProgram(IMinerProgram program) { bool toSave = false; string algoName = program.MainCoin.Algorithm.Name; MinerAlgo algo = null; foreach (MinerAlgo item in MinerAlgos) { if (item.Name == algoName) { algo = item; break; } } if (algo != null) { MinerProgram prog = new MinerProgram(); prog.ProgramType = program.Type; prog.Exepath = program.MinerEXE; prog.ExeFolder = program.MinerFolder; //if a similar type is alredy present, them remove it List <int> removeIds = new List <int>(); int i = 0; foreach (MinerProgram item in algo.MinerPrograms) { if (item.ProgramType == program.Type) { removeIds.Add(i); } i++; } foreach (int j in removeIds) { algo.MinerPrograms.RemoveAt(j); } algo.MinerPrograms.Add(prog); toSave = true; } return(toSave); }
void DownLoadingThread(object obj) { IncrThreadCount(); while (m_keepRunning) { try { m_Downloading = false; if (DownloadingQueue.Count == 0 || m_keepMining == false) { Thread.Sleep(3000); } else { IMinerProgram miner = DownloadingQueue.Dequeue(); m_Downloading = true; miner.DownloadProgram(); m_Downloading = false; if (miner.ReadyForMining()) { MiningQueue.Enqueue(miner); } } } catch (ThreadAbortException e) { Logger.Instance.LogInfo("Downloading Thread has been stopped and will resume again!!"); Thread.ResetAbort(); } catch (Exception e) { Logger.Instance.LogError(e.Message); //if we feel the need to exit when there is an error in miner thread //m_keepRunning = false; } m_Downloading = false; } DecrThreadCount(); }
void MiningThread(object obj) { IncrThreadCount(); while (m_keepRunning)//thread runs as long as app is on { try { if (MiningQueue.Count == 0 || m_keepMining == false) { Thread.Sleep(3000); } else { IMinerProgram miner = MiningQueue.Dequeue(); if (miner.ReadyForMining()) { try { miner.StartMining(); RunningMiners.Add(miner); } catch (Exception e) { Logger.Instance.LogError(e.Message); } } else { DownloadingQueue.Enqueue(miner); } } if (m_keepMining) { try { List <IMinerProgram> stoppedMiners = new List <IMinerProgram>(); //Ensure all started miners are still running for (int i = 0; i < RunningMiners.Count; i++) { IMinerProgram item = RunningMiners[i]; if (!item.Running()) { item.SetRunningState(MinerProgramState.Stopped); //just to be sure. we never want to start miner twice item.KillMiner(); //Dont directly start mining. push it to queue and let the workflow start. also only if mining is stil on if (m_keepMining) { //MessageBox.Show(item.Miner.Name); MiningQueue.Enqueue(item); } stoppedMiners.Add(item); } } //if a miner has stopped, we need to remove it from the running list as anyway it will be added once run foreach (IMinerProgram item in stoppedMiners) { RunningMiners.Remove(item); } } catch (Exception e) { } } else { //Kill all running miners and go to sleep for some time for (int i = 0; i < RunningMiners.Count; i++) { IMinerProgram item = RunningMiners[i]; item.KillMiner(); } RunningMiners.Clear(); } } catch (Exception e) { Logger.Instance.LogError(e.Message); } } DecrThreadCount(); }