Added a minimal control interface to allow manual fan control and implemented the interface for ATI GPUs.
3 Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 The contents of this file are subject to the Mozilla Public License Version
6 1.1 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.mozilla.org/MPL/
11 Software distributed under the License is distributed on an "AS IS" basis,
12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 for the specific language governing rights and limitations under the License.
15 The Original Code is the Open Hardware Monitor code.
17 The Initial Developer of the Original Code is
18 Michael Möller <m.moeller@gmx.ch>.
19 Portions created by the Initial Developer are Copyright (C) 2010
20 the Initial Developer. All Rights Reserved.
24 Alternatively, the contents of this file may be used under the terms of
25 either the GNU General Public License Version 2 or later (the "GPL"), or
26 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 in which case the provisions of the GPL or the LGPL are applicable instead
28 of those above. If you wish to allow use of your version of this file only
29 under the terms of either the GPL or the LGPL, and not to allow others to
30 use your version of this file under the terms of the MPL, indicate your
31 decision by deleting the provisions above and replace them with the notice
32 and other provisions required by the GPL or the LGPL. If you do not delete
33 the provisions above, a recipient may use your version of this file under
34 the terms of any one of the MPL, the GPL or the LGPL.
39 using System.Globalization;
41 namespace OpenHardwareMonitor.Hardware {
43 internal delegate void ControlEventHandler(Control control);
45 internal class Control : IControl {
47 private readonly Identifier identifier;
48 private readonly ISettings settings;
49 private ControlMode mode;
50 private float softwareValue;
51 private float minSoftwareValue;
52 private float maxSoftwareValue;
54 public Control(ISensor sensor, ISettings settings, float minSoftwareValue,
55 float maxSoftwareValue)
57 this.identifier = new Identifier(sensor.Identifier, "control");
58 this.settings = settings;
59 this.minSoftwareValue = minSoftwareValue;
60 this.maxSoftwareValue = maxSoftwareValue;
62 if (!float.TryParse(settings.GetValue(
63 new Identifier(identifier, "value").ToString(), "0"),
64 NumberStyles.Float, CultureInfo.InvariantCulture,
65 out this.softwareValue))
67 this.softwareValue = 0;
70 if (!int.TryParse(settings.GetValue(
71 new Identifier(identifier, "mode").ToString(),
72 ((int)ControlMode.Default).ToString(CultureInfo.InvariantCulture)),
73 NumberStyles.Integer, CultureInfo.InvariantCulture,
76 this.mode = ControlMode.Default;
78 this.mode = (ControlMode)mode;
82 public Identifier Identifier {
88 public ControlMode ControlMode {
95 if (ControlModeChanged != null)
96 ControlModeChanged(this);
97 this.settings.SetValue(new Identifier(identifier, "mode").ToString(),
98 ((int)mode).ToString(CultureInfo.InvariantCulture));
103 public float SoftwareValue {
105 return softwareValue;
108 if (softwareValue != value) {
109 softwareValue = value;
110 if (SoftwareControlValueChanged != null)
111 SoftwareControlValueChanged(this);
112 this.settings.SetValue(new Identifier(identifier,
114 value.ToString(CultureInfo.InvariantCulture));
119 public void SetDefault() {
120 ControlMode = ControlMode.Default;
123 public float MinSoftwareValue {
125 return minSoftwareValue;
129 public float MaxSoftwareValue {
131 return maxSoftwareValue;
135 public void SetSoftware(float value) {
136 ControlMode = ControlMode.Software;
137 SoftwareValue = value;
140 internal event ControlEventHandler ControlModeChanged;
141 internal event ControlEventHandler SoftwareControlValueChanged;