GameObject CloneNewInstance(GameObject prefab, PoolSet pooledSet, Vector3 position, Quaternion rotation) { // Initialized a new GameObject GameObject returnObject = (GameObject)Instantiate(prefab, position, rotation); // Update this object's parent so it won't get destroyed easily returnObject.transform.parent = poolingParent; // Grab the script from the clone if there is any in the original IPooledObject script = null; if (pooledSet.containsPoolScript == true) { script = returnObject.GetComponent <IPooledObject>(); script.OriginalPrefab = prefab; } // Add this new GameObject and script into the dictionary pooledSet.allClonedInstances.Add(returnObject, script); // Indicate to the script the object was initialized if (script != null) { script.Initialized(this); } return(returnObject); }
//location chosen void OnLocChosen(object sender, EventArgs args) { Picker modePicker = (Picker)sender; mode = modePicker.SelectedItem.ToString(); rolePicker.IsEnabled = false; rolePicker.ItemsSource = null; rolePicker.Items.Clear(); Character temp = _viewModel.DatasetCharacter.FirstOrDefault(a => a.Id == player); List <Item> templist; CurrentItem.Text = temp.GetItemAtLocation((ItemLocationEnum)Enum.Parse(typeof(ItemLocationEnum), mode)); LocationSet.Clear(); PoolSet = PoolSet.Where(a => a != null).ToList(); if (mode == ItemLocationEnum.LeftFinger.ToString() || mode == ItemLocationEnum.RightFinger.ToString()) { templist = PoolSet.FindAll(a => a.Location.ToString() == mode || a.Location.ToString() == "Finger"); } else { templist = PoolSet.FindAll(a => a.Location.ToString() == mode); } foreach (var data in templist) { LocationSet.Add(data); } rolePicker.ItemsSource = LocationSet; rolePicker.IsEnabled = true; }
public GameObject GetInstance(GameObject prefab, Vector3 position, Quaternion rotation) { // Cover the edge case GameObject returnObject = null; if (prefab != null) { // Check if the prefab is already pooled if (allPooledObjects.ContainsKey(prefab) == true) { // Grab the pooled objects PoolSet pooledSet = allPooledObjects[prefab]; // Check if there are any deactivated objects foreach (KeyValuePair <GameObject, IPooledObject> cloneInstance in pooledSet.allClonedInstances) { if (cloneInstance.Key.activeSelf == false) { // If so, position this object properly returnObject = cloneInstance.Key; Transform cloneTransform = returnObject.transform; cloneTransform.position = position; cloneTransform.rotation = rotation; // Activate this object and return it returnObject.SetActive(true); // If this set has a script, indicate this GameObject was activated if (cloneInstance.Value != null) { cloneInstance.Value.Activated(this); } break; } } // If not, initialize a new object if (returnObject == null) { // Initialized a new GameObject returnObject = CloneNewInstance(prefab, pooledSet, position, rotation); } } else { // Create a new entry in the dictionary PoolSet pooledSet = new PoolSet(prefab); allPooledObjects.Add(prefab, pooledSet); // Initialized a new GameObject returnObject = CloneNewInstance(prefab, pooledSet, position, rotation); } } return(returnObject); }
//remove item private async void RemoveItems_Command(object sender, EventArgs e) { var movitem = _viewModel.DatasetCharacter.FirstOrDefault(a => a.Id == player).RemoveItem((ItemLocationEnum)Enum.Parse(typeof(ItemLocationEnum), mode)); PoolSet.Add(movitem); _viewModel.Dataset.Add(movitem); _viewModel.clean(); CurrentItem.Text = _viewModel.DatasetCharacter.FirstOrDefault(a => a.Id == player).GetItemAtLocation((ItemLocationEnum)Enum.Parse(typeof(ItemLocationEnum), mode)); RemoveItem.IsEnabled = true; }
//items select void OnItemChosen(object sender, EventArgs args) { Picker picker = (Picker)sender; Item temp = (Item)picker.SelectedItem; if (temp == null) { return; } var movitem = _viewModel.DatasetCharacter.FirstOrDefault(a => a.Id == player).RemoveItem((ItemLocationEnum)Enum.Parse(typeof(ItemLocationEnum), mode)); PoolSet.Add(movitem); _viewModel.Dataset.Add(movitem); _viewModel.DatasetCharacter.FirstOrDefault(a => a.Id == player).AddItem((ItemLocationEnum)Enum.Parse(typeof(ItemLocationEnum), mode), temp.Id); PoolSet.Remove(temp); _viewModel.Dataset.Remove(temp); _viewModel.clean(); PoolSet = PoolSet.Where(x => x != null).ToList(); CurrentItem.Text = _viewModel.DatasetCharacter.FirstOrDefault(a => a.Id == player).GetItemAtLocation((ItemLocationEnum)Enum.Parse(typeof(ItemLocationEnum), mode)); RemoveItem.IsEnabled = true; }
public static IPool StartWach(PoolSet ps) { if (ps != null) { if (ps.Pool != null && ps.Coin != null) { switch (ps.Pool) { case PoolType.Bitfly: return(new Bitfly(ps.Coin.Value, ps.Wallet)); case PoolType._2Miners: return(new _2Miners(ps.Coin.Value, ps.Wallet)); default: return(null); } } return(null); } else { return(null); } }
public string BuildAssembleArgs(out Dictionary <string, string> parameters, out Dictionary <Guid, string> fileWriters, out Dictionary <Guid, string> fragments) { parameters = new Dictionary <string, string>(); fileWriters = new Dictionary <Guid, string>(); fragments = new Dictionary <Guid, string>(); if (!CoinSet.TryGetCoin(this.MinerProfile.CoinId, out ICoin mainCoin)) { return(string.Empty); } ICoinProfile coinProfile = this.MinerProfile.GetCoinProfile(mainCoin.GetId()); if (!PoolSet.TryGetPool(coinProfile.PoolId, out IPool mainCoinPool)) { return(string.Empty); } if (!CoinKernelSet.TryGetCoinKernel(coinProfile.CoinKernelId, out ICoinKernel coinKernel)) { return(string.Empty); } if (!KernelSet.TryGetKernel(coinKernel.KernelId, out IKernel kernel)) { return(string.Empty); } if (!kernel.IsSupported(mainCoin)) { return(string.Empty); } if (!KernelInputSet.TryGetKernelInput(kernel.KernelInputId, out IKernelInput kernelInput)) { return(string.Empty); } ICoinKernelProfile coinKernelProfile = this.MinerProfile.GetCoinKernelProfile(coinProfile.CoinKernelId); string poolKernelArgs = string.Empty; IPoolKernel poolKernel = PoolKernelSet.FirstOrDefault(a => a.PoolId == mainCoinPool.GetId() && a.KernelId == kernel.GetId()); if (poolKernel != null) { poolKernelArgs = poolKernel.Args; } string kernelArgs = kernelInput.Args; string coinKernelArgs = coinKernel.Args; string customArgs = coinKernelProfile.CustomArgs; parameters.Add("mainCoin", mainCoin.Code); if (mainCoinPool.IsUserMode) { IPoolProfile poolProfile = MinerProfile.GetPoolProfile(mainCoinPool.GetId()); string password = poolProfile.Password; if (string.IsNullOrEmpty(password)) { password = "******"; } parameters.Add("userName", poolProfile.UserName); parameters.Add("password", password); } else { parameters.Add("wallet", coinProfile.Wallet); } parameters.Add("host", mainCoinPool.GetHost()); parameters.Add("port", mainCoinPool.GetPort().ToString()); parameters.Add("pool", mainCoinPool.Server); parameters.Add("worker", this.MinerProfile.MinerName); if (coinKernel.IsSupportPool1) { parameters.Add("worker1", this.MinerProfile.MinerName); if (PoolSet.TryGetPool(coinProfile.PoolId1, out IPool mainCoinPool1)) { parameters.Add("host1", mainCoinPool1.GetHost()); parameters.Add("port1", mainCoinPool1.GetPort().ToString()); parameters.Add("pool1", mainCoinPool1.Server); if (mainCoinPool1.IsUserMode) { IPoolProfile poolProfile1 = MinerProfile.GetPoolProfile(mainCoinPool1.GetId()); string password1 = poolProfile1.Password; if (string.IsNullOrEmpty(password1)) { password1 = "x"; } parameters.Add("userName1", poolProfile1.UserName); parameters.Add("password1", password1); } else { parameters.Add("wallet1", coinProfile.Wallet); } } } // 这里不要考虑{logfile},{logfile}往后推迟 if (coinKernelProfile.IsDualCoinEnabled && kernelInput.IsSupportDualMine) { Guid dualCoinGroupId = coinKernel.DualCoinGroupId; if (dualCoinGroupId == Guid.Empty) { dualCoinGroupId = kernelInput.DualCoinGroupId; } if (dualCoinGroupId != Guid.Empty) { if (this.CoinSet.TryGetCoin(coinKernelProfile.DualCoinId, out ICoin dualCoin)) { ICoinProfile dualCoinProfile = this.MinerProfile.GetCoinProfile(dualCoin.GetId()); if (PoolSet.TryGetPool(dualCoinProfile.DualCoinPoolId, out IPool dualCoinPool)) { IPoolProfile dualPoolProfile = MinerProfile.GetPoolProfile(dualCoinPool.GetId()); string dualPassword = dualPoolProfile.Password; if (string.IsNullOrEmpty(dualPassword)) { dualPassword = "******"; } parameters.Add("dualCoin", dualCoin.Code); parameters.Add("dualWallet", dualCoinProfile.DualCoinWallet); parameters.Add("dualUserName", dualPoolProfile.UserName); parameters.Add("dualPassword", dualPassword); parameters.Add("dualHost", dualCoinPool.GetHost()); parameters.Add("dualPort", dualCoinPool.GetPort().ToString()); parameters.Add("dualPool", dualCoinPool.Server); kernelArgs = kernelInput.DualFullArgs; AssembleArgs(parameters, ref kernelArgs, isDual: true); AssembleArgs(parameters, ref poolKernelArgs, isDual: true); AssembleArgs(parameters, ref customArgs, isDual: true); string dualWeightArg; if (!string.IsNullOrEmpty(kernelInput.DualWeightArg)) { if (coinKernelProfile.IsAutoDualWeight && kernelInput.IsAutoDualWeight) { dualWeightArg = string.Empty; } else { dualWeightArg = $"{kernelInput.DualWeightArg} {Convert.ToInt32(coinKernelProfile.DualCoinWeight)}"; } } else { dualWeightArg = string.Empty; } StringBuilder dualSb = new StringBuilder(); dualSb.Append(kernelArgs); if (!string.IsNullOrEmpty(dualWeightArg)) { dualSb.Append(" ").Append(dualWeightArg); } if (!string.IsNullOrEmpty(poolKernelArgs)) { dualSb.Append(" ").Append(poolKernelArgs); } BuildFragments(coinKernel, parameters, out fileWriters, out fragments); foreach (var fragment in fragments.Values) { dualSb.Append(" ").Append(fragment); } if (!string.IsNullOrEmpty(customArgs)) { dualSb.Append(" ").Append(customArgs); } // 注意:这里退出 return(dualSb.ToString()); } } } } AssembleArgs(parameters, ref kernelArgs, isDual: false); AssembleArgs(parameters, ref coinKernelArgs, isDual: false); AssembleArgs(parameters, ref poolKernelArgs, isDual: false); AssembleArgs(parameters, ref customArgs, isDual: false); string devicesArgs = string.Empty; if (!string.IsNullOrWhiteSpace(kernelInput.DevicesArg)) { List <int> useDevices = this.GpuSet.GetUseDevices(); if (useDevices.Count != 0 && useDevices.Count != GpuSet.Count) { string separator = kernelInput.DevicesSeparator; if (kernelInput.DevicesSeparator == "space") { separator = " "; } if (string.IsNullOrEmpty(separator)) { List <string> gpuIndexes = new List <string>(); foreach (var index in useDevices) { int i = index; if (kernelInput.DeviceBaseIndex != 0) { i = index + kernelInput.DeviceBaseIndex; } if (i > 9) { gpuIndexes.Add(gpuIndexChars[i - 10]); } else { gpuIndexes.Add(i.ToString()); } } devicesArgs = $"{kernelInput.DevicesArg} {string.Join(separator, gpuIndexes)}"; } else { devicesArgs = $"{kernelInput.DevicesArg} {string.Join(separator, useDevices)}"; } } } StringBuilder sb = new StringBuilder(); sb.Append(kernelArgs); if (!string.IsNullOrEmpty(coinKernelArgs)) { sb.Append(" ").Append(coinKernelArgs); } if (!string.IsNullOrEmpty(poolKernelArgs)) { sb.Append(" ").Append(poolKernelArgs); } if (!string.IsNullOrEmpty(devicesArgs)) { sb.Append(" ").Append(devicesArgs); } BuildFragments(coinKernel, parameters, out fileWriters, out fragments); foreach (var fragment in fragments.Values) { sb.Append(" ").Append(fragment); } if (!string.IsNullOrEmpty(customArgs)) { sb.Append(" ").Append(customArgs); } return(sb.ToString()); }
public string BuildAssembleArgs() { if (!CoinSet.TryGetCoin(this.MinerProfile.CoinId, out ICoin mainCoin)) { return(string.Empty); } ICoinProfile coinProfile = this.MinerProfile.GetCoinProfile(mainCoin.GetId()); if (!PoolSet.TryGetPool(coinProfile.PoolId, out IPool mainCoinPool)) { return(string.Empty); } if (!CoinKernelSet.TryGetCoinKernel(coinProfile.CoinKernelId, out ICoinKernel coinKernel)) { return(string.Empty); } if (!KernelSet.TryGetKernel(coinKernel.KernelId, out IKernel kernel)) { return(string.Empty); } if (!kernel.IsSupported(mainCoin)) { return(string.Empty); } if (!KernelInputSet.TryGetKernelInput(kernel.KernelInputId, out IKernelInput kernelInput)) { return(string.Empty); } ICoinKernelProfile coinKernelProfile = this.MinerProfile.GetCoinKernelProfile(coinProfile.CoinKernelId); string wallet = coinProfile.Wallet; string pool = mainCoinPool.Server; string poolKernelArgs = string.Empty; IPoolKernel poolKernel = PoolKernelSet.FirstOrDefault(a => a.PoolId == mainCoinPool.GetId() && a.KernelId == kernel.GetId()); if (poolKernel != null) { poolKernelArgs = poolKernel.Args; } IPoolProfile poolProfile = MinerProfile.GetPoolProfile(mainCoinPool.GetId()); string userName = poolProfile.UserName; string password = poolProfile.Password; if (string.IsNullOrEmpty(password)) { password = "******"; } string kernelArgs = kernelInput.Args; string coinKernelArgs = coinKernel.Args; string customArgs = coinKernelProfile.CustomArgs; var argsDic = new Dictionary <string, string> { { "mainCoin", mainCoin.Code }, { "wallet", wallet }, { "userName", userName }, { "password", password }, { "host", mainCoinPool.GetHost() }, { "port", mainCoinPool.GetPort().ToString() }, { "pool", pool }, { "worker", this.MinerProfile.MinerName } };// 这里不要考虑{logfile},{logfile}往后推迟 if (coinKernelProfile.IsDualCoinEnabled && kernelInput.IsSupportDualMine) { Guid dualCoinGroupId = coinKernel.DualCoinGroupId; if (dualCoinGroupId == Guid.Empty) { dualCoinGroupId = kernelInput.DualCoinGroupId; } if (dualCoinGroupId != Guid.Empty) { if (this.CoinSet.TryGetCoin(coinKernelProfile.DualCoinId, out ICoin dualCoin)) { ICoinProfile dualCoinProfile = this.MinerProfile.GetCoinProfile(dualCoin.GetId()); if (PoolSet.TryGetPool(dualCoinProfile.DualCoinPoolId, out IPool dualCoinPool)) { string dualWallet = dualCoinProfile.DualCoinWallet; string dualPool = dualCoinPool.Server; IPoolProfile dualPoolProfile = MinerProfile.GetPoolProfile(dualCoinPool.GetId()); string dualUserName = dualPoolProfile.UserName; string dualPassword = dualPoolProfile.Password; if (string.IsNullOrEmpty(dualPassword)) { dualPassword = "******"; } argsDic.Add("dualCoin", dualCoin.Code); argsDic.Add("dualAlgo", dualCoin.Algo); argsDic.Add("dualWallet", dualWallet); argsDic.Add("dualUserName", dualUserName); argsDic.Add("dualPassword", dualPassword); argsDic.Add("dualHost", dualCoinPool.GetHost()); argsDic.Add("dualPort", dualCoinPool.GetPort().ToString()); argsDic.Add("dualPool", dualPool); kernelArgs = kernelInput.DualFullArgs; AssembleArgs(argsDic, ref kernelArgs, isDual: true); AssembleArgs(argsDic, ref poolKernelArgs, isDual: true); AssembleArgs(argsDic, ref customArgs, isDual: true); string dualWeightArg; if (!string.IsNullOrEmpty(kernelInput.DualWeightArg)) { if (coinKernelProfile.IsAutoDualWeight && kernelInput.IsAutoDualWeight) { dualWeightArg = string.Empty; } else { dualWeightArg = $"{kernelInput.DualWeightArg} {Convert.ToInt32(coinKernelProfile.DualCoinWeight)}"; } } else { dualWeightArg = string.Empty; } return($"{kernelArgs} {dualWeightArg} {poolKernelArgs} {customArgs}"); } } } } AssembleArgs(argsDic, ref kernelArgs, isDual: false); AssembleArgs(argsDic, ref coinKernelArgs, isDual: false); AssembleArgs(argsDic, ref poolKernelArgs, isDual: false); AssembleArgs(argsDic, ref customArgs, isDual: false); string devicesArgs = string.Empty; if (!string.IsNullOrWhiteSpace(kernelInput.DevicesArg)) { List <int> useDevices = GetUseDevices(); if (useDevices.Count != 0 && useDevices.Count != GpuSet.Count) { string separator = kernelInput.DevicesSeparator; if (kernelInput.DevicesSeparator == "space") { separator = " "; } if (string.IsNullOrEmpty(separator)) { List <string> gpuIndexes = new List <string>(); foreach (var index in useDevices) { int i = index; if (kernelInput.DeviceBaseIndex != 0) { i = index + kernelInput.DeviceBaseIndex; } if (i > 9) { gpuIndexes.Add(gpuIndexChars[i - 10]); } else { gpuIndexes.Add(i.ToString()); } } devicesArgs = $"{kernelInput.DevicesArg} {string.Join(separator, gpuIndexes)}"; } else { devicesArgs = $"{kernelInput.DevicesArg} {string.Join(separator, useDevices)}"; } } } StringBuilder sb = new StringBuilder(); sb.Append(kernelArgs); if (!string.IsNullOrEmpty(coinKernelArgs)) { sb.Append(" ").Append(coinKernelArgs); } if (!string.IsNullOrEmpty(poolKernelArgs)) { sb.Append(" ").Append(poolKernelArgs); } if (!string.IsNullOrEmpty(devicesArgs)) { sb.Append(" ").Append(devicesArgs); } if (!string.IsNullOrEmpty(customArgs)) { sb.Append(" ").Append(customArgs); } return(sb.ToString()); }
public string BuildAssembleArgs(out Dictionary <string, string> parameters, out Dictionary <Guid, string> fileWriters, out Dictionary <Guid, string> fragments) { parameters = new Dictionary <string, string>(); fileWriters = new Dictionary <Guid, string>(); fragments = new Dictionary <Guid, string>(); if (!CoinSet.TryGetCoin(this.MinerProfile.CoinId, out ICoin mainCoin)) { return(string.Empty); } ICoinProfile coinProfile = this.MinerProfile.GetCoinProfile(mainCoin.GetId()); if (!PoolSet.TryGetPool(coinProfile.PoolId, out IPool mainCoinPool)) { return(string.Empty); } if (!CoinKernelSet.TryGetCoinKernel(coinProfile.CoinKernelId, out ICoinKernel coinKernel)) { return(string.Empty); } if (!KernelSet.TryGetKernel(coinKernel.KernelId, out IKernel kernel)) { return(string.Empty); } if (!kernel.IsSupported(mainCoin)) { return(string.Empty); } if (!KernelInputSet.TryGetKernelInput(kernel.KernelInputId, out IKernelInput kernelInput)) { return(string.Empty); } ICoinKernelProfile coinKernelProfile = this.MinerProfile.GetCoinKernelProfile(coinProfile.CoinKernelId); string poolKernelArgs = string.Empty; IPoolKernel poolKernel = PoolKernelSet.FirstOrDefault(a => a.PoolId == mainCoinPool.GetId() && a.KernelId == kernel.GetId()); if (poolKernel != null) { poolKernelArgs = poolKernel.Args; } string kernelArgs = kernelInput.Args; string coinKernelArgs = coinKernel.Args; string customArgs = coinKernelProfile.CustomArgs ?? string.Empty; parameters.Add(Consts.MainCoinParameterName, mainCoin.Code); if (mainCoinPool.IsUserMode) { IPoolProfile poolProfile = MinerProfile.GetPoolProfile(mainCoinPool.GetId()); string password = poolProfile.Password; if (string.IsNullOrEmpty(password)) { password = Consts.PasswordDefaultValue; } parameters.Add(Consts.UserNameParameterName, poolProfile.UserName); parameters.Add(Consts.PasswordParameterName, password); parameters.Add(Consts.WalletParameterName, poolProfile.UserName); } else { parameters.Add(Consts.WalletParameterName, coinProfile.Wallet); } parameters.Add(Consts.HostParameterName, mainCoinPool.GetHost()); parameters.Add(Consts.PortParameterName, mainCoinPool.GetPort().ToString()); parameters.Add(Consts.PoolParameterName, mainCoinPool.Server); string minerName = $"{mainCoinPool.MinerNamePrefix}{this.MinerProfile.MinerName}{mainCoinPool.MinerNamePostfix}"; parameters.Add(Consts.WorkerParameterName, minerName); if (coinKernel.IsSupportPool1 && !mainCoinPool.NoPool1) { parameters.Add(Consts.Worker1ParameterName, minerName); if (PoolSet.TryGetPool(coinProfile.PoolId1, out IPool mainCoinPool1)) { parameters.Add(Consts.Host1ParameterName, mainCoinPool1.GetHost()); parameters.Add(Consts.Port1ParameterName, mainCoinPool1.GetPort().ToString()); parameters.Add(Consts.Pool1ParameterName, mainCoinPool1.Server); if (mainCoinPool1.IsUserMode) { IPoolProfile poolProfile1 = MinerProfile.GetPoolProfile(mainCoinPool1.GetId()); string password1 = poolProfile1.Password; if (string.IsNullOrEmpty(password1)) { password1 = Consts.PasswordDefaultValue; } parameters.Add(Consts.UserName1ParameterName, poolProfile1.UserName); parameters.Add(Consts.Password1ParameterName, password1); } else { parameters.Add(Consts.Wallet1ParameterName, coinProfile.Wallet); } } } string devicesArgs = GetDevicesArgs(kernelInput); // 这里不要考虑{logfile},{logfile}往后推迟 if (coinKernelProfile.IsDualCoinEnabled && kernelInput.IsSupportDualMine) { Guid dualCoinGroupId = coinKernel.DualCoinGroupId; if (dualCoinGroupId != Guid.Empty) { if (this.CoinSet.TryGetCoin(coinKernelProfile.DualCoinId, out ICoin dualCoin)) { ICoinProfile dualCoinProfile = this.MinerProfile.GetCoinProfile(dualCoin.GetId()); if (PoolSet.TryGetPool(dualCoinProfile.DualCoinPoolId, out IPool dualCoinPool)) { IPoolProfile dualPoolProfile = MinerProfile.GetPoolProfile(dualCoinPool.GetId()); string dualPassword = dualPoolProfile.Password; if (string.IsNullOrEmpty(dualPassword)) { dualPassword = Consts.PasswordDefaultValue; } parameters.Add(Consts.DualCoinParameterName, dualCoin.Code); parameters.Add(Consts.DualWalletParameterName, dualCoinProfile.DualCoinWallet); parameters.Add(Consts.DualUserNameParameterName, dualPoolProfile.UserName); parameters.Add(Consts.DualPasswordParameterName, dualPassword); parameters.Add(Consts.DualHostParameterName, dualCoinPool.GetHost()); parameters.Add(Consts.DualPortParameterName, dualCoinPool.GetPort().ToString()); parameters.Add(Consts.DualPoolParameterName, dualCoinPool.Server); kernelArgs = coinKernel.DualFullArgs; AssembleArgs(parameters, ref kernelArgs, isDual: true); AssembleArgs(parameters, ref poolKernelArgs, isDual: true); AssembleArgs(parameters, ref customArgs, isDual: true); string dualWeightArg; if (!string.IsNullOrEmpty(kernelInput.DualWeightArg)) { if (coinKernelProfile.IsAutoDualWeight && kernelInput.IsAutoDualWeight) { dualWeightArg = string.Empty; } else { dualWeightArg = $"{kernelInput.DualWeightArg} {Convert.ToInt32(coinKernelProfile.DualCoinWeight)}"; } } else { dualWeightArg = string.Empty; } StringBuilder dualSb = new StringBuilder(); dualSb.Append(kernelArgs); if (!string.IsNullOrEmpty(dualWeightArg)) { dualSb.Append(" ").Append(dualWeightArg); } if (!string.IsNullOrEmpty(poolKernelArgs)) { dualSb.Append(" ").Append(poolKernelArgs); } BuildFragments(coinKernel, parameters, out fileWriters, out fragments); foreach (var fragment in fragments.Values) { dualSb.Append(" ").Append(fragment); } if (!string.IsNullOrEmpty(customArgs)) { dualSb.Append(" ").Append(customArgs); } if (!string.IsNullOrEmpty(devicesArgs)) { dualSb.Append(" ").Append(devicesArgs); } // 注意:这里退出 return(dualSb.ToString()); } } } } AssembleArgs(parameters, ref kernelArgs, isDual: false); AssembleArgs(parameters, ref coinKernelArgs, isDual: false); AssembleArgs(parameters, ref poolKernelArgs, isDual: false); AssembleArgs(parameters, ref customArgs, isDual: false); StringBuilder sb = new StringBuilder(); sb.Append(kernelArgs); if (!string.IsNullOrEmpty(coinKernelArgs)) { sb.Append(" ").Append(coinKernelArgs); } if (!string.IsNullOrEmpty(poolKernelArgs)) { sb.Append(" ").Append(poolKernelArgs); } if (!string.IsNullOrEmpty(devicesArgs)) { sb.Append(" ").Append(devicesArgs); } BuildFragments(coinKernel, parameters, out fileWriters, out fragments); foreach (var fragment in fragments.Values) { sb.Append(" ").Append(fragment); } if (!string.IsNullOrEmpty(customArgs)) { sb.Append(" ").Append(customArgs); } return(sb.ToString()); }
public string BuildAssembleArgs() { ICoin mainCoin; if (!CoinSet.TryGetCoin(this.MinerProfile.CoinId, out mainCoin)) { return(string.Empty); } ICoinProfile coinProfile = this.CoinProfileSet.GetCoinProfile(mainCoin.GetId()); IPool mainCoinPool; if (!PoolSet.TryGetPool(coinProfile.PoolId, out mainCoinPool)) { return(string.Empty); } ICoinKernel coinKernel; if (!CoinKernelSet.TryGetKernel(coinProfile.CoinKernelId, out coinKernel)) { return(string.Empty); } IKernel kernel; if (!KernelSet.TryGetKernel(coinKernel.KernelId, out kernel)) { return(string.Empty); } if (!kernel.IsSupported()) { return(string.Empty); } ICoinKernelProfile coinKernelProfile = this.CoinKernelProfileSet.GetCoinKernelProfile(coinProfile.CoinKernelId); string wallet = coinProfile.Wallet; string pool = mainCoinPool.Server; string kernelArgs = kernel.Args; string coinKernelArgs = coinKernel.Args; string customArgs = coinKernelProfile.CustomArgs; var argsDic = new Dictionary <string, string> { { "mainCoin", mainCoin.Code }, { "mainAlgo", mainCoin.Algo }, { "wallet", wallet }, { "host", mainCoinPool.GetHost() }, { "port", mainCoinPool.GetPort().ToString() }, { "pool", pool }, { "worker", this.MinerProfile.MinerName } };// 这里不要考虑{logfile},{logfile}往后推迟 if (coinKernelProfile.IsDualCoinEnabled) { Guid dualCoinGroupId = coinKernel.DualCoinGroupId; if (dualCoinGroupId == Guid.Empty) { dualCoinGroupId = kernel.DualCoinGroupId; } if (dualCoinGroupId != Guid.Empty) { ICoin dualCoin; if (this.CoinSet.TryGetCoin(coinKernelProfile.DualCoinId, out dualCoin)) { ICoinProfile dualCoinProfile = this.CoinProfileSet.GetCoinProfile(dualCoin.GetId()); IPool dualCoinPool; if (PoolSet.TryGetPool(dualCoinProfile.DualCoinPoolId, out dualCoinPool)) { string dualWallet = dualCoinProfile.DualCoinWallet; string dualPool = dualCoinPool.Server; argsDic.Add("dualCoin", dualCoin.Code); argsDic.Add("dualAlgo", dualCoin.Algo); argsDic.Add("dualWallet", dualWallet); argsDic.Add("dualHost", dualCoinPool.GetHost()); argsDic.Add("dualPort", dualCoinPool.GetPort().ToString()); argsDic.Add("dualPool", dualPool); kernelArgs = kernel.DualFullArgs; AssembleArgs(argsDic, ref kernelArgs, isDual: true); AssembleArgs(argsDic, ref customArgs, isDual: true); string dualWeightArg; if (!string.IsNullOrEmpty(kernel.DualWeightArg)) { if (coinKernelProfile.IsAutoDualWeight && kernel.IsAutoDualWeight) { dualWeightArg = string.Empty; } else { dualWeightArg = $"{kernel.DualWeightArg} {Convert.ToInt32(coinKernelProfile.DualCoinWeight)}"; } } else { dualWeightArg = string.Empty; } return($"{kernelArgs} {dualWeightArg} {customArgs}"); } } } } AssembleArgs(argsDic, ref kernelArgs, isDual: false); AssembleArgs(argsDic, ref coinKernelArgs, isDual: false); AssembleArgs(argsDic, ref customArgs, isDual: false); return($"{kernelArgs} {coinKernelArgs} {customArgs}"); }