Skip to content

Commit

Permalink
implemented enum Manufacturer
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Jun 18, 2021
1 parent ebc8899 commit 0394fe8
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions DockerForm/CPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ namespace DockerForm
{
public class CPU
{
public string Name, Manufacturer, MCHBAR;
public enum Manufacturer
{
Intel = 0,
AMD = 1
}

public string Name, MCHBAR;
public Manufacturer Constructor;
private string GetProcessorDetails(string value)
{
ManagementClass managClass = new ManagementClass("win32_processor");
Expand All @@ -25,15 +32,21 @@ private string GetProcessorDetails(string value)
public CPU()
{
Name = GetProcessorDetails("Name");
Manufacturer = GetProcessorDetails("Manufacturer");

switch(GetProcessorDetails("Manufacturer"))
{
case "GenuineIntel":
Constructor = Manufacturer.Intel;
break;
}
}

public void Initialise()
{
if (Manufacturer == "GenuineIntel")
if (Constructor == Manufacturer.Intel)
{
string command = "/Min /Nologo /Stdout /command=\"Delay 1000;rpci32 0 0 0 0x48;Delay 1000;rwexit\"";
using (var ProcessOutput = Process.Start(new ProcessStartInfo(Form1.path_rw, command)
using (var ProcessOutput = Process.Start(new ProcessStartInfo(MainForm.path_rw, command)
{
UseShellExecute = false,
RedirectStandardOutput = true,
Expand Down Expand Up @@ -67,19 +80,19 @@ public void SetPowerProfile(PowerProfile profile)
return;

// skip update on similar profiles
if (Form1.CurrentProfile.Equals(profile))
if (MainForm.CurrentProfile.Equals(profile))
return;

string command = null;
string tool = null;

if (Manufacturer == "GenuineIntel")
if (Constructor == Manufacturer.Intel)
{
// skip if unsupported platform
if (MCHBAR == null || !MCHBAR.Contains("0x"))
return;

tool = Form1.path_rw;
tool = MainForm.path_rw;
command = "/Min /Nologo /Stdout /command=\"Delay 1000;";

if (profile.HasLongPowerMax())
Expand Down Expand Up @@ -112,13 +125,13 @@ public void SetPowerProfile(PowerProfile profile)
}
else
{
tool = Form1.path_ryz;
tool = MainForm.path_ryz;
command = "";

if (profile.HasLongPowerMax())
command += $"--slow-limit={profile.TurboBoostLongPowerMax}1000 --stapm-limit={profile.TurboBoostLongPowerMax}1000 ";
command += $"--slow-limit={profile.TurboBoostLongPowerMax}000 --stapm-limit={profile.TurboBoostLongPowerMax}000 ";
if (profile.HasShortPowerMax())
command += $"--fast-limit={profile.TurboBoostLongPowerMax}1000 ";
command += $"--fast-limit={profile.TurboBoostLongPowerMax}000 ";
}

// execute command
Expand All @@ -137,8 +150,8 @@ public void SetPowerProfile(PowerProfile profile)
Process.Start(PowerProcess);

// update current profile
Form1.CurrentProfile = profile;
Form1.SendNotification($"Power Profile [{profile.GetName()}] applied.", true, true);
MainForm.CurrentProfile = profile;
MainForm.SendNotification($"Power Profile [{profile.GetName()}] applied.", true, true);
}
}
}

0 comments on commit 0394fe8

Please sign in to comment.