internal void MinerGPUSerializeToJSON(string _testdatainput)
        {
            var hrpc = new ConcurrentObservableDictionary <Coin, HashRate>()
            {
                { Coin.ETH, new HashRate(20.0,
                                         new TimeSpan(0,
                                                      0,
                                                      1)) }
            };
            VideoCardSignil vcdc = VideoCardsKnown.TuningParameters.Keys.Where(x => (x.VideoCardMaker ==
                                                                                     VideoCardMaker.ASUS &&
                                                                                     x.GPUMaker ==
                                                                                     GPUMaker.NVIDEA))
                                   .Single();
            MinerGPU minerGPU = new MinerGPU(vcdc,
                                             "10DE 17C8 - 3842",
                                             "100.00001.02320.00",
                                             false,
                                             1140,
                                             1753,
                                             11.13,
                                             0.8,
                                             hrpc);
            var str = JsonConvert.SerializeObject(minerGPU);

            str.Should()
            .NotBeNull();
            str.Should()
            .Be(_testdatainput);
        }
        internal void MinerGPUDeSerializeFromJSON(string _testdatainput)
        {
            MinerGPU vc = JsonConvert.DeserializeObject <MinerGPU>(_testdatainput);

            vc.Should()
            .NotBeNull();
            vc.DeviceID.Should()
            .Be("10DE 17C8 - 3842");
            vc.BIOSVersion.Should()
            .Be("100.00001.02320.00");
            vc.HashRatePerCoin.Keys.Contains(Coin.ETH)
            .Should()
            .Be(true);
            vc.HashRatePerCoin[Coin.ETH].HashRatePerTimeSpan.Should()
            .Be(20.0);
        }
        public void AAtest()
        {
            bool   fine                     = false;
            string processName              = "EthDcrMiner64";
            string configFilePath           = @"C:\ProgramData\CryptoCurrency\Ethereum\Claymore's Dual Ethereum+Decred_Siacoin_Lbry_Pascal AMD+NVIDIA GPU Miner v10.2\config.txt";
            bool   hasAPI                   = true;
            bool   hasConfigurationSettings = true;;
            bool   hasERROut                = true;
            bool   hasLogFiles              = true;
            bool   hasSTDOut                = true;
            string logFileFnPattern         = "\\d{10}_log.txt";
            string logFileFolder            = @"C:\ProgramData\CryptoCurrency\Ethereum\Claymore's Dual Ethereum+Decred_Siacoin_Lbry_Pascal AMD+NVIDIA GPU Miner v10.2";;
            string processPath              = @"C:\ProgramData\CryptoCurrency\Ethereum\Claymore's Dual Ethereum+Decred_Siacoin_Lbry_Pascal AMD+NVIDIA GPU Miner v10.2\EthDcrMiner64.exe";
            string processStartPath         = @"C:\ProgramData\CryptoCurrency\Ethereum\Claymore's Dual Ethereum+Decred_Siacoin_Lbry_Pascal AMD+NVIDIA GPU Miner v10.2";
            string version                  = "10.2";

            Coin[] coinsMined = new Coin[2] {
                Coin.ETH, Coin.ZEC
            };
            ConcurrentObservableDictionary <string, string> configurationSettings = new ConcurrentObservableDictionary <string, string>()
            {
                { "mport", "21200" },
                { "epool", "eth-us-east1.nanopool.org:9999" },
                { "epsw", "x" },
                { "ewal", "0xcdac8dea6d3ced686bacc9622fb7f92d29ed8874.ncat-m01/[email protected]" },
                { "esm", "STRATUMTYPE" },
                { "mode", "0" },
                { "dcoin", "sc" },
                { "dpool", "stratum+tcp://sia-us-east1.nanopool.org:7777" },
                { "dwal", "72cb72ceb7b2b6b7a06c3393bdbd2311e180bb14cd629960d5a017d2dc816043be77abf79efe.ncat-m01/[email protected]" },
                { "dpsw", "x" },
                { "dcri", "4" },
                { "allpools", "0" },
                { "ftime", "0" },
                { "tt", "85" },
                { "tstop", "90" },
                //{"di","0" },
                { "asm", "1" },
                { "gser", "2" },
                { "fanmin", "50" },
                { "fanmax", "100" },
                //{"benchmark", "170" },
                { "cclock", "0" },
                { "mclock", "0" },
            };

            VideoCardSignil localcardvcdc = VideoCardsKnown.TuningParameters.Keys.Where(x => (x.VideoCardMaker ==
                                                                                              VideoCardMaker.ASUS &&
                                                                                              x.GPUMaker ==
                                                                                              GPUMaker.NVIDEA))
                                            .Single();
            ConcurrentObservableDictionary <Coin, HashRate> hashRatePerCoin = new ConcurrentObservableDictionary <Coin, HashRate>();
            MinerGPU minerGPU = new MinerGPU(localcardvcdc,
                                             "10DE 17C8 - 3842",
                                             "100.00001.02320.00",
                                             false,
                                             1140,
                                             1753,
                                             11.13,
                                             0.8,
                                             hashRatePerCoin);

            List <TuneMinerGPUsResult> tuneMinerGPUsResultList = new List <TuneMinerGPUsResult>();

            MinerGPU[] minerGPUsToTune = new MinerGPU[1] {
                minerGPU
            };


            // create the collection of MinerSWs to tune
            MinerSW[] minerSWsToTune = new MinerSW[1];
            ClaymoreETHDualMinerSW claymoreETHDualMinerSW = new ClaymoreETHDualMinerSW(processName,
                                                                                       processPath,
                                                                                       processStartPath,
                                                                                       version,
                                                                                       hasConfigurationSettings,
                                                                                       configurationSettings,
                                                                                       configFilePath,
                                                                                       hasLogFiles,
                                                                                       logFileFolder,
                                                                                       logFileFnPattern,
                                                                                       hasAPI,
                                                                                       hasSTDOut,
                                                                                       hasERROut,
                                                                                       coinsMined);

            minerSWsToTune[0] = claymoreETHDualMinerSW;


            foreach (var msw in minerSWsToTune)
            {
                // Move to the directory where this software expects to start
                Directory.SetCurrentDirectory(msw.ProcessStartPath);
                foreach (var mg in minerGPUsToTune)
                {
                    // stop any running instances of this SW
                    Process.GetProcessesByName(msw.ProcessName).ToList().ForEach(x => x.Kill());
                    // Select the tuning strategy for this MinerSW and this VideoCard
                    var vcdc = mg.VideoCardSignil;
                    var vctp = VideoCardsKnown.TuningParameters[vcdc];
                    // Calculate the step for each parameter
                    int memoryClockStep = (vctp.MemoryClockMax - vctp.MemoryClockMin) / (fine ? 1 : 5);
                    int coreClockStep   = (vctp.CoreClockMax - vctp.CoreClockMin) / (fine ? 1 : 5);
                    //double voltageStep = (vctp.VoltageMax - vctp.VoltageMin) / (fine ? 0.01 : 0.05);
                    // memoryClock Min, max, step
                    // CoreClock Min, max, step
                    // memoryVoltage min, max, step
                    int memoryClockTune;
                    int coreClockTune;
                    //double voltageTune = vctp.VoltageMin;
                    ConcurrentObservableDictionary <Coin, HashRate> hashRatePerCoinTune;
                    Power powerConsumptionTune;
                    // ToDo: initialize the structures that monitor for miner SW stopping, or Rig rebooting
                    //while (voltageTune <= vctp.VoltageMax)
                    //{
                    coreClockTune = vctp.CoreClockMin;
                    while (coreClockTune <= vctp.CoreClockMax)
                    {
                        msw.ConfigurationSettings["-cclock"] = coreClockTune.ToString();
                        memoryClockTune = vctp.MemoryClockMin;
                        while (memoryClockTune <= vctp.MemoryClockMax)
                        {
                            msw.ConfigurationSettings["-mclock"] = memoryClockTune.ToString();
                            // Stop the miner software
                            Process.GetProcessesByName(msw.ProcessName).ToList().ForEach(x => x.Kill());
                            // write the MinerSW Configuration to the miner's configuration file
                            //Func<KeyValuePair, string> cfgpair = (x) => $"-{x.Key} {x.Value}";
                            string s = string.Join(Environment.NewLine, msw.ConfigurationSettings.Select(x => $"-{x.Key} {x.Value}"));
                            System.IO.File.WriteAllText(msw.ConfigFilePath, s);
                            // update the structures that monitor for miner SW stopping, or Rig rebooting

                            // Start the miner process
                            var cmd = Command.Run(processPath, new[] { "" }, options: o => o.DisposeOnExit(false));
                            //var outputLines = cmd.StandardOutput.GetLines().ToList();
                            //var errorText = cmd.StandardError.ReadToEnd();
                            // Wait a Delay for the card to settle
                            Task.Delay(new TimeSpan(0, 0, 3));
                            // Get the current HashRate and power consumption
                            //var minerStatus = await StatusFetchAsync();
                            // Dictionary<Coin, HashRate> hashRatesTune = new Dictionary<Coin, HashRate> { { Coin.ETH, new HashRate(1000.0, new TimeSpan(0, 0, 1)) } };
                            //PowerConsumption powerConsumptionTune = new PowerConsumption();
                            // Or Detect a minerSW stoppage or detect a rig reboot
                            // Stop the miner process
                            //cmd.Process.Close(); //todo: figure out DisposeOnExit(false)
                            Process.GetProcessesByName(msw.ProcessName).ToList().ForEach(x => x.Kill());


                            powerConsumptionTune = new Power(1, UnitsNet.Units.PowerUnit.Watt);
                            hashRatePerCoinTune  = new ConcurrentObservableDictionary <Coin, HashRate>();
                            foreach (var k in msw.CoinsMined)
                            {
                                hashRatePerCoinTune[k] = new HashRate(1, new TimeSpan(0, 0, 1));
                            }
                            // Record the results for this combination of msw,mvc,mClock,cClock,and mVoltage
                            tuneMinerGPUsResultList.Add(new TuneMinerGPUsResult(coreClockTune, memoryClockTune, vctp.VoltageDefault, hashRatePerCoinTune, powerConsumptionTune));
                            if (memoryClockTune != vctp.MemoryClockMax)
                            {
                                memoryClockTune += memoryClockStep;
                                memoryClockTune  = memoryClockTune > vctp.MemoryClockMax ? vctp.MemoryClockMax : memoryClockTune;
                            }
                            else
                            {
                                memoryClockTune += 1;
                            }
                        }
                        if (coreClockTune != vctp.CoreClockMax)
                        {
                            coreClockTune += coreClockStep;
                            coreClockTune  = coreClockTune > vctp.CoreClockMax ? vctp.CoreClockMax : coreClockTune;
                        }
                        else
                        {
                            coreClockTune += 1;
                        }
                    }

                    //voltageTune += voltageStep;
                    //voltageTune = voltageTune > vctp.VoltageMax ? vctp.VoltageMax : voltageTune;
                    //}
                }
                // Best hashrate for this MinerSW, by order of coins mined
                //ConcurrentObservableDictionary<Coin, HashRate> bestHashRates
                //var bestMinerGPUResult = tuneMinerGPUsResultList.Max(x => x.HashRates[msw.CoinsMined[0]]);
            }
            //return tuneMinerGPUsResultList;

            Assert.Equal(1, 1);
        }