Added support for Fintek F71858 chips. Corrected the number of fans for Fintek.
3 Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 The contents of this file are subject to the Mozilla Public License Version
6 1.1 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.mozilla.org/MPL/
11 Software distributed under the License is distributed on an "AS IS" basis,
12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 for the specific language governing rights and limitations under the License.
15 The Original Code is the Open Hardware Monitor code.
17 The Initial Developer of the Original Code is
18 Michael Möller <m.moeller@gmx.ch>.
19 Portions created by the Initial Developer are Copyright (C) 2009-2010
20 the Initial Developer. All Rights Reserved.
24 Alternatively, the contents of this file may be used under the terms of
25 either the GNU General Public License Version 2 or later (the "GPL"), or
26 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 in which case the provisions of the GPL or the LGPL are applicable instead
28 of those above. If you wish to allow use of your version of this file only
29 under the terms of either the GPL or the LGPL, and not to allow others to
30 use your version of this file under the terms of the MPL, indicate your
31 decision by deleting the provisions above and replace them with the notice
32 and other provisions required by the GPL or the LGPL. If you do not delete
33 the provisions above, a recipient may use your version of this file under
34 the terms of any one of the MPL, the GPL or the LGPL.
39 using System.Collections.Generic;
41 using System.Globalization;
44 namespace OpenHardwareMonitor.Hardware {
46 public delegate void HardwareEventHandler(IHardware hardware);
48 public class Computer {
50 private List<IGroup> groups = new List<IGroup>();
52 private bool open = false;
53 private bool hddEnabled = false;
57 private void Add(IGroup group) {
58 if (groups.Contains(group))
63 if (HardwareAdded != null)
64 foreach (IHardware hardware in group.Hardware)
65 HardwareAdded(hardware);
68 private void Remove(IGroup group) {
69 if (!groups.Contains(group))
74 if (HardwareRemoved != null)
75 foreach (IHardware hardware in group.Hardware)
76 HardwareRemoved(hardware);
83 Add(new Mainboard.MainboardGroup());
84 Add(new CPU.CPUGroup());
85 Add(new ATI.ATIGroup());
86 Add(new Nvidia.NvidiaGroup());
87 Add(new TBalancer.TBalancerGroup());
90 Add(new HDD.HDDGroup());
95 private void SubHardwareUpdate(IHardware hardware) {
96 foreach (IHardware subHardware in hardware.SubHardware) {
98 SubHardwareUpdate(subHardware);
102 public void Update() {
103 foreach (IGroup group in groups)
104 foreach (IHardware hardware in group.Hardware) {
106 SubHardwareUpdate(hardware);
110 public bool HDDEnabled {
111 get { return hddEnabled; }
113 if (open && value && !hddEnabled) {
114 Add(new HDD.HDDGroup());
115 } else if (open && !value && hddEnabled) {
116 List<IGroup> list = new List<IGroup>();
117 foreach (IGroup group in groups)
118 if (group is HDD.HDDGroup)
120 foreach (IGroup group in list)
127 public IEnumerable<IHardware> Hardware {
129 foreach (IGroup group in groups)
130 foreach (IHardware hardware in group.Hardware)
131 yield return hardware;
135 private void NewSection(TextWriter writer) {
136 for (int i = 0; i < 8; i++)
137 writer.Write("----------");
142 private void ReportHardwareTree(IHardware hardware, TextWriter w,
145 w.WriteLine("{0}|", space);
146 w.WriteLine("{0}+-+ {1} ({2})",
147 space, hardware.Name, hardware.Identifier);
148 foreach (ISensor sensor in hardware.Sensors) {
149 w.WriteLine("{0}| +- {1} : {2} : {3} : {4}",
150 space, sensor.SensorType, sensor.Index, sensor.Name,
151 string.Format(CultureInfo.InvariantCulture, "{0} : {1} : {2}",
152 sensor.Value, sensor.Min, sensor.Max));
153 foreach (IParameter parameter in sensor.Parameters) {
154 w.WriteLine("{0}| +- {1} : {2} : {3}",
155 space, parameter.Name, parameter.IsDefault,
156 string.Format(CultureInfo.InvariantCulture, "{0} : {1}",
157 parameter.DefaultValue, parameter.Value));
160 foreach (IHardware subHardware in hardware.SubHardware)
161 ReportHardwareTree(subHardware, w, "| ");
164 private void ReportHardware(IHardware hardware, TextWriter w) {
165 string hardwareReport = hardware.GetReport();
166 if (hardwareReport != null && hardwareReport != "") {
168 w.Write(hardwareReport);
170 foreach (IHardware subHardware in hardware.SubHardware)
171 ReportHardware(subHardware, w);
174 public void SaveReport(Version version) {
176 using (TextWriter w =
177 new StreamWriter("OpenHardwareMonitor.Report.txt")) {
180 w.WriteLine("Open Hardware Monitor Report");
184 w.Write("Version: "); w.WriteLine(version.ToString());
188 foreach (IGroup group in groups) {
189 foreach (IHardware hardware in group.Hardware)
190 ReportHardwareTree(hardware, w, "");
194 foreach (IGroup group in groups) {
195 string report = group.GetReport();
196 if (report != null && report != "") {
201 IHardware[] hardwareArray = group.Hardware;
202 foreach (IHardware hardware in hardwareArray)
203 ReportHardware(hardware, w);
209 public void Close() {
213 foreach (IGroup group in groups)
220 public event HardwareEventHandler HardwareAdded;
221 public event HardwareEventHandler HardwareRemoved;