moel@135: /*
moel@130:   
moel@130:   Version: MPL 1.1/GPL 2.0/LGPL 2.1
moel@130: 
moel@130:   The contents of this file are subject to the Mozilla Public License Version
moel@130:   1.1 (the "License"); you may not use this file except in compliance with
moel@130:   the License. You may obtain a copy of the License at
moel@130:  
moel@130:   http://www.mozilla.org/MPL/
moel@130: 
moel@130:   Software distributed under the License is distributed on an "AS IS" basis,
moel@130:   WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
moel@130:   for the specific language governing rights and limitations under the License.
moel@130: 
moel@130:   The Original Code is the Open Hardware Monitor code.
moel@130: 
moel@130:   The Initial Developer of the Original Code is 
moel@130:   Michael Möller <m.moeller@gmx.ch>.
moel@130:   Portions created by the Initial Developer are Copyright (C) 2009-2010
moel@130:   the Initial Developer. All Rights Reserved.
moel@130: 
moel@130:   Contributor(s):
moel@130: 
moel@130:   Alternatively, the contents of this file may be used under the terms of
moel@130:   either the GNU General Public License Version 2 or later (the "GPL"), or
moel@130:   the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
moel@130:   in which case the provisions of the GPL or the LGPL are applicable instead
moel@130:   of those above. If you wish to allow use of your version of this file only
moel@130:   under the terms of either the GPL or the LGPL, and not to allow others to
moel@130:   use your version of this file under the terms of the MPL, indicate your
moel@130:   decision by deleting the provisions above and replace them with the notice
moel@130:   and other provisions required by the GPL or the LGPL. If you do not delete
moel@130:   the provisions above, a recipient may use your version of this file under
moel@130:   the terms of any one of the MPL, the GPL or the LGPL.
moel@130:  
moel@130: */
moel@130: 
moel@130: using System.Collections.Generic;
moel@166: using System.Globalization;
moel@130: using OpenHardwareMonitor.Hardware.LPC;
moel@130: 
moel@130: namespace OpenHardwareMonitor.Hardware.Mainboard {
moel@165:   internal class SuperIOHardware : Hardware {
moel@130: 
moel@195:     private readonly Mainboard mainboard;
moel@195:     private readonly ISuperIO superIO;
moel@195:     private readonly string name;
moel@130: 
moel@195:     private readonly List<Sensor> voltages = new List<Sensor>();
moel@195:     private readonly List<Sensor> temperatures = new List<Sensor>();
moel@195:     private readonly List<Sensor> fans = new List<Sensor>();
moel@167: 
moel@130: 
moel@176:     public SuperIOHardware(Mainboard mainboard, ISuperIO superIO, 
moel@176:       Manufacturer manufacturer, Model model, ISettings settings) 
moel@130:     {
moel@176:       this.mainboard = mainboard;
moel@130:       this.superIO = superIO;
moel@167:       this.name = ChipName.GetName(superIO.Chip);
moel@130: 
moel@130:       List<Voltage> v = new List<Voltage>();
moel@130:       List<Temperature> t = new List<Temperature>();
moel@130:       List<Fan> f = new List<Fan>();
moel@130: 
moel@130:       switch (superIO.Chip) {
moel@130:         case Chip.IT8712F:
moel@130:         case Chip.IT8716F:
moel@130:         case Chip.IT8718F:
moel@177:         case Chip.IT8720F: 
moel@130:         case Chip.IT8726F:
moel@130:           switch (manufacturer) {
moel@133:             case Manufacturer.ASUS:
moel@133:               switch (model) {
moel@168:                 case Model.Crosshair_III_Formula: // IT8720F
moel@133:                   v.Add(new Voltage("VBat", 8));
moel@133:                   t.Add(new Temperature("CPU", 0));
moel@133:                   for (int i = 0; i < superIO.Fans.Length; i++)
moel@133:                     f.Add(new Fan("Fan #" + (i + 1), i));
moel@133:                   break;
moel@144:                 case Model.M2N_SLI_DELUXE:                
moel@133:                   v.Add(new Voltage("CPU VCore", 0));
moel@133:                   v.Add(new Voltage("+3.3V", 1));
moel@195:                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
moel@195:                   v.Add(new Voltage("+12V", 4, 30, 10));
moel@195:                   v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
moel@133:                   v.Add(new Voltage("VBat", 8));
moel@133:                   t.Add(new Temperature("CPU", 0));
moel@133:                   t.Add(new Temperature("Motherboard", 1));
moel@133:                   f.Add(new Fan("CPU Fan", 0));
moel@133:                   f.Add(new Fan("Chassis Fan #1", 1));
moel@133:                   f.Add(new Fan("Power Fan", 2));
moel@133:                   break;
moel@168:                 case Model.M4A79XTD_EVO: // IT8720F           
moel@195:                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
moel@144:                   v.Add(new Voltage("VBat", 8));
moel@144:                   t.Add(new Temperature("CPU", 0));
moel@144:                   t.Add(new Temperature("Motherboard", 1));
moel@144:                   f.Add(new Fan("CPU Fan", 0));
moel@144:                   f.Add(new Fan("Chassis Fan #1", 1));
moel@144:                   f.Add(new Fan("Chassis Fan #2", 2));
moel@144:                   break;
moel@133:                 default:
moel@133:                   v.Add(new Voltage("CPU VCore", 0));
moel@133:                   v.Add(new Voltage("Voltage #2", 1, true));
moel@133:                   v.Add(new Voltage("Voltage #3", 2, true));
moel@133:                   v.Add(new Voltage("Voltage #4", 3, true));
moel@133:                   v.Add(new Voltage("Voltage #5", 4, true));
moel@133:                   v.Add(new Voltage("Voltage #6", 5, true));
moel@133:                   v.Add(new Voltage("Voltage #7", 6, true));
moel@133:                   v.Add(new Voltage("Voltage #8", 7, true));
moel@133:                   v.Add(new Voltage("VBat", 8));
moel@133:                   for (int i = 0; i < superIO.Temperatures.Length; i++)
moel@133:                     t.Add(new Temperature("Temperature #" + (i + 1), i));
moel@133:                   for (int i = 0; i < superIO.Fans.Length; i++)
moel@133:                     f.Add(new Fan("Fan #" + (i + 1), i));
moel@133:                   break;
moel@133:               }
moel@133:               break;
moel@130:             case Manufacturer.DFI:
moel@130:               switch (model) {
moel@168:                 case Model.LP_BI_P45_T2RS_Elite: // IT8718F
moel@130:                   v.Add(new Voltage("CPU VCore", 0));
moel@130:                   v.Add(new Voltage("FSB VTT", 1));
moel@130:                   v.Add(new Voltage("+3.3V", 2));
moel@195:                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
moel@195:                   v.Add(new Voltage("+12V", 4, 30, 10));
moel@130:                   v.Add(new Voltage("NB Core", 5));
moel@130:                   v.Add(new Voltage("VDIMM", 6));
moel@195:                   v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
moel@130:                   v.Add(new Voltage("VBat", 8));
moel@130:                   t.Add(new Temperature("CPU", 0));
moel@130:                   t.Add(new Temperature("System", 1));
moel@130:                   t.Add(new Temperature("Chipset", 2));
moel@130:                   f.Add(new Fan("Fan #1", 0));
moel@130:                   f.Add(new Fan("Fan #2", 1));
moel@130:                   f.Add(new Fan("Fan #3", 2));
moel@130:                   break;
moel@168:                 case Model.LP_DK_P55_T3eH9: // IT8720F
moel@130:                   v.Add(new Voltage("CPU VCore", 0));
moel@130:                   v.Add(new Voltage("VTT", 1));
moel@130:                   v.Add(new Voltage("+3.3V", 2));
moel@195:                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
moel@195:                   v.Add(new Voltage("+12V", 4, 30, 10));
moel@130:                   v.Add(new Voltage("CPU PLL", 5));
moel@130:                   v.Add(new Voltage("DRAM", 6));
moel@195:                   v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
moel@130:                   v.Add(new Voltage("VBat", 8));
moel@130:                   t.Add(new Temperature("Chipset", 0));
moel@130:                   t.Add(new Temperature("CPU PWM", 1));
moel@130:                   t.Add(new Temperature("CPU", 2));
moel@130:                   f.Add(new Fan("Fan #1", 0));
moel@130:                   f.Add(new Fan("Fan #2", 1));
moel@130:                   f.Add(new Fan("Fan #3", 2));
moel@130:                   break;
moel@130:                 default:
moel@130:                   v.Add(new Voltage("CPU VCore", 0));
moel@130:                   v.Add(new Voltage("VTT", 1, true));
moel@130:                   v.Add(new Voltage("+3.3V", 2, true));
moel@130:                   v.Add(new Voltage("+5V", 3, 6.8f, 10, 0, true));
moel@130:                   v.Add(new Voltage("+12V", 4, 30, 10, 0, true));
moel@130:                   v.Add(new Voltage("Voltage #6", 5, true));
moel@130:                   v.Add(new Voltage("DRAM", 6, true));
moel@130:                   v.Add(new Voltage("+5VSB", 7, 6.8f, 10, 0, true));
moel@130:                   v.Add(new Voltage("VBat", 8));
moel@130:                   for (int i = 0; i < superIO.Temperatures.Length; i++)
moel@130:                     t.Add(new Temperature("Temperature #" + (i + 1), i));
moel@130:                   for (int i = 0; i < superIO.Fans.Length; i++)
moel@130:                     f.Add(new Fan("Fan #" + (i + 1), i));
moel@130:                   break;
moel@130:               }
moel@130:               break;
moel@130: 
moel@130:             case Manufacturer.Gigabyte:
moel@130:               switch (model) {
moel@168:                 case Model._965P_S3: // IT8718F
moel@130:                   v.Add(new Voltage("CPU VCore", 0));
moel@130:                   v.Add(new Voltage("DRAM", 1));
moel@130:                   v.Add(new Voltage("+3.3V", 2));
moel@195:                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
moel@195:                   v.Add(new Voltage("+12V", 7, 27, 9.1f));
moel@130:                   v.Add(new Voltage("VBat", 8));
moel@130:                   t.Add(new Temperature("System", 0));
moel@130:                   t.Add(new Temperature("CPU", 1));
moel@130:                   f.Add(new Fan("CPU Fan", 0));
moel@130:                   f.Add(new Fan("System Fan", 1));
moel@130:                   break;
moel@168:                 case Model.EP45_DS3R: // IT8718F
moel@130:                 case Model.EP45_UD3R: 
moel@138:                 case Model.X38_DS5:    
moel@130:                   v.Add(new Voltage("CPU VCore", 0));
moel@130:                   v.Add(new Voltage("DRAM", 1));
moel@130:                   v.Add(new Voltage("+3.3V", 2));
moel@195:                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
moel@195:                   v.Add(new Voltage("+12V", 7, 27, 9.1f));
moel@130:                   v.Add(new Voltage("VBat", 8));
moel@130:                   t.Add(new Temperature("System", 0));
moel@130:                   t.Add(new Temperature("CPU", 1));
moel@130:                   f.Add(new Fan("CPU Fan", 0));
moel@130:                   f.Add(new Fan("System Fan #2", 1));
moel@130:                   f.Add(new Fan("Power Fan", 2));
moel@130:                   f.Add(new Fan("System Fan #1", 3));
moel@130:                   break;
moel@168:                 case Model.EX58_EXTREME: // IT8720F 
moel@133:                   v.Add(new Voltage("CPU VCore", 0));
moel@133:                   v.Add(new Voltage("DRAM", 1));
moel@195:                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
moel@133:                   v.Add(new Voltage("VBat", 8));
moel@133:                   t.Add(new Temperature("System", 0));
moel@133:                   t.Add(new Temperature("CPU", 1));
moel@138:                   t.Add(new Temperature("Northbridge", 2));
moel@133:                   f.Add(new Fan("CPU Fan", 0));
moel@133:                   f.Add(new Fan("System Fan #2", 1));
moel@133:                   f.Add(new Fan("Power Fan", 2));
moel@133:                   f.Add(new Fan("System Fan #1", 3));
moel@133:                   break;
moel@168:                 case Model.P35_DS3: // IT8718F 
moel@168:                 case Model.P35_DS3L: // IT8718F
moel@130:                   v.Add(new Voltage("CPU VCore", 0));
moel@130:                   v.Add(new Voltage("DRAM", 1));
moel@130:                   v.Add(new Voltage("+3.3V", 2));
moel@195:                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
moel@195:                   v.Add(new Voltage("+12V", 7, 27, 9.1f));
moel@130:                   v.Add(new Voltage("VBat", 8));
moel@130:                   t.Add(new Temperature("System", 0));
moel@130:                   t.Add(new Temperature("CPU", 1));
moel@130:                   f.Add(new Fan("CPU Fan", 0));
moel@130:                   f.Add(new Fan("System Fan #1", 1));
moel@130:                   f.Add(new Fan("System Fan #2", 2));
moel@130:                   f.Add(new Fan("Power Fan", 3));
moel@130:                   break;
moel@168:                 case Model.P55_UD4: // IT8720F
moel@168:                 case Model.P55M_UD4: // IT8720F
moel@148:                   v.Add(new Voltage("CPU VCore", 0));
moel@148:                   v.Add(new Voltage("DRAM", 1));
moel@148:                   v.Add(new Voltage("+3.3V", 2));
moel@195:                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
moel@195:                   v.Add(new Voltage("+12V", 5, 27, 9.1f));
moel@148:                   v.Add(new Voltage("VBat", 8));
moel@148:                   t.Add(new Temperature("System", 0));
moel@148:                   t.Add(new Temperature("CPU", 2));
moel@148:                   f.Add(new Fan("CPU Fan", 0));
moel@148:                   f.Add(new Fan("System Fan #2", 1));
moel@148:                   f.Add(new Fan("Power Fan", 2));
moel@148:                   f.Add(new Fan("System Fan #1", 3));
moel@148:                   break;
moel@168:                 case Model.GA_MA770T_UD3: // IT8720F
moel@154:                   v.Add(new Voltage("CPU VCore", 0));
moel@154:                   v.Add(new Voltage("DRAM", 1));
moel@154:                   v.Add(new Voltage("+3.3V", 2));
moel@195:                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
moel@195:                   v.Add(new Voltage("+12V", 4, 27, 9.1f));
moel@154:                   v.Add(new Voltage("VBat", 8));
moel@154:                   t.Add(new Temperature("System", 0));
moel@154:                   t.Add(new Temperature("CPU", 1));
moel@154:                   f.Add(new Fan("CPU Fan", 0));
moel@154:                   f.Add(new Fan("System Fan #1", 1));
moel@154:                   f.Add(new Fan("System Fan #2", 2));
moel@154:                   f.Add(new Fan("Power Fan", 3));
moel@154:                   break;
moel@168:                 case Model.GA_MA785GMT_UD2H: // IT8718F
moel@130:                   v.Add(new Voltage("CPU VCore", 0));
moel@130:                   v.Add(new Voltage("DRAM", 1));
moel@130:                   v.Add(new Voltage("+3.3V", 2));
moel@195:                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
moel@195:                   v.Add(new Voltage("+12V", 4, 27, 9.1f));
moel@130:                   v.Add(new Voltage("VBat", 8));
moel@130:                   t.Add(new Temperature("System", 0));
moel@130:                   t.Add(new Temperature("CPU", 1));
moel@130:                   f.Add(new Fan("CPU Fan", 0));
moel@130:                   f.Add(new Fan("System Fan", 1));
moel@130:                   f.Add(new Fan("NB Fan", 2));
moel@130:                   break;
moel@168:                 case Model.X58A_UD3R: // IT8720F 
moel@138:                   v.Add(new Voltage("CPU VCore", 0));
moel@138:                   v.Add(new Voltage("DRAM", 1));
moel@138:                   v.Add(new Voltage("+3.3V", 2));
moel@195:                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
moel@195:                   v.Add(new Voltage("+12V", 5, 27, 9.1f));
moel@138:                   v.Add(new Voltage("VBat", 8));
moel@138:                   t.Add(new Temperature("System", 0));
moel@138:                   t.Add(new Temperature("CPU", 1));
moel@138:                   t.Add(new Temperature("Northbridge", 2));
moel@138:                   f.Add(new Fan("CPU Fan", 0));
moel@138:                   f.Add(new Fan("System Fan #2", 1));
moel@138:                   f.Add(new Fan("Power Fan", 2));
moel@138:                   f.Add(new Fan("System Fan #1", 3));
moel@138:                   break;
moel@130:                 default:
moel@130:                   v.Add(new Voltage("CPU VCore", 0));
moel@130:                   v.Add(new Voltage("DRAM", 1, true));
moel@130:                   v.Add(new Voltage("+3.3V", 2, true));
moel@130:                   v.Add(new Voltage("+5V", 3, 6.8f, 10, 0, true));
moel@130:                   v.Add(new Voltage("Voltage #5", 4, true));
moel@130:                   v.Add(new Voltage("Voltage #6", 5, true));
moel@130:                   v.Add(new Voltage("Voltage #7", 6, true));
moel@130:                   v.Add(new Voltage("+12V", 7, 27, 9.1f, 0, true));
moel@130:                   v.Add(new Voltage("VBat", 8));
moel@130:                   for (int i = 0; i < superIO.Temperatures.Length; i++)
moel@130:                     t.Add(new Temperature("Temperature #" + (i + 1), i));
moel@130:                   for (int i = 0; i < superIO.Fans.Length; i++)
moel@130:                     f.Add(new Fan("Fan #" + (i + 1), i));
moel@130:                   break;
moel@130:               }
moel@130:               break;
moel@130: 
moel@130:             default:
moel@130:               v.Add(new Voltage("CPU VCore", 0));
moel@130:               v.Add(new Voltage("Voltage #2", 1, true));
moel@130:               v.Add(new Voltage("Voltage #3", 2, true));
moel@130:               v.Add(new Voltage("Voltage #4", 3, true));
moel@130:               v.Add(new Voltage("Voltage #5", 4, true));
moel@130:               v.Add(new Voltage("Voltage #6", 5, true));
moel@130:               v.Add(new Voltage("Voltage #7", 6, true));
moel@130:               v.Add(new Voltage("Voltage #8", 7, true));
moel@130:               v.Add(new Voltage("VBat", 8));
moel@130:               for (int i = 0; i < superIO.Temperatures.Length; i++)
moel@130:                 t.Add(new Temperature("Temperature #" + (i + 1), i));
moel@130:               for (int i = 0; i < superIO.Fans.Length; i++)
moel@130:                 f.Add(new Fan("Fan #" + (i + 1), i));
moel@130:               break;
moel@130:           }
moel@130:           break;
moel@170: 
moel@170:         case Chip.IT8721F:
moel@177:           switch (manufacturer) {
moel@177:             case Manufacturer.ECS:
moel@177:               switch (model) {
moel@177:                 case Model.A890GXM_A: // IT8721F
moel@177:                   v.Add(new Voltage("CPU VCore", 0));
moel@177:                   v.Add(new Voltage("VDIMM", 1));
moel@177:                   v.Add(new Voltage("NB Voltage", 2));
moel@195:                   v.Add(new Voltage("Analog +3.3V", 3, 10, 10));
moel@177:                   // v.Add(new Voltage("VDIMM", 6, true));
moel@195:                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10));
moel@195:                   v.Add(new Voltage("VBat", 8, 10, 10));
moel@177:                   t.Add(new Temperature("CPU", 0));
moel@177:                   t.Add(new Temperature("System", 1));
moel@177:                   t.Add(new Temperature("Northbridge", 2));
moel@177:                   f.Add(new Fan("CPU Fan", 0));
moel@177:                   f.Add(new Fan("System Fan", 1));
moel@177:                   f.Add(new Fan("Power Fan", 2));
moel@177:                   break;
moel@177:                 default:
moel@177:                   v.Add(new Voltage("Voltage #1", 0, true));
moel@177:                   v.Add(new Voltage("Voltage #2", 1, true));
moel@177:                   v.Add(new Voltage("Voltage #3", 2, true));
moel@177:                   v.Add(new Voltage("Analog +3.3V", 3, 10, 10, 0, true));
moel@177:                   v.Add(new Voltage("Voltage #5", 4, true));
moel@177:                   v.Add(new Voltage("Voltage #6", 5, true));
moel@177:                   v.Add(new Voltage("Voltage #7", 6, true));
moel@177:                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
moel@195:                   v.Add(new Voltage("VBat", 8, 10, 10));
moel@177:                   for (int i = 0; i < superIO.Temperatures.Length; i++)
moel@177:                     t.Add(new Temperature("Temperature #" + (i + 1), i));
moel@177:                   for (int i = 0; i < superIO.Fans.Length; i++)
moel@177:                     f.Add(new Fan("Fan #" + (i + 1), i));
moel@177:                   break;
moel@177:               }
moel@177:               break;
moel@177:             default:
moel@177:               v.Add(new Voltage("Voltage #1", 0, true));
moel@177:               v.Add(new Voltage("Voltage #2", 1, true));
moel@177:               v.Add(new Voltage("Voltage #3", 2, true));
moel@177:               v.Add(new Voltage("Analog +3.3V", 3, 10, 10, 0, true));
moel@177:               v.Add(new Voltage("Voltage #5", 4, true));
moel@177:               v.Add(new Voltage("Voltage #6", 5, true));
moel@177:               v.Add(new Voltage("Voltage #7", 6, true));
moel@177:               v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
moel@195:               v.Add(new Voltage("VBat", 8, 10, 10));
moel@177:               for (int i = 0; i < superIO.Temperatures.Length; i++)
moel@177:                 t.Add(new Temperature("Temperature #" + (i + 1), i));
moel@177:               for (int i = 0; i < superIO.Fans.Length; i++)
moel@177:                 f.Add(new Fan("Fan #" + (i + 1), i));
moel@177:               break;
moel@177:           }
moel@170:           break;
moel@130:           
moel@130:         case Chip.F71858:
moel@195:           v.Add(new Voltage("VCC3V", 0, 150, 150));
moel@195:           v.Add(new Voltage("VSB3V", 1, 150, 150));
moel@195:           v.Add(new Voltage("Battery", 2, 150, 150));
moel@130:           for (int i = 0; i < superIO.Temperatures.Length; i++)
moel@130:             t.Add(new Temperature("Temperature #" + (i + 1), i));
moel@130:           for (int i = 0; i < superIO.Fans.Length; i++)
moel@130:             f.Add(new Fan("Fan #" + (i + 1), i));
moel@130:           break;
moel@130:         case Chip.F71862: 
moel@130:         case Chip.F71869: 
moel@130:         case Chip.F71882:
moel@130:         case Chip.F71889ED: 
moel@130:         case Chip.F71889F:
moel@132:           switch (manufacturer) {
moel@132:             case Manufacturer.EVGA:
moel@132:               switch (model) {
moel@168:                 case Model.X58_SLI_Classified: // F71882 
moel@195:                   v.Add(new Voltage("VCC3V", 0, 150, 150));
moel@195:                   v.Add(new Voltage("CPU VCore", 1, 47, 100));
moel@195:                   v.Add(new Voltage("DIMM", 2, 47, 100));
moel@195:                   v.Add(new Voltage("CPU VTT", 3, 24, 100));
moel@195:                   v.Add(new Voltage("IOH Vcore", 4, 24, 100));
moel@195:                   v.Add(new Voltage("+5V", 5, 51, 12));
moel@195:                   v.Add(new Voltage("+12V", 6, 56, 6.8f));
moel@195:                   v.Add(new Voltage("3VSB", 7, 150, 150));
moel@195:                   v.Add(new Voltage("VBat", 8, 150, 150));
moel@132:                   t.Add(new Temperature("CPU", 0));
moel@132:                   t.Add(new Temperature("VREG", 1));
moel@132:                   t.Add(new Temperature("System", 2));
moel@132:                   f.Add(new Fan("CPU Fan", 0));
moel@132:                   f.Add(new Fan("Power Fan", 1));
moel@132:                   f.Add(new Fan("Chassis Fan", 2));
moel@132:                   break;
moel@132:                 default:
moel@195:                   v.Add(new Voltage("VCC3V", 0, 150, 150));
moel@132:                   v.Add(new Voltage("CPU VCore", 1));
moel@132:                   v.Add(new Voltage("Voltage #3", 2, true));
moel@132:                   v.Add(new Voltage("Voltage #4", 3, true));
moel@132:                   v.Add(new Voltage("Voltage #5", 4, true));
moel@132:                   v.Add(new Voltage("Voltage #6", 5, true));
moel@132:                   v.Add(new Voltage("Voltage #7", 6, true));
moel@195:                   v.Add(new Voltage("VSB3V", 7, 150, 150));
moel@195:                   v.Add(new Voltage("VBat", 8, 150, 150));
moel@132:                   for (int i = 0; i < superIO.Temperatures.Length; i++)
moel@132:                     t.Add(new Temperature("Temperature #" + (i + 1), i));
moel@132:                   for (int i = 0; i < superIO.Fans.Length; i++)
moel@132:                     f.Add(new Fan("Fan #" + (i + 1), i));
moel@132:                   break;
moel@132:               }
moel@132:               break;
moel@132:             default:
moel@195:               v.Add(new Voltage("VCC3V", 0, 150, 150));
moel@132:               v.Add(new Voltage("CPU VCore", 1));
moel@132:               v.Add(new Voltage("Voltage #3", 2, true));
moel@132:               v.Add(new Voltage("Voltage #4", 3, true));
moel@132:               v.Add(new Voltage("Voltage #5", 4, true));
moel@132:               v.Add(new Voltage("Voltage #6", 5, true));
moel@132:               v.Add(new Voltage("Voltage #7", 6, true));
moel@195:               v.Add(new Voltage("VSB3V", 7, 150, 150));
moel@195:               v.Add(new Voltage("VBat", 8, 150, 150));
moel@132:               for (int i = 0; i < superIO.Temperatures.Length; i++)
moel@132:                 t.Add(new Temperature("Temperature #" + (i + 1), i));
moel@132:               for (int i = 0; i < superIO.Fans.Length; i++)
moel@132:                 f.Add(new Fan("Fan #" + (i + 1), i));
moel@132:               break;
moel@132:           }
moel@130:           break;
moel@130: 
moel@130:         case Chip.W83627EHF:          
moel@130:           v.Add(new Voltage("CPU VCore", 0));
moel@130:           v.Add(new Voltage("Voltage #2", 1, true));
moel@195:           v.Add(new Voltage("AVCC", 2, 34, 34));
moel@195:           v.Add(new Voltage("3VCC", 3, 34, 34));
moel@130:           v.Add(new Voltage("Voltage #5", 4, true));
moel@130:           v.Add(new Voltage("Voltage #6", 5, true));
moel@130:           v.Add(new Voltage("Voltage #7", 6, true));
moel@195:           v.Add(new Voltage("3VSB", 7, 34, 34));
moel@195:           v.Add(new Voltage("VBAT", 8, 34, 34));
moel@130:           v.Add(new Voltage("Voltage #10", 9, true));
moel@130:           t.Add(new Temperature("CPU", 0));
moel@130:           t.Add(new Temperature("Auxiliary", 1));
moel@130:           t.Add(new Temperature("System", 2));
moel@153:           f.Add(new Fan("System Fan", 0));
moel@153:           f.Add(new Fan("CPU Fan", 1));
moel@153:           f.Add(new Fan("Auxiliary Fan", 2));
moel@153:           f.Add(new Fan("CPU Fan #2", 3));
moel@153:           f.Add(new Fan("Auxiliary Fan #2", 4));
moel@130:           break;
moel@130:         case Chip.W83627DHG: 
moel@130:         case Chip.W83627DHGP:                      
moel@130:         case Chip.W83667HG:
moel@130:         case Chip.W83667HGB:
moel@152:           switch (manufacturer) {
moel@153:             case Manufacturer.ASRock:
moel@153:               switch (model) {
moel@168:                 case Model._880GMH_USB3: // W83627DHG-P
moel@153:                   v.Add(new Voltage("CPU VCore", 0));
moel@195:                   v.Add(new Voltage("+3.3V", 3, 34, 34));
moel@195:                   v.Add(new Voltage("+5V", 5, 15, 7.5f));
moel@195:                   v.Add(new Voltage("+12V", 6, 56, 10));
moel@195:                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
moel@195:                   v.Add(new Voltage("VBAT", 8, 34, 34));
moel@153:                   t.Add(new Temperature("CPU", 0));
moel@153:                   t.Add(new Temperature("Motherboard", 2));
moel@153:                   f.Add(new Fan("Chassis Fan", 0));
moel@153:                   f.Add(new Fan("CPU Fan", 1));
moel@153:                   f.Add(new Fan("Power Fan", 2));
moel@153:                   break;
moel@153:                 default:
moel@153:                   v.Add(new Voltage("CPU VCore", 0));
moel@153:                   v.Add(new Voltage("Voltage #2", 1, true));
moel@195:                   v.Add(new Voltage("AVCC", 2, 34, 34));
moel@195:                   v.Add(new Voltage("3VCC", 3, 34, 34));
moel@153:                   v.Add(new Voltage("Voltage #5", 4, true));
moel@153:                   v.Add(new Voltage("Voltage #6", 5, true));
moel@153:                   v.Add(new Voltage("Voltage #7", 6, true));
moel@195:                   v.Add(new Voltage("3VSB", 7, 34, 34));
moel@195:                   v.Add(new Voltage("VBAT", 8, 34, 34));
moel@153:                   t.Add(new Temperature("CPU", 0));
moel@153:                   t.Add(new Temperature("Auxiliary", 1));
moel@153:                   t.Add(new Temperature("System", 2));
moel@153:                   f.Add(new Fan("System Fan", 0));
moel@153:                   f.Add(new Fan("CPU Fan", 1));
moel@153:                   f.Add(new Fan("Auxiliary Fan", 2));
moel@153:                   f.Add(new Fan("CPU Fan #2", 3));
moel@153:                   f.Add(new Fan("Auxiliary Fan #2", 4));
moel@153:                   break;
moel@153:               }
moel@153:               break;
moel@152:             case Manufacturer.ASUS:
moel@152:               switch (model) {
moel@174:                 case Model.P6X58D_E: // W83667HG                 
moel@174:                 case Model.Rampage_II_GENE: // W83667HG 
moel@152:                   v.Add(new Voltage("CPU VCore", 0));
moel@195:                   v.Add(new Voltage("+12V", 1, 11.5f, 1.91f));
moel@195:                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
moel@195:                   v.Add(new Voltage("+3.3V", 3, 34, 34));
moel@195:                   v.Add(new Voltage("+5V", 4, 15, 7.5f));
moel@195:                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
moel@195:                   v.Add(new Voltage("VBAT", 8, 34, 34));
moel@174:                   t.Add(new Temperature("CPU", 0));
moel@174:                   t.Add(new Temperature("Motherboard", 2));
moel@174:                   f.Add(new Fan("Chassis Fan #1", 0));
moel@174:                   f.Add(new Fan("CPU Fan", 1));
moel@174:                   f.Add(new Fan("Power Fan", 2));
moel@174:                   f.Add(new Fan("Chassis Fan #2", 3));
moel@174:                   f.Add(new Fan("Chassis Fan #3", 4));
moel@174:                   break;
moel@174:                 case Model.Rampage_Extreme: // W83667HG 
moel@174:                   v.Add(new Voltage("CPU VCore", 0));
moel@195:                   v.Add(new Voltage("+12V", 1, 12, 2));
moel@195:                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
moel@195:                   v.Add(new Voltage("+3.3V", 3, 34, 34));
moel@195:                   v.Add(new Voltage("+5V", 4, 15, 7.5f));
moel@195:                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
moel@195:                   v.Add(new Voltage("VBAT", 8, 34, 34));
moel@152:                   t.Add(new Temperature("CPU", 0));
moel@152:                   t.Add(new Temperature("Motherboard", 2));
moel@152:                   f.Add(new Fan("Chassis Fan #1", 0));
moel@153:                   f.Add(new Fan("CPU Fan", 1));
moel@153:                   f.Add(new Fan("Power Fan", 2));
moel@152:                   f.Add(new Fan("Chassis Fan #2", 3));
moel@152:                   f.Add(new Fan("Chassis Fan #3", 4));
moel@152:                   break;
moel@152:                 default:
moel@152:                   v.Add(new Voltage("CPU VCore", 0));
moel@152:                   v.Add(new Voltage("Voltage #2", 1, true));
moel@195:                   v.Add(new Voltage("AVCC", 2, 34, 34));
moel@195:                   v.Add(new Voltage("3VCC", 3, 34, 34));
moel@152:                   v.Add(new Voltage("Voltage #5", 4, true));
moel@152:                   v.Add(new Voltage("Voltage #6", 5, true));
moel@152:                   v.Add(new Voltage("Voltage #7", 6, true));
moel@195:                   v.Add(new Voltage("3VSB", 7, 34, 34));
moel@195:                   v.Add(new Voltage("VBAT", 8, 34, 34));
moel@152:                   t.Add(new Temperature("CPU", 0));
moel@152:                   t.Add(new Temperature("Auxiliary", 1));
moel@152:                   t.Add(new Temperature("System", 2));
moel@153:                   f.Add(new Fan("System Fan", 0));
moel@153:                   f.Add(new Fan("CPU Fan", 1));
moel@153:                   f.Add(new Fan("Auxiliary Fan", 2));
moel@153:                   f.Add(new Fan("CPU Fan #2", 3));
moel@153:                   f.Add(new Fan("Auxiliary Fan #2", 4));
moel@152:                   break;
moel@152:               }
moel@152:               break;
moel@152:             default:
moel@152:               v.Add(new Voltage("CPU VCore", 0));
moel@152:               v.Add(new Voltage("Voltage #2", 1, true));
moel@195:               v.Add(new Voltage("AVCC", 2, 34, 34));
moel@195:               v.Add(new Voltage("3VCC", 3, 34, 34));
moel@152:               v.Add(new Voltage("Voltage #5", 4, true));
moel@152:               v.Add(new Voltage("Voltage #6", 5, true));
moel@152:               v.Add(new Voltage("Voltage #7", 6, true));
moel@195:               v.Add(new Voltage("3VSB", 7, 34, 34));
moel@195:               v.Add(new Voltage("VBAT", 8, 34, 34));
moel@152:               t.Add(new Temperature("CPU", 0));
moel@152:               t.Add(new Temperature("Auxiliary", 1));
moel@152:               t.Add(new Temperature("System", 2));
moel@153:               f.Add(new Fan("System Fan", 0));
moel@153:               f.Add(new Fan("CPU Fan", 1));
moel@153:               f.Add(new Fan("Auxiliary Fan", 2));
moel@153:               f.Add(new Fan("CPU Fan #2", 3));
moel@153:               f.Add(new Fan("Auxiliary Fan #2", 4));
moel@152:               break;
moel@152:           } 
moel@130:           break;
moel@130:         case Chip.W83627HF: 
moel@130:         case Chip.W83627THF: 
moel@130:         case Chip.W83687THF:
moel@130:           v.Add(new Voltage("CPU VCore", 0));
moel@130:           v.Add(new Voltage("Voltage #2", 1, true));
moel@130:           v.Add(new Voltage("Voltage #3", 2, true));
moel@195:           v.Add(new Voltage("AVCC", 3, 34, 51));
moel@130:           v.Add(new Voltage("Voltage #5", 4, true));
moel@195:           v.Add(new Voltage("5VSB", 5, 34, 51));
moel@130:           v.Add(new Voltage("VBAT", 6));
moel@130:           t.Add(new Temperature("CPU", 0));
moel@130:           t.Add(new Temperature("Auxiliary", 1));
moel@130:           t.Add(new Temperature("System", 2));
moel@153:           f.Add(new Fan("System Fan", 0));
moel@153:           f.Add(new Fan("CPU Fan", 1));
moel@153:           f.Add(new Fan("Auxiliary Fan", 2));
moel@130:           break;
moel@130:         default:
moel@130:           for (int i = 0; i < superIO.Voltages.Length; i++)
moel@130:             v.Add(new Voltage("Voltage #" + (i + 1), i, true));
moel@130:           for (int i = 0; i < superIO.Temperatures.Length; i++)
moel@130:             t.Add(new Temperature("Temperature #" + (i + 1), i));
moel@130:           for (int i = 0; i < superIO.Fans.Length; i++)
moel@130:             f.Add(new Fan("Fan #" + (i + 1), i));
moel@130:           break;
moel@130:       }
moel@130: 
moel@195:       const string formula = "Voltage = value + (value - Vf) * Ri / Rf.";
moel@130:       foreach (Voltage voltage in v) 
moel@130:         if (voltage.Index < superIO.Voltages.Length) {
moel@130:           Sensor sensor = new Sensor(voltage.Name, voltage.Index, 
moel@195:             voltage.Hidden, SensorType.Voltage, this, new [] {
moel@130:             new ParameterDescription("Ri [kΩ]", "Input resistance.\n" + 
moel@130:               formula, voltage.Ri),
moel@130:             new ParameterDescription("Rf [kΩ]", "Reference resistance.\n" + 
moel@130:               formula, voltage.Rf),
moel@130:             new ParameterDescription("Vf [V]", "Reference voltage.\n" + 
moel@130:               formula, voltage.Vf)
moel@165:             }, settings);
moel@130:           voltages.Add(sensor);
moel@130:       }
moel@130: 
moel@130:       foreach (Temperature temperature in t) 
moel@130:         if (temperature.Index < superIO.Temperatures.Length) {
moel@134:         Sensor sensor = new Sensor(temperature.Name, temperature.Index,
moel@195:           SensorType.Temperature, this, new [] {
moel@130:           new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
moel@165:         }, settings);
moel@130:         temperatures.Add(sensor);
moel@130:       }
moel@130: 
moel@130:       foreach (Fan fan in f)
moel@130:         if (fan.Index < superIO.Fans.Length) {
moel@134:           Sensor sensor = new Sensor(fan.Name, fan.Index, SensorType.Fan,
moel@165:             this, settings);
moel@130:           fans.Add(sensor);
moel@130:         }
moel@130:     }
moel@130: 
moel@130:     public override Identifier Identifier {
moel@166:       get { 
moel@166:         return new Identifier("lpc", 
moel@166:           superIO.Chip.ToString().ToLower(CultureInfo.InvariantCulture)); 
moel@166:       }
moel@130:     }
moel@130: 
moel@165:     public override HardwareType HardwareType {
moel@165:       get { return HardwareType.SuperIO; }
moel@130:     }
moel@130: 
moel@176:     public override IHardware Parent {
moel@176:       get { return mainboard; }
moel@176:     }
moel@176: 
moel@130:     public override string Name {
moel@130:       get { return name; }
moel@130:     }
moel@130: 
moel@130:     public override string GetReport() {
moel@130:       return superIO.GetReport();
moel@130:     }
moel@130: 
moel@130:     public override void Update() {
moel@130:       superIO.Update();
moel@130: 
moel@130:       foreach (Sensor sensor in voltages) {
moel@130:         float? value = superIO.Voltages[sensor.Index];
moel@130:         if (value.HasValue) {
moel@130:           sensor.Value = value + (value - sensor.Parameters[2].Value) *
moel@130:             sensor.Parameters[0].Value / sensor.Parameters[1].Value;
moel@130:           ActivateSensor(sensor);
moel@130:         }
moel@130:       }
moel@130: 
moel@130:       foreach (Sensor sensor in temperatures) {
moel@130:         float? value = superIO.Temperatures[sensor.Index];
moel@130:         if (value.HasValue) {
moel@130:           sensor.Value = value + sensor.Parameters[0].Value;
moel@130:           ActivateSensor(sensor);
moel@130:         }
moel@130:       }
moel@130: 
moel@130:       foreach (Sensor sensor in fans) {
moel@130:         float? value = superIO.Fans[sensor.Index];
moel@130:         if (value.HasValue) {
moel@130:           sensor.Value = value;
moel@130:           if (value.Value > 0)
moel@130:             ActivateSensor(sensor);
moel@130:         }
moel@130:       }
moel@130:     }
moel@130: 
moel@130:     private class Voltage {
moel@130:       public readonly string Name;
moel@130:       public readonly int Index;
moel@130:       public readonly float Ri;
moel@130:       public readonly float Rf;
moel@130:       public readonly float Vf;
moel@130:       public readonly bool Hidden;
moel@130: 
moel@202:       public Voltage(string name, int index) :
moel@202:         this(name, index, false) { }
moel@202:       
moel@130:       public Voltage(string name, int index, bool hidden) :
moel@130:         this(name, index, 0, 1, 0, hidden) { }
moel@202:       
moel@202:       public Voltage(string name, int index, float ri, float rf) :
moel@202:         this(name, index, ri, rf, 0, false) { }
moel@202:       
moel@202:       // float ri = 0, float rf = 1, float vf = 0, bool hidden = false) 
moel@202:       
moel@195:       public Voltage(string name, int index, 
moel@202:         float ri, float rf, float vf, bool hidden) 
moel@195:       {
moel@130:         this.Name = name;
moel@130:         this.Index = index;
moel@130:         this.Ri = ri;
moel@130:         this.Rf = rf;
moel@130:         this.Vf = vf;
moel@130:         this.Hidden = hidden;
moel@130:       }
moel@130:     }
moel@130: 
moel@130:     private class Temperature {
moel@130:       public readonly string Name;
moel@130:       public readonly int Index;
moel@130: 
moel@167:       public Temperature(string name, int index) {
moel@130:         this.Name = name;
moel@130:         this.Index = index;
moel@130:       }
moel@130:     }
moel@130: 
moel@130:     private class Fan {
moel@130:       public readonly string Name;
moel@130:       public readonly int Index;
moel@130: 
moel@130:       public Fan(string name, int index) {
moel@130:         this.Name = name;
moel@130:         this.Index = index;
moel@130:       }
moel@130:     }
moel@130:   }
moel@130: }