Added a RAM hardware and sensor, fixed Issue 115.
3 This Source Code Form is subject to the terms of the Mozilla Public
4 License, v. 2.0. If a copy of the MPL was not distributed with this
5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
13 using OpenHardwareMonitor.Hardware.LPC;
15 namespace OpenHardwareMonitor.Hardware.Mainboard {
16 internal class Mainboard : IHardware {
17 private readonly SMBIOS smbios;
18 private readonly string name;
19 private string customName;
20 private readonly ISettings settings;
21 private readonly LPCIO lpcio;
22 private readonly LMSensors lmSensors;
23 private readonly Hardware[] superIOHardware;
25 public Mainboard(SMBIOS smbios, ISettings settings) {
26 this.settings = settings;
29 Manufacturer manufacturer = smbios.Board == null ? Manufacturer.Unknown :
30 Identification.GetManufacturer(smbios.Board.ManufacturerName);
32 Model model = smbios.Board == null ? Model.Unknown :
33 Identification.GetModel(smbios.Board.ProductName);
35 if (smbios.Board != null) {
36 if (!string.IsNullOrEmpty(smbios.Board.ProductName)) {
37 if (manufacturer == Manufacturer.Unknown)
38 this.name = smbios.Board.ProductName;
40 this.name = manufacturer + " " +
41 smbios.Board.ProductName;
43 this.name = manufacturer.ToString();
46 this.name = Manufacturer.Unknown.ToString();
49 this.customName = settings.GetValue(
50 new Identifier(Identifier, "name").ToString(), name);
53 int p = (int)Environment.OSVersion.Platform;
54 if ((p == 4) || (p == 128)) {
55 this.lmSensors = new LMSensors();
56 superIO = lmSensors.SuperIO;
58 this.lpcio = new LPCIO();
59 superIO = lpcio.SuperIO;
62 superIOHardware = new Hardware[superIO.Length];
63 for (int i = 0; i < superIO.Length; i++)
64 superIOHardware[i] = new SuperIOHardware(this, superIO[i],
65 manufacturer, model, settings);
73 if (!string.IsNullOrEmpty(value))
77 settings.SetValue(new Identifier(Identifier, "name").ToString(),
82 public Identifier Identifier {
83 get { return new Identifier("mainboard"); }
86 public HardwareType HardwareType {
87 get { return HardwareType.Mainboard; }
90 public virtual IHardware Parent {
94 public string GetReport() {
95 StringBuilder r = new StringBuilder();
97 r.AppendLine("Mainboard");
99 r.Append(smbios.GetReport());
102 r.Append(lpcio.GetReport());
105 FirmwareTable.GetTable(FirmwareTable.Provider.ACPI, "TAMG");
107 GigabyteTAMG tamg = new GigabyteTAMG(table);
108 r.Append(tamg.GetReport());
114 public void Update() { }
116 public void Close() {
117 if (lmSensors != null)
119 foreach (Hardware hardware in superIOHardware)
123 public IHardware[] SubHardware {
124 get { return superIOHardware; }
127 public ISensor[] Sensors {
128 get { return new ISensor[0]; }
131 #pragma warning disable 67
132 public event SensorEventHandler SensorAdded;
133 public event SensorEventHandler SensorRemoved;
134 #pragma warning restore 67
136 public void Accept(IVisitor visitor) {
138 throw new ArgumentNullException("visitor");
139 visitor.VisitHardware(this);
142 public void Traverse(IVisitor visitor) {
143 foreach (IHardware hardware in superIOHardware)
144 hardware.Accept(visitor);