From 559890c482f5973f06aafdfec9550fee5ba3c7f2 Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 09 十一月 2026 17:02:15 +0800
Subject: [PATCH] feat: CAN 模拟器 TCP 化 + 多设备并发调试 + 后台生命周期管理
---
Plugin.TestResult/SingleCell.xaml.cs | 40 +++++++++++++++++++++++++++++-----------
1 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/Plugin.TestResult/SingleCell.xaml.cs b/Plugin.TestResult/SingleCell.xaml.cs
index b9a6ab0..0e7a8b9 100644
--- a/Plugin.TestResult/SingleCell.xaml.cs
+++ b/Plugin.TestResult/SingleCell.xaml.cs
@@ -297,6 +297,17 @@
private string visualTestId;
private Sqlite3Helper helper;
+ private void InitCurrentTestHelper()
+ {
+ if (helper == null)
+ {
+ var now = DateTime.Now;
+ string dateStr = now.ToString("yyyyMMdd");
+ visualTestId = $"{title}_{now.ToString("yyyyMMddHHmmssfff")}";
+ helper = CheckSqlHelper(dateStr);
+ }
+ }
+
public void SetStatus(string status)
{
Dispatcher.Invoke(() =>
@@ -306,11 +317,8 @@
if (oldStatus != "testing" && status == "testing")
{
UpdateProbeCount(ProbeCount + 1);
- var now = DateTime.Now;
- string dateStr = now.ToString("yyyyMMdd");
- visualTestId = $"{title}_{now.ToString("yyyyMMddHHmmssfff")}";
- helper = CheckSqlHelper(dateStr);
- InsertARecourd();
+ InitCurrentTestHelper();
+ InsertARecord();
}
if (oldStatus != "ok" && status == "ok")
@@ -325,7 +333,7 @@
});
}
- private void InsertARecourd()
+ private void InsertARecord()
{
try
{
@@ -336,7 +344,7 @@
}
catch (Exception ex)
{
- ViewControl.Logger.Error($"Cell[{title}] SaveToDB Error.", ex);
+ ViewControl.Logger.Error($"Cell[{title}] InsertARecord Error.", ex);
}
}
@@ -457,6 +465,7 @@
try
{
+ InitCurrentTestHelper();
string model = table?.CbProduct?.SelectedItem?.ToString();
sql = $@"INSERT INTO serialData (sn,model,station,position,step,limitDown,limitUp,unit,value,status,finalStatus,time,resultId)
VALUES ('{sn}','{model}','','{this.title}','{info.step}','{info.limitDown}','{info.limitUp}','{info.unit}','{info.value}','{info.result}',
@@ -992,7 +1001,7 @@
/// <param name="filePath"></param>
public void SaveInfoToDB()
{
- Dispatcher.BeginInvoke(new Action(() =>
+ Dispatcher.Invoke(() =>
{
try
{
@@ -1021,7 +1030,7 @@
{
ViewControl.Logger.Error($"Cell[{title}] SaveToDB Error.", ex);
}
- }));
+ });
}
private void MenuItem_Click(object sender, RoutedEventArgs e)
@@ -1093,8 +1102,17 @@
public bool LightGreen(bool on, out string msg)
{
- return S7Context.WriteData(RunTimeVariablePool.DEFAULT_PLC_NAME,
- $"Oven{table.index + 1}_Cell{index + 1}_Light_OK", on, out msg);
+ string key = $"Oven{table.index + 1}_Cell{index + 1}_Light_OK";
+ bool res = S7Context.WriteData(RunTimeVariablePool.DEFAULT_PLC_NAME, key, on, out msg);
+ if (res)
+ {
+ ViewControl.Logger.Debug($"Set Light [{key}] {on}.");
+ }
+ else
+ {
+ ViewControl.Logger.Debug($"Open Light [{key}] {on} Error.{msg}");
+ }
+ return res;
}
public bool LightRed(bool on, out string msg)
--
Gitblit v1.9.1