コード例 #1
0
ファイル: MainForm.cs プロジェクト: peterwillcn/Avalon-nano
        private void RestartBfgMinerProc(object state)
        {
            SafeCloseBfgMiner();

            _summaryQueue.Clear();
            _currentSummaryResult = null;
            _currentPoolResult = null;

            SafeControlUpdater.Invalidate(pictureBox1);
            SafeControlUpdater.Invalidate(pictureBoxGraph);

            _avalonFloatWindow.CurMHS = 0;

            Thread.Sleep(100);

            RunMinerAndMonitorData();
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: peterwillcn/Avalon-nano
        private void UpdatePoolInfo(PoolResult poolResult)
        {
            if (poolResult == null)
            {
                return;
            }

            Control[] poolStatusIcons = { pictureBoxPoolStatus1, pictureBoxPoolStatus2, pictureBoxPoolStatus3 };

            int i = 0;
            for (; i < poolResult.Pools.Length && i < 3; i++)
            {
                if (poolResult.Pools[i].Status == "Alive")
                {
                    SafeControlUpdater.SetbackgroundImage(poolStatusIcons[i], Resources.online);
                }
                else
                {
                    SafeControlUpdater.SetbackgroundImage(poolStatusIcons[i], Resources.offline);
                }
            }

            SafeControlUpdater.Invalidate(this.pictureBox1);
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: peterwillcn/Avalon-nano
        private bool ParseData(string apiName, string content)
        {
            string[] items = content.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            if (items == null || items.Length < 2)
            {
                return false;
            }

            if (string.Compare(apiName, "summary", true) == 0)
            {
                SummaryResult summary = new SummaryResult();
                summary.Header.Deserialize(items[0]);
                summary.Summary.Deserialize(items[1]);

                if (_summaryQueue.Count > SummaryQueueSize)
                {
                    _summaryQueue.Dequeue();
                }

                _summaryQueue.Enqueue(summary);

                UpdateSummary(summary);

                return true;
            }
            else if (string.Compare(apiName, "pools", true) == 0)
            {
                PoolResult poolResult = new PoolResult();
                poolResult.Header.Deserialize(items[0]);
                int poolSize = items.Length - 1;
                int v = 0;

                if (Int32.TryParse(poolResult.Header.Msg, out v))
                {
                    if (v < poolSize)
                    {
                        poolSize = v;
                    }
                }

                if (poolSize > 0)
                {
                    Pool[] pools = new Pool[poolSize];
                    for (int i = 0; i < poolSize; i++)
                    {
                        Pool pi = new Pool();
                        pi.Deserialize(items[i + 1]);
                        pools[i] = pi;
                    }
                    poolResult.Pools = pools;
                }

                _currentPoolResult = poolResult;

                UpdatePoolInfo(poolResult);

                return true;
            }

            return false;
        }