1.1 --- a/Hardware/Sensor.cs Tue Feb 23 19:45:40 2010 +0000
1.2 +++ b/Hardware/Sensor.cs Sat Feb 27 15:55:17 2010 +0000
1.3 @@ -37,6 +37,7 @@
1.4
1.5 using System;
1.6 using System.Collections.Generic;
1.7 +using OpenHardwareMonitor.Utilities;
1.8
1.9 namespace OpenHardwareMonitor.Hardware {
1.10
1.11 @@ -47,6 +48,7 @@
1.12 private int index;
1.13 private SensorType sensorType;
1.14 private IHardware hardware;
1.15 + private ReadOnlyArray<IParameter> parameters;
1.16 private float? value;
1.17 private float? min;
1.18 private float? max;
1.19 @@ -61,25 +63,32 @@
1.20 private const int MAX_MINUTES = 120;
1.21
1.22 public Sensor(string name, int index, SensorType sensorType,
1.23 - IHardware hardware)
1.24 - : this(name, index, null, sensorType, hardware) { }
1.25 + IHardware hardware) : this(name, index, null, sensorType, hardware,
1.26 + new ParameterDescription[0]) { }
1.27
1.28 - public Sensor(string name, int index, float? limit,
1.29 - SensorType sensorType, IHardware hardware)
1.30 + public Sensor(string name, int index, float? limit,
1.31 + SensorType sensorType, IHardware hardware) : this(name, index, limit,
1.32 + sensorType, hardware, new ParameterDescription[0]) { }
1.33 +
1.34 + public Sensor(string name, int index, float? limit, SensorType sensorType,
1.35 + IHardware hardware, ParameterDescription[] parameterDescriptions)
1.36 {
1.37 this.defaultName = name;
1.38 this.index = index;
1.39 this.defaultLimit = limit;
1.40 this.sensorType = sensorType;
1.41 this.hardware = hardware;
1.42 - string configName =
1.43 - Utilities.Config.Settings[Identifier + "/name"];
1.44 + Parameter[] parameters = new Parameter[parameterDescriptions.Length];
1.45 + for (int i = 0; i < parameters.Length; i++ )
1.46 + parameters[i] = new Parameter(parameterDescriptions[i], this);
1.47 + this.parameters = parameters;
1.48 +
1.49 + string configName = Config.Settings[Identifier + "/name"];
1.50 if (configName != null)
1.51 this.name = configName;
1.52 else
1.53 this.name = name;
1.54 - string configLimit =
1.55 - Utilities.Config.Settings[Identifier + "/limit"];
1.56 + string configLimit = Config.Settings[Identifier + "/limit"];
1.57 if (configLimit != null && configLimit != "")
1.58 this.limit = float.Parse(configLimit);
1.59 else
1.60 @@ -110,7 +119,7 @@
1.61 name = value;
1.62 else
1.63 name = defaultName;
1.64 - Utilities.Config.Settings[Identifier + "/name"] = name;
1.65 + Config.Settings[Identifier + "/name"] = name;
1.66 }
1.67 }
1.68
1.69 @@ -118,6 +127,10 @@
1.70 get { return index; }
1.71 }
1.72
1.73 + public IReadOnlyArray<IParameter> Parameters {
1.74 + get { return parameters; }
1.75 + }
1.76 +
1.77 public float? Value {
1.78 get {
1.79 return value;
1.80 @@ -156,11 +169,11 @@
1.81 set {
1.82 if (value.HasValue) {
1.83 limit = value;
1.84 - Utilities.Config.Settings[Identifier + "/limit"] =
1.85 + Config.Settings[Identifier + "/limit"] =
1.86 limit.ToString();
1.87 } else {
1.88 limit = defaultLimit;
1.89 - Utilities.Config.Settings[Identifier + "/limit"] = "";
1.90 + Config.Settings[Identifier + "/limit"] = "";
1.91 }
1.92 }
1.93 }