diff --git a/LenovoFanManagementApp/DellFanManagementGuiForm.Designer.cs b/LenovoFanManagementApp/DellFanManagementGuiForm.Designer.cs index 4a5d88d..a6c3118 100644 --- a/LenovoFanManagementApp/DellFanManagementGuiForm.Designer.cs +++ b/LenovoFanManagementApp/DellFanManagementGuiForm.Designer.cs @@ -113,6 +113,7 @@ private void InitializeComponent() this.chargeStopControlCheckBox = new System.Windows.Forms.CheckBox(); this.chargeStartControlCheckBox = new System.Windows.Forms.CheckBox(); this.limitFrequencyGroupBox = new System.Windows.Forms.GroupBox(); + this.activePowerPlanLabel = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); @@ -1088,6 +1089,7 @@ private void InitializeComponent() // // limitFrequencyGroupBox // + this.limitFrequencyGroupBox.Controls.Add(this.activePowerPlanLabel); this.limitFrequencyGroupBox.Controls.Add(this.label12); this.limitFrequencyGroupBox.Controls.Add(this.label10); this.limitFrequencyGroupBox.Controls.Add(this.label11); @@ -1106,7 +1108,18 @@ private void InitializeComponent() this.limitFrequencyGroupBox.Size = new System.Drawing.Size(661, 116); this.limitFrequencyGroupBox.TabIndex = 19; this.limitFrequencyGroupBox.TabStop = false; - this.limitFrequencyGroupBox.Text = "限制CPU频率(当前电源计划)"; + this.limitFrequencyGroupBox.Text = "限制CPU频率 "; + // + // activePowerPlanLabel + // + this.activePowerPlanLabel.AutoSize = true; + this.activePowerPlanLabel.Location = new System.Drawing.Point(138, 0); + this.activePowerPlanLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.activePowerPlanLabel.Name = "activePowerPlanLabel"; + this.activePowerPlanLabel.Size = new System.Drawing.Size(177, 28); + this.activePowerPlanLabel.TabIndex = 18; + this.activePowerPlanLabel.Text = "(当前电源计划: )"; + this.activePowerPlanLabel.Click += new System.EventHandler(this.label2_Click); // // label12 // @@ -1439,6 +1452,7 @@ private void InitializeComponent() private System.Windows.Forms.RadioButton operationModeRadioButtonCustom; private System.Windows.Forms.Button editFanButton; private System.Windows.Forms.CheckBox logCheckBox; + private System.Windows.Forms.Label activePowerPlanLabel; } } diff --git a/LenovoFanManagementApp/DellFanManagementGuiForm.cs b/LenovoFanManagementApp/DellFanManagementGuiForm.cs index 9fd2a4f..58b222a 100644 --- a/LenovoFanManagementApp/DellFanManagementGuiForm.cs +++ b/LenovoFanManagementApp/DellFanManagementGuiForm.cs @@ -80,6 +80,8 @@ public partial class DellFanManagementGuiForm : Form private int _prevStartChargeIndex; private int _prevStopChargeIndex; + private Guid _activePlan; + /// /// Constructor. Get everything set up before the window is displayed. /// @@ -455,9 +457,7 @@ private void ApplyConfiguration() DCCpuFreqTextBox.Text = DCCpuFreq.ToString(); } - // Power schemes /* - Guid activePlan = PowerManager.GetActivePlan(); List plans = PowerManager.ListPlans(); for (int i = 0; i < plans.Count; i++) { @@ -845,6 +845,23 @@ public void UpdateForm() } } + // Power schemes (Always monitoring current actived power scheme) + Guid activePlan = PowerManager.GetActivePlan(); + if (activePlan != _activePlan) + { + _activePlan = activePlan; + activePowerPlanLabel.Text = "(当前电源计划:" + PowerManager.GetPlanName(activePlan) + ")"; + uint acFreqMax = PowerManager.GetPlanSetting(activePlan, SettingSubgroup.PROCESSOR_SETTINGS_SUBGROUP, Setting.PROCFREQMAX, PowerMode.AC); + uint dcFreqMax = PowerManager.GetPlanSetting(activePlan, SettingSubgroup.PROCESSOR_SETTINGS_SUBGROUP, Setting.PROCFREQMAX, PowerMode.DC); + uint acFreqMax1 = PowerManager.GetPlanSetting(activePlan, SettingSubgroup.PROCESSOR_SETTINGS_SUBGROUP, Setting.PROCFREQMAX1, PowerMode.AC); + uint dcFreqMax1 = PowerManager.GetPlanSetting(activePlan, SettingSubgroup.PROCESSOR_SETTINGS_SUBGROUP, Setting.PROCFREQMAX1, PowerMode.DC); + + ACCpuFreqTextBox.Text = acFreqMax.ToString(); + ACCpuFreq1TextBox.Text = acFreqMax1.ToString(); + DCCpuFreqTextBox.Text = dcFreqMax.ToString(); + DCCpuFreq1TextBox.Text = dcFreqMax1.ToString(); + } + _state.Release(); if (bringBackAudioDevice != null) @@ -1279,6 +1296,7 @@ private void ApplyCpuFreqButtonClickedEventHandler(Object sender, EventArgs e) try { // P-cores + /* Process p = new Process(); p.StartInfo.FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "powercfg.exe"); p.StartInfo.Arguments = " /setDCvalueindex scheme_current SUB_PROCESSOR PROCFREQMAX1 " + (DCCpuFreq1TextBox.Text == "" ? "0" : DCCpuFreq1TextBox.Text); @@ -1311,6 +1329,17 @@ private void ApplyCpuFreqButtonClickedEventHandler(Object sender, EventArgs e) p.Start(); p.WaitForExit(); p.Close(); + */ + Guid activePlan = PowerManager.GetActivePlan(); + uint acFreq1 = (ACCpuFreq1TextBox.Text == "") ? 0 : uint.Parse(ACCpuFreq1TextBox.Text); + uint dcFreq1 = (DCCpuFreq1TextBox.Text == "") ? 0 : uint.Parse(DCCpuFreq1TextBox.Text); + uint acFreq = (ACCpuFreqTextBox.Text == "") ? 0 : uint.Parse(ACCpuFreqTextBox.Text); + uint dcFreq = (DCCpuFreqTextBox.Text == "") ? 0 : uint.Parse(DCCpuFreqTextBox.Text); + PowerManager.SetPlanSetting(activePlan, SettingSubgroup.PROCESSOR_SETTINGS_SUBGROUP, Setting.PROCFREQMAX1, PowerMode.AC, acFreq1); + PowerManager.SetPlanSetting(activePlan, SettingSubgroup.PROCESSOR_SETTINGS_SUBGROUP, Setting.PROCFREQMAX1, PowerMode.DC, dcFreq1); + PowerManager.SetPlanSetting(activePlan, SettingSubgroup.PROCESSOR_SETTINGS_SUBGROUP, Setting.PROCFREQMAX, PowerMode.AC, acFreq); + PowerManager.SetPlanSetting(activePlan, SettingSubgroup.PROCESSOR_SETTINGS_SUBGROUP, Setting.PROCFREQMAX, PowerMode.DC, dcFreq); + PowerManager.SetActivePlan(activePlan); bool success = int.TryParse(ACCpuFreq1TextBox.Text, out int ACCpuFreq1); //if (success) diff --git a/PowerManagerAPI/SettingIdLookup.cs b/PowerManagerAPI/SettingIdLookup.cs index 790ca10..d4390da 100644 --- a/PowerManagerAPI/SettingIdLookup.cs +++ b/PowerManagerAPI/SettingIdLookup.cs @@ -45,6 +45,7 @@ public enum Setting DISKIDLE, ASPM, PROCFREQMAX, + PROCFREQMAX1, PROCTHROTTLEMAX, PROCTHROTTLEMIN, SYSCOOLPOL, @@ -83,7 +84,8 @@ public static class SettingIdLookup { Setting.UIBUTTON_ACTION, new Guid("a7066653-8d6c-40a8-910e-a1f54b84c7e5") }, { Setting.DISKIDLE, new Guid("6738e2c4-e8a5-4a42-b16a-e040e769756e") }, { Setting.ASPM, new Guid("ee12f906-d277-404b-b6da-e5fa1a576df5") }, - { Setting.PROCFREQMAX, new Guid("75b0ae3f-bce0-45a7-8c89-c9611c25e100") }, + { Setting.PROCFREQMAX, new Guid("75b0ae3f-bce0-45a7-8c89-c9611c25e100") }, // E-Core + { Setting.PROCFREQMAX1, new Guid("75b0ae3f-bce0-45a7-8c89-c9611c25e101") }, // P-Core { Setting.PROCTHROTTLEMAX, new Guid("bc5038f7-23e0-4960-96da-33abaf5935ec") }, { Setting.PROCTHROTTLEMIN, new Guid("893dee8e-2bef-41e0-89c6-b55d0929964c") }, { Setting.SYSCOOLPOL, new Guid("94d3a615-a899-4ac5-ae2b-e4d8f634367f") },