mirror of
https://github.com/hirschmann/nbfc
synced 2025-09-03 15:45:22 +00:00
[chg] Updated OpenHardwareMonitorLib (fork).
[fix] Changed TargetFrameworkVersion of new projects from 4.5 to 4.0 CP. [new] Moved EmbeddedController.cs from OpenHardwareMonitorLib to new StagWare.Hardware library. [chg] Refactored and improved EmbeddedController.cs. [chg] Improved FanControl.Dispose(). [fix] Plugins are now compatible to updated OpenHardwareMonitorLib.
This commit is contained in:
Submodule Libraries/Plugins/OpenHardwareMonitorLib updated: 79451883f1...42d37cfe75
218
Libraries/Plugins/StagWare.Hardware.EC/EmbeddedController.cs
Normal file
218
Libraries/Plugins/StagWare.Hardware.EC/EmbeddedController.cs
Normal file
@@ -0,0 +1,218 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace StagWare.Hardware
|
||||
{
|
||||
public class EmbeddedController
|
||||
{
|
||||
#region Enums
|
||||
|
||||
// See ACPI specs ch.12.2
|
||||
[Flags]
|
||||
enum ECStatus : byte
|
||||
{
|
||||
OutputBufferFull = 0x01, // EC_OBF
|
||||
InputBufferFull = 0x02, // EC_IBF
|
||||
Command = 0x04, // CMD
|
||||
BurstMode = 0x08, // BURST
|
||||
SCIEventPending = 0x10, // SCI_EVT
|
||||
SMIEventPending = 0x20 // SMI_EVT
|
||||
}
|
||||
|
||||
// See ACPI specs ch.12.3
|
||||
enum ECCommand : byte
|
||||
{
|
||||
Read = 0x80, // RD_EC
|
||||
Write = 0x81, // WR_EC
|
||||
BurstEnable = 0x82, // BE_EC
|
||||
BurstDisable = 0x83, // BD_EC
|
||||
Query = 0x84 // QR_EC
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
|
||||
const int CommandPort = 0x66; //EC_SC
|
||||
const int DataPort = 0x62; //EC_DATA
|
||||
|
||||
const int RWTimeout = 500; // spins
|
||||
const int IsaBusTimeout = 100; // ms
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Fields
|
||||
|
||||
IPort port;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public EmbeddedController(IPort port)
|
||||
{
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public bool TryReadByte(byte register, out byte value)
|
||||
{
|
||||
if (WaitFree())
|
||||
{
|
||||
this.port.Write(CommandPort, (byte)ECCommand.Read);
|
||||
|
||||
if (WaitWrite())
|
||||
{
|
||||
this.port.Write(DataPort, register);
|
||||
|
||||
if (WaitWrite() && WaitRead())
|
||||
{
|
||||
value = this.port.Read(DataPort);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
value = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryWriteByte(byte register, byte value)
|
||||
{
|
||||
if (WaitFree())
|
||||
{
|
||||
this.port.Write(CommandPort, (byte)ECCommand.Write);
|
||||
|
||||
if (WaitWrite())
|
||||
{
|
||||
this.port.Write(DataPort, register);
|
||||
|
||||
if (WaitWrite())
|
||||
{
|
||||
this.port.Write(DataPort, value);
|
||||
|
||||
if (WaitWrite())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryReadWord(byte register, out int value)
|
||||
{
|
||||
//Byte order: little endian
|
||||
|
||||
byte result = 0;
|
||||
value = 0;
|
||||
|
||||
if (!TryReadByte(register, out result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
value = result;
|
||||
|
||||
if (!TryReadByte((byte)(register + 1), out result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
value |= (ushort)(result << 8);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TryWriteWord(byte register, int value)
|
||||
{
|
||||
//Byte order: little endian
|
||||
|
||||
ushort val = (ushort)value;
|
||||
|
||||
byte msb = (byte)(val >> 8);
|
||||
byte lsb = (byte)val;
|
||||
|
||||
if (!TryWriteByte(register, lsb))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TryWriteByte((byte)(register + 1), msb))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private bool WaitRead()
|
||||
{
|
||||
int timeout = RWTimeout;
|
||||
|
||||
while (timeout > 0)
|
||||
{
|
||||
var status = (ECStatus)this.port.Read(CommandPort);
|
||||
|
||||
if (status.HasFlag(ECStatus.OutputBufferFull))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
timeout--;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool WaitWrite()
|
||||
{
|
||||
int timeout = RWTimeout;
|
||||
|
||||
while (timeout > 0)
|
||||
{
|
||||
var status = (ECStatus)this.port.Read(CommandPort);
|
||||
|
||||
if (!status.HasFlag(ECStatus.InputBufferFull))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
timeout--;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool WaitFree()
|
||||
{
|
||||
int timeout = RWTimeout;
|
||||
|
||||
while (timeout > 0)
|
||||
{
|
||||
var status = (ECStatus)this.port.Read(CommandPort);
|
||||
|
||||
if (!status.HasFlag(ECStatus.InputBufferFull)
|
||||
&& !status.HasFlag(ECStatus.OutputBufferFull))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
timeout--;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
9
Libraries/Plugins/StagWare.Hardware.EC/IPort.cs
Normal file
9
Libraries/Plugins/StagWare.Hardware.EC/IPort.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
namespace StagWare.Hardware
|
||||
{
|
||||
public interface IPort
|
||||
{
|
||||
void Write(int port, byte value);
|
||||
byte Read(int port);
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("StagWare.Hardware.EC")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("StagWare.Hardware.EC")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a615a483-0e43-4097-88a1-47f4558d8ca4")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1D5D7C81-802F-46E0-913F-8519F157BC3C}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>StagWare.Hardware</RootNamespace>
|
||||
<AssemblyName>StagWare.Hardware</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="EmbeddedController.cs" />
|
||||
<Compile Include="IPort.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@@ -8,14 +8,33 @@ namespace StagWare.Windows.CpuTempProvider
|
||||
{
|
||||
public class CpuTemperatureProvider : ITemperatureProvider
|
||||
{
|
||||
private readonly IHardware cpu;
|
||||
private readonly ISensor[] cpuTempSensors;
|
||||
#region Private Fields
|
||||
|
||||
private Computer computer;
|
||||
private IHardware cpu;
|
||||
private ISensor[] cpuTempSensors;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public CpuTemperatureProvider()
|
||||
{
|
||||
var computer = new Computer();
|
||||
computer.CPUEnabled = true;
|
||||
computer.Open();
|
||||
this.computer = new Computer();
|
||||
this.computer.CPUEnabled = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITemperatureProvider implementation
|
||||
|
||||
public bool IsInitialized { get; private set; }
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (!this.IsInitialized)
|
||||
{
|
||||
this.computer.Open();
|
||||
this.cpu = computer.Hardware.FirstOrDefault(x => x.HardwareType == HardwareType.CPU);
|
||||
|
||||
if (this.cpu != null)
|
||||
@@ -24,11 +43,21 @@ namespace StagWare.Windows.CpuTempProvider
|
||||
}
|
||||
|
||||
if (this.cpuTempSensors == null || this.cpuTempSensors.Length <= 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
finally
|
||||
{
|
||||
throw new PlatformNotSupportedException("No CPU temperature sensor(s) found.");
|
||||
}
|
||||
}
|
||||
|
||||
this.IsInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public double GetTemperature()
|
||||
{
|
||||
double temperatureSum = 0;
|
||||
@@ -47,6 +76,21 @@ namespace StagWare.Windows.CpuTempProvider
|
||||
return temperatureSum / count;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (this.computer != null)
|
||||
{
|
||||
this.computer.Close();
|
||||
this.computer = null;
|
||||
}
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private static ISensor[] InitializeTempSensors(IHardware cpu)
|
||||
{
|
||||
if (cpu == null)
|
||||
@@ -69,5 +113,7 @@ namespace StagWare.Windows.CpuTempProvider
|
||||
? new ISensor[] { packageSensor }
|
||||
: sensors.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -9,8 +9,9 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>StagWare.Windows.CpuTempProvider</RootNamespace>
|
||||
<AssemblyName>StagWare.Windows.CpuTempProvider</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@@ -1,44 +1,67 @@
|
||||
using StagWare.FanControl.Plugins;
|
||||
using OpenHardwareMonitor.Hardware;
|
||||
using StagWare.FanControl.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using EC = OpenHardwareMonitor.Hardware.LPC.EmbeddedController;
|
||||
|
||||
namespace StagWare.Windows.EmbeddedController
|
||||
{
|
||||
public class EmbeddedController : IEmbeddedController
|
||||
{
|
||||
#region Constants
|
||||
|
||||
private const int MaxRetries = 10;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Fields
|
||||
|
||||
StagWare.Hardware.EmbeddedController ec;
|
||||
Computer computer;
|
||||
|
||||
#endregion
|
||||
|
||||
#region IEmbeddedController implementation
|
||||
|
||||
public bool IsInitialized { get; private set; }
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (!this.IsInitialized)
|
||||
{
|
||||
this.computer = new Computer();
|
||||
this.ec = new StagWare.Hardware.EmbeddedController(new Port(computer));
|
||||
this.computer.Open();
|
||||
this.IsInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteByte(byte register, byte value)
|
||||
{
|
||||
int tries = 0;
|
||||
int successfulTries = 0;
|
||||
int writes = 0;
|
||||
int successful = 0;
|
||||
|
||||
while ((successfulTries < 3) && (tries < MaxRetries))
|
||||
while ((successful < 3) && (writes < MaxRetries))
|
||||
{
|
||||
tries++;
|
||||
writes++;
|
||||
|
||||
if (EC.TryWriteByte(register, value))
|
||||
if (this.ec.TryWriteByte(register, value))
|
||||
{
|
||||
successfulTries++;
|
||||
successful++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteWord(byte register, ushort value)
|
||||
{
|
||||
int tries = 0;
|
||||
int successfulTries = 0;
|
||||
int writes = 0;
|
||||
int successful = 0;
|
||||
|
||||
while ((successfulTries < 3) && (tries < MaxRetries))
|
||||
while ((successful < 3) && (writes < MaxRetries))
|
||||
{
|
||||
tries++;
|
||||
writes++;
|
||||
|
||||
if (EC.TryWriteWord(register, value))
|
||||
if (this.ec.TryWriteWord(register, value))
|
||||
{
|
||||
successfulTries++;
|
||||
successful++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,13 +69,13 @@ namespace StagWare.Windows.EmbeddedController
|
||||
public byte ReadByte(byte register)
|
||||
{
|
||||
byte result = 0;
|
||||
int tries = 0;
|
||||
int reads = 0;
|
||||
bool success = false;
|
||||
|
||||
while (!success && (tries < MaxRetries))
|
||||
while (!success && (reads < MaxRetries))
|
||||
{
|
||||
tries++;
|
||||
success = EC.TryReadByte(register, out result);
|
||||
reads++;
|
||||
success = this.ec.TryReadByte(register, out result);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -61,13 +84,13 @@ namespace StagWare.Windows.EmbeddedController
|
||||
public ushort ReadWord(byte register)
|
||||
{
|
||||
int result = 0;
|
||||
int tries = 0;
|
||||
int reads = 0;
|
||||
bool success = false;
|
||||
|
||||
while (!success && (tries < MaxRetries))
|
||||
while (!success && (reads < MaxRetries))
|
||||
{
|
||||
tries++;
|
||||
success = EC.TryReadWord(register, out result);
|
||||
reads++;
|
||||
success = this.ec.TryReadWord(register, out result);
|
||||
}
|
||||
|
||||
return (ushort)result;
|
||||
@@ -75,12 +98,25 @@ namespace StagWare.Windows.EmbeddedController
|
||||
|
||||
public bool AquireLock(int timeout)
|
||||
{
|
||||
return EC.WaitIsaBusMutex(timeout);
|
||||
return this.computer.WaitIsaBusMutex(timeout);
|
||||
}
|
||||
|
||||
public void ReleaseLock()
|
||||
{
|
||||
EC.ReleaseIsaBusMutex();
|
||||
}
|
||||
this.computer.ReleaseIsaBusMutex();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (this.computer != null)
|
||||
{
|
||||
this.computer.Close();
|
||||
this.computer = null;
|
||||
}
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,42 @@
|
||||
using OpenHardwareMonitor.Hardware;
|
||||
using StagWare.Hardware;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StagWare.Windows.EmbeddedController
|
||||
{
|
||||
internal class Port : IPort
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
Computer computer;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public Port(Computer computer)
|
||||
{
|
||||
this.computer = computer;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IPort implementation
|
||||
|
||||
public void Write(int port, byte value)
|
||||
{
|
||||
this.computer.WriteIoPort((int)port, value);
|
||||
}
|
||||
|
||||
public byte Read(int port)
|
||||
{
|
||||
return this.computer.ReadIoPort((int)port);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -7,10 +7,11 @@
|
||||
<ProjectGuid>{49BBEBDD-9A3A-4963-A52C-D6154E2D6B3E}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>StagWare.Windows.EC</RootNamespace>
|
||||
<AssemblyName>StagWare.Windows.EC</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<RootNamespace>StagWare.Windows.EmbeddedController</RootNamespace>
|
||||
<AssemblyName>StagWare.Windows.EmbeddedController</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -40,6 +41,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="EmbeddedController.cs" />
|
||||
<Compile Include="Port.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -51,6 +53,10 @@
|
||||
<Project>{b0397530-545a-471d-bb74-027ae456df1a}</Project>
|
||||
<Name>OpenHardwareMonitorLib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\StagWare.Hardware.EC\StagWare.Hardware.csproj">
|
||||
<Project>{1d5d7c81-802f-46e0-913f-8519f157bc3c}</Project>
|
||||
<Name>StagWare.Hardware</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@@ -171,6 +171,16 @@ namespace StagWare.FanControl
|
||||
|
||||
public void Start(int delay = 0)
|
||||
{
|
||||
if (!this.tempProvider.IsInitialized)
|
||||
{
|
||||
this.tempProvider.Initialize();
|
||||
}
|
||||
|
||||
if (!this.ec.IsInitialized)
|
||||
{
|
||||
this.ec.Initialize();
|
||||
}
|
||||
|
||||
if (this.ec.AquireLock(DefaultPollInterval))
|
||||
{
|
||||
try
|
||||
@@ -205,6 +215,29 @@ namespace StagWare.FanControl
|
||||
UpdateEcAsync();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (this.autoEvent != null && !this.autoEvent.SafeWaitHandle.IsClosed)
|
||||
{
|
||||
this.autoEvent.Reset();
|
||||
}
|
||||
|
||||
if (timer != null)
|
||||
{
|
||||
using (var handle = new EventWaitHandle(false, EventResetMode.ManualReset))
|
||||
{
|
||||
timer.Dispose(handle);
|
||||
|
||||
if (handle.WaitOne())
|
||||
{
|
||||
timer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ResetEc();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected Methods
|
||||
@@ -223,20 +256,6 @@ namespace StagWare.FanControl
|
||||
|
||||
#region Update EC
|
||||
|
||||
private void Stop()
|
||||
{
|
||||
if (this.autoEvent != null && !this.autoEvent.SafeWaitHandle.IsClosed)
|
||||
{
|
||||
this.autoEvent.Reset();
|
||||
}
|
||||
|
||||
if (this.timer != null)
|
||||
{
|
||||
this.timer.Dispose();
|
||||
this.timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void TimerCallback(object state)
|
||||
{
|
||||
if (this.autoEvent.WaitOne(pollInterval / 2))
|
||||
@@ -383,10 +402,12 @@ namespace StagWare.FanControl
|
||||
: this.ec.ReadByte((byte)register);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Reset EC
|
||||
|
||||
private void ResetEc()
|
||||
{
|
||||
Stop();
|
||||
|
||||
if (this.config.RegisterWriteConfigurations.Any(x => x.ResetRequired)
|
||||
|| this.config.FanConfigurations.Any(x => x.ResetRequired))
|
||||
{
|
||||
@@ -471,43 +492,33 @@ namespace StagWare.FanControl
|
||||
|
||||
#region IDisposable implementation
|
||||
|
||||
~FanControl()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
Stop();
|
||||
|
||||
if (this.autoEvent != null)
|
||||
{
|
||||
this.autoEvent.Dispose();
|
||||
}
|
||||
|
||||
if (this.asyncOp != null)
|
||||
{
|
||||
this.asyncOp.OperationCompleted();
|
||||
}
|
||||
|
||||
if (this.ec != null)
|
||||
{
|
||||
this.ec.Dispose();
|
||||
}
|
||||
|
||||
if (this.tempProvider != null)
|
||||
{
|
||||
this.tempProvider.Dispose();
|
||||
}
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposeManagedResources)
|
||||
{
|
||||
if (disposeManagedResources)
|
||||
{
|
||||
if (timer != null)
|
||||
{
|
||||
using (var handle = new EventWaitHandle(false, EventResetMode.ManualReset))
|
||||
{
|
||||
timer.Dispose(handle);
|
||||
|
||||
if (handle.WaitOne())
|
||||
{
|
||||
timer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (autoEvent != null)
|
||||
{
|
||||
autoEvent.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
ResetEc();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace StagWare.FanControl.Plugins
|
||||
{
|
||||
public interface IEmbeddedController
|
||||
public interface IEmbeddedController : IFanControlPlugin
|
||||
{
|
||||
void WriteByte(byte register, byte value);
|
||||
void WriteWord(byte register, ushort value);
|
||||
|
13
Libraries/StagWare.FanControl/Plugins/IFanControlPlugin.cs
Normal file
13
Libraries/StagWare.FanControl/Plugins/IFanControlPlugin.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace StagWare.FanControl.Plugins
|
||||
{
|
||||
public interface IFanControlPlugin : IDisposable
|
||||
{
|
||||
bool IsInitialized { get; }
|
||||
void Initialize();
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace StagWare.FanControl.Plugins
|
||||
{
|
||||
public interface ITemperatureProvider
|
||||
public interface ITemperatureProvider : IFanControlPlugin
|
||||
{
|
||||
double GetTemperature();
|
||||
}
|
||||
|
@@ -66,6 +66,7 @@
|
||||
<Compile Include="Plugins\FanControlMetadataAttribute.cs" />
|
||||
<Compile Include="Plugins\FanControlPluginLoader.cs" />
|
||||
<Compile Include="Plugins\IEmbeddedController.cs" />
|
||||
<Compile Include="Plugins\IFanControlPlugin.cs" />
|
||||
<Compile Include="Plugins\IFanControlPluginMetadata.cs" />
|
||||
<Compile Include="Plugins\ITemperatureProvider.cs" />
|
||||
<Compile Include="Plugins\TemperatureProviderPluginLoader.cs" />
|
||||
|
@@ -36,6 +36,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StagWare.Windows.CpuTempPro
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StagWare.Windows.EmbeddedController", "Libraries\Plugins\StagWare.Windows.EmbeddedController\StagWare.Windows.EmbeddedController.csproj", "{49BBEBDD-9A3A-4963-A52C-D6154E2D6B3E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StagWare.Hardware", "Libraries\Plugins\StagWare.Hardware.EC\StagWare.Hardware.csproj", "{1D5D7C81-802F-46E0-913F-8519F157BC3C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -277,24 +279,43 @@ Global
|
||||
{49BBEBDD-9A3A-4963-A52C-D6154E2D6B3E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{49BBEBDD-9A3A-4963-A52C-D6154E2D6B3E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{49BBEBDD-9A3A-4963-A52C-D6154E2D6B3E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Release Mono|Any CPU.Build.0 = Release|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Release Mono|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Release Mono|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Release Mono|x64.ActiveCfg = Release|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Release Mono|x86.ActiveCfg = Release|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{12084B38-C1A2-414C-80A7-B8D02D6F5B84} = {656212AC-91B4-49EC-9460-7BC3D6DD500C}
|
||||
{EB60FFBC-51F9-42F7-B22B-2200C3F0CB64} = {656212AC-91B4-49EC-9460-7BC3D6DD500C}
|
||||
{15B3E0D2-6217-493A-A690-158C497F5318} = {656212AC-91B4-49EC-9460-7BC3D6DD500C}
|
||||
{0288F2E8-672E-49DA-9B93-86CEE224D996} = {656212AC-91B4-49EC-9460-7BC3D6DD500C}
|
||||
{12084B38-C1A2-414C-80A7-B8D02D6F5B84} = {656212AC-91B4-49EC-9460-7BC3D6DD500C}
|
||||
{A2E2E628-7BDA-4072-83DE-B28DE7EA85A9} = {F3E7AF84-72E0-4812-A039-B02FDD4E9040}
|
||||
{DF818D02-6FBC-44E1-88FA-0D62BD73CA95} = {F3E7AF84-72E0-4812-A039-B02FDD4E9040}
|
||||
{820ABB59-7F86-4D7F-89C9-8F7DA013D992} = {F3E7AF84-72E0-4812-A039-B02FDD4E9040}
|
||||
{809C12D7-9AD6-409B-BF2C-76D6297FC8DD} = {F3E7AF84-72E0-4812-A039-B02FDD4E9040}
|
||||
{98EE4668-8F55-43B7-B2F9-A8C4B0DAFA79} = {809C12D7-9AD6-409B-BF2C-76D6297FC8DD}
|
||||
{820ABB59-7F86-4D7F-89C9-8F7DA013D992} = {F3E7AF84-72E0-4812-A039-B02FDD4E9040}
|
||||
{088065D5-99ED-4A8B-9301-3666C5B88718} = {809C12D7-9AD6-409B-BF2C-76D6297FC8DD}
|
||||
{98EE4668-8F55-43B7-B2F9-A8C4B0DAFA79} = {809C12D7-9AD6-409B-BF2C-76D6297FC8DD}
|
||||
{D709446B-7DEC-4F18-B2A2-638A2EF8AAA6} = {809C12D7-9AD6-409B-BF2C-76D6297FC8DD}
|
||||
{B0397530-545A-471D-BB74-027AE456DF1A} = {0288F2E8-672E-49DA-9B93-86CEE224D996}
|
||||
{FC64E51E-1372-45D5-8B25-134A6859DEDD} = {0288F2E8-672E-49DA-9B93-86CEE224D996}
|
||||
{49BBEBDD-9A3A-4963-A52C-D6154E2D6B3E} = {0288F2E8-672E-49DA-9B93-86CEE224D996}
|
||||
{1D5D7C81-802F-46E0-913F-8519F157BC3C} = {0288F2E8-672E-49DA-9B93-86CEE224D996}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Deployment.WindowsInstaller;
|
||||
using OpenHardwareMonitor.Hardware.LPC;
|
||||
using OpenHardwareMonitor.Hardware;
|
||||
using System.IO;
|
||||
|
||||
namespace DriverSetupWixAction
|
||||
@@ -19,7 +19,7 @@ namespace DriverSetupWixAction
|
||||
|
||||
try
|
||||
{
|
||||
EmbeddedController.InstallDriver(session.CustomActionData[InstallDirPropertyName]);
|
||||
Computer.InstallDriver(session.CustomActionData[InstallDirPropertyName]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -38,7 +38,7 @@ namespace DriverSetupWixAction
|
||||
|
||||
try
|
||||
{
|
||||
EmbeddedController.UninstallDriver();
|
||||
Computer.UninstallDriver();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
Reference in New Issue
Block a user