1.1 --- a/Hardware/TBalancer/TBalancer.cs Sat Apr 23 14:18:02 2011 +0000
1.2 +++ b/Hardware/TBalancer/TBalancer.cs Sat Apr 30 16:03:58 2011 +0000
1.3 @@ -16,7 +16,7 @@
1.4
1.5 The Initial Developer of the Original Code is
1.6 Michael Möller <m.moeller@gmx.ch>.
1.7 - Portions created by the Initial Developer are Copyright (C) 2009-2010
1.8 + Portions created by the Initial Developer are Copyright (C) 2009-2011
1.9 the Initial Developer. All Rights Reserved.
1.10
1.11 Contributor(s):
1.12 @@ -41,9 +41,8 @@
1.13 using System.Text;
1.14
1.15 namespace OpenHardwareMonitor.Hardware.TBalancer {
1.16 - internal class TBalancer : IHardware {
1.17 + internal class TBalancer : Hardware {
1.18
1.19 - private readonly ISettings settings;
1.20 private readonly int portIndex;
1.21 private readonly byte protocolVersion;
1.22 private readonly Sensor[] digitalTemperatures = new Sensor[8];
1.23 @@ -55,7 +54,6 @@
1.24 private readonly Sensor[] miniNGTemperatures = new Sensor[4];
1.25 private readonly Sensor[] miniNGFans = new Sensor[4];
1.26 private readonly Sensor[] miniNGControls = new Sensor[4];
1.27 - private readonly List<ISensor> active = new List<ISensor>();
1.28 private readonly List<ISensor> deactivating = new List<ISensor>();
1.29
1.30 private FT_HANDLE handle;
1.31 @@ -66,10 +64,12 @@
1.32 public const byte ENDFLAG = 254;
1.33
1.34 private delegate void MethodDelegate();
1.35 - private readonly MethodDelegate alternativeRequest;
1.36 + private readonly MethodDelegate alternativeRequest;
1.37
1.38 - public TBalancer(int portIndex, byte protocolVersion, ISettings settings) {
1.39 - this.settings = settings;
1.40 + public TBalancer(int portIndex, byte protocolVersion, ISettings settings)
1.41 + : base("T-Balancer bigNG", new Identifier("bigng",
1.42 + portIndex.ToString(CultureInfo.InvariantCulture)), settings)
1.43 + {
1.44
1.45 this.portIndex = portIndex;
1.46 this.protocolVersion = protocolVersion;
1.47 @@ -123,21 +123,15 @@
1.48 Update();
1.49 }
1.50
1.51 - private void ActivateSensor(Sensor sensor) {
1.52 + protected override void ActivateSensor(ISensor sensor) {
1.53 deactivating.Remove(sensor);
1.54 - if (!active.Contains(sensor)) {
1.55 - active.Add(sensor);
1.56 - if (SensorAdded != null)
1.57 - SensorAdded(sensor);
1.58 - }
1.59 - }
1.60 + base.ActivateSensor(sensor);
1.61 + }
1.62
1.63 - private void DeactivateSensor(Sensor sensor) {
1.64 + protected override void DeactivateSensor(ISensor sensor) {
1.65 if (deactivating.Contains(sensor)) {
1.66 - active.Remove(sensor);
1.67 deactivating.Remove(sensor);
1.68 - if (SensorRemoved != null)
1.69 - SensorRemoved(sensor);
1.70 + base.DeactivateSensor(sensor);
1.71 } else if (active.Contains(sensor)) {
1.72 deactivating.Add(sensor);
1.73 }
1.74 @@ -265,34 +259,11 @@
1.75 }
1.76 }
1.77
1.78 - public HardwareType HardwareType {
1.79 + public override HardwareType HardwareType {
1.80 get { return HardwareType.TBalancer; }
1.81 }
1.82
1.83 - public string Name {
1.84 - get { return "T-Balancer bigNG"; }
1.85 - }
1.86 -
1.87 - public Identifier Identifier {
1.88 - get {
1.89 - return new Identifier("bigng",
1.90 - this.portIndex.ToString(CultureInfo.InvariantCulture));
1.91 - }
1.92 - }
1.93 -
1.94 - public IHardware[] SubHardware {
1.95 - get { return new IHardware[0]; }
1.96 - }
1.97 -
1.98 - public virtual IHardware Parent {
1.99 - get { return null; }
1.100 - }
1.101 -
1.102 - public ISensor[] Sensors {
1.103 - get { return active.ToArray(); }
1.104 - }
1.105 -
1.106 - public string GetReport() {
1.107 + public override string GetReport() {
1.108 StringBuilder r = new StringBuilder();
1.109
1.110 r.AppendLine("T-Balancer bigNG");
1.111 @@ -359,7 +330,7 @@
1.112 FTD2XX.FT_Purge(handle, FT_PURGE.FT_PURGE_ALL);
1.113 }
1.114
1.115 - public void Update() {
1.116 + public override void Update() {
1.117 while (FTD2XX.BytesToRead(handle) >= 285)
1.118 ReadData();
1.119 if (FTD2XX.BytesToRead(handle) == 1)
1.120 @@ -373,15 +344,5 @@
1.121 FTD2XX.FT_Close(handle);
1.122 }
1.123
1.124 - public event SensorEventHandler SensorAdded;
1.125 - public event SensorEventHandler SensorRemoved;
1.126 -
1.127 - public void Accept(IVisitor visitor) {
1.128 - if (visitor == null)
1.129 - throw new ArgumentNullException("visitor");
1.130 - visitor.VisitHardware(this);
1.131 - }
1.132 -
1.133 - public void Traverse(IVisitor visitor) { }
1.134 }
1.135 }