Hardware/Mainboard/SuperIOHardware.cs
author moel.mich
Sun, 27 May 2012 14:23:31 +0000
changeset 344 3145aadca3d2
parent 341 5172a92c5c20
child 352 0899f651d5cf
permissions -rw-r--r--
Changed the license to the Mozilla Public License 2.0 and update the licensing information.
     1 /*
     2  
     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/.
     6  
     7   Copyright (C) 2009-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
     8 	
     9 */
    10 
    11 using System;
    12 using System.Collections.Generic;
    13 using System.Globalization;
    14 using System.Threading;
    15 using OpenHardwareMonitor.Hardware.LPC;
    16 
    17 namespace OpenHardwareMonitor.Hardware.Mainboard {
    18   internal class SuperIOHardware : Hardware {
    19 
    20     private readonly Mainboard mainboard;
    21     private readonly ISuperIO superIO;
    22 
    23     private readonly List<Sensor> voltages = new List<Sensor>();
    24     private readonly List<Sensor> temperatures = new List<Sensor>();
    25     private readonly List<Sensor> fans = new List<Sensor>();
    26     private readonly List<Sensor> controls = new List<Sensor>();
    27 
    28     private delegate float? ReadValueDelegate(int index);
    29     private delegate void UpdateDelegate();
    30 
    31     // delegates for mainboard specific sensor reading code
    32     private readonly ReadValueDelegate readVoltage;
    33     private readonly ReadValueDelegate readTemperature;
    34     private readonly ReadValueDelegate readFan;
    35     private readonly ReadValueDelegate readControl;
    36 
    37     // delegate for post update mainboard specific code
    38     private readonly UpdateDelegate postUpdate;
    39 
    40     // mainboard specific mutex
    41     private readonly Mutex mutex;
    42 
    43     public SuperIOHardware(Mainboard mainboard, ISuperIO superIO, 
    44       Manufacturer manufacturer, Model model, ISettings settings) 
    45       : base(ChipName.GetName(superIO.Chip), new Identifier("lpc", 
    46         superIO.Chip.ToString().ToLower(CultureInfo.InvariantCulture)), 
    47         settings)
    48     {
    49       this.mainboard = mainboard;
    50       this.superIO = superIO;
    51 
    52       this.readVoltage = (index) => superIO.Voltages[index];
    53       this.readTemperature = (index) => superIO.Temperatures[index];
    54       this.readFan = (index) => superIO.Fans[index];
    55       this.readControl = (index) => superIO.Controls[index];
    56 
    57       this.postUpdate = () => { };
    58 
    59       List<Voltage> v = new List<Voltage>();
    60       List<Temperature> t = new List<Temperature>();
    61       List<Fan> f = new List<Fan>();
    62       List<Ctrl> c = new List<Ctrl>();
    63 
    64       switch (superIO.Chip) {
    65         case Chip.IT8712F:
    66         case Chip.IT8716F:
    67         case Chip.IT8718F:
    68         case Chip.IT8720F: 
    69         case Chip.IT8726F:        
    70           switch (manufacturer) {
    71             case Manufacturer.ASUS:
    72               switch (model) {
    73                 case Model.Crosshair_III_Formula: // IT8720F
    74                   v.Add(new Voltage("VBat", 8));
    75                   t.Add(new Temperature("CPU", 0));
    76                   for (int i = 0; i < superIO.Fans.Length; i++)
    77                     f.Add(new Fan("Fan #" + (i + 1), i));
    78                   break;
    79                 case Model.M2N_SLI_DELUXE:                
    80                   v.Add(new Voltage("CPU VCore", 0));
    81                   v.Add(new Voltage("+3.3V", 1));
    82                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
    83                   v.Add(new Voltage("+12V", 4, 30, 10));
    84                   v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
    85                   v.Add(new Voltage("VBat", 8));
    86                   t.Add(new Temperature("CPU", 0));
    87                   t.Add(new Temperature("Motherboard", 1));
    88                   f.Add(new Fan("CPU Fan", 0));
    89                   f.Add(new Fan("Chassis Fan #1", 1));
    90                   f.Add(new Fan("Power Fan", 2));
    91                   break;
    92                 case Model.M4A79XTD_EVO: // IT8720F           
    93                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
    94                   v.Add(new Voltage("VBat", 8));
    95                   t.Add(new Temperature("CPU", 0));
    96                   t.Add(new Temperature("Motherboard", 1));
    97                   f.Add(new Fan("CPU Fan", 0));
    98                   f.Add(new Fan("Chassis Fan #1", 1));
    99                   f.Add(new Fan("Chassis Fan #2", 2));
   100                   break;
   101                 default:
   102                   v.Add(new Voltage("CPU VCore", 0));
   103                   v.Add(new Voltage("Voltage #2", 1, true));
   104                   v.Add(new Voltage("Voltage #3", 2, true));
   105                   v.Add(new Voltage("Voltage #4", 3, true));
   106                   v.Add(new Voltage("Voltage #5", 4, true));
   107                   v.Add(new Voltage("Voltage #6", 5, true));
   108                   v.Add(new Voltage("Voltage #7", 6, true));
   109                   v.Add(new Voltage("Voltage #8", 7, true));
   110                   v.Add(new Voltage("VBat", 8));
   111                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   112                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   113                   for (int i = 0; i < superIO.Fans.Length; i++)
   114                     f.Add(new Fan("Fan #" + (i + 1), i));
   115                   break;
   116               }
   117               break;
   118 
   119             case Manufacturer.ASRock:
   120               switch (model) {
   121                 case Model.P55_Deluxe: // IT8720F
   122                   
   123                   v.Add(new Voltage("CPU VCore", 0));
   124                   v.Add(new Voltage("+3.3V", 2));
   125                   v.Add(new Voltage("+12V", 4, 30, 10));
   126                   v.Add(new Voltage("+5V", 5, 6.8f, 10));
   127                   v.Add(new Voltage("VBat", 8));                  
   128                   t.Add(new Temperature("CPU", 0));
   129                   t.Add(new Temperature("Motherboard", 1));
   130                   f.Add(new Fan("CPU Fan", 0));
   131                   f.Add(new Fan("Chassis Fan #1", 1));
   132 
   133                   // this mutex is also used by the official ASRock tool
   134                   mutex = new Mutex(false, "ASRockOCMark");
   135                   
   136                   bool exclusiveAccess = false;
   137                   try {
   138                     exclusiveAccess = mutex.WaitOne(10, false);
   139                   } catch (AbandonedMutexException) { } 
   140                     catch (InvalidOperationException) { }  
   141 
   142                   // only read additional fans if we get exclusive access
   143                   if (exclusiveAccess) {
   144 
   145                     f.Add(new Fan("Chassis Fan #2", 2));
   146                     f.Add(new Fan("Chassis Fan #3", 3));
   147                     f.Add(new Fan("Power Fan", 4));
   148 
   149                     readFan = (index) => {
   150                       if (index < 2) {
   151                         return superIO.Fans[index];
   152                       } else {
   153                         // get GPIO 80-87
   154                         byte? gpio = superIO.ReadGPIO(7);
   155                         if (!gpio.HasValue)
   156                           return null;
   157 
   158                         // read the last 3 fans based on GPIO 83-85
   159                         int[] masks = { 0x05, 0x03, 0x06 };
   160                         return (((gpio.Value >> 3) & 0x07) ==
   161                           masks[index - 2]) ? superIO.Fans[2] : null;
   162                       }
   163                     };
   164 
   165                     int fanIndex = 0;
   166                     postUpdate = () => {
   167                       // get GPIO 80-87
   168                       byte? gpio = superIO.ReadGPIO(7);
   169                       if (!gpio.HasValue)
   170                         return;
   171 
   172                       // prepare the GPIO 83-85 for the next update
   173                       int[] masks = { 0x05, 0x03, 0x06 };
   174                       superIO.WriteGPIO(7,
   175                         (byte)((gpio.Value & 0xC7) | (masks[fanIndex] << 3)));
   176                       fanIndex = (fanIndex + 1) % 3;
   177                     };
   178                   }
   179 
   180                   break;
   181                 default:
   182                   v.Add(new Voltage("CPU VCore", 0));
   183                   v.Add(new Voltage("Voltage #2", 1, true));
   184                   v.Add(new Voltage("Voltage #3", 2, true));
   185                   v.Add(new Voltage("Voltage #4", 3, true));
   186                   v.Add(new Voltage("Voltage #5", 4, true));
   187                   v.Add(new Voltage("Voltage #6", 5, true));
   188                   v.Add(new Voltage("Voltage #7", 6, true));
   189                   v.Add(new Voltage("Voltage #8", 7, true));
   190                   v.Add(new Voltage("VBat", 8));
   191                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   192                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   193                   for (int i = 0; i < superIO.Fans.Length; i++)
   194                     f.Add(new Fan("Fan #" + (i + 1), i));
   195                   break;
   196               };
   197               break;
   198 
   199             case Manufacturer.DFI:
   200               switch (model) {
   201                 case Model.LP_BI_P45_T2RS_Elite: // IT8718F
   202                   v.Add(new Voltage("CPU VCore", 0));
   203                   v.Add(new Voltage("FSB VTT", 1));
   204                   v.Add(new Voltage("+3.3V", 2));
   205                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   206                   v.Add(new Voltage("+12V", 4, 30, 10));
   207                   v.Add(new Voltage("NB Core", 5));
   208                   v.Add(new Voltage("VDIMM", 6));
   209                   v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
   210                   v.Add(new Voltage("VBat", 8));
   211                   t.Add(new Temperature("CPU", 0));
   212                   t.Add(new Temperature("System", 1));
   213                   t.Add(new Temperature("Chipset", 2));
   214                   f.Add(new Fan("Fan #1", 0));
   215                   f.Add(new Fan("Fan #2", 1));
   216                   f.Add(new Fan("Fan #3", 2));
   217                   break;
   218                 case Model.LP_DK_P55_T3eH9: // IT8720F
   219                   v.Add(new Voltage("CPU VCore", 0));
   220                   v.Add(new Voltage("VTT", 1));
   221                   v.Add(new Voltage("+3.3V", 2));
   222                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   223                   v.Add(new Voltage("+12V", 4, 30, 10));
   224                   v.Add(new Voltage("CPU PLL", 5));
   225                   v.Add(new Voltage("DRAM", 6));
   226                   v.Add(new Voltage("+5VSB", 7, 6.8f, 10));
   227                   v.Add(new Voltage("VBat", 8));
   228                   t.Add(new Temperature("Chipset", 0));
   229                   t.Add(new Temperature("CPU PWM", 1));
   230                   t.Add(new Temperature("CPU", 2));
   231                   f.Add(new Fan("Fan #1", 0));
   232                   f.Add(new Fan("Fan #2", 1));
   233                   f.Add(new Fan("Fan #3", 2));
   234                   break;
   235                 default:
   236                   v.Add(new Voltage("CPU VCore", 0));
   237                   v.Add(new Voltage("VTT", 1, true));
   238                   v.Add(new Voltage("+3.3V", 2, true));
   239                   v.Add(new Voltage("+5V", 3, 6.8f, 10, 0, true));
   240                   v.Add(new Voltage("+12V", 4, 30, 10, 0, true));
   241                   v.Add(new Voltage("Voltage #6", 5, true));
   242                   v.Add(new Voltage("DRAM", 6, true));
   243                   v.Add(new Voltage("+5VSB", 7, 6.8f, 10, 0, true));
   244                   v.Add(new Voltage("VBat", 8));
   245                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   246                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   247                   for (int i = 0; i < superIO.Fans.Length; i++)
   248                     f.Add(new Fan("Fan #" + (i + 1), i));
   249                   break;
   250               }
   251               break;
   252 
   253             case Manufacturer.Gigabyte:
   254               switch (model) {
   255                 case Model._965P_S3: // IT8718F
   256                   v.Add(new Voltage("CPU VCore", 0));
   257                   v.Add(new Voltage("DRAM", 1));
   258                   v.Add(new Voltage("+3.3V", 2));
   259                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   260                   v.Add(new Voltage("+12V", 7, 27, 9.1f));
   261                   v.Add(new Voltage("VBat", 8));
   262                   t.Add(new Temperature("System", 0));
   263                   t.Add(new Temperature("CPU", 1));
   264                   f.Add(new Fan("CPU Fan", 0));
   265                   f.Add(new Fan("System Fan", 1));
   266                   break;
   267                 case Model.EP45_DS3R: // IT8718F
   268                 case Model.EP45_UD3R: 
   269                 case Model.X38_DS5:    
   270                   v.Add(new Voltage("CPU VCore", 0));
   271                   v.Add(new Voltage("DRAM", 1));
   272                   v.Add(new Voltage("+3.3V", 2));
   273                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   274                   v.Add(new Voltage("+12V", 7, 27, 9.1f));
   275                   v.Add(new Voltage("VBat", 8));
   276                   t.Add(new Temperature("System", 0));
   277                   t.Add(new Temperature("CPU", 1));
   278                   f.Add(new Fan("CPU Fan", 0));
   279                   f.Add(new Fan("System Fan #2", 1));
   280                   f.Add(new Fan("Power Fan", 2));
   281                   f.Add(new Fan("System Fan #1", 3));
   282                   break;
   283                 case Model.EX58_EXTREME: // IT8720F 
   284                   v.Add(new Voltage("CPU VCore", 0));
   285                   v.Add(new Voltage("DRAM", 1));
   286                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   287                   v.Add(new Voltage("VBat", 8));
   288                   t.Add(new Temperature("System", 0));
   289                   t.Add(new Temperature("CPU", 1));
   290                   t.Add(new Temperature("Northbridge", 2));
   291                   f.Add(new Fan("CPU Fan", 0));
   292                   f.Add(new Fan("System Fan #2", 1));
   293                   f.Add(new Fan("Power Fan", 2));
   294                   f.Add(new Fan("System Fan #1", 3));
   295                   break;
   296                 case Model.P35_DS3: // IT8718F 
   297                 case Model.P35_DS3L: // IT8718F
   298                   v.Add(new Voltage("CPU VCore", 0));
   299                   v.Add(new Voltage("DRAM", 1));
   300                   v.Add(new Voltage("+3.3V", 2));
   301                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   302                   v.Add(new Voltage("+12V", 7, 27, 9.1f));
   303                   v.Add(new Voltage("VBat", 8));
   304                   t.Add(new Temperature("System", 0));
   305                   t.Add(new Temperature("CPU", 1));
   306                   f.Add(new Fan("CPU Fan", 0));
   307                   f.Add(new Fan("System Fan #1", 1));
   308                   f.Add(new Fan("System Fan #2", 2));
   309                   f.Add(new Fan("Power Fan", 3));
   310                   break;
   311                 case Model.P55_UD4: // IT8720F
   312                 case Model.P55M_UD4: // IT8720F
   313                   v.Add(new Voltage("CPU VCore", 0));
   314                   v.Add(new Voltage("DRAM", 1));
   315                   v.Add(new Voltage("+3.3V", 2));
   316                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   317                   v.Add(new Voltage("+12V", 5, 27, 9.1f));
   318                   v.Add(new Voltage("VBat", 8));
   319                   t.Add(new Temperature("System", 0));
   320                   t.Add(new Temperature("CPU", 2));
   321                   f.Add(new Fan("CPU Fan", 0));
   322                   f.Add(new Fan("System Fan #2", 1));
   323                   f.Add(new Fan("Power Fan", 2));
   324                   f.Add(new Fan("System Fan #1", 3));
   325                   break;
   326                 case Model.GA_MA770T_UD3: // IT8720F
   327                   v.Add(new Voltage("CPU VCore", 0));
   328                   v.Add(new Voltage("DRAM", 1));
   329                   v.Add(new Voltage("+3.3V", 2));
   330                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   331                   v.Add(new Voltage("+12V", 4, 27, 9.1f));
   332                   v.Add(new Voltage("VBat", 8));
   333                   t.Add(new Temperature("System", 0));
   334                   t.Add(new Temperature("CPU", 1));
   335                   f.Add(new Fan("CPU Fan", 0));
   336                   f.Add(new Fan("System Fan #1", 1));
   337                   f.Add(new Fan("System Fan #2", 2));
   338                   f.Add(new Fan("Power Fan", 3));
   339                   break;
   340                 case Model.GA_MA785GMT_UD2H: // IT8718F
   341                   v.Add(new Voltage("CPU VCore", 0));
   342                   v.Add(new Voltage("DRAM", 1));
   343                   v.Add(new Voltage("+3.3V", 2));
   344                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   345                   v.Add(new Voltage("+12V", 4, 27, 9.1f));
   346                   v.Add(new Voltage("VBat", 8));
   347                   t.Add(new Temperature("System", 0));
   348                   t.Add(new Temperature("CPU", 1));
   349                   f.Add(new Fan("CPU Fan", 0));
   350                   f.Add(new Fan("System Fan", 1));
   351                   f.Add(new Fan("NB Fan", 2));
   352                   break;
   353                 case Model.X58A_UD3R: // IT8720F 
   354                   v.Add(new Voltage("CPU VCore", 0));
   355                   v.Add(new Voltage("DRAM", 1));
   356                   v.Add(new Voltage("+3.3V", 2));
   357                   v.Add(new Voltage("+5V", 3, 6.8f, 10));
   358                   v.Add(new Voltage("+12V", 5, 27, 9.1f));
   359                   v.Add(new Voltage("VBat", 8));
   360                   t.Add(new Temperature("System", 0));
   361                   t.Add(new Temperature("CPU", 1));
   362                   t.Add(new Temperature("Northbridge", 2));
   363                   f.Add(new Fan("CPU Fan", 0));
   364                   f.Add(new Fan("System Fan #2", 1));
   365                   f.Add(new Fan("Power Fan", 2));
   366                   f.Add(new Fan("System Fan #1", 3));
   367                   break;
   368                 default:
   369                   v.Add(new Voltage("CPU VCore", 0));
   370                   v.Add(new Voltage("DRAM", 1, true));
   371                   v.Add(new Voltage("+3.3V", 2, true));
   372                   v.Add(new Voltage("+5V", 3, 6.8f, 10, 0, true));
   373                   v.Add(new Voltage("Voltage #5", 4, true));
   374                   v.Add(new Voltage("Voltage #6", 5, true));
   375                   v.Add(new Voltage("Voltage #7", 6, true));
   376                   v.Add(new Voltage("Voltage #8", 7, true));
   377                   v.Add(new Voltage("VBat", 8));
   378                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   379                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   380                   for (int i = 0; i < superIO.Fans.Length; i++)
   381                     f.Add(new Fan("Fan #" + (i + 1), i));
   382                   break;
   383               }
   384               break;
   385 
   386             default:
   387               v.Add(new Voltage("CPU VCore", 0));
   388               v.Add(new Voltage("Voltage #2", 1, true));
   389               v.Add(new Voltage("Voltage #3", 2, true));
   390               v.Add(new Voltage("Voltage #4", 3, true));
   391               v.Add(new Voltage("Voltage #5", 4, true));
   392               v.Add(new Voltage("Voltage #6", 5, true));
   393               v.Add(new Voltage("Voltage #7", 6, true));
   394               v.Add(new Voltage("Voltage #8", 7, true));
   395               v.Add(new Voltage("VBat", 8));
   396               for (int i = 0; i < superIO.Temperatures.Length; i++)
   397                 t.Add(new Temperature("Temperature #" + (i + 1), i));
   398               for (int i = 0; i < superIO.Fans.Length; i++)
   399                 f.Add(new Fan("Fan #" + (i + 1), i));
   400               break;
   401           }
   402           break;
   403 
   404         case Chip.IT8721F:
   405         case Chip.IT8728F:
   406         case Chip.IT8771E:
   407         case Chip.IT8772E:
   408           switch (manufacturer) {
   409             case Manufacturer.ECS:
   410               switch (model) {
   411                 case Model.A890GXM_A: // IT8721F
   412                   v.Add(new Voltage("CPU VCore", 0));
   413                   v.Add(new Voltage("VDIMM", 1));
   414                   v.Add(new Voltage("NB Voltage", 2));
   415                   v.Add(new Voltage("Analog +3.3V", 3, 10, 10));
   416                   // v.Add(new Voltage("VDIMM", 6, true));
   417                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10));
   418                   v.Add(new Voltage("VBat", 8, 10, 10));
   419                   t.Add(new Temperature("CPU", 0));
   420                   t.Add(new Temperature("System", 1));
   421                   t.Add(new Temperature("Northbridge", 2));
   422                   f.Add(new Fan("CPU Fan", 0));
   423                   f.Add(new Fan("System Fan", 1));
   424                   f.Add(new Fan("Power Fan", 2));
   425                   break;
   426                 default:
   427                   v.Add(new Voltage("Voltage #1", 0, true));
   428                   v.Add(new Voltage("Voltage #2", 1, true));
   429                   v.Add(new Voltage("Voltage #3", 2, true));
   430                   v.Add(new Voltage("Analog +3.3V", 3, 10, 10, 0, true));
   431                   v.Add(new Voltage("Voltage #5", 4, true));
   432                   v.Add(new Voltage("Voltage #6", 5, true));
   433                   v.Add(new Voltage("Voltage #7", 6, true));
   434                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
   435                   v.Add(new Voltage("VBat", 8, 10, 10));
   436                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   437                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   438                   for (int i = 0; i < superIO.Fans.Length; i++)
   439                     f.Add(new Fan("Fan #" + (i + 1), i));
   440                   break;
   441               }
   442               break;
   443             case Manufacturer.Gigabyte:
   444               switch (model) {
   445                 case Model.P67A_UD4_B3: // IT8728F
   446                   v.Add(new Voltage("+12V", 0, 100, 10));
   447                   v.Add(new Voltage("+5V", 1, 15, 10));
   448                   v.Add(new Voltage("Voltage #3", 2, true));
   449                   v.Add(new Voltage("Voltage #4", 3, true));
   450                   v.Add(new Voltage("Voltage #5", 4, true));
   451                   v.Add(new Voltage("CPU VCore", 5));
   452                   v.Add(new Voltage("DRAM", 6));
   453                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10));
   454                   v.Add(new Voltage("VBat", 8, 10, 10));
   455                   t.Add(new Temperature("System", 0));
   456                   t.Add(new Temperature("CPU", 2));
   457                   f.Add(new Fan("CPU Fan", 0));
   458                   f.Add(new Fan("System Fan #2", 1));
   459                   f.Add(new Fan("Power Fan", 2));
   460                   f.Add(new Fan("System Fan #1", 3));
   461                   break;
   462                 case Model.H67A_UD3H_B3: // IT8728F
   463                   v.Add(new Voltage("VTT", 0));
   464                   v.Add(new Voltage("+5V", 1, 15, 10));
   465                   v.Add(new Voltage("+12V", 2, 68, 22));
   466                   v.Add(new Voltage("Voltage #4", 3, true));
   467                   v.Add(new Voltage("Voltage #5", 4, true));
   468                   v.Add(new Voltage("CPU VCore", 5));
   469                   v.Add(new Voltage("DRAM", 6));
   470                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10));
   471                   v.Add(new Voltage("VBat", 8, 10, 10));
   472                   t.Add(new Temperature("System", 0));
   473                   t.Add(new Temperature("CPU", 2));
   474                   f.Add(new Fan("CPU Fan", 0));
   475                   f.Add(new Fan("System Fan #1", 1));
   476                   f.Add(new Fan("Power Fan", 2));
   477                   f.Add(new Fan("System Fan #2", 3));
   478                   break;
   479                 case Model.Z68X_UD7_B3: // IT8728F
   480                   v.Add(new Voltage("VTT", 0));
   481                   v.Add(new Voltage("+3.3V", 1, 13.3f, 20.5f));
   482                   v.Add(new Voltage("+12V", 2, 68, 22));
   483                   v.Add(new Voltage("+5V", 3, 14.3f, 20));
   484                   v.Add(new Voltage("CPU VCore", 5));
   485                   v.Add(new Voltage("DRAM", 6));
   486                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10));
   487                   v.Add(new Voltage("VBat", 8, 10, 10));
   488                   t.Add(new Temperature("System", 0));
   489                   t.Add(new Temperature("CPU", 1));
   490                   t.Add(new Temperature("System 3", 2));
   491                   f.Add(new Fan("CPU Fan", 0));
   492                   f.Add(new Fan("Power Fan", 1));
   493                   f.Add(new Fan("System Fan #1", 2));
   494                   f.Add(new Fan("System Fan #2", 3));
   495                   f.Add(new Fan("System Fan #3", 4));
   496                   break;
   497                 default:
   498                   v.Add(new Voltage("Voltage #1", 0, true));
   499                   v.Add(new Voltage("Voltage #2", 1, true));
   500                   v.Add(new Voltage("Voltage #3", 2, true));
   501                   v.Add(new Voltage("Voltage #4", 3, true));
   502                   v.Add(new Voltage("Voltage #5", 4, true));
   503                   v.Add(new Voltage("Voltage #6", 5, true));
   504                   v.Add(new Voltage("Voltage #7", 6, true));
   505                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
   506                   v.Add(new Voltage("VBat", 8, 10, 10));
   507                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   508                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   509                   for (int i = 0; i < superIO.Fans.Length; i++)
   510                     f.Add(new Fan("Fan #" + (i + 1), i));
   511                   break;
   512               }
   513               break;
   514             case Manufacturer.Shuttle:
   515               switch (model) {
   516                 case Model.FH67: // IT8772E 
   517                   v.Add(new Voltage("CPU VCore", 0));
   518                   v.Add(new Voltage("DRAM", 1));
   519                   v.Add(new Voltage("PCH VCCIO", 2));
   520                   v.Add(new Voltage("CPU VCCIO", 3));
   521                   v.Add(new Voltage("Graphic Voltage", 4));
   522                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10));
   523                   v.Add(new Voltage("VBat", 8, 10, 10));
   524                   t.Add(new Temperature("System", 0));
   525                   t.Add(new Temperature("CPU", 1));                  
   526                   f.Add(new Fan("Fan #1", 0));
   527                   f.Add(new Fan("CPU Fan", 1));
   528                   break;
   529                 default:
   530                   v.Add(new Voltage("Voltage #1", 0, true));
   531                   v.Add(new Voltage("Voltage #2", 1, true));
   532                   v.Add(new Voltage("Voltage #3", 2, true));
   533                   v.Add(new Voltage("Voltage #4", 3, true));
   534                   v.Add(new Voltage("Voltage #5", 4, true));
   535                   v.Add(new Voltage("Voltage #6", 5, true));
   536                   v.Add(new Voltage("Voltage #7", 6, true));
   537                   v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
   538                   v.Add(new Voltage("VBat", 8, 10, 10));
   539                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   540                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   541                   for (int i = 0; i < superIO.Fans.Length; i++)
   542                     f.Add(new Fan("Fan #" + (i + 1), i));
   543                   break;
   544               }
   545               break;
   546             default:
   547               v.Add(new Voltage("Voltage #1", 0, true));
   548               v.Add(new Voltage("Voltage #2", 1, true));
   549               v.Add(new Voltage("Voltage #3", 2, true));
   550               v.Add(new Voltage("Voltage #4", 3, true));
   551               v.Add(new Voltage("Voltage #5", 4, true));
   552               v.Add(new Voltage("Voltage #6", 5, true));
   553               v.Add(new Voltage("Voltage #7", 6, true));
   554               v.Add(new Voltage("Standby +3.3V", 7, 10, 10, 0, true));
   555               v.Add(new Voltage("VBat", 8, 10, 10));
   556               for (int i = 0; i < superIO.Temperatures.Length; i++)
   557                 t.Add(new Temperature("Temperature #" + (i + 1), i));
   558               for (int i = 0; i < superIO.Fans.Length; i++)
   559                 f.Add(new Fan("Fan #" + (i + 1), i));
   560               break;
   561           }
   562           break;
   563           
   564         case Chip.F71858:
   565           v.Add(new Voltage("VCC3V", 0, 150, 150));
   566           v.Add(new Voltage("VSB3V", 1, 150, 150));
   567           v.Add(new Voltage("Battery", 2, 150, 150));
   568           for (int i = 0; i < superIO.Temperatures.Length; i++)
   569             t.Add(new Temperature("Temperature #" + (i + 1), i));
   570           for (int i = 0; i < superIO.Fans.Length; i++)
   571             f.Add(new Fan("Fan #" + (i + 1), i));
   572           break;
   573         case Chip.F71862: 
   574         case Chip.F71869: 
   575         case Chip.F71882:
   576         case Chip.F71889AD: 
   577         case Chip.F71889ED: 
   578         case Chip.F71889F:
   579           switch (manufacturer) {
   580             case Manufacturer.EVGA:
   581               switch (model) {
   582                 case Model.X58_SLI_Classified: // F71882 
   583                   v.Add(new Voltage("VCC3V", 0, 150, 150));
   584                   v.Add(new Voltage("CPU VCore", 1, 47, 100));
   585                   v.Add(new Voltage("DIMM", 2, 47, 100));
   586                   v.Add(new Voltage("CPU VTT", 3, 24, 100));
   587                   v.Add(new Voltage("IOH Vcore", 4, 24, 100));
   588                   v.Add(new Voltage("+5V", 5, 51, 12));
   589                   v.Add(new Voltage("+12V", 6, 56, 6.8f));
   590                   v.Add(new Voltage("3VSB", 7, 150, 150));
   591                   v.Add(new Voltage("VBat", 8, 150, 150));
   592                   t.Add(new Temperature("CPU", 0));
   593                   t.Add(new Temperature("VREG", 1));
   594                   t.Add(new Temperature("System", 2));
   595                   f.Add(new Fan("CPU Fan", 0));
   596                   f.Add(new Fan("Power Fan", 1));
   597                   f.Add(new Fan("Chassis Fan", 2));
   598                   break;
   599                 default:
   600                   v.Add(new Voltage("VCC3V", 0, 150, 150));
   601                   v.Add(new Voltage("CPU VCore", 1));
   602                   v.Add(new Voltage("Voltage #3", 2, true));
   603                   v.Add(new Voltage("Voltage #4", 3, true));
   604                   v.Add(new Voltage("Voltage #5", 4, true));
   605                   v.Add(new Voltage("Voltage #6", 5, true));
   606                   v.Add(new Voltage("Voltage #7", 6, true));
   607                   v.Add(new Voltage("VSB3V", 7, 150, 150));
   608                   v.Add(new Voltage("VBat", 8, 150, 150));
   609                   for (int i = 0; i < superIO.Temperatures.Length; i++)
   610                     t.Add(new Temperature("Temperature #" + (i + 1), i));
   611                   for (int i = 0; i < superIO.Fans.Length; i++)
   612                     f.Add(new Fan("Fan #" + (i + 1), i));
   613                   break;
   614               }
   615               break;
   616             default:
   617               v.Add(new Voltage("VCC3V", 0, 150, 150));
   618               v.Add(new Voltage("CPU VCore", 1));
   619               v.Add(new Voltage("Voltage #3", 2, true));
   620               v.Add(new Voltage("Voltage #4", 3, true));
   621               v.Add(new Voltage("Voltage #5", 4, true));
   622               v.Add(new Voltage("Voltage #6", 5, true));
   623               v.Add(new Voltage("Voltage #7", 6, true));
   624               v.Add(new Voltage("VSB3V", 7, 150, 150));
   625               v.Add(new Voltage("VBat", 8, 150, 150));
   626               for (int i = 0; i < superIO.Temperatures.Length; i++)
   627                 t.Add(new Temperature("Temperature #" + (i + 1), i));
   628               for (int i = 0; i < superIO.Fans.Length; i++)
   629                 f.Add(new Fan("Fan #" + (i + 1), i));
   630               break;
   631           }
   632           break;
   633 
   634         case Chip.W83627EHF:
   635           switch (manufacturer) {
   636             case Manufacturer.ASRock:
   637               switch (model) {
   638                 case Model.AOD790GX_128M: // W83627EHF
   639                   v.Add(new Voltage("CPU VCore", 0));
   640                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   641                   v.Add(new Voltage("+3.3V", 4, 10, 10));
   642                   v.Add(new Voltage("+5V", 5, 20, 10));
   643                   v.Add(new Voltage("+12V", 6, 28, 5));
   644                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   645                   v.Add(new Voltage("VBAT", 8, 34, 34));
   646                   t.Add(new Temperature("CPU", 0));
   647                   t.Add(new Temperature("Motherboard", 2));
   648                   f.Add(new Fan("CPU Fan", 0));
   649                   f.Add(new Fan("Chassis Fan", 1));                 
   650                   break;
   651                 default:
   652                   v.Add(new Voltage("CPU VCore", 0));
   653                   v.Add(new Voltage("Voltage #2", 1, true));
   654                   v.Add(new Voltage("AVCC", 2, 34, 34));
   655                   v.Add(new Voltage("3VCC", 3, 34, 34));
   656                   v.Add(new Voltage("Voltage #5", 4, true));
   657                   v.Add(new Voltage("Voltage #6", 5, true));
   658                   v.Add(new Voltage("Voltage #7", 6, true));
   659                   v.Add(new Voltage("3VSB", 7, 34, 34));
   660                   v.Add(new Voltage("VBAT", 8, 34, 34));
   661                   v.Add(new Voltage("Voltage #10", 9, true));
   662                   t.Add(new Temperature("CPU", 0));
   663                   t.Add(new Temperature("Auxiliary", 1));
   664                   t.Add(new Temperature("System", 2));
   665                   f.Add(new Fan("System Fan", 0));
   666                   f.Add(new Fan("CPU Fan", 1));
   667                   f.Add(new Fan("Auxiliary Fan", 2));
   668                   f.Add(new Fan("CPU Fan #2", 3));
   669                   f.Add(new Fan("Auxiliary Fan #2", 4));
   670                   break;
   671               } break;
   672             default:
   673               v.Add(new Voltage("CPU VCore", 0));
   674               v.Add(new Voltage("Voltage #2", 1, true));
   675               v.Add(new Voltage("AVCC", 2, 34, 34));
   676               v.Add(new Voltage("3VCC", 3, 34, 34));
   677               v.Add(new Voltage("Voltage #5", 4, true));
   678               v.Add(new Voltage("Voltage #6", 5, true));
   679               v.Add(new Voltage("Voltage #7", 6, true));
   680               v.Add(new Voltage("3VSB", 7, 34, 34));
   681               v.Add(new Voltage("VBAT", 8, 34, 34));
   682               v.Add(new Voltage("Voltage #10", 9, true));
   683               t.Add(new Temperature("CPU", 0));
   684               t.Add(new Temperature("Auxiliary", 1));
   685               t.Add(new Temperature("System", 2));
   686               f.Add(new Fan("System Fan", 0));
   687               f.Add(new Fan("CPU Fan", 1));
   688               f.Add(new Fan("Auxiliary Fan", 2));
   689               f.Add(new Fan("CPU Fan #2", 3));
   690               f.Add(new Fan("Auxiliary Fan #2", 4));
   691               break;
   692           }
   693           break;
   694         case Chip.W83627DHG: 
   695         case Chip.W83627DHGP:                      
   696         case Chip.W83667HG:
   697         case Chip.W83667HGB:
   698           switch (manufacturer) {
   699             case Manufacturer.ASRock:
   700               switch (model) {
   701                 case Model._880GMH_USB3: // W83627DHG-P
   702                   v.Add(new Voltage("CPU VCore", 0));
   703                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   704                   v.Add(new Voltage("+5V", 5, 15, 7.5f));
   705                   v.Add(new Voltage("+12V", 6, 56, 10));
   706                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   707                   v.Add(new Voltage("VBAT", 8, 34, 34));
   708                   t.Add(new Temperature("CPU", 0));
   709                   t.Add(new Temperature("Motherboard", 2));
   710                   f.Add(new Fan("Chassis Fan", 0));
   711                   f.Add(new Fan("CPU Fan", 1));
   712                   f.Add(new Fan("Power Fan", 2));
   713                   break;
   714                 default:
   715                   v.Add(new Voltage("CPU VCore", 0));
   716                   v.Add(new Voltage("Voltage #2", 1, true));
   717                   v.Add(new Voltage("AVCC", 2, 34, 34));
   718                   v.Add(new Voltage("3VCC", 3, 34, 34));
   719                   v.Add(new Voltage("Voltage #5", 4, true));
   720                   v.Add(new Voltage("Voltage #6", 5, true));
   721                   v.Add(new Voltage("Voltage #7", 6, true));
   722                   v.Add(new Voltage("3VSB", 7, 34, 34));
   723                   v.Add(new Voltage("VBAT", 8, 34, 34));
   724                   t.Add(new Temperature("CPU", 0));
   725                   t.Add(new Temperature("Auxiliary", 1));
   726                   t.Add(new Temperature("System", 2));
   727                   f.Add(new Fan("System Fan", 0));
   728                   f.Add(new Fan("CPU Fan", 1));
   729                   f.Add(new Fan("Auxiliary Fan", 2));
   730                   f.Add(new Fan("CPU Fan #2", 3));
   731                   f.Add(new Fan("Auxiliary Fan #2", 4));
   732                   break;
   733               }
   734               break;
   735             case Manufacturer.ASUS:
   736               switch (model) {
   737                 case Model.P6T: // W83667HG
   738                 case Model.P6X58D_E: // W83667HG                 
   739                 case Model.Rampage_II_GENE: // W83667HG 
   740                   v.Add(new Voltage("CPU VCore", 0));
   741                   v.Add(new Voltage("+12V", 1, 11.5f, 1.91f));
   742                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   743                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   744                   v.Add(new Voltage("+5V", 4, 15, 7.5f));
   745                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   746                   v.Add(new Voltage("VBAT", 8, 34, 34));
   747                   t.Add(new Temperature("CPU", 0));
   748                   t.Add(new Temperature("Motherboard", 2));
   749                   f.Add(new Fan("Chassis Fan #1", 0));
   750                   f.Add(new Fan("CPU Fan", 1));
   751                   f.Add(new Fan("Power Fan", 2));
   752                   f.Add(new Fan("Chassis Fan #2", 3));
   753                   f.Add(new Fan("Chassis Fan #3", 4));
   754                   break;
   755                 case Model.Rampage_Extreme: // W83667HG 
   756                   v.Add(new Voltage("CPU VCore", 0));
   757                   v.Add(new Voltage("+12V", 1, 12, 2));
   758                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   759                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   760                   v.Add(new Voltage("+5V", 4, 15, 7.5f));
   761                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   762                   v.Add(new Voltage("VBAT", 8, 34, 34));
   763                   t.Add(new Temperature("CPU", 0));
   764                   t.Add(new Temperature("Motherboard", 2));
   765                   f.Add(new Fan("Chassis Fan #1", 0));
   766                   f.Add(new Fan("CPU Fan", 1));
   767                   f.Add(new Fan("Power Fan", 2));
   768                   f.Add(new Fan("Chassis Fan #2", 3));
   769                   f.Add(new Fan("Chassis Fan #3", 4));
   770                   break;
   771                 default:
   772                   v.Add(new Voltage("CPU VCore", 0));
   773                   v.Add(new Voltage("Voltage #2", 1, true));
   774                   v.Add(new Voltage("AVCC", 2, 34, 34));
   775                   v.Add(new Voltage("3VCC", 3, 34, 34));
   776                   v.Add(new Voltage("Voltage #5", 4, true));
   777                   v.Add(new Voltage("Voltage #6", 5, true));
   778                   v.Add(new Voltage("Voltage #7", 6, true));
   779                   v.Add(new Voltage("3VSB", 7, 34, 34));
   780                   v.Add(new Voltage("VBAT", 8, 34, 34));
   781                   t.Add(new Temperature("CPU", 0));
   782                   t.Add(new Temperature("Auxiliary", 1));
   783                   t.Add(new Temperature("System", 2));
   784                   f.Add(new Fan("System Fan", 0));
   785                   f.Add(new Fan("CPU Fan", 1));
   786                   f.Add(new Fan("Auxiliary Fan", 2));
   787                   f.Add(new Fan("CPU Fan #2", 3));
   788                   f.Add(new Fan("Auxiliary Fan #2", 4));
   789                   break;
   790               }
   791               break;
   792             default:
   793               v.Add(new Voltage("CPU VCore", 0));
   794               v.Add(new Voltage("Voltage #2", 1, true));
   795               v.Add(new Voltage("AVCC", 2, 34, 34));
   796               v.Add(new Voltage("3VCC", 3, 34, 34));
   797               v.Add(new Voltage("Voltage #5", 4, true));
   798               v.Add(new Voltage("Voltage #6", 5, true));
   799               v.Add(new Voltage("Voltage #7", 6, true));
   800               v.Add(new Voltage("3VSB", 7, 34, 34));
   801               v.Add(new Voltage("VBAT", 8, 34, 34));
   802               t.Add(new Temperature("CPU", 0));
   803               t.Add(new Temperature("Auxiliary", 1));
   804               t.Add(new Temperature("System", 2));
   805               f.Add(new Fan("System Fan", 0));
   806               f.Add(new Fan("CPU Fan", 1));
   807               f.Add(new Fan("Auxiliary Fan", 2));
   808               f.Add(new Fan("CPU Fan #2", 3));
   809               f.Add(new Fan("Auxiliary Fan #2", 4));
   810               break;
   811           } 
   812           break;
   813         case Chip.W83627HF: 
   814         case Chip.W83627THF: 
   815         case Chip.W83687THF:
   816           v.Add(new Voltage("CPU VCore", 0));
   817           v.Add(new Voltage("Voltage #2", 1, true));
   818           v.Add(new Voltage("Voltage #3", 2, true));
   819           v.Add(new Voltage("AVCC", 3, 34, 51));
   820           v.Add(new Voltage("Voltage #5", 4, true));
   821           v.Add(new Voltage("5VSB", 5, 34, 51));
   822           v.Add(new Voltage("VBAT", 6));
   823           t.Add(new Temperature("CPU", 0));
   824           t.Add(new Temperature("Auxiliary", 1));
   825           t.Add(new Temperature("System", 2));
   826           f.Add(new Fan("System Fan", 0));
   827           f.Add(new Fan("CPU Fan", 1));
   828           f.Add(new Fan("Auxiliary Fan", 2));
   829           break;
   830         case Chip.NCT6771F:
   831         case Chip.NCT6776F:
   832           switch (manufacturer) {
   833             case Manufacturer.ASUS:
   834               switch (model) {
   835                 case Model.P8P67: // NCT6776F
   836                 case Model.P8P67_EVO: // NCT6776F
   837                 case Model.P8P67_PRO: // NCT6776F
   838                   v.Add(new Voltage("CPU VCore", 0));
   839                   v.Add(new Voltage("+12V", 1, 11, 1));
   840                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   841                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   842                   v.Add(new Voltage("+5V", 4, 12, 3));
   843                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   844                   v.Add(new Voltage("VBAT", 8, 34, 34));
   845                   t.Add(new Temperature("CPU", 0));
   846                   t.Add(new Temperature("Auxiliary", 2));
   847                   t.Add(new Temperature("Motherboard", 3));
   848                   f.Add(new Fan("Chassis Fan #1", 0));
   849                   f.Add(new Fan("CPU Fan", 1));
   850                   f.Add(new Fan("Power Fan", 2));
   851                   f.Add(new Fan("Chassis Fan #2", 3));
   852                   c.Add(new Ctrl("Chassis Fan #2", 0));
   853                   c.Add(new Ctrl("CPU Fan", 1));
   854                   c.Add(new Ctrl("Chassis Fan #1", 2));
   855                   break;
   856                 case Model.P8P67_M_PRO: // NCT6776F
   857                   v.Add(new Voltage("CPU VCore", 0));
   858                   v.Add(new Voltage("+12V", 1, 11, 1));
   859                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   860                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   861                   v.Add(new Voltage("+5V", 4, 12, 3));
   862                   v.Add(new Voltage("Voltage #6", 5, true));
   863                   v.Add(new Voltage("Voltage #7", 6, true));
   864                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   865                   v.Add(new Voltage("VBAT", 8, 34, 34));
   866                   t.Add(new Temperature("CPU", 0));
   867                   t.Add(new Temperature("Motherboard", 3));
   868                   f.Add(new Fan("Chassis Fan #1", 0));
   869                   f.Add(new Fan("CPU Fan", 1));
   870                   f.Add(new Fan("Chassis Fan #2", 2));
   871                   f.Add(new Fan("Power Fan", 3));
   872                   f.Add(new Fan("Auxiliary Fan", 4));
   873                   break;
   874                 case Model.P8Z68_V_PRO: // NCT6776F
   875                   v.Add(new Voltage("CPU VCore", 0));
   876                   v.Add(new Voltage("+12V", 1, 11, 1));
   877                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   878                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   879                   v.Add(new Voltage("+5V", 4, 12, 3));
   880                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   881                   v.Add(new Voltage("VBAT", 8, 34, 34));
   882                   t.Add(new Temperature("CPU", 0));
   883                   t.Add(new Temperature("Auxiliary", 2));
   884                   t.Add(new Temperature("Motherboard", 3));
   885                   for (int i = 0; i < superIO.Fans.Length; i++)
   886                     f.Add(new Fan("Fan #" + (i + 1), i));
   887                   for (int i = 0; i < superIO.Controls.Length; i++)
   888                     c.Add(new Ctrl("Fan #" + (i + 1), i));
   889                   break;
   890                 case Model.P9X79: // NCT6776F
   891                   v.Add(new Voltage("CPU VCore", 0));
   892                   v.Add(new Voltage("+12V", 1, 11, 1));
   893                   v.Add(new Voltage("Analog +3.3V", 2, 34, 34));
   894                   v.Add(new Voltage("+3.3V", 3, 34, 34));
   895                   v.Add(new Voltage("+5V", 4, 12, 3));
   896                   v.Add(new Voltage("Standby +3.3V", 7, 34, 34));
   897                   v.Add(new Voltage("VBAT", 8, 34, 34));
   898                   t.Add(new Temperature("CPU", 0));
   899                   t.Add(new Temperature("Motherboard", 3));
   900                   for (int i = 0; i < superIO.Fans.Length; i++)
   901                     f.Add(new Fan("Fan #" + (i + 1), i));
   902                   break;
   903                 default:
   904                   v.Add(new Voltage("CPU VCore", 0));
   905                   v.Add(new Voltage("Voltage #2", 1, true));
   906                   v.Add(new Voltage("AVCC", 2, 34, 34));
   907                   v.Add(new Voltage("3VCC", 3, 34, 34));
   908                   v.Add(new Voltage("Voltage #5", 4, true));
   909                   v.Add(new Voltage("Voltage #6", 5, true));
   910                   v.Add(new Voltage("Voltage #7", 6, true));
   911                   v.Add(new Voltage("3VSB", 7, 34, 34));
   912                   v.Add(new Voltage("VBAT", 8, 34, 34));
   913                   t.Add(new Temperature("CPU", 0));
   914                   t.Add(new Temperature("CPU", 1));
   915                   t.Add(new Temperature("Auxiliary", 2));
   916                   t.Add(new Temperature("System", 3));
   917                   for (int i = 0; i < superIO.Fans.Length; i++)
   918                     f.Add(new Fan("Fan #" + (i + 1), i));
   919                   break;
   920               }
   921               break;
   922             default:
   923               v.Add(new Voltage("CPU VCore", 0));
   924               v.Add(new Voltage("Voltage #2", 1, true));
   925               v.Add(new Voltage("AVCC", 2, 34, 34));
   926               v.Add(new Voltage("3VCC", 3, 34, 34));
   927               v.Add(new Voltage("Voltage #5", 4, true));
   928               v.Add(new Voltage("Voltage #6", 5, true));
   929               v.Add(new Voltage("Voltage #7", 6, true));
   930               v.Add(new Voltage("3VSB", 7, 34, 34));
   931               v.Add(new Voltage("VBAT", 8, 34, 34));
   932               t.Add(new Temperature("CPU", 0));
   933               t.Add(new Temperature("CPU", 1));
   934               t.Add(new Temperature("Auxiliary", 2));
   935               t.Add(new Temperature("System", 3));
   936               for (int i = 0; i < superIO.Fans.Length; i++)
   937                 f.Add(new Fan("Fan #" + (i + 1), i));
   938               break;
   939           }
   940           break;
   941         default:
   942           for (int i = 0; i < superIO.Voltages.Length; i++)
   943             v.Add(new Voltage("Voltage #" + (i + 1), i, true));
   944           for (int i = 0; i < superIO.Temperatures.Length; i++)
   945             t.Add(new Temperature("Temperature #" + (i + 1), i));
   946           for (int i = 0; i < superIO.Fans.Length; i++)
   947             f.Add(new Fan("Fan #" + (i + 1), i));
   948           for (int i = 0; i < superIO.Controls.Length; i++)
   949             c.Add(new Ctrl("Fan Control #" + (i + 1), i));
   950           break;
   951       }
   952 
   953       const string formula = "Voltage = value + (value - Vf) * Ri / Rf.";
   954       foreach (Voltage voltage in v) 
   955         if (voltage.Index < superIO.Voltages.Length) {
   956           Sensor sensor = new Sensor(voltage.Name, voltage.Index, 
   957             voltage.Hidden, SensorType.Voltage, this, new [] {
   958             new ParameterDescription("Ri [kΩ]", "Input resistance.\n" + 
   959               formula, voltage.Ri),
   960             new ParameterDescription("Rf [kΩ]", "Reference resistance.\n" + 
   961               formula, voltage.Rf),
   962             new ParameterDescription("Vf [V]", "Reference voltage.\n" + 
   963               formula, voltage.Vf)
   964             }, settings);
   965           voltages.Add(sensor);
   966       }
   967 
   968       foreach (Temperature temperature in t) 
   969         if (temperature.Index < superIO.Temperatures.Length) {
   970         Sensor sensor = new Sensor(temperature.Name, temperature.Index,
   971           SensorType.Temperature, this, new [] {
   972           new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
   973         }, settings);
   974         temperatures.Add(sensor);
   975       }
   976 
   977       foreach (Fan fan in f)
   978         if (fan.Index < superIO.Fans.Length) {
   979           Sensor sensor = new Sensor(fan.Name, fan.Index, SensorType.Fan,
   980             this, settings);
   981           fans.Add(sensor);
   982         }
   983 
   984       foreach (Ctrl ctrl in c) {
   985         int index = ctrl.Index;
   986         if (index < superIO.Controls.Length) {
   987           Sensor sensor = new Sensor(ctrl.Name, index, SensorType.Control,
   988             this, settings);
   989           Control control = new Control(sensor, settings, 0, 100);
   990           control.ControlModeChanged += (cc) => {
   991             if (cc.ControlMode == ControlMode.Default) {
   992               superIO.SetControl(index, null);
   993             } else {
   994               superIO.SetControl(index, (byte)(cc.SoftwareValue * 2.55));
   995             }
   996           };
   997           control.SoftwareControlValueChanged += (cc) => {
   998             if (cc.ControlMode == ControlMode.Software) 
   999               superIO.SetControl(index, (byte)(cc.SoftwareValue * 2.55));
  1000           };
  1001           if (control.ControlMode == ControlMode.Software) 
  1002             superIO.SetControl(index, (byte)(control.SoftwareValue * 2.55));
  1003           sensor.Control = control;
  1004           controls.Add(sensor);
  1005         }
  1006       }
  1007     }
  1008 
  1009     public override HardwareType HardwareType {
  1010       get { return HardwareType.SuperIO; }
  1011     }
  1012 
  1013     public override IHardware Parent {
  1014       get { return mainboard; }
  1015     }
  1016 
  1017 
  1018     public override string GetReport() {
  1019       return superIO.GetReport();
  1020     }
  1021 
  1022     public override void Update() {
  1023       superIO.Update();
  1024 
  1025       foreach (Sensor sensor in voltages) {
  1026         float? value = readVoltage(sensor.Index);
  1027         if (value.HasValue) {
  1028           sensor.Value = value + (value - sensor.Parameters[2].Value) *
  1029             sensor.Parameters[0].Value / sensor.Parameters[1].Value;
  1030           ActivateSensor(sensor);
  1031         }
  1032       }
  1033 
  1034       foreach (Sensor sensor in temperatures) {
  1035         float? value = readTemperature(sensor.Index);
  1036         if (value.HasValue) {
  1037           sensor.Value = value + sensor.Parameters[0].Value;
  1038           ActivateSensor(sensor);
  1039         }
  1040       }
  1041 
  1042       foreach (Sensor sensor in fans) {
  1043         float? value = readFan(sensor.Index);
  1044         if (value.HasValue) {
  1045           sensor.Value = value;
  1046           if (value.Value > 0)
  1047             ActivateSensor(sensor);
  1048         }
  1049       }
  1050 
  1051       foreach (Sensor sensor in controls) {
  1052         float? value = readControl(sensor.Index);
  1053         if (value.HasValue) {
  1054           sensor.Value = value;
  1055           ActivateSensor(sensor);
  1056         }
  1057       }
  1058 
  1059       postUpdate();
  1060     }
  1061 
  1062     public override void Close() {
  1063       foreach (Sensor sensor in controls) {
  1064         // restore all controls back to default
  1065         superIO.SetControl(sensor.Index, null);
  1066       }
  1067       base.Close();
  1068     }
  1069 
  1070     private class Voltage {
  1071       public readonly string Name;
  1072       public readonly int Index;
  1073       public readonly float Ri;
  1074       public readonly float Rf;
  1075       public readonly float Vf;
  1076       public readonly bool Hidden;
  1077 
  1078       public Voltage(string name, int index) :
  1079         this(name, index, false) { }
  1080       
  1081       public Voltage(string name, int index, bool hidden) :
  1082         this(name, index, 0, 1, 0, hidden) { }
  1083       
  1084       public Voltage(string name, int index, float ri, float rf) :
  1085         this(name, index, ri, rf, 0, false) { }
  1086       
  1087       // float ri = 0, float rf = 1, float vf = 0, bool hidden = false) 
  1088       
  1089       public Voltage(string name, int index, 
  1090         float ri, float rf, float vf, bool hidden) 
  1091       {
  1092         this.Name = name;
  1093         this.Index = index;
  1094         this.Ri = ri;
  1095         this.Rf = rf;
  1096         this.Vf = vf;
  1097         this.Hidden = hidden;
  1098       }
  1099     }
  1100 
  1101     private class Temperature {
  1102       public readonly string Name;
  1103       public readonly int Index;
  1104 
  1105       public Temperature(string name, int index) {
  1106         this.Name = name;
  1107         this.Index = index;
  1108       }
  1109     }
  1110 
  1111     private class Fan {
  1112       public readonly string Name;
  1113       public readonly int Index;
  1114 
  1115       public Fan(string name, int index) {
  1116         this.Name = name;
  1117         this.Index = index;
  1118       }
  1119     }
  1120 
  1121     private class Ctrl {
  1122       public readonly string Name;
  1123       public readonly int Index;
  1124 
  1125       public Ctrl(string name, int index) {
  1126         this.Name = name;
  1127         this.Index = index;
  1128       }
  1129     }
  1130   }
  1131 }