public GpuProfileViewModel(IGpuProfile data, GpuViewModel gpuVm) : this() { _coinId = data.CoinId; _index = data.Index; _coreClockDelta = data.CoreClockDelta; _memoryClockDelta = data.MemoryClockDelta; _powerCapacity = data.PowerCapacity; _cool = data.Cool; _gpuVm = gpuVm; }
public GpuProfileViewModel(IGpuProfile data, GpuViewModel gpuVm) : this() { _coinId = data.CoinId; _index = data.Index; _coreClockDelta = data.CoreClockDelta; _memoryClockDelta = data.MemoryClockDelta; _powerCapacity = data.PowerCapacity; _tempLimit = data.TempLimit; _isAutoFanSpeed = data.IsAutoFanSpeed; _cool = data.Cool; _gpuVm = gpuVm; _coreVoltage = data.CoreVoltage; _memoryVoltage = data.MemoryVoltage; }
public GpuProfilesPageViewModel(MinerClientsWindowViewModel minerClientsWindowVm) { _minerClientsWindowVm = minerClientsWindowVm; if (minerClientsWindowVm.SelectedMinerClients == null && minerClientsWindowVm.SelectedMinerClients.Length != 1) { throw new InvalidProgramException(); } _minerClientVm = minerClientsWindowVm.SelectedMinerClients[0]; this.Save = new DelegateCommand(() => { if (_data == null) { return; } GpuProfilesJsonDb jsonObj = new GpuProfilesJsonDb() { Gpus = _data.Gpus }; foreach (var coinVm in CoinVms.MainCoins) { if (coinVm.IsOverClockEnabled) { jsonObj.CoinOverClocks.Add(new CoinOverClockData() { CoinId = coinVm.Id, IsOverClockEnabled = coinVm.IsOverClockEnabled, IsOverClockGpuAll = coinVm.IsOverClockGpuAll }); if (CoinVm.IsOverClockGpuAll) { jsonObj.GpuProfiles.Add(new GpuProfileData(coinVm.GpuAllProfileVm)); } jsonObj.GpuProfiles.AddRange(coinVm.GpuProfileVms.Select(a => new GpuProfileData(a))); } } string json = VirtualRoot.JsonSerializer.Serialize(jsonObj); foreach (var client in minerClientsWindowVm.SelectedMinerClients) { Client.NTMinerDaemonService.SaveGpuProfilesJsonAsync(client.MinerIp, json); } NotiCenterWindowViewModel.Instance.Manager.ShowSuccessMessage("应用成功,请观察效果"); CloseWindow?.Invoke(); }); Client.NTMinerDaemonService.GetGpuProfilesJsonAsync(_minerClientVm.MinerIp, (data, e) => { _data = data; if (e != null) { Write.UserError(e.Message); } else if (data != null) { string iconName; switch (_minerClientVm.GpuType) { case GpuType.NVIDIA: case GpuType.AMD: iconName = "Icon_Nvidia"; GpuIconFill = "Green"; RedText = "超频有风险,操作需谨慎"; IsEnabled = true; break; case GpuType.Empty: default: iconName = "Icon_GpuEmpty"; GpuIconFill = "Gray"; RedText = "没有矿卡或矿卡未驱动"; IsEnabled = false; break; } GpuIcon = (Geometry)System.Windows.Application.Current.Resources[iconName]; foreach (var coinVm in AppContext.Instance.CoinVms.MainCoins) { var coinOverClock = data.CoinOverClocks.FirstOrDefault(a => a.CoinId == coinVm.Id); var gpuProfiles = data.GpuProfiles.Where(a => a.CoinId == coinVm.Id).ToArray(); if (coinOverClock == null) { coinOverClock = new CoinOverClockData() { CoinId = coinVm.Id, IsOverClockEnabled = false, IsOverClockGpuAll = true }; } coinVm.IsOverClockEnabled = coinOverClock.IsOverClockEnabled; coinVm.IsOverClockGpuAll = coinOverClock.IsOverClockGpuAll; List <GpuProfileViewModel> gpuProfileVms = new List <GpuProfileViewModel>(); GpuProfileViewModel gpuAllProfileVm = null; #region foreach (var gpu in data.Gpus.OrderBy(a => a.Index)) { var gpuProfile = gpuProfiles.FirstOrDefault(a => a.Index == gpu.Index); if (gpuProfile == null) { gpuProfile = new GpuProfileData(coinVm.Id, gpu.Index); } var gpuVm = new GpuViewModel(gpu, data.Gpus); if (gpu.Index == NTMinerRoot.GpuAllId) { gpuAllProfileVm = new GpuProfileViewModel(gpuProfile, gpuVm); } else { gpuProfileVms.Add(new GpuProfileViewModel(gpuProfile, gpuVm)); } } if (gpuAllProfileVm == null) { gpuAllProfileVm = new GpuProfileViewModel( new GpuProfileData(coinVm.Id, NTMinerRoot.GpuAllId), new GpuViewModel(new GpuData { Index = NTMinerRoot.GpuAllId, Name = "All" }, data.Gpus)); } #endregion coinVm.GpuAllProfileVm = gpuAllProfileVm; coinVm.GpuProfileVms = gpuProfileVms; } this.CoinVm = CoinVms.MainCoins.FirstOrDefault(a => a.IsOverClockEnabled); if (this.CoinVm == null) { this.CoinVm = CoinVms.MainCoins.FirstOrDefault(); } } }); }
private GpuProfileViewModel GetGpuProfileVm(Guid coinId, GpuViewModel gpuVm) { IGpuProfile data = GpuProfileSet.Instance.GetGpuProfile(coinId, gpuVm.Index); return(new GpuProfileViewModel(data, gpuVm)); }