# HG changeset patch # User moel.mich # Date 1265229310 0 # Node ID 09ab31bee6bd48fb0ff14ed6d33751493dc78750 # Parent 1662dea7a261624b26427327b013b7ca123537c7 Release version 0.1.11. Added support for load percentage sensor type. Added load sensors for CPUs and ATI GPUs. diff -r 1662dea7a261 -r 09ab31bee6bd GUI/HardwareNode.cs --- a/GUI/HardwareNode.cs Wed Feb 03 18:10:11 2010 +0000 +++ b/GUI/HardwareNode.cs Wed Feb 03 20:35:10 2010 +0000 @@ -54,8 +54,9 @@ this.Image = hardware.Icon; typeNodes.Add(new TypeNode(SensorType.Voltage)); - typeNodes.Add(new TypeNode(SensorType.Clock)); + typeNodes.Add(new TypeNode(SensorType.Clock)); typeNodes.Add(new TypeNode(SensorType.Temperature)); + typeNodes.Add(new TypeNode(SensorType.Load)); typeNodes.Add(new TypeNode(SensorType.Fan)); foreach (ISensor sensor in hardware.Sensors) diff -r 1662dea7a261 -r 09ab31bee6bd GUI/MainForm.Designer.cs --- a/GUI/MainForm.Designer.cs Wed Feb 03 18:10:11 2010 +0000 +++ b/GUI/MainForm.Designer.cs Wed Feb 03 20:35:10 2010 +0000 @@ -88,6 +88,7 @@ this.sensorsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.voltMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.clocksMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.loadMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.tempMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.fansMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); @@ -328,9 +329,10 @@ this.voltMenuItem, this.clocksMenuItem, this.tempMenuItem, + this.loadMenuItem, this.fansMenuItem}); this.sensorsToolStripMenuItem.Name = "sensorsToolStripMenuItem"; - this.sensorsToolStripMenuItem.Size = new System.Drawing.Size(114, 22); + this.sensorsToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.sensorsToolStripMenuItem.Text = "Sensors"; // // voltMenuItem @@ -339,7 +341,7 @@ this.voltMenuItem.CheckOnClick = true; this.voltMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.voltMenuItem.Name = "voltMenuItem"; - this.voltMenuItem.Size = new System.Drawing.Size(147, 22); + this.voltMenuItem.Size = new System.Drawing.Size(152, 22); this.voltMenuItem.Text = "Voltages"; this.voltMenuItem.CheckedChanged += new System.EventHandler(this.UpdateSensorTypeChecked); // @@ -349,17 +351,27 @@ this.clocksMenuItem.CheckOnClick = true; this.clocksMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.clocksMenuItem.Name = "clocksMenuItem"; - this.clocksMenuItem.Size = new System.Drawing.Size(147, 22); + this.clocksMenuItem.Size = new System.Drawing.Size(152, 22); this.clocksMenuItem.Text = "Clocks"; this.clocksMenuItem.CheckedChanged += new System.EventHandler(this.UpdateSensorTypeChecked); // + // loadMenuItem + // + this.loadMenuItem.Checked = true; + this.loadMenuItem.CheckOnClick = true; + this.loadMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.loadMenuItem.Name = "loadMenuItem"; + this.loadMenuItem.Size = new System.Drawing.Size(152, 22); + this.loadMenuItem.Text = "Load"; + this.loadMenuItem.CheckedChanged += new System.EventHandler(this.UpdateSensorTypeChecked); + // // tempMenuItem // this.tempMenuItem.Checked = true; this.tempMenuItem.CheckOnClick = true; this.tempMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.tempMenuItem.Name = "tempMenuItem"; - this.tempMenuItem.Size = new System.Drawing.Size(147, 22); + this.tempMenuItem.Size = new System.Drawing.Size(152, 22); this.tempMenuItem.Text = "Temperatures"; this.tempMenuItem.CheckedChanged += new System.EventHandler(this.UpdateSensorTypeChecked); // @@ -369,14 +381,14 @@ this.fansMenuItem.CheckOnClick = true; this.fansMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.fansMenuItem.Name = "fansMenuItem"; - this.fansMenuItem.Size = new System.Drawing.Size(147, 22); + this.fansMenuItem.Size = new System.Drawing.Size(152, 22); this.fansMenuItem.Text = "Fans"; this.fansMenuItem.CheckedChanged += new System.EventHandler(this.UpdateSensorTypeChecked); // // toolStripMenuItem1 // this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(111, 6); + this.toolStripMenuItem1.Size = new System.Drawing.Size(149, 6); // // plotMenuItem // @@ -384,7 +396,7 @@ this.plotMenuItem.CheckOnClick = true; this.plotMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.plotMenuItem.Name = "plotMenuItem"; - this.plotMenuItem.Size = new System.Drawing.Size(114, 22); + this.plotMenuItem.Size = new System.Drawing.Size(152, 22); this.plotMenuItem.Text = "Plot"; this.plotMenuItem.CheckedChanged += new System.EventHandler(this.plotToolStripMenuItem_CheckedChanged); // @@ -400,7 +412,7 @@ // this.hddMenuItem.CheckOnClick = true; this.hddMenuItem.Name = "hddMenuItem"; - this.hddMenuItem.Size = new System.Drawing.Size(141, 22); + this.hddMenuItem.Size = new System.Drawing.Size(152, 22); this.hddMenuItem.Text = "HDD sensors"; this.hddMenuItem.CheckedChanged += new System.EventHandler(this.hddsensorsToolStripMenuItem_CheckedChanged); // @@ -518,6 +530,7 @@ private System.Windows.Forms.ToolStripMenuItem fansMenuItem; private System.Windows.Forms.ToolStripMenuItem voltMenuItem; private System.Windows.Forms.ToolStripMenuItem hddMenuItem; + private System.Windows.Forms.ToolStripMenuItem loadMenuItem; } } diff -r 1662dea7a261 -r 09ab31bee6bd GUI/MainForm.cs --- a/GUI/MainForm.cs Wed Feb 03 18:10:11 2010 +0000 +++ b/GUI/MainForm.cs Wed Feb 03 20:35:10 2010 +0000 @@ -130,6 +130,7 @@ voltMenuItem.Checked = Utilities.Config.Get(voltMenuItem.Name, true); clocksMenuItem.Checked = Utilities.Config.Get(clocksMenuItem.Name, true); + loadMenuItem.Checked = Utilities.Config.Get(loadMenuItem.Name, true); tempMenuItem.Checked = Utilities.Config.Get(tempMenuItem.Name, true); fansMenuItem.Checked = Utilities.Config.Get(fansMenuItem.Name, true); @@ -235,6 +236,7 @@ Utilities.Config.Set(voltMenuItem.Name, voltMenuItem.Checked); Utilities.Config.Set(clocksMenuItem.Name, clocksMenuItem.Checked); + Utilities.Config.Set(loadMenuItem.Name, loadMenuItem.Checked); Utilities.Config.Set(tempMenuItem.Name, tempMenuItem.Checked); Utilities.Config.Set(fansMenuItem.Name, fansMenuItem.Checked); @@ -319,6 +321,7 @@ foreach (HardwareNode node in root.Nodes) { node.SetVisible(SensorType.Voltage, voltMenuItem.Checked); node.SetVisible(SensorType.Clock, clocksMenuItem.Checked); + node.SetVisible(SensorType.Load, loadMenuItem.Checked); node.SetVisible(SensorType.Temperature, tempMenuItem.Checked); node.SetVisible(SensorType.Fan, fansMenuItem.Checked); } diff -r 1662dea7a261 -r 09ab31bee6bd GUI/SensorNode.cs --- a/GUI/SensorNode.cs Wed Feb 03 18:10:11 2010 +0000 +++ b/GUI/SensorNode.cs Wed Feb 03 20:35:10 2010 +0000 @@ -59,6 +59,7 @@ switch (sensor.SensorType) { case SensorType.Voltage: format = "{0:F2} V"; break; case SensorType.Clock: format = "{0:F0} MHz"; break; + case SensorType.Load: format = "{0:F1} %"; break; case SensorType.Temperature: format = "{0:F1} °C"; break; case SensorType.Fan: format = "{0:F0} RPM"; break; } diff -r 1662dea7a261 -r 09ab31bee6bd GUI/TypeNode.cs --- a/GUI/TypeNode.cs Wed Feb 03 18:10:11 2010 +0000 +++ b/GUI/TypeNode.cs Wed Feb 03 20:35:10 2010 +0000 @@ -58,6 +58,10 @@ this.Image = Utilities.EmbeddedResources.GetImage("clock.png"); this.Text = "Clocks"; break; + case SensorType.Load: + this.Image = Utilities.EmbeddedResources.GetImage("load.png"); + this.Text = "Load"; + break; case SensorType.Temperature: this.Image = Utilities.EmbeddedResources.GetImage("temperature.png"); this.Text = "Temperatures"; diff -r 1662dea7a261 -r 09ab31bee6bd Hardware/ATI/ATIGPU.cs --- a/Hardware/ATI/ATIGPU.cs Wed Feb 03 18:10:11 2010 +0000 +++ b/Hardware/ATI/ATIGPU.cs Wed Feb 03 20:35:10 2010 +0000 @@ -53,6 +53,7 @@ private Sensor coreClock; private Sensor memoryClock; private Sensor coreVoltage; + private Sensor coreLoad; private List active = new List(); @@ -74,6 +75,7 @@ this.coreClock = new Sensor("GPU Core", 0, SensorType.Clock, this); this.memoryClock = new Sensor("GPU Memory", 1, SensorType.Clock, this); this.coreVoltage = new Sensor("GPU Core", 0, SensorType.Voltage, this); + this.coreLoad = new Sensor("GPU Core", 0, SensorType.Load, this); Update(); } @@ -130,13 +132,16 @@ coreClock.Value = 0.01f * adlp.EngineClock; memoryClock.Value = 0.01f * adlp.MemoryClock; coreVoltage.Value = 0.001f * adlp.Vddc; + coreLoad.Value = adlp.ActivityPercent; ActivateSensor(coreClock); ActivateSensor(memoryClock); ActivateSensor(coreVoltage); + ActivateSensor(coreLoad); } else { DeactivateSensor(coreClock); DeactivateSensor(memoryClock); DeactivateSensor(coreVoltage); + DeactivateSensor(coreLoad); } } diff -r 1662dea7a261 -r 09ab31bee6bd Hardware/CPU/AMD0FCPU.cs --- a/Hardware/CPU/AMD0FCPU.cs Wed Feb 03 18:10:11 2010 +0000 +++ b/Hardware/CPU/AMD0FCPU.cs Wed Feb 03 20:35:10 2010 +0000 @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Diagnostics; using System.Text; @@ -50,8 +51,15 @@ private uint pciAddress; private Sensor[] coreTemperatures; + private float offset; - private float offset; + private Sensor totalLoad; + private Sensor[] coreLoads; + + private List active = new List(); + + private PerformanceCounter totalLoadCounter; + private PerformanceCounter[] coreLoadCounters; private const ushort PCI_AMD_VENDOR_ID = 0x1022; private const ushort PCI_AMD_0FH_MISCELLANEOUS_DEVICE_ID = 0x1103; @@ -72,6 +80,23 @@ // max two cores coreCount = coreCount > 2 ? 2 : coreCount; + totalLoadCounter = new PerformanceCounter(); + totalLoadCounter.CategoryName = "Processor"; + totalLoadCounter.CounterName = "% Processor Time"; + totalLoadCounter.InstanceName = "_Total"; + totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); + + coreLoadCounters = new PerformanceCounter[coreCount]; + coreLoads = new Sensor[coreCount]; + for (int i = 0; i < coreLoadCounters.Length; i++) { + coreLoadCounters[i] = new PerformanceCounter(); + coreLoadCounters[i].CategoryName = "Processor"; + coreLoadCounters[i].CounterName = "% Processor Time"; + coreLoadCounters[i].InstanceName = i.ToString(); + coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1, + SensorType.Load, this); + } + coreTemperatures = new Sensor[coreCount]; for (int i = 0; i < coreCount; i++) coreTemperatures[i] = @@ -102,9 +127,7 @@ } public ISensor[] Sensors { - get { - return coreTemperatures; - } + get { return active.ToArray(); } } public string GetReport() { @@ -121,16 +144,42 @@ i > 0 ? THERM_SENSE_CORE_SEL_CPU1 : THERM_SENSE_CORE_SEL_CPU0)) { uint value; if (WinRing0.ReadPciConfigDwordEx( - pciAddress, THERMTRIP_STATUS_REGISTER, out value)) - coreTemperatures[i].Value = ((value >> 16) & 0xFF) + offset; + pciAddress, THERMTRIP_STATUS_REGISTER, out value)) { + coreTemperatures[i].Value = ((value >> 16) & 0xFF) + offset; + ActivateSensor(coreTemperatures[i]); + } else { + DeactivateSensor(coreTemperatures[i]); + } } - } + } + + totalLoad.Value = totalLoadCounter.NextValue(); + ActivateSensor(totalLoad); + + for (int i = 0; i < coreLoads.Length; i++) { + coreLoads[i].Value = coreLoadCounters[i].NextValue(); + ActivateSensor(coreLoads[i]); + } } - #pragma warning disable 67 + private void ActivateSensor(Sensor sensor) { + if (!active.Contains(sensor)) { + active.Add(sensor); + if (SensorAdded != null) + SensorAdded(sensor); + } + } + + private void DeactivateSensor(Sensor sensor) { + if (active.Contains(sensor)) { + active.Remove(sensor); + if (SensorRemoved != null) + SensorRemoved(sensor); + } + } + public event SensorEventHandler SensorAdded; public event SensorEventHandler SensorRemoved; - #pragma warning restore 67 } } diff -r 1662dea7a261 -r 09ab31bee6bd Hardware/CPU/AMD10CPU.cs --- a/Hardware/CPU/AMD10CPU.cs Wed Feb 03 18:10:11 2010 +0000 +++ b/Hardware/CPU/AMD10CPU.cs Wed Feb 03 20:35:10 2010 +0000 @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Diagnostics; using System.Text; namespace OpenHardwareMonitor.Hardware.CPU { @@ -49,6 +50,13 @@ private uint pciAddress; private Sensor coreTemperature; + private Sensor totalLoad; + private Sensor[] coreLoads; + + private List active = new List(); + + private PerformanceCounter totalLoadCounter; + private PerformanceCounter[] coreLoadCounters; private const ushort PCI_AMD_VENDOR_ID = 0x1022; private const ushort PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID = 0x1203; @@ -63,6 +71,23 @@ uint coreCount = 1; if (cpuidExtData.GetLength(0) > 8) coreCount = (cpuidExtData[8, 2] & 0xFF) + 1; + + totalLoadCounter = new PerformanceCounter(); + totalLoadCounter.CategoryName = "Processor"; + totalLoadCounter.CounterName = "% Processor Time"; + totalLoadCounter.InstanceName = "_Total"; + totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); + + coreLoadCounters = new PerformanceCounter[coreCount]; + coreLoads = new Sensor[coreCount]; + for (int i = 0; i < coreLoadCounters.Length; i++) { + coreLoadCounters[i] = new PerformanceCounter(); + coreLoadCounters[i].CategoryName = "Processor"; + coreLoadCounters[i].CounterName = "% Processor Time"; + coreLoadCounters[i].InstanceName = i.ToString(); + coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1, + SensorType.Load, this); + } // AMD family 10h processors support only one temperature sensor coreTemperature = new Sensor( @@ -87,9 +112,7 @@ } public ISensor[] Sensors { - get { - return new ISensor[] { coreTemperature }; - } + get { return active.ToArray(); } } public string GetReport() { @@ -102,14 +125,40 @@ uint value; if (WinRing0.ReadPciConfigDwordEx(pciAddress, - REPORTED_TEMPERATURE_CONTROL_REGISTER, out value)) - coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f; + REPORTED_TEMPERATURE_CONTROL_REGISTER, out value)) { + coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f; + ActivateSensor(coreTemperature); + } else { + DeactivateSensor(coreTemperature); + } + + totalLoad.Value = totalLoadCounter.NextValue(); + ActivateSensor(totalLoad); + + for (int i = 0; i < coreLoads.Length; i++) { + coreLoads[i].Value = coreLoadCounters[i].NextValue(); + ActivateSensor(coreLoads[i]); + } } - #pragma warning disable 67 + private void ActivateSensor(Sensor sensor) { + if (!active.Contains(sensor)) { + active.Add(sensor); + if (SensorAdded != null) + SensorAdded(sensor); + } + } + + private void DeactivateSensor(Sensor sensor) { + if (active.Contains(sensor)) { + active.Remove(sensor); + if (SensorRemoved != null) + SensorRemoved(sensor); + } + } + public event SensorEventHandler SensorAdded; public event SensorEventHandler SensorRemoved; - #pragma warning restore 67 } } diff -r 1662dea7a261 -r 09ab31bee6bd Hardware/CPU/IntelCPU.cs --- a/Hardware/CPU/IntelCPU.cs Wed Feb 03 18:10:11 2010 +0000 +++ b/Hardware/CPU/IntelCPU.cs Wed Feb 03 20:35:10 2010 +0000 @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Diagnostics; using System.Reflection; using System.Text; @@ -48,12 +49,19 @@ private Image icon; private Sensor[] coreTemperatures; + private Sensor totalLoad; + private Sensor[] coreLoads; + + private List active = new List(); private float tjMax = 0; private uint logicalProcessors; private uint logicalProcessorsPerCore; private uint coreCount; + private PerformanceCounter totalLoadCounter; + private PerformanceCounter[] coreLoadCounters; + private const uint IA32_THERM_STATUS_MSR = 0x019C; private const uint IA32_TEMPERATURE_TARGET = 0x01A2; @@ -125,11 +133,29 @@ default: tjMax = 100; break; } + totalLoadCounter = new PerformanceCounter(); + totalLoadCounter.CategoryName = "Processor"; + totalLoadCounter.CounterName = "% Processor Time"; + totalLoadCounter.InstanceName = "_Total"; + totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); + + coreLoadCounters = new PerformanceCounter[ + coreCount * logicalProcessorsPerCore]; + for (int i = 0; i < coreLoadCounters.Length; i++) { + coreLoadCounters[i] = new PerformanceCounter(); + coreLoadCounters[i].CategoryName = "Processor"; + coreLoadCounters[i].CounterName = "% Processor Time"; + coreLoadCounters[i].InstanceName = i.ToString(); + } + coreTemperatures = new Sensor[coreCount]; - for (int i = 0; i < coreTemperatures.Length; i++) - coreTemperatures[i] = - new Sensor("Core #" + (i + 1), i, tjMax, SensorType.Temperature, - this); + coreLoads = new Sensor[coreCount]; + for (int i = 0; i < coreTemperatures.Length; i++) { + coreTemperatures[i] = new Sensor("Core #" + (i + 1), i, tjMax, + SensorType.Temperature, this); + coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1, + SensorType.Load, this); + } Update(); } @@ -147,9 +173,7 @@ } public ISensor[] Sensors { - get { - return coreTemperatures; - } + get { return active.ToArray(); } } public string GetReport() { @@ -180,14 +204,44 @@ if ((eax & 0x80000000) != 0) { // get the dist from tjMax from bits 22:16 coreTemperatures[i].Value = tjMax - ((eax & 0x007F0000) >> 16); + ActivateSensor(coreTemperatures[i]); + } else { + DeactivateSensor(coreTemperatures[i]); } } - } + } + + totalLoad.Value = totalLoadCounter.NextValue(); + ActivateSensor(totalLoad); + + for (int i = 0; i < coreLoads.Length; i++) { + float value = 0; + for (int j = 0; j < logicalProcessorsPerCore; j++) + value += coreLoadCounters[ + logicalProcessorsPerCore * i + j].NextValue(); + value /= logicalProcessorsPerCore; + coreLoads[i].Value = value; + ActivateSensor(coreLoads[i]); + } } - #pragma warning disable 67 + private void ActivateSensor(Sensor sensor) { + if (!active.Contains(sensor)) { + active.Add(sensor); + if (SensorAdded != null) + SensorAdded(sensor); + } + } + + private void DeactivateSensor(Sensor sensor) { + if (active.Contains(sensor)) { + active.Remove(sensor); + if (SensorRemoved != null) + SensorRemoved(sensor); + } + } + public event SensorEventHandler SensorAdded; public event SensorEventHandler SensorRemoved; - #pragma warning restore 67 } } diff -r 1662dea7a261 -r 09ab31bee6bd Hardware/ISensor.cs --- a/Hardware/ISensor.cs Wed Feb 03 18:10:11 2010 +0000 +++ b/Hardware/ISensor.cs Wed Feb 03 20:35:10 2010 +0000 @@ -42,8 +42,9 @@ public enum SensorType { Voltage, - Clock, + Clock, Temperature, + Load, Fan } diff -r 1662dea7a261 -r 09ab31bee6bd OpenHardwareMonitor.csproj --- a/OpenHardwareMonitor.csproj Wed Feb 03 18:10:11 2010 +0000 +++ b/OpenHardwareMonitor.csproj Wed Feb 03 20:35:10 2010 +0000 @@ -4,7 +4,7 @@ Debug AnyCPU {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880} - 9.0.21022 + 9.0.30729 2.0 WinExe false @@ -135,6 +135,7 @@ + diff -r 1662dea7a261 -r 09ab31bee6bd Properties/AssemblyInfo.cs --- a/Properties/AssemblyInfo.cs Wed Feb 03 18:10:11 2010 +0000 +++ b/Properties/AssemblyInfo.cs Wed Feb 03 20:35:10 2010 +0000 @@ -69,5 +69,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.10.0")] -[assembly: AssemblyFileVersion("0.1.10.0")] +[assembly: AssemblyVersion("0.1.11.0")] +[assembly: AssemblyFileVersion("0.1.11.0")] diff -r 1662dea7a261 -r 09ab31bee6bd Resources/load.png Binary file Resources/load.png has changed