From c4a3f8db90530a727ffab77c3bb5bb7d782792bf Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期一, 25 八月 2025 15:50:27 +0800
Subject: [PATCH] 上传代码;
---
Plugin.TsExecution/SingleControl.xaml.cs | 214 ++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 178 insertions(+), 36 deletions(-)
diff --git a/Plugin.TsExecution/SingleControl.xaml.cs b/Plugin.TsExecution/SingleControl.xaml.cs
index 8d2e1e0..293f3f6 100644
--- a/Plugin.TsExecution/SingleControl.xaml.cs
+++ b/Plugin.TsExecution/SingleControl.xaml.cs
@@ -1,4 +1,5 @@
-锘縰sing HMI.Core.Util;
+锘縰sing HMI.Core.Manager;
+using HMI.Core.Util;
using HMI.Util;
using NationalInstruments.TestStand.Interop.API;
using Plugin.TsExecution.Entity;
@@ -10,6 +11,7 @@
using System.Timers;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Media;
namespace Plugin.TsExecution
{
@@ -58,15 +60,15 @@
}
}
- private double passNum;
- public double PassNum
+ private int passNum;
+ public int PassNum
{
get => passNum;
private set { Set(ref passNum, value); }
}
- private double failNum;
- public double FailNum
+ private int failNum;
+ public int FailNum
{
get => failNum;
private set { Set(ref failNum, value); }
@@ -108,7 +110,8 @@
if (value == "Start Timing")
{
this.refreshTimer.Enabled = true;
- TimeNow = DateTime.Now;
+ TestStartTime = DateTime.Now;
+ StepStartTime = DateTime.Now;
}
else
{
@@ -132,10 +135,11 @@
}
}
- private DateTime TimeNow = new DateTime();
+ private DateTime TestStartTime = new DateTime();
+ private DateTime StepStartTime = new DateTime();
private TimeSpan TimeCount = new TimeSpan();
- private Timer refreshTimer;
+ private System.Timers.Timer refreshTimer;
private string currentStep = "绛夊緟鎵爜";
public string CurrentStep
@@ -157,7 +161,56 @@
}
}
+ /// <summary>
+ /// 杩涘害鍊�
+ /// </summary>
+ private int _processValue;
+ public int ProcessValue
+ {
+ get => _processValue;
+ set
+ {
+ Set(ref _processValue, value);
+ }
+ }
+
+ public string ProcessValueLabel
+ {
+ get
+ {
+ if (ProcessValue > 0) return $"{ProcessValue}%";
+ return "";
+ }
+ set
+ {
+ }
+ }
+
+ public void SetSimpleUI(bool flag)
+ {
+ if (flag)
+ {
+ simplePanel.Visibility = Visibility.Visible;
+ detailPanel.Visibility = Visibility.Collapsed;
+ }
+ else
+ {
+ simplePanel.Visibility = Visibility.Collapsed;
+ detailPanel.Visibility = Visibility.Visible;
+ }
+ }
+
public int ProbeWarn { get; private set; }
+
+ private bool isAutoMode;
+ public bool IsAutoMode
+ {
+ get => isAutoMode;
+ set
+ {
+ Set(ref isAutoMode, value);
+ }
+ }
public SingleControl(int Index, string CountIniPath, int probeWarn)
{
@@ -166,7 +219,7 @@
this.index = Index;
ProbeWarn = probeWarn;
- refreshTimer = new Timer()
+ refreshTimer = new System.Timers.Timer()
{
Interval = 100
};
@@ -174,6 +227,15 @@
ReadProbeCount();
ReadCounter();
InitializeComponent();
+ try
+ {
+ var value = ParameterManager.GetCommonParameterByName("AutoTestMode");
+ IsAutoMode = bool.Parse(value.Value);
+ }
+ catch
+ {
+ IsAutoMode = true;
+ }
//if (ProbeWarn > 0)
//{
// probeWarnPanel.Visibility = Visibility.Visible;
@@ -204,7 +266,7 @@
//AddTestData("1", "1", "1", "1", "1", "1", "1");
- TimeCount = DateTime.Now - TimeNow;
+ TimeCount = DateTime.Now - TestStartTime;
elapseTime = string.Format("{0:00}:{1:00}:{2:00}", TimeCount.Hours, TimeCount.Minutes, TimeCount.Seconds);
Set("ElapseTime");
Set("TestInfo");
@@ -235,8 +297,12 @@
Unit = unit,
Result = Status
};
- Dispatcher.BeginInvoke(new Action(() =>
+ table.Dispatcher.Invoke(new Action(() =>
{
+ var now = DateTime.Now;
+ var span = now - StepStartTime;
+ StepStartTime = now;
+ data.ConsumeTime = $"{span.Seconds}s";
Datasource.Add(data);
table.ScrollIntoView(data);
}));
@@ -275,8 +341,8 @@
/// <param name="ProcessVal"></param>
public void SetTestProcess(int ProcessVal)
{
- this.testProcess.Value = ProcessVal;
- this.testProcessLabel.Content = ProcessVal.ToString() + "%";
+ ProcessValue = ProcessVal;
+ Set("ProcessValueLabel");
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
@@ -289,16 +355,20 @@
if (result == true)
{
PassNum += 1;
+ //Interlocked.Increment(ref passNum);
+ //Set("PassNum");
}
else if (result == false)
{
FailNum += 1;
+ //Interlocked.Increment(ref failNum);
+ //Set("FailNum");
}
TotalNum = PassNum + FailNum;
if (TotalNum != 0)
{
- PassRate = (PassNum / TotalNum);
+ PassRate = ((double)PassNum / TotalNum);
}
else
{
@@ -362,41 +432,49 @@
public void ResetCounter()
{
- this.passNum = 0;
- this.failNum = 0;
+ this.PassNum = 0;
+ this.FailNum = 0;
this.UpdateTestCounter(null);
}
public void WriteToCSV(string path)
{
- try
+ Dispatcher.BeginInvoke(new Action(() =>
{
-
- FileInfo fi = new FileInfo(path);
- if (!fi.Directory.Exists)
+ try
{
- fi.Directory.Create(); //鏂囦欢涓嶅瓨鍦紝鍒涘缓鏂囦欢
- }
- using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
- using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8))
- {
- string title = "椤圭洰鍚嶇О,娴嬭瘯鍙傛暟,娴嬭瘯鍊�,涓婇檺,涓嬮檺,鍗曚綅,缁撴灉";
- sw.WriteLine(title);
-
- if (Datasource != null && Datasource.Count > 0)
+ FileInfo fi = new FileInfo(path);
+ if (!fi.Directory.Exists)
{
- foreach (var data in Datasource)
+ fi.Directory.Create(); //鏂囦欢涓嶅瓨鍦紝鍒涘缓鏂囦欢
+ }
+
+ using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
+ using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8))
+ {
+ string title = "椤圭洰鍚嶇О,娴嬭瘯鍙傛暟,娴嬭瘯鍊�,涓婇檺,涓嬮檺,鍗曚綅,缁撴灉";
+ sw.WriteLine(title);
+
+ if (Datasource != null && Datasource.Count > 0)
{
- sw.WriteLine($"{data.Name},{data.Step},{data.Value},{data.LimitUp},{data.LimitDown},{data.Unit},{data.Result}");
+ foreach (var data in Datasource)
+ {
+ sw.WriteLine($"{data.Name},{data.Step},{data.Value},{data.LimitUp},{data.LimitDown},{data.Unit},{data.Result}");
+ }
}
}
}
- }
- catch (Exception ex)
- {
- TsExecution.logger.Error("Write CSV File Failed.", ex);
- }
+ catch (Exception ex)
+ {
+ TsExecution.logger.Error("Write CSV File Failed.", ex);
+ }
+ }));
+ }
+
+ public void ShowPausePanel()
+ {
+ pausePanel.Visibility = Visibility.Visible;
}
private void Button_Click(object sender, RoutedEventArgs e)
@@ -407,9 +485,73 @@
case "clear":
UpdateProbeCount(0);
break;
+ case "cancelPauseBtn":
+ SequenceFileContext?.StationGlobals.SetValBoolean($"StationState.IsContinue_{index}", 1, false);
+ pausePanel.Visibility = Visibility.Collapsed;
+ break;
+ case "continuePauseBtn":
+ SequenceFileContext?.StationGlobals.SetValBoolean($"StationState.IsContinue_{index}", 1, true);
+ pausePanel.Visibility = Visibility.Collapsed;
+ break;
+ case "scannerSetting":
+ //ScannerSetting setting = new ScannerSetting()
+ //{
+ // Owner = Window.GetWindow(this)
+ //};
+ //setting.Open(true, $"Socket{index}", CountIniPath);
+ ShowScannerPanel();
+ break;
+ case "scannerOkBtn":
+ SendSnr2Ts();
+ break;
default:
break;
}
}
+ public void ShowScannerPanel()
+ {
+ //scannerPanel.Visibility = Visibility.Visible;
+ }
+
+ 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)
+ {
+ if (sender == pausePanel)
+ {
+ var can = pausePanel;
+ var modal = visualModal;
+ Canvas.SetLeft(modal, (pausePanel.ActualWidth - visualModal.ActualWidth) / 2);
+ Canvas.SetTop(modal, (pausePanel.ActualHeight - visualModal.ActualHeight) / 2);
+ }
+ else
+ {
+ //var can = scannerPanel;
+ //var modal = scannerVisualModal;
+ //Canvas.SetLeft(modal, (scannerPanel.ActualWidth - scannerVisualModal.ActualWidth) / 2);
+ //Canvas.SetTop(modal, (scannerPanel.ActualHeight - scannerVisualModal.ActualHeight) / 2);
+ }
+ }
+
+ private void TextBlock_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ DependencyObject parent = VisualTreeHelper.GetParent((DependencyObject)sender);
+ while (parent != null) {
+ parent = VisualTreeHelper.GetParent(parent);
+ }
+ }
}
}
--
Gitblit v1.9.1