# HG changeset patch # User moel.mich # Date 1267286117 0 # Node ID 1a7c13ac7348534a51bad912fc9a4e6cbcc88590 # Parent 5400e3e383f7dbf03a0766522bce541e09b5b883 Added support for sensor parameters. Fixed Core and Thread count detection for Intel Core i7 CPUs with disabled HyperThreading. diff -r 5400e3e383f7 -r 1a7c13ac7348 GUI/AboutBox.Designer.cs --- a/GUI/AboutBox.Designer.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/GUI/AboutBox.Designer.cs Sat Feb 27 15:55:17 2010 +0000 @@ -122,9 +122,9 @@ this.label3.Location = new System.Drawing.Point(86, 36); this.label3.Margin = new System.Windows.Forms.Padding(12, 0, 12, 0); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(99, 15); + this.label3.Size = new System.Drawing.Size(132, 15); this.label3.TabIndex = 4; - this.label3.Text = "Version " + System.Windows.Forms.Application.ProductVersion + " Beta"; + this.label3.Text = "Version 9.0.30729.1 Beta"; // // label4 // @@ -189,6 +189,7 @@ this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "AboutBox"; + this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "About"; ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); diff -r 5400e3e383f7 -r 1a7c13ac7348 GUI/MainForm.Designer.cs --- a/GUI/MainForm.Designer.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/GUI/MainForm.Designer.cs Sat Feb 27 15:55:17 2010 +0000 @@ -103,12 +103,12 @@ this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.timer = new System.Windows.Forms.Timer(this.components); this.splitContainer = new System.Windows.Forms.SplitContainer(); + this.plotPanel = new OpenHardwareMonitor.GUI.PlotPanel(); this.notifyContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.restoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); this.exitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.sensorContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); - this.plotPanel = new OpenHardwareMonitor.GUI.PlotPanel(); this.columnsContextMenuStrip.SuspendLayout(); this.menuStrip.SuspendLayout(); this.splitContainer.Panel1.SuspendLayout(); @@ -148,6 +148,7 @@ this.treeView.TabIndex = 0; this.treeView.Text = "treeView"; this.treeView.UseColumns = true; + this.treeView.NodeMouseDoubleClick += new System.EventHandler(this.treeView_NodeMouseDoubleClick); this.treeView.Click += new System.EventHandler(this.treeView_Click); // // sensor @@ -501,6 +502,16 @@ this.splitContainer.SplitterWidth = 3; this.splitContainer.TabIndex = 3; // + // plotPanel + // + this.plotPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.plotPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.plotPanel.Font = new System.Drawing.Font("Segoe UI", 9F); + this.plotPanel.Location = new System.Drawing.Point(0, 0); + this.plotPanel.Name = "plotPanel"; + this.plotPanel.Size = new System.Drawing.Size(478, 198); + this.plotPanel.TabIndex = 0; + // // notifyContextMenuStrip // this.notifyContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -535,16 +546,6 @@ this.sensorContextMenuStrip.Name = "sensorContextMenuStrip"; this.sensorContextMenuStrip.Size = new System.Drawing.Size(61, 4); // - // plotPanel - // - this.plotPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.plotPanel.Dock = System.Windows.Forms.DockStyle.Fill; - this.plotPanel.Font = new System.Drawing.Font("Segoe UI", 9F); - this.plotPanel.Location = new System.Drawing.Point(0, 0); - this.plotPanel.Name = "plotPanel"; - this.plotPanel.Size = new System.Drawing.Size(478, 198); - this.plotPanel.TabIndex = 0; - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); diff -r 5400e3e383f7 -r 1a7c13ac7348 GUI/MainForm.cs --- a/GUI/MainForm.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/GUI/MainForm.cs Sat Feb 27 15:55:17 2010 +0000 @@ -63,7 +63,7 @@ InitializeComponent(); this.Font = SystemFonts.MessageBoxFont; treeView.Font = SystemFonts.MessageBoxFont; - plotPanel.Font = SystemFonts.MessageBoxFont; + plotPanel.Font = SystemFonts.MessageBoxFont; nodeCheckBox.IsVisibleValueNeeded += new EventHandler( @@ -320,6 +320,13 @@ if (node != null && node.Sensor != null) { sensorContextMenuStrip.Items.Clear(); + if (node.Sensor.Parameters.Length > 0) { + ToolStripMenuItem item = new ToolStripMenuItem("Parameters..."); + item.Click += delegate(object obj, EventArgs args) { + ShowParameterForm(node.Sensor); + }; + sensorContextMenuStrip.Items.Add(item); + } if (sensorSystemTray.Contains(node.Sensor)) { ToolStripMenuItem item = new ToolStripMenuItem("Remove From Tray"); item.Click += delegate(object obj, EventArgs args) { @@ -398,5 +405,21 @@ sensorSystemTray.Remove(sensor); } + + private void ShowParameterForm(ISensor sensor) { + ParameterForm form = new ParameterForm(); + form.Parameters = sensor.Parameters; + form.captionLabel.Text = sensor.Name; + form.ShowDialog(); + } + + private void treeView_NodeMouseDoubleClick(object sender, + TreeNodeAdvMouseEventArgs e) { + SensorNode node = e.Node.Tag as SensorNode; + if (node != null && node.Sensor != null && + node.Sensor.Parameters.Length > 0) { + ShowParameterForm(node.Sensor); + } + } } } diff -r 5400e3e383f7 -r 1a7c13ac7348 GUI/ParameterForm.Designer.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GUI/ParameterForm.Designer.cs Sat Feb 27 15:55:17 2010 +0000 @@ -0,0 +1,188 @@ +namespace OpenHardwareMonitor.GUI { + partial class ParameterForm { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + this.okButton = new System.Windows.Forms.Button(); + this.cancelButton = new System.Windows.Forms.Button(); + this.captionLabel = new System.Windows.Forms.Label(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Default = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.ValueColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.bindingSource = new System.Windows.Forms.BindingSource(this.components); + this.descriptionLabel = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit(); + this.SuspendLayout(); + // + // okButton + // + this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.okButton.Location = new System.Drawing.Point(186, 213); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(75, 23); + this.okButton.TabIndex = 2; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // cancelButton + // + this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(267, 213); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(75, 23); + this.cancelButton.TabIndex = 3; + this.cancelButton.Text = "Canel"; + this.cancelButton.UseVisualStyleBackColor = true; + // + // captionLabel + // + this.captionLabel.AutoSize = true; + this.captionLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.captionLabel.Location = new System.Drawing.Point(12, 9); + this.captionLabel.Name = "captionLabel"; + this.captionLabel.Size = new System.Drawing.Size(80, 13); + this.captionLabel.TabIndex = 4; + this.captionLabel.Text = "captionLabel"; + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.AllowUserToResizeRows = false; + this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dataGridView.AutoGenerateColumns = false; + this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.Window; + this.dataGridView.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.NameColumn, + this.Default, + this.ValueColumn}); + this.dataGridView.DataSource = this.bindingSource; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dataGridView.DefaultCellStyle = dataGridViewCellStyle1; + this.dataGridView.Location = new System.Drawing.Point(15, 30); + this.dataGridView.MultiSelect = false; + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersVisible = false; + this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView.ShowRowErrors = false; + this.dataGridView.Size = new System.Drawing.Size(327, 121); + this.dataGridView.TabIndex = 0; + this.dataGridView.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_RowEnter); + this.dataGridView.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.dataGridView_CellValidating); + this.dataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellEndEdit); + this.dataGridView.CurrentCellDirtyStateChanged += new System.EventHandler(this.dataGridView_CurrentCellDirtyStateChanged); + // + // NameColumn + // + this.NameColumn.DataPropertyName = "Name"; + this.NameColumn.HeaderText = "Name"; + this.NameColumn.Name = "NameColumn"; + this.NameColumn.ReadOnly = true; + this.NameColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // Default + // + this.Default.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; + this.Default.DataPropertyName = "Default"; + this.Default.HeaderText = "Default"; + this.Default.Name = "Default"; + this.Default.Width = 47; + // + // ValueColumn + // + this.ValueColumn.DataPropertyName = "Value"; + this.ValueColumn.HeaderText = "Value"; + this.ValueColumn.Name = "ValueColumn"; + this.ValueColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + // + // bindingSource + // + this.bindingSource.AllowNew = false; + // + // descriptionLabel + // + this.descriptionLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.descriptionLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.descriptionLabel.Location = new System.Drawing.Point(15, 154); + this.descriptionLabel.Name = "descriptionLabel"; + this.descriptionLabel.Padding = new System.Windows.Forms.Padding(2); + this.descriptionLabel.Size = new System.Drawing.Size(327, 50); + this.descriptionLabel.TabIndex = 6; + this.descriptionLabel.Text = "descriptionLabel"; + // + // ParameterForm + // + this.AcceptButton = this.okButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(354, 248); + this.Controls.Add(this.descriptionLabel); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.captionLabel); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.okButton); + this.Name = "ParameterForm"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Parameters"; + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Button cancelButton; + public System.Windows.Forms.Label captionLabel; + private System.Windows.Forms.DataGridView dataGridView; + private System.Windows.Forms.Label descriptionLabel; + private System.Windows.Forms.BindingSource bindingSource; + private System.Windows.Forms.DataGridViewTextBoxColumn NameColumn; + private System.Windows.Forms.DataGridViewCheckBoxColumn Default; + private System.Windows.Forms.DataGridViewTextBoxColumn ValueColumn; + + } +} \ No newline at end of file diff -r 5400e3e383f7 -r 1a7c13ac7348 GUI/ParameterForm.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GUI/ParameterForm.cs Sat Feb 27 15:55:17 2010 +0000 @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; +using System.Windows.Forms; +using OpenHardwareMonitor.Hardware; +using OpenHardwareMonitor.Utilities; + +namespace OpenHardwareMonitor.GUI { + public partial class ParameterForm : Form { + + private IReadOnlyArray parameters; + private BindingList parameterRows; + + public ParameterForm() { + InitializeComponent(); + } + + public IReadOnlyArray Parameters { + get { + return parameters; + } + set { + parameters = value; + parameterRows = new BindingList(); + foreach (IParameter parameter in parameters) + parameterRows.Add(new ParameterRow(parameter)); + bindingSource.DataSource = parameterRows; + } + } + + private class ParameterRow : INotifyPropertyChanged { + public IParameter parameter; + private float value; + public bool isDefault; + + public event PropertyChangedEventHandler PropertyChanged; + + private void NotifyPropertyChanged(String propertyName) { + if (PropertyChanged != null) { + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + + public ParameterRow(IParameter parameter){ + this.parameter = parameter; + this.value = parameter.Value; + this.isDefault = parameter.IsDefault; + } + + public string Name { + get { return parameter.Name; } + } + + public float Value { + get { return value; } + set { + this.isDefault = false; + this.value = value; + NotifyPropertyChanged("Default"); + NotifyPropertyChanged("Value"); + } + } + + public bool Default { + get { return isDefault; } + set { + isDefault = value; + if (value) + this.value = parameter.DefaultValue; + NotifyPropertyChanged("Default"); + NotifyPropertyChanged("Value"); + } + } + } + + private void dataGridView_RowEnter(object sender, + DataGridViewCellEventArgs e) + { + if (e.RowIndex >= 0 && e.RowIndex < parameters.Length) + descriptionLabel.Text = parameters[e.RowIndex].Description; + else + descriptionLabel.Text = ""; + } + + private void dataGridView_CellValidating(object sender, + DataGridViewCellValidatingEventArgs e) + { + float value; + if (e.ColumnIndex == 2 && + !float.TryParse(e.FormattedValue.ToString(), out value)) { + dataGridView.Rows[e.RowIndex].Cells[0].ErrorText = + "Invalid value"; + e.Cancel = true; + } + } + + private void dataGridView_CellEndEdit(object sender, + DataGridViewCellEventArgs e) { + dataGridView.Rows[e.RowIndex].Cells[0].ErrorText = ""; + } + + private void okButton_Click(object sender, EventArgs e) { + foreach (ParameterRow row in parameterRows) { + if (row.Default) { + row.parameter.IsDefault = true; + } else { + row.parameter.Value = row.Value; + } + } + } + + private void dataGridView_CurrentCellDirtyStateChanged(object sender, + EventArgs e) { + if (dataGridView.CurrentCell is DataGridViewCheckBoxCell || + dataGridView.CurrentCell is DataGridViewComboBoxCell) + { + dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit); + } + } + } +} diff -r 5400e3e383f7 -r 1a7c13ac7348 GUI/ParameterForm.resx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GUI/ParameterForm.resx Sat Feb 27 15:55:17 2010 +0000 @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + 17, 17 + + \ No newline at end of file diff -r 5400e3e383f7 -r 1a7c13ac7348 Hardware/CPU/AMD0FCPU.cs --- a/Hardware/CPU/AMD0FCPU.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/Hardware/CPU/AMD0FCPU.cs Sat Feb 27 15:55:17 2010 +0000 @@ -79,13 +79,23 @@ totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this); + offset = -49.0f; + + // AM2+ 65nm +21 offset + if (model >= 0x69 && model != 0xc1 && model != 0x6c && model != 0x7c) + offset += 21; + coreTemperatures = new Sensor[coreCount]; coreLoads = new Sensor[coreCount]; for (int i = 0; i < coreCount; i++) { coreTemperatures[i] = new Sensor("Core #" + (i + 1), i, SensorType.Temperature, this); - coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1, - SensorType.Load, this); + coreLoads[i] = new Sensor("Core #" + (i + 1), i + 1, null, + SensorType.Load, this, new ParameterDescription[] { + new ParameterDescription("Offset", + "Temperature offset of the thermal sensor.\n" + + "Temperature = Value + Offset.", offset) + }); } cpuLoad = new CPULoad(coreCount, 1); @@ -98,12 +108,6 @@ pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, PCI_AMD_0FH_MISCELLANEOUS_DEVICE_ID, 0); - offset = -49.0f; - - // AM2+ 65nm +21 offset - if (model >= 0x69 && model != 0xc1 && model != 0x6c && model != 0x7c) - offset += 21; - Update(); } @@ -133,7 +137,8 @@ uint value; if (WinRing0.ReadPciConfigDwordEx( pciAddress, THERMTRIP_STATUS_REGISTER, out value)) { - coreTemperatures[i].Value = ((value >> 16) & 0xFF) + offset; + coreTemperatures[i].Value = ((value >> 16) & 0xFF) + + coreTemperatures[i].Parameters[0].Value; ActivateSensor(coreTemperatures[i]); } else { DeactivateSensor(coreTemperatures[i]); diff -r 5400e3e383f7 -r 1a7c13ac7348 Hardware/CPU/AMD10CPU.cs --- a/Hardware/CPU/AMD10CPU.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/Hardware/CPU/AMD10CPU.cs Sat Feb 27 15:55:17 2010 +0000 @@ -86,8 +86,10 @@ // AMD family 10h processors support only one temperature sensor coreTemperature = new Sensor( - "Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0, - SensorType.Temperature, this); + "Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0, null, + SensorType.Temperature, this, new ParameterDescription[] { + new ParameterDescription("Offset", "Temperature offset.", 0) + }); pciAddress = WinRing0.FindPciDeviceById(PCI_AMD_VENDOR_ID, PCI_AMD_10H_MISCELLANEOUS_DEVICE_ID, 0); @@ -119,7 +121,8 @@ uint value; if (WinRing0.ReadPciConfigDwordEx(pciAddress, REPORTED_TEMPERATURE_CONTROL_REGISTER, out value)) { - coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f; + coreTemperature.Value = ((value >> 21) & 0x7FF) / 8.0f + + coreTemperature.Parameters[0].Value; ActivateSensor(coreTemperature); } else { DeactivateSensor(coreTemperature); diff -r 5400e3e383f7 -r 1a7c13ac7348 Hardware/CPU/IntelCPU.cs --- a/Hardware/CPU/IntelCPU.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/Hardware/CPU/IntelCPU.cs Sat Feb 27 15:55:17 2010 +0000 @@ -40,6 +40,8 @@ using System.Drawing; using System.Diagnostics; using System.Reflection; +using System.Runtime.InteropServices; +using System.Threading; using System.Text; namespace OpenHardwareMonitor.Hardware.CPU { @@ -53,15 +55,15 @@ private uint stepping; private Sensor[] coreTemperatures; + private Sensor totalLoad; private Sensor[] coreLoads; private Sensor[] coreClocks; private Sensor busClock; - - private float tjMax = 0; private uint logicalProcessors; private uint logicalProcessorsPerCore; private uint coreCount; + private ulong affinityMask; private CPULoad cpuLoad; @@ -81,6 +83,10 @@ return "CPU Core #" + (i + 1); } + [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] + private static extern bool GetProcessAffinityMask(IntPtr handle, + out IntPtr processMask, out IntPtr systemMask); + public IntelCPU(string name, uint family, uint model, uint stepping, uint[,] cpuidData, uint[,] cpuidExtData) { @@ -117,8 +123,30 @@ logicalProcessorsPerCore = 1; } + IntPtr processMask, systemMask; + GetProcessAffinityMask(Process.GetCurrentProcess().Handle, + out processMask, out systemMask); + affinityMask = (ulong)systemMask; + + // correct values in case HypeThreading is disabled + if (logicalProcessorsPerCore > 1) { + ulong affinity = affinityMask; + int availableLogicalProcessors = 0; + while (affinity != 0) { + if ((affinity & 0x1) > 0) + availableLogicalProcessors++; + affinity >>= 1; + } + while (logicalProcessorsPerCore > 1 && + availableLogicalProcessors < logicalProcessors) { + logicalProcessors >>= 1; + logicalProcessorsPerCore >>= 1; + } + } + coreCount = logicalProcessors / logicalProcessorsPerCore; - + + float tjMax; switch (family) { case 0x06: { switch (model) { @@ -170,7 +198,13 @@ coreTemperatures = new Sensor[coreCount]; for (int i = 0; i < coreTemperatures.Length; i++) { coreTemperatures[i] = new Sensor(CoreString(i), i, tjMax, - SensorType.Temperature, this); + SensorType.Temperature, this, new ParameterDescription[] { + new ParameterDescription( + "TjMax", "TjMax temperature of the core.\n" + + "Temperature = TjMax - TSlope * Value.", tjMax), + new ParameterDescription( + "TSlope", "Temperature slope of the digital thermal sensor.\n" + + "Temperature = TjMax - TSlope * Value.", 1)}); } } else { coreTemperatures = new Sensor[0]; @@ -237,11 +271,12 @@ r.AppendLine("Intel CPU"); r.AppendLine(); r.AppendFormat("Name: {0}{1}", name, Environment.NewLine); - r.AppendFormat("Number of cores: {0}{1}", coreCount, + r.AppendFormat("Number of Cores: {0}{1}", coreCount, Environment.NewLine); - r.AppendFormat("Threads per core: {0}{1}", logicalProcessorsPerCore, + r.AppendFormat("Threads per Core: {0}{1}", logicalProcessorsPerCore, Environment.NewLine); - r.AppendFormat("TjMax: {0}{1}", tjMax, Environment.NewLine); + r.AppendFormat("Affinity Mask: 0x{0}{1}", affinityMask.ToString("X"), + Environment.NewLine); r.AppendLine(); for (int i = 0; i < coreCount; i++) { @@ -269,7 +304,10 @@ // if reading is valid if ((eax & 0x80000000) != 0) { // get the dist from tjMax from bits 22:16 - coreTemperatures[i].Value = tjMax - ((eax & 0x007F0000) >> 16); + float deltaT = ((eax & 0x007F0000) >> 16); + float tjMax = coreTemperatures[i].Parameters[0].Value; + float tSlope = coreTemperatures[i].Parameters[1].Value; + coreTemperatures[i].Value = tjMax - tSlope * deltaT; ActivateSensor(coreTemperatures[i]); } else { DeactivateSensor(coreTemperatures[i]); diff -r 5400e3e383f7 -r 1a7c13ac7348 Hardware/Computer.cs --- a/Hardware/Computer.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/Hardware/Computer.cs Sat Feb 27 15:55:17 2010 +0000 @@ -152,9 +152,15 @@ new object[] { hardware.Name, hardware.Identifier }); foreach (ISensor sensor in hardware.Sensors) { w.WriteLine("| +- {0} : {1} : {2} : {3}", - new object[] { sensor.SensorType, sensor.Index, sensor.Name, - string.Format(CultureInfo.InvariantCulture, "{0}", - sensor.Value) }); + sensor.SensorType, sensor.Index, sensor.Name, + string.Format(CultureInfo.InvariantCulture, "{0} : {1} : {2}", + sensor.Value, sensor.Min, sensor.Max) ); + foreach (IParameter parameter in sensor.Parameters) { + w.WriteLine("| +- {0} : {1} : {2}", + parameter.Name, parameter.IsDefault, + string.Format(CultureInfo.InvariantCulture, "{0} : {1}", + parameter.DefaultValue, parameter.Value) ); + } } } } diff -r 5400e3e383f7 -r 1a7c13ac7348 Hardware/IParameter.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hardware/IParameter.cs Sat Feb 27 15:55:17 2010 +0000 @@ -0,0 +1,54 @@ +/* + + Version: MPL 1.1/GPL 2.0/LGPL 2.1 + + The contents of this file are subject to the Mozilla Public License Version + 1.1 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + for the specific language governing rights and limitations under the License. + + The Original Code is the Open Hardware Monitor code. + + The Initial Developer of the Original Code is + Michael Möller . + Portions created by the Initial Developer are Copyright (C) 2009-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + + Alternatively, the contents of this file may be used under the terms of + either the GNU General Public License Version 2 or later (the "GPL"), or + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + in which case the provisions of the GPL or the LGPL are applicable instead + of those above. If you wish to allow use of your version of this file only + under the terms of either the GPL or the LGPL, and not to allow others to + use your version of this file under the terms of the MPL, indicate your + decision by deleting the provisions above and replace them with the notice + and other provisions required by the GPL or the LGPL. If you do not delete + the provisions above, a recipient may use your version of this file under + the terms of any one of the MPL, the GPL or the LGPL. + +*/ + +using System; +using System.Collections.Generic; + +namespace OpenHardwareMonitor.Hardware { + + public interface IParameter { + + ISensor Sensor { get; } + string Identifier { get; } + + string Name { get; } + string Description { get; } + float Value { get; set; } + float DefaultValue { get; } + bool IsDefault { get; set; } + } +} diff -r 5400e3e383f7 -r 1a7c13ac7348 Hardware/ISensor.cs --- a/Hardware/ISensor.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/Hardware/ISensor.cs Sat Feb 27 15:55:17 2010 +0000 @@ -37,6 +37,7 @@ using System; using System.Collections.Generic; +using OpenHardwareMonitor.Utilities; namespace OpenHardwareMonitor.Hardware { @@ -55,15 +56,21 @@ } public interface ISensor { + IHardware Hardware { get; } + SensorType SensorType { get; } string Identifier { get; } string Name { get; set; } int Index { get; } + + IReadOnlyArray Parameters { get; } + float? Value { get; } float? Min { get; } float? Max { get; } float? Limit { get; set; } + IEnumerable Plot { get; } } diff -r 5400e3e383f7 -r 1a7c13ac7348 Hardware/LPC/F718XX.cs --- a/Hardware/LPC/F718XX.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/Hardware/LPC/F718XX.cs Sat Feb 27 15:55:17 2010 +0000 @@ -70,8 +70,10 @@ temperatures = new Sensor[3]; for (int i = 0; i < temperatures.Length; i++) - temperatures[i] = new Sensor("Temperature #" + (i + 1), i, - SensorType.Temperature, this); + temperatures[i] = new Sensor("Temperature #" + (i + 1), i, null, + SensorType.Temperature, this, new ParameterDescription[] { + new ParameterDescription("Offset", "Temperature offset.", 0) + }); fans = new Sensor[4]; for (int i = 0; i < fans.Length; i++) @@ -123,7 +125,7 @@ foreach (Sensor sensor in temperatures) { sbyte value = (sbyte)ReadByte((byte)( TEMPERATURE_BASE_REG + 2 * sensor.Index)); - sensor.Value = value; + sensor.Value = value + sensor.Parameters[0].Value; if (value < sbyte.MaxValue && value > 0) ActivateSensor(sensor); else diff -r 5400e3e383f7 -r 1a7c13ac7348 Hardware/LPC/IT87XX.cs --- a/Hardware/LPC/IT87XX.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/Hardware/LPC/IT87XX.cs Sat Feb 27 15:55:17 2010 +0000 @@ -90,8 +90,10 @@ temperatures = new Sensor[3]; for (int i = 0; i < temperatures.Length; i++) - temperatures[i] = new Sensor("Temperature #" + (i + 1), i, - SensorType.Temperature, this); + temperatures[i] = new Sensor("Temperature #" + (i + 1), i, null, + SensorType.Temperature, this, new ParameterDescription[] { + new ParameterDescription("Offset", "Temperature offset.", 0) + }); fans = new Sensor[5]; for (int i = 0; i < fans.Length; i++) @@ -150,8 +152,9 @@ } foreach (Sensor sensor in temperatures) { - sbyte value = (sbyte)ReadByte((byte)(TEMPERATURE_BASE_REG + sensor.Index)); - sensor.Value = value; + sbyte value = + (sbyte)ReadByte((byte)(TEMPERATURE_BASE_REG + sensor.Index)); + sensor.Value = value + sensor.Parameters[0].Value; if (value < sbyte.MaxValue && value > 0) ActivateSensor(sensor); else diff -r 5400e3e383f7 -r 1a7c13ac7348 Hardware/LPC/W836XX.cs --- a/Hardware/LPC/W836XX.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/Hardware/LPC/W836XX.cs Sat Feb 27 15:55:17 2010 +0000 @@ -73,7 +73,6 @@ new string[] {"CPU", "Auxiliary", "System"}; private byte[] TEMPERATURE_REG = new byte[] { 0x50, 0x50, 0x27 }; private byte[] TEMPERATURE_BANK = new byte[] { 1, 2, 0 }; - private byte[] TEMPERATURE_SEL = new byte[] { 1, 2, 0 }; private byte[] FAN_TACHO_REG = new byte[] { 0x28, 0x29, 0x2A, 0x3F, 0x53 }; private byte[] FAN_TACHO_BANK = new byte[] { 0, 0, 0, 0, 5 }; @@ -112,26 +111,42 @@ available = IsWinbondVendor(); + ParameterDescription[] parameter = new ParameterDescription[] { + new ParameterDescription("Offset", "Temperature offset.", 0) + }; List list = new List(); switch (chip) { - case Chip.W83627DHG: - // do not add temperature sensor registers that read PECI agents + case Chip.W83667HG: + case Chip.W83667HGB: + // do not add temperature sensor registers that read PECI + byte flag = ReadByte(0, TEMPERATURE_SOURCE_SELECT_REG); + if ((flag & 0x04) == 0) + list.Add(new Sensor(TEMPERATURE_NAME[0], 0, null, + SensorType.Temperature, this, parameter)); + if ((flag & 0x40) == 0) + list.Add(new Sensor(TEMPERATURE_NAME[1], 1, null, + SensorType.Temperature, this, parameter)); + list.Add(new Sensor(TEMPERATURE_NAME[2], 2, null, + SensorType.Temperature, this, parameter)); + break; + case Chip.W83627DHG: + case Chip.W83627DHGP: + // do not add temperature sensor registers that read PECI byte sel = ReadByte(0, TEMPERATURE_SOURCE_SELECT_REG); if ((sel & 0x07) == 0) - list.Add(new Sensor(TEMPERATURE_NAME[0], 0, - SensorType.Temperature, this)); + list.Add(new Sensor(TEMPERATURE_NAME[0], 0, null, + SensorType.Temperature, this, parameter)); if ((sel & 0x70) == 0) - list.Add(new Sensor(TEMPERATURE_NAME[1], 1, - SensorType.Temperature, this)); - list.Add(new Sensor(TEMPERATURE_NAME[2], 2, - SensorType.Temperature, this)); + list.Add(new Sensor(TEMPERATURE_NAME[1], 1, null, + SensorType.Temperature, this, parameter)); + list.Add(new Sensor(TEMPERATURE_NAME[2], 2, null, + SensorType.Temperature, this, parameter)); break; default: - // no PECI support or extra sensor report register - for (int i = 0; i < TEMPERATURE_NAME.Length; i++) { - list.Add(new Sensor(TEMPERATURE_NAME[i], i, - SensorType.Temperature, this)); - } + // no PECI support, add all sensors + for (int i = 0; i < TEMPERATURE_NAME.Length; i++) + list.Add(new Sensor(TEMPERATURE_NAME[i], i, null, + SensorType.Temperature, this, parameter)); break; } temperatures = list.ToArray(); @@ -212,29 +227,15 @@ } foreach (Sensor sensor in temperatures) { - int value; - switch (chip) { - case Chip.W83667HG: - case Chip.W83667HGB: - WriteByte(0, 0x7D, TEMPERATURE_SEL[sensor.Index]); - value = ((sbyte)ReadByte(0, 0x7E)) << 1; - break; - case Chip.W83627DHGP: - WriteByte(0, 0x7C, TEMPERATURE_SEL[sensor.Index]); - value = ((sbyte)ReadByte(0, 0x7D)) << 1; - break; - default: - value = ((sbyte)ReadByte(TEMPERATURE_BANK[sensor.Index], - TEMPERATURE_REG[sensor.Index])) << 1; - if (TEMPERATURE_BANK[sensor.Index] > 0) { - value |= ReadByte(TEMPERATURE_BANK[sensor.Index], - (byte)(TEMPERATURE_REG[sensor.Index] + 1)) >> 7; - } - break; - } + int value = ((sbyte)ReadByte(TEMPERATURE_BANK[sensor.Index], + TEMPERATURE_REG[sensor.Index])) << 1; + if (TEMPERATURE_BANK[sensor.Index] > 0) + value |= ReadByte(TEMPERATURE_BANK[sensor.Index], + (byte)(TEMPERATURE_REG[sensor.Index] + 1)) >> 7; + float temperature = value / 2.0f; if (temperature <= 125 && temperature >= -55) { - sensor.Value = temperature; + sensor.Value = temperature + sensor.Parameters[0].Value; ActivateSensor(sensor); } else { DeactivateSensor(sensor); diff -r 5400e3e383f7 -r 1a7c13ac7348 Hardware/Parameter.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hardware/Parameter.cs Sat Feb 27 15:55:17 2010 +0000 @@ -0,0 +1,118 @@ +/* + + Version: MPL 1.1/GPL 2.0/LGPL 2.1 + + The contents of this file are subject to the Mozilla Public License Version + 1.1 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + for the specific language governing rights and limitations under the License. + + The Original Code is the Open Hardware Monitor code. + + The Initial Developer of the Original Code is + Michael Möller . + Portions created by the Initial Developer are Copyright (C) 2009-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + + Alternatively, the contents of this file may be used under the terms of + either the GNU General Public License Version 2 or later (the "GPL"), or + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + in which case the provisions of the GPL or the LGPL are applicable instead + of those above. If you wish to allow use of your version of this file only + under the terms of either the GPL or the LGPL, and not to allow others to + use your version of this file under the terms of the MPL, indicate your + decision by deleting the provisions above and replace them with the notice + and other provisions required by the GPL or the LGPL. If you do not delete + the provisions above, a recipient may use your version of this file under + the terms of any one of the MPL, the GPL or the LGPL. + +*/ + +using System; +using System.Collections.Generic; + +namespace OpenHardwareMonitor.Hardware { + + public struct ParameterDescription { + private string name; + private string description; + private float defaultValue; + + public ParameterDescription(string name, string description, + float defaultValue) { + this.name = name; + this.description = description; + this.defaultValue = defaultValue; + } + + public string Name { get { return name; } } + + public string Description { get { return description; } } + + public float DefaultValue { get { return defaultValue; } } + } + + public class Parameter : IParameter { + private ISensor sensor; + private ParameterDescription description; + private float value; + private bool isDefault; + + public Parameter(ParameterDescription description, ISensor sensor) { + this.sensor = sensor; + this.description = description; + this.value = Utilities.Config.Get(Identifier, description.DefaultValue); + this.isDefault = !Utilities.Config.Contains(Identifier); + } + + public ISensor Sensor { + get { + return sensor; + } + } + + public string Identifier { + get { + return sensor.Identifier + "/parameter/" + + Name.Replace(" ", "").ToLower(); + } + } + + public string Name { get { return description.Name; } } + + public string Description { get { return description.Description; } } + + public float Value { + get { + return value; + } + set { + this.isDefault = false; + this.value = value; + Utilities.Config.Set(Identifier, value); + } + } + + public float DefaultValue { + get { return description.DefaultValue; } + } + + public bool IsDefault { + get { return isDefault; } + set { + this.isDefault = value; + if (value) { + this.value = description.DefaultValue; + Utilities.Config.Remove(Identifier); + } + } + } + } +} diff -r 5400e3e383f7 -r 1a7c13ac7348 Hardware/Sensor.cs --- a/Hardware/Sensor.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/Hardware/Sensor.cs Sat Feb 27 15:55:17 2010 +0000 @@ -37,6 +37,7 @@ using System; using System.Collections.Generic; +using OpenHardwareMonitor.Utilities; namespace OpenHardwareMonitor.Hardware { @@ -47,6 +48,7 @@ private int index; private SensorType sensorType; private IHardware hardware; + private ReadOnlyArray parameters; private float? value; private float? min; private float? max; @@ -61,25 +63,32 @@ private const int MAX_MINUTES = 120; public Sensor(string name, int index, SensorType sensorType, - IHardware hardware) - : this(name, index, null, sensorType, hardware) { } + IHardware hardware) : this(name, index, null, sensorType, hardware, + new ParameterDescription[0]) { } - public Sensor(string name, int index, float? limit, - SensorType sensorType, IHardware hardware) + public Sensor(string name, int index, float? limit, + SensorType sensorType, IHardware hardware) : this(name, index, limit, + sensorType, hardware, new ParameterDescription[0]) { } + + public Sensor(string name, int index, float? limit, SensorType sensorType, + IHardware hardware, ParameterDescription[] parameterDescriptions) { this.defaultName = name; this.index = index; this.defaultLimit = limit; this.sensorType = sensorType; this.hardware = hardware; - string configName = - Utilities.Config.Settings[Identifier + "/name"]; + Parameter[] parameters = new Parameter[parameterDescriptions.Length]; + for (int i = 0; i < parameters.Length; i++ ) + parameters[i] = new Parameter(parameterDescriptions[i], this); + this.parameters = parameters; + + string configName = Config.Settings[Identifier + "/name"]; if (configName != null) this.name = configName; else this.name = name; - string configLimit = - Utilities.Config.Settings[Identifier + "/limit"]; + string configLimit = Config.Settings[Identifier + "/limit"]; if (configLimit != null && configLimit != "") this.limit = float.Parse(configLimit); else @@ -110,7 +119,7 @@ name = value; else name = defaultName; - Utilities.Config.Settings[Identifier + "/name"] = name; + Config.Settings[Identifier + "/name"] = name; } } @@ -118,6 +127,10 @@ get { return index; } } + public IReadOnlyArray Parameters { + get { return parameters; } + } + public float? Value { get { return value; @@ -156,11 +169,11 @@ set { if (value.HasValue) { limit = value; - Utilities.Config.Settings[Identifier + "/limit"] = + Config.Settings[Identifier + "/limit"] = limit.ToString(); } else { limit = defaultLimit; - Utilities.Config.Settings[Identifier + "/limit"] = ""; + Config.Settings[Identifier + "/limit"] = ""; } } } diff -r 5400e3e383f7 -r 1a7c13ac7348 Hardware/TBalancer/TBalancer.cs --- a/Hardware/TBalancer/TBalancer.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/Hardware/TBalancer/TBalancer.cs Sat Feb 27 15:55:17 2010 +0000 @@ -73,30 +73,37 @@ this.icon = Utilities.EmbeddedResources.GetImage("bigng.png"); this.protocolVersion = protocolVersion; + ParameterDescription[] parameter = new ParameterDescription[] { + new ParameterDescription("Offset", "Temperature offset.", 0) + }; int offset = 0; for (int i = 0; i < digitalTemperatures.Length; i++) digitalTemperatures[i] = new Sensor("Digital Sensor #" + (i + 1), - offset + i, SensorType.Temperature, this); + offset + i, null, SensorType.Temperature, this, parameter); offset += digitalTemperatures.Length; for (int i = 0; i < analogTemperatures.Length; i++) analogTemperatures[i] = new Sensor("Analog Sensor #" + (i + 1), - offset + i, SensorType.Temperature, this); + offset + i, null, SensorType.Temperature, this, parameter); offset += analogTemperatures.Length; for (int i = 0; i < sensorhubTemperatures.Length; i++) sensorhubTemperatures[i] = new Sensor("Sensorhub Sensor #" + (i + 1), - offset + i, SensorType.Temperature, this); + offset + i, null, SensorType.Temperature, this, parameter); offset += sensorhubTemperatures.Length; for (int i = 0; i < sensorhubFlows.Length; i++) sensorhubFlows[i] = new Sensor("Flowmeter #" + (i + 1), - offset + i, SensorType.Flow, this); + offset + i, null, SensorType.Flow, this, new ParameterDescription[] { + new ParameterDescription("Impulse Rate", + "The impulse rate of the flowmeter in pulses/L", 509) + }); offset += sensorhubFlows.Length; for (int i = 0; i < miniNGTemperatures.Length; i++) - miniNGTemperatures[i] = new Sensor("miniNG #" + (i / 2 + 1) + - " Sensor #" + (i % 2 + 1), offset + i, SensorType.Temperature, this); + miniNGTemperatures[i] = new Sensor("miniNG #" + (i / 2 + 1) + + " Sensor #" + (i % 2 + 1), offset + i, null, SensorType.Temperature, + this, parameter); offset += miniNGTemperatures.Length; alternativeRequest = new MethodDelegate(DelayedAlternativeRequest); @@ -138,7 +145,8 @@ for (int i = 0; i < 2; i++) { Sensor sensor = miniNGTemperatures[number * 2 + i]; if (data[offset + 7 + i] > 0) { - sensor.Value = 0.5f * data[offset + 7 + i]; + sensor.Value = 0.5f * data[offset + 7 + i] + + sensor.Parameters[0].Value; ActivateSensor(sensor); } else { DeactivateSensor(sensor); @@ -179,7 +187,8 @@ for (int i = 0; i < digitalTemperatures.Length; i++) if (data[238 + i] > 0) { - digitalTemperatures[i].Value = 0.5f * data[238 + i]; + digitalTemperatures[i].Value = 0.5f * data[238 + i] + + digitalTemperatures[i].Parameters[0].Value; ActivateSensor(digitalTemperatures[i]); } else { DeactivateSensor(digitalTemperatures[i]); @@ -187,7 +196,8 @@ for (int i = 0; i < analogTemperatures.Length; i++) if (data[260 + i] > 0) { - analogTemperatures[i].Value = 0.5f * data[260 + i]; + analogTemperatures[i].Value = 0.5f * data[260 + i] + + analogTemperatures[i].Parameters[0].Value; ActivateSensor(analogTemperatures[i]); } else { DeactivateSensor(analogTemperatures[i]); @@ -195,7 +205,8 @@ for (int i = 0; i < sensorhubTemperatures.Length; i++) if (data[246 + i] > 0) { - sensorhubTemperatures[i].Value = 0.5f * data[246 + i]; + sensorhubTemperatures[i].Value = 0.5f * data[246 + i] + + sensorhubTemperatures[i].Parameters[0].Value; ActivateSensor(sensorhubTemperatures[i]); } else { DeactivateSensor(sensorhubTemperatures[i]); @@ -204,7 +215,7 @@ for (int i = 0; i < sensorhubFlows.Length; i++) if (data[231 + i] > 0 && data[234] > 0) { float pulsesPerSecond = ((float)data[231 + i]) / data[234]; - const float pulsesPerLiter = 509; + float pulsesPerLiter = sensorhubFlows[i].Parameters[0].Value; sensorhubFlows[i].Value = pulsesPerSecond * 3600 / pulsesPerLiter; ActivateSensor(sensorhubFlows[i]); } else { @@ -216,12 +227,15 @@ if (fans[i] == null) fans[i] = new Sensor("Fan #" + (i + 1), i, maxRPM, SensorType.Fan, - this); + this, new ParameterDescription[] { + new ParameterDescription("MaxRPM", + "Maximum revolutions per minute (RPM) of the fan.", maxRPM) + }); - if ((data[136] & (1 << i)) == 0) - fans[i].Value = maxRPM * 0.01f * data[156 + i]; // pwm mode - else - fans[i].Value = maxRPM * 0.01f * data[141 + i]; // analog mode + if ((data[136] & (1 << i)) == 0) // pwm mode + fans[i].Value = fans[i].Parameters[0].Value * 0.01f * data[156 + i]; + else // analog mode + fans[i].Value = fans[i].Parameters[0].Value * 0.01f * data[141 + i]; ActivateSensor(fans[i]); } diff -r 5400e3e383f7 -r 1a7c13ac7348 OpenHardwareMonitor.csproj --- a/OpenHardwareMonitor.csproj Tue Feb 23 19:45:40 2010 +0000 +++ b/OpenHardwareMonitor.csproj Sat Feb 27 15:55:17 2010 +0000 @@ -4,7 +4,7 @@ Debug AnyCPU {F5E0C1F7-9E9B-46F2-AC88-8C9C1C923880} - 9.0.21022 + 9.0.30729 2.0 WinExe false @@ -58,6 +58,12 @@ + + Form + + + ParameterForm.cs + @@ -68,9 +74,11 @@ + + @@ -84,7 +92,7 @@ - + @@ -104,6 +112,7 @@ + UserControl @@ -119,6 +128,7 @@ + @@ -157,6 +167,9 @@ + + ParameterForm.cs + diff -r 5400e3e383f7 -r 1a7c13ac7348 Properties/AssemblyInfo.cs --- a/Properties/AssemblyInfo.cs Tue Feb 23 19:45:40 2010 +0000 +++ b/Properties/AssemblyInfo.cs Sat Feb 27 15:55:17 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.23.2")] -[assembly: AssemblyFileVersion("0.1.23.2")] +[assembly: AssemblyVersion("0.1.24.0")] +[assembly: AssemblyFileVersion("0.1.24.0")] diff -r 5400e3e383f7 -r 1a7c13ac7348 Utilities/Config.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Utilities/Config.cs Sat Feb 27 15:55:17 2010 +0000 @@ -0,0 +1,179 @@ +/* + + Version: MPL 1.1/GPL 2.0/LGPL 2.1 + + The contents of this file are subject to the Mozilla Public License Version + 1.1 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + for the specific language governing rights and limitations under the License. + + The Original Code is the Open Hardware Monitor code. + + The Initial Developer of the Original Code is + Michael Möller . + Portions created by the Initial Developer are Copyright (C) 2009-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + + Alternatively, the contents of this file may be used under the terms of + either the GNU General Public License Version 2 or later (the "GPL"), or + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + in which case the provisions of the GPL or the LGPL are applicable instead + of those above. If you wish to allow use of your version of this file only + under the terms of either the GPL or the LGPL, and not to allow others to + use your version of this file under the terms of the MPL, indicate your + decision by deleting the provisions above and replace them with the notice + and other provisions required by the GPL or the LGPL. If you do not delete + the provisions above, a recipient may use your version of this file under + the terms of any one of the MPL, the GPL or the LGPL. + +*/ + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; + +namespace OpenHardwareMonitor.Utilities { + + public sealed class Config { + private static readonly Config instance = new Config(); + + private string fileName; + + private System.Configuration.Configuration config; + + private Config() { + this.fileName = Path.ChangeExtension( + System.Windows.Forms.Application.ExecutablePath, ".config"); + System.Configuration.ExeConfigurationFileMap fileMap = + new System.Configuration.ExeConfigurationFileMap(); + fileMap.ExeConfigFilename = fileName; + config = System.Configuration.ConfigurationManager. + OpenMappedExeConfiguration(fileMap, + System.Configuration.ConfigurationUserLevel.None); + } + + ~Config() { + string tempName = Path.ChangeExtension(fileName, ".tmp"); + + if (File.Exists(tempName)) + File.Delete(tempName); + try { + config.SaveAs(tempName); + if (File.Exists(fileName) && File.Exists(tempName)) + File.Delete(fileName); + File.Move(tempName, fileName); + } catch (System.Configuration.ConfigurationErrorsException) { } + } + + public static Config Settings { + get { + return instance; + } + } + + public string this[string name] { + get { + System.Configuration.KeyValueConfigurationElement element = + config.AppSettings.Settings[name]; + if (element != null) + return element.Value; + else + return null; + } + set { + config.AppSettings.Settings.Remove(name); + config.AppSettings.Settings.Add(name, value); + } + } + + public static bool Contains(string name) { + System.Configuration.KeyValueConfigurationElement element = + instance.config.AppSettings.Settings[name]; + return element != null; + } + + public static void Remove(string name) { + instance.config.AppSettings.Settings.Remove(name); + } + + public static void Set(string name, bool value) { + instance[name] = value ? "true" : "false"; + } + + public static bool Get(string name, bool value) { + System.Configuration.KeyValueConfigurationElement element = + instance.config.AppSettings.Settings[name]; + if (element == null) + return value; + else + return element.Value == "true"; + } + + public static void Set(string name, int value) { + instance[name] = value.ToString(); + } + + public static int Get(string name, int value) { + System.Configuration.KeyValueConfigurationElement element = + instance.config.AppSettings.Settings[name]; + if (element == null) + return value; + else { + int parsedValue; + if (int.TryParse(element.Value, out parsedValue)) + return parsedValue; + else + return value; + } + } + + public static void Set(string name, Color color) { + instance[name] = color.ToArgb().ToString("X8"); + } + + public static Color Get(string name, Color value) { + System.Configuration.KeyValueConfigurationElement element = + instance.config.AppSettings.Settings[name]; + if (element == null) + return value; + else { + int parsedValue; + if (int.TryParse(element.Value, + System.Globalization.NumberStyles.HexNumber, + System.Globalization.CultureInfo.InvariantCulture, out parsedValue)) + return Color.FromArgb(parsedValue); + else + return value; + } + } + + public static void Set(string name, float value) { + instance[name] = value.ToString( + System.Globalization.CultureInfo.InvariantCulture.NumberFormat); + } + + public static float Get(string name, float value) { + System.Configuration.KeyValueConfigurationElement element = + instance.config.AppSettings.Settings[name]; + if (element == null) + return value; + else { + float parsedValue; + if (float.TryParse(element.Value, + System.Globalization.NumberStyles.Float, + System.Globalization.CultureInfo.InvariantCulture, out parsedValue)) + return parsedValue; + else + return value; + } + } + } +} diff -r 5400e3e383f7 -r 1a7c13ac7348 Utilities/Configuration.cs --- a/Utilities/Configuration.cs Tue Feb 23 19:45:40 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,158 +0,0 @@ -/* - - Version: MPL 1.1/GPL 2.0/LGPL 2.1 - - The contents of this file are subject to the Mozilla Public License Version - 1.1 (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" basis, - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - for the specific language governing rights and limitations under the License. - - The Original Code is the Open Hardware Monitor code. - - The Initial Developer of the Original Code is - Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2009-2010 - the Initial Developer. All Rights Reserved. - - Contributor(s): - - Alternatively, the contents of this file may be used under the terms of - either the GNU General Public License Version 2 or later (the "GPL"), or - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - in which case the provisions of the GPL or the LGPL are applicable instead - of those above. If you wish to allow use of your version of this file only - under the terms of either the GPL or the LGPL, and not to allow others to - use your version of this file under the terms of the MPL, indicate your - decision by deleting the provisions above and replace them with the notice - and other provisions required by the GPL or the LGPL. If you do not delete - the provisions above, a recipient may use your version of this file under - the terms of any one of the MPL, the GPL or the LGPL. - -*/ - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; - -namespace OpenHardwareMonitor.Utilities { - - public sealed class Config { - private static readonly Config instance = new Config(); - - private string fileName; - - private System.Configuration.Configuration config; - - private Config() { - this.fileName = Path.ChangeExtension( - System.Windows.Forms.Application.ExecutablePath, ".config"); - System.Configuration.ExeConfigurationFileMap fileMap = - new System.Configuration.ExeConfigurationFileMap(); - fileMap.ExeConfigFilename = fileName; - config = System.Configuration.ConfigurationManager. - OpenMappedExeConfiguration(fileMap, - System.Configuration.ConfigurationUserLevel.None); - } - - ~Config() { - string tempName = Path.ChangeExtension(fileName, ".tmp"); - - if (File.Exists(tempName)) - File.Delete(tempName); - try { - config.SaveAs(tempName); - if (File.Exists(fileName) && File.Exists(tempName)) - File.Delete(fileName); - File.Move(tempName, fileName); - } catch (System.Configuration.ConfigurationErrorsException) { } - } - - public static Config Settings { - get { - return instance; - } - } - - public string this[string name] { - get { - System.Configuration.KeyValueConfigurationElement element = - config.AppSettings.Settings[name]; - if (element != null) - return element.Value; - else - return null; - } - set { - config.AppSettings.Settings.Remove(name); - config.AppSettings.Settings.Add(name, value); - } - } - - public static bool Contains(string name) { - System.Configuration.KeyValueConfigurationElement element = - instance.config.AppSettings.Settings[name]; - return element != null; - } - - public static void Remove(string name) { - instance.config.AppSettings.Settings.Remove(name); - } - - public static void Set(string name, bool value) { - instance[name] = value ? "true" : "false"; - } - - public static bool Get(string name, bool value) { - System.Configuration.KeyValueConfigurationElement element = - instance.config.AppSettings.Settings[name]; - if (element == null) - return value; - else - return element.Value == "true"; - } - - public static void Set(string name, int value) { - instance[name] = value.ToString(); - } - - public static int Get(string name, int value) { - System.Configuration.KeyValueConfigurationElement element = - instance.config.AppSettings.Settings[name]; - if (element == null) - return value; - else { - int parsedValue; - if (int.TryParse(element.Value, out parsedValue)) - return parsedValue; - else - return value; - } - } - - public static void Set(string name, Color color) { - instance[name] = color.ToArgb().ToString("X8"); - } - - public static Color Get(string name, Color value) { - System.Configuration.KeyValueConfigurationElement element = - instance.config.AppSettings.Settings[name]; - if (element == null) - return value; - else { - int parsedValue; - if (int.TryParse(element.Value, - System.Globalization.NumberStyles.HexNumber, - System.Globalization.CultureInfo.InvariantCulture, out parsedValue)) - return Color.FromArgb(parsedValue); - else - return value; - } - } - } -} diff -r 5400e3e383f7 -r 1a7c13ac7348 Utilities/IReadOnlyArray.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Utilities/IReadOnlyArray.cs Sat Feb 27 15:55:17 2010 +0000 @@ -0,0 +1,50 @@ +/* + + Version: MPL 1.1/GPL 2.0/LGPL 2.1 + + The contents of this file are subject to the Mozilla Public License Version + 1.1 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + for the specific language governing rights and limitations under the License. + + The Original Code is the Open Hardware Monitor code. + + The Initial Developer of the Original Code is + Michael Möller . + Portions created by the Initial Developer are Copyright (C) 2009-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + + Alternatively, the contents of this file may be used under the terms of + either the GNU General Public License Version 2 or later (the "GPL"), or + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + in which case the provisions of the GPL or the LGPL are applicable instead + of those above. If you wish to allow use of your version of this file only + under the terms of either the GPL or the LGPL, and not to allow others to + use your version of this file under the terms of the MPL, indicate your + decision by deleting the provisions above and replace them with the notice + and other provisions required by the GPL or the LGPL. If you do not delete + the provisions above, a recipient may use your version of this file under + the terms of any one of the MPL, the GPL or the LGPL. + +*/ + +using System; +using System.Collections.Generic; + +namespace OpenHardwareMonitor.Utilities { + + public interface IReadOnlyArray : IEnumerable { + + T this[int index] { get; } + + int Length { get; } + + } +} diff -r 5400e3e383f7 -r 1a7c13ac7348 Utilities/ReadOnlyArray.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Utilities/ReadOnlyArray.cs Sat Feb 27 15:55:17 2010 +0000 @@ -0,0 +1,70 @@ +/* + + Version: MPL 1.1/GPL 2.0/LGPL 2.1 + + The contents of this file are subject to the Mozilla Public License Version + 1.1 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + for the specific language governing rights and limitations under the License. + + The Original Code is the Open Hardware Monitor code. + + The Initial Developer of the Original Code is + Michael Möller . + Portions created by the Initial Developer are Copyright (C) 2009-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + + Alternatively, the contents of this file may be used under the terms of + either the GNU General Public License Version 2 or later (the "GPL"), or + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + in which case the provisions of the GPL or the LGPL are applicable instead + of those above. If you wish to allow use of your version of this file only + under the terms of either the GPL or the LGPL, and not to allow others to + use your version of this file under the terms of the MPL, indicate your + decision by deleting the provisions above and replace them with the notice + and other provisions required by the GPL or the LGPL. If you do not delete + the provisions above, a recipient may use your version of this file under + the terms of any one of the MPL, the GPL or the LGPL. + +*/ + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace OpenHardwareMonitor.Utilities { + + public class ReadOnlyArray : IReadOnlyArray { + + private T[] array; + + public ReadOnlyArray(T[] array) { + this.array = array; + } + + public T this[int index] { + get { return array[index]; } + } + + public int Length { get { return array.Length; } } + + public IEnumerator GetEnumerator() { + return ((IEnumerable)array).GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() { + return array.GetEnumerator(); + } + + public static implicit operator ReadOnlyArray(T[] array) { + return new ReadOnlyArray(array); + } + } +}