alielie
2026-03-02 12e606635c42ea20f4b7c2bdda5204237a4b4c96
Plugin.TestResult/TestResultView.xaml.cs
@@ -1,8 +1,9 @@
using HMI.Core.Util;
using HMI.Core.Entity;
using HMI.Core.Manager;
using HMI.Core.Util;
using HMI.UI.Util;
using NationalInstruments.TestStand.Interop.API;
using NationalInstruments.TestStand.Interop.UI.Ax;
using NationalInstruments.TestStand.Utility;
using Plugin.TestResult_WPF.Model;
using Plugin.TsSupport;
using System;
@@ -20,11 +21,13 @@
        private int rowCount;
        private int colCount;
        private int cellCount;
        private DataTable[] tables;
        public Dictionary<string, DataTable> nameTables { get; private set; }
        public static DataTable[] tables { get; private set; }
        public static Dictionary<string, DataTable> nameTables { get; private set; } = new Dictionary<string, DataTable>();
        private readonly BaseConfig config;
        public AxApplicationMgr testApp;
        public string testModelFile;
        public string testSeqFile;
        /// <summary>
        /// 测试序列
@@ -48,8 +51,73 @@
        public bool IsRunning { get; set; } = false;
        public void RefreshCooler()
        {
        }
        private void RefreshNumberConfig(BaseConfig config)
        {
            ParameterData value = null;
            try
            {
                value = ParameterManager.GetCommonParameterByName("BurnInOvenCount");
                string[] datas = value.Value.Trim().Split(',');
                config.Row = int.Parse(datas[0]);
                config.Column = int.Parse(datas[1]);
            }
            catch (Exception ex)
            {
            }
            try
            {
                value = ParameterManager.GetCommonParameterByName("BurnInOvenName");
                config.NameStr = value.Value;
            }
            catch (Exception ex)
            {
            }
            try
            {
                value = ParameterManager.GetCommonParameterByName("BurnInOvenPort");
                config.PortStart = int.Parse(value.Value);
            }
            catch (Exception ex)
            {
            }
            try
            {
                value = ParameterManager.GetCommonParameterByName("BurnInCellCount");
                string[] datas = value.Value.Trim().Split(',');
                config.PositionColumn = int.Parse(datas[0]);
                config.PositionCount = int.Parse(datas[1]);
            }
            catch (Exception ex)
            {
            }
        }
        public TestResultView(BaseConfig config)
        {
            try
            {
                var value = ParameterManager.GetCommonParameterByName("TsModelPath");
                testModelFile = value?.Value ?? @"C:\Users\Public\Documents\National Instruments\TestStand 2020 (64-bit)\Components\Models\ParallelModel.seq";
            }
            catch
            {
                //@"C:\Program Files\National Instruments\TestStand 2020\Components\Models\TestStandModels\ParallelModel.seq"
                testModelFile = @"C:\Users\Public\Documents\National Instruments\TestStand 2020 (64-bit)\Components\Models\ParallelModel.seq";
            }
            RefreshNumberConfig(config);
            this.rowCount = config.Row;
            this.colCount = config.Column;
            this.config = config;
@@ -83,6 +151,9 @@
        {
        }
        /// <summary>
        /// 探针计数配置路径
        /// </summary>
        private string CountIniPath;
        public void SetCountIniPath(string countIniPath)
        {
@@ -137,7 +208,7 @@
                this.testApp.IsEditor = true;
                this.testApp.LoginOnStart = false;
                this.testApp.Start();
                this.modeSeq = this.engine.GetSequenceFileEx(@"C:\Program Files\National Instruments\TestStand 2020\Components\Models\TestStandModels\ParallelModel.seq");
                this.modeSeq = this.engine.GetSequenceFileEx(testModelFile);
            }
            catch (Exception ex)
            {
@@ -186,7 +257,7 @@
        private void axApplicationMgr_ExitApplication(object sender, EventArgs e)
        {
            Environment.ExitCode = testApp.ExitCode;
            TSHelper.DoSynchronousGCForCOMObjectDestruction();
            //TSHelper.DoSynchronousGCForCOMObjectDestruction();
        }
        private void axApplicationMgr_ExecutionClosed(object sender, _ApplicationMgrEvents_ExecutionClosedEvent e)
@@ -249,13 +320,19 @@
                    strData = e.uiMsg.StringData;
                    string[] datas_10014 = strData.Split(';');
                    int ovenIndex = int.Parse(datas_10014[0]);
                    string startTime = datas_10014[1];
                    string consumeTime = datas_10014[2];
                    string planEndTime = datas_10014[3];
                    tables[ovenIndex].SetStartTime(startTime);
                    tables[ovenIndex].SetConsumeTime(double.Parse(consumeTime));
                    tables[ovenIndex].SetEndTime(planEndTime);
                    double? leftTime = null;
                    /// 为了兼容旧版本,如果有剩余时间就传,没有就传null
                    if (datas_10014.Length >= 5)
                    {
                        leftTime = double.Parse(datas_10014[4]);
                    }
                    tables[ovenIndex].UpdateConsumeTime(double.Parse(consumeTime), leftTime);
                    return;
                }
                if (MethodCode == 4)
@@ -371,13 +448,16 @@
                    tables[ovenIndex].GetSingleCell(cellIndex).AddElectricData(eData);
                    return;
                }
                if (MethodCode == 14)
                {
                    /// 清空电流和电压数据
                    strData = e.uiMsg.StringData;
                    int ovenIndex = int.Parse(strData);
                    tables[ovenIndex].ClearElectricData();
                    tables[ovenIndex].ClearVData();
                    tables[ovenIndex].ClearCellData();
                    //tables[ovenIndex].ClearElectricData();
                    //tables[ovenIndex].ClearVData();
                    //tables[ovenIndex].ClearWaterData();
                    return;
                }
@@ -395,7 +475,7 @@
                if (MethodCode == 16)
                {
                    /// 添加电压数据
                    /// 添加电压图表数据
                    strData = e.uiMsg.StringData;
                    string[] datas = strData.Split(';');
                    int ovenIndex = int.Parse(datas[0]);
@@ -449,6 +529,20 @@
                    return;
                }
                if (MethodCode == 21)
                {
                    /// 添加水流图表数据
                    strData = e.uiMsg.StringData;
                    string[] datas = strData.Split(';');
                    int ovenIndex = int.Parse(datas[0]);
                    int cellIndex = int.Parse(datas[1]);
                    double waterTemp = double.Parse(datas[2]);
                    double backWaterTemp = double.Parse(datas[3]);
                    double waterPressure = double.Parse(datas[4]);
                    tables[ovenIndex].GetSingleCell(cellIndex).AddWaterData(waterTemp, backWaterTemp, waterPressure);
                    return;
                }
                if (MethodCode == 99)
                {
                    strData = e.uiMsg.StringData;