From 771a0e7b6b1276087515bbe94de28358cb92963b Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期四, 04 六月 2026 10:32:27 +0800
Subject: [PATCH] 优化老化;
---
Plugin.TsExecution/SingleControl.xaml.cs | 136 ++++++++++++++++++++++++++++++---------------
1 files changed, 90 insertions(+), 46 deletions(-)
diff --git a/Plugin.TsExecution/SingleControl.xaml.cs b/Plugin.TsExecution/SingleControl.xaml.cs
index 3e3c21a..373fcd4 100644
--- a/Plugin.TsExecution/SingleControl.xaml.cs
+++ b/Plugin.TsExecution/SingleControl.xaml.cs
@@ -1,14 +1,17 @@
锘縰sing HMI.Core.Entity;
using HMI.Core.Manager;
+using HMI.Core.Setting;
using HMI.Core.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;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
-using System.Linq;
using System.Runtime.CompilerServices;
using System.Timers;
using System.Windows;
@@ -243,7 +246,7 @@
Interval = 100
};
refreshTimer.Elapsed += RefreshTimer_Elapsed;
- ReadProbeCount();
+ RefreshProbeCount(null);
ReadCounter();
InitializeComponent();
try
@@ -397,37 +400,6 @@
this.WriteCounter();
}
- /// <summary>
- /// 浠巌ni璇诲彇鎺㈤拡浣跨敤娆℃暟
- /// </summary>
- private void ReadProbeCount()
- {
- try
- {
- var num = IniFileHelper.ReadIniData("Socket" + this.index.ToString(), "ProbeCount", "0", this.CountIniPath);
- this.ProbeCount = int.Parse(num);
- }
- catch (Exception ex)
- {
- this.ProbeCount = 0;
- }
- }
-
- /// <summary>
- /// 鏇存柊鎺㈤拡浣跨敤娆℃暟
- /// </summary>
- /// <param name="count"></param>
- private void UpdateProbeCount(int count)
- {
- /// 鍐欏埌閰嶇疆鏂囦欢
- 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;
- }
-
private void WriteCounter()
{
IniFileHelper.WriteIniData("Socket" + this.index.ToString(), "Pass",
@@ -456,9 +428,48 @@
this.UpdateTestCounter(null);
}
+ public void WriteToExcel(string path)
+ {
+ Dispatcher.Invoke(() =>
+ {
+ try
+ {
+ string suffix = Path.GetExtension(path);
+ if (!string.Equals(".xlsx", suffix, StringComparison.OrdinalIgnoreCase) &&
+ !string.Equals(".xls", suffix, StringComparison.OrdinalIgnoreCase))
+ {
+ path = path.Replace(suffix, ".xls");
+ }
+
+ FileInfo fi = new FileInfo(path);
+ if (!fi.Directory.Exists)
+ {
+ fi.Directory.Create(); //鏂囦欢涓嶅瓨鍦紝鍒涘缓鏂囦欢
+ }
+ List<string[]> rows = new List<string[]>();
+ rows.Add(new string[] { "娴嬭瘯鏃堕棿", "娴嬭瘯浜�", "娴嬭瘯璁惧", "鏉″舰鐮�", "娴嬭瘯缁撴灉" });
+ rows.Add(new string[] { DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), UserInfo.User.Name, ParamSetting.StationName, Barcode, Status });
+ rows.Add(new string[] { "椤圭洰鍚嶇О", "娴嬭瘯鍙傛暟", "娴嬭瘯鍊�", "涓婇檺", "涓嬮檺", "鍗曚綅", "缁撴灉" });
+ if (Datasource != null && Datasource.Count > 0)
+ {
+ foreach (var data in Datasource)
+ {
+ rows.Add(new string[] { data.Name, data.Step, data.Value, data.LimitUp, data.LimitDown, data.Unit, data.Result });
+ }
+ }
+ ExcelHelper.ExportExcel(path, rows);
+ }
+ catch (Exception ex)
+ {
+ TsExecution.logger.Error("Write CSV File Failed.", ex);
+ }
+ });
+ }
+
+
public void WriteToCSV(string path)
{
- Dispatcher.BeginInvoke(new Action(() =>
+ Dispatcher.Invoke(() =>
{
try
{
@@ -488,7 +499,7 @@
{
TsExecution.logger.Error("Write CSV File Failed.", ex);
}
- }));
+ });
}
public void ShowPausePanel()
@@ -534,17 +545,7 @@
private void SendSnr2Ts()
{
- //try
- //{
- // string snr = TbManualSnr.Text;
- // SequenceFileContext?.StationGlobals.SetValString($"StationState.SN[{index}]", 1, snr);
- // scannerPanel.Visibility = Visibility.Collapsed;
- // TbManualSnr.Text = string.Empty;
- //}
- //catch (Exception ex)
- //{
- // ToastHelper.Error(ex.Message);
- //}
+
}
private void pausePanel_Loaded(object sender, RoutedEventArgs e)
@@ -605,16 +606,59 @@
screens[index].DrawPoint(x, y);
}
+ /// <summary>
+ /// 缁樺浘涔嬪墠娓呯┖宸叉湁鐨�
+ /// </summary>
+ /// <param name="index"></param>
+ /// <param name="points"></param>
public void DrawScreenPoints(int index, int[][] points)
{
screens[index].DrawPoints(points);
}
+ /// <summary>
+ /// 缁樺浘涔嬪墠涓嶆竻绌哄凡鏈夌殑
+ /// </summary>
+ /// <param name="index"></param>
+ /// <param name="points"></param>
+ public void DrawNewScreenPoints(int index, int[][] points)
+ {
+ screens[index].DrawNewPoints(points);
+ }
+
public void ClearScreenPoint(int index)
{
screens[index].Clear();
}
+ public void RefreshProbeCount(ProductData product)
+ {
+ try
+ {
+ var num = IniFileHelper.ReadIniData($"Socket{this.index.ToString()}", "ProbeCount", "0", this.CountIniPath);
+ this.ProbeCount = int.Parse(num);
+ }
+ catch (Exception ex)
+ {
+ this.ProbeCount = 0;
+ }
+ }
+
+ /// <summary>
+ /// 鏇存柊鎺㈤拡浣跨敤娆℃暟
+ /// </summary>
+ /// <param name="count"></param>
+ private void UpdateProbeCount(int count)
+ {
+ /// 鍐欏埌閰嶇疆鏂囦欢
+ 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)
{
if (product == null)
--
Gitblit v1.9.1