Exemplo n.º 1
0
 public override void OnBlockEntityTransformBeforeActivated(WorldBase _world, Vector3i _blockPos, int _cIdx, BlockValue _blockValue, BlockEntityData _ebcd)
 {
     this.shape.OnBlockEntityTransformBeforeActivated(_world, _blockPos, _cIdx, _blockValue, _ebcd);
     DebugMsg("BlockMiner.OnBlockEntityTransformBeforeActivated");
     try
     {
         if (_ebcd != null && _ebcd.bHasTransform)
         {
             GameObject   gameObject = _ebcd.transform.gameObject;
             MinerControl healingPodControlScript = gameObject.GetComponent <MinerControl>();
             if (healingPodControlScript == null)
             {
                 healingPodControlScript = gameObject.AddComponent <MinerControl>();
             }
             healingPodControlScript.enabled     = true;
             healingPodControlScript.cIdx        = _cIdx;
             healingPodControlScript.blockPos    = _blockPos;
             healingPodControlScript.soundStart  = soundStart;
             healingPodControlScript.soundRepeat = soundRepeat;
             healingPodControlScript.soundEnd    = soundEnd;
         }
         else
         {
             DebugMsg("ERROR: _ebcd null (BlockMiner.OnBlockEntityTransformBeforeActivated)");
         }
     }
     catch (Exception ex)
     {
         DebugMsg("Error Message: " + ex.ToString());
     }
 }
Exemplo n.º 2
0
        public void TestKillProcess()
        {
            string  path = "C:\\SoftwareMiner\\CryptoDredge_0.9.3\\start-BCD-bcd-zpool.bat";
            Process _runningMinerProcess;
            var     startInfo = new ProcessStartInfo();

            startInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(path);
            startInfo.CreateNoWindow   = false;
            startInfo.UseShellExecute  = true;
            //        startInfo.RedirectStandardOutput = false;
            startInfo.FileName   = path;
            _runningMinerProcess = System.Diagnostics.Process.Start(startInfo);
            string message = DateTime.Now.ToString("yyyy-MM-dd HH':'mm") + " start " + path;

            EasyLog.Log(@"c:\\Log\\minerlog.txt", message);
            System.Threading.Thread.Sleep(10000);
            if (_runningMinerProcess != null)
            {
                MinerControl.KillProcessAndChildrens(_runningMinerProcess.Id);
                message = DateTime.Now.ToString("yyyy-MM-dd HH':'mm") + " stop " + _runningMinerProcess.StartInfo.FileName;
                EasyLog.Log(@"c:\\Log\\minerlog.txt", message);
                _runningMinerProcess = null;
            }
            Assert.AreEqual(null, _runningMinerProcess);
        }
Exemplo n.º 3
0
        public void TestGetBestAlgorPrice()
        {
            string                 json   = System.IO.File.ReadAllText("miner.json");
            MinerModel             miners = JsonConvert.DeserializeObject <MinerModel>(json);
            List <AlgorithmResult> algors = new List <AlgorithmResult>();
            List <KeyValuePair <string, string> > paths = new List <KeyValuePair <string, string> >();
            AlgorithmResult algorX17 = new AlgorithmResult();

            algorX17.name             = "x17";
            algorX17.Pool             = PoolName.Zpool;
            algorX17.estimate_current = 600;
            algorX17.estimate_last24h = 700;
            algors.Add(algorX17);

            AlgorithmResult algorSkein = new AlgorithmResult();

            algorSkein.name             = "skein";
            algorSkein.Pool             = PoolName.Zpool;
            algorSkein.estimate_current = 500;
            algorSkein.estimate_last24h = 400;
            algors.Add(algorSkein);

            paths.Add(new KeyValuePair <string, string>("x17@zpool", "c:\\miner\\start-t-rex.bat"));
            miners.Path = paths;
            string algorAtPool;
            double price;

            (algorAtPool, price) = MinerControl.FindBestPrice(algors, true, miners);
            Assert.AreEqual(0, String.Compare("x17@zpool", algorAtPool, true));
        }
Exemplo n.º 4
0
        public void TestDoMining()
        {
            List <AlgorithmResult> algors = new List <AlgorithmResult>();
            List <KeyValuePair <string, string> > paths = new List <KeyValuePair <string, string> >();
            string          json     = System.IO.File.ReadAllText("miner.json");
            MinerModel      miners   = JsonConvert.DeserializeObject <MinerModel>(json);
            AlgorithmResult algorX17 = new AlgorithmResult();

            algorX17.name             = "x17";
            algorX17.Pool             = PoolName.Zpool;
            algorX17.estimate_current = 600;
            algorX17.estimate_last24h = 700;
            algors.Add(algorX17);

            AlgorithmResult algorSkein = new AlgorithmResult();

            algorSkein.name             = "skein";
            algorSkein.Pool             = PoolName.Zpool;
            algorSkein.estimate_current = 500;
            algorSkein.estimate_last24h = 400;
            algors.Add(algorSkein);

            paths.Add(new KeyValuePair <string, string>("x17@zpool", "C:\\SoftwareMiner\\CryptoDredge_0.9.3\\start-BCD-bcd-zpool.bat"));
            miners.Path = paths;
            string bestAlgorAtPool;
            double bestPrice;

            (bestAlgorAtPool, bestPrice) = MinerControl.FindBestPrice(algors, true, miners);


            MinerControl.DoMining(bestAlgorAtPool, miners.Path);

            System.Threading.Thread.Sleep(12000);

            AlgorithmResult algorNewGreater = new AlgorithmResult();

            algorNewGreater.name             = "skein";
            algorNewGreater.Pool             = PoolName.Zpool;
            algorNewGreater.estimate_current = 1000;
            algorNewGreater.estimate_last24h = 1000;
            algors.Add(algorNewGreater);

            (bestAlgorAtPool, bestPrice) = MinerControl.FindBestPrice(algors, true, miners);
            MinerControl.DoMining(bestAlgorAtPool, miners.Path);

            Assert.AreEqual(true, miners.SwapTime > 0);
        }
Exemplo n.º 5
0
        private static void DoMining()
        {
            string bestAlgor      = "";
            string bestCoin       = "";
            double bestAlgorPrice = 0;
            double bestCoinPrice  = 0;

            try
            {
                (bestAlgor, bestAlgorPrice) = MinerControl.FindBestPrice(_algorsResult, true, _miners);
                (bestCoin, bestCoinPrice)   = MinerControl.FindBestPrice(_coinsResult, _miners);
                if (bestAlgorPrice > bestCoinPrice)
                {
                    if (MinerControl.DoMining(bestAlgor, _miners.Path))
                    {
                        Console.WriteLine($"Start mining {bestAlgor} estimate {bestAlgorPrice} per day.");
                    }
                    else
                    {
                        Console.WriteLine($"Warning: Found best algor {bestAlgor} but not found miner config.");
                    }
                }
                else
                {
                    if (MinerControl.DoMining(bestCoin, _miners.Path))
                    {
                        Console.WriteLine($"Start mining {bestCoin} estimate {bestCoinPrice} per day.");
                    }
                    else
                    {
                        Console.WriteLine($"Warning: Found best coin {bestCoin} but not found miner config.");
                    }
                }
            }
            catch (Exception err)
            {
                Console.WriteLine($"Error : Can not start mining {bestAlgor} estimate {bestAlgorPrice} per day.");
                Console.WriteLine($"Error : {err.Message}. Error detail : {err.InnerException.Message}");
                Console.WriteLine();
                Console.WriteLine("Press Enter to exit.");
                Console.ReadLine();
                System.Environment.Exit(-1);
            }
        }