From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点

---
 Plugin.BurnIn/CoolerStatus.xaml.cs |   93 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 93 insertions(+), 0 deletions(-)

diff --git a/Plugin.BurnIn/CoolerStatus.xaml.cs b/Plugin.BurnIn/CoolerStatus.xaml.cs
new file mode 100644
index 0000000..d446edf
--- /dev/null
+++ b/Plugin.BurnIn/CoolerStatus.xaml.cs
@@ -0,0 +1,93 @@
+锘縰sing Panuon.WPF.UI;
+using PLCHelper;
+using System.Timers;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Plugin.BurnIn
+{
+    /// <summary>
+    /// CoolerStatus.xaml 鐨勪氦浜掗�昏緫
+    /// </summary>
+    public partial class CoolerStatus : WindowX
+    {
+        private int ovenIndex;
+        private int columns;
+        private System.Timers.Timer timer;
+        private List<Cooler> coolers = new List<Cooler>();
+
+        public CoolerStatus(int ovenIndex, int columns, string title)
+        {
+            DataContext = this;
+            this.ovenIndex = ovenIndex;
+            this.columns = columns;
+            Title = title;
+            timer = new System.Timers.Timer();
+            timer.Interval = 1000;
+            timer.Elapsed += Timer_Elapsed;
+            InitializeComponent();
+            RefreshUI();
+            RefreshStatus();
+        }
+
+        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
+        {
+            RefreshStatus();
+        }
+
+        private void RefreshStatus()
+        {
+            foreach (var cooler in coolers)
+            {
+                try
+                {
+                    if (S7Context.GetData("", $"Cooler{cooler.index + 1}_Status", out object val))
+                    {
+                        cooler.Dispatcher.Invoke(() =>
+                        {
+                            cooler.Status = (ushort)val;
+                        });
+                    }
+                }
+                catch (Exception ex)
+                {
+
+                }
+            }
+        }
+
+        private void RefreshUI()
+        {
+            mainGrid.Children.Clear();
+            mainGrid.ColumnDefinitions.Clear();
+
+            for (int i = 0; i < this.columns; i++)
+            {
+                ColumnDefinition newCol = new ColumnDefinition();
+                newCol.Width = new GridLength(1, GridUnitType.Star);
+                mainGrid.ColumnDefinitions.Add(newCol);
+                var cooler = new Cooler(ovenIndex * columns + i);
+                Grid.SetColumn(cooler, i);
+                mainGrid.Children.Add(cooler);
+                coolers.Add(cooler);
+            }
+        }
+
+        private void WindowX_Closed(object sender, EventArgs e)
+        {
+            timer.Enabled = false;
+            timer.Dispose();
+
+            foreach (var cooler in coolers)
+            {
+                cooler.Release();
+            }
+        }
+
+        private void WindowX_Loaded(object sender, RoutedEventArgs e)
+        {
+            timer.Enabled = true;
+            this.Loaded -= WindowX_Loaded;
+        }
+    }
+}

--
Gitblit v1.9.1