From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点
---
Plugin.DeviceDebug/Panels/PowerSupplyDebugPanel.xaml.cs | 125 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 125 insertions(+), 0 deletions(-)
diff --git a/Plugin.DeviceDebug/Panels/PowerSupplyDebugPanel.xaml.cs b/Plugin.DeviceDebug/Panels/PowerSupplyDebugPanel.xaml.cs
new file mode 100644
index 0000000..fa76700
--- /dev/null
+++ b/Plugin.DeviceDebug/Panels/PowerSupplyDebugPanel.xaml.cs
@@ -0,0 +1,125 @@
+using log4net;
+using Plugin.DeviceDebug.Entity;
+using System;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Plugin.DeviceDebug.Panels
+{
+ /// <summary>
+ /// PowerSupplyDebugPanel.xaml 鐨勪氦浜掗�昏緫
+ /// </summary>
+ public partial class PowerSupplyDebugPanel : UserControl
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(PowerSupplyDebugPanel));
+
+ /// <summary>
+ /// 鏄惁涓虹淮鎶ゆā寮忥紙鎺у埗杈撳叆鍙敤鎬э級
+ /// </summary>
+ public static readonly DependencyProperty IsMaintenanceModeProperty =
+ DependencyProperty.Register(nameof(IsMaintenanceMode), typeof(bool), typeof(PowerSupplyDebugPanel),
+ new PropertyMetadata(false));
+
+ public bool IsMaintenanceMode
+ {
+ get => (bool)GetValue(IsMaintenanceModeProperty);
+ set => SetValue(IsMaintenanceModeProperty, value);
+ }
+
+ /// <summary>
+ /// 鍛戒护鎵ц浜嬩欢
+ /// </summary>
+ public event EventHandler<DebugCommand> OnCommandExecute;
+
+ public PowerSupplyDebugPanel()
+ {
+ InitializeComponent();
+ }
+
+ /// <summary>
+ /// 鏇存柊瀹炴祴鍊�
+ /// </summary>
+ public void UpdateReadback(string voltage, string current, DateTime time)
+ {
+ try
+ {
+ measuredVoltage.Text = $"{voltage} V";
+ measuredCurrent.Text = $"{current} A";
+ lastUpdateTime.Text = time.ToString("yyyy-MM-dd HH:mm:ss");
+ }
+ catch (Exception ex)
+ {
+ log.Error("鏇存柊瀹炴祴鍊煎け璐�", ex);
+ }
+ }
+
+ private void ApplyBtn_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ if (!IsMaintenanceMode)
+ {
+ MessageBox.Show("褰撳墠涓哄彧璇绘ā寮忥紝鏃犳硶鎵ц璁剧疆鎿嶄綔", "鎻愮ず", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+
+ // 瑙f瀽杈撳叆鍊�
+ if (!double.TryParse(voltageInput.Text, out double voltage))
+ {
+ MessageBox.Show("鐢靛帇鍊兼牸寮忎笉姝g‘", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ if (!double.TryParse(currentInput.Text, out double currentLimit))
+ {
+ MessageBox.Show("鐢垫祦鍊兼牸寮忎笉姝g‘", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ bool output = outputToggle.IsChecked == true;
+
+ // 鍒涘缓鍛戒护
+ var command = new PowerSetCommand
+ {
+ Voltage = voltage,
+ CurrentLimit = currentLimit,
+ Output = output
+ };
+
+ // 瑙﹀彂鍛戒护鎵ц浜嬩欢
+ OnCommandExecute?.Invoke(this, command);
+
+ log.Info($"鍙戦�佺數婧愯缃懡浠�: V={voltage}, I={currentLimit}, Output={output}");
+ }
+ catch (Exception ex)
+ {
+ log.Error("鍙戦�佺數婧愯缃懡浠ゅけ璐�", ex);
+ MessageBox.Show($"鍙戦�佸懡浠ゅけ璐�: {ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private void MeasureBtn_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ // 鍒涘缓娴嬮噺鍛戒护
+ var command = new PowerMeasureCommand();
+
+ // 瑙﹀彂鍛戒护鎵ц浜嬩欢
+ OnCommandExecute?.Invoke(this, command);
+
+ log.Info("鍙戦�佺數婧愭祴閲忓懡浠�");
+ }
+ catch (Exception ex)
+ {
+ log.Error("鍙戦�佺數婧愭祴閲忓懡浠ゅけ璐�", ex);
+ MessageBox.Show($"鍙戦�佸懡浠ゅけ璐�: {ex.Message}", "閿欒", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private void OutputToggle_Changed(object sender, RoutedEventArgs e)
+ {
+ // ToggleButton 鐘舵�佸彉鍖栨椂鐨勮瑙夊弽棣堝凡鍦� XAML Style 涓鐞�
+ }
+ }
+}
--
Gitblit v1.9.1