wenxiangchao
2026-11-02 9d1660270272180cd71147d6ddd53d1382643d2e
Plugin.TsExecution/SingleControl.xaml.cs
@@ -2,10 +2,9 @@
using HMI.Core.Manager;
using HMI.Core.Setting;
using HMI.Core.Util;
using HMI.UI.Util;
using HMI.Util;
using NationalInstruments.TestStand.Interop.API;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using Plugin.TsExecution.Entity;
using System;
using System.Collections.Generic;
@@ -16,6 +15,7 @@
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using Util.ManualDebug;
namespace Plugin.TsExecution
{
@@ -64,6 +64,8 @@
                Set(ref totalNum, value);
            }
        }
        public TsExecution parent { get; set; }
        private int passNum;
        public int PassNum
@@ -180,6 +182,16 @@
            set
            {
                Set(ref _probeCount, value);
                try
                {
                    if (ProbeWarn <= 0) probeCountAlarm.Visibility = Visibility.Collapsed;
                    else if (value >= ProbeWarn) probeCountAlarm.Visibility = Visibility.Visible;
                    else probeCountAlarm.Visibility = Visibility.Collapsed;
                }
                catch
                {
                }
            }
        }
@@ -222,7 +234,15 @@
            }
        }
        public int ProbeWarn { get; private set; }
        private int _probeWarn;
        public int ProbeWarn
        {
            get => _probeWarn;
            private set
            {
                Set(ref _probeWarn, value);
            }
        }
        private bool isAutoMode;
        public bool IsAutoMode
@@ -246,13 +266,13 @@
                Interval = 100
            };
            refreshTimer.Elapsed += RefreshTimer_Elapsed;
            RefreshProbeCount(null);
            ReadCounter();
            InitializeComponent();
            RefreshProbeCount(null);
            try
            {
                var value = ParameterManager.GetCommonParameterByName("AutoTestMode");
                IsAutoMode = bool.Parse(value.Value);
                IsAutoMode = value == null ? true : bool.Parse(value.Value);
            }
            catch
            {
@@ -354,7 +374,10 @@
        public void IniTestData()
        {
            Datasource.Clear();
            Dispatcher.Invoke(() =>
            {
                Datasource.Clear();
            });
        }
        /// <summary>
@@ -545,7 +568,7 @@
        private void SendSnr2Ts()
        {
        }
        private void pausePanel_Loaded(object sender, RoutedEventArgs e)
@@ -653,10 +676,6 @@
            /// 写到配置文件
            IniFileHelper.WriteIniData("Socket" + this.index.ToString(), "ProbeCount", count.ToString(), this.CountIniPath);
            ProbeCount = count;
            //if (ProbeWarn <= 0) probeCountAlarm.Visibility = Visibility.Collapsed;
            //else if (count >= ProbeWarn) probeCountAlarm.Visibility = Visibility.Visible;
            //else probeCountAlarm.Visibility = Visibility.Collapsed;
        }
        public void RefreshProduct(ProductData product)
@@ -720,5 +739,57 @@
                }.ShowDialog();
            }
        }
        private void control_PreviewMouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (parent.EnableManualDebug)
            {
                ContextMenu contextMenu = new ContextMenu();
                contextMenu.Closed += ContextMenu_Closed;
                var item = new MenuItem
                {
                    IsCheckable = false,
                    Name = "manualDebugItem",
                    Header = this.lang("手动调试"),
                };
                item.Click += Item_Click; ;
                contextMenu.Items.Add(item);
                this.ContextMenu = contextMenu;
            }
            else
            {
                this.ContextMenu = null;
            }
        }
        private void Item_Click(object sender, RoutedEventArgs e)
        {
            string manualDebugSeq = ParameterManager.GetCommonParameterByName("ManualDebugSeqPath")?.Value;
            if (string.IsNullOrEmpty(manualDebugSeq))
            {
                MsgBoxHelper2.Error("请先设置手动调试序列路径[ManualDebugSeqPath]!");
                return;
            }
            string modelPath = parent.tsModelPath;
            var win = new ManualDebugWindow(manualDebugSeq, modelPath, false)
            {
                Title = $"工位{this.index}手动调试",
                Owner = Window.GetWindow(this),
                OvenIndex = 0,
                OvenName = "",
                CellCount = parent.tsSockets.Count,
                CellIndex = this.index,
                CellName = "",
            };
            win.ShowDialog();
        }
        private void ContextMenu_Closed(object sender, RoutedEventArgs e)
        {
            this.ContextMenu = null;
        }
    }
}