From af337fc6f32456bc71d9f3bbbe949e81f42a8249 Mon Sep 17 00:00:00 2001 From: Tyrone CT Date: Sat, 9 May 2026 10:29:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E5=B7=AE=E5=80=BC=E5=92=8C=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=8A=9F=E8=83=BD=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CapMachine.Wpf/App.xaml.cs | 1 + .../Models/PPCalc/TherdyConfigModel.cs | 15 +++ CapMachine.Wpf/Services/ComActionService.cs | 17 ++- .../Services/NavigationMenuService.cs | 1 + .../ViewModels/DialogTherdyConfigViewModel.cs | 114 ++++++++++++++++++ .../Views/DialogTherdyConfigView.xaml | 59 +++++++++ .../Views/DialogTherdyConfigView.xaml.cs | 12 ++ 7 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 CapMachine.Wpf/Models/PPCalc/TherdyConfigModel.cs create mode 100644 CapMachine.Wpf/ViewModels/DialogTherdyConfigViewModel.cs create mode 100644 CapMachine.Wpf/Views/DialogTherdyConfigView.xaml create mode 100644 CapMachine.Wpf/Views/DialogTherdyConfigView.xaml.cs diff --git a/CapMachine.Wpf/App.xaml.cs b/CapMachine.Wpf/App.xaml.cs index 78f4307..42c3692 100644 --- a/CapMachine.Wpf/App.xaml.cs +++ b/CapMachine.Wpf/App.xaml.cs @@ -205,6 +205,7 @@ namespace CapMachine.Wpf containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); + containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); diff --git a/CapMachine.Wpf/Models/PPCalc/TherdyConfigModel.cs b/CapMachine.Wpf/Models/PPCalc/TherdyConfigModel.cs new file mode 100644 index 0000000..e4d4881 --- /dev/null +++ b/CapMachine.Wpf/Models/PPCalc/TherdyConfigModel.cs @@ -0,0 +1,15 @@ +using Prism.Mvvm; + +namespace CapMachine.Wpf.Models.PPCalc +{ + public class TherdyConfigModel : BindableBase + { + private double _h3TempOffset_C = -10.0; + + public double H3TempOffset_C + { + get { return _h3TempOffset_C; } + set { _h3TempOffset_C = value; RaisePropertyChanged(); } + } + } +} diff --git a/CapMachine.Wpf/Services/ComActionService.cs b/CapMachine.Wpf/Services/ComActionService.cs index 9b05c87..41b7404 100644 --- a/CapMachine.Wpf/Services/ComActionService.cs +++ b/CapMachine.Wpf/Services/ComActionService.cs @@ -62,6 +62,9 @@ namespace CapMachine.Wpf.Services case "过热度/过冷度配置": ShowSuperHeatCool(msg.Par); break; + case "COP物性参数回差": + ShowTherdyConfig(msg.Par); + break; case "规则转换": if (SysRunServer.MachineRunState1.IsRunState) { @@ -104,7 +107,19 @@ namespace CapMachine.Wpf.Services }); } - + /// + /// COP物性参数回差配置弹窗 + /// + private void ShowTherdyConfig(object par) + { + DialogService.ShowDialog("DialogTherdyConfigView", new DialogParameters() { { "Name", par } }, (dialogResult) => + { + if (dialogResult.Result == ButtonResult.OK) + { + PPCService.ReloadTherdyH3TempOffset(); + } + }); + } /// /// 过热度和过冷度配置弹窗 diff --git a/CapMachine.Wpf/Services/NavigationMenuService.cs b/CapMachine.Wpf/Services/NavigationMenuService.cs index 1c595e3..a2b5bc5 100644 --- a/CapMachine.Wpf/Services/NavigationMenuService.cs +++ b/CapMachine.Wpf/Services/NavigationMenuService.cs @@ -38,6 +38,7 @@ namespace CapMachine.Wpf.Services new NavigationItem("", "计算信息","",new ObservableCollection() { new NavigationItem("SuperHeatCool","过热度/过冷度配置","DialogSuperHeatCoolConfigView"), + new NavigationItem("","COP物性参数回差","DialogTherdyConfigView"), //new NavigationItem("Palette","过冷度",""), }), new NavigationItem("", "规则设置","",new ObservableCollection() diff --git a/CapMachine.Wpf/ViewModels/DialogTherdyConfigViewModel.cs b/CapMachine.Wpf/ViewModels/DialogTherdyConfigViewModel.cs new file mode 100644 index 0000000..843ae6f --- /dev/null +++ b/CapMachine.Wpf/ViewModels/DialogTherdyConfigViewModel.cs @@ -0,0 +1,114 @@ +using CapMachine.Core; +using CapMachine.Wpf.Models.PPCalc; +using Prism.Commands; +using Prism.Services.Dialogs; +using System; +using System.Globalization; +using System.Windows; + +namespace CapMachine.Wpf.ViewModels +{ + public class DialogTherdyConfigViewModel : DialogViewModel + { + private const string H3TempOffsetConfigKey = "Therdy_H3TempOffset_C"; + + public DialogTherdyConfigViewModel() + { + TherdyConfig = new TherdyConfigModel(); + LoadConfig(); + } + + private string _h3TempOffsetText = string.Empty; + public string H3TempOffsetText + { + get { return _h3TempOffsetText; } + set { _h3TempOffsetText = value; RaisePropertyChanged(); } + } + + public TherdyConfigModel TherdyConfig { get; set; } + + private DelegateCommand saveCmd; + public DelegateCommand SaveCmd + { + get + { + if (saveCmd == null) + { + saveCmd = new DelegateCommand(SaveCmdMethod); + } + return saveCmd; + } + set { saveCmd = value; } + } + + private DelegateCommand cancelCmd; + public DelegateCommand CancelCmd + { + get + { + if (cancelCmd == null) + { + cancelCmd = new DelegateCommand(CancelCmdMethod); + } + return cancelCmd; + } + set { cancelCmd = value; } + } + + private void LoadConfig() + { + try + { + string raw = ConfigHelper.GetValue(H3TempOffsetConfigKey); + if (!string.IsNullOrWhiteSpace(raw) && double.TryParse(raw, NumberStyles.Float, CultureInfo.InvariantCulture, out var v)) + { + TherdyConfig.H3TempOffset_C = v; + } + } + catch + { + } + + H3TempOffsetText = TherdyConfig.H3TempOffset_C.ToString(CultureInfo.InvariantCulture); + } + + private void SaveConfig() + { + ConfigHelper.SetValue(H3TempOffsetConfigKey, TherdyConfig.H3TempOffset_C.ToString(CultureInfo.InvariantCulture)); + } + + private void SaveCmdMethod() + { + try + { + if (!double.TryParse(H3TempOffsetText, NumberStyles.Float, CultureInfo.InvariantCulture, out var offsetC)) + { + MessageBox.Show("回差值格式不正确,请输入数字(例如 -10)。", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + + TherdyConfig.H3TempOffset_C = offsetC; + SaveConfig(); + DialogParameters pars = new DialogParameters + { + { "H3TempOffset_C", TherdyConfig.H3TempOffset_C } + }; + RaiseRequestClose(new DialogResult(ButtonResult.OK, pars)); + } + catch + { + RaiseRequestClose(new DialogResult(ButtonResult.Cancel)); + } + } + + private void CancelCmdMethod() + { + RaiseRequestClose(new DialogResult(ButtonResult.Cancel)); + } + + public override void OnDialogOpened(IDialogParameters parameters) + { + LoadConfig(); + } + } +} diff --git a/CapMachine.Wpf/Views/DialogTherdyConfigView.xaml b/CapMachine.Wpf/Views/DialogTherdyConfigView.xaml new file mode 100644 index 0000000..418c955 --- /dev/null +++ b/CapMachine.Wpf/Views/DialogTherdyConfigView.xaml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + +