alielie
2026-04-23 ef52fd6fd07508883dce4eb002acda59f0169e59
Plugin.TestResult/DataTable.xaml.cs
@@ -1,10 +1,13 @@
using HMI.Core.Setting;
using 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("测试启动中,不允许Abort");
            //    return;
            //}
            var win = new RequirePasswordByUser("admin")
            {
                Owner = Window.GetWindow(this)
            };
            if (win.ShowDialog() != true)
            {
                return;
            }
            if (MsgBoxHelper2.WarnChoose("请确认老化仓在安全温度,水冷机吹水完成,单击OK按钮仓位回到初始化状态") != MessageBoxResult.OK)
            {
                return;
            }
            LogHelper.Info("UI", "Abort按钮按下", out _);
            ViewControl.Logger.Info("Abort按钮按下");
            key = $"StationState.Abort[{this.index}]";
            parent.executionWrapper?.SetStationGlobalValue(key, 0, true);
        }
    }
}