修改错误,添加硬件监控
This commit is contained in:
commit
df21f7f4cf
7 files changed
+103
-24
No files matched your search
@@ -35,15 +35,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using TouchSocket.Sockets;
|
||||
using static DyeingComputer.UserClass.SqliteHelper;
|
||||
using static DyeingComputer.ViewModel.MainWindowViewModel;
|
||||
using static DyeingComputer.Windows.ViewStep;
|
||||
using static System.Net.WebRequestMethods;
|
||||
using static System.Security.Cryptography.ECCurve;
|
||||
using static System.Windows.Forms.AxHost;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
|
||||
|
||||
using OpenHardwareMonitor.Hardware;
|
||||
|
||||
namespace DyeingComputer.ViewModel
|
||||
{
|
||||
@@ -82,6 +74,7 @@ namespace DyeingComputer.ViewModel
|
||||
public static DataTable errTabler = new DataTable();//错误表
|
||||
// public static DataTable RUN_DATATABLE = new DataTable();//缓存工作表
|
||||
public static DataTable Dyelot_dat = new DataTable();//物料表
|
||||
public static Dictionary<string, object> Hardware =new Dictionary<string, object>();
|
||||
public static string Dyelot; //领料单号
|
||||
public static int RUN_STEPID;//当前步骤
|
||||
public static int SYS_REDYE=0;//当前重燃步
|
||||
@@ -91,7 +84,20 @@ namespace DyeingComputer.ViewModel
|
||||
public static int UserInfoStart = 900;
|
||||
public static string UserInfo;
|
||||
public static bool UserCall_OK = false;
|
||||
public static int ViewID = 0;//页面id
|
||||
public static object Name_err = "";
|
||||
public static object SYSTime = "-----";
|
||||
public static object WorkNumder = "-----";
|
||||
public static object StatusStr = "-----";
|
||||
public static object Process_step = "-----";
|
||||
public static string ProgramName = "-----";//工艺名
|
||||
public static Int32 DIDETime; //空闲计时器
|
||||
public static bool ERR_JOG;//故障状态
|
||||
private int timer1s_ = 0;
|
||||
private int timer5s_ = 0;
|
||||
private int timer60s_ = 0;
|
||||
uint TX_t;//中央连接状态判断
|
||||
|
||||
public ICommand ProgramgroupView_stop { get; }
|
||||
bool _isInteractive;
|
||||
public bool IsInteractive//步骤表交互选择
|
||||
@@ -204,17 +210,16 @@ namespace DyeingComputer.ViewModel
|
||||
get { return program_Name; }
|
||||
set { program_Name = value; OnPropertyChanged("Program_Name"); }
|
||||
}
|
||||
public static int ViewID = 0;//页面id
|
||||
public static object Name_err = "";
|
||||
public static object SYSTime = "-----";
|
||||
public static object WorkNumder = "-----";
|
||||
public static object StatusStr = "-----";
|
||||
public static object Process_step = "-----";
|
||||
public static string ProgramName = "-----";//工艺名
|
||||
public static Int32 DIDETime; //空闲计时器
|
||||
public static bool ERR_JOG;//故障状态
|
||||
private int timer1s_ = 0;
|
||||
private int timer5s_ = 0;
|
||||
|
||||
// 创建 Computer 实例并启用需要的硬件监控
|
||||
Computer computer = new Computer
|
||||
{
|
||||
CPUEnabled = true, // 启用 CPU 监控
|
||||
GPUEnabled = true, // 启用 GPU 监控
|
||||
HDDEnabled = true, // 启用硬盘监控
|
||||
RAMEnabled = true, // 启用内存监控(注意:大多数内存模块无温度传感器:cite[1])
|
||||
MainboardEnabled = true // 启用主板监控
|
||||
};
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
SYSKEY = MD5check.MD5Encrypt16(HardwareSN.GetCPUSerialNumber()+HardwareSN.GetBIOSSerialNumber());
|
||||
@@ -709,6 +714,28 @@ namespace DyeingComputer.ViewModel
|
||||
else { ERRinf.ERRinf_d(errTabler, "ERR110-12"); }
|
||||
}//布轮12检测超时
|
||||
}
|
||||
void Tick_Event_60S()//Tick_Event周期执行事件5S
|
||||
{
|
||||
if(Hardware.Count>0) Hardware.Clear();
|
||||
computer.Open(); // 开始监控
|
||||
|
||||
// 遍历所有硬件设备及其传感器,筛选出温度传感器并读取值
|
||||
foreach (var hardwareItem in computer.Hardware)
|
||||
{
|
||||
hardwareItem.Update(); // 更新硬件信息:cite[2]
|
||||
foreach (var sensor in hardwareItem.Sensors)
|
||||
{
|
||||
if (sensor.SensorType == SensorType.Temperature && sensor.Value.HasValue)
|
||||
{
|
||||
//Console.WriteLine($"{hardwareItem.Name} - {sensor.Name}: {sensor.Value.Value}°C");
|
||||
// 实际应用中,你可能需要将这里的数据绑定到UI控件或存储起来
|
||||
Hardware.Add(sensor.Name, sensor.Value.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
computer.Close(); // 结束监控:cite[1]
|
||||
}
|
||||
void DisTimer_500MS(object sender, EventArgs e)//Tick_Event周期执行事件200MS
|
||||
{
|
||||
if (User_Button)
|
||||
@@ -721,9 +748,11 @@ namespace DyeingComputer.ViewModel
|
||||
|
||||
timer1s_++;
|
||||
timer5s_++;
|
||||
timer60s_++;
|
||||
|
||||
if (timer1s_ >= 2) { timer1s_ =0; Tick_Event_1S(); }
|
||||
if (timer5s_ >=10) { timer5s_ = 0; Tick_Event_5S(); }
|
||||
if (timer60s_ >= 20) { timer60s_ = 0; Tick_Event_60S(); }
|
||||
if (LINK_OK) IO_data();
|
||||
}
|
||||
void Chart()
|
||||
|
||||
Reference in new issue
Block a user