# HG changeset patch # User moel.mich # Date 1273422133 0 # Node ID 411b72b73d8f22cffa73ac738fb7517aff2c4f5f # Parent 70d0c31024244f243c780e21b6ef1b544efa408b Refactored the hardware code and added the visitor pattern for operations on the computer/hardware/sensor/parameter tree. diff -r 70d0c3102424 -r 411b72b73d8f GUI/MainForm.cs --- a/GUI/MainForm.cs Thu May 06 19:20:38 2010 +0000 +++ b/GUI/MainForm.cs Sun May 09 16:22:13 2010 +0000 @@ -60,6 +60,8 @@ private SensorSystemTray sensorSystemTray; private NotifyIcon notifyIcon; private StartupManager startupManager = new StartupManager(); + private SensorProperties sensorProperties = new SensorProperties(); + private UpdateVisitor updateVisitor = new UpdateVisitor(); public MainForm() { InitializeComponent(); @@ -241,7 +243,7 @@ } private void timer_Tick(object sender, EventArgs e) { - computer.Update(); + computer.Accept(updateVisitor); treeView.Invalidate(); plotPanel.Invalidate(); sensorSystemTray.Redraw(); diff -r 70d0c3102424 -r 411b72b73d8f GUI/SensorProperties.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GUI/SensorProperties.cs Sun May 09 16:22:13 2010 +0000 @@ -0,0 +1,76 @@ +/* + + 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 OpenHardwareMonitor.Hardware; +using OpenHardwareMonitor.Utilities; + +namespace OpenHardwareMonitor.GUI { + public class SensorProperties { + + private IDictionary properties = + new Dictionary(); + + private Properties GetProperties(ISensor sensor) { + Properties value; + if (!properties.TryGetValue(sensor.Identifier, out value)) { + value = new Properties(sensor.Identifier, sensor.IsDefaultHidden); + properties.Add(sensor.Identifier, value); + } + return value; + } + + public bool IsHidden(ISensor sensor) { + return GetProperties(sensor).IsHidden; + } + + private class Properties { + private Identifier identifier; + private bool hidden; + + public Properties(Identifier identifier, bool defaultHidden) { + this.identifier = identifier; + + hidden = Config.Get(new Identifier(identifier, "hidden").ToString(), + defaultHidden); + } + + public bool IsHidden { get { return hidden; } } + } + } +} diff -r 70d0c3102424 -r 411b72b73d8f GUI/UpdateVisitor.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GUI/UpdateVisitor.cs Sun May 09 16:22:13 2010 +0000 @@ -0,0 +1,58 @@ +/* + + 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 OpenHardwareMonitor.Hardware; + +namespace OpenHardwareMonitor.GUI { + public class UpdateVisitor : IVisitor { + public void VisitComputer(IComputer computer) { + computer.Traverse(this); + } + + public void VisitHardware(IHardware hardware) { + hardware.Update(); + foreach (IHardware subHardware in hardware.SubHardware) + subHardware.Accept(this); + } + + public void VisitSensor(ISensor sensor) { } + + public void VisitParameter(IParameter parameter) { } + } +} diff -r 70d0c3102424 -r 411b72b73d8f Hardware/ATI/ATIGPU.cs --- a/Hardware/ATI/ATIGPU.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/ATI/ATIGPU.cs Sun May 09 16:22:13 2010 +0000 @@ -82,23 +82,19 @@ public int DeviceNumber { get { return deviceNumber; } } - public string Name { + public override string Name { get { return name; } } - public Identifier Identifier { + public override Identifier Identifier { get { return new Identifier("atigpu", adapterIndex.ToString()); } } - public Image Icon { + public override Image Icon { get { return icon; } } - public string GetReport() { - return null; - } - - public void Update() { + public override void Update() { ADLTemperature adlt = new ADLTemperature(); if (ADL.ADL_Overdrive5_Temperature_Get(adapterIndex, 0, ref adlt) == ADL.ADL_OK) diff -r 70d0c3102424 -r 411b72b73d8f Hardware/CPU/AMD0FCPU.cs --- a/Hardware/CPU/AMD0FCPU.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/CPU/AMD0FCPU.cs Sun May 09 16:22:13 2010 +0000 @@ -117,23 +117,19 @@ Update(); } - public string Name { + public override string Name { get { return name; } } - public Identifier Identifier { + public override Identifier Identifier { get { return new Identifier("amdcpu", processorIndex.ToString()); } } - public Image Icon { + public override Image Icon { get { return icon; } } - public string GetReport() { - return null; - } - - public void Update() { + public override void Update() { if (pciAddress != 0xFFFFFFFF) { for (uint i = 0; i < coreTemperatures.Length; i++) { if (WinRing0.WritePciConfigDwordEx( diff -r 70d0c3102424 -r 411b72b73d8f Hardware/CPU/AMD10CPU.cs --- a/Hardware/CPU/AMD10CPU.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/CPU/AMD10CPU.cs Sun May 09 16:22:13 2010 +0000 @@ -99,23 +99,19 @@ Update(); } - public string Name { + public override string Name { get { return name; } } - public Identifier Identifier { + public override Identifier Identifier { get { return new Identifier("amdcpu", processorIndex.ToString()); } } - public Image Icon { + public override Image Icon { get { return icon; } } - public string GetReport() { - return null; - } - - public void Update() { + public override void Update() { if (pciAddress != 0xFFFFFFFF) { uint value; if (WinRing0.ReadPciConfigDwordEx(pciAddress, diff -r 70d0c3102424 -r 411b72b73d8f Hardware/CPU/IntelCPU.cs --- a/Hardware/CPU/IntelCPU.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/CPU/IntelCPU.cs Sun May 09 16:22:13 2010 +0000 @@ -233,15 +233,15 @@ Update(); } - public string Name { + public override string Name { get { return name; } } - public Identifier Identifier { + public override Identifier Identifier { get { return new Identifier("intelcpu", processorIndex.ToString()); } } - public Image Icon { + public override Image Icon { get { return icon; } } @@ -258,7 +258,7 @@ } } - public string GetReport() { + public override string GetReport() { StringBuilder r = new StringBuilder(); r.AppendLine("Intel CPU"); @@ -311,7 +311,7 @@ (timeEnd - timeBegin); } - public void Update() { + public override void Update() { for (int i = 0; i < coreTemperatures.Length; i++) { uint eax, edx; if (WinRing0.RdmsrTx( diff -r 70d0c3102424 -r 411b72b73d8f Hardware/Computer.cs --- a/Hardware/Computer.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/Computer.cs Sun May 09 16:22:13 2010 +0000 @@ -91,21 +91,6 @@ open = true; } - private void SubHardwareUpdate(IHardware hardware) { - foreach (IHardware subHardware in hardware.SubHardware) { - subHardware.Update(); - SubHardwareUpdate(subHardware); - } - } - - public void Update() { - foreach (IGroup group in groups) - foreach (IHardware hardware in group.Hardware) { - hardware.Update(); - SubHardwareUpdate(hardware); - } - } - public bool HDDEnabled { get { return hddEnabled; } set { @@ -221,5 +206,15 @@ public event HardwareEventHandler HardwareAdded; public event HardwareEventHandler HardwareRemoved; + + public void Accept(IVisitor visitor) { + visitor.VisitComputer(this); + } + + public void Traverse(IVisitor visitor) { + foreach (IGroup group in groups) + foreach (IHardware hardware in group.Hardware) + hardware.Accept(visitor); + } } } diff -r 70d0c3102424 -r 411b72b73d8f Hardware/HDD/HDD.cs --- a/Hardware/HDD/HDD.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/HDD/HDD.cs Sun May 09 16:22:13 2010 +0000 @@ -110,6 +110,12 @@ #pragma warning disable 67 public event SensorEventHandler SensorAdded; public event SensorEventHandler SensorRemoved; - #pragma warning restore 67 + #pragma warning restore 67 + + public void Accept(IVisitor visitor) { + visitor.VisitHardware(this); + } + + public void Traverse(IVisitor visitor) { } } } diff -r 70d0c3102424 -r 411b72b73d8f Hardware/Hardware.cs --- a/Hardware/Hardware.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/Hardware.cs Sun May 09 16:22:13 2010 +0000 @@ -37,11 +37,13 @@ using System; using System.Collections.Generic; +using System.Drawing; +using OpenHardwareMonitor.Utilities; namespace OpenHardwareMonitor.Hardware { - public abstract class Hardware { + public abstract class Hardware : IHardware { - private List active = new List(); + private ListSet active = new ListSet(); public IHardware[] SubHardware { get { return new IHardware[0]; } @@ -52,24 +54,39 @@ } protected void ActivateSensor(Sensor sensor) { - if (!active.Contains(sensor)) { - active.Add(sensor); + if (active.Add(sensor)) if (SensorAdded != null) SensorAdded(sensor); - } } protected void DeactivateSensor(Sensor sensor) { - if (active.Contains(sensor)) { - active.Remove(sensor); + if (active.Remove(sensor)) if (SensorRemoved != null) - SensorRemoved(sensor); - } + SensorRemoved(sensor); } #pragma warning disable 67 public event SensorEventHandler SensorAdded; public event SensorEventHandler SensorRemoved; #pragma warning restore 67 + + public abstract string Name { get; } + public abstract Identifier Identifier { get; } + public abstract Image Icon { get; } + + public virtual string GetReport() { + return null; + } + + public abstract void Update(); + + public void Accept(IVisitor visitor) { + visitor.VisitHardware(this); + } + + public void Traverse(IVisitor visitor) { + foreach (ISensor sensor in active) + sensor.Accept(visitor); + } } } diff -r 70d0c3102424 -r 411b72b73d8f Hardware/IComputer.cs --- a/Hardware/IComputer.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/IComputer.cs Sun May 09 16:22:13 2010 +0000 @@ -42,7 +42,7 @@ public delegate void HardwareEventHandler(IHardware hardware); - public interface IComputer { + public interface IComputer : IElement { IHardware[] Hardware { get; } diff -r 70d0c3102424 -r 411b72b73d8f Hardware/IElement.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hardware/IElement.cs Sun May 09 16:22:13 2010 +0000 @@ -0,0 +1,52 @@ +/* + + 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.Text; + +namespace OpenHardwareMonitor.Hardware { + + public interface IElement { + // accept visitor on this element + void Accept(IVisitor visitor); + + // call accept(visitor) on all child elements (called only from visitors) + void Traverse(IVisitor visitor); + } + +} diff -r 70d0c3102424 -r 411b72b73d8f Hardware/IHardware.cs --- a/Hardware/IHardware.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/IHardware.cs Sun May 09 16:22:13 2010 +0000 @@ -43,7 +43,7 @@ public delegate void SensorEventHandler(ISensor sensor); - public interface IHardware { + public interface IHardware : IElement { string Name { get; } Identifier Identifier { get; } diff -r 70d0c3102424 -r 411b72b73d8f Hardware/IParameter.cs --- a/Hardware/IParameter.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/IParameter.cs Sun May 09 16:22:13 2010 +0000 @@ -40,7 +40,7 @@ namespace OpenHardwareMonitor.Hardware { - public interface IParameter { + public interface IParameter : IElement { ISensor Sensor { get; } Identifier Identifier { get; } diff -r 70d0c3102424 -r 411b72b73d8f Hardware/ISensor.cs --- a/Hardware/ISensor.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/ISensor.cs Sun May 09 16:22:13 2010 +0000 @@ -55,7 +55,7 @@ DateTime Time { get; } } - public interface ISensor { + public interface ISensor : IElement { IHardware Hardware { get; } diff -r 70d0c3102424 -r 411b72b73d8f Hardware/IVisitor.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hardware/IVisitor.cs Sun May 09 16:22:13 2010 +0000 @@ -0,0 +1,51 @@ +/* + + 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.Text; + +namespace OpenHardwareMonitor.Hardware { + + public interface IVisitor { + void VisitComputer(IComputer computer); + void VisitHardware(IHardware hardware); + void VisitSensor(ISensor sensor); + void VisitParameter(IParameter parameter); + } + +} diff -r 70d0c3102424 -r 411b72b73d8f Hardware/LPC/F718XX.cs --- a/Hardware/LPC/F718XX.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/LPC/F718XX.cs Sun May 09 16:22:13 2010 +0000 @@ -99,7 +99,7 @@ } } - public string GetReport() { + public override string GetReport() { StringBuilder r = new StringBuilder(); r.AppendLine("LPC " + this.GetType().Name); @@ -123,7 +123,7 @@ return r.ToString(); } - public void Update() { + public override void Update() { foreach (Sensor sensor in voltages) { int value = ReadByte((byte)(VOLTAGE_BASE_REG + sensor.Index)); diff -r 70d0c3102424 -r 411b72b73d8f Hardware/LPC/IT87XX.cs --- a/Hardware/LPC/IT87XX.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/LPC/IT87XX.cs Sun May 09 16:22:13 2010 +0000 @@ -122,7 +122,7 @@ get { return available; } } - public string GetReport() { + public override string GetReport() { StringBuilder r = new StringBuilder(); r.AppendLine("LPC " + this.GetType().Name); @@ -154,7 +154,7 @@ return r.ToString(); } - public void Update() { + public override void Update() { foreach (Sensor sensor in voltages) { bool valid; diff -r 70d0c3102424 -r 411b72b73d8f Hardware/LPC/LPCGroup.cs --- a/Hardware/LPC/LPCGroup.cs Thu May 06 19:20:38 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,400 +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.Text; -using System.Threading; - -namespace OpenHardwareMonitor.Hardware.LPC { - public class LPCGroup : IGroup { - - private List hardware = new List(); - private StringBuilder report = new StringBuilder(); - - private Chip chip = Chip.Unknown; - - // I/O Ports - private ushort[] REGISTER_PORTS = new ushort[] { 0x2e, 0x4e }; - private ushort[] VALUE_PORTS = new ushort[] { 0x2f, 0x4f }; - - private ushort registerPort; - private ushort valuePort; - - // Registers - private const byte CONFIGURATION_CONTROL_REGISTER = 0x02; - private const byte DEVCIE_SELECT_REGISTER = 0x07; - private const byte CHIP_ID_REGISTER = 0x20; - private const byte CHIP_REVISION_REGISTER = 0x21; - private const byte BASE_ADDRESS_REGISTER = 0x60; - - private byte ReadByte(byte register) { - WinRing0.WriteIoPortByte(registerPort, register); - return WinRing0.ReadIoPortByte(valuePort); - } - - private ushort ReadWord(byte register) { - return (ushort)((ReadByte(register) << 8) | - ReadByte((byte)(register + 1))); - } - - private void Select(byte logicalDeviceNumber) { - WinRing0.WriteIoPortByte(registerPort, DEVCIE_SELECT_REGISTER); - WinRing0.WriteIoPortByte(valuePort, logicalDeviceNumber); - } - - // ITE - private const byte IT87_ENVIRONMENT_CONTROLLER_LDN = 0x04; - - private void IT87Enter() { - WinRing0.WriteIoPortByte(registerPort, 0x87); - WinRing0.WriteIoPortByte(registerPort, 0x01); - WinRing0.WriteIoPortByte(registerPort, 0x55); - WinRing0.WriteIoPortByte(registerPort, 0x55); - } - - internal void IT87Exit() { - WinRing0.WriteIoPortByte(registerPort, CONFIGURATION_CONTROL_REGISTER); - WinRing0.WriteIoPortByte(valuePort, 0x02); - } - - // Winbond, Fintek - private const byte FINTEK_VENDOR_ID_REGISTER = 0x23; - private const ushort FINTEK_VENDOR_ID = 0x1934; - - private const byte WINBOND_HARDWARE_MONITOR_LDN = 0x0B; - - private const byte F71858_HARDWARE_MONITOR_LDN = 0x02; - private const byte FINTEK_HARDWARE_MONITOR_LDN = 0x04; - - private void WinbondFintekEnter() { - WinRing0.WriteIoPortByte(registerPort, 0x87); - WinRing0.WriteIoPortByte(registerPort, 0x87); - } - - private void WinbondFintekExit() { - WinRing0.WriteIoPortByte(registerPort, 0xAA); - } - - // SMSC - private void SMSCEnter() { - WinRing0.WriteIoPortByte(registerPort, 0x55); - } - - private void SMSCExit() { - WinRing0.WriteIoPortByte(registerPort, 0xAA); - } - - public LPCGroup() { - if (!WinRing0.IsAvailable) - return; - - for (int i = 0; i < REGISTER_PORTS.Length; i++) { - registerPort = REGISTER_PORTS[i]; - valuePort = VALUE_PORTS[i]; - - WinbondFintekEnter(); - - byte logicalDeviceNumber; - byte id = ReadByte(CHIP_ID_REGISTER); - byte revision = ReadByte(CHIP_REVISION_REGISTER); - chip = Chip.Unknown; - logicalDeviceNumber = 0; - switch (id) { - case 0x05: - switch (revision) { - case 0x07: - chip = Chip.F71858; - logicalDeviceNumber = F71858_HARDWARE_MONITOR_LDN; - break; - case 0x41: - chip = Chip.F71882; - logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; - break; - } break; - case 0x06: - switch (revision) { - case 0x01: - chip = Chip.F71862; - logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; - break; - } break; - case 0x07: - switch (revision) { - case 0x23: - chip = Chip.F71889F; - logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; - break; - } break; - case 0x08: - switch (revision) { - case 0x14: - chip = Chip.F71869; - logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; - break; - } break; - case 0x09: - switch (revision) { - case 0x09: - chip = Chip.F71889ED; - logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; - break; - } break; - case 0x52: - switch (revision) { - case 0x17: - case 0x3A: - case 0x41: - chip = Chip.W83627HF; - logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; - break; - } break; - case 0x82: - switch (revision) { - case 0x83: - chip = Chip.W83627THF; - logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; - break; - } break; - case 0x85: - switch (revision) { - case 0x41: - chip = Chip.W83687THF; - logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; - break; - } break; - case 0x88: - switch (revision & 0xF0) { - case 0x50: - case 0x60: - chip = Chip.W83627EHF; - logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; - break; - } break; - case 0xA0: - switch (revision & 0xF0) { - case 0x20: - chip = Chip.W83627DHG; - logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; - break; - } break; - case 0xA5: - switch (revision & 0xF0) { - case 0x10: - chip = Chip.W83667HG; - logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; - break; - } break; - case 0xB0: - switch (revision & 0xF0) { - case 0x70: - chip = Chip.W83627DHGP; - logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; - break; - } break; - case 0xB3: - switch (revision & 0xF0) { - case 0x50: - chip = Chip.W83667HGB; - logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; - break; - } break; - } - if (chip == Chip.Unknown) { - if (id != 0 && id != 0xff) { - WinbondFintekExit(); - - report.Append("Chip ID: Unknown Winbond / Fintek with ID 0x"); - report.AppendLine(((id << 8) | revision).ToString("X")); - report.AppendLine(); - } - } else { - - Select(logicalDeviceNumber); - ushort address = ReadWord(BASE_ADDRESS_REGISTER); - Thread.Sleep(1); - ushort verify = ReadWord(BASE_ADDRESS_REGISTER); - - ushort vendorID = ReadWord(FINTEK_VENDOR_ID_REGISTER); - - WinbondFintekExit(); - - if (address != verify) { - report.Append("Chip ID: 0x"); - report.AppendLine(chip.ToString("X")); - report.Append("Chip revision: 0x"); - report.AppendLine(revision.ToString("X")); - report.AppendLine("Error: Address verification failed"); - report.AppendLine(); - return; - } - - // some Fintek chips have address register offset 0x05 added already - if ((address & 0x07) == 0x05) - address &= 0xFFF8; - - if (address < 0x100 || (address & 0xF007) != 0) { - report.Append("Chip ID: 0x"); - report.AppendLine(chip.ToString("X")); - report.Append("Chip revision: 0x"); - report.AppendLine(revision.ToString("X")); - report.Append("Error: Invalid address 0x"); - report.AppendLine(address.ToString("X")); - report.AppendLine(); - return; - } - - switch (chip) { - case Chip.W83627DHG: - case Chip.W83627DHGP: - case Chip.W83627EHF: - case Chip.W83627HF: - case Chip.W83627THF: - case Chip.W83667HG: - case Chip.W83667HGB: - case Chip.W83687THF: - W836XX w836XX = new W836XX(chip, revision, address); - if (w836XX.IsAvailable) - hardware.Add(w836XX); - break; - case Chip.F71858: - case Chip.F71862: - case Chip.F71869: - case Chip.F71882: - case Chip.F71889ED: - case Chip.F71889F: - if (vendorID != FINTEK_VENDOR_ID) { - report.Append("Chip ID: 0x"); - report.AppendLine(chip.ToString("X")); - report.Append("Chip revision: 0x"); - report.AppendLine(revision.ToString("X")); - report.Append("Error: Invalid vendor ID 0x"); - report.AppendLine(vendorID.ToString("X")); - report.AppendLine(); - return; - } - hardware.Add(new F718XX(chip, address)); - break; - default: break; - } - - return; - } - - IT87Enter(); - - ushort chipID = ReadWord(CHIP_ID_REGISTER); - switch (chipID) { - case 0x8712: chip = Chip.IT8712F; break; - case 0x8716: chip = Chip.IT8716F; break; - case 0x8718: chip = Chip.IT8718F; break; - case 0x8720: chip = Chip.IT8720F; break; - case 0x8726: chip = Chip.IT8726F; break; - default: chip = Chip.Unknown; break; - } - if (chip == Chip.Unknown) { - if (chipID != 0 && chipID != 0xffff) { - IT87Exit(); - - report.Append("Chip ID: Unknown ITE with ID 0x"); - report.AppendLine(chipID.ToString("X")); - report.AppendLine(); - } - } else { - Select(IT87_ENVIRONMENT_CONTROLLER_LDN); - ushort address = ReadWord(BASE_ADDRESS_REGISTER); - Thread.Sleep(1); - ushort verify = ReadWord(BASE_ADDRESS_REGISTER); - - IT87Exit(); - - if (address != verify || address < 0x100 || (address & 0xF007) != 0) { - report.Append("Chip ID: 0x"); - report.AppendLine(chip.ToString("X")); - report.Append("Error: Invalid address 0x"); - report.AppendLine(address.ToString("X")); - report.AppendLine(); - return; - } - - IT87XX it87 = new IT87XX(chip, address); - if (it87.IsAvailable) - hardware.Add(it87); - - return; - } - - SMSCEnter(); - - chipID = ReadWord(CHIP_ID_REGISTER); - switch (chipID) { - default: chip = Chip.Unknown; break; - } - if (chip == Chip.Unknown) { - if (chipID != 0 && chipID != 0xffff) { - SMSCExit(); - - report.Append("Chip ID: Unknown SMSC with ID 0x"); - report.AppendLine(chipID.ToString("X")); - report.AppendLine(); - } - } else { - SMSCExit(); - - return; - } - } - } - - public IHardware[] Hardware { - get { - return hardware.ToArray(); - } - } - - public string GetReport() { - if (report.Length > 0) { - report.Insert(0, "LPCIO" + Environment.NewLine + - Environment.NewLine); - return report.ToString(); - } else - return null; - } - - public void Close() { } - } -} diff -r 70d0c3102424 -r 411b72b73d8f Hardware/LPC/LPCHardware.cs --- a/Hardware/LPC/LPCHardware.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/LPC/LPCHardware.cs Sun May 09 16:22:13 2010 +0000 @@ -73,15 +73,15 @@ } } - public Identifier Identifier { + public override Identifier Identifier { get { return new Identifier("lpc", chip.ToString().ToLower()); } } - public Image Icon { + public override Image Icon { get { return icon; } } - public string Name { + public override string Name { get { return name; } } } diff -r 70d0c3102424 -r 411b72b73d8f Hardware/LPC/LPCIO.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hardware/LPC/LPCIO.cs Sun May 09 16:22:13 2010 +0000 @@ -0,0 +1,398 @@ +/* + + 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.Text; +using System.Threading; + +namespace OpenHardwareMonitor.Hardware.LPC { + public class LPCIO { + + private List hardware = new List(); + private StringBuilder report = new StringBuilder(); + + private Chip chip = Chip.Unknown; + + // I/O Ports + private ushort[] REGISTER_PORTS = new ushort[] { 0x2e, 0x4e }; + private ushort[] VALUE_PORTS = new ushort[] { 0x2f, 0x4f }; + + private ushort registerPort; + private ushort valuePort; + + // Registers + private const byte CONFIGURATION_CONTROL_REGISTER = 0x02; + private const byte DEVCIE_SELECT_REGISTER = 0x07; + private const byte CHIP_ID_REGISTER = 0x20; + private const byte CHIP_REVISION_REGISTER = 0x21; + private const byte BASE_ADDRESS_REGISTER = 0x60; + + private byte ReadByte(byte register) { + WinRing0.WriteIoPortByte(registerPort, register); + return WinRing0.ReadIoPortByte(valuePort); + } + + private ushort ReadWord(byte register) { + return (ushort)((ReadByte(register) << 8) | + ReadByte((byte)(register + 1))); + } + + private void Select(byte logicalDeviceNumber) { + WinRing0.WriteIoPortByte(registerPort, DEVCIE_SELECT_REGISTER); + WinRing0.WriteIoPortByte(valuePort, logicalDeviceNumber); + } + + // ITE + private const byte IT87_ENVIRONMENT_CONTROLLER_LDN = 0x04; + + private void IT87Enter() { + WinRing0.WriteIoPortByte(registerPort, 0x87); + WinRing0.WriteIoPortByte(registerPort, 0x01); + WinRing0.WriteIoPortByte(registerPort, 0x55); + WinRing0.WriteIoPortByte(registerPort, 0x55); + } + + internal void IT87Exit() { + WinRing0.WriteIoPortByte(registerPort, CONFIGURATION_CONTROL_REGISTER); + WinRing0.WriteIoPortByte(valuePort, 0x02); + } + + // Winbond, Fintek + private const byte FINTEK_VENDOR_ID_REGISTER = 0x23; + private const ushort FINTEK_VENDOR_ID = 0x1934; + + private const byte WINBOND_HARDWARE_MONITOR_LDN = 0x0B; + + private const byte F71858_HARDWARE_MONITOR_LDN = 0x02; + private const byte FINTEK_HARDWARE_MONITOR_LDN = 0x04; + + private void WinbondFintekEnter() { + WinRing0.WriteIoPortByte(registerPort, 0x87); + WinRing0.WriteIoPortByte(registerPort, 0x87); + } + + private void WinbondFintekExit() { + WinRing0.WriteIoPortByte(registerPort, 0xAA); + } + + // SMSC + private void SMSCEnter() { + WinRing0.WriteIoPortByte(registerPort, 0x55); + } + + private void SMSCExit() { + WinRing0.WriteIoPortByte(registerPort, 0xAA); + } + + public LPCIO() { + if (!WinRing0.IsAvailable) + return; + + for (int i = 0; i < REGISTER_PORTS.Length; i++) { + registerPort = REGISTER_PORTS[i]; + valuePort = VALUE_PORTS[i]; + + WinbondFintekEnter(); + + byte logicalDeviceNumber; + byte id = ReadByte(CHIP_ID_REGISTER); + byte revision = ReadByte(CHIP_REVISION_REGISTER); + chip = Chip.Unknown; + logicalDeviceNumber = 0; + switch (id) { + case 0x05: + switch (revision) { + case 0x07: + chip = Chip.F71858; + logicalDeviceNumber = F71858_HARDWARE_MONITOR_LDN; + break; + case 0x41: + chip = Chip.F71882; + logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; + break; + } break; + case 0x06: + switch (revision) { + case 0x01: + chip = Chip.F71862; + logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; + break; + } break; + case 0x07: + switch (revision) { + case 0x23: + chip = Chip.F71889F; + logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; + break; + } break; + case 0x08: + switch (revision) { + case 0x14: + chip = Chip.F71869; + logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; + break; + } break; + case 0x09: + switch (revision) { + case 0x09: + chip = Chip.F71889ED; + logicalDeviceNumber = FINTEK_HARDWARE_MONITOR_LDN; + break; + } break; + case 0x52: + switch (revision) { + case 0x17: + case 0x3A: + case 0x41: + chip = Chip.W83627HF; + logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; + break; + } break; + case 0x82: + switch (revision) { + case 0x83: + chip = Chip.W83627THF; + logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; + break; + } break; + case 0x85: + switch (revision) { + case 0x41: + chip = Chip.W83687THF; + logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; + break; + } break; + case 0x88: + switch (revision & 0xF0) { + case 0x50: + case 0x60: + chip = Chip.W83627EHF; + logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; + break; + } break; + case 0xA0: + switch (revision & 0xF0) { + case 0x20: + chip = Chip.W83627DHG; + logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; + break; + } break; + case 0xA5: + switch (revision & 0xF0) { + case 0x10: + chip = Chip.W83667HG; + logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; + break; + } break; + case 0xB0: + switch (revision & 0xF0) { + case 0x70: + chip = Chip.W83627DHGP; + logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; + break; + } break; + case 0xB3: + switch (revision & 0xF0) { + case 0x50: + chip = Chip.W83667HGB; + logicalDeviceNumber = WINBOND_HARDWARE_MONITOR_LDN; + break; + } break; + } + if (chip == Chip.Unknown) { + if (id != 0 && id != 0xff) { + WinbondFintekExit(); + + report.Append("Chip ID: Unknown Winbond / Fintek with ID 0x"); + report.AppendLine(((id << 8) | revision).ToString("X")); + report.AppendLine(); + } + } else { + + Select(logicalDeviceNumber); + ushort address = ReadWord(BASE_ADDRESS_REGISTER); + Thread.Sleep(1); + ushort verify = ReadWord(BASE_ADDRESS_REGISTER); + + ushort vendorID = ReadWord(FINTEK_VENDOR_ID_REGISTER); + + WinbondFintekExit(); + + if (address != verify) { + report.Append("Chip ID: 0x"); + report.AppendLine(chip.ToString("X")); + report.Append("Chip revision: 0x"); + report.AppendLine(revision.ToString("X")); + report.AppendLine("Error: Address verification failed"); + report.AppendLine(); + return; + } + + // some Fintek chips have address register offset 0x05 added already + if ((address & 0x07) == 0x05) + address &= 0xFFF8; + + if (address < 0x100 || (address & 0xF007) != 0) { + report.Append("Chip ID: 0x"); + report.AppendLine(chip.ToString("X")); + report.Append("Chip revision: 0x"); + report.AppendLine(revision.ToString("X")); + report.Append("Error: Invalid address 0x"); + report.AppendLine(address.ToString("X")); + report.AppendLine(); + return; + } + + switch (chip) { + case Chip.W83627DHG: + case Chip.W83627DHGP: + case Chip.W83627EHF: + case Chip.W83627HF: + case Chip.W83627THF: + case Chip.W83667HG: + case Chip.W83667HGB: + case Chip.W83687THF: + W836XX w836XX = new W836XX(chip, revision, address); + if (w836XX.IsAvailable) + hardware.Add(w836XX); + break; + case Chip.F71858: + case Chip.F71862: + case Chip.F71869: + case Chip.F71882: + case Chip.F71889ED: + case Chip.F71889F: + if (vendorID != FINTEK_VENDOR_ID) { + report.Append("Chip ID: 0x"); + report.AppendLine(chip.ToString("X")); + report.Append("Chip revision: 0x"); + report.AppendLine(revision.ToString("X")); + report.Append("Error: Invalid vendor ID 0x"); + report.AppendLine(vendorID.ToString("X")); + report.AppendLine(); + return; + } + hardware.Add(new F718XX(chip, address)); + break; + default: break; + } + + return; + } + + IT87Enter(); + + ushort chipID = ReadWord(CHIP_ID_REGISTER); + switch (chipID) { + case 0x8712: chip = Chip.IT8712F; break; + case 0x8716: chip = Chip.IT8716F; break; + case 0x8718: chip = Chip.IT8718F; break; + case 0x8720: chip = Chip.IT8720F; break; + case 0x8726: chip = Chip.IT8726F; break; + default: chip = Chip.Unknown; break; + } + if (chip == Chip.Unknown) { + if (chipID != 0 && chipID != 0xffff) { + IT87Exit(); + + report.Append("Chip ID: Unknown ITE with ID 0x"); + report.AppendLine(chipID.ToString("X")); + report.AppendLine(); + } + } else { + Select(IT87_ENVIRONMENT_CONTROLLER_LDN); + ushort address = ReadWord(BASE_ADDRESS_REGISTER); + Thread.Sleep(1); + ushort verify = ReadWord(BASE_ADDRESS_REGISTER); + + IT87Exit(); + + if (address != verify || address < 0x100 || (address & 0xF007) != 0) { + report.Append("Chip ID: 0x"); + report.AppendLine(chip.ToString("X")); + report.Append("Error: Invalid address 0x"); + report.AppendLine(address.ToString("X")); + report.AppendLine(); + return; + } + + IT87XX it87 = new IT87XX(chip, address); + if (it87.IsAvailable) + hardware.Add(it87); + + return; + } + + SMSCEnter(); + + chipID = ReadWord(CHIP_ID_REGISTER); + switch (chipID) { + default: chip = Chip.Unknown; break; + } + if (chip == Chip.Unknown) { + if (chipID != 0 && chipID != 0xffff) { + SMSCExit(); + + report.Append("Chip ID: Unknown SMSC with ID 0x"); + report.AppendLine(chipID.ToString("X")); + report.AppendLine(); + } + } else { + SMSCExit(); + + return; + } + } + } + + public IHardware[] Hardware { + get { + return hardware.ToArray(); + } + } + + public string GetReport() { + if (report.Length > 0) { + report.Insert(0, "LPCIO" + Environment.NewLine + + Environment.NewLine); + return report.ToString(); + } else + return null; + } + } +} diff -r 70d0c3102424 -r 411b72b73d8f Hardware/LPC/W836XX.cs --- a/Hardware/LPC/W836XX.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/LPC/W836XX.cs Sun May 09 16:22:13 2010 +0000 @@ -206,7 +206,7 @@ return value > 0 ? target | mask : target & ~mask; } - public void Update() { + public override void Update() { foreach (Sensor sensor in voltages) { if (sensor.Index < 7) { @@ -300,7 +300,7 @@ } } - public string GetReport() { + public override string GetReport() { StringBuilder r = new StringBuilder(); r.AppendLine("LPC " + this.GetType().Name); diff -r 70d0c3102424 -r 411b72b73d8f Hardware/Mainboard/Mainboard.cs --- a/Hardware/Mainboard/Mainboard.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/Mainboard/Mainboard.cs Sun May 09 16:22:13 2010 +0000 @@ -47,7 +47,7 @@ private string name; private Image icon; - private LPCGroup lpcGroup; + private LPCIO lpcGroup; public Mainboard() { this.smbios = new SMBIOS(); @@ -68,7 +68,7 @@ } this.icon = Utilities.EmbeddedResources.GetImage("mainboard.png"); - this.lpcGroup = new LPCGroup(); + this.lpcGroup = new LPCIO(); } public string Name { @@ -97,9 +97,7 @@ public void Update() { } - public void Close() { - lpcGroup.Close(); - } + public void Close() { } public IHardware[] SubHardware { get { return lpcGroup.Hardware; } @@ -113,5 +111,14 @@ public event SensorEventHandler SensorAdded; public event SensorEventHandler SensorRemoved; #pragma warning restore 67 + + public void Accept(IVisitor visitor) { + visitor.VisitHardware(this); + } + + public void Traverse(IVisitor visitor) { + foreach (IHardware hardware in lpcGroup.Hardware) + hardware.Accept(visitor); + } } } diff -r 70d0c3102424 -r 411b72b73d8f Hardware/Nvidia/NvidiaGPU.cs --- a/Hardware/Nvidia/NvidiaGPU.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/Nvidia/NvidiaGPU.cs Sun May 09 16:22:13 2010 +0000 @@ -89,22 +89,18 @@ } } - public string Name { + public override string Name { get { return name; } } - public Identifier Identifier { + public override Identifier Identifier { get { return new Identifier("nvidiagpu", adapterIndex.ToString()); } } - public Image Icon { + public override Image Icon { get { return icon; } } - public string GetReport() { - return null; - } - private NvGPUThermalSettings GetThermalSettings() { NvGPUThermalSettings settings = new NvGPUThermalSettings(); settings.Version = NVAPI.GPU_THERMAL_SETTINGS_VER; @@ -117,7 +113,7 @@ return settings; } - public void Update() { + public override void Update() { NvGPUThermalSettings settings = GetThermalSettings(); foreach (Sensor sensor in temperatures) sensor.Value = settings.Sensor[sensor.Index].CurrentTemp; diff -r 70d0c3102424 -r 411b72b73d8f Hardware/Parameter.cs --- a/Hardware/Parameter.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/Parameter.cs Sun May 09 16:22:13 2010 +0000 @@ -114,6 +114,12 @@ Utilities.Config.Remove(Identifier.ToString()); } } - } + } + + public void Accept(IVisitor visitor) { + visitor.VisitParameter(this); + } + + public void Traverse(IVisitor visitor) { } } } diff -r 70d0c3102424 -r 411b72b73d8f Hardware/Sensor.cs --- a/Hardware/Sensor.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/Sensor.cs Sun May 09 16:22:13 2010 +0000 @@ -205,5 +205,14 @@ public float Value { get { return value; } } public DateTime Time { get { return time; } } } + + public void Accept(IVisitor visitor) { + visitor.VisitSensor(this); + } + + public void Traverse(IVisitor visitor) { + foreach (IParameter parameter in parameters) + parameter.Accept(visitor); + } } } diff -r 70d0c3102424 -r 411b72b73d8f Hardware/TBalancer/TBalancer.cs --- a/Hardware/TBalancer/TBalancer.cs Thu May 06 19:20:38 2010 +0000 +++ b/Hardware/TBalancer/TBalancer.cs Sun May 09 16:22:13 2010 +0000 @@ -341,5 +341,11 @@ public event SensorEventHandler SensorAdded; public event SensorEventHandler SensorRemoved; + + public void Accept(IVisitor visitor) { + visitor.VisitHardware(this); + } + + public void Traverse(IVisitor visitor) { } } } diff -r 70d0c3102424 -r 411b72b73d8f OpenHardwareMonitor.csproj --- a/OpenHardwareMonitor.csproj Thu May 06 19:20:38 2010 +0000 +++ b/OpenHardwareMonitor.csproj Sun May 09 16:22:13 2010 +0000 @@ -72,10 +72,12 @@ ParameterForm.cs + + @@ -86,6 +88,8 @@ + + @@ -115,7 +119,7 @@ - + Form diff -r 70d0c3102424 -r 411b72b73d8f Utilities/ListSet.cs --- a/Utilities/ListSet.cs Thu May 06 19:20:38 2010 +0000 +++ b/Utilities/ListSet.cs Sun May 09 16:22:13 2010 +0000 @@ -36,11 +36,12 @@ */ using System; +using System.Collections; using System.Collections.Generic; using System.Text; namespace OpenHardwareMonitor.Utilities { - public class ListSet { + public class ListSet : IEnumerable { private List list = new List(); @@ -65,6 +66,17 @@ public bool Contains(T item) { return list.Contains(item); } - + + public T[] ToArray() { + return list.ToArray(); + } + + public IEnumerator GetEnumerator() { + return list.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() { + return list.GetEnumerator(); + } } }