示例#1
0
            public override void Read()
            {
                try
                {
                    CGMinerCommandOutputs output = new CGMinerCommandOutputs();
                    string        result         = "";
                    TcpReaderUtil util           = new TcpReaderUtil(StatsLink, StatsPort);
                    result         = util.GetData("{\"command\":\"summary\"}");
                    output.Summary = result;

                    result      = util.GetData("{\"command\":\"devs\"}");
                    output.Devs = result;

                    result            = util.GetData("{\"command\":\"devdetails\"}");
                    output.Devdetails = result;

                    string str = new JavaScriptSerializer().Serialize(output);


                    NextLog = str;
                }
                catch (Exception e)
                {
                    throw;
                }
            }
示例#2
0
                public bool Parse(object obj)
                {
                    Succeeded     = false;
                    m_CgminerData = obj as CGMinerCommandOutputs;
                    try
                    {
                        if (m_CgminerData == null)
                        {
                            return(false);
                        }
                        m_MinerResult      = new MinerDataResult();
                        m_MinerResult.GPUs = new List <GpuData>();
                        try
                        {
                            string content = m_CgminerData.Summary.Replace(" ", "");
                            Logger.Instance.LogInfo("CGMiner summary: " + content);

                            content = content.Substring(0, content.Length - 1);
                            SummaryRoot minerResult = (SummaryRoot) new JavaScriptSerializer().Deserialize(content, typeof(SummaryRoot));
                            m_MinerResult.TotalHashrate  = (int)minerResult.SUMMARY[0].MHS5s;
                            m_MinerResult.TotalHashrate *= 1000;
                            m_MinerResult.TotalShares    = (int)minerResult.SUMMARY[0].Accepted;
                            m_MinerResult.Rejected       = (int)minerResult.SUMMARY[0].Rejected;
                            Logger.Instance.LogInfo("CCMiner TotalHashrate: " + m_MinerResult.TotalHashrate.ToString());
                        }
                        catch (Exception e)
                        {
                        }
                        //now read gpus from dev

                        try
                        {
                            string content = m_CgminerData.Devs.Replace(" ", "");
                            content = content.Substring(0, content.Length - 1);

                            RootObject minerResult = (RootObject) new JavaScriptSerializer().Deserialize(content, typeof(RootObject));
                            foreach (DEV item in minerResult.DEVS)
                            {
                                GpuData gpu = new GpuData("AMD GPU " + item.GPU.ToString()); //Todo: finfing the name has proven difficult
                                gpu.Make        = CardMake.Amd;
                                gpu.Hashrate    = (item.MHS5s * 1000).ToString();            //convert to Khs
                                gpu.Temperature = item.Temperature.ToString() + "C";
                                m_MinerResult.GPUs.Add(gpu);
                                Logger.Instance.LogInfo("GPU " + gpu.Hashrate.ToString());
                            }
                        }
                        catch (Exception e)
                        {
                        }
                        m_CgminerData.MinerDataResult = m_MinerResult;
                        return(true);
                    }
                    catch (Exception e)
                    {
                        Succeeded = false;
                    }
                    return(false);
                }
示例#3
0
 public override void Parse()
 {
     try
     {
         CGMinerCommandOutputs minerResult = (CGMinerCommandOutputs) new JavaScriptSerializer().Deserialize(LastLog, typeof(CGMinerCommandOutputs));
         if (minerResult != null)
         {
             if (minerResult.Parse(new CGMinerResultParser(LastLog, ReReadGpuNames)))
             {
                 MinerResult = minerResult.MinerDataResult;
             }
         }
     }
     catch (Exception e)
     {
     }
     ReReadGpuNames = false;
 }