├── ECView
├── ECView.ico
├── ecview.dll
├── dpmemio.dll
├── dpmemio.reg
├── dpmemio.sys
├── bin
│ └── Release
│ │ ├── ECView.exe
│ │ ├── ECView.pdb
│ │ ├── dpmemio.dll
│ │ ├── dpmemio.reg
│ │ ├── dpmemio.sys
│ │ ├── ecview.dll
│ │ └── ECView.exe.config
├── app.config
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ ├── app.manifest
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── App.xaml
├── ECView.csproj.user
├── Module
│ ├── ModuleFactory.cs
│ ├── IFanDutyModify.cs
│ └── ModuleImpl
│ │ └── FanDutyModifyImpl.cs
├── Pages
│ ├── Binding
│ │ ├── PropertyChangeBase.cs
│ │ ├── ECEditorBinding.cs
│ │ └── ECViewBinding.cs
│ └── Windows
│ │ ├── ECEditor.xaml
│ │ └── ECEditor.xaml.cs
├── Tools
│ ├── CallingVariation.cs
│ ├── ECViewTools.cs
│ └── FileAnlyze.cs
├── DataDefinitions
│ ├── ConfigPara.cs
│ └── IntePara.cs
├── App.xaml.cs
├── MainWindow.xaml
├── ECView.csproj
└── MainWindow.xaml.cs
├── ECViewService
├── dpmemio.dll
├── ecview.dll
├── bin
│ └── Release
│ │ ├── ECViewService.exe
│ │ └── ECViewService.pdb
├── ProjectInstaller.cs
├── Program.cs
├── Module
│ ├── ModuleFactory.cs
│ ├── IFanDutyModify.cs
│ └── ModuleImpl
│ │ └── FanDutyModifyImpl.cs
├── Tools
│ ├── CallingVariation.cs
│ ├── ECViewTools.cs
│ └── FileAnlyze.cs
├── ECViewService.Designer.cs
├── Properties
│ ├── AssemblyInfo.cs
│ └── app.manifest
├── DataDefinitions
│ ├── ConfigPara.cs
│ └── IntePara.cs
├── ProjectInstaller.Designer.cs
├── ECViewService.cs
├── ProjectInstaller.resx
└── ECViewService.csproj
├── conf_2.xml
├── conf_1.xml
├── Setup
└── Setup.isproj
├── README.md
├── .gitignore
└── ECView.sln
/ECView/ECView.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECView/ECView.ico
--------------------------------------------------------------------------------
/ECView/ecview.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECView/ecview.dll
--------------------------------------------------------------------------------
/ECView/dpmemio.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECView/dpmemio.dll
--------------------------------------------------------------------------------
/ECView/dpmemio.reg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECView/dpmemio.reg
--------------------------------------------------------------------------------
/ECView/dpmemio.sys:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECView/dpmemio.sys
--------------------------------------------------------------------------------
/ECViewService/dpmemio.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECViewService/dpmemio.dll
--------------------------------------------------------------------------------
/ECViewService/ecview.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECViewService/ecview.dll
--------------------------------------------------------------------------------
/ECView/bin/Release/ECView.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECView/bin/Release/ECView.exe
--------------------------------------------------------------------------------
/ECView/bin/Release/ECView.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECView/bin/Release/ECView.pdb
--------------------------------------------------------------------------------
/ECView/bin/Release/dpmemio.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECView/bin/Release/dpmemio.dll
--------------------------------------------------------------------------------
/ECView/bin/Release/dpmemio.reg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECView/bin/Release/dpmemio.reg
--------------------------------------------------------------------------------
/ECView/bin/Release/dpmemio.sys:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECView/bin/Release/dpmemio.sys
--------------------------------------------------------------------------------
/ECView/bin/Release/ecview.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECView/bin/Release/ecview.dll
--------------------------------------------------------------------------------
/ECViewService/bin/Release/ECViewService.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECViewService/bin/Release/ECViewService.exe
--------------------------------------------------------------------------------
/ECViewService/bin/Release/ECViewService.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ycraurora/Clevo-ECView/HEAD/ECViewService/bin/Release/ECViewService.pdb
--------------------------------------------------------------------------------
/ECView/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ECView/bin/Release/ECView.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ECView/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/conf_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ECView/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ECViewService/ProjectInstaller.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 |
3 | namespace ECViewService
4 | {
5 | [RunInstaller(true)]
6 | public partial class ProjectInstaller : System.Configuration.Install.Installer
7 | {
8 | public ProjectInstaller()
9 | {
10 | InitializeComponent();
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/conf_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ECViewService/Program.cs:
--------------------------------------------------------------------------------
1 | using System.ServiceProcess;
2 |
3 | namespace ECViewService
4 | {
5 | static class Program
6 | {
7 | ///
8 | /// 应用程序的主入口点。
9 | ///
10 | static void Main()
11 | {
12 | ServiceBase[] ServicesToRun;
13 | ServicesToRun = new ServiceBase[]
14 | {
15 | new ECViewService()
16 | };
17 | ServiceBase.Run(ServicesToRun);
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ECView/ECView.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | publish\
5 |
6 |
7 |
8 |
9 |
10 | en-US
11 | false
12 |
13 |
--------------------------------------------------------------------------------
/ECView/Module/ModuleFactory.cs:
--------------------------------------------------------------------------------
1 | using ECView.Module.ModuleImpl;
2 |
3 | namespace ECView.Module
4 | {
5 | public class ModuleFactory
6 | {
7 | ///
8 | /// 风扇调节功能接口实例化
9 | ///
10 | private static IFanDutyModify moduleFanDutyModify = null;
11 | public static IFanDutyModify GetFanDutyModifyModule()
12 | {
13 | if (moduleFanDutyModify == null)
14 | {
15 | moduleFanDutyModify = new FanDutyModifyImpl();
16 | }
17 | return moduleFanDutyModify;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ECViewService/Module/ModuleFactory.cs:
--------------------------------------------------------------------------------
1 | using ECView.Module.ModuleImpl;
2 |
3 | namespace ECView.Module
4 | {
5 | public class ModuleFactory
6 | {
7 | ///
8 | /// 风扇调节功能接口实例化
9 | ///
10 | private static IFanDutyModify moduleFanDutyModify = null;
11 | public static IFanDutyModify GetFanDutyModifyModule()
12 | {
13 | if (moduleFanDutyModify == null)
14 | {
15 | moduleFanDutyModify = new FanDutyModifyImpl();
16 | }
17 | return moduleFanDutyModify;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ECView/Pages/Binding/PropertyChangeBase.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 |
3 | namespace ECView.Pages.Binding
4 | {
5 | ///
6 | /// 属性更新基类
7 | ///
8 | public class PropertyChangeBase : INotifyPropertyChanged
9 | {
10 | ///
11 | /// 属性更新委托
12 | ///
13 | public event PropertyChangedEventHandler PropertyChanged;
14 | ///
15 | /// 数据更新
16 | ///
17 | ///
18 | public void Notify(string propertyName)
19 | {
20 | if (PropertyChanged != null)
21 | {
22 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ECView/Tools/CallingVariation.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace ECView.Tools
4 | {
5 | public class CallingVariation
6 | {
7 | [DllImport("ecview.dll", EntryPoint = "#3")]
8 | public static extern void SetFanDuty(int p1, int p2);
9 |
10 | [DllImport("ecview.dll", EntryPoint = "#4")]
11 | public static extern int SetFANDutyAuto(int p1);
12 |
13 | [DllImport("ecview.dll", EntryPoint = "#5")]
14 | public static extern ECData GetTempFanDuty(int p1);
15 |
16 | [DllImport("ecview.dll", EntryPoint = "#6")]
17 | public static extern int GetFANCounter();
18 |
19 | [DllImport("ecview.dll", EntryPoint = "#8")]
20 | public static extern string GetECVersion();
21 |
22 | public struct ECData
23 | {
24 | public int data;
25 | public int data1;
26 | public int data2;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ECViewService/Tools/CallingVariation.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace ECView.Tools
4 | {
5 | public class CallingVariation
6 | {
7 | [DllImport("ecview.dll", EntryPoint = "#3")]
8 | public static extern void SetFanDuty(int p1, int p2);
9 |
10 | [DllImport("ecview.dll", EntryPoint = "#4")]
11 | public static extern int SetFANDutyAuto(int p1);
12 |
13 | [DllImport("ecview.dll", EntryPoint = "#5")]
14 | public static extern ECData GetTempFanDuty(int p1);
15 |
16 | [DllImport("ecview.dll", EntryPoint = "#6")]
17 | public static extern int GetFANCounter();
18 |
19 | [DllImport("ecview.dll", EntryPoint = "#8")]
20 | public static extern string GetECVersion();
21 |
22 | public struct ECData
23 | {
24 | public int data;
25 | public int data1;
26 | public int data2;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ECViewService/ECViewService.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace ECViewService
2 | {
3 | partial class ECViewService
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region 组件设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要修改
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | components = new System.ComponentModel.Container();
32 | this.ServiceName = "Service1";
33 | }
34 |
35 | #endregion
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ECViewService/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // 有关程序集的一般信息由以下
5 | // 控制。更改这些特性值可修改
6 | // 与程序集关联的信息。
7 | [assembly: AssemblyTitle("ECViewService")]
8 | [assembly: AssemblyDescription("YcraD")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("HIT_DDS")]
11 | [assembly: AssemblyProduct("ECViewService")]
12 | [assembly: AssemblyCopyright("Copyright © DDS 2015")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | //将 ComVisible 设置为 false 将使此程序集中的类型
17 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
18 | //请将此类型的 ComVisible 特性设置为 true。
19 | [assembly: ComVisible(true)]
20 |
21 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
22 | [assembly: Guid("b0300d4f-247d-4cea-adbc-f0d0809c8764")]
23 |
24 | // 程序集的版本信息由下列四个值组成:
25 | //
26 | // 主版本
27 | // 次版本
28 | // 生成号
29 | // 修订号
30 | //
31 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
32 | // 方法是按如下所示使用“*”: :
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.1.0.0")]
35 | [assembly: AssemblyFileVersion("1.1.0.0")]
36 |
--------------------------------------------------------------------------------
/ECView/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ECView.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ECView/DataDefinitions/ConfigPara.cs:
--------------------------------------------------------------------------------
1 | namespace ECView.DataDefinitions
2 | {
3 | public class ConfigPara
4 | {
5 | ///
6 | /// 主板型号
7 | ///
8 | public string NbModel
9 | {
10 | get;
11 | set;
12 | }
13 | ///
14 | /// EC版本
15 | ///
16 | public string ECVersion
17 | {
18 | get;
19 | set;
20 | }
21 | ///
22 | /// 调节模式号
23 | ///
24 | public int SetMode
25 | {
26 | get;
27 | set;
28 | }
29 | ///
30 | /// 风扇号
31 | ///
32 | public int FanNo
33 | {
34 | get;
35 | set;
36 | }
37 | ///
38 | /// 调节模式
39 | ///
40 | public string FanSet
41 | {
42 | get;
43 | set;
44 | }
45 | ///
46 | /// 风扇转速
47 | ///
48 | public int FanDuty
49 | {
50 | get;
51 | set;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/ECViewService/DataDefinitions/ConfigPara.cs:
--------------------------------------------------------------------------------
1 | namespace ECView.DataDefinitions
2 | {
3 | public class ConfigPara
4 | {
5 | ///
6 | /// 主板型号
7 | ///
8 | public string NbModel
9 | {
10 | get;
11 | set;
12 | }
13 | ///
14 | /// EC版本
15 | ///
16 | public string ECVersion
17 | {
18 | get;
19 | set;
20 | }
21 | ///
22 | /// 调节模式号
23 | ///
24 | public int SetMode
25 | {
26 | get;
27 | set;
28 | }
29 | ///
30 | /// 风扇号
31 | ///
32 | public int FanNo
33 | {
34 | get;
35 | set;
36 | }
37 | ///
38 | /// 调节模式
39 | ///
40 | public string FanSet
41 | {
42 | get;
43 | set;
44 | }
45 | ///
46 | /// 风扇转速
47 | ///
48 | public int FanDuty
49 | {
50 | get;
51 | set;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/ECView/Pages/Binding/ECEditorBinding.cs:
--------------------------------------------------------------------------------
1 | namespace ECView.Pages.Binding
2 | {
3 | public class ECEditorBinding : PropertyChangeBase
4 | {
5 | ///
6 | /// 风扇号
7 | ///
8 | private string _fanNo;
9 | public string FanNo
10 | {
11 | set
12 | {
13 | _fanNo = value;
14 | Notify("FanNo");
15 | }
16 | get
17 | {
18 | return _fanNo;
19 | }
20 | }
21 | ///
22 | /// 风扇转速
23 | ///
24 | private int _fanDuty;
25 | public int FanDuty
26 | {
27 | set
28 | {
29 | _fanDuty = value;
30 | Notify("FanDuty");
31 | }
32 | get
33 | {
34 | return _fanDuty;
35 | }
36 | }
37 | ///
38 | /// 配置文件路径
39 | ///
40 | private string _filePath;
41 | public string FilePath
42 | {
43 | set
44 | {
45 | _filePath = value;
46 | Notify("FilePath");
47 | }
48 | get
49 | {
50 | return _filePath;
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/ECView/DataDefinitions/IntePara.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace ECView.DataDefinitions
4 | {
5 | public class IntePara
6 | {
7 | ///
8 | /// 风扇号
9 | ///
10 | public int FanNo
11 | {
12 | get;
13 | set;
14 | }
15 | ///
16 | /// 智能控速模式号
17 | ///
18 | public int ControlType
19 | {
20 | get;
21 | set;
22 | }
23 | ///
24 | /// 最小转速
25 | ///
26 | public int MinFanDuty
27 | {
28 | get;
29 | set;
30 | }
31 | ///
32 | /// 范围参数列表
33 | ///
34 | public List RangeParaList
35 | {
36 | get;
37 | set;
38 | }
39 | }
40 |
41 | public class RangePara
42 | {
43 | ///
44 | /// 范围号
45 | ///
46 | public int RangeNo
47 | {
48 | get;
49 | set;
50 | }
51 | ///
52 | /// 转速
53 | ///
54 | public int FanDuty
55 | {
56 | get;
57 | set;
58 | }
59 | ///
60 | /// 温度基础上增加百分比
61 | ///
62 | public int AddPercentage
63 | {
64 | get;
65 | set;
66 | }
67 | ///
68 | /// 范围下限
69 | ///
70 | public int InferiorLimit
71 | {
72 | get;
73 | set;
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/ECViewService/DataDefinitions/IntePara.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace ECView.DataDefinitions
4 | {
5 | public class IntePara
6 | {
7 | ///
8 | /// 风扇号
9 | ///
10 | public int FanNo
11 | {
12 | get;
13 | set;
14 | }
15 | ///
16 | /// 智能控速模式号
17 | ///
18 | public int ControlType
19 | {
20 | get;
21 | set;
22 | }
23 | ///
24 | /// 最小转速
25 | ///
26 | public int MinFanDuty
27 | {
28 | get;
29 | set;
30 | }
31 | ///
32 | /// 范围参数列表
33 | ///
34 | public List RangeParaList
35 | {
36 | get;
37 | set;
38 | }
39 | }
40 |
41 | public class RangePara
42 | {
43 | ///
44 | /// 范围号
45 | ///
46 | public int RangeNo
47 | {
48 | get;
49 | set;
50 | }
51 | ///
52 | /// 转速
53 | ///
54 | public int FanDuty
55 | {
56 | get;
57 | set;
58 | }
59 | ///
60 | /// 温度基础上增加百分比
61 | ///
62 | public int AddPercentage
63 | {
64 | get;
65 | set;
66 | }
67 | ///
68 | /// 范围下限
69 | ///
70 | public int InferiorLimit
71 | {
72 | get;
73 | set;
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/ECView/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.Threading;
3 | using System.Windows;
4 |
5 | namespace ECView
6 | {
7 | ///
8 | /// Interaction logic for App.xaml
9 | ///
10 | public partial class App : Application
11 | {
12 | Mutex mut;
13 | public App()
14 | {
15 | //禁用重复开启
16 | /*bool createNew = false;
17 | string targetExeName = System.Reflection.Assembly.GetExecutingAssembly().Location;
18 | string productName = System.IO.Path.GetFileName(System.Reflection.Assembly.GetEntryAssembly().GetName().Name);
19 |
20 | using (System.Threading.Mutex mutex = new System.Threading.Mutex(true, productName, out createNew))
21 | {
22 | if (createNew)
23 | {
24 | StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
25 | Run();
26 | }
27 | else
28 | {
29 | //PTMCWin32API.SendMessage(targetExeName, "Protocol Testing Management Console", "/v:true");
30 | Environment.Exit(1);
31 | }
32 | }*/
33 | bool requestInitialOwnership = true;
34 | bool mutexWasCreated;
35 | mut = new Mutex(requestInitialOwnership, "com.ECView.Ding", out mutexWasCreated);
36 | if (!(requestInitialOwnership && mutexWasCreated))
37 | {
38 | // 随意什么操作啦~
39 | //Current.Shutdown();
40 | //当前运行WPF程序的进程实例
41 | Process process = Process.GetCurrentProcess();
42 | process.Kill();
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Setup/Setup.isproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Express
6 |
7 | Debug
8 | $(Configuration)
9 |
10 |
11 |
12 |
13 |
14 |
15 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
29 |
30 |
31 |
32 |
33 | ECView
34 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}
35 |
36 |
37 | ECViewService
38 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}
39 |
40 |
41 |
--------------------------------------------------------------------------------
/ECViewService/ProjectInstaller.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace ECViewService
2 | {
3 | partial class ProjectInstaller
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region 组件设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要修改
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
32 | this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
33 | //
34 | // serviceProcessInstaller1
35 | //
36 | this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
37 | this.serviceProcessInstaller1.Password = null;
38 | this.serviceProcessInstaller1.Username = null;
39 | //
40 | // serviceInstaller1
41 | //
42 | this.serviceInstaller1.Description = "ECView服务";
43 | this.serviceInstaller1.DisplayName = "ECViewService";
44 | this.serviceInstaller1.ServiceName = "Service1";
45 | //
46 | // ProjectInstaller
47 | //
48 | this.Installers.AddRange(new System.Configuration.Install.Installer[] {
49 | this.serviceProcessInstaller1,
50 | this.serviceInstaller1});
51 |
52 | }
53 |
54 | #endregion
55 |
56 | private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
57 | private System.ServiceProcess.ServiceInstaller serviceInstaller1;
58 | }
59 | }
--------------------------------------------------------------------------------
/ECView/Module/IFanDutyModify.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using ECView.DataDefinitions;
3 |
4 | namespace ECView.Module
5 | {
6 | public interface IFanDutyModify
7 | {
8 | ///
9 | /// 设置风扇转速
10 | ///
11 | /// 风扇号
12 | /// 风扇转速
13 | /// 自动调节标识
14 | /// 风扇实际转速
15 | int[] SetFanduty(int fanNo, int fanduty, bool isAuto);
16 | ///
17 | /// 获取EC版本号
18 | ///
19 | /// EC版本
20 | string GetECVersion();
21 | ///
22 | /// 获取风扇转速与温度数据
23 | ///
24 | /// 风扇号
25 | /// 转速与温度结构体
26 | int[] GetTempFanDuty(int fanNo);
27 | ///
28 | /// 获取风扇数量
29 | ///
30 | /// 风扇数量
31 | int GetFanCount();
32 | ///
33 | /// 检测服务是否启动
34 | ///
35 | /// 服务名称
36 | /// 服务状态
37 | int CheckServiceState(string serviceName);
38 | ///
39 | /// 启动服务
40 | ///
41 | /// 服务名称
42 | /// 启动状态
43 | bool StartService(string serviceName);
44 | ///
45 | /// 停止服务
46 | ///
47 | /// 服务名称
48 | ///
49 | bool StopService(string serviceName);
50 | ///
51 | /// 写入配置文件
52 | ///
53 | /// 配置文件名
54 | /// 风扇配置
55 | void WriteCfgFile(string filename, List configParaList);
56 | ///
57 | /// 读取配置文件
58 | ///
59 | /// 配置文件名
60 | /// 风扇配置
61 | List ReadCfgFile(string filename);
62 | ///
63 | /// 智能调节风扇转速
64 | ///
65 | /// 配置文件路径
66 | /// 风扇号
67 | ///
68 | bool InteFandutyControl(string filePath, int fanNo);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/ECViewService/Module/IFanDutyModify.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using ECView.DataDefinitions;
3 |
4 | namespace ECView.Module
5 | {
6 | public interface IFanDutyModify
7 | {
8 | ///
9 | /// 设置风扇转速
10 | ///
11 | /// 风扇号
12 | /// 风扇转速
13 | /// 自动调节标识
14 | /// 风扇实际转速
15 | int[] SetFanduty(int fanNo, int fanduty, bool isAuto);
16 | ///
17 | /// 获取EC版本号
18 | ///
19 | /// EC版本
20 | string GetECVersion();
21 | ///
22 | /// 获取风扇转速与温度数据
23 | ///
24 | /// 风扇号
25 | /// 转速与温度结构体
26 | int[] GetTempFanDuty(int fanNo);
27 | ///
28 | /// 获取风扇数量
29 | ///
30 | /// 风扇数量
31 | int GetFanCount();
32 | ///
33 | /// 检测服务是否启动
34 | ///
35 | /// 服务名称
36 | /// 服务状态
37 | int CheckServiceState(string serviceName);
38 | ///
39 | /// 启动服务
40 | ///
41 | /// 服务名称
42 | /// 启动状态
43 | bool StartService(string serviceName);
44 | ///
45 | /// 停止服务
46 | ///
47 | /// 服务名称
48 | ///
49 | bool StopService(string serviceName);
50 | ///
51 | /// 写入配置文件
52 | ///
53 | /// 配置文件名
54 | /// 风扇配置
55 | void WriteCfgFile(string filename, List configParaList);
56 | ///
57 | /// 读取配置文件
58 | ///
59 | /// 配置文件名
60 | /// 风扇配置
61 | List ReadCfgFile(string filename);
62 | ///
63 | /// 智能调节风扇转速
64 | ///
65 | /// 配置文件路径
66 | /// 风扇号
67 | ///
68 | bool InteFandutyControl(string filePath, int fanNo);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/ECView/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 | using System.Windows;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ECView")]
9 | [assembly: AssemblyDescription("YcraD")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("HIT_DDS")]
12 | [assembly: AssemblyProduct("ECView")]
13 | [assembly: AssemblyCopyright("Copyright © DDS 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(true)]
21 |
22 | //In order to begin building localizable applications, set
23 | //CultureYouAreCodingWith in your .csproj file
24 | //inside a . For example, if you are using US english
25 | //in your source files, set the to en-US. Then uncomment
26 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
27 | //the line below to match the UICulture setting in the project file.
28 |
29 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
30 |
31 |
32 | [assembly: ThemeInfo(
33 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
34 | //(used if a resource is not found in the page,
35 | // or application resource dictionaries)
36 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
37 | //(used if a resource is not found in the page,
38 | // app, or any theme specific resource dictionaries)
39 | )]
40 |
41 |
42 | // Version information for an assembly consists of the following four values:
43 | //
44 | // Major Version
45 | // Minor Version
46 | // Build Number
47 | // Revision
48 | //
49 | // You can specify all the values or you can default the Build and Revision Numbers
50 | // by using the '*' as shown below:
51 | // [assembly: AssemblyVersion("1.0.*")]
52 | [assembly: AssemblyVersion("1.1.0.0")]
53 | [assembly: AssemblyFileVersion("1.1.0.0")]
54 |
--------------------------------------------------------------------------------
/ECViewService/ECViewService.cs:
--------------------------------------------------------------------------------
1 | using ECView.DataDefinitions;
2 | using ECView.Module;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.ServiceProcess;
6 | using System.Threading;
7 |
8 | namespace ECViewService
9 | {
10 | public partial class ECViewService : ServiceBase
11 | {
12 | //当前路径
13 | private string currentDirectory = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
14 | //功能接口
15 | private IFanDutyModify iFanDutyModify;
16 | //线程
17 | private Thread t = null;
18 | List configParaList = null;
19 | ///
20 | /// 初始化服务
21 | ///
22 | public ECViewService()
23 | {
24 | InitializeComponent();
25 | iFanDutyModify = ModuleFactory.GetFanDutyModifyModule();
26 | }
27 | ///
28 | /// 循环处理事件
29 | ///
30 | private void setFandutyThread()
31 | {
32 | //判断配置文件是否存在
33 | if (System.IO.File.Exists(currentDirectory + "ecview.cfg"))
34 | {
35 | while (true)
36 | {
37 | //线程暂停10s
38 | Thread.Sleep(10 * 1000);
39 | foreach (ConfigPara configPara in configParaList)
40 | {
41 | if (configPara.SetMode == 1)
42 | {
43 | //若配置为自动调节,设置风扇自动调节
44 | iFanDutyModify.SetFanduty(configPara.FanNo, 0, true);
45 | }
46 | else if (configPara.SetMode == 2)
47 | {
48 | //若配置为手动调节,设置风扇转速
49 | iFanDutyModify.SetFanduty(configPara.FanNo, (int)(configPara.FanDuty * 2.55m), false);
50 | }
51 | else if (configPara.SetMode == 3)
52 | {
53 | //若配置为智能调节,设置风扇转速
54 | iFanDutyModify.InteFandutyControl(currentDirectory + "conf\\Configuration_" + configPara.FanNo + ".xml", configPara.FanNo);
55 | }
56 | }
57 | }
58 | }
59 | }
60 | ///
61 | /// 服务启动动作
62 | ///
63 | ///
64 | protected override void OnStart(string[] args)
65 | {
66 | configParaList = iFanDutyModify.ReadCfgFile(currentDirectory + "ecview.cfg");
67 | t = new Thread(new ThreadStart(setFandutyThread));
68 | //设置线程优先级最低
69 | t.Priority = ThreadPriority.Lowest;
70 | t.Start();
71 | }
72 | ///
73 | /// 服务关闭动作
74 | ///
75 | protected override void OnStop()
76 | {
77 | //停止线程
78 | t.Abort();
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/ECView/Properties/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
47 |
54 |
55 |
69 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Clevo-ECView
2 | ============
3 |
4 | Clevo ECviewer and FanDuty Controller
5 |
6 | Visual Studio 2010
7 | Visual Studio 2013
8 | Visual Studio 2015
9 |
10 | Visual C# WPF & Setup Project InstallShield LE Setup Project
11 |
12 | NOTICE: This project is in Chinese(Simplified)
13 | ==================================================================
14 |
15 | Update NOTE:
16 | 2015.12.17 Thur.
17 |
18 | 1.Click once only method fixed
19 | 2.A few UI improvements
20 | 3.A few code optimization,including rewrite the inteControl method
21 | 4.Other fixes
22 | ==================================================================
23 |
24 | Update NOTE:
25 | 2015.12.09 Tue.
26 |
27 | 1.Set click once only
28 | ==================================================================
29 |
30 | Update NOTE:
31 | 2015.12.05 Sat.
32 |
33 | 1.Adaptation for windows 10
34 | ==================================================================
35 |
36 | Release NOTE:
37 | 2014.12.10 Wed.
38 |
39 | 1.Update project to VS2013
40 | 2.Rewrite methods in DLL
41 | 3.Rewrite loop in Windows Service
42 | 4.Remove autorun & backrun and use Windows Service instead
43 | 5.Now you can add & remove fans(support multifans' control)
44 | 6.Other features see the history release(s)
45 | ==================================================================
46 |
47 | Update NOTE(WIP):
48 | 2014.12.04 Tur.
49 |
50 | 1.Update project to VS2012
51 | 2.Delete original Visual Studio Setup Project
52 | 3.Add InstallShield LE Setup Project
53 | ==================================================================
54 |
55 | Release NOTE:
56 | 2014.11.30 Sun.
57 |
58 | 1.Enable/disable autorun/backrun in Settings
59 | 2.Show EC version and baseboard model in main window
60 | 3.Show CPU Remote/Local temperatures in main window
61 | 4.List all detected fans in main window
62 | 5.Set fan duty in fan setting window
63 | 6.Auto control mode(bios default)
64 | 7.Manuel control mode to set fan duty percentage
65 | 8.Intellectual control mode to set fan duty by loading config files
66 |
67 | Intellectual control mode 1:
68 | conf_1.xml
69 | This is the example config file for Intellectual control mode 1.You can
70 | set fan duty percentage with different ranges.
71 |
72 | Intellectual control mode 2:
73 | conf_2.xml
74 | This is the example config file for Intellectual control mode 2.You can
75 | set fan duty percentage added by the CPU temperature(℃) with different
76 | ranges.
77 |
78 | Author: ycrad
79 | E-mail: just4steven@163.com/just4steven@gmail.com
--------------------------------------------------------------------------------
/ECView/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ECView.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ECView.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 使用此强类型资源类,为所有资源查找
51 | /// 重写当前线程的 CurrentUICulture 属性。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// 查找类似于 (Icon) 的 System.Drawing.Icon 类型的本地化资源。
65 | ///
66 | internal static System.Drawing.Icon ECView {
67 | get {
68 | object obj = ResourceManager.GetObject("ECView", resourceCulture);
69 | return ((System.Drawing.Icon)(obj));
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/ECViewService/Properties/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
47 |
54 |
55 |
69 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 | [Dd]ebug/
11 | [Dd]ebugPublic/
12 | [Rr]elease/
13 | [Rr]eleases/
14 | x64/
15 | x86/
16 | build/
17 | bld/
18 | [Bb]in/
19 | [Oo]bj/
20 |
21 | # Roslyn cache directories
22 | *.ide/
23 |
24 | # MSTest test Results
25 | [Tt]est[Rr]esult*/
26 | [Bb]uild[Ll]og.*
27 |
28 | #NUNIT
29 | *.VisualState.xml
30 | TestResult.xml
31 |
32 | # Build Results of an ATL Project
33 | [Dd]ebugPS/
34 | [Rr]eleasePS/
35 | dlldata.c
36 |
37 | *_i.c
38 | *_p.c
39 | *_i.h
40 | *.ilk
41 | *.meta
42 | *.obj
43 | *.pch
44 | *.pdb
45 | *.pgc
46 | *.pgd
47 | *.rsp
48 | *.sbr
49 | *.tlb
50 | *.tli
51 | *.tlh
52 | *.tmp
53 | *.tmp_proj
54 | *.log
55 | *.vspscc
56 | *.vssscc
57 | .builds
58 | *.pidb
59 | *.svclog
60 | *.scc
61 |
62 | # Chutzpah Test files
63 | _Chutzpah*
64 |
65 | # Visual C++ cache files
66 | ipch/
67 | *.aps
68 | *.ncb
69 | *.opensdf
70 | *.sdf
71 | *.cachefile
72 |
73 | # Visual Studio profiler
74 | *.psess
75 | *.vsp
76 | *.vspx
77 |
78 | # TFS 2012 Local Workspace
79 | $tf/
80 |
81 | # Guidance Automation Toolkit
82 | *.gpState
83 |
84 | # ReSharper is a .NET coding add-in
85 | _ReSharper*/
86 | *.[Rr]e[Ss]harper
87 | *.DotSettings.user
88 |
89 | # JustCode is a .NET coding addin-in
90 | .JustCode
91 |
92 | # TeamCity is a build add-in
93 | _TeamCity*
94 |
95 | # DotCover is a Code Coverage Tool
96 | *.dotCover
97 |
98 | # NCrunch
99 | _NCrunch_*
100 | .*crunch*.local.xml
101 |
102 | # MightyMoose
103 | *.mm.*
104 | AutoTest.Net/
105 |
106 | # Web workbench (sass)
107 | .sass-cache/
108 |
109 | # Installshield output folder
110 | [Ee]xpress/
111 |
112 | # DocProject is a documentation generator add-in
113 | DocProject/buildhelp/
114 | DocProject/Help/*.HxT
115 | DocProject/Help/*.HxC
116 | DocProject/Help/*.hhc
117 | DocProject/Help/*.hhk
118 | DocProject/Help/*.hhp
119 | DocProject/Help/Html2
120 | DocProject/Help/html
121 |
122 | # Click-Once directory
123 | publish/
124 |
125 | # Publish Web Output
126 | *.[Pp]ublish.xml
127 | *.azurePubxml
128 | # TODO: Comment the next line if you want to checkin your web deploy settings
129 | # but database connection strings (with potential passwords) will be unencrypted
130 | *.pubxml
131 | *.publishproj
132 |
133 | # NuGet Packages
134 | *.nupkg
135 | # The packages folder can be ignored because of Package Restore
136 | **/packages/*
137 | # except build/, which is used as an MSBuild target.
138 | !**/packages/build/
139 | # If using the old MSBuild-Integrated Package Restore, uncomment this:
140 | #!**/packages/repositories.config
141 |
142 | # Windows Azure Build Output
143 | csx/
144 | *.build.csdef
145 |
146 | # Windows Store app package directory
147 | AppPackages/
148 |
149 | # Others
150 | sql/
151 | *.Cache
152 | ClientBin/
153 | [Ss]tyle[Cc]op.*
154 | ~$*
155 | *~
156 | *.dbmdl
157 | *.dbproj.schemaview
158 | *.pfx
159 | *.publishsettings
160 | node_modules/
161 |
162 | # RIA/Silverlight projects
163 | Generated_Code/
164 |
165 | # Backup & report files from converting an old project file
166 | # to a newer Visual Studio version. Backup files are not needed,
167 | # because we have git ;-)
168 | _UpgradeReport_Files/
169 | Backup*/
170 | UpgradeLog*.XML
171 | UpgradeLog*.htm
172 |
173 | # SQL Server files
174 | *.mdf
175 | *.ldf
176 |
177 | # Business Intelligence projects
178 | *.rdl.data
179 | *.bim.layout
180 | *.bim_*.settings
181 |
182 | # Microsoft Fakes
183 | FakesAssemblies/
184 | /*.suo
185 | /*.suo
186 |
--------------------------------------------------------------------------------
/ECView/Tools/ECViewTools.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceProcess;
3 |
4 | namespace ECView.Tools
5 | {
6 | public class ECViewTools
7 | {
8 | ///
9 |
10 | public static int CheckServiceState(string serviceName)
11 | {
12 | ServiceController[] service = ServiceController.GetServices();
13 | bool isStart = false;
14 | bool isExite = false;
15 | for (int i = 0; i < service.Length; i++)
16 | {
17 | if (service[i].ServiceName.ToUpper().Equals(serviceName.ToUpper()))
18 | {
19 | isExite = true;
20 | ServiceController server = service[i];
21 | if (service[i].Status == ServiceControllerStatus.Running)
22 | {
23 | isStart = true;
24 | break;
25 | }
26 | }
27 | }
28 |
29 | if (!isExite)
30 | {
31 | //服务不存在
32 | return 0;
33 | }else{
34 | if (isStart)
35 | {
36 | //服务存在并启动
37 | return 1;
38 | }
39 | else
40 | {
41 | //服务存在但未启动
42 | return 2;
43 | }
44 | }
45 | }
46 | ///
47 | /// 启动服务
48 | ///
49 | ///
50 | ///
51 | public static bool StartService(string serviceName)
52 | {
53 | try
54 | {
55 | ServiceController service = new ServiceController(serviceName);
56 | if (service.Status == ServiceControllerStatus.Running)
57 | {
58 | //服务已启动
59 | return true;
60 | }
61 | else
62 | {
63 | //服务未启动
64 | //设置timeout
65 | TimeSpan timeout = TimeSpan.FromMilliseconds(1000 * 10);
66 | service.Start();//启动程序
67 | service.WaitForStatus(ServiceControllerStatus.Running, timeout);
68 | return true;
69 | }
70 | }
71 | catch (Exception e)
72 | {
73 | Console.WriteLine("启动服务错误,原因:" + e.Message);
74 | return false;
75 | }
76 | }
77 | ///
78 | /// 停止服务
79 | ///
80 | ///
81 | ///
82 | public static bool StopService(string serviceName)
83 | {
84 | try
85 | {
86 | ServiceController service = new ServiceController(serviceName);
87 | if (service.Status == ServiceControllerStatus.Stopped)
88 | {
89 | //服务已停止
90 | return true;
91 | }
92 | else
93 | {
94 | //服务未停止
95 | //设置timeout
96 | TimeSpan timeout = TimeSpan.FromMilliseconds(1000 * 10);
97 | service.Stop();//停止程序
98 | service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
99 | return true;
100 | }
101 | }
102 | catch (Exception e)
103 | {
104 | Console.WriteLine("停止服务错误,原因:" + e.Message);
105 | return false;
106 | }
107 | }
108 | ///
109 | /// 检测XML文件
110 | ///
111 | /// 文件路径
112 | ///
113 | public static bool CheckXmlFile(string filePath)
114 | {
115 | return false;
116 | }
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/ECViewService/Tools/ECViewTools.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ServiceProcess;
3 |
4 | namespace ECView.Tools
5 | {
6 | public class ECViewTools
7 | {
8 | ///
9 |
10 | public static int CheckServiceState(string serviceName)
11 | {
12 | ServiceController[] service = ServiceController.GetServices();
13 | bool isStart = false;
14 | bool isExite = false;
15 | for (int i = 0; i < service.Length; i++)
16 | {
17 | if (service[i].ServiceName.ToUpper().Equals(serviceName.ToUpper()))
18 | {
19 | isExite = true;
20 | ServiceController server = service[i];
21 | if (service[i].Status == ServiceControllerStatus.Running)
22 | {
23 | isStart = true;
24 | break;
25 | }
26 | }
27 | }
28 |
29 | if (!isExite)
30 | {
31 | //服务不存在
32 | return 0;
33 | }else{
34 | if (isStart)
35 | {
36 | //服务存在并启动
37 | return 1;
38 | }
39 | else
40 | {
41 | //服务存在但未启动
42 | return 2;
43 | }
44 | }
45 | }
46 | ///
47 | /// 启动服务
48 | ///
49 | ///
50 | ///
51 | public static bool StartService(string serviceName)
52 | {
53 | try
54 | {
55 | ServiceController service = new ServiceController(serviceName);
56 | if (service.Status == ServiceControllerStatus.Running)
57 | {
58 | //服务已启动
59 | return true;
60 | }
61 | else
62 | {
63 | //服务未启动
64 | //设置timeout
65 | TimeSpan timeout = TimeSpan.FromMilliseconds(1000 * 10);
66 | service.Start();//启动程序
67 | service.WaitForStatus(ServiceControllerStatus.Running, timeout);
68 | return true;
69 | }
70 | }
71 | catch (Exception e)
72 | {
73 | Console.WriteLine("启动服务错误,原因:" + e.Message);
74 | return false;
75 | }
76 | }
77 | ///
78 | /// 停止服务
79 | ///
80 | ///
81 | ///
82 | public static bool StopService(string serviceName)
83 | {
84 | try
85 | {
86 | ServiceController service = new ServiceController(serviceName);
87 | if (service.Status == ServiceControllerStatus.Stopped)
88 | {
89 | //服务已停止
90 | return true;
91 | }
92 | else
93 | {
94 | //服务未停止
95 | //设置timeout
96 | TimeSpan timeout = TimeSpan.FromMilliseconds(1000 * 10);
97 | service.Stop();//停止程序
98 | service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
99 | return true;
100 | }
101 | }
102 | catch (Exception e)
103 | {
104 | Console.WriteLine("停止服务错误,原因:" + e.Message);
105 | return false;
106 | }
107 | }
108 | ///
109 | /// 检测XML文件
110 | ///
111 | /// 文件路径
112 | ///
113 | public static bool CheckXmlFile(string filePath)
114 | {
115 | return false;
116 | }
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/ECView/Pages/Binding/ECViewBinding.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.ObjectModel;
2 |
3 | namespace ECView.Pages.Binding
4 | {
5 | public class ECViewCollec : ObservableCollection
6 | {
7 | ///
8 | /// EC参数与DataGrid绑定
9 | ///
10 | public ECViewCollec()
11 | {
12 | ;
13 | }
14 | }
15 |
16 | public class ECViewBinding : PropertyChangeBase
17 | {
18 | ///
19 | /// 模具型号
20 | ///
21 | private string _nbModel;
22 | public string NbModel
23 | {
24 | set
25 | {
26 | _nbModel = value;
27 | Notify("NbModel");
28 | }
29 | get
30 | {
31 | return _nbModel;
32 | }
33 | }
34 | ///
35 | /// EC版本
36 | ///
37 | private string _ecversion;
38 | public string ECVersion
39 | {
40 | set
41 | {
42 | _ecversion = value;
43 | Notify("ECVersion");
44 | }
45 | get
46 | {
47 | return _ecversion;
48 | }
49 | }
50 | ///
51 | /// 风扇号
52 | ///
53 | private int _fanNo;
54 | public int FanNo
55 | {
56 | set
57 | {
58 | _fanNo = value;
59 | Notify("FanNo");
60 | }
61 | get
62 | {
63 | return _fanNo;
64 | }
65 | }
66 | ///
67 | /// 风扇转速
68 | ///
69 | private string _fandutyStr;
70 | public string FanDutyStr
71 | {
72 | set
73 | {
74 | _fandutyStr = value;
75 | Notify("FanDutyStr");
76 | }
77 | get
78 | {
79 | return _fandutyStr;
80 | }
81 | }
82 | ///
83 | /// 风扇转速
84 | ///
85 | private int _fanduty;
86 | public int FanDuty
87 | {
88 | set
89 | {
90 | _fanduty = value;
91 | Notify("FanDuty");
92 | }
93 | get
94 | {
95 | return _fanduty;
96 | }
97 | }
98 | ///
99 | /// CPU温度
100 | ///
101 | private string _cpuLocal;
102 | public string CpuLocal
103 | {
104 | set
105 | {
106 | _cpuLocal = value;
107 | Notify("CpuLocal");
108 | }
109 | get
110 | {
111 | return _cpuLocal;
112 | }
113 | }
114 | ///
115 | /// 主板温度
116 | ///
117 | private string _cpuRemote;
118 | public string CpuRemote
119 | {
120 | set
121 | {
122 | _cpuRemote = value;
123 | Notify("CpuRemote");
124 | }
125 | get
126 | {
127 | return _cpuRemote;
128 | }
129 | }
130 | ///
131 | /// 风扇当前设置
132 | ///
133 | private string _fanset;
134 | public string FanSet
135 | {
136 | set
137 | {
138 | _fanset = value;
139 | Notify("FanSet");
140 | }
141 | get
142 | {
143 | return _fanset;
144 | }
145 | }
146 | ///
147 | /// 设置模式
148 | ///
149 | private int _fanSetModel;
150 | public int FanSetModel
151 | {
152 | set
153 | {
154 | _fanSetModel = value;
155 | Notify("FanSetModel");
156 | }
157 | get
158 | {
159 | return _fanSetModel;
160 | }
161 | }
162 | ///
163 | /// 更新设置标识
164 | ///
165 | private bool _updateFlag;
166 | public bool UpdateFlag
167 | {
168 | set
169 | {
170 | _updateFlag = value;
171 | Notify("UpdateFlag");
172 | }
173 | get
174 | {
175 | return _updateFlag;
176 | }
177 | }
178 | }
179 | }
180 |
--------------------------------------------------------------------------------
/ECView/Pages/Windows/ECEditor.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
15 |
21 |
26 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/ECView/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\ECView.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
--------------------------------------------------------------------------------
/ECViewService/ProjectInstaller.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
124 | 208, 17
125 |
126 |
127 | False
128 |
129 |
--------------------------------------------------------------------------------
/ECView/Tools/FileAnlyze.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Xml;
5 | using ECView.DataDefinitions;
6 |
7 | namespace ECView.Tools
8 | {
9 | public class FileAnlyze
10 | {
11 | ///
12 | /// 读取XML文件
13 | ///
14 | ///
15 | public static IntePara ReadXmlFile(string filePath, int fanNo)
16 | {
17 | //声明XMLDocument对象
18 | XmlDocument doc = new XmlDocument();
19 | try
20 | {
21 | //数据存储结构体
22 | IntePara inte = new IntePara();
23 | inte.FanNo = fanNo;
24 | //范围数据存储结构体列表
25 | List rangeParaList = new List();
26 | //加载XML文件
27 | doc.Load(filePath);
28 | //获取XML根结点
29 | XmlNode root = doc.SelectSingleNode("ECView");
30 | //获取根结点属性--智能控速模式号
31 | XmlElement rootXe = (XmlElement)root;
32 | inte.ControlType = Convert.ToInt32(rootXe.GetAttribute("Type"));
33 | //获取下层结点
34 | XmlNodeList fanList = root.ChildNodes;
35 | foreach (XmlNode fan in fanList)
36 | {
37 | //获取下层结点属性--风扇最小转速
38 | XmlElement fanXe = (XmlElement)fan;
39 | inte.MinFanDuty = Convert.ToInt32(fanXe.GetAttribute("MinFanduty"));
40 | //获取范围数据
41 | XmlNodeList rangeList = fan.ChildNodes;
42 | foreach (XmlNode rangeXn in rangeList)
43 | {
44 | RangePara rangePara = new RangePara();
45 | XmlElement rangeXe = (XmlElement)rangeXn;
46 | //获取范围号
47 | rangePara.RangeNo = Convert.ToInt32(rangeXe.GetAttribute("Num"));
48 | //获取范围下限
49 | rangePara.InferiorLimit = Convert.ToInt32(rangeXe.GetAttribute("InferiorLimit"));
50 | if (inte.ControlType == 1)
51 | {
52 | //控速模式1下直接定义风扇转速
53 | rangePara.FanDuty = Convert.ToInt32(rangeXe.GetAttribute("Fanduty"));
54 | }
55 | else if (inte.ControlType == 2)
56 | {
57 | //控速模式2下为温度+自定义增幅百分比
58 | rangePara.AddPercentage = Convert.ToInt32(rangeXe.GetAttribute("AddPercentage"));
59 | }
60 | rangeParaList.Add(rangePara);
61 | }
62 | }
63 | inte.RangeParaList = rangeParaList;
64 | return inte;
65 | }
66 | catch (Exception e)
67 | {
68 | Console.WriteLine("解析XML出错,原因:" + e.Message);
69 | return null;
70 | }
71 | finally
72 | {
73 | if (doc != null)
74 | {
75 | //释放资源
76 | doc = null;
77 | }
78 | }
79 | }
80 | ///
81 | /// 读取配置文件
82 | ///
83 | /// 配置文件名
84 | /// 风扇配置
85 | public static List ReadCfgFile(string filePath)
86 | {
87 | StreamReader sr = new StreamReader(filePath);
88 | try
89 | {
90 | List configParaList = new List();
91 |
92 | List lines = new List();
93 |
94 | string line = "";
95 | while ((line = sr.ReadLine()) != null)
96 | {
97 | lines.Add(line);
98 | }
99 | for (int i = 6; i < lines.Count; i++)
100 | {
101 | ConfigPara configPara = new ConfigPara();
102 | string NbModel = lines[3].Split(new char[] { '\t' })[1];
103 | string ECVersion = lines[4].Split(new char[] { '\t' })[1];
104 | int fanNo = Convert.ToInt32(lines[i].Split(new char[] { '\t' })[1]);
105 | int setMode = Convert.ToInt32(lines[i].Split(new char[] { '\t' })[3]);
106 | string fanSet = lines[i].Split(new char[] { '\t' })[5];
107 | int fanDuty = Convert.ToInt32(lines[i].Split(new char[] { '\t' })[7]);
108 | configPara.NbModel = NbModel;
109 | configPara.ECVersion = ECVersion;
110 | configPara.FanNo = fanNo;
111 | configPara.SetMode = setMode;
112 | configPara.FanSet = fanSet;
113 | configPara.FanDuty = fanDuty;
114 | configParaList.Add(configPara);
115 | }
116 | return configParaList;
117 | }
118 | catch
119 | {
120 | return null;
121 | }
122 | finally
123 | {
124 | if (sr != null)
125 | {
126 | //释放资源
127 | sr = null;
128 | }
129 | }
130 |
131 | }
132 | ///
133 | /// 写入配置文件
134 | ///
135 | /// 配置文件路径
136 | /// 风扇配置
137 | public static void WriteCfgFile(string filePath, List configParaList)
138 | {
139 | StreamWriter sw = new StreamWriter(filePath);
140 | try
141 | {
142 | sw.WriteLine("#ECView");
143 | sw.WriteLine("#Author YcraD");
144 | sw.WriteLine("#Config File -- DO NOT EDIT!");
145 | sw.WriteLine("MbModel" + "\t" + configParaList[0].NbModel);
146 | sw.WriteLine("ECVersion" + "\t" + configParaList[0].ECVersion);
147 | sw.WriteLine("FanCount" + "\t" + configParaList.Count);
148 | foreach (ConfigPara configPara in configParaList)
149 | {
150 | sw.WriteLine("FanNo" + "\t" + configPara.FanNo + "\t" + "SetMode" + "\t" + configPara.SetMode + "\t" + "FanSet" + "\t" + configPara.FanSet + "\t" + "FanDuty" + "\t" + configPara.FanDuty);
151 | }
152 | sw.Close();
153 | }
154 | catch
155 | {
156 | return;
157 | }
158 | finally
159 | {
160 | if (sw != null)
161 | {
162 | //释放资源
163 | sw = null;
164 | }
165 | }
166 | }
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/ECViewService/Tools/FileAnlyze.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Xml;
5 | using ECView.DataDefinitions;
6 |
7 | namespace ECView.Tools
8 | {
9 | public class FileAnlyze
10 | {
11 | ///
12 | /// 读取XML文件
13 | ///
14 | ///
15 | public static IntePara ReadXmlFile(string filePath, int fanNo)
16 | {
17 | //声明XMLDocument对象
18 | XmlDocument doc = new XmlDocument();
19 | try
20 | {
21 | //数据存储结构体
22 | IntePara inte = new IntePara();
23 | inte.FanNo = fanNo;
24 | //范围数据存储结构体列表
25 | List rangeParaList = new List();
26 | //加载XML文件
27 | doc.Load(filePath);
28 | //获取XML根结点
29 | XmlNode root = doc.SelectSingleNode("ECView");
30 | //获取根结点属性--智能控速模式号
31 | XmlElement rootXe = (XmlElement)root;
32 | inte.ControlType = Convert.ToInt32(rootXe.GetAttribute("Type"));
33 | //获取下层结点
34 | XmlNodeList fanList = root.ChildNodes;
35 | foreach (XmlNode fan in fanList)
36 | {
37 | //获取下层结点属性--风扇最小转速
38 | XmlElement fanXe = (XmlElement)fan;
39 | inte.MinFanDuty = Convert.ToInt32(fanXe.GetAttribute("MinFanduty"));
40 | //获取范围数据
41 | XmlNodeList rangeList = fan.ChildNodes;
42 | foreach (XmlNode rangeXn in rangeList)
43 | {
44 | RangePara rangePara = new RangePara();
45 | XmlElement rangeXe = (XmlElement)rangeXn;
46 | //获取范围号
47 | rangePara.RangeNo = Convert.ToInt32(rangeXe.GetAttribute("Num"));
48 | //获取范围下限
49 | rangePara.InferiorLimit = Convert.ToInt32(rangeXe.GetAttribute("InferiorLimit"));
50 | if (inte.ControlType == 1)
51 | {
52 | //控速模式1下直接定义风扇转速
53 | rangePara.FanDuty = Convert.ToInt32(rangeXe.GetAttribute("Fanduty"));
54 | }
55 | else if (inte.ControlType == 2)
56 | {
57 | //控速模式2下为温度+自定义增幅百分比
58 | rangePara.AddPercentage = Convert.ToInt32(rangeXe.GetAttribute("AddPercentage"));
59 | }
60 | rangeParaList.Add(rangePara);
61 | }
62 | }
63 | inte.RangeParaList = rangeParaList;
64 | return inte;
65 | }
66 | catch (Exception e)
67 | {
68 | Console.WriteLine("解析XML出错,原因:" + e.Message);
69 | return null;
70 | }
71 | finally
72 | {
73 | if (doc != null)
74 | {
75 | //释放资源
76 | doc = null;
77 | }
78 | }
79 | }
80 | ///
81 | /// 读取配置文件
82 | ///
83 | /// 配置文件名
84 | /// 风扇配置
85 | public static List ReadCfgFile(string filePath)
86 | {
87 | StreamReader sr = new StreamReader(filePath);
88 | try
89 | {
90 | List configParaList = new List();
91 |
92 | List lines = new List();
93 |
94 | string line = "";
95 | while ((line = sr.ReadLine()) != null)
96 | {
97 | lines.Add(line);
98 | }
99 | for (int i = 6; i < lines.Count; i++)
100 | {
101 | ConfigPara configPara = new ConfigPara();
102 | string NbModel = lines[3].Split(new char[] { '\t' })[1];
103 | string ECVersion = lines[4].Split(new char[] { '\t' })[1];
104 | int fanNo = Convert.ToInt32(lines[i].Split(new char[] { '\t' })[1]);
105 | int setMode = Convert.ToInt32(lines[i].Split(new char[] { '\t' })[3]);
106 | string fanSet = lines[i].Split(new char[] { '\t' })[5];
107 | int fanDuty = Convert.ToInt32(lines[i].Split(new char[] { '\t' })[7]);
108 | configPara.NbModel = NbModel;
109 | configPara.ECVersion = ECVersion;
110 | configPara.FanNo = fanNo;
111 | configPara.SetMode = setMode;
112 | configPara.FanSet = fanSet;
113 | configPara.FanDuty = fanDuty;
114 | configParaList.Add(configPara);
115 | }
116 | return configParaList;
117 | }
118 | catch
119 | {
120 | return null;
121 | }
122 | finally
123 | {
124 | if (sr != null)
125 | {
126 | //释放资源
127 | sr = null;
128 | }
129 | }
130 |
131 | }
132 | ///
133 | /// 写入配置文件
134 | ///
135 | /// 配置文件路径
136 | /// 风扇配置
137 | public static void WriteCfgFile(string filePath, List configParaList)
138 | {
139 | StreamWriter sw = new StreamWriter(filePath);
140 | try
141 | {
142 | sw.WriteLine("#ECView");
143 | sw.WriteLine("#Author YcraD");
144 | sw.WriteLine("#Config File -- DO NOT EDIT!");
145 | sw.WriteLine("MbModel" + "\t" + configParaList[0].NbModel);
146 | sw.WriteLine("ECVersion" + "\t" + configParaList[0].ECVersion);
147 | sw.WriteLine("FanCount" + "\t" + configParaList.Count);
148 | foreach (ConfigPara configPara in configParaList)
149 | {
150 | sw.WriteLine("FanNo" + "\t" + configPara.FanNo + "\t" + "SetMode" + "\t" + configPara.SetMode + "\t" + "FanSet" + "\t" + configPara.FanSet + "\t" + "FanDuty" + "\t" + configPara.FanDuty);
151 | }
152 | sw.Close();
153 | }
154 | catch
155 | {
156 | return;
157 | }
158 | finally
159 | {
160 | if (sw != null)
161 | {
162 | //释放资源
163 | sw = null;
164 | }
165 | }
166 | }
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/ECViewService/ECViewService.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}
8 | WinExe
9 | Properties
10 | ECViewService
11 | ECViewService
12 | v4.0
13 | 512
14 | publish\
15 | true
16 | Disk
17 | false
18 | Foreground
19 | 7
20 | Days
21 | false
22 | false
23 | true
24 | 0
25 | 1.0.0.%2a
26 | false
27 | false
28 | true
29 |
30 |
31 | x86
32 | true
33 | full
34 | false
35 | bin\Debug\
36 | DEBUG
37 | prompt
38 | 4
39 |
40 |
41 | x86
42 | pdbonly
43 | false
44 | bin\Release\
45 | TRACE
46 | prompt
47 | 4
48 |
49 |
50 | LocalIntranet
51 |
52 |
53 | false
54 |
55 |
56 | Properties\app.manifest
57 |
58 |
59 | true
60 | bin\x64\Debug\
61 | DEBUG;TRACE
62 | full
63 | x64
64 | prompt
65 | MinimumRecommendedRules.ruleset
66 |
67 |
68 | bin\x64\Release\
69 | TRACE
70 | pdbonly
71 | x64
72 | prompt
73 | MinimumRecommendedRules.ruleset
74 |
75 |
76 | ECViewService.Program
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 | Component
95 |
96 |
97 | ECViewService.cs
98 |
99 |
100 |
101 |
102 |
103 |
104 | Component
105 |
106 |
107 | ProjectInstaller.cs
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 | Always
117 |
118 |
119 | Always
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | False
128 | Microsoft .NET Framework 4 %28x86 和 x64%29
129 | true
130 |
131 |
132 | False
133 | .NET Framework 3.5 SP1
134 | false
135 |
136 |
137 | False
138 | Windows Installer 4.5
139 | true
140 |
141 |
142 |
143 |
144 | ProjectInstaller.cs
145 |
146 |
147 |
148 |
155 |
--------------------------------------------------------------------------------
/ECView/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
13 |
19 |
24 |
38 |
41 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/ECView/Pages/Windows/ECEditor.xaml.cs:
--------------------------------------------------------------------------------
1 | using ECView.Module;
2 | using ECView.Pages.Binding;
3 | using System;
4 | using System.IO;
5 | using System.Windows;
6 |
7 | namespace ECView.Pages.Windows
8 | {
9 | ///
10 | /// Interaction logic for ECEditor.xaml
11 | ///
12 | public partial class ECEditor : Window
13 | {
14 | ECEditorBinding ecBinding;
15 | MainWindow main;
16 | IFanDutyModify iFanDutyModify;
17 | private int index;
18 | private int fanSetModel;
19 | private string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
20 |
21 | public ECEditor(MainWindow main, int index, int fanduty, int fanSetModel)
22 | {
23 | InitializeComponent();
24 | ecBinding = (ECEditorBinding)ECEditGrid.DataContext;
25 | iFanDutyModify = ModuleFactory.GetFanDutyModifyModule();
26 | this.main = main;
27 | this.index = index;
28 | this.fanSetModel = fanSetModel;
29 | //界面初始化
30 | InitEcData(fanduty);
31 | }
32 | ///
33 | /// 界面初始化
34 | ///
35 | ///
36 | private void InitEcData(int fanduty)
37 | {
38 | int fanNo = index + 1;
39 | ecBinding.FanNo = "当前风扇号:" + fanNo;
40 | ecBinding.FanDuty = fanduty;
41 | switch (fanSetModel)
42 | {
43 | case 1:
44 | AutoChkBox.IsChecked = true;
45 | break;
46 | case 2:
47 | ManuChkBox.IsChecked = true;
48 | break;
49 | case 3:
50 | InteChkBox.IsChecked = true;
51 | break;
52 | default:
53 | ManuChkBox.IsChecked = true;
54 | break;
55 | }
56 | }
57 | //////////////////////////////////////////////////////界面事件//////////////////////////////////////////////////////
58 |
59 | ///
60 | /// 自动调节
61 | ///
62 | ///
63 | ///
64 | private void AutoChecked(object sender, RoutedEventArgs e)
65 | {
66 | //禁用手动与智能调节
67 | ManuSet.IsEnabled = false;
68 | InteSet.IsEnabled = false;
69 | //设置模式
70 | fanSetModel = 1;
71 | }
72 | ///
73 | /// 手动调节
74 | ///
75 | ///
76 | ///
77 | private void ManuChecked(object sender, RoutedEventArgs e)
78 | {
79 | //启用手动调节
80 | ManuSet.IsEnabled = true;
81 | //禁用智能调节
82 | InteSet.IsEnabled = false;
83 | //设置模式
84 | fanSetModel = 2;
85 | }
86 | ///
87 | /// 智能调节
88 | ///
89 | ///
90 | ///
91 | private void InteChecked(object sender, RoutedEventArgs e)
92 | {
93 | //禁用手动调节
94 | ManuSet.IsEnabled = false;
95 | //启用智能调节
96 | InteSet.IsEnabled = true;
97 | //设置模式
98 | fanSetModel = 3;
99 | }
100 | ///
101 | /// 事件--取消
102 | ///
103 | ///
104 | ///
105 | private void Cancel_Click(object sender, RoutedEventArgs e)
106 | {
107 | //关闭窗口
108 | this.Close();
109 | }
110 | ///
111 | /// 事件--确定
112 | ///
113 | ///
114 | ///
115 | private void Confirm_Click(object sender, RoutedEventArgs e)
116 | {
117 | if (fanSetModel == 1)
118 | {
119 | main.ECViewDataCollec[index].FanSet = "自动调节";
120 | main.ECViewDataCollec[index].FanSetModel = 1;
121 | iFanDutyModify.SetFanduty(index + 1, 0, true);
122 | main.ECViewDataCollec[index].UpdateFlag = true;
123 |
124 | //关闭窗口
125 | this.Close();
126 | }
127 | else if (fanSetModel == 2)
128 | {
129 | main.ECViewDataCollec[index].FanSet = "手动调节";
130 | main.ECViewDataCollec[index].FanSetModel = 2;
131 | main.ECViewDataCollec[index].FanDuty = ecBinding.FanDuty;
132 | main.ECViewDataCollec[index].FanDutyStr = ecBinding.FanDuty + "%";
133 | iFanDutyModify.SetFanduty(index + 1, (int)(ecBinding.FanDuty*2.55m), false);
134 | main.ECViewDataCollec[index].UpdateFlag = true;
135 |
136 | //关闭窗口
137 | this.Close();
138 | }
139 | else if (fanSetModel == 3)
140 | {
141 | main.ECViewDataCollec[index].FanSet = "智能调节";
142 | main.ECViewDataCollec[index].FanSetModel = 3;
143 | if (ecBinding.FilePath == null || ecBinding.FilePath == "")
144 | {
145 | MessageBox.Show("请选择配置文件", "提示信息", MessageBoxButton.OK, MessageBoxImage.Information);
146 | }
147 | else
148 | {
149 | main.ECViewDataCollec[index].UpdateFlag = true;
150 | MessageBox.Show("智能调节将在程序关闭后启用", "提示信息", MessageBoxButton.OK, MessageBoxImage.Information);
151 |
152 | //关闭窗口
153 | this.Close();
154 | }
155 | }
156 | }
157 | ///
158 | /// 事件--选择配置文件
159 | ///
160 | ///
161 | ///
162 | private void FileSelect_Click(object sender, RoutedEventArgs e)
163 | {
164 | Microsoft.Win32.OpenFileDialog fileDialog = new Microsoft.Win32.OpenFileDialog();
165 | fileDialog.InitialDirectory = Directory.GetCurrentDirectory();//初始目录
166 | fileDialog.DefaultExt = ".xml"; // 默认文件类型
167 | fileDialog.Filter = "XML Files (.xml)|*.xml";
168 | fileDialog.Multiselect = false;
169 | //加入选择的文件信息
170 | if (fileDialog.ShowDialog() == true)
171 | {
172 | try
173 | {
174 | string filePath = fileDialog.FileName;//选择配置文件
175 | //风扇号
176 | int fanNo = index + 1;
177 | //目标文件绝对路径
178 | string targetPath = path + "conf\\Configuration_" + fanNo + ".xml";
179 | //检测目标文件夹是否存在
180 | if (!Directory.Exists(path + "conf\\"))
181 | {
182 | //若不存在则建立文件夹
183 | Directory.CreateDirectory(path + "conf\\");
184 | }
185 | //复制配置文件(覆盖同名文件)
186 | File.Copy(fileDialog.FileName, targetPath, true);
187 | ecBinding.FilePath = filePath;
188 | }
189 | catch (Exception ee)
190 | {
191 | MessageBox.Show("文件读取错误!错误原因" + ee.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Information);
192 | }
193 | }
194 | }
195 | }
196 | }
197 |
--------------------------------------------------------------------------------
/ECView/ECView.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}
9 | WinExe
10 | Properties
11 | ECView
12 | ECView
13 | v4.0
14 | Client
15 | 512
16 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
17 | 4
18 | false
19 | publish\
20 | true
21 | Disk
22 | false
23 | Foreground
24 | 7
25 | Days
26 | false
27 | false
28 | true
29 | 0
30 | 1.0.0.%2a
31 | false
32 | true
33 |
34 |
35 | x86
36 | true
37 | full
38 | false
39 | bin\Debug\
40 | DEBUG
41 | prompt
42 | 4
43 | false
44 | false
45 |
46 |
47 | x86
48 | pdbonly
49 | false
50 | bin\Release\
51 | DEBUG;TRACE
52 | prompt
53 | 4
54 | false
55 | false
56 |
57 |
58 | ECView.ico
59 |
60 |
61 |
62 | LocalIntranet
63 |
64 |
65 | false
66 |
67 |
68 | Properties\app.manifest
69 |
70 |
71 | true
72 | bin\x64\Debug\
73 | DEBUG
74 | full
75 | x64
76 | false
77 | prompt
78 | MinimumRecommendedRules.ruleset
79 |
80 |
81 | bin\x64\Release\
82 | DEBUG;TRACE
83 | pdbonly
84 | x64
85 | false
86 | prompt
87 | MinimumRecommendedRules.ruleset
88 |
89 |
90 | ECView.App
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 | 4.0
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 | MSBuild:Compile
114 | Designer
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 | MSBuild:Compile
123 | Designer
124 |
125 |
126 | App.xaml
127 | Code
128 |
129 |
130 | MainWindow.xaml
131 | Code
132 |
133 |
134 | Designer
135 | MSBuild:Compile
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 | ECEditor.xaml
147 |
148 |
149 | Code
150 |
151 |
152 | True
153 | True
154 | Resources.resx
155 |
156 |
157 | True
158 | Settings.settings
159 | True
160 |
161 |
162 | ResXFileCodeGenerator
163 | Resources.Designer.cs
164 |
165 |
166 |
167 | Always
168 |
169 |
170 | Always
171 |
172 |
173 |
174 | SettingsSingleFileGenerator
175 | Settings.Designer.cs
176 |
177 |
178 |
179 |
180 |
181 | Always
182 |
183 |
184 | Always
185 |
186 |
187 |
188 |
189 |
190 | False
191 | Microsoft .NET Framework 4 Client Profile %28x86 和 x64%29
192 | true
193 |
194 |
195 | False
196 | .NET Framework 3.5 SP1 Client Profile
197 | false
198 |
199 |
200 | False
201 | .NET Framework 3.5 SP1
202 | false
203 |
204 |
205 | False
206 | Windows Installer 3.1
207 | true
208 |
209 |
210 |
211 |
218 |
--------------------------------------------------------------------------------
/ECView.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ECView", "ECView\ECView.csproj", "{66A0097B-7BAB-428C-BCF0-31977BAE8375}"
7 | EndProject
8 | Project("{6141683F-8A12-4E36-9623-2EB02B2C2303}") = "Setup", "Setup\Setup.isproj", "{938AA544-BFCE-42E6-AB7A-192CAC1501A3}"
9 | ProjectSection(ProjectDependencies) = postProject
10 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764} = {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}
11 | {66A0097B-7BAB-428C-BCF0-31977BAE8375} = {66A0097B-7BAB-428C-BCF0-31977BAE8375}
12 | EndProjectSection
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ECViewService", "ECViewService\ECViewService.csproj", "{B0300D4F-247D-4CEA-ADBC-F0D0809C8764}"
15 | EndProject
16 | Global
17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 | CD_ROM|Any CPU = CD_ROM|Any CPU
19 | CD_ROM|Mixed Platforms = CD_ROM|Mixed Platforms
20 | CD_ROM|x64 = CD_ROM|x64
21 | CD_ROM|x86 = CD_ROM|x86
22 | Debug|Any CPU = Debug|Any CPU
23 | Debug|Mixed Platforms = Debug|Mixed Platforms
24 | Debug|x64 = Debug|x64
25 | Debug|x86 = Debug|x86
26 | DVD-5|Any CPU = DVD-5|Any CPU
27 | DVD-5|Mixed Platforms = DVD-5|Mixed Platforms
28 | DVD-5|x64 = DVD-5|x64
29 | DVD-5|x86 = DVD-5|x86
30 | Release|Any CPU = Release|Any CPU
31 | Release|Mixed Platforms = Release|Mixed Platforms
32 | Release|x64 = Release|x64
33 | Release|x86 = Release|x86
34 | SingleImage|Any CPU = SingleImage|Any CPU
35 | SingleImage|Mixed Platforms = SingleImage|Mixed Platforms
36 | SingleImage|x64 = SingleImage|x64
37 | SingleImage|x86 = SingleImage|x86
38 | EndGlobalSection
39 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
40 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.CD_ROM|Any CPU.ActiveCfg = Release|x86
41 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.CD_ROM|Mixed Platforms.ActiveCfg = Release|x86
42 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.CD_ROM|Mixed Platforms.Build.0 = Release|x86
43 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.CD_ROM|x64.ActiveCfg = Release|x64
44 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.CD_ROM|x64.Build.0 = Release|x64
45 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.CD_ROM|x86.ActiveCfg = Release|x86
46 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.CD_ROM|x86.Build.0 = Release|x86
47 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.Debug|Any CPU.ActiveCfg = Debug|x86
48 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
49 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.Debug|Mixed Platforms.Build.0 = Debug|x86
50 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.Debug|x64.ActiveCfg = Debug|x64
51 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.Debug|x86.ActiveCfg = Debug|x86
52 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.Debug|x86.Build.0 = Debug|x86
53 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.DVD-5|Any CPU.ActiveCfg = Debug|x86
54 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.DVD-5|Mixed Platforms.ActiveCfg = Debug|x86
55 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.DVD-5|Mixed Platforms.Build.0 = Debug|x86
56 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.DVD-5|x64.ActiveCfg = Debug|x64
57 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.DVD-5|x64.Build.0 = Debug|x64
58 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.DVD-5|x86.ActiveCfg = Debug|x86
59 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.DVD-5|x86.Build.0 = Debug|x86
60 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.Release|Any CPU.ActiveCfg = Release|x86
61 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.Release|Mixed Platforms.ActiveCfg = Release|x86
62 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.Release|Mixed Platforms.Build.0 = Release|x86
63 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.Release|x64.ActiveCfg = Release|x64
64 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.Release|x86.ActiveCfg = Release|x86
65 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.Release|x86.Build.0 = Release|x86
66 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.SingleImage|Any CPU.ActiveCfg = Release|x86
67 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.SingleImage|Mixed Platforms.ActiveCfg = Release|x86
68 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.SingleImage|Mixed Platforms.Build.0 = Release|x86
69 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.SingleImage|x64.ActiveCfg = Release|x64
70 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.SingleImage|x64.Build.0 = Release|x64
71 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.SingleImage|x86.ActiveCfg = Release|x86
72 | {66A0097B-7BAB-428C-BCF0-31977BAE8375}.SingleImage|x86.Build.0 = Release|x86
73 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.CD_ROM|Any CPU.ActiveCfg = CD_ROM
74 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.CD_ROM|Any CPU.Build.0 = CD_ROM
75 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.CD_ROM|Mixed Platforms.ActiveCfg = CD_ROM
76 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.CD_ROM|Mixed Platforms.Build.0 = CD_ROM
77 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.CD_ROM|x64.ActiveCfg = CD_ROM
78 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.CD_ROM|x64.Build.0 = CD_ROM
79 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.CD_ROM|x86.ActiveCfg = CD_ROM
80 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.CD_ROM|x86.Build.0 = CD_ROM
81 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Debug|Any CPU.ActiveCfg = DVD-5
82 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Debug|Any CPU.Build.0 = DVD-5
83 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Debug|Mixed Platforms.ActiveCfg = DVD-5
84 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Debug|Mixed Platforms.Build.0 = DVD-5
85 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Debug|x64.ActiveCfg = DVD-5
86 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Debug|x64.Build.0 = DVD-5
87 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Debug|x86.ActiveCfg = DVD-5
88 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Debug|x86.Build.0 = DVD-5
89 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.DVD-5|Any CPU.ActiveCfg = DVD-5
90 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.DVD-5|Any CPU.Build.0 = DVD-5
91 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.DVD-5|Mixed Platforms.ActiveCfg = DVD-5
92 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.DVD-5|Mixed Platforms.Build.0 = DVD-5
93 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.DVD-5|x64.ActiveCfg = DVD-5
94 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.DVD-5|x64.Build.0 = DVD-5
95 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.DVD-5|x86.ActiveCfg = DVD-5
96 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.DVD-5|x86.Build.0 = DVD-5
97 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Release|Any CPU.ActiveCfg = SingleImage
98 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Release|Any CPU.Build.0 = SingleImage
99 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Release|Mixed Platforms.ActiveCfg = SingleImage
100 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Release|Mixed Platforms.Build.0 = SingleImage
101 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Release|x64.ActiveCfg = SingleImage
102 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Release|x64.Build.0 = SingleImage
103 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Release|x86.ActiveCfg = SingleImage
104 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.Release|x86.Build.0 = SingleImage
105 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.SingleImage|Any CPU.ActiveCfg = SingleImage
106 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.SingleImage|Any CPU.Build.0 = SingleImage
107 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.SingleImage|Mixed Platforms.ActiveCfg = SingleImage
108 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.SingleImage|Mixed Platforms.Build.0 = SingleImage
109 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.SingleImage|x64.ActiveCfg = SingleImage
110 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.SingleImage|x64.Build.0 = SingleImage
111 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.SingleImage|x86.ActiveCfg = SingleImage
112 | {938AA544-BFCE-42E6-AB7A-192CAC1501A3}.SingleImage|x86.Build.0 = SingleImage
113 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
114 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
115 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.CD_ROM|Mixed Platforms.ActiveCfg = Release|Any CPU
116 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.CD_ROM|Mixed Platforms.Build.0 = Release|Any CPU
117 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.CD_ROM|x64.ActiveCfg = Release|x64
118 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.CD_ROM|x64.Build.0 = Release|x64
119 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.CD_ROM|x86.ActiveCfg = Release|Any CPU
120 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.CD_ROM|x86.Build.0 = Release|Any CPU
121 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
122 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Debug|Any CPU.Build.0 = Debug|Any CPU
123 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
124 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
125 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Debug|x64.ActiveCfg = Debug|x64
126 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Debug|x64.Build.0 = Debug|x64
127 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Debug|x86.ActiveCfg = Debug|Any CPU
128 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Debug|x86.Build.0 = Debug|Any CPU
129 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU
130 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.DVD-5|Any CPU.Build.0 = Debug|Any CPU
131 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.DVD-5|Mixed Platforms.ActiveCfg = Debug|Any CPU
132 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.DVD-5|Mixed Platforms.Build.0 = Debug|Any CPU
133 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.DVD-5|x64.ActiveCfg = Debug|x64
134 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.DVD-5|x64.Build.0 = Debug|x64
135 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.DVD-5|x86.ActiveCfg = Debug|Any CPU
136 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.DVD-5|x86.Build.0 = Debug|Any CPU
137 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Release|Any CPU.ActiveCfg = Release|Any CPU
138 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Release|Any CPU.Build.0 = Release|Any CPU
139 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
140 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Release|Mixed Platforms.Build.0 = Release|Any CPU
141 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Release|x64.ActiveCfg = Release|x64
142 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Release|x64.Build.0 = Release|x64
143 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Release|x86.ActiveCfg = Release|Any CPU
144 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.Release|x86.Build.0 = Release|Any CPU
145 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
146 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.SingleImage|Any CPU.Build.0 = Release|Any CPU
147 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.SingleImage|Mixed Platforms.ActiveCfg = Release|Any CPU
148 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.SingleImage|Mixed Platforms.Build.0 = Release|Any CPU
149 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.SingleImage|x64.ActiveCfg = Release|x64
150 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.SingleImage|x64.Build.0 = Release|x64
151 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.SingleImage|x86.ActiveCfg = Release|Any CPU
152 | {B0300D4F-247D-4CEA-ADBC-F0D0809C8764}.SingleImage|x86.Build.0 = Release|Any CPU
153 | EndGlobalSection
154 | GlobalSection(SolutionProperties) = preSolution
155 | HideSolutionNode = FALSE
156 | EndGlobalSection
157 | EndGlobal
158 |
--------------------------------------------------------------------------------
/ECView/Module/ModuleImpl/FanDutyModifyImpl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using ECView.Tools;
4 | using System.Threading;
5 | using ECView.DataDefinitions;
6 |
7 | namespace ECView.Module.ModuleImpl
8 | {
9 | public class FanDutyModifyImpl : IFanDutyModify
10 | {
11 | ///
12 | /// 设置风扇转速
13 | ///
14 | /// 风扇号
15 | /// 风扇转速
16 | /// 自动调节标识
17 | /// 风扇实际转速
18 | public int[] SetFanduty(int fanNo, int fanduty, bool isAuto)
19 | {
20 | try
21 | {
22 | if (isAuto)
23 | {
24 | //自动调节风扇转速
25 | CallingVariation.SetFANDutyAuto(fanNo);
26 | }
27 | else
28 | {
29 | //将风扇转速设置为定值
30 | CallingVariation.SetFanDuty(fanNo, fanduty);
31 | }
32 | Thread.Sleep(500);
33 | int[] newFanduty = this._updateFanDuty(fanNo);
34 | return newFanduty;
35 | }
36 | catch (Exception e)
37 | {
38 | Console.WriteLine("设置风扇转速错误,原因:" + e.Message);
39 | int[] newFanduty = { -1, -1, -1 };
40 | return newFanduty;
41 | }
42 | }
43 | ///
44 | /// 获取EC版本号
45 | ///
46 | /// EC版本
47 | public string GetECVersion()
48 | {
49 | try
50 | {
51 | string ECVersion = CallingVariation.GetECVersion();
52 | return ECVersion;
53 | }
54 | catch (Exception e)
55 | {
56 | Console.WriteLine("获取EC版本错误,原因:" + e.Message);
57 | return "";
58 | }
59 | }
60 | ///
61 | /// 获取风扇转速与温度数据
62 | ///
63 | /// 转速与温度结构体
64 | public int[] GetTempFanDuty(int fanNo)
65 | {
66 | try
67 | {
68 | var ecData = CallingVariation.GetTempFanDuty(fanNo);
69 | int byteData = ecData.data;
70 | byte[] ec = BitConverter.GetBytes(byteData);
71 | int[] fanduty = { 0, 0, 0 };
72 | fanduty[0] = ec[0];
73 | fanduty[1] = ec[1];
74 | fanduty[2] = (int)Math.Round(ec[2] / 2.55m);
75 | return fanduty;
76 | }
77 | catch (Exception e)
78 | {
79 | Console.WriteLine("获取风扇转速与温度数据错误,原因:" + e.Message);
80 | int[] fanduty = { -1, -1, -1 };
81 | return fanduty;
82 | }
83 | }
84 | ///
85 | /// 获取风扇数量
86 | ///
87 | /// 风扇数量
88 | public int GetFanCount()
89 | {
90 | try
91 | {
92 | int FANCount = CallingVariation.GetFANCounter();
93 | return FANCount;
94 | }
95 | catch (Exception e)
96 | {
97 | Console.WriteLine("获取风扇数量错误,原因:" + e.Message);
98 | return -1;
99 | }
100 | }
101 | ///
102 | /// 检测服务是否启动
103 | ///
104 | /// 服务名称
105 | /// 服务状态
106 | public int CheckServiceState(string serviceName)
107 | {
108 | try
109 | {
110 | int serviceState = ECViewTools.CheckServiceState(serviceName);
111 | return serviceState;
112 | }
113 | catch (Exception e)
114 | {
115 | Console.WriteLine("获取服务状态错误,原因:" + e.Message);
116 | return -1;
117 | }
118 | }
119 | ///
120 | /// 启动服务
121 | ///
122 | /// 服务名称
123 | /// 启动状态
124 | public bool StartService(string serviceName)
125 | {
126 | bool flag = ECViewTools.StartService(serviceName);
127 | return flag;
128 | }
129 | ///
130 | /// 停止服务
131 | ///
132 | /// 服务名称
133 | ///
134 | public bool StopService(string serviceName)
135 | {
136 | bool flag = ECViewTools.StopService(serviceName);
137 | return flag;
138 | }
139 | ///
140 | /// 写入配置文件
141 | ///
142 | /// 配置文件名
143 | /// 风扇配置
144 | public void WriteCfgFile(string filename, List configParaList)
145 | {
146 | FileAnlyze.WriteCfgFile(filename, configParaList);
147 | }
148 | ///
149 | /// 读取配置文件
150 | ///
151 | /// 配置文件名
152 | /// 风扇配置
153 | public List ReadCfgFile(string filename)
154 | {
155 | return FileAnlyze.ReadCfgFile(filename);
156 | }
157 | ///
158 | /// 智能控制
159 | ///
160 | ///
161 | ///
162 | ///
163 | public bool InteFandutyControl(string filePath, int fanNo)
164 | {
165 | bool state = _inteFandutyControl(filePath, fanNo);
166 | return state;
167 | }
168 |
169 | #region 私有方法
170 | ///
171 | /// 智能调节风扇转速
172 | ///
173 | ///
174 | ///
175 | ///
176 | private bool _inteFandutyControl(string filePath, int fanNo)
177 | {
178 | try
179 | {
180 | IntePara intePara = FileAnlyze.ReadXmlFile(filePath, fanNo);
181 | _setInteFanduty(intePara);
182 | return true;
183 | }
184 | catch
185 | {
186 | return false;
187 | }
188 |
189 | }
190 | ///
191 | /// 智能调节风扇转速
192 | ///
193 | ///
194 | private void _setInteFanduty(IntePara intePara)
195 | {
196 | int[] ecData = GetTempFanDuty(intePara.FanNo);
197 | if (intePara.ControlType == 1)
198 | {
199 | _inteControl(intePara, ecData);
200 | }
201 | else if (intePara.ControlType == 2)
202 | {
203 | _inteControl(intePara, ecData);
204 | }
205 | }
206 | ///
207 | /// 智能控制方案
208 | ///
209 | ///
210 | ///
211 | private void _inteControl(IntePara intePara, int[] ecData)
212 | {
213 | int count = intePara.RangeParaList.Count;//风扇数量
214 | int fanNo = intePara.FanNo;//风扇号
215 | int minFanDuty = _checkFanDuty(intePara.MinFanDuty, 100, 2);//最小转速
216 | for (int i = 0; i < count; i++)
217 | {
218 | RangePara rp = intePara.RangeParaList[i];//当前遍历标签
219 | int fanDuty = 0;//目标转速
220 | if (intePara.ControlType == 1)//方案一
221 | {
222 | fanDuty = _checkFanDuty(rp.FanDuty, 100, 2);
223 | }
224 | else if (intePara.ControlType == 2)//方案二
225 | {
226 | fanDuty = _checkFanDuty(rp.AddPercentage + ecData[0], 100, 2);
227 | }
228 | int inferiorLimit = rp.InferiorLimit;//当前标签温度下限
229 | if (i == 0)
230 | {
231 | //若小于最小温度,设置风扇转速为最小值
232 | if (ecData[0] < inferiorLimit)
233 | {
234 | SetFanduty(intePara.FanNo, _parseFanDuty(minFanDuty), false);
235 | }
236 | else if (_checkLogicalAnd(ecData[0], inferiorLimit, intePara.RangeParaList[i + 1].InferiorLimit))
237 | {
238 | _compareFanDuty(fanNo, minFanDuty, fanDuty);
239 | }
240 | else
241 | {
242 | continue;
243 | }
244 | }
245 | else if (i != count - 1)
246 | {
247 | if (_checkLogicalAnd(ecData[0], inferiorLimit, intePara.RangeParaList[i + 1].InferiorLimit))
248 | {
249 | _compareFanDuty(fanNo, minFanDuty, fanDuty);
250 | }
251 | else
252 | {
253 | continue;
254 | }
255 | }
256 | else if (i == count - 1)
257 | {
258 | if (ecData[0] >= inferiorLimit)
259 | {
260 | _compareFanDuty(fanNo, minFanDuty, fanDuty);
261 | }
262 | }
263 | }
264 | }
265 | ///
266 | /// 风扇转速逻辑判断
267 | ///
268 | ///
269 | ///
270 | ///
271 | ///
272 | private int _checkFanDuty(int first, int second, int op)
273 | {
274 | int output = 0;
275 | switch (op)
276 | {
277 | case 1:
278 | output = first > second ? first : second;
279 | break;
280 | case 2:
281 | output = first > second ? second : first;
282 | break;
283 | default:
284 | break;
285 | }
286 | return output;
287 | }
288 | ///
289 | /// 风扇转速格式转换
290 | ///
291 | ///
292 | ///
293 | private int _parseFanDuty(int fanDuty)
294 | {
295 | return (int)(fanDuty * 2.55m);
296 | }
297 | ///
298 | /// 风扇转速区间判断
299 | ///
300 | ///
301 | ///
302 | ///
303 | private void _compareFanDuty(int fanNo, int minFanDuty, int fanDuty)
304 | {
305 | int duty = _checkFanDuty(minFanDuty, fanDuty, 1);
306 | SetFanduty(fanNo, _parseFanDuty(duty), false);
307 | }
308 | ///
309 | /// 温度区间逻辑判断
310 | ///
311 | ///
312 | ///
313 | ///
314 | ///
315 | private bool _checkLogicalAnd(int a, int b, int c)
316 | {
317 | return a >= b && a < c;
318 | }
319 | ///
320 | /// 更新风扇转速状态
321 | ///
322 | private int[] _updateFanDuty(int fanNo)
323 | {
324 | int[] fanduty = GetTempFanDuty(fanNo);
325 | return fanduty;
326 | }
327 | #endregion
328 | }
329 | }
330 |
--------------------------------------------------------------------------------
/ECViewService/Module/ModuleImpl/FanDutyModifyImpl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using ECView.Tools;
4 | using System.Threading;
5 | using ECView.DataDefinitions;
6 |
7 | namespace ECView.Module.ModuleImpl
8 | {
9 | public class FanDutyModifyImpl : IFanDutyModify
10 | {
11 | ///
12 | /// 设置风扇转速
13 | ///
14 | /// 风扇号
15 | /// 风扇转速
16 | /// 自动调节标识
17 | /// 风扇实际转速
18 | public int[] SetFanduty(int fanNo, int fanduty, bool isAuto)
19 | {
20 | try
21 | {
22 | if (isAuto)
23 | {
24 | //自动调节风扇转速
25 | CallingVariation.SetFANDutyAuto(fanNo);
26 | }
27 | else
28 | {
29 | //将风扇转速设置为定值
30 | CallingVariation.SetFanDuty(fanNo, fanduty);
31 | }
32 | Thread.Sleep(500);
33 | int[] newFanduty = this._updateFanDuty(fanNo);
34 | return newFanduty;
35 | }
36 | catch (Exception e)
37 | {
38 | Console.WriteLine("设置风扇转速错误,原因:" + e.Message);
39 | int[] newFanduty = { -1, -1, -1 };
40 | return newFanduty;
41 | }
42 | }
43 | ///
44 | /// 获取EC版本号
45 | ///
46 | /// EC版本
47 | public string GetECVersion()
48 | {
49 | try
50 | {
51 | string ECVersion = CallingVariation.GetECVersion();
52 | return ECVersion;
53 | }
54 | catch (Exception e)
55 | {
56 | Console.WriteLine("获取EC版本错误,原因:" + e.Message);
57 | return "";
58 | }
59 | }
60 | ///
61 | /// 获取风扇转速与温度数据
62 | ///
63 | /// 转速与温度结构体
64 | public int[] GetTempFanDuty(int fanNo)
65 | {
66 | try
67 | {
68 | var ecData = CallingVariation.GetTempFanDuty(fanNo);
69 | int byteData = ecData.data;
70 | byte[] ec = BitConverter.GetBytes(byteData);
71 | int[] fanduty = { 0, 0, 0 };
72 | fanduty[0] = ec[0];
73 | fanduty[1] = ec[1];
74 | fanduty[2] = (int)Math.Round(ec[2] / 2.55m);
75 | return fanduty;
76 | }
77 | catch (Exception e)
78 | {
79 | Console.WriteLine("获取风扇转速与温度数据错误,原因:" + e.Message);
80 | int[] fanduty = { -1, -1, -1 };
81 | return fanduty;
82 | }
83 | }
84 | ///
85 | /// 获取风扇数量
86 | ///
87 | /// 风扇数量
88 | public int GetFanCount()
89 | {
90 | try
91 | {
92 | int FANCount = CallingVariation.GetFANCounter();
93 | return FANCount;
94 | }
95 | catch (Exception e)
96 | {
97 | Console.WriteLine("获取风扇数量错误,原因:" + e.Message);
98 | return -1;
99 | }
100 | }
101 | ///
102 | /// 检测服务是否启动
103 | ///
104 | /// 服务名称
105 | /// 服务状态
106 | public int CheckServiceState(string serviceName)
107 | {
108 | try
109 | {
110 | int serviceState = ECViewTools.CheckServiceState(serviceName);
111 | return serviceState;
112 | }
113 | catch (Exception e)
114 | {
115 | Console.WriteLine("获取服务状态错误,原因:" + e.Message);
116 | return -1;
117 | }
118 | }
119 | ///
120 | /// 启动服务
121 | ///
122 | /// 服务名称
123 | /// 启动状态
124 | public bool StartService(string serviceName)
125 | {
126 | bool flag = ECViewTools.StartService(serviceName);
127 | return flag;
128 | }
129 | ///
130 | /// 停止服务
131 | ///
132 | /// 服务名称
133 | ///
134 | public bool StopService(string serviceName)
135 | {
136 | bool flag = ECViewTools.StopService(serviceName);
137 | return flag;
138 | }
139 | ///
140 | /// 写入配置文件
141 | ///
142 | /// 配置文件名
143 | /// 风扇配置
144 | public void WriteCfgFile(string filename, List configParaList)
145 | {
146 | FileAnlyze.WriteCfgFile(filename, configParaList);
147 | }
148 | ///
149 | /// 读取配置文件
150 | ///
151 | /// 配置文件名
152 | /// 风扇配置
153 | public List ReadCfgFile(string filename)
154 | {
155 | return FileAnlyze.ReadCfgFile(filename);
156 | }
157 | ///
158 | /// 智能控制
159 | ///
160 | ///
161 | ///
162 | ///
163 | public bool InteFandutyControl(string filePath, int fanNo)
164 | {
165 | bool state = _inteFandutyControl(filePath, fanNo);
166 | return state;
167 | }
168 |
169 | #region 私有方法
170 | ///
171 | /// 智能调节风扇转速
172 | ///
173 | ///
174 | ///
175 | ///
176 | private bool _inteFandutyControl(string filePath, int fanNo)
177 | {
178 | try
179 | {
180 | IntePara intePara = FileAnlyze.ReadXmlFile(filePath, fanNo);
181 | _setInteFanduty(intePara);
182 | return true;
183 | }
184 | catch
185 | {
186 | return false;
187 | }
188 |
189 | }
190 | ///
191 | /// 智能调节风扇转速
192 | ///
193 | ///
194 | private void _setInteFanduty(IntePara intePara)
195 | {
196 | int[] ecData = GetTempFanDuty(intePara.FanNo);
197 | if (intePara.ControlType == 1)
198 | {
199 | _inteControl(intePara, ecData);
200 | }
201 | else if (intePara.ControlType == 2)
202 | {
203 | _inteControl(intePara, ecData);
204 | }
205 | }
206 | ///
207 | /// 智能控制方案
208 | ///
209 | ///
210 | ///
211 | private void _inteControl(IntePara intePara, int[] ecData)
212 | {
213 | int count = intePara.RangeParaList.Count;//风扇数量
214 | int fanNo = intePara.FanNo;//风扇号
215 | int minFanDuty = _checkFanDuty(intePara.MinFanDuty, 100, 2);//最小转速
216 | for (int i = 0; i < count; i++)
217 | {
218 | RangePara rp = intePara.RangeParaList[i];//当前遍历标签
219 | int fanDuty = 0;//目标转速
220 | if (intePara.ControlType == 1)//方案一
221 | {
222 | fanDuty = _checkFanDuty(rp.FanDuty, 100, 2);
223 | }
224 | else if (intePara.ControlType == 2)//方案二
225 | {
226 | fanDuty = _checkFanDuty(rp.AddPercentage + ecData[0], 100, 2);
227 | }
228 | int inferiorLimit = rp.InferiorLimit;//当前标签温度下限
229 | if (i == 0)
230 | {
231 | //若小于最小温度,设置风扇转速为最小值
232 | if (ecData[0] < inferiorLimit)
233 | {
234 | SetFanduty(intePara.FanNo, _parseFanDuty(minFanDuty), false);
235 | }
236 | else if (_checkLogicalAnd(ecData[0], inferiorLimit, intePara.RangeParaList[i + 1].InferiorLimit))
237 | {
238 | _compareFanDuty(fanNo, minFanDuty, fanDuty);
239 | }
240 | else
241 | {
242 | continue;
243 | }
244 | }
245 | else if (i != count - 1)
246 | {
247 | if (_checkLogicalAnd(ecData[0], inferiorLimit, intePara.RangeParaList[i + 1].InferiorLimit))
248 | {
249 | _compareFanDuty(fanNo, minFanDuty, fanDuty);
250 | }
251 | else
252 | {
253 | continue;
254 | }
255 | }
256 | else if (i == count - 1)
257 | {
258 | if (ecData[0] >= inferiorLimit)
259 | {
260 | _compareFanDuty(fanNo, minFanDuty, fanDuty);
261 | }
262 | }
263 | }
264 | }
265 | ///
266 | /// 风扇转速逻辑判断
267 | ///
268 | ///
269 | ///
270 | ///
271 | ///
272 | private int _checkFanDuty(int first, int second, int op)
273 | {
274 | int output = 0;
275 | switch (op)
276 | {
277 | case 1:
278 | output = first > second ? first : second;
279 | break;
280 | case 2:
281 | output = first > second ? second : first;
282 | break;
283 | default:
284 | break;
285 | }
286 | return output;
287 | }
288 | ///
289 | /// 风扇转速格式转换
290 | ///
291 | ///
292 | ///
293 | private int _parseFanDuty(int fanDuty)
294 | {
295 | return (int)(fanDuty * 2.55m);
296 | }
297 | ///
298 | /// 风扇转速区间判断
299 | ///
300 | ///
301 | ///
302 | ///
303 | private void _compareFanDuty(int fanNo, int minFanDuty, int fanDuty)
304 | {
305 | int duty = _checkFanDuty(minFanDuty, fanDuty, 1);
306 | SetFanduty(fanNo, _parseFanDuty(duty), false);
307 | }
308 | ///
309 | /// 温度区间逻辑判断
310 | ///
311 | ///
312 | ///
313 | ///
314 | ///
315 | private bool _checkLogicalAnd(int a, int b, int c)
316 | {
317 | return a >= b && a < c;
318 | }
319 | ///
320 | /// 更新风扇转速状态
321 | ///
322 | private int[] _updateFanDuty(int fanNo)
323 | {
324 | int[] fanduty = GetTempFanDuty(fanNo);
325 | return fanduty;
326 | }
327 | #endregion
328 | }
329 | }
330 |
--------------------------------------------------------------------------------
/ECView/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using ECView.DataDefinitions;
2 | using ECView.Module;
3 | using ECView.Pages.Binding;
4 | using ECView.Pages.Windows;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Management;
8 | using System.Threading;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 | using System.Windows.Input;
13 | using System.Windows.Media;
14 |
15 | namespace ECView
16 | {
17 | ///
18 | /// Interaction logic for MainWindow.xaml
19 | ///
20 | public partial class MainWindow : Window
21 | {
22 | //ECViewService状态
23 | private int status = 0;
24 | private string serviceName = "ECViewService";
25 | //设置行号
26 | private int index;
27 | //主窗口绑定
28 | ECViewBinding ecviewData = null;
29 | //数据列表绑定
30 | ECViewCollec ecviewDataList = null;
31 | //当前工作目录
32 | private string currentDirectory = "";
33 | //线程任务
34 | Task tempGetter = null;
35 | //功能接口
36 | IFanDutyModify iFanDutyModify;
37 | ///
38 | /// 子窗口传参
39 | ///
40 | public ECViewCollec ECViewDataCollec
41 | {
42 | get
43 | {
44 | return ecviewDataList;
45 | }
46 | }
47 | //模具型号
48 | ManagementObjectSearcher Searcher_BaseBoard;
49 | //风扇数量
50 | private int FANCount=0;
51 |
52 | public MainWindow()
53 | {
54 | InitializeComponent();
55 | iFanDutyModify = ModuleFactory.GetFanDutyModifyModule();
56 | //检测服务
57 | CheckService();
58 | //数据绑定
59 | ecviewData = (ECViewBinding)ECViewGrid.DataContext;
60 | ecviewDataList = (ECViewCollec)ECDataGrid.DataContext;
61 | //当前工作目录
62 | currentDirectory = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
63 | //初始化数据
64 | InitECData();
65 | //CPU更新线程
66 | _getTemp_Task();
67 | }
68 | ///
69 | /// 检测服务状态
70 | ///
71 | private void CheckService()
72 | {
73 | status = iFanDutyModify.CheckServiceState(serviceName);
74 | if (status == 0)
75 | {
76 | MessageBox.Show("ECView服务未正确安装,无法使用智能调节。\nECView虽然仍可继续使用,但建议重新安装ECView。", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
77 | }
78 | else if (status == 1)
79 | {
80 | iFanDutyModify.StopService(serviceName);
81 | return;
82 | }
83 | else if (status == 2)
84 | {
85 | MessageBox.Show("ECView服务已关闭。\n当服务设置为手动或已关闭时,无法使用智能调节以及开机自动设定风扇转速等功能。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
86 | }
87 | }
88 | ///
89 | /// 初始化数据
90 | ///
91 | private void InitECData()
92 | {
93 | //判断配置文件是否存在
94 | if (System.IO.File.Exists(currentDirectory + "ecview.cfg"))
95 | {
96 | List configParaList = iFanDutyModify.ReadCfgFile(currentDirectory + "ecview.cfg");
97 | //风扇转速与温度信息
98 | for (int i = 0; i < configParaList.Count; i++)
99 | {
100 | int[] ecData= { 0,0,0 };// = iFanDutyModify.GetTempFanDuty(i + 1);
101 | ecviewData.NbModel = configParaList[0].NbModel;
102 | ecviewData.ECVersion = configParaList[0].ECVersion;
103 | ecviewData.FanNo = i + 1;
104 | foreach (ConfigPara configPara in configParaList)
105 | {
106 | if (ecviewData.FanNo == configPara.FanNo)
107 | {
108 | ecviewData.FanSetModel = configPara.SetMode;
109 | ecviewData.FanSet = configPara.FanSet;
110 | if (configPara.SetMode == 1)
111 | {
112 | //若上次配置为自动调节,设置风扇自动调节
113 | ecData = iFanDutyModify.SetFanduty(configPara.FanNo, 0, true);
114 | }
115 | else if (configPara.SetMode == 2)
116 | {
117 | //若为上次配置手动调节,设置风扇转速
118 | ecData = iFanDutyModify.SetFanduty(configPara.FanNo, (int)(configPara.FanDuty * 2.55m), false);
119 | }
120 | else { }
121 | }
122 | }
123 | ecviewData.CpuRemote = ecData[0] + "℃";
124 | ecviewData.CpuLocal = ecData[1] + "℃";
125 | ecviewData.UpdateFlag = false;
126 | ecviewData.FanDutyStr = ecData[2] + "%";
127 | ecviewData.FanDuty = ecData[2];
128 | ecviewDataList.Add(ecviewData);
129 | }
130 | }
131 | else
132 | {
133 | Searcher_BaseBoard = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_BaseBoard");
134 | //模具型号
135 | ecviewData.NbModel = "当前模具型号为:";
136 | foreach (var baseBoard in Searcher_BaseBoard.Get())
137 | ecviewData.NbModel += Convert.ToString((baseBoard)["Product"]);
138 | //EC版本
139 | ecviewData.ECVersion = "当前EC版本为:1.";
140 | ecviewData.ECVersion += iFanDutyModify.GetECVersion();
141 | //风扇数量
142 | FANCount = iFanDutyModify.GetFanCount();
143 | if (FANCount > 4)
144 | FANCount = 0;
145 | if (FANCount == 0)
146 | FANCount = 1;
147 | //风扇转速与温度信息
148 | for (int i = 0; i < FANCount; i++)
149 | {
150 | int[] ecData = iFanDutyModify.GetTempFanDuty(i + 1);
151 | ecviewData.CpuRemote = ecData[0] + "℃";
152 | ecviewData.CpuLocal = ecData[1] + "℃";
153 | ecviewData.FanDutyStr = ecData[2] + "%";
154 | ecviewData.FanDuty = ecData[2];
155 | ecviewData.FanNo = i + 1;
156 | ecviewData.FanSet = "未设置";
157 | ecviewData.FanSetModel = 0;
158 | ecviewData.UpdateFlag = false;
159 | ecviewDataList.Add(ecviewData);
160 | }
161 | }
162 | }
163 | protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
164 | {
165 | bool isUpdated = false;
166 | foreach (ECViewBinding ec in ecviewDataList)
167 | {
168 | if (ec.UpdateFlag)
169 | {
170 | isUpdated = true;
171 | }
172 | }
173 | if (isUpdated)
174 | {
175 | MessageBoxResult res = MessageBox.Show("保存设置并退出?\n(ECView将在退出时启动ECViewService服务)", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
176 | if (res == MessageBoxResult.OK)
177 | {
178 | SaveConfig();
179 | }
180 | }
181 | if (status != 0)
182 | {
183 | iFanDutyModify.StartService(serviceName);
184 | }
185 | base.OnClosing(e);
186 | }
187 | ///
188 | /// 检测是否更新设置
189 | ///
190 | private void SaveConfig()
191 | {
192 | for (int i = 0; i < ecviewDataList.Count; i++)
193 | {
194 | if (ecviewDataList[i].UpdateFlag)
195 | {
196 | List configParaList = new List();
197 | foreach (ECViewBinding ec in ecviewDataList)
198 | {
199 | ConfigPara configPara = new ConfigPara();
200 | configPara.NbModel = ec.NbModel;
201 | configPara.ECVersion = ec.ECVersion;
202 | configPara.FanNo = ec.FanNo;
203 | configPara.SetMode = ec.FanSetModel;
204 | configPara.FanSet = ec.FanSet;
205 | configPara.FanDuty = ec.FanDuty;
206 | configParaList.Add(configPara);
207 | }
208 | iFanDutyModify.WriteCfgFile(currentDirectory + "ecview.cfg", configParaList);
209 | }
210 | ecviewDataList[i].UpdateFlag = false;
211 | }
212 | }
213 | ////////////////////////////////////////////////////////界面事件////////////////////////////////////////////////////////
214 | ///
215 | /// DataGrid行点击事件
216 | ///
217 | ///
218 | ///
219 | private void ECDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
220 | {
221 | Point aP = e.GetPosition(ECDataGrid);
222 | IInputElement obj = ECDataGrid.InputHitTest(aP);
223 | DependencyObject target = obj as DependencyObject;
224 |
225 | while (target != null)
226 | {
227 | if (target is DataGridRow)
228 | {
229 | break;
230 | }
231 | target = VisualTreeHelper.GetParent(target);
232 | }
233 | if(target != null)
234 | {
235 | _ecEditorLoader(target as DataGridRow);
236 | }
237 | }
238 |
239 | private void _ecEditorLoader(DataGridRow row)
240 | {
241 | //读取选择行的参数
242 | index = row.GetIndex();
243 | ECViewBinding selectFan = (ECViewBinding)row.Item;
244 | int fanduty = iFanDutyModify.GetTempFanDuty(index + 1)[2];
245 | //加载窗体
246 | ECEditor ecWindow = new ECEditor(this, index, fanduty, selectFan.FanSetModel);
247 | ecWindow.ShowDialog();
248 | }
249 | ///
250 | /// 关于提示
251 | ///
252 | ///
253 | ///
254 | private void About_Click(object sender, RoutedEventArgs e)
255 | {
256 | MessageBox.Show("ECView\n版本:" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() +
257 | "\n作者:YcraD\n鸣谢:特别的帅(神舟笔记本吧)\n说明:本程序主要实现Clevo模具风扇转速控制,部分灵感来源于“特别的帅”,在此感谢",
258 | "关于", MessageBoxButton.OK, MessageBoxImage.Information);
259 | }
260 | ///
261 | /// 退出程序
262 | ///
263 | private void _exit()
264 | {
265 | System.Windows.Application.Current.Shutdown();
266 | }
267 | ///
268 | /// CPU温度更新线程
269 | ///
270 | private void _getTemp_Task()
271 | {
272 | tempGetter = new Task(() => { return _tempGetter(); });
273 | tempGetter.Start();
274 | }
275 | ///
276 | /// 更新CPU温度
277 | ///
278 | private int _tempGetter()
279 | {
280 | try
281 | {
282 | while (true)
283 | {
284 | int[] temp = iFanDutyModify.GetTempFanDuty(1);
285 | for (int i = 0; i < ecviewDataList.Count; i++)
286 | {
287 | ecviewDataList[i].FanDuty = iFanDutyModify.GetTempFanDuty(i + 1)[2];
288 | ecviewDataList[i].FanDutyStr = ecviewDataList[i].FanDuty + "%";
289 | }
290 | ecviewData.CpuRemote = temp[0] + "℃";
291 | ecviewData.CpuLocal = temp[1] + "℃";
292 | Thread.Sleep(5000);
293 | }
294 | }
295 | catch
296 | {
297 | return 0;
298 | }
299 | }
300 | }
301 | }
302 |
--------------------------------------------------------------------------------