Fixed Issue 199.

This commit is contained in:
Michael Möller
2011-04-30 16:03:58 +00:00
parent ca3a2d3864
commit 6e86c9e1a9
14 changed files with 161 additions and 207 deletions

View File

@@ -16,7 +16,7 @@
The Initial Developer of the Original Code is
Michael Möller <m.moeller@gmx.ch>.
Portions created by the Initial Developer are Copyright (C) 2009-2010
Portions created by the Initial Developer are Copyright (C) 2009-2011
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -50,7 +50,7 @@ namespace OpenHardwareMonitor.GUI {
private List<TypeNode> typeNodes = new List<TypeNode>();
public HardwareNode(IHardware hardware, PersistentSettings settings,
UnitManager unitManager) : base(hardware.Name)
UnitManager unitManager) : base()
{
this.settings = settings;
this.unitManager = unitManager;
@@ -73,6 +73,11 @@ namespace OpenHardwareMonitor.GUI {
hardware.SensorRemoved += new SensorEventHandler(SensorRemoved);
}
public override string Text {
get { return hardware.Name; }
set { hardware.Name = value; }
}
public IHardware Hardware {
get { return hardware; }
}

View File

@@ -102,7 +102,7 @@ namespace OpenHardwareMonitor.GUI {
this.hddMenuItem = new System.Windows.Forms.MenuItem();
this.helpMenuItem = new System.Windows.Forms.MenuItem();
this.aboutMenuItem = new System.Windows.Forms.MenuItem();
this.sensorContextMenu = new System.Windows.Forms.ContextMenu();
this.treeContextMenu = new System.Windows.Forms.ContextMenu();
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.timer = new System.Windows.Forms.Timer(this.components);
this.splitContainer = new OpenHardwareMonitor.GUI.SplitContainerAdv();
@@ -517,7 +517,7 @@ namespace OpenHardwareMonitor.GUI {
private System.Windows.Forms.MenuItem hddMenuItem;
private System.Windows.Forms.MenuItem minTrayMenuItem;
private System.Windows.Forms.MenuItem separatorMenuItem;
private System.Windows.Forms.ContextMenu sensorContextMenu;
private System.Windows.Forms.ContextMenu treeContextMenu;
private System.Windows.Forms.MenuItem startMinMenuItem;
private System.Windows.Forms.MenuItem startupMenuItem;
private System.Windows.Forms.SaveFileDialog saveFileDialog;

View File

@@ -16,7 +16,7 @@
The Initial Developer of the Original Code is
Michael Möller <m.moeller@gmx.ch>.
Portions created by the Initial Developer are Copyright (C) 2009-2010
Portions created by the Initial Developer are Copyright (C) 2009-2011
the Initial Developer. All Rights Reserved.
Contributor(s): Paul Werelds
@@ -317,7 +317,8 @@ namespace OpenHardwareMonitor.GUI {
CancelEventArgs e)
{
e.Cancel = !(treeView.CurrentNode != null &&
treeView.CurrentNode.Tag is SensorNode);
(treeView.CurrentNode.Tag is SensorNode ||
treeView.CurrentNode.Tag is HardwareNode));
}
private void nodeCheckBox_IsVisibleValueNeeded(object sender,
@@ -403,7 +404,7 @@ namespace OpenHardwareMonitor.GUI {
}
private void treeView_Click(object sender, EventArgs e) {
MouseEventArgs m = e as MouseEventArgs;
if (m == null || m.Button != MouseButtons.Right)
return;
@@ -415,35 +416,35 @@ namespace OpenHardwareMonitor.GUI {
if (info.Node != null) {
SensorNode node = info.Node.Tag as SensorNode;
if (node != null && node.Sensor != null) {
sensorContextMenu.MenuItems.Clear();
treeContextMenu.MenuItems.Clear();
if (node.Sensor.Parameters.Length > 0) {
MenuItem item = new MenuItem("Parameters...");
item.Click += delegate(object obj, EventArgs args) {
ShowParameterForm(node.Sensor);
};
sensorContextMenu.MenuItems.Add(item);
treeContextMenu.MenuItems.Add(item);
}
if (nodeTextBoxText.EditEnabled) {
MenuItem item = new MenuItem("Rename");
item.Click += delegate(object obj, EventArgs args) {
nodeTextBoxText.BeginEdit();
};
sensorContextMenu.MenuItems.Add(item);
treeContextMenu.MenuItems.Add(item);
}
if (node.IsVisible) {
MenuItem item = new MenuItem("Hide");
item.Click += delegate(object obj, EventArgs args) {
node.IsVisible = false;
};
sensorContextMenu.MenuItems.Add(item);
treeContextMenu.MenuItems.Add(item);
} else {
MenuItem item = new MenuItem("Unhide");
item.Click += delegate(object obj, EventArgs args) {
node.IsVisible = true;
};
sensorContextMenu.MenuItems.Add(item);
treeContextMenu.MenuItems.Add(item);
}
sensorContextMenu.MenuItems.Add(new MenuItem("-"));
treeContextMenu.MenuItems.Add(new MenuItem("-"));
{
MenuItem item = new MenuItem("Show in Tray");
item.Checked = systemTray.Contains(node.Sensor);
@@ -453,7 +454,7 @@ namespace OpenHardwareMonitor.GUI {
else
systemTray.Add(node.Sensor, true);
};
sensorContextMenu.MenuItems.Add(item);
treeContextMenu.MenuItems.Add(item);
}
if (gadget != null) {
MenuItem item = new MenuItem("Show in Gadget");
@@ -465,10 +466,10 @@ namespace OpenHardwareMonitor.GUI {
gadget.Add(node.Sensor);
}
};
sensorContextMenu.MenuItems.Add(item);
treeContextMenu.MenuItems.Add(item);
}
if (node.Sensor.Control != null) {
sensorContextMenu.MenuItems.Add(new MenuItem("-"));
treeContextMenu.MenuItems.Add(new MenuItem("-"));
IControl control = node.Sensor.Control;
MenuItem controlItem = new MenuItem("Control");
MenuItem defaultItem = new MenuItem("Default");
@@ -477,13 +478,12 @@ namespace OpenHardwareMonitor.GUI {
defaultItem.Click += delegate(object obj, EventArgs args) {
control.SetDefault();
};
MenuItem manualItem = new MenuItem("Manual");
MenuItem manualItem = new MenuItem("Manual");
controlItem.MenuItems.Add(manualItem);
manualItem.Checked = control.ControlMode == ControlMode.Software;
for (int i = 0; i <= 100; i += 5) {
if (i <= control.MaxSoftwareValue &&
i >= control.MinSoftwareValue)
{
i >= control.MinSoftwareValue) {
MenuItem item = new MenuItem(i + " %");
manualItem.MenuItems.Add(item);
item.Checked = control.ControlMode == ControlMode.Software &&
@@ -494,10 +494,25 @@ namespace OpenHardwareMonitor.GUI {
};
}
}
sensorContextMenu.MenuItems.Add(controlItem);
treeContextMenu.MenuItems.Add(controlItem);
}
sensorContextMenu.Show(treeView, new Point(m.X, m.Y));
treeContextMenu.Show(treeView, new Point(m.X, m.Y));
}
HardwareNode hardwareNode = info.Node.Tag as HardwareNode;
if (hardwareNode != null && hardwareNode.Hardware != null) {
treeContextMenu.MenuItems.Clear();
if (nodeTextBoxText.EditEnabled) {
MenuItem item = new MenuItem("Rename");
item.Click += delegate(object obj, EventArgs args) {
nodeTextBoxText.BeginEdit();
};
treeContextMenu.MenuItems.Add(item);
}
treeContextMenu.Show(treeView, new Point(m.X, m.Y));
}
}
}

View File

@@ -16,7 +16,7 @@
The Initial Developer of the Original Code is
Michael Möller <m.moeller@gmx.ch>.
Portions created by the Initial Developer are Copyright (C) 2009-2010
Portions created by the Initial Developer are Copyright (C) 2009-2011
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -41,7 +41,6 @@ using System.Globalization;
namespace OpenHardwareMonitor.Hardware.ATI {
internal sealed class ATIGPU : Hardware {
private readonly string name;
private readonly int adapterIndex;
private readonly int busNumber;
private readonly int deviceNumber;
@@ -59,8 +58,9 @@ namespace OpenHardwareMonitor.Hardware.ATI {
public ATIGPU(string name, int adapterIndex, int busNumber,
int deviceNumber, ISettings settings)
: base(name, new Identifier("atigpu",
adapterIndex.ToString(CultureInfo.InvariantCulture)), settings)
{
this.name = name;
this.adapterIndex = adapterIndex;
this.busNumber = busNumber;
this.deviceNumber = deviceNumber;
@@ -133,16 +133,6 @@ namespace OpenHardwareMonitor.Hardware.ATI {
public int DeviceNumber { get { return deviceNumber; } }
public override string Name {
get { return name; }
}
public override Identifier Identifier {
get {
return new Identifier("atigpu",
adapterIndex.ToString(CultureInfo.InvariantCulture));
}
}
public override HardwareType HardwareType {
get { return HardwareType.GpuAti; }

View File

@@ -54,7 +54,6 @@ namespace OpenHardwareMonitor.Hardware.CPU {
protected readonly int processorIndex;
protected readonly int coreCount;
protected readonly string name;
private readonly bool hasModelSpecificRegisters;
@@ -79,7 +78,10 @@ namespace OpenHardwareMonitor.Hardware.CPU {
return "CPU Core #" + (i + 1);
}
public GenericCPU(int processorIndex, CPUID[][] cpuid, ISettings settings) {
public GenericCPU(int processorIndex, CPUID[][] cpuid, ISettings settings)
: base(cpuid[0][0].Name, CreateIdentifier(cpuid[0][0].Vendor,
processorIndex), settings)
{
this.cpuid = cpuid;
this.vendor = cpuid[0][0].Vendor;
@@ -89,8 +91,7 @@ namespace OpenHardwareMonitor.Hardware.CPU {
this.stepping = cpuid[0][0].Stepping;
this.processorIndex = processorIndex;
this.coreCount = cpuid.Length;
this.name = cpuid[0][0].Name;
this.coreCount = cpuid.Length;
// check if processor has MSRs
if (cpuid[0][0].Data.GetLength(0) > 1
@@ -143,6 +144,19 @@ namespace OpenHardwareMonitor.Hardware.CPU {
timeStampCounterFrequency = estimatedTimeStampCounterFrequency;
}
private static Identifier CreateIdentifier(Vendor vendor,
int processorIndex)
{
string s;
switch (vendor) {
case Vendor.AMD: s = "amdcpu"; break;
case Vendor.Intel: s = "intelcpu"; break;
default: s = "genericcpu"; break;
}
return new Identifier(s,
processorIndex.ToString(CultureInfo.InvariantCulture));
}
private static double EstimateTimeStampCounterFrequency() {
// preload the function
EstimateTimeStampCounterFrequency(0);
@@ -230,23 +244,6 @@ namespace OpenHardwareMonitor.Hardware.CPU {
return r.ToString();
}
public override Identifier Identifier {
get {
string s;
switch (vendor) {
case Vendor.AMD: s = "amdcpu"; break;
case Vendor.Intel: s = "intelcpu"; break;
default: s = "genericcpu"; break;
}
return new Identifier(s,
processorIndex.ToString(CultureInfo.InvariantCulture));
}
}
public override string Name {
get { return name; }
}
public override HardwareType HardwareType {
get { return HardwareType.CPU; }
}

View File

@@ -40,11 +40,10 @@ using System.Collections.Generic;
using System.Globalization;
namespace OpenHardwareMonitor.Hardware.HDD {
internal class HDD : IHardware {
internal class HDD : Hardware {
private const int UPDATE_DIVIDER = 30; // update only every 30s
private readonly string name;
private readonly IntPtr handle;
private readonly int drive;
private int count;
@@ -57,9 +56,9 @@ namespace OpenHardwareMonitor.Hardware.HDD {
public HDD(string name, IntPtr handle, int drive,
SMART.AttributeID temperatureID, SMART.AttributeID lifeID,
ISettings settings)
ISettings settings) : base(name, new Identifier("hdd",
drive.ToString(CultureInfo.InvariantCulture)), settings)
{
this.name = name;
this.handle = handle;
this.drive = drive;
this.count = 0;
@@ -78,30 +77,11 @@ namespace OpenHardwareMonitor.Hardware.HDD {
Update();
}
public string Name {
get { return name; }
}
public Identifier Identifier {
get {
return new Identifier("hdd",
drive.ToString(CultureInfo.InvariantCulture));
}
}
public HardwareType HardwareType {
public override HardwareType HardwareType {
get { return HardwareType.HDD; }
}
public IHardware[] SubHardware {
get { return new IHardware[0]; }
}
public virtual IHardware Parent {
get { return null; }
}
public ISensor[] Sensors {
public override ISensor[] Sensors {
get {
if (lifeID != SMART.AttributeID.None)
return new ISensor[] { lifeSensor };
@@ -113,11 +93,7 @@ namespace OpenHardwareMonitor.Hardware.HDD {
}
}
public string GetReport() {
return null;
}
public void Update() {
public override void Update() {
if (count == 0) {
SMART.DriveAttribute[] attributes = SMART.ReadSmart(handle, drive);
@@ -151,18 +127,7 @@ namespace OpenHardwareMonitor.Hardware.HDD {
SMART.CloseHandle(handle);
}
#pragma warning disable 67
public event SensorEventHandler SensorAdded;
public event SensorEventHandler SensorRemoved;
#pragma warning restore 67
public void Accept(IVisitor visitor) {
if (visitor == null)
throw new ArgumentNullException("visitor");
visitor.VisitHardware(this);
}
public void Traverse(IVisitor visitor) {
public override void Traverse(IVisitor visitor) {
foreach (ISensor sensor in Sensors)
sensor.Accept(visitor);
}

View File

@@ -16,7 +16,7 @@
The Initial Developer of the Original Code is
Michael Möller <m.moeller@gmx.ch>.
Portions created by the Initial Developer are Copyright (C) 2009-2010
Portions created by the Initial Developer are Copyright (C) 2009-2011
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -41,7 +41,19 @@ using OpenHardwareMonitor.Collections;
namespace OpenHardwareMonitor.Hardware {
internal abstract class Hardware : IHardware {
private readonly ListSet<ISensor> active = new ListSet<ISensor>();
private readonly Identifier identifier;
protected readonly string name;
private string customName;
protected readonly ISettings settings;
protected readonly ListSet<ISensor> active = new ListSet<ISensor>();
public Hardware(string name, Identifier identifier, ISettings settings) {
this.settings = settings;
this.identifier = identifier;
this.name = name;
this.customName = settings.GetValue(
new Identifier(Identifier, "name").ToString(), name);
}
public IHardware[] SubHardware {
get { return new IHardware[0]; }
@@ -51,29 +63,48 @@ namespace OpenHardwareMonitor.Hardware {
get { return null; }
}
public ISensor[] Sensors {
public virtual ISensor[] Sensors {
get { return active.ToArray(); }
}
protected void ActivateSensor(ISensor sensor) {
protected virtual void ActivateSensor(ISensor sensor) {
if (active.Add(sensor))
if (SensorAdded != null)
SensorAdded(sensor);
}
protected void DeactivateSensor(ISensor sensor) {
protected virtual void DeactivateSensor(ISensor sensor) {
if (active.Remove(sensor))
if (SensorRemoved != null)
SensorRemoved(sensor);
}
public string Name {
get {
return customName;
}
set {
if (!string.IsNullOrEmpty(value))
customName = value;
else
customName = name;
settings.SetValue(new Identifier(Identifier, "name").ToString(),
customName);
}
}
public Identifier Identifier {
get {
return identifier;
}
}
#pragma warning disable 67
public event SensorEventHandler SensorAdded;
public event SensorEventHandler SensorRemoved;
#pragma warning restore 67
public abstract string Name { get; }
public abstract Identifier Identifier { get; }
public abstract HardwareType HardwareType { get; }
public virtual string GetReport() {
@@ -88,7 +119,7 @@ namespace OpenHardwareMonitor.Hardware {
visitor.VisitHardware(this);
}
public void Traverse(IVisitor visitor) {
public virtual void Traverse(IVisitor visitor) {
foreach (ISensor sensor in active)
sensor.Accept(visitor);
}

View File

@@ -134,8 +134,10 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
return WriteField(device, field, '"' + value + '"');
}
public Heatmaster(string portName, ISettings settings) {
public Heatmaster(string portName, ISettings settings)
: base("Heatmaster", new Identifier("heatmaster",
portName.TrimStart(new [] {'/'}).ToLowerInvariant()), settings)
{
this.portName = portName;
try {
serialPort = new SerialPort(portName, 38400, Parity.None, 8,
@@ -209,17 +211,6 @@ namespace OpenHardwareMonitor.Hardware.Heatmaster {
get { return HardwareType.Heatmaster; }
}
public override Identifier Identifier {
get {
return new Identifier("heatmaster",
serialPort.PortName.TrimStart(new [] {'/'}).ToLowerInvariant());
}
}
public override string Name {
get { return "Heatmaster"; }
}
private void ProcessUpdateLine(string line) {
Match match = Regex.Match(line, @">\[0:(\d+)\]([0-9:\|-]+)");
if (match.Success) {

View File

@@ -16,7 +16,7 @@
The Initial Developer of the Original Code is
Michael Möller <m.moeller@gmx.ch>.
Portions created by the Initial Developer are Copyright (C) 2009-2010
Portions created by the Initial Developer are Copyright (C) 2009-2011
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -52,7 +52,7 @@ namespace OpenHardwareMonitor.Hardware {
public interface IHardware : IElement {
string Name { get; }
string Name { get; set; }
Identifier Identifier { get; }
HardwareType HardwareType { get; }

View File

@@ -16,7 +16,7 @@
The Initial Developer of the Original Code is
Michael Möller <m.moeller@gmx.ch>.
Portions created by the Initial Developer are Copyright (C) 2009-2010
Portions created by the Initial Developer are Copyright (C) 2009-2011
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -43,12 +43,14 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
internal class Mainboard : IHardware {
private readonly SMBIOS smbios;
private readonly string name;
private string customName;
private readonly ISettings settings;
private readonly LPCIO lpcio;
private readonly LMSensors lmSensors;
private readonly IHardware[] superIOHardware;
public Mainboard(ISettings settings) {
this.settings = settings;
this.smbios = new SMBIOS();
if (smbios.Board != null) {
@@ -65,6 +67,9 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
this.name = Manufacturer.Unknown.ToString();
}
this.customName = settings.GetValue(
new Identifier(Identifier, "name").ToString(), name);
ISuperIO[] superIO;
int p = (int)Environment.OSVersion.Platform;
if ((p == 4) || (p == 128)) {
@@ -84,7 +89,17 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
}
public string Name {
get { return name; }
get {
return customName;
}
set {
if (!string.IsNullOrEmpty(value))
customName = value;
else
customName = name;
settings.SetValue(new Identifier(Identifier, "name").ToString(),
customName);
}
}
public Identifier Identifier {

View File

@@ -46,7 +46,6 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
private readonly Mainboard mainboard;
private readonly ISuperIO superIO;
private readonly string name;
private readonly List<Sensor> voltages = new List<Sensor>();
private readonly List<Sensor> temperatures = new List<Sensor>();
@@ -68,10 +67,12 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
public SuperIOHardware(Mainboard mainboard, ISuperIO superIO,
Manufacturer manufacturer, Model model, ISettings settings)
: base(ChipName.GetName(superIO.Chip), new Identifier("lpc",
superIO.Chip.ToString().ToLower(CultureInfo.InvariantCulture)),
settings)
{
this.mainboard = mainboard;
this.superIO = superIO;
this.name = ChipName.GetName(superIO.Chip);
this.readVoltage = (index) => superIO.Voltages[index];
this.readTemperature = (index) => superIO.Temperatures[index];
@@ -843,13 +844,6 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
}
}
public override Identifier Identifier {
get {
return new Identifier("lpc",
superIO.Chip.ToString().ToLower(CultureInfo.InvariantCulture));
}
}
public override HardwareType HardwareType {
get { return HardwareType.SuperIO; }
}
@@ -858,9 +852,6 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
get { return mainboard; }
}
public override string Name {
get { return name; }
}
public override string GetReport() {
return superIO.GetReport();

View File

@@ -16,7 +16,7 @@
The Initial Developer of the Original Code is
Michael Möller <m.moeller@gmx.ch>.
Portions created by the Initial Developer are Copyright (C) 2009-2010
Portions created by the Initial Developer are Copyright (C) 2009-2011
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -42,7 +42,6 @@ using System.Text;
namespace OpenHardwareMonitor.Hardware.Nvidia {
internal class NvidiaGPU : Hardware {
private readonly string name;
private readonly int adapterIndex;
private readonly NvPhysicalGpuHandle handle;
private readonly NvDisplayHandle? displayHandle;
@@ -56,13 +55,9 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle,
NvDisplayHandle? displayHandle, ISettings settings)
: base(GetName(handle), new Identifier("nvidiagpu",
adapterIndex.ToString(CultureInfo.InvariantCulture)), settings)
{
string gpuName;
if (NVAPI.NvAPI_GPU_GetFullName(handle, out gpuName) == NvStatus.OK) {
this.name = "NVIDIA " + gpuName.Trim();
} else {
this.name = "NVIDIA";
}
this.adapterIndex = adapterIndex;
this.handle = handle;
this.displayHandle = displayHandle;
@@ -110,14 +105,12 @@ namespace OpenHardwareMonitor.Hardware.Nvidia {
control = new Sensor("GPU Fan", 0, SensorType.Control, this, settings);
}
public override string Name {
get { return name; }
}
public override Identifier Identifier {
get {
return new Identifier("nvidiagpu",
adapterIndex.ToString(CultureInfo.InvariantCulture));
private static string GetName(NvPhysicalGpuHandle handle) {
string gpuName;
if (NVAPI.NvAPI_GPU_GetFullName(handle, out gpuName) == NvStatus.OK) {
return "NVIDIA " + gpuName.Trim();
} else {
return "NVIDIA";
}
}

View File

@@ -16,7 +16,7 @@
The Initial Developer of the Original Code is
Michael Möller <m.moeller@gmx.ch>.
Portions created by the Initial Developer are Copyright (C) 2009-2010
Portions created by the Initial Developer are Copyright (C) 2009-2011
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -41,9 +41,8 @@ using System.Globalization;
using System.Text;
namespace OpenHardwareMonitor.Hardware.TBalancer {
internal class TBalancer : IHardware {
internal class TBalancer : Hardware {
private readonly ISettings settings;
private readonly int portIndex;
private readonly byte protocolVersion;
private readonly Sensor[] digitalTemperatures = new Sensor[8];
@@ -55,7 +54,6 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
private readonly Sensor[] miniNGTemperatures = new Sensor[4];
private readonly Sensor[] miniNGFans = new Sensor[4];
private readonly Sensor[] miniNGControls = new Sensor[4];
private readonly List<ISensor> active = new List<ISensor>();
private readonly List<ISensor> deactivating = new List<ISensor>();
private FT_HANDLE handle;
@@ -66,10 +64,12 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
public const byte ENDFLAG = 254;
private delegate void MethodDelegate();
private readonly MethodDelegate alternativeRequest;
private readonly MethodDelegate alternativeRequest;
public TBalancer(int portIndex, byte protocolVersion, ISettings settings) {
this.settings = settings;
public TBalancer(int portIndex, byte protocolVersion, ISettings settings)
: base("T-Balancer bigNG", new Identifier("bigng",
portIndex.ToString(CultureInfo.InvariantCulture)), settings)
{
this.portIndex = portIndex;
this.protocolVersion = protocolVersion;
@@ -123,21 +123,15 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
Update();
}
private void ActivateSensor(Sensor sensor) {
protected override void ActivateSensor(ISensor sensor) {
deactivating.Remove(sensor);
if (!active.Contains(sensor)) {
active.Add(sensor);
if (SensorAdded != null)
SensorAdded(sensor);
}
}
base.ActivateSensor(sensor);
}
private void DeactivateSensor(Sensor sensor) {
protected override void DeactivateSensor(ISensor sensor) {
if (deactivating.Contains(sensor)) {
active.Remove(sensor);
deactivating.Remove(sensor);
if (SensorRemoved != null)
SensorRemoved(sensor);
base.DeactivateSensor(sensor);
} else if (active.Contains(sensor)) {
deactivating.Add(sensor);
}
@@ -265,34 +259,11 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
}
}
public HardwareType HardwareType {
public override HardwareType HardwareType {
get { return HardwareType.TBalancer; }
}
public string Name {
get { return "T-Balancer bigNG"; }
}
public Identifier Identifier {
get {
return new Identifier("bigng",
this.portIndex.ToString(CultureInfo.InvariantCulture));
}
}
public IHardware[] SubHardware {
get { return new IHardware[0]; }
}
public virtual IHardware Parent {
get { return null; }
}
public ISensor[] Sensors {
get { return active.ToArray(); }
}
public string GetReport() {
public override string GetReport() {
StringBuilder r = new StringBuilder();
r.AppendLine("T-Balancer bigNG");
@@ -359,7 +330,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
FTD2XX.FT_Purge(handle, FT_PURGE.FT_PURGE_ALL);
}
public void Update() {
public override void Update() {
while (FTD2XX.BytesToRead(handle) >= 285)
ReadData();
if (FTD2XX.BytesToRead(handle) == 1)
@@ -373,15 +344,5 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
FTD2XX.FT_Close(handle);
}
public event SensorEventHandler SensorAdded;
public event SensorEventHandler SensorRemoved;
public void Accept(IVisitor visitor) {
if (visitor == null)
throw new ArgumentNullException("visitor");
visitor.VisitHardware(this);
}
public void Traverse(IVisitor visitor) { }
}
}

View File

@@ -37,5 +37,5 @@
using System.Reflection;
[assembly: AssemblyVersion("0.3.0.0")]
[assembly: AssemblyInformationalVersion("0.3.0 Beta")]
[assembly: AssemblyVersion("0.3.0.1")]
[assembly: AssemblyInformationalVersion("0.3.0.1 Alpha")]