alielie
2025-06-12 c1c3772a11b1f3fbad8846cc714120771d85fa53
Plugin.TsExecution/TsExecution.xaml.cs
@@ -212,7 +212,6 @@
            }
        }
        public TsExecution()
        {
            DataContext = this;
@@ -283,15 +282,14 @@
                if (!string.IsNullOrEmpty(lastModel))
                {
                    var product = Products.FirstOrDefault(p => p.Name == lastModel);
                    if (product != null) SelectedProduct = product;
                    goto Write;
                    if (product != null)
                    {
                        SelectedProduct = product;
                        RefershUI();
                        return;
                    }
                }
                goto Write;
            Write:
                SelectedProduct = Products[0];
                engine?.Globals.SetValString("StationState.ProductModel", 1, Products[0].Name);
                RefershUI();
            }
            SampleStatus = false;
@@ -461,6 +459,8 @@
            fail = Convert.ToInt32(IniFileHelper.ReadIniData("Count", "Fail", "0", CountIniPath));
        }
        private string csvDir;
        /// <summary>
        /// 读取配置文件里的几个属性
        /// </summary>
@@ -535,6 +535,21 @@
            catch
            {
                UI_ShowInfoDock = false;
            }
            try
            {
                value = ParameterManager.GetCommonParameterByName("TestReportFolder");
                csvDir = value.Value;
                if (!Directory.Exists(csvDir))
                {
                    Directory.CreateDirectory(csvDir);
                }
            }
            catch
            {
                csvDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestReport");
            }
            //Convert.ToBoolean(IniFileHelper.ReadIniData("Config", "EnableMes", "true", CountIniPath));
@@ -647,8 +662,14 @@
            //MaskWindow mask = new MaskWindow();
            try
            {
                engine?.Globals.SetValString("StationState.ProductModel", 1, SelectedProduct?.Name);
                engine?.CommitGlobalsToDisk(promptOnSaveConflicts: false);
                this.modeSeq = this.engine.GetSequenceFileEx(@"C:\Program Files\National Instruments\TestStand 2020\Components\Models\TestStandModels\ParallelModel.seq");
                this.testSeq = this.engine.GetSequenceFileEx(this.testSeqFile, 0, TypeConflictHandlerTypes.ConflictHandler_UseGlobalType);
                //var sb = testSeq.GetSequenceByName("MainSequence");
                //sb.
                this.execution = this.engine.NewExecution(this.testSeq, "Test UUTs", this.modeSeq, false, 0, null, null, null);
                IsTesting = true;
            }
@@ -831,6 +852,15 @@
            this.tsSockets[index].Barcode = barcode;
        }
        public void SavePositionCSV(int index)
        {
            var time = DateTime.Now;
            string status = this.tsSockets[index].Status == "Passed" ? "PASS" : "FAIL";
            string csvPath = Path.Combine(csvDir, SelectedProduct?.Name ?? "未知产品", time.ToString("yyyyMMdd"), status,
                $"{this.tsSockets[index].Barcode}-{time.ToString("HHmmss")}.csv");
            this.tsSockets[index].WriteToCSV(csvPath);
        }
        /// <summary>
        /// TestStand用户交互事件
        /// </summary>
@@ -939,7 +969,7 @@
                        this.tsSockets[Index].SetTestProcess(ProcessVal);
                        break;
                    case 10031://导出CSV
                        this.tsSockets[Index].WriteToCSV(e.uiMsg.StringData);
                        SavePositionCSV(Index);
                        break;
                    case 10032://按下标暂停测试
                        this.tsSockets[Index].ShowPausePanel();