diff --git a/DLL/OpenHardwareMonitorLib.dll b/DLL/OpenHardwareMonitorLib.dll
new file mode 100644
index 0000000..0adc888
Binary files /dev/null and b/DLL/OpenHardwareMonitorLib.dll differ
diff --git a/DyeingComputer.csproj b/DyeingComputer.csproj
index 9cf81eb..be997fd 100644
--- a/DyeingComputer.csproj
+++ b/DyeingComputer.csproj
@@ -81,6 +81,9 @@
true
+
+ DLL\OpenHardwareMonitorLib.dll
+
@@ -394,6 +397,7 @@
+
diff --git a/KEY/TouchKeyboard.xaml.cs b/KEY/TouchKeyboard.xaml.cs
index 2239905..0b6ff7c 100644
--- a/KEY/TouchKeyboard.xaml.cs
+++ b/KEY/TouchKeyboard.xaml.cs
@@ -23,8 +23,6 @@ namespace DyeingComputer.KEY
private bool isShiftActive = false;
public string KeyValue;
public event EventHandler KeyPressed;
- private KeyboardMode currentMode = KeyboardMode.Default;
- private TextBox targetTextBox;
public TouchKeyboard()
{
diff --git a/UserClass/SQLDATA.cs b/UserClass/SQLDATA.cs
index e976b1d..c8ff6b5 100644
--- a/UserClass/SQLDATA.cs
+++ b/UserClass/SQLDATA.cs
@@ -74,7 +74,6 @@ namespace DyeingComputer.UserClass
{
// SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
// SQLiteHelpers.Open(); //打开数据库
- int r = 0;
string sql_script = "select * from WorkorderSteps where ProgramID = '" + workName + "'";
// if (TechnologicalProcessView.sql != null) TechnologicalProcessView.sql.Clear(); //清空缓存
MainWindowViewModel.dt_TP = MainWindow.SQLiteHelpers.ExecuteDataSet(sql_script, null).Tables[0]; //读取表写入缓存
diff --git a/View/EngineerSetView.xaml b/View/EngineerSetView.xaml
index 8098e56..66087c7 100644
--- a/View/EngineerSetView.xaml
+++ b/View/EngineerSetView.xaml
@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:DyeingComputer.View"
xmlns:lang="clr-namespace:DyeingComputer.Properties"
mc:Ignorable="d"
- d:DesignHeight="500" d:DesignWidth="800">
+ d:DesignHeight="500" d:DesignWidth="1200">
@@ -17,6 +17,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/View/EngineerSetView.xaml.cs b/View/EngineerSetView.xaml.cs
index 2fbfd44..3aec001 100644
--- a/View/EngineerSetView.xaml.cs
+++ b/View/EngineerSetView.xaml.cs
@@ -69,6 +69,13 @@ namespace DyeingComputer.View
{
RX.Text = MainWindowViewModel.RX.ToString();
TX.Text = MainWindowViewModel.TX.ToString();
+
+ var displayData = MainWindowViewModel.Hardware.Select(kvp => new AdvancedDictionaryEntry
+ {
+ Key = kvp.Key,
+ Value = kvp.Value
+ }).ToList();
+ _set.ItemsSource = displayData;
}
private void Shutdown_Click(object sender, RoutedEventArgs e)
@@ -81,5 +88,11 @@ namespace DyeingComputer.View
System.Environment.Exit(0);//退出
}
}
+
+ public class AdvancedDictionaryEntry
+ {
+ public string Key { get; set; }
+ public object Value { get; set; }
+ }
}
}
diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs
index d522ebd..0473a13 100644
--- a/ViewModel/MainWindowViewModel.cs
+++ b/ViewModel/MainWindowViewModel.cs
@@ -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 Hardware =new Dictionary();
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()