修改错误,添加硬件监控
This commit is contained in:
commit
df21f7f4cf
7 files changed
+103
-24
No files matched your search
Binary file not shown.
@@ -81,6 +81,9 @@
|
|||||||
<Prefer32Bit>true</Prefer32Bit>
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="OpenHardwareMonitorLib">
|
||||||
|
<HintPath>DLL\OpenHardwareMonitorLib.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
@@ -394,6 +397,7 @@
|
|||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Folder Include="DLL\" />
|
||||||
<Folder Include="Model\" />
|
<Folder Include="Model\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ namespace DyeingComputer.KEY
|
|||||||
private bool isShiftActive = false;
|
private bool isShiftActive = false;
|
||||||
public string KeyValue;
|
public string KeyValue;
|
||||||
public event EventHandler<KeyPressedEventArgs> KeyPressed;
|
public event EventHandler<KeyPressedEventArgs> KeyPressed;
|
||||||
private KeyboardMode currentMode = KeyboardMode.Default;
|
|
||||||
private TextBox targetTextBox;
|
|
||||||
|
|
||||||
public TouchKeyboard()
|
public TouchKeyboard()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ namespace DyeingComputer.UserClass
|
|||||||
{
|
{
|
||||||
// SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
// SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
// SQLiteHelpers.Open(); //打开数据库
|
// SQLiteHelpers.Open(); //打开数据库
|
||||||
int r = 0;
|
|
||||||
string sql_script = "select * from WorkorderSteps where ProgramID = '" + workName + "'";
|
string sql_script = "select * from WorkorderSteps where ProgramID = '" + workName + "'";
|
||||||
// if (TechnologicalProcessView.sql != null) TechnologicalProcessView.sql.Clear(); //清空缓存
|
// if (TechnologicalProcessView.sql != null) TechnologicalProcessView.sql.Clear(); //清空缓存
|
||||||
MainWindowViewModel.dt_TP = MainWindow.SQLiteHelpers.ExecuteDataSet(sql_script, null).Tables[0]; //读取表写入缓存
|
MainWindowViewModel.dt_TP = MainWindow.SQLiteHelpers.ExecuteDataSet(sql_script, null).Tables[0]; //读取表写入缓存
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
xmlns:local="clr-namespace:DyeingComputer.View"
|
xmlns:local="clr-namespace:DyeingComputer.View"
|
||||||
xmlns:lang="clr-namespace:DyeingComputer.Properties"
|
xmlns:lang="clr-namespace:DyeingComputer.Properties"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="500" d:DesignWidth="800">
|
d:DesignHeight="500" d:DesignWidth="1200">
|
||||||
<Grid>
|
<Grid>
|
||||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,50,0,0" x:Name="comboBoxCOM" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="20" IsEditable="True" IsReadOnly="True"/>
|
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,50,0,0" x:Name="comboBoxCOM" VerticalAlignment="Top" Width="200" SelectionChanged="comboBoxCOM_SelectionChanged" FontSize="20" IsEditable="True" IsReadOnly="True"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,50,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Port}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,50,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Port}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||||
@@ -17,6 +17,42 @@
|
|||||||
<TextBlock Name="RX" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="30" Width="100" Margin="5,0,0,0"/>
|
<TextBlock Name="RX" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="30" Width="100" Margin="5,0,0,0"/>
|
||||||
<TextBlock Name="TX" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="30" Width="100" Margin="200,0,0,0"/>
|
<TextBlock Name="TX" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="30" Width="100" Margin="200,0,0,0"/>
|
||||||
|
|
||||||
|
<DataGrid x:Name="_set" AutoGenerateColumns="False" FontSize="15"
|
||||||
|
ColumnHeaderHeight="40" Width="400" HorizontalAlignment="Right" Margin="0,10,10,200" Background="{x:Null}" >
|
||||||
|
<DataGrid.RowStyle >
|
||||||
|
<Style TargetType="{x:Type DataGridRow}">
|
||||||
|
<Setter Property="Height" Value="30" />
|
||||||
|
<Setter Property="FontSize" Value="25" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
|
||||||
|
<Setter Property="Background" Value="#FFFFFFFF" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
|
||||||
|
<Setter Property="Background" Value="#FFF0F0F0" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsMouseOver" Value="False"/>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.RowStyle>
|
||||||
|
<DataGrid.CellStyle>
|
||||||
|
<Style TargetType="DataGridCell">
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="MinWidth" Value="20"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter Property="Background" Value="#FFC0C0C0"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#FFC0C0C0"/>
|
||||||
|
<Setter Property="Foreground" Value="Black"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.CellStyle>
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="Key" Binding="{Binding Key}" Width="*"/>
|
||||||
|
<DataGridTextColumn Header="Type" Binding="{Binding Value}" Width="*"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
|
||||||
<Button Content="{x:Static lang:Resources.Shutdown}" x:Name="Shutdown" FontSize="20" HorizontalAlignment="Right" Height="40" Margin="0,0,10,10"
|
<Button Content="{x:Static lang:Resources.Shutdown}" x:Name="Shutdown" FontSize="20" HorizontalAlignment="Right" Height="40" Margin="0,0,10,10"
|
||||||
VerticalAlignment="Bottom" Width="200" Background="White" Click="Shutdown_Click"/>
|
VerticalAlignment="Bottom" Width="200" Background="White" Click="Shutdown_Click"/>
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,13 @@ namespace DyeingComputer.View
|
|||||||
{
|
{
|
||||||
RX.Text = MainWindowViewModel.RX.ToString();
|
RX.Text = MainWindowViewModel.RX.ToString();
|
||||||
TX.Text = MainWindowViewModel.TX.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)
|
private void Shutdown_Click(object sender, RoutedEventArgs e)
|
||||||
@@ -81,5 +88,11 @@ namespace DyeingComputer.View
|
|||||||
System.Environment.Exit(0);//退出
|
System.Environment.Exit(0);//退出
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AdvancedDictionaryEntry
|
||||||
|
{
|
||||||
|
public string Key { get; set; }
|
||||||
|
public object Value { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,15 +35,7 @@ using System.Windows.Input;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using TouchSocket.Sockets;
|
using TouchSocket.Sockets;
|
||||||
using static DyeingComputer.UserClass.SqliteHelper;
|
using OpenHardwareMonitor.Hardware;
|
||||||
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;
|
|
||||||
|
|
||||||
|
|
||||||
namespace DyeingComputer.ViewModel
|
namespace DyeingComputer.ViewModel
|
||||||
{
|
{
|
||||||
@@ -82,6 +74,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
public static DataTable errTabler = new DataTable();//错误表
|
public static DataTable errTabler = new DataTable();//错误表
|
||||||
// public static DataTable RUN_DATATABLE = new DataTable();//缓存工作表
|
// public static DataTable RUN_DATATABLE = new DataTable();//缓存工作表
|
||||||
public static DataTable Dyelot_dat = 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 string Dyelot; //领料单号
|
||||||
public static int RUN_STEPID;//当前步骤
|
public static int RUN_STEPID;//当前步骤
|
||||||
public static int SYS_REDYE=0;//当前重燃步
|
public static int SYS_REDYE=0;//当前重燃步
|
||||||
@@ -91,7 +84,20 @@ namespace DyeingComputer.ViewModel
|
|||||||
public static int UserInfoStart = 900;
|
public static int UserInfoStart = 900;
|
||||||
public static string UserInfo;
|
public static string UserInfo;
|
||||||
public static bool UserCall_OK = false;
|
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;//中央连接状态判断
|
uint TX_t;//中央连接状态判断
|
||||||
|
|
||||||
public ICommand ProgramgroupView_stop { get; }
|
public ICommand ProgramgroupView_stop { get; }
|
||||||
bool _isInteractive;
|
bool _isInteractive;
|
||||||
public bool IsInteractive//步骤表交互选择
|
public bool IsInteractive//步骤表交互选择
|
||||||
@@ -204,17 +210,16 @@ namespace DyeingComputer.ViewModel
|
|||||||
get { return program_Name; }
|
get { return program_Name; }
|
||||||
set { program_Name = value; OnPropertyChanged("Program_Name"); }
|
set { program_Name = value; OnPropertyChanged("Program_Name"); }
|
||||||
}
|
}
|
||||||
public static int ViewID = 0;//页面id
|
|
||||||
public static object Name_err = "";
|
// 创建 Computer 实例并启用需要的硬件监控
|
||||||
public static object SYSTime = "-----";
|
Computer computer = new Computer
|
||||||
public static object WorkNumder = "-----";
|
{
|
||||||
public static object StatusStr = "-----";
|
CPUEnabled = true, // 启用 CPU 监控
|
||||||
public static object Process_step = "-----";
|
GPUEnabled = true, // 启用 GPU 监控
|
||||||
public static string ProgramName = "-----";//工艺名
|
HDDEnabled = true, // 启用硬盘监控
|
||||||
public static Int32 DIDETime; //空闲计时器
|
RAMEnabled = true, // 启用内存监控(注意:大多数内存模块无温度传感器:cite[1])
|
||||||
public static bool ERR_JOG;//故障状态
|
MainboardEnabled = true // 启用主板监控
|
||||||
private int timer1s_ = 0;
|
};
|
||||||
private int timer5s_ = 0;
|
|
||||||
public MainWindowViewModel()
|
public MainWindowViewModel()
|
||||||
{
|
{
|
||||||
SYSKEY = MD5check.MD5Encrypt16(HardwareSN.GetCPUSerialNumber()+HardwareSN.GetBIOSSerialNumber());
|
SYSKEY = MD5check.MD5Encrypt16(HardwareSN.GetCPUSerialNumber()+HardwareSN.GetBIOSSerialNumber());
|
||||||
@@ -709,6 +714,28 @@ namespace DyeingComputer.ViewModel
|
|||||||
else { ERRinf.ERRinf_d(errTabler, "ERR110-12"); }
|
else { ERRinf.ERRinf_d(errTabler, "ERR110-12"); }
|
||||||
}//布轮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
|
void DisTimer_500MS(object sender, EventArgs e)//Tick_Event周期执行事件200MS
|
||||||
{
|
{
|
||||||
if (User_Button)
|
if (User_Button)
|
||||||
@@ -721,9 +748,11 @@ namespace DyeingComputer.ViewModel
|
|||||||
|
|
||||||
timer1s_++;
|
timer1s_++;
|
||||||
timer5s_++;
|
timer5s_++;
|
||||||
|
timer60s_++;
|
||||||
|
|
||||||
if (timer1s_ >= 2) { timer1s_ =0; Tick_Event_1S(); }
|
if (timer1s_ >= 2) { timer1s_ =0; Tick_Event_1S(); }
|
||||||
if (timer5s_ >=10) { timer5s_ = 0; Tick_Event_5S(); }
|
if (timer5s_ >=10) { timer5s_ = 0; Tick_Event_5S(); }
|
||||||
|
if (timer60s_ >= 20) { timer60s_ = 0; Tick_Event_60S(); }
|
||||||
if (LINK_OK) IO_data();
|
if (LINK_OK) IO_data();
|
||||||
}
|
}
|
||||||
void Chart()
|
void Chart()
|
||||||
|
|||||||
Reference in new issue
Block a user