From ef52fd6fd07508883dce4eb002acda59f0169e59 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期四, 23 四月 2026 10:19:33 +0800
Subject: [PATCH] 优化;

---
 Plugin.TestResult/DataTable.xaml.cs |  120 +++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 95 insertions(+), 25 deletions(-)

diff --git a/Plugin.TestResult/DataTable.xaml.cs b/Plugin.TestResult/DataTable.xaml.cs
index 1ac79ce..4be9f27 100644
--- a/Plugin.TestResult/DataTable.xaml.cs
+++ b/Plugin.TestResult/DataTable.xaml.cs
@@ -1,10 +1,13 @@
-锘縰sing HMI.Core.Setting;
+锘縰sing HMI.Base;
+using HMI.Core.Setting;
 using HMI.Core.Util;
+using HMI.LogUtil;
 using HMI.UI.Util;
 using HMI.Util;
 using Plugin.TestResult;
 using Plugin.TestResult.Util;
 using Plugin.TestResult_WPF.Model;
+using Plugin.TsSupport;
 using SuperSocket.SocketBase.Config;
 using SuperSocket.SocketBase.Protocol;
 using System;
@@ -15,6 +18,7 @@
 using System.Timers;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Markup;
 
 namespace Plugin.TestResult_WPF
 {
@@ -88,9 +92,9 @@
             set { RaiseAndSetIfchanged(ref tcpServerInfo, value); }
         }
         public int index { get; private set; }
-        private readonly int cellCount;
+        public readonly int cellCount;
         private readonly string chartTitle;
-        private readonly TestResultView parent;
+        public readonly TestResultView parent;
 
         private BaseConfig config;
         private LiveChart chart;
@@ -137,7 +141,7 @@
             {
                 var cellRow = (i / config.PositionColumn) + 1;
                 var cellCol = (i % config.PositionColumn) + 1;
-                var cellTitle = $"{title}-{cellRow}-{cellCol}";                
+                var cellTitle = $"{title}-{cellRow}-{cellCol}";
 
                 var cell = new SingleCell(this, cellTitle, i, config.CellListMaxSize, countIniPath);
                 mainGrid.Children.Add(cell);
@@ -152,6 +156,7 @@
             testTimeTimer.AutoReset = true;
             testTimeTimer.Elapsed += TestTimeTimer_Elapsed;
             if (!ParamSetting.ShowCoolerSetting) coolerSetting.Visibility = Visibility.Collapsed;
+            if (!ParamSetting.ShowBurnInAbort) abortBtn.Visibility = Visibility.Collapsed;
         }
 
         private void TestTimeTimer_Elapsed(object sender, ElapsedEventArgs e)
@@ -306,13 +311,42 @@
             {
                 if (MsgBoxHelper2.WarnChoose(this.lang("Tr.MakeSureStopOvenTest", title)) == MessageBoxResult.OK)
                 {
+                    LogHelper.Info("UI", $"鑰佸寲鐐塠{title}]鍋滄鎸夐挳鎸変笅", out _);
+                    ViewControl.Logger.Info($"鑰佸寲鐐塠{title}]鍋滄鎸夐挳鎸変笅");
                     parent.SetStartFlag(this.index, false);
                 }
             }
             else
             {
-                ClearChartData();
-                parent.SetStartFlag(this.index, true);
+                /// 妫�鏌ユ槸鍚﹀叧闂�
+                if (parent.executionWrapper?.GetStationGlobalValue<bool>($"StationState.DoorClose[{this.index}]", 0) != true)
+                {
+                    /// 娌″叧闂ㄤ笉鍏佽鍚姩
+                    MsgBoxHelper2.Warn("璇峰厛鍏抽棴鑸遍棬锛�");
+                    return;
+                }
+
+                /// 妫�鏌ユ槸鍚︽湁鏉$爜
+                bool flag = false;
+                foreach (var cell in cells)
+                {
+                    if (!string.IsNullOrEmpty(cell.sn))
+                    {
+                        flag = true;
+                        break;
+                    }
+                }
+                if (flag)
+                {
+                    LogHelper.Info("UI", $"鑰佸寲鐐塠{title}]鍚姩鎸夐挳鎸変笅", out _);
+                    ViewControl.Logger.Info($"鑰佸寲鐐塠{title}]鍚姩鎸夐挳鎸変笅");
+                    ClearChartData();
+                    parent.SetStartFlag(this.index, true);
+                }
+                else
+                {
+                    MsgBoxHelper2.Warn("璇峰厛瀹屾垚鎵爜锛�");
+                }
             }
         }
 
@@ -346,8 +380,9 @@
         private void Scanner_ComplateClick(object sender, RoutedEventArgs e)
         {
             string paramName = $"StationState.Scanner[{index}]";
-            parent.engine.Globals.SetValBoolean(paramName, 1, true);
-            //parent.engine.CommitGlobalsToDisk(promptOnSaveConflicts: false);
+
+            parent.executionWrapper.SetStationGlobalValue<bool>(paramName, 1, true);
+            //parent.engine.Globals.SetValBoolean(paramName, 1, true);
         }
 
         private void Scanner_Closed(object sender, EventArgs e)
@@ -357,7 +392,8 @@
 
         private void Scanner_FinishBarcode(object sender, BarcodeEventArg e)
         {
-            if (parent.SequenceContext == null) return;
+            if (parent.executionWrapper == null) return;
+            //if (parent.SequenceContext == null) return;
 
             int rows = (config.CellCount / config.PositionColumn) + 1;
             CellInfo cellInfo = ScannerParser.GetCellInfoByCode(CbProduct.SelectedItem?.ToString(), mainGrid.Columns, rows, e.positionCode);
@@ -381,9 +417,11 @@
                     throw new Exception(this.lang("Tr.PositionCantClearSNR", oldCellInfo.OriginCode));
                 }
                 // 绉婚櫎鏉$爜
-                parent.engine.Globals.SetValString(oldCellInfo.LookUpStr, 1, "");
-                parent.engine.CommitGlobalsToDisk(promptOnSaveConflicts: false);
+                parent.executionWrapper.SetStationGlobalValue<string>(oldCellInfo.LookUpStr, 1, "");
+                parent.executionWrapper.CommitToDisk(false);
 
+                //parent.engine.Globals.SetValString(oldCellInfo.LookUpStr, 1, "");
+                //parent.engine.CommitGlobalsToDisk(promptOnSaveConflicts: false);
                 oldCell.SetStatus("waiting");
                 oldCell.ClearSN();
                 return;
@@ -397,8 +435,11 @@
             }
 
             // 鍐欏叆鏉$爜
-            parent.engine.Globals.SetValString(LookupStr, 1, snrCode);
-            parent.engine.CommitGlobalsToDisk(promptOnSaveConflicts: false);
+            parent.executionWrapper.SetStationGlobalValue<string>(LookupStr, 1, snrCode);
+            parent.executionWrapper.CommitToDisk(false);
+
+            //parent.engine.Globals.SetValString(LookupStr, 1, snrCode);
+            //parent.engine.CommitGlobalsToDisk(promptOnSaveConflicts: false);
 
             TestResultView.nameTables[cellInfo.OvenName].GetSingleCell(cellInfo.Index).SetStatus("hadCode");
             TestResultView.nameTables[cellInfo.OvenName].GetSingleCell(cellInfo.Index).sn = snrCode;
@@ -532,8 +573,6 @@
             string strs = datas_10015[2];
             string[] values = strs.Split(',');
 
-            //string step = datas_10015[2];
-            //string result = datas_10015[3];
             GetSingleCell(cellIndex).SetInfos(new Info
             {
                 step = values[0],
@@ -747,10 +786,10 @@
 
         private void ClearAllSnr_Click(object sender, RoutedEventArgs e)
         {
-            var str = $"StationState.DoorClose[{index}]";
-            if (parent.engine.Globals.GetValBoolean(str, 0) == true)
+            if (parent.executionWrapper?.GetStationGlobalValue<bool>($"StationState.DoorClose[{this.index}]", 0) == true)
             {
-                MsgBoxHelper.Error(Window.GetWindow(this), this.lang("Tr.CantClearSNR"));
+                /// 鍏抽棬浜嗗氨涓嶅厑璁告竻鏉$爜
+                MsgBoxHelper2.Warn(this.lang("Tr.CantClearSNR"));
                 return;
             }
 
@@ -779,8 +818,7 @@
 
         public void TryClearCellSN(int cellIndex)
         {
-            var str = $"StationState.DoorClose[{this.index}]";
-            if (parent.engine.Globals.GetValBoolean(str, 0) == true)
+            if (parent.executionWrapper?.GetStationGlobalValue<bool>($"StationState.DoorClose[{this.index}]", 0) == true)
             {
                 MsgBoxHelper.Error(Window.GetWindow(this), this.lang("Tr.CantClearSNR"));
                 return;
@@ -795,18 +833,50 @@
             string LookupStr = $"StationState.SN[{dutNo}]";
             var lastSN = cell.sn;
             cell.SetStatus("waiting");
-            parent.engine.Globals.SetValString(LookupStr, 1, "");
-            parent.engine.CommitGlobalsToDisk(promptOnSaveConflicts: false);
+
+            parent.executionWrapper.SetStationGlobalValue<string>(LookupStr, 1, "");
+            parent.executionWrapper.CommitToDisk(false);
+
+            //parent.engine.Globals.SetValString(LookupStr, 1, "");
+            //parent.engine.CommitGlobalsToDisk(promptOnSaveConflicts: false);
             if (!string.IsNullOrEmpty(lastSN)) Scanner.RemoveSNR(lastSN);
             cell.ClearSN();
         }
 
-        private void Button_Click_2(object sender, RoutedEventArgs e)
+        private void Abort_Click(object sender, RoutedEventArgs e)
         {
-            if (MsgBoxHelper.WarnMessage(Window.GetWindow(this), this.lang("Tr.MakeSureStopOvenTest", title)) == MessageBoxResult.OK)
+            if (!parent.IsRunning)
             {
-                parent.SetStartFlag(this.index, false);
+                MsgBoxHelper.WarnMessage(this, this.lang("Tr.StartSeqFirst"), null, MessageBoxButton.OK);
+                return;
             }
+
+
+
+
+            string key = $"StationState.Start[{this.index}]";
+            //if (parent.executionWrapper?.GetStationGlobalValue<bool>(key, 0) == true)
+            //{
+            //    MsgBoxHelper2.Warn("娴嬭瘯鍚姩涓紝涓嶅厑璁窤bort");
+            //    return;
+            //}
+            var win = new RequirePasswordByUser("admin")
+            {
+                Owner = Window.GetWindow(this)
+            };
+            if (win.ShowDialog() != true)
+            {
+                return;
+            }
+
+            if (MsgBoxHelper2.WarnChoose("璇风‘璁よ�佸寲浠撳湪瀹夊叏娓╁害锛屾按鍐锋満鍚规按瀹屾垚锛屽崟鍑籓K鎸夐挳浠撲綅鍥炲埌鍒濆鍖栫姸鎬�") != MessageBoxResult.OK)
+            {
+                return;
+            }
+            LogHelper.Info("UI", "Abort鎸夐挳鎸変笅", out _);
+            ViewControl.Logger.Info("Abort鎸夐挳鎸変笅");
+            key = $"StationState.Abort[{this.index}]";
+            parent.executionWrapper?.SetStationGlobalValue(key, 0, true);
         }
     }
 }

--
Gitblit v1.9.1