Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: GUI/MainForm.cs
- ===================================================================
- --- GUI/MainForm.cs (revision 314)
- +++ GUI/MainForm.cs (working copy)
- @@ -60,6 +60,7 @@
- private SystemTray systemTray;
- private StartupManager startupManager = new StartupManager();
- private UpdateVisitor updateVisitor = new UpdateVisitor();
- + private DateTime lastLogTime = System.DateTime.MinValue;
- private SensorGadget gadget;
- private UserOption showHiddenSensors;
- @@ -343,6 +344,27 @@
- if (wmiProvider != null)
- wmiProvider.Update();
- +
- + try
- + {
- + int intervalSeconds = settings.GetValue("log.interval", 0);
- + if (intervalSeconds > 0)
- + {
- + DateTime currentTime = System.DateTime.Now;
- + if (currentTime.CompareTo(lastLogTime.AddSeconds(intervalSeconds)) >= 0)
- + {
- + string timeStr = System.DateTime.Now.ToString();
- + LogVisitor logVisitor = new LogVisitor(timeStr);
- + computer.Accept(logVisitor);
- + logVisitor.AppendToFile("sensor.tsv");
- + lastLogTime = currentTime;
- + }
- + }
- + }
- + catch (Exception)
- + {
- + //ignore
- + }
- }
- private void SaveConfiguration() {
- @@ -494,6 +516,26 @@
- };
- }
- }
- +
- + if (control.ReferenceSensor != null)
- + {
- + MenuItem autoItem = new MenuItem("Auto");
- + controlItem.MenuItems.Add(autoItem);
- + autoItem.Checked = control.ControlMode == ControlMode.Auto;
- + for (int i = 35; i <= 60; i += 1)
- + {
- + MenuItem item = new MenuItem(i + " degrees");
- + autoItem.MenuItems.Add(item);
- + item.Checked = control.ControlMode == ControlMode.Auto &&
- + Math.Round(control.ReferenceValue) == i;
- + int refValue = i;
- + item.Click += delegate(object obj, EventArgs args)
- + {
- + control.SetAuto(refValue);
- + };
- + }
- + }
- +
- treeContextMenu.MenuItems.Add(controlItem);
- }
- Index: GUI/LogVisitor.cs
- ===================================================================
- --- GUI/LogVisitor.cs (revision 0)
- +++ GUI/LogVisitor.cs (revision 0)
- @@ -0,0 +1,46 @@
- +using System;
- +using System.Collections.Generic;
- +using OpenHardwareMonitor.Hardware;
- +
- +namespace OpenHardwareMonitor.GUI
- +{
- + public class LogVisitor : IVisitor
- + {
- + private System.Text.StringBuilder buffer;
- + private string timeString;
- + private string parentName;
- +
- + public LogVisitor(string timeStr)
- + {
- + buffer = new System.Text.StringBuilder();
- + timeString = timeStr;
- + }
- +
- + public void AppendToFile(string filename)
- + {
- + System.IO.File.AppendAllText(filename, buffer.ToString());
- + }
- +
- + public void VisitComputer(IComputer computer)
- + {
- + computer.Traverse(this);
- + }
- +
- + public void VisitHardware(IHardware hardware)
- + {
- + foreach (IHardware subHardware in hardware.SubHardware)
- + subHardware.Accept(this);
- +
- + parentName = hardware.Name;
- + foreach (ISensor sensor in hardware.Sensors)
- + sensor.Accept(this);
- + }
- +
- + public void VisitSensor(ISensor sensor)
- + {
- + buffer.Append(timeString + "\t" + parentName + "\t" + sensor.Name + "\t" + sensor.SensorType + "\t" + sensor.Value + "\n");
- + }
- +
- + public void VisitParameter(IParameter parameter) { }
- + }
- +}
- Index: GUI/UpdateVisitor.cs
- ===================================================================
- --- GUI/UpdateVisitor.cs (revision 314)
- +++ GUI/UpdateVisitor.cs (working copy)
- @@ -49,9 +49,27 @@
- hardware.Update();
- foreach (IHardware subHardware in hardware.SubHardware)
- subHardware.Accept(this);
- +
- + foreach (ISensor sensor in hardware.Sensors)
- + sensor.Accept(this);
- }
- - public void VisitSensor(ISensor sensor) { }
- + public void VisitSensor(ISensor sensor)
- + {
- + if (sensor.Control != null && sensor.Control.ControlMode == ControlMode.Auto && sensor.Control.ReferenceSensor.Value.HasValue)
- + {
- + float currentVal = sensor.Control.ReferenceSensor.Value.Value;
- + if (currentVal > sensor.Control.ReferenceValue && sensor.Control.SoftwareValue < sensor.Control.MaxSoftwareValue)
- + {
- + sensor.Control.SetSoftware(sensor.Control.SoftwareValue + 1);
- + }
- + else if (currentVal < sensor.Control.ReferenceValue && sensor.Control.SoftwareValue > sensor.Control.MinSoftwareValue)
- + {
- + sensor.Control.SetSoftware(sensor.Control.SoftwareValue - 1);
- + }
- + sensor.Control.SetAuto(sensor.Control.ReferenceValue);
- + }
- + }
- public void VisitParameter(IParameter parameter) { }
- }
- Index: OpenHardwareMonitor.csproj
- ===================================================================
- --- OpenHardwareMonitor.csproj (revision 314)
- +++ OpenHardwareMonitor.csproj (working copy)
- @@ -72,6 +72,7 @@
- <Compile Include="GUI\GadgetWindow.cs" />
- <Compile Include="GUI\Gadget.cs" />
- <Compile Include="GUI\HardwareTypeImage.cs" />
- + <Compile Include="GUI\LogVisitor.cs" />
- <Compile Include="GUI\PlotPanel.cs">
- <SubType>UserControl</SubType>
- </Compile>
- Index: Hardware/ATI/ATIGPU.cs
- ===================================================================
- --- Hardware/ATI/ATIGPU.cs (revision 314)
- +++ Hardware/ATI/ATIGPU.cs (working copy)
- @@ -82,7 +82,7 @@
- }
- this.fanControl = new Control(controlSensor, settings, afsi.MinPercent,
- - afsi.MaxPercent);
- + afsi.MaxPercent, this.temperature);
- this.fanControl.ControlModeChanged += ControlModeChanged;
- this.fanControl.SoftwareControlValueChanged +=
- SoftwareControlValueChanged;
- Index: Hardware/Control.cs
- ===================================================================
- --- Hardware/Control.cs (revision 314)
- +++ Hardware/Control.cs (working copy)
- @@ -50,14 +50,17 @@
- private float softwareValue;
- private float minSoftwareValue;
- private float maxSoftwareValue;
- + private ISensor referenceSensor;
- + private float referenceValue;
- public Control(ISensor sensor, ISettings settings, float minSoftwareValue,
- - float maxSoftwareValue)
- + float maxSoftwareValue, Sensor referenceSensor)
- {
- this.identifier = new Identifier(sensor.Identifier, "control");
- this.settings = settings;
- this.minSoftwareValue = minSoftwareValue;
- this.maxSoftwareValue = maxSoftwareValue;
- + this.referenceSensor = referenceSensor;
- if (!float.TryParse(settings.GetValue(
- new Identifier(identifier, "value").ToString(), "0"),
- @@ -100,6 +103,18 @@
- }
- }
- + public ISensor ReferenceSensor
- + {
- + get
- + {
- + return referenceSensor;
- + }
- + private set
- + {
- + referenceSensor = value;
- + }
- + }
- +
- public float SoftwareValue {
- get {
- return softwareValue;
- @@ -116,6 +131,18 @@
- }
- }
- + public float ReferenceValue
- + {
- + get
- + {
- + return referenceValue;
- + }
- + private set
- + {
- + referenceValue = value;
- + }
- + }
- +
- public void SetDefault() {
- ControlMode = ControlMode.Default;
- }
- @@ -137,6 +164,12 @@
- SoftwareValue = value;
- }
- + public void SetAuto(float value)
- + {
- + ControlMode = ControlMode.Auto;
- + ReferenceValue = value;
- + }
- +
- internal event ControlEventHandler ControlModeChanged;
- internal event ControlEventHandler SoftwareControlValueChanged;
- }
- Index: Hardware/IControl.cs
- ===================================================================
- --- Hardware/IControl.cs (revision 314)
- +++ Hardware/IControl.cs (working copy)
- @@ -39,7 +39,8 @@
- public enum ControlMode {
- Default,
- - Software
- + Software,
- + Auto
- }
- public interface IControl {
- @@ -48,7 +49,10 @@
- ControlMode ControlMode { get; }
- + ISensor ReferenceSensor { get; }
- +
- float SoftwareValue { get; }
- + float ReferenceValue { get; }
- void SetDefault();
- @@ -56,6 +60,7 @@
- float MaxSoftwareValue { get; }
- void SetSoftware(float value);
- + void SetAuto(float value);
- }
- }
Add Comment
Please, Sign In to add comment