From fe2aa4880d5c9fd88088ad0ed81ebaca05629f5f Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 17:59:45 +0800
Subject: [PATCH] feat: 集成CAN驱动/模拟器 + 仪器仪表注册/硬件调试模块

---
 Plugin.TestResult/DataTable.xaml.cs |  107 ++++++++++++++++++++++++++++++-----------------------
 1 files changed, 61 insertions(+), 46 deletions(-)

diff --git a/Plugin.TestResult/DataTable.xaml.cs b/Plugin.TestResult/DataTable.xaml.cs
index 4be9f27..bcff8ec 100644
--- a/Plugin.TestResult/DataTable.xaml.cs
+++ b/Plugin.TestResult/DataTable.xaml.cs
@@ -319,7 +319,7 @@
             else
             {
                 /// 妫�鏌ユ槸鍚﹀叧闂�
-                if (parent.executionWrapper?.GetStationGlobalValue<bool>($"StationState.DoorClose[{this.index}]", 0) != true)
+                if (!GetDoorClose(parent.executionWrapper))
                 {
                     /// 娌″叧闂ㄤ笉鍏佽鍚姩
                     MsgBoxHelper2.Warn("璇峰厛鍏抽棴鑸遍棬锛�");
@@ -390,6 +390,11 @@
             scanner = null;
         }
 
+        public bool GetDoorClose(ITestExecutionWrapper wrapper)
+        {
+            return wrapper?.GetStationGlobalValue<bool>($"StationState.DoorClose[{this.index}]", 0) == true;
+        }
+
         private void Scanner_FinishBarcode(object sender, BarcodeEventArg e)
         {
             if (parent.executionWrapper == null) return;
@@ -399,19 +404,37 @@
             CellInfo cellInfo = ScannerParser.GetCellInfoByCode(CbProduct.SelectedItem?.ToString(), mainGrid.Columns, rows, e.positionCode);
             string positionCode = e.positionCode, snrCode = e.snrCode;
 
-            //灏嗚鍒扮殑鏉$爜鍐欏叆鍒癝N涓�
-            int dutNo = this.index * this.cellCount + cellInfo.Index;
+            //if (cellInfo.OvenName != this.title)
+            //{
+            //    MsgBoxHelper2.Warn($"璇峰垏鎹㈣嚦 [{cellInfo.OvenName}] 鍖烘壂鐮侊紝褰撳墠涓� [{this.title}] 鍖猴紒");
+            //    return;
+            //}
 
+
+            var targetTable = TestResultView.nameTables[cellInfo.OvenName];
+
+            //灏嗚鍒扮殑鏉$爜鍐欏叆鍒癝N涓�
+            int dutNo = targetTable.index * targetTable.cellCount + cellInfo.Index;
             string LookupStr = $"StationState.SN[{dutNo}]";
             cellInfo.LookUpStr = LookupStr;
 
-            ViewControl.Logger.Debug($"PositionCode: [{e.positionCode}], SNR: [{e.snrCode}], LookUpStr: [{LookupStr}]");
-            ViewControl.Logger.Debug($"OvenName: [{cellInfo.OvenName}], CellIndex: [{cellInfo.Index}]");
-            var cell = TestResultView.nameTables[cellInfo.OvenName].GetSingleCell(cellInfo.Index);
+            ViewControl.Logger.Info($"PositionCode: [{e.positionCode}], SNR: [{e.snrCode}], LookUpStr: [{LookupStr}]");
+            ViewControl.Logger.Info($"OvenName: [{cellInfo.OvenName}], CellIndex: [{cellInfo.Index}]");
+            var cell = targetTable.GetSingleCell(cellInfo.Index);
+
+            if (targetTable.GetDoorClose(parent.executionWrapper))
+            {
+                /// 鍏抽棬浜嗗氨涓嶅厑璁告竻鏉$爜
+                MsgBoxHelper2.Warn($"{targetTable.title}鐐夌敓浜т腑锛屼笉鍏佽鎿嶄綔鏉$爜");
+                //MsgBoxHelper2.Warn(this.lang("Tr.CantClearSNR"));
+                return;
+            }
+
             if (snrCode == null)
             {
                 var oldCellInfo = e.lastInfo;
-                var oldCell = TestResultView.nameTables[oldCellInfo.OvenName].GetSingleCell(oldCellInfo.Index);
+                var oldTable = TestResultView.nameTables[oldCellInfo.OvenName];
+                var oldCell = oldTable.GetSingleCell(oldCellInfo.Index);
                 if (oldCell.status != "hadCode")
                 {
                     throw new Exception(this.lang("Tr.PositionCantClearSNR", oldCellInfo.OriginCode));
@@ -441,18 +464,10 @@
             //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;
+            cell.SetStatus("hadCode");
+            cell.sn = snrCode;
             Scanner.InsertNewCode(snrCode, cellInfo);
-            var light = $"Oven{this.index + 1}_Cell{cell.index + 1}_Light_OK";
-            if (cell.LightGreen(true, out string msg))
-            {
-                ViewControl.Logger.Debug($"Open Light [{light}] ON.");
-            }
-            else
-            {
-                ViewControl.Logger.Debug($"Open Light [{light}] Error.{msg}");
-            }
+            cell.LightGreen(true, out string msg);            
         }
 
 
@@ -572,16 +587,18 @@
 
             string strs = datas_10015[2];
             string[] values = strs.Split(',');
-
-            GetSingleCell(cellIndex).SetInfos(new Info
+            Dispatcher.Invoke(() =>
             {
-                step = values[0],
-                value = values[1],
-                limitUp = values[2],
-                limitDown = values[3],
-                unit = values[4],
-                result = values[5],
-                updateTime = values[6]
+                GetSingleCell(cellIndex).SetInfos(new Info
+                {
+                    step = values[0],
+                    value = values[1],
+                    limitUp = values[2],
+                    limitDown = values[3],
+                    unit = values[4],
+                    result = values[5],
+                    updateTime = values[6]
+                });
             });
             //session.Send("1");
         }
@@ -590,17 +607,18 @@
         {
             infoTable.UpdateNumber(infoTable.okCount + ok, infoTable.ngCount + ng);
 
-            if (ParamSetting.ProbeByModel)
-            {
+            //if (ParamSetting.ProbeByModel)
+            //{
 
-            }
-            else
-            {
-                IniFileHelper.WriteIniData($"Oven_{index}", "Pass", infoTable.okCount.ToString(),
-                   this.CountIniPath);
-                IniFileHelper.WriteIniData($"Oven_{index}", "Fail", infoTable.ngCount.ToString(),
-                    this.CountIniPath);
-            }
+            //}
+            //else
+            //{
+
+            //}
+            IniFileHelper.WriteIniData($"Oven_{index}", "Pass", infoTable.okCount.ToString(),
+                  this.CountIniPath);
+            IniFileHelper.WriteIniData($"Oven_{index}", "Fail", infoTable.ngCount.ToString(),
+                this.CountIniPath);
         }
 
         /// <summary>
@@ -786,7 +804,7 @@
 
         private void ClearAllSnr_Click(object sender, RoutedEventArgs e)
         {
-            if (parent.executionWrapper?.GetStationGlobalValue<bool>($"StationState.DoorClose[{this.index}]", 0) == true)
+            if (GetDoorClose(parent.executionWrapper))
             {
                 /// 鍏抽棬浜嗗氨涓嶅厑璁告竻鏉$爜
                 MsgBoxHelper2.Warn(this.lang("Tr.CantClearSNR"));
@@ -818,7 +836,7 @@
 
         public void TryClearCellSN(int cellIndex)
         {
-            if (parent.executionWrapper?.GetStationGlobalValue<bool>($"StationState.DoorClose[{this.index}]", 0) == true)
+            if (GetDoorClose(parent.executionWrapper))
             {
                 MsgBoxHelper.Error(Window.GetWindow(this), this.lang("Tr.CantClearSNR"));
                 return;
@@ -851,10 +869,7 @@
                 return;
             }
 
-
-
-
-            string key = $"StationState.Start[{this.index}]";
+            //string key = $"StationState.Start[{this.index}]";
             //if (parent.executionWrapper?.GetStationGlobalValue<bool>(key, 0) == true)
             //{
             //    MsgBoxHelper2.Warn("娴嬭瘯鍚姩涓紝涓嶅厑璁窤bort");
@@ -873,9 +888,9 @@
             {
                 return;
             }
-            LogHelper.Info("UI", "Abort鎸夐挳鎸変笅", out _);
-            ViewControl.Logger.Info("Abort鎸夐挳鎸変笅");
-            key = $"StationState.Abort[{this.index}]";
+            LogHelper.Info("UI", $"{title} Abort鎸夐挳鎸変笅", out _);
+            ViewControl.Logger.Info($"{title} Abort鎸夐挳鎸変笅");
+            string key = $"StationState.Abort[{this.index}]";
             parent.executionWrapper?.SetStationGlobalValue(key, 0, true);
         }
     }

--
Gitblit v1.9.1