author | moel.mich |
Mon, 13 Feb 2012 20:34:39 +0000 | |
changeset 338 | f580591971ce |
parent 227 | 97757a798918 |
child 344 | 3145aadca3d2 |
permissions | -rw-r--r-- |
paulwerelds@224 | 1 |
/* |
paulwerelds@224 | 2 |
|
paulwerelds@224 | 3 |
Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
paulwerelds@224 | 4 |
|
paulwerelds@224 | 5 |
The contents of this file are subject to the Mozilla Public License Version |
paulwerelds@224 | 6 |
1.1 (the "License"); you may not use this file except in compliance with |
paulwerelds@224 | 7 |
the License. You may obtain a copy of the License at |
paulwerelds@224 | 8 |
|
paulwerelds@224 | 9 |
http://www.mozilla.org/MPL/ |
paulwerelds@224 | 10 |
|
paulwerelds@224 | 11 |
Software distributed under the License is distributed on an "AS IS" basis, |
paulwerelds@224 | 12 |
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
paulwerelds@224 | 13 |
for the specific language governing rights and limitations under the License. |
paulwerelds@224 | 14 |
|
paulwerelds@224 | 15 |
The Original Code is the Open Hardware Monitor code. |
paulwerelds@224 | 16 |
|
paulwerelds@224 | 17 |
The Initial Developer of the Original Code is |
paulwerelds@224 | 18 |
Paul Werelds <paul@werelds.net>. |
paulwerelds@224 | 19 |
Portions created by the Initial Developer are Copyright (C) 2009-2010 |
paulwerelds@224 | 20 |
the Initial Developer. All Rights Reserved. |
paulwerelds@224 | 21 |
|
paulwerelds@224 | 22 |
Contributor(s): |
paulwerelds@224 | 23 |
|
paulwerelds@224 | 24 |
Alternatively, the contents of this file may be used under the terms of |
paulwerelds@224 | 25 |
either the GNU General Public License Version 2 or later (the "GPL"), or |
paulwerelds@224 | 26 |
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
paulwerelds@224 | 27 |
in which case the provisions of the GPL or the LGPL are applicable instead |
paulwerelds@224 | 28 |
of those above. If you wish to allow use of your version of this file only |
paulwerelds@224 | 29 |
under the terms of either the GPL or the LGPL, and not to allow others to |
paulwerelds@224 | 30 |
use your version of this file under the terms of the MPL, indicate your |
paulwerelds@224 | 31 |
decision by deleting the provisions above and replace them with the notice |
paulwerelds@224 | 32 |
and other provisions required by the GPL or the LGPL. If you do not delete |
paulwerelds@224 | 33 |
the provisions above, a recipient may use your version of this file under |
paulwerelds@224 | 34 |
the terms of any one of the MPL, the GPL or the LGPL. |
paulwerelds@224 | 35 |
|
paulwerelds@224 | 36 |
*/ |
paulwerelds@224 | 37 |
|
paulwerelds@223 | 38 |
using System.Management.Instrumentation; |
paulwerelds@223 | 39 |
using OpenHardwareMonitor.Hardware; |
paulwerelds@223 | 40 |
|
paulwerelds@227 | 41 |
namespace OpenHardwareMonitor.WMI { |
paulwerelds@223 | 42 |
[InstrumentationClass(InstrumentationType.Instance)] |
paulwerelds@224 | 43 |
public class Sensor : IWmiObject { |
paulwerelds@224 | 44 |
private ISensor sensor; |
paulwerelds@223 | 45 |
|
paulwerelds@224 | 46 |
#region WMI Exposed |
paulwerelds@223 | 47 |
|
paulwerelds@223 | 48 |
public string SensorType { get; private set; } |
paulwerelds@223 | 49 |
public string Identifier { get; private set; } |
paulwerelds@223 | 50 |
public string Parent { get; private set; } |
paulwerelds@223 | 51 |
public string Name { get; private set; } |
paulwerelds@223 | 52 |
public float Value { get; private set; } |
paulwerelds@223 | 53 |
public float Min { get; private set; } |
paulwerelds@223 | 54 |
public float Max { get; private set; } |
paulwerelds@223 | 55 |
public int Index { get; private set; } |
paulwerelds@223 | 56 |
|
paulwerelds@224 | 57 |
#endregion |
paulwerelds@223 | 58 |
|
paulwerelds@225 | 59 |
public Sensor(ISensor sensor) { |
paulwerelds@225 | 60 |
Name = sensor.Name; |
paulwerelds@225 | 61 |
Index = sensor.Index; |
paulwerelds@223 | 62 |
|
paulwerelds@225 | 63 |
SensorType = sensor.SensorType.ToString(); |
paulwerelds@225 | 64 |
Identifier = sensor.Identifier.ToString(); |
paulwerelds@225 | 65 |
Parent = sensor.Hardware.Identifier.ToString(); |
paulwerelds@224 | 66 |
|
paulwerelds@225 | 67 |
this.sensor = sensor; |
paulwerelds@223 | 68 |
} |
paulwerelds@223 | 69 |
|
paulwerelds@223 | 70 |
public void Update() { |
paulwerelds@224 | 71 |
Value = (sensor.Value != null) ? (float)sensor.Value : 0; |
paulwerelds@223 | 72 |
|
paulwerelds@224 | 73 |
if (sensor.Min != null) |
paulwerelds@224 | 74 |
Min = (float)sensor.Min; |
paulwerelds@223 | 75 |
|
paulwerelds@224 | 76 |
if (sensor.Max != null) |
paulwerelds@224 | 77 |
Max = (float)sensor.Max; |
paulwerelds@223 | 78 |
} |
paulwerelds@223 | 79 |
} |
paulwerelds@223 | 80 |
} |