paulwerelds@224: /* paulwerelds@224: moel@344: This Source Code Form is subject to the terms of the Mozilla Public moel@344: License, v. 2.0. If a copy of the MPL was not distributed with this moel@344: file, You can obtain one at http://mozilla.org/MPL/2.0/. paulwerelds@224: moel@344: Copyright (C) 2009-2010 Paul Werelds moel@344: paulwerelds@224: */ paulwerelds@224: paulwerelds@223: using System.Management.Instrumentation; paulwerelds@223: using OpenHardwareMonitor.Hardware; paulwerelds@223: paulwerelds@227: namespace OpenHardwareMonitor.WMI { paulwerelds@223: [InstrumentationClass(InstrumentationType.Instance)] paulwerelds@224: public class Sensor : IWmiObject { paulwerelds@224: private ISensor sensor; paulwerelds@223: paulwerelds@224: #region WMI Exposed paulwerelds@223: paulwerelds@223: public string SensorType { get; private set; } paulwerelds@223: public string Identifier { get; private set; } paulwerelds@223: public string Parent { get; private set; } paulwerelds@223: public string Name { get; private set; } paulwerelds@223: public float Value { get; private set; } paulwerelds@223: public float Min { get; private set; } paulwerelds@223: public float Max { get; private set; } paulwerelds@223: public int Index { get; private set; } paulwerelds@223: paulwerelds@224: #endregion paulwerelds@223: paulwerelds@225: public Sensor(ISensor sensor) { paulwerelds@225: Name = sensor.Name; paulwerelds@225: Index = sensor.Index; paulwerelds@223: paulwerelds@225: SensorType = sensor.SensorType.ToString(); paulwerelds@225: Identifier = sensor.Identifier.ToString(); paulwerelds@225: Parent = sensor.Hardware.Identifier.ToString(); paulwerelds@224: paulwerelds@225: this.sensor = sensor; paulwerelds@223: } paulwerelds@223: paulwerelds@223: public void Update() { paulwerelds@224: Value = (sensor.Value != null) ? (float)sensor.Value : 0; paulwerelds@223: paulwerelds@224: if (sensor.Min != null) paulwerelds@224: Min = (float)sensor.Min; paulwerelds@223: paulwerelds@224: if (sensor.Max != null) paulwerelds@224: Max = (float)sensor.Max; paulwerelds@223: } paulwerelds@223: } paulwerelds@223: }