public void GetIndexCharTest() { List <string> chars1 = new List <string>(); List <string> chars2 = new List <string>(); for (int i = 0; i < 12; i++) { chars1.Add(NTKeyword.GetIndexChar(i, string.Empty)); chars2.Add(NTKeyword.GetIndexChar(i, ",")); } Assert.AreEqual("0123456789ab", string.Join(string.Empty, chars1)); Assert.AreEqual("0,1,2,3,4,5,6,7,8,9,10,11", string.Join(",", chars2)); }
private static string GetDevicesArgs(IKernelInput kernelInput) { INTMinerContext ntminerContext = NTMinerContext.Instance; var gpuSet = ntminerContext.GpuSet; string devicesArgs = string.Empty; if (!string.IsNullOrWhiteSpace(kernelInput.DevicesArg)) { int[] useDevices = gpuSet.GetUseDevices(); if ((useDevices.Length != 0 && useDevices.Length != gpuSet.Count) || kernelInput.IsDeviceAllNotEqualsNone) { string separator = kernelInput.DevicesSeparator; // 因为空格在界面上不易被人读取所以以关键字代替空格 if (kernelInput.DevicesSeparator == NTKeyword.SpaceKeyword) { separator = " "; } List <string> gpuIndexes = new List <string>(); foreach (var index in useDevices) { int i = index; if (kernelInput.DeviceBaseIndex != 0) { i = index + kernelInput.DeviceBaseIndex; } string nText = NTKeyword.GetIndexChar(i, separator); gpuIndexes.Add(nText); } switch (gpuSet.GpuType) { case GpuType.Empty: break; case GpuType.NVIDIA: devicesArgs = $"{kernelInput.DevicesArg} {string.Join(separator, gpuIndexes.Select(a => $"{kernelInput.NDevicePrefix}{a}{kernelInput.NDevicePostfix}"))}"; break; case GpuType.AMD: devicesArgs = $"{kernelInput.DevicesArg} {string.Join(separator, gpuIndexes.Select(a => $"{kernelInput.ADevicePrefix}{a}{kernelInput.ADevicePostfix}"))}"; break; default: break; } } } return(devicesArgs); }