Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 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);
     }
 }
Esempio n. 4
0
 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();
     }
 }
Esempio n. 5
0
        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);
                }
            }
        }
Esempio n. 6
0
 public void AddMinerScript(IMinerProgram program, IMiner miner)
 {
     try
     {
         if (Data.AddMinerScript(program, miner))
         {
             Save();
         }
     }
     catch (Exception e)
     {
     }
 }
Esempio n. 7
0
 public void AddMinerProgram(IMinerProgram program)
 {
     try
     {
         if (Data.AddMinerProgram(program))
         {
             Save();
         }
     }
     catch (Exception e)
     {
     }
 }
Esempio n. 8
0
 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)
     {
     }
 }
Esempio n. 9
0
 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();
     }
 }
Esempio n. 10
0
 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)
     {
     }
 }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
                }
            }
        }
Esempio n. 13
0
 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)
     {
     }
 }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
 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();
 }
Esempio n. 16
0
 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();
 }