WMIProvider/Sensor.cs
changeset 223 39f73ac8c2f4
child 224 be9534663a55
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/WMIProvider/Sensor.cs	Sat Oct 16 13:29:06 2010 +0000
     1.3 @@ -0,0 +1,40 @@
     1.4 +using System.Management.Instrumentation;
     1.5 +using OpenHardwareMonitor.Hardware;
     1.6 +
     1.7 +namespace OpenHardwareMonitor.WMIProvider {
     1.8 +  [InstrumentationClass(InstrumentationType.Instance)]
     1.9 +  public class Sensor : IWmiClass {
    1.10 +
    1.11 +    private ISensor _sensor;
    1.12 +
    1.13 +    public string SensorType { get; private set; }
    1.14 +    public string Identifier { get; private set; }
    1.15 +    public string Parent { get; private set; }
    1.16 +    public string Name { get; private set; }
    1.17 +    public float Value { get; private set; }
    1.18 +    public float Min { get; private set; }
    1.19 +    public float Max { get; private set; }
    1.20 +    public int Index { get; private set; }
    1.21 +
    1.22 +    public Sensor(ISensor sensor) {
    1.23 +      Name = sensor.Name;
    1.24 +      Index = sensor.Index;
    1.25 +
    1.26 +      SensorType = sensor.SensorType.ToString();
    1.27 +      Identifier = sensor.Identifier.ToString();
    1.28 +      Parent = sensor.Hardware.Identifier.ToString();
    1.29 +
    1.30 +      _sensor = sensor;
    1.31 +    }
    1.32 +    
    1.33 +    public void Update() {
    1.34 +      Value = (_sensor.Value != null) ? (float)_sensor.Value : 0;
    1.35 +
    1.36 +      if (_sensor.Min != null)
    1.37 +        Min = (float)_sensor.Min;
    1.38 +
    1.39 +      if (_sensor.Max != null)
    1.40 +        Max = (float)_sensor.Max;
    1.41 +    }
    1.42 +  }
    1.43 +}