2010-10-16 18:24:20 +00:00
|
|
|
/*
|
|
|
|
|
2012-05-27 14:23:31 +00:00
|
|
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2010-10-16 18:24:20 +00:00
|
|
|
|
2012-05-27 14:23:31 +00:00
|
|
|
Copyright (C) 2009-2010 Paul Werelds <paul@werelds.net>
|
|
|
|
|
2010-10-16 18:24:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
using System.Management.Instrumentation;
|
|
|
|
using OpenHardwareMonitor.Hardware;
|
|
|
|
|
2010-10-17 08:21:33 +00:00
|
|
|
namespace OpenHardwareMonitor.WMI {
|
2010-10-16 18:24:20 +00:00
|
|
|
[InstrumentationClass(InstrumentationType.Instance)]
|
|
|
|
public class Sensor : IWmiObject {
|
|
|
|
private ISensor sensor;
|
|
|
|
|
|
|
|
#region WMI Exposed
|
|
|
|
|
|
|
|
public string SensorType { get; private set; }
|
|
|
|
public string Identifier { get; private set; }
|
|
|
|
public string Parent { get; private set; }
|
|
|
|
public string Name { get; private set; }
|
|
|
|
public float Value { get; private set; }
|
|
|
|
public float Min { get; private set; }
|
|
|
|
public float Max { get; private set; }
|
|
|
|
public int Index { get; private set; }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
public Sensor(ISensor sensor) {
|
|
|
|
Name = sensor.Name;
|
|
|
|
Index = sensor.Index;
|
|
|
|
|
|
|
|
SensorType = sensor.SensorType.ToString();
|
|
|
|
Identifier = sensor.Identifier.ToString();
|
|
|
|
Parent = sensor.Hardware.Identifier.ToString();
|
|
|
|
|
|
|
|
this.sensor = sensor;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Update() {
|
|
|
|
Value = (sensor.Value != null) ? (float)sensor.Value : 0;
|
|
|
|
|
|
|
|
if (sensor.Min != null)
|
|
|
|
Min = (float)sensor.Min;
|
|
|
|
|
|
|
|
if (sensor.Max != null)
|
|
|
|
Max = (float)sensor.Max;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|