Added sub-hardware support and basic enumeration for mainboards.
authormoel.mich
Sat, 27 Feb 2010 20:08:13 +0000
changeset 6415181001ee61
parent 63 1a7c13ac7348
child 65 d94a9b712b64
Added sub-hardware support and basic enumeration for mainboards.
GUI/MainForm.cs
GUI/SensorSystemTray.cs
Hardware/Computer.cs
Hardware/HDD/HDD.cs
Hardware/Hardware.cs
Hardware/IHardware.cs
Hardware/Mainboard/Mainboard.cs
Hardware/Mainboard/MainboardGroup.cs
Hardware/Mainboard/Manufacturer.cs
Hardware/Mainboard/SMBIOS.cs
Hardware/SMBIOS/SMBIOSGroup.cs
Hardware/TBalancer/TBalancer.cs
OpenHardwareMonitor.csproj
     1.1 --- a/GUI/MainForm.cs	Sat Feb 27 15:55:17 2010 +0000
     1.2 +++ b/GUI/MainForm.cs	Sat Feb 27 20:08:13 2010 +0000
     1.3 @@ -159,8 +159,18 @@
     1.4        }
     1.5      }
     1.6  
     1.7 +    private void SubHardwareAdded(IHardware hardware, Node node) {
     1.8 +      Node hardwareNode = new HardwareNode(hardware);
     1.9 +      node.Nodes.Add(hardwareNode);
    1.10 +      foreach (IHardware subHardware in hardware.SubHardware)
    1.11 +        SubHardwareAdded(subHardware, hardwareNode);  
    1.12 +    }
    1.13 +
    1.14      private void HardwareAdded(IHardware hardware) {
    1.15 -      root.Nodes.Add(new HardwareNode(hardware));
    1.16 +      Node hardwareNode = new HardwareNode(hardware);
    1.17 +      root.Nodes.Add(hardwareNode);
    1.18 +      foreach (IHardware subHardware in hardware.SubHardware)
    1.19 +        SubHardwareAdded(subHardware, hardwareNode);     
    1.20      }
    1.21  
    1.22      private void HardwareRemoved(IHardware hardware) {      
    1.23 @@ -357,15 +367,25 @@
    1.24        UpdatePlotSelection(null, null);      
    1.25      }
    1.26  
    1.27 -    private void UpdateSensorTypeChecked(object sender, EventArgs e) {
    1.28 -      foreach (HardwareNode node in root.Nodes) {
    1.29 -        node.SetVisible(SensorType.Voltage, voltMenuItem.Checked);
    1.30 -        node.SetVisible(SensorType.Clock, clocksMenuItem.Checked);
    1.31 -        node.SetVisible(SensorType.Load, loadMenuItem.Checked);
    1.32 -        node.SetVisible(SensorType.Temperature, tempMenuItem.Checked);
    1.33 -        node.SetVisible(SensorType.Fan, fansMenuItem.Checked);
    1.34 -        node.SetVisible(SensorType.Flow, flowsMenuItem.Checked);
    1.35 -      }
    1.36 +    private void UpdateSensorTypeVisible(Node node) {
    1.37 +      HardwareNode hardwareNode = node as HardwareNode;
    1.38 +      if (hardwareNode == null)
    1.39 +        return;
    1.40 +
    1.41 +      hardwareNode.SetVisible(SensorType.Voltage, voltMenuItem.Checked);
    1.42 +      hardwareNode.SetVisible(SensorType.Clock, clocksMenuItem.Checked);
    1.43 +      hardwareNode.SetVisible(SensorType.Load, loadMenuItem.Checked);
    1.44 +      hardwareNode.SetVisible(SensorType.Temperature, tempMenuItem.Checked);
    1.45 +      hardwareNode.SetVisible(SensorType.Fan, fansMenuItem.Checked);
    1.46 +      hardwareNode.SetVisible(SensorType.Flow, flowsMenuItem.Checked);
    1.47 +
    1.48 +      foreach (Node n in node.Nodes)
    1.49 +        UpdateSensorTypeVisible(n);
    1.50 +    }
    1.51 +
    1.52 +    private void UpdateSensorTypeChecked(object sender, EventArgs e) {          
    1.53 +      foreach (HardwareNode node in root.Nodes) 
    1.54 +        UpdateSensorTypeVisible(node);
    1.55      }
    1.56  
    1.57      private void ToggleSysTray() {
     2.1 --- a/GUI/SensorSystemTray.cs	Sat Feb 27 15:55:17 2010 +0000
     2.2 +++ b/GUI/SensorSystemTray.cs	Sat Feb 27 20:08:13 2010 +0000
     2.3 @@ -59,13 +59,17 @@
     2.4        hardware.SensorRemoved -= new SensorEventHandler(SensorRemoved);
     2.5        foreach (ISensor sensor in hardware.Sensors) 
     2.6          SensorRemoved(sensor);
     2.7 +      foreach (IHardware subHardware in hardware.SubHardware)
     2.8 +        HardwareRemoved(subHardware);
     2.9      }
    2.10 -   
    2.11 +
    2.12      private void HardwareAdded(IHardware hardware) {
    2.13        foreach (ISensor sensor in hardware.Sensors)
    2.14          SensorAdded(sensor);
    2.15        hardware.SensorAdded += new SensorEventHandler(SensorAdded);
    2.16        hardware.SensorRemoved += new SensorEventHandler(SensorRemoved);
    2.17 +      foreach (IHardware subHardware in hardware.SubHardware)
    2.18 +        HardwareAdded(subHardware);
    2.19      }
    2.20  
    2.21      private void SensorAdded(ISensor sensor) {
     3.1 --- a/Hardware/Computer.cs	Sat Feb 27 15:55:17 2010 +0000
     3.2 +++ b/Hardware/Computer.cs	Sat Feb 27 20:08:13 2010 +0000
     3.3 @@ -61,7 +61,7 @@
     3.4        groups.Add(group);
     3.5  
     3.6        if (HardwareAdded != null)
     3.7 -        foreach (IHardware hardware in group.Hardware)
     3.8 +        foreach (IHardware hardware in group.Hardware) 
     3.9            HardwareAdded(hardware);
    3.10      }
    3.11  
    3.12 @@ -72,7 +72,7 @@
    3.13        groups.Remove(group);
    3.14  
    3.15        if (HardwareRemoved != null)
    3.16 -        foreach (IHardware hardware in group.Hardware)
    3.17 +        foreach (IHardware hardware in group.Hardware) 
    3.18            HardwareRemoved(hardware);
    3.19      }
    3.20  
    3.21 @@ -80,8 +80,7 @@
    3.22        if (open)
    3.23          return;
    3.24  
    3.25 -      Add(new SMBIOS.SMBIOSGroup());
    3.26 -      Add(new LPC.LPCGroup());
    3.27 +      Add(new Mainboard.MainboardGroup());
    3.28        Add(new CPU.CPUGroup());
    3.29        Add(new ATI.ATIGroup());
    3.30        Add(new Nvidia.NvidiaGroup());
    3.31 @@ -93,10 +92,19 @@
    3.32        open = true;
    3.33      }
    3.34  
    3.35 +    private void SubHardwareUpdate(IHardware hardware) {
    3.36 +      foreach (IHardware subHardware in hardware.SubHardware) {
    3.37 +        subHardware.Update();
    3.38 +        SubHardwareUpdate(subHardware);
    3.39 +      }
    3.40 +    }
    3.41 +
    3.42      public void Update() {
    3.43        foreach (IGroup group in groups)
    3.44 -        foreach (IHardware hardware in group.Hardware)
    3.45 +        foreach (IHardware hardware in group.Hardware) {
    3.46            hardware.Update();
    3.47 +          SubHardwareUpdate(hardware);
    3.48 +        }
    3.49      }
    3.50  
    3.51      public bool HDDEnabled {
    3.52 @@ -131,6 +139,38 @@
    3.53        writer.WriteLine();
    3.54      }
    3.55  
    3.56 +    private void ReportHardwareTree(IHardware hardware, TextWriter w, 
    3.57 +      string space) 
    3.58 +    {
    3.59 +      w.WriteLine("{0}|", space);
    3.60 +      w.WriteLine("{0}+-+ {1} ({2})", 
    3.61 +        space, hardware.Name, hardware.Identifier);
    3.62 +      foreach (ISensor sensor in hardware.Sensors) {
    3.63 +        w.WriteLine("{0}|   +- {1} : {2} : {3} : {4}",
    3.64 +          space, sensor.SensorType, sensor.Index, sensor.Name,
    3.65 +            string.Format(CultureInfo.InvariantCulture, "{0} : {1} : {2}",
    3.66 +            sensor.Value, sensor.Min, sensor.Max));
    3.67 +        foreach (IParameter parameter in sensor.Parameters) {
    3.68 +          w.WriteLine("{0}|      +- {1} : {2} : {3}",
    3.69 +            space, parameter.Name, parameter.IsDefault,
    3.70 +            string.Format(CultureInfo.InvariantCulture, "{0} : {1}",
    3.71 +              parameter.DefaultValue, parameter.Value));
    3.72 +        }
    3.73 +      }
    3.74 +      foreach (IHardware subHardware in hardware.SubHardware)
    3.75 +        ReportHardwareTree(subHardware, w, "|   ");
    3.76 +    }
    3.77 +
    3.78 +    private void ReportHardware(IHardware hardware, TextWriter w) {
    3.79 +      string hardwareReport = hardware.GetReport();
    3.80 +      if (hardwareReport != null && hardwareReport != "") {
    3.81 +        NewSection(w);
    3.82 +        w.Write(hardwareReport);
    3.83 +      }
    3.84 +      foreach (IHardware subHardware in hardware.SubHardware)
    3.85 +        ReportHardware(subHardware, w);
    3.86 +    }
    3.87 +
    3.88      public void SaveReport(Version version) {
    3.89  
    3.90        using (TextWriter w =
    3.91 @@ -146,23 +186,8 @@
    3.92  
    3.93          NewSection(w);
    3.94          foreach (IGroup group in groups) {
    3.95 -          foreach (IHardware hardware in group.Hardware) {
    3.96 -            w.WriteLine("|");
    3.97 -            w.WriteLine("+-+ {0} ({1})",
    3.98 -              new object[] { hardware.Name, hardware.Identifier });
    3.99 -            foreach (ISensor sensor in hardware.Sensors) {
   3.100 -              w.WriteLine("|   +- {0} : {1} : {2} : {3}",
   3.101 -                sensor.SensorType, sensor.Index, sensor.Name, 
   3.102 -                  string.Format(CultureInfo.InvariantCulture, "{0} : {1} : {2}", 
   3.103 -                  sensor.Value, sensor.Min, sensor.Max) );
   3.104 -              foreach (IParameter parameter in sensor.Parameters) {
   3.105 -                w.WriteLine("|      +- {0} : {1} : {2}",
   3.106 -                  parameter.Name, parameter.IsDefault,   
   3.107 -                  string.Format(CultureInfo.InvariantCulture, "{0} : {1}", 
   3.108 -                    parameter.DefaultValue, parameter.Value) );
   3.109 -              }
   3.110 -            }
   3.111 -          }
   3.112 +          foreach (IHardware hardware in group.Hardware)
   3.113 +            ReportHardwareTree(hardware, w, "");          
   3.114          }
   3.115          w.WriteLine();
   3.116  
   3.117 @@ -174,13 +199,9 @@
   3.118            }
   3.119  
   3.120            IHardware[] hardwareArray = group.Hardware;
   3.121 -          foreach (IHardware hardware in hardwareArray) {
   3.122 -            string hardwareReport = hardware.GetReport();
   3.123 -            if (hardwareReport != null && hardwareReport != "") {
   3.124 -              NewSection(w);
   3.125 -              w.Write(hardwareReport);
   3.126 -            }
   3.127 -          }
   3.128 +          foreach (IHardware hardware in hardwareArray)
   3.129 +            ReportHardware(hardware, w);
   3.130 +          
   3.131          }
   3.132        }
   3.133      }
   3.134 @@ -199,7 +220,5 @@
   3.135      public event HardwareEventHandler HardwareAdded;
   3.136      public event HardwareEventHandler HardwareRemoved;
   3.137  
   3.138 -
   3.139 -
   3.140    }
   3.141  }
     4.1 --- a/Hardware/HDD/HDD.cs	Sat Feb 27 15:55:17 2010 +0000
     4.2 +++ b/Hardware/HDD/HDD.cs	Sat Feb 27 20:08:13 2010 +0000
     4.3 @@ -77,6 +77,10 @@
     4.4        get { return icon; }
     4.5      }
     4.6  
     4.7 +    public IHardware[] SubHardware {
     4.8 +      get { return new IHardware[0]; }
     4.9 +    }
    4.10 +
    4.11      public ISensor[] Sensors {
    4.12        get {
    4.13          return new ISensor[] { temperature };
     5.1 --- a/Hardware/Hardware.cs	Sat Feb 27 15:55:17 2010 +0000
     5.2 +++ b/Hardware/Hardware.cs	Sat Feb 27 20:08:13 2010 +0000
     5.3 @@ -43,6 +43,10 @@
     5.4  
     5.5      private List<ISensor> active = new List<ISensor>();
     5.6  
     5.7 +    public IHardware[] SubHardware {
     5.8 +      get { return new IHardware[0]; }
     5.9 +    }
    5.10 +
    5.11      public ISensor[] Sensors {
    5.12        get { return active.ToArray(); }
    5.13      }
    5.14 @@ -63,7 +67,9 @@
    5.15        }
    5.16      }
    5.17  
    5.18 +    #pragma warning disable 67
    5.19      public event SensorEventHandler SensorAdded;
    5.20      public event SensorEventHandler SensorRemoved;
    5.21 +    #pragma warning restore 67
    5.22    }
    5.23  }
     6.1 --- a/Hardware/IHardware.cs	Sat Feb 27 15:55:17 2010 +0000
     6.2 +++ b/Hardware/IHardware.cs	Sat Feb 27 20:08:13 2010 +0000
     6.3 @@ -54,6 +54,8 @@
     6.4  
     6.5      void Update();
     6.6  
     6.7 +    IHardware[] SubHardware { get; }
     6.8 +
     6.9      ISensor[] Sensors { get; }
    6.10  
    6.11      event SensorEventHandler SensorAdded;
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/Hardware/Mainboard/Mainboard.cs	Sat Feb 27 20:08:13 2010 +0000
     7.3 @@ -0,0 +1,109 @@
     7.4 +/*
     7.5 +  
     7.6 +  Version: MPL 1.1/GPL 2.0/LGPL 2.1
     7.7 +
     7.8 +  The contents of this file are subject to the Mozilla Public License Version
     7.9 +  1.1 (the "License"); you may not use this file except in compliance with
    7.10 +  the License. You may obtain a copy of the License at
    7.11 + 
    7.12 +  http://www.mozilla.org/MPL/
    7.13 +
    7.14 +  Software distributed under the License is distributed on an "AS IS" basis,
    7.15 +  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
    7.16 +  for the specific language governing rights and limitations under the License.
    7.17 +
    7.18 +  The Original Code is the Open Hardware Monitor code.
    7.19 +
    7.20 +  The Initial Developer of the Original Code is 
    7.21 +  Michael Möller <m.moeller@gmx.ch>.
    7.22 +  Portions created by the Initial Developer are Copyright (C) 2009-2010
    7.23 +  the Initial Developer. All Rights Reserved.
    7.24 +
    7.25 +  Contributor(s):
    7.26 +
    7.27 +  Alternatively, the contents of this file may be used under the terms of
    7.28 +  either the GNU General Public License Version 2 or later (the "GPL"), or
    7.29 +  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    7.30 +  in which case the provisions of the GPL or the LGPL are applicable instead
    7.31 +  of those above. If you wish to allow use of your version of this file only
    7.32 +  under the terms of either the GPL or the LGPL, and not to allow others to
    7.33 +  use your version of this file under the terms of the MPL, indicate your
    7.34 +  decision by deleting the provisions above and replace them with the notice
    7.35 +  and other provisions required by the GPL or the LGPL. If you do not delete
    7.36 +  the provisions above, a recipient may use your version of this file under
    7.37 +  the terms of any one of the MPL, the GPL or the LGPL.
    7.38 + 
    7.39 +*/
    7.40 +
    7.41 +using System;
    7.42 +using System.Collections.Generic;
    7.43 +using System.Drawing;
    7.44 +using System.Text;
    7.45 +using OpenHardwareMonitor.Hardware.LPC;
    7.46 +
    7.47 +namespace OpenHardwareMonitor.Hardware.Mainboard {
    7.48 +  public class Mainboard : IHardware {
    7.49 +    private SMBIOS smbios;
    7.50 +    private string name;
    7.51 +    private Image icon;
    7.52 +
    7.53 +    private LPCGroup lpcGroup;
    7.54 +
    7.55 +    public Mainboard() {
    7.56 +      this.smbios = new SMBIOS();
    7.57 +      if (smbios.Board != null && smbios.Board.ProductName != null
    7.58 +        && smbios.Board.ProductName != "") {
    7.59 +        if (smbios.Board.Manufacturer == Manufacturer.Unkown)
    7.60 +          this.name = smbios.Board.ProductName;
    7.61 +        else
    7.62 +          this.name = smbios.Board.Manufacturer + " " + 
    7.63 +            smbios.Board.ProductName;
    7.64 +      } else {
    7.65 +        this.name = smbios.Board.Manufacturer.ToString();
    7.66 +      }
    7.67 +      this.icon = Utilities.EmbeddedResources.GetImage("mainboard.png");
    7.68 +      this.lpcGroup = new LPCGroup();
    7.69 +    }
    7.70 +
    7.71 +    public string Name {
    7.72 +      get { return name; } 
    7.73 +    }
    7.74 +
    7.75 +    public string Identifier {
    7.76 +      get { return "/mainboard"; }
    7.77 +    }
    7.78 +
    7.79 +    public Image Icon {
    7.80 +      get { return icon; }
    7.81 +    }
    7.82 +
    7.83 +    public string GetReport() {
    7.84 +      StringBuilder r = new StringBuilder(); 
    7.85 +
    7.86 +      r.AppendLine("Mainboard");
    7.87 +      r.AppendLine();           
    7.88 +      r.Append(smbios.GetReport());
    7.89 +
    7.90 +      return r.ToString();
    7.91 +    }
    7.92 +
    7.93 +    public void Update() { }
    7.94 +
    7.95 +    public void Close() {
    7.96 +      lpcGroup.Close();
    7.97 +    }
    7.98 +
    7.99 +    public IHardware[] SubHardware {
   7.100 +      get { return lpcGroup.Hardware; }
   7.101 +    }
   7.102 +
   7.103 +    public ISensor[] Sensors {
   7.104 +      get { return new ISensor[0]; }
   7.105 +    }
   7.106 +
   7.107 +    #pragma warning disable 67
   7.108 +    public event SensorEventHandler SensorAdded;
   7.109 +    public event SensorEventHandler SensorRemoved;
   7.110 +    #pragma warning restore 67
   7.111 +  }
   7.112 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/Hardware/Mainboard/MainboardGroup.cs	Sat Feb 27 20:08:13 2010 +0000
     8.3 @@ -0,0 +1,65 @@
     8.4 +/*
     8.5 +  
     8.6 +  Version: MPL 1.1/GPL 2.0/LGPL 2.1
     8.7 +
     8.8 +  The contents of this file are subject to the Mozilla Public License Version
     8.9 +  1.1 (the "License"); you may not use this file except in compliance with
    8.10 +  the License. You may obtain a copy of the License at
    8.11 + 
    8.12 +  http://www.mozilla.org/MPL/
    8.13 +
    8.14 +  Software distributed under the License is distributed on an "AS IS" basis,
    8.15 +  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
    8.16 +  for the specific language governing rights and limitations under the License.
    8.17 +
    8.18 +  The Original Code is the Open Hardware Monitor code.
    8.19 +
    8.20 +  The Initial Developer of the Original Code is 
    8.21 +  Michael Möller <m.moeller@gmx.ch>.
    8.22 +  Portions created by the Initial Developer are Copyright (C) 2009-2010
    8.23 +  the Initial Developer. All Rights Reserved.
    8.24 +
    8.25 +  Contributor(s):
    8.26 +
    8.27 +  Alternatively, the contents of this file may be used under the terms of
    8.28 +  either the GNU General Public License Version 2 or later (the "GPL"), or
    8.29 +  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    8.30 +  in which case the provisions of the GPL or the LGPL are applicable instead
    8.31 +  of those above. If you wish to allow use of your version of this file only
    8.32 +  under the terms of either the GPL or the LGPL, and not to allow others to
    8.33 +  use your version of this file under the terms of the MPL, indicate your
    8.34 +  decision by deleting the provisions above and replace them with the notice
    8.35 +  and other provisions required by the GPL or the LGPL. If you do not delete
    8.36 +  the provisions above, a recipient may use your version of this file under
    8.37 +  the terms of any one of the MPL, the GPL or the LGPL.
    8.38 + 
    8.39 +*/
    8.40 +
    8.41 +using System;
    8.42 +using System.Collections.Generic;
    8.43 +
    8.44 +namespace OpenHardwareMonitor.Hardware.Mainboard {
    8.45 +  public class MainboardGroup : IGroup {
    8.46 +
    8.47 +    private Mainboard[] mainboards;
    8.48 +
    8.49 +    public MainboardGroup() {
    8.50 +      mainboards = new Mainboard[1];
    8.51 +      mainboards[0] = new Mainboard();
    8.52 +    }
    8.53 +
    8.54 +    public void Close() {
    8.55 +      foreach (Mainboard mainboard in mainboards)
    8.56 +        mainboard.Close();
    8.57 +    }
    8.58 +
    8.59 +    public string GetReport() {
    8.60 +      return null;
    8.61 +    }
    8.62 +
    8.63 +    public IHardware[] Hardware {
    8.64 +      get { return mainboards; }
    8.65 +
    8.66 +    }
    8.67 +  }
    8.68 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/Hardware/Mainboard/Manufacturer.cs	Sat Feb 27 20:08:13 2010 +0000
     9.3 @@ -0,0 +1,52 @@
     9.4 +/*
     9.5 +  
     9.6 +  Version: MPL 1.1/GPL 2.0/LGPL 2.1
     9.7 +
     9.8 +  The contents of this file are subject to the Mozilla Public License Version
     9.9 +  1.1 (the "License"); you may not use this file except in compliance with
    9.10 +  the License. You may obtain a copy of the License at
    9.11 + 
    9.12 +  http://www.mozilla.org/MPL/
    9.13 +
    9.14 +  Software distributed under the License is distributed on an "AS IS" basis,
    9.15 +  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
    9.16 +  for the specific language governing rights and limitations under the License.
    9.17 +
    9.18 +  The Original Code is the Open Hardware Monitor code.
    9.19 +
    9.20 +  The Initial Developer of the Original Code is 
    9.21 +  Michael Möller <m.moeller@gmx.ch>.
    9.22 +  Portions created by the Initial Developer are Copyright (C) 2009-2010
    9.23 +  the Initial Developer. All Rights Reserved.
    9.24 +
    9.25 +  Contributor(s):
    9.26 +
    9.27 +  Alternatively, the contents of this file may be used under the terms of
    9.28 +  either the GNU General Public License Version 2 or later (the "GPL"), or
    9.29 +  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    9.30 +  in which case the provisions of the GPL or the LGPL are applicable instead
    9.31 +  of those above. If you wish to allow use of your version of this file only
    9.32 +  under the terms of either the GPL or the LGPL, and not to allow others to
    9.33 +  use your version of this file under the terms of the MPL, indicate your
    9.34 +  decision by deleting the provisions above and replace them with the notice
    9.35 +  and other provisions required by the GPL or the LGPL. If you do not delete
    9.36 +  the provisions above, a recipient may use your version of this file under
    9.37 +  the terms of any one of the MPL, the GPL or the LGPL.
    9.38 + 
    9.39 +*/
    9.40 +
    9.41 +using System;
    9.42 +using System.Collections.Generic;
    9.43 +
    9.44 +namespace OpenHardwareMonitor.Hardware.Mainboard {
    9.45 +  
    9.46 +  public enum Manufacturer {
    9.47 +    ASUS,
    9.48 +    DFI,
    9.49 +    EPoX,
    9.50 +    Gigabyte,
    9.51 +    MSI,
    9.52 +    Unkown    
    9.53 +  }
    9.54 +
    9.55 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/Hardware/Mainboard/SMBIOS.cs	Sat Feb 27 20:08:13 2010 +0000
    10.3 @@ -0,0 +1,223 @@
    10.4 +/*
    10.5 +  
    10.6 +  Version: MPL 1.1/GPL 2.0/LGPL 2.1
    10.7 +
    10.8 +  The contents of this file are subject to the Mozilla Public License Version
    10.9 +  1.1 (the "License"); you may not use this file except in compliance with
   10.10 +  the License. You may obtain a copy of the License at
   10.11 + 
   10.12 +  http://www.mozilla.org/MPL/
   10.13 +
   10.14 +  Software distributed under the License is distributed on an "AS IS" basis,
   10.15 +  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
   10.16 +  for the specific language governing rights and limitations under the License.
   10.17 +
   10.18 +  The Original Code is the Open Hardware Monitor code.
   10.19 +
   10.20 +  The Initial Developer of the Original Code is 
   10.21 +  Michael Möller <m.moeller@gmx.ch>.
   10.22 +  Portions created by the Initial Developer are Copyright (C) 2009-2010
   10.23 +  the Initial Developer. All Rights Reserved.
   10.24 +
   10.25 +  Contributor(s):
   10.26 +
   10.27 +  Alternatively, the contents of this file may be used under the terms of
   10.28 +  either the GNU General Public License Version 2 or later (the "GPL"), or
   10.29 +  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
   10.30 +  in which case the provisions of the GPL or the LGPL are applicable instead
   10.31 +  of those above. If you wish to allow use of your version of this file only
   10.32 +  under the terms of either the GPL or the LGPL, and not to allow others to
   10.33 +  use your version of this file under the terms of the MPL, indicate your
   10.34 +  decision by deleting the provisions above and replace them with the notice
   10.35 +  and other provisions required by the GPL or the LGPL. If you do not delete
   10.36 +  the provisions above, a recipient may use your version of this file under
   10.37 +  the terms of any one of the MPL, the GPL or the LGPL.
   10.38 + 
   10.39 +*/
   10.40 +
   10.41 +using System;
   10.42 +using System.Collections.Generic;
   10.43 +using System.Management;
   10.44 +using System.Text;
   10.45 +
   10.46 +namespace OpenHardwareMonitor.Hardware.Mainboard {
   10.47 +
   10.48 +  public class SMBIOS {
   10.49 +
   10.50 +    private Structure[] table;
   10.51 +
   10.52 +    private BIOSInformation biosInformation = null;
   10.53 +    private BaseBoardInformation baseBoardInformation = null;
   10.54 +
   10.55 +    public SMBIOS() {
   10.56 +      int p = (int)System.Environment.OSVersion.Platform;
   10.57 +      if ((p == 4) || (p == 128))
   10.58 +        return;
   10.59 +      
   10.60 +      List<Structure> structureList = new List<Structure>();
   10.61 +
   10.62 +      try {
   10.63 +        ManagementObjectCollection collection = new ManagementObjectSearcher(
   10.64 +          "root\\WMI", "SELECT SMBiosData FROM MSSMBios_RawSMBiosTables").Get();
   10.65 +
   10.66 +        byte[] raw = null;
   10.67 +        foreach (ManagementObject mo in collection) {
   10.68 +          raw = (byte[])mo["SMBiosData"];
   10.69 +          break;
   10.70 +        }
   10.71 +
   10.72 +        if (raw != null && raw.Length > 0) {
   10.73 +          int offset = 0;
   10.74 +          byte type = raw[offset];
   10.75 +          while (offset < raw.Length && type != 127) {
   10.76 +
   10.77 +            type = raw[offset]; offset++;
   10.78 +            int length = raw[offset]; offset++;
   10.79 +            ushort handle = (ushort)((raw[offset] << 8) | raw[offset + 1]);
   10.80 +            offset += 2;
   10.81 +
   10.82 +            byte[] data = new byte[length];
   10.83 +            Array.Copy(raw, offset - 4, data, 0, length); offset += length - 4;
   10.84 +
   10.85 +            List<string> stringsList = new List<string>();
   10.86 +            if (raw[offset] == 0)
   10.87 +              offset++;
   10.88 +            while (raw[offset] != 0) {
   10.89 +              StringBuilder sb = new StringBuilder();
   10.90 +              while (raw[offset] != 0) {
   10.91 +                sb.Append((char)raw[offset]); offset++;
   10.92 +              }
   10.93 +              offset++;
   10.94 +              stringsList.Add(sb.ToString());
   10.95 +            }
   10.96 +            offset++;
   10.97 +            switch (type) {
   10.98 +              case 0x00:
   10.99 +                this.biosInformation = new BIOSInformation(
  10.100 +                  type, handle, data, stringsList.ToArray());
  10.101 +                structureList.Add(this.biosInformation); break;
  10.102 +              case 0x02: this.baseBoardInformation = new BaseBoardInformation(
  10.103 +                  type, handle, data, stringsList.ToArray());
  10.104 +                structureList.Add(this.baseBoardInformation); break;
  10.105 +              default: structureList.Add(new Structure(
  10.106 +                type, handle, data, stringsList.ToArray())); break;
  10.107 +            }
  10.108 +          }
  10.109 +        }
  10.110 +      } catch (NotImplementedException) { } catch (ManagementException) { }
  10.111 +      
  10.112 +      table = structureList.ToArray();
  10.113 +    }
  10.114 +
  10.115 +    public string GetReport() {
  10.116 +      StringBuilder r = new StringBuilder();      
  10.117 +
  10.118 +      if (biosInformation != null) {
  10.119 +        r.Append("BIOS Vendor: "); r.AppendLine(biosInformation.Vendor);
  10.120 +        r.Append("BIOS Version: "); r.AppendLine(biosInformation.Version);
  10.121 +        r.AppendLine();
  10.122 +      }
  10.123 +
  10.124 +      if (baseBoardInformation != null) {
  10.125 +        r.Append("Mainboard Manufacturer: "); 
  10.126 +        r.AppendLine(baseBoardInformation.ManufacturerName);
  10.127 +        r.Append("Mainboard Name: "); 
  10.128 +        r.AppendLine(baseBoardInformation.ProductName);
  10.129 +        r.AppendLine();
  10.130 +      }
  10.131 +     
  10.132 +      return r.ToString();
  10.133 +    }
  10.134 +
  10.135 +    public BIOSInformation BIOS {
  10.136 +      get { return biosInformation; }
  10.137 +    }
  10.138 +
  10.139 +    public BaseBoardInformation Board {
  10.140 +      get { return baseBoardInformation; }
  10.141 +    }
  10.142 +
  10.143 +    public class Structure {
  10.144 +      private byte type;
  10.145 +      private ushort handle;
  10.146 +
  10.147 +      private byte[] data;
  10.148 +      private string[] strings;
  10.149 +
  10.150 +      protected string GetString(int offset) {
  10.151 +        if (offset < data.Length && data[offset] > 0 &&
  10.152 +         data[offset] <= strings.Length)
  10.153 +          return strings[data[offset] - 1];
  10.154 +        else
  10.155 +          return "";
  10.156 +      }
  10.157 +
  10.158 +      public Structure(byte type, ushort handle, byte[] data, string[] strings) 
  10.159 +      {
  10.160 +        this.type = type;
  10.161 +        this.handle = handle;
  10.162 +        this.data = data;
  10.163 +        this.strings = strings;
  10.164 +      }
  10.165 +
  10.166 +      public byte Type { get { return type; } }
  10.167 +
  10.168 +      public ushort Handle { get { return handle; } }
  10.169 +    }
  10.170 +
  10.171 +    public class BIOSInformation : Structure {
  10.172 +
  10.173 +      private string vendor;
  10.174 +      private string version;
  10.175 +
  10.176 +      public BIOSInformation(byte type, ushort handle, byte[] data,
  10.177 +        string[] strings)
  10.178 +        : base(type, handle, data, strings) {
  10.179 +
  10.180 +        this.vendor = GetString(0x04);
  10.181 +        this.version = GetString(0x05);
  10.182 +      }
  10.183 +
  10.184 +      public string Vendor { get { return vendor; } }
  10.185 +
  10.186 +      public string Version { get { return version; } }
  10.187 +    }
  10.188 +
  10.189 +    public class BaseBoardInformation : Structure {
  10.190 +
  10.191 +      private string manufacturerName;
  10.192 +      private string productName;
  10.193 +      private Manufacturer manufacturer;
  10.194 +
  10.195 +      public BaseBoardInformation(byte type, ushort handle, byte[] data,
  10.196 +        string[] strings)
  10.197 +        : base(type, handle, data, strings) {
  10.198 +
  10.199 +        this.manufacturerName = GetString(0x04).Trim();
  10.200 +        this.productName = GetString(0x05).Trim();
  10.201 +
  10.202 +        switch (manufacturerName) {
  10.203 +          case "ASUSTeK Computer INC.":
  10.204 +            manufacturer = Manufacturer.ASUS; break;
  10.205 +          case "DFI":
  10.206 +          case "DFI Inc.:":
  10.207 +            manufacturer = Manufacturer.DFI; break;
  10.208 +          case "EPoX COMPUTER CO., LTD":
  10.209 +            manufacturer = Manufacturer.EPoX; break;
  10.210 +          case "Gigabyte Technology Co., Ltd.":
  10.211 +            manufacturer = Manufacturer.Gigabyte; break;
  10.212 +          case "MICRO-STAR INTERNATIONAL CO., LTD":
  10.213 +            manufacturer = Manufacturer.MSI; break;
  10.214 +          default:
  10.215 +            manufacturer = Manufacturer.Unkown; break;
  10.216 +        }
  10.217 +      }
  10.218 +
  10.219 +      public string ManufacturerName { get { return manufacturerName; } }
  10.220 +
  10.221 +      public string ProductName { get { return productName; } }
  10.222 +
  10.223 +      public Manufacturer Manufacturer { get { return manufacturer; } }
  10.224 +    }
  10.225 +  }
  10.226 +}
    11.1 --- a/Hardware/SMBIOS/SMBIOSGroup.cs	Sat Feb 27 15:55:17 2010 +0000
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,204 +0,0 @@
    11.4 -/*
    11.5 -  
    11.6 -  Version: MPL 1.1/GPL 2.0/LGPL 2.1
    11.7 -
    11.8 -  The contents of this file are subject to the Mozilla Public License Version
    11.9 -  1.1 (the "License"); you may not use this file except in compliance with
   11.10 -  the License. You may obtain a copy of the License at
   11.11 - 
   11.12 -  http://www.mozilla.org/MPL/
   11.13 -
   11.14 -  Software distributed under the License is distributed on an "AS IS" basis,
   11.15 -  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
   11.16 -  for the specific language governing rights and limitations under the License.
   11.17 -
   11.18 -  The Original Code is the Open Hardware Monitor code.
   11.19 -
   11.20 -  The Initial Developer of the Original Code is 
   11.21 -  Michael Möller <m.moeller@gmx.ch>.
   11.22 -  Portions created by the Initial Developer are Copyright (C) 2009-2010
   11.23 -  the Initial Developer. All Rights Reserved.
   11.24 -
   11.25 -  Contributor(s):
   11.26 -
   11.27 -  Alternatively, the contents of this file may be used under the terms of
   11.28 -  either the GNU General Public License Version 2 or later (the "GPL"), or
   11.29 -  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
   11.30 -  in which case the provisions of the GPL or the LGPL are applicable instead
   11.31 -  of those above. If you wish to allow use of your version of this file only
   11.32 -  under the terms of either the GPL or the LGPL, and not to allow others to
   11.33 -  use your version of this file under the terms of the MPL, indicate your
   11.34 -  decision by deleting the provisions above and replace them with the notice
   11.35 -  and other provisions required by the GPL or the LGPL. If you do not delete
   11.36 -  the provisions above, a recipient may use your version of this file under
   11.37 -  the terms of any one of the MPL, the GPL or the LGPL.
   11.38 - 
   11.39 -*/
   11.40 -
   11.41 -using System;
   11.42 -using System.Collections.Generic;
   11.43 -using System.Management;
   11.44 -using System.Text;
   11.45 -
   11.46 -namespace OpenHardwareMonitor.Hardware.SMBIOS {
   11.47 -
   11.48 -  public class SMBIOSGroup : IGroup {
   11.49 -
   11.50 -    private Structure[] table;
   11.51 -
   11.52 -    private BIOSInformation biosInformation = null;
   11.53 -
   11.54 -    private BaseBoardInformation baseBoardInformation = null;
   11.55 -
   11.56 -    public SMBIOSGroup() {
   11.57 -      int p = (int)System.Environment.OSVersion.Platform;
   11.58 -      if ((p == 4) || (p == 128))
   11.59 -        return;
   11.60 -      
   11.61 -      List<Structure> structureList = new List<Structure>();
   11.62 -
   11.63 -      try {
   11.64 -        ManagementObjectCollection collection = new ManagementObjectSearcher(
   11.65 -          "root\\WMI", "SELECT SMBiosData FROM MSSMBios_RawSMBiosTables").Get();
   11.66 -
   11.67 -        byte[] raw = null;
   11.68 -        foreach (ManagementObject mo in collection) {
   11.69 -          raw = (byte[])mo["SMBiosData"];
   11.70 -          break;
   11.71 -        }
   11.72 -
   11.73 -        if (raw != null && raw.Length > 0) {
   11.74 -          int offset = 0;
   11.75 -          byte type = raw[offset];
   11.76 -          while (offset < raw.Length && type != 127) {
   11.77 -
   11.78 -            type = raw[offset]; offset++;
   11.79 -            int length = raw[offset]; offset++;
   11.80 -            ushort handle = (ushort)((raw[offset] << 8) | raw[offset + 1]);
   11.81 -            offset += 2;
   11.82 -
   11.83 -            byte[] data = new byte[length];
   11.84 -            Array.Copy(raw, offset - 4, data, 0, length); offset += length - 4;
   11.85 -
   11.86 -            List<string> stringsList = new List<string>();
   11.87 -            if (raw[offset] == 0)
   11.88 -              offset++;
   11.89 -            while (raw[offset] != 0) {
   11.90 -              StringBuilder sb = new StringBuilder();
   11.91 -              while (raw[offset] != 0) {
   11.92 -                sb.Append((char)raw[offset]); offset++;
   11.93 -              }
   11.94 -              offset++;
   11.95 -              stringsList.Add(sb.ToString());
   11.96 -            }
   11.97 -            offset++;
   11.98 -            switch (type) {
   11.99 -              case 0x00:
  11.100 -                this.biosInformation = new BIOSInformation(
  11.101 -                  type, handle, data, stringsList.ToArray());
  11.102 -                structureList.Add(this.biosInformation); break;
  11.103 -              case 0x02: this.baseBoardInformation = new BaseBoardInformation(
  11.104 -                  type, handle, data, stringsList.ToArray());
  11.105 -                structureList.Add(this.baseBoardInformation); break;
  11.106 -              default: structureList.Add(new Structure(
  11.107 -                type, handle, data, stringsList.ToArray())); break;
  11.108 -            }
  11.109 -          }
  11.110 -        }
  11.111 -      } catch (NotImplementedException) { } catch (ManagementException) { }
  11.112 -      
  11.113 -      table = structureList.ToArray();
  11.114 -    }
  11.115 -
  11.116 -    public IHardware[] Hardware { get { return new IHardware[0]; } }
  11.117 -
  11.118 -    public string GetReport() {
  11.119 -      StringBuilder r = new StringBuilder();
  11.120 -
  11.121 -      r.AppendLine("SMBIOS");
  11.122 -      r.AppendLine();
  11.123 -
  11.124 -      if (biosInformation != null) {
  11.125 -        r.Append("BIOS Vendor: "); r.AppendLine(biosInformation.Vendor);
  11.126 -        r.Append("BIOS Version: "); r.AppendLine(biosInformation.Version);
  11.127 -        r.AppendLine();
  11.128 -      }
  11.129 -
  11.130 -      if (baseBoardInformation != null) {
  11.131 -        r.Append("Mainboard Manufacturer: "); 
  11.132 -        r.AppendLine(baseBoardInformation.Manufacturer);
  11.133 -        r.Append("Mainboard Name: "); 
  11.134 -        r.AppendLine(baseBoardInformation.ProductName);
  11.135 -        r.AppendLine();
  11.136 -      }
  11.137 -     
  11.138 -      return r.ToString();
  11.139 -    }
  11.140 -
  11.141 -    public void Close() { }
  11.142 -
  11.143 -    public class Structure {
  11.144 -      private byte type;
  11.145 -      private ushort handle;
  11.146 -
  11.147 -      private byte[] data;
  11.148 -      private string[] strings;
  11.149 -
  11.150 -      protected string GetString(int offset) {
  11.151 -        if (offset < data.Length && data[offset] > 0 &&
  11.152 -         data[offset] <= strings.Length)
  11.153 -          return strings[data[offset] - 1];
  11.154 -        else
  11.155 -          return "";
  11.156 -      }
  11.157 -
  11.158 -      public Structure(byte type, ushort handle, byte[] data, string[] strings) 
  11.159 -      {
  11.160 -        this.type = type;
  11.161 -        this.handle = handle;
  11.162 -        this.data = data;
  11.163 -        this.strings = strings;
  11.164 -      }
  11.165 -
  11.166 -      public byte Type { get { return type; } }
  11.167 -
  11.168 -      public ushort Handle { get { return handle; } }
  11.169 -    }
  11.170 -
  11.171 -    public class BIOSInformation : Structure {
  11.172 -
  11.173 -      private string vendor;
  11.174 -      private string version;
  11.175 -
  11.176 -      public BIOSInformation(byte type, ushort handle, byte[] data,
  11.177 -        string[] strings)
  11.178 -        : base(type, handle, data, strings) {
  11.179 -
  11.180 -        this.vendor = GetString(0x04);
  11.181 -        this.version = GetString(0x05);
  11.182 -      }
  11.183 -
  11.184 -      public string Vendor { get { return vendor; } }
  11.185 -
  11.186 -      public string Version { get { return version; } }
  11.187 -    }
  11.188 -
  11.189 -    public class BaseBoardInformation : Structure {
  11.190 -
  11.191 -      private string manufacturer;
  11.192 -      private string productName;
  11.193 -
  11.194 -      public BaseBoardInformation(byte type, ushort handle, byte[] data,
  11.195 -        string[] strings)
  11.196 -        : base(type, handle, data, strings) {
  11.197 -
  11.198 -        this.manufacturer = GetString(0x04);
  11.199 -        this.productName = GetString(0x05);
  11.200 -      }
  11.201 -
  11.202 -      public string Manufacturer { get { return manufacturer; } }
  11.203 -
  11.204 -      public string ProductName { get { return productName; } }
  11.205 -    }
  11.206 -  }
  11.207 -}
    12.1 --- a/Hardware/TBalancer/TBalancer.cs	Sat Feb 27 15:55:17 2010 +0000
    12.2 +++ b/Hardware/TBalancer/TBalancer.cs	Sat Feb 27 20:08:13 2010 +0000
    12.3 @@ -262,6 +262,10 @@
    12.4          this.portName.TrimStart(new char[]{'/'}).ToLower(); }
    12.5      }
    12.6  
    12.7 +    public IHardware[] SubHardware {
    12.8 +      get { return new IHardware[0]; }
    12.9 +    }
   12.10 +
   12.11      public ISensor[] Sensors {
   12.12        get { return active.ToArray(); }
   12.13      }
    13.1 --- a/OpenHardwareMonitor.csproj	Sat Feb 27 15:55:17 2010 +0000
    13.2 +++ b/OpenHardwareMonitor.csproj	Sat Feb 27 20:08:13 2010 +0000
    13.3 @@ -78,8 +78,11 @@
    13.4      <Compile Include="Hardware\LPC\Chip.cs" />
    13.5      <Compile Include="Hardware\LPC\F718XX.cs" />
    13.6      <Compile Include="Hardware\LPC\LPCHardware.cs" />
    13.7 +    <Compile Include="Hardware\Mainboard\Mainboard.cs" />
    13.8 +    <Compile Include="Hardware\Mainboard\MainboardGroup.cs" />
    13.9 +    <Compile Include="Hardware\Mainboard\Manufacturer.cs" />
   13.10      <Compile Include="Hardware\Parameter.cs" />
   13.11 -    <Compile Include="Hardware\SMBIOS\SMBIOSGroup.cs" />
   13.12 +    <Compile Include="Hardware\Mainboard\SMBIOS.cs" />
   13.13      <Compile Include="Hardware\LPC\W836XX.cs" />
   13.14      <Compile Include="Hardware\Computer.cs" />
   13.15      <Compile Include="Properties\AssemblyInfo.cs" />
   13.16 @@ -172,6 +175,9 @@
   13.17      </EmbeddedResource>
   13.18      <EmbeddedResource Include="Resources\flow.png" />
   13.19    </ItemGroup>
   13.20 +  <ItemGroup>
   13.21 +    <EmbeddedResource Include="Resources\mainboard.png" />
   13.22 +  </ItemGroup>
   13.23    <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   13.24    <ProjectExtensions>
   13.25      <VisualStudio AllowExistingFolder="true" />