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.JarUI/JarUI.xaml.cs | 161 +++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 149 insertions(+), 12 deletions(-)
diff --git a/Plugin.JarUI/JarUI.xaml.cs b/Plugin.JarUI/JarUI.xaml.cs
index cdaea7c..2279e7a 100644
--- a/Plugin.JarUI/JarUI.xaml.cs
+++ b/Plugin.JarUI/JarUI.xaml.cs
@@ -14,7 +14,6 @@
using System.IO;
using System.IO.Ports;
using System.Linq;
-using System.Reflection;
using System.Windows;
using System.Windows.Controls;
@@ -29,8 +28,8 @@
{
DataContext = this;
InitializeComponent();
- InitProducts();
InitTsEngine();
+ InitProducts();
}
public override void InitFinish()
@@ -97,8 +96,21 @@
get { return _selectedProduct; }
set
{
- SetTestSeqFile(value);
Set(ref _selectedProduct, value);
+ SetTestSeqFile(value);
+ }
+ }
+
+ private bool _enableMes;
+ public bool EnableMes
+ {
+ get => _enableMes;
+ set
+ {
+ if (WriteConfig("EnableMes", value))
+ {
+ Set(ref _enableMes, value);
+ }
}
}
@@ -156,17 +168,130 @@
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();
}
+ }
+
+ private bool WriteConfig(string name, bool value)
+ {
+ //IniFileHelper.WriteIniData("Config", name, value.ToString(), CountIniPath);
+ try
+ {
+ if (ParameterManager.UpdateCommonParameter(name, value, out string errMsg))
+ {
+ SequenceContext?.StationGlobals.SetValBoolean($"SystemSetting.{name}", 1, value);
+ return true;
+ }
+ else
+ {
+ throw new Exception(errMsg);
+ }
+ }
+ catch (Exception ex)
+ {
+ MsgBoxHelper2.Error(ex.Message);
+ return false;
+ }
+ }
+
+ /// <summary>
+ /// 璇诲彇閰嶇疆鏂囦欢閲岀殑鍑犱釜灞炴��
+ /// </summary>
+ /// <param name="pass"></param>
+ /// <param name="fail"></param>
+ private void ReadConfig()
+ {
+ ParameterData value;
+ try
+ {
+ value = ParameterManager.GetCommonParameterByName("EnableMes");
+ _enableMes = bool.Parse(value.Value);
+ Set("EnableMes");
+ }
+ catch
+ {
+ _enableMes = false;
+ Set("EnableMes");
+ }
+
+ //try
+ //{
+ // value = ParameterManager.GetCommonParameterByName("EnableNGPause");
+ // _enableNGPause = bool.Parse(value.Value);
+ // Set("EnableNGPause");
+ //}
+ //catch
+ //{
+ // _enableNGPause = false;
+ // Set("EnableNGPause");
+ //}
+
+ //try
+ //{
+ // value = ParameterManager.GetCommonParameterByName("EnableCanLog");
+ // _enableCanLog = bool.Parse(value.Value);
+ // Set("EnableCanLog");
+ //}
+ //catch
+ //{
+ // _enableCanLog = false;
+ // Set("EnableCanLog");
+ //}
+
+ //try
+ //{
+ // value = ParameterManager.GetCommonParameterByName("EnableDebugMode");
+ // _enableDebugMode = bool.Parse(value.Value);
+ // Set("EnableDebugMode");
+ //}
+ //catch
+ //{
+ // _enableDebugMode = false;
+ // Set("EnableDebugMode");
+ //}
+
+ //try
+ //{
+ // value = ParameterManager.GetCommonParameterByName("EnableSimpleMode");
+ // EnableSimpleMode = bool.Parse(value.Value);
+ //}
+ //catch
+ //{
+ // EnableSimpleMode = false;
+ //}
+
+ //try
+ //{
+ // value = ParameterManager.GetCommonParameterByName("UI_ShowInfoDock");
+ // UI_ShowInfoDock = bool.Parse(value.Value);
+ //}
+ //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");
+ //}
}
#region 鎵爜鏋浉鍏�
@@ -203,7 +328,10 @@
catch (Exception ex)
{
log.Error("Init Scan Gun Failed.", ex);
- MsgBoxHelper.Error(this, $"{this.lang("Tr.InitGunFailed")}: {ex.StackTrace}");
+ Dispatcher.Invoke(() =>
+ {
+ MsgBoxHelper.Error(this, $"{this.lang("Tr.InitGunFailed")}: {ex.StackTrace}");
+ });
}
}
private string ReadDataFrom(SerialPort sp)
@@ -318,6 +446,7 @@
try
{
SequenceContext?.StationGlobals.SetValBoolean("StationState.StopTest", 1, true);
+ log.Info($"Stop Result: {SequenceContext?.StationGlobals.GetValBoolean("StationState.StopTest", 1)}");
if (this.execution == null) return true;
return this.execution.WaitForEndEx(2000, true, null, null);
}
@@ -343,7 +472,10 @@
catch (Exception ex)
{
log.Error("TsExecution Loaded Failed.", ex);
- MsgBoxHelper.Error(this, $"{LangUtil.Get("Ts.UserControlLoadFailed")}: {ex.Message}");
+ Dispatcher.Invoke(() =>
+ {
+ MsgBoxHelper.Error(this, $"{LangUtil.Get("Ts.UserControlLoadFailed")}: {ex.Message}");
+ });
}
Dispatcher.Invoke(() =>
{
@@ -362,6 +494,8 @@
try
{
if (!isLoadOk) return;
+ 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);
this.execution = this.engine.NewExecution(this.testSeq, "Test UUTs", this.modeSeq, false, 0, null, null, null);
@@ -482,6 +616,9 @@
int index2 = int.Parse(arr2[0]);
this.tsSockets[index2].SetInfo(arr2[1]);
break;
+ case 8:
+ IsRunning = false;
+ break;
default:
break;
}
--
Gitblit v1.9.1