diff --git a/CapMachine.Wpf/App.config b/CapMachine.Wpf/App.config index 133d9f2..f00b9b7 100644 --- a/CapMachine.Wpf/App.config +++ b/CapMachine.Wpf/App.config @@ -8,6 +8,7 @@ + \ No newline at end of file diff --git a/CapMachine.Wpf/App.xaml.cs b/CapMachine.Wpf/App.xaml.cs index dda6b59..fdfa8b4 100644 --- a/CapMachine.Wpf/App.xaml.cs +++ b/CapMachine.Wpf/App.xaml.cs @@ -100,8 +100,9 @@ namespace CapMachine.Wpf containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); - + containerRegistry.RegisterSingleton(); + //注册AutoMapper 将IAutoMapperProvider注入IOC容器,并对外提供IMapper注入类型。 containerRegistry.RegisterSingleton(); containerRegistry.Register(typeof(IMapper), GetMapper); @@ -159,6 +160,7 @@ namespace CapMachine.Wpf containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); + containerRegistry.RegisterDialog(); //注册AutoMapper @@ -232,6 +234,7 @@ namespace CapMachine.Wpf var appVersionService9 = ContainerLocator.Container.Resolve(); var appVersionService10 = ContainerLocator.Container.Resolve(); var appVersionService11 = ContainerLocator.Container.Resolve(); + var appVersionService15 = ContainerLocator.Container.Resolve(); diff --git a/CapMachine.Wpf/Models/PPCalc/SuperHeatCoolConfigModel.cs b/CapMachine.Wpf/Models/PPCalc/SuperHeatCoolConfigModel.cs new file mode 100644 index 0000000..a28e891 --- /dev/null +++ b/CapMachine.Wpf/Models/PPCalc/SuperHeatCoolConfigModel.cs @@ -0,0 +1,45 @@ +using Prism.Mvvm; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CapMachine.Wpf.Models.PPCalc +{ + /// + /// 过热度和过冷度的计算配置 + /// + public class SuperHeatCoolConfigModel : BindableBase + { + + /// + /// 制冷剂 + /// + public string? Cryogen { get; set; } + + private string _FluidsPath = "C:\\Program Files (x86)\\REFPROP\\fluids"; + /// + /// 过热度和过冷度计算FLUID路径 + /// REFPROP + /// REFPRP64.DLL + /// + /// ****FluidsPath 路径不能太长,否则会导致错误*********** + /// + public string FluidsPath + { + get { return _FluidsPath; } + set { _FluidsPath = value; RaisePropertyChanged(); } + } + + + ///// + ///// 过热度和过冷度计算FLUID路径 + ///// REFPROP + ///// REFPRP64.DLL + ///// + ///// ****FluidsPath 路径不能太长,否则会导致错误*********** + ///// + //public string FluidsPath { get; set; } = "C:\\Program Files (x86)\\REFPROP\\fluids"; + } +} diff --git a/CapMachine.Wpf/PrismEvent/ComDialogEvent.cs b/CapMachine.Wpf/PrismEvent/ComDialogEvent.cs new file mode 100644 index 0000000..122c8cc --- /dev/null +++ b/CapMachine.Wpf/PrismEvent/ComDialogEvent.cs @@ -0,0 +1,17 @@ +using Prism.Events; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CapMachine.Wpf.PrismEvent +{ + /// + /// 公共弹窗事件 + /// + public class ComDialogEvent : PubSubEvent + { + + } +} diff --git a/CapMachine.Wpf/PrismEvent/ComDialogMsg.cs b/CapMachine.Wpf/PrismEvent/ComDialogMsg.cs new file mode 100644 index 0000000..e9ca799 --- /dev/null +++ b/CapMachine.Wpf/PrismEvent/ComDialogMsg.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CapMachine.Wpf.PrismEvent +{ + /// + /// 公共弹窗消息 + /// + public class ComDialogMsg + { + /// + /// 名称 + /// + public string? Name { get; set; } + + /// + ///参数 + /// + public object Par { get; set; } + } +} diff --git a/CapMachine.Wpf/Services/ComActionService.cs b/CapMachine.Wpf/Services/ComActionService.cs new file mode 100644 index 0000000..0f5bf7e --- /dev/null +++ b/CapMachine.Wpf/Services/ComActionService.cs @@ -0,0 +1,95 @@ +using CapMachine.Wpf.PrismEvent; +using Prism.Events; +using Prism.Services.Dialogs; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CapMachine.Wpf.Services +{ + + /// + /// 公共操作的服务 + /// 存放公共事件的服务 + /// + public class ComActionService + { + public ConfigService ConfigService { get; } + + private IEventAggregator EventAggregator { get; set; } + public DataRecordService DataRecordService { get; } + public SysRunService SysRunServer { get; } + public PPCService PPCService { get; } + public MachineRtDataService MachineRtDataService { get; } + public IDialogService DialogService { get; } + + + public ComActionService(ConfigService configService, IEventAggregator eventAggregator, + DataRecordService dataRecordService, SysRunService sysRunService,PPCService pPCService, + MachineRtDataService machineRtDataService, IDialogService dialogService) + { + ConfigService = configService; + //事件服务 + EventAggregator = eventAggregator; + DataRecordService = dataRecordService; + SysRunServer = sysRunService; + PPCService = pPCService; + MachineRtDataService = machineRtDataService; + DialogService = dialogService; + + EventAggregator.GetEvent().Subscribe(ComDialogEventCall); + } + + + + #region 公共弹窗操作 + + /// + /// 公共弹窗事件执行方法 + /// + /// + /// + private void ComDialogEventCall(ComDialogMsg msg) + { + switch (msg.Name) + { + case "过热度/过冷度配置": + ShowSuperHeatCool(msg.Par); + break; + default: + break; + } + } + + + + /// + /// 过热度和过冷度配置弹窗 + /// + private void ShowSuperHeatCool(object par) + { + //弹窗 + DialogService.ShowDialog("DialogSuperHeatCoolConfigView", new DialogParameters() { { "Name", par } }, (par) => + { + if (par.Result == ButtonResult.OK) + { + //保存配置信息 + PPCService.SaveSuperHeatCoolConfig(); + + + } + else if (par.Result == ButtonResult.Cancel) + { + //取消 + + } + + }); + } + + + #endregion + } +} diff --git a/CapMachine.Wpf/Services/ConfigService.cs b/CapMachine.Wpf/Services/ConfigService.cs index 9bc5fea..78003de 100644 --- a/CapMachine.Wpf/Services/ConfigService.cs +++ b/CapMachine.Wpf/Services/ConfigService.cs @@ -1,6 +1,9 @@ using CapMachine.Model; using CapMachine.Wpf.Dtos; +using CapMachine.Wpf.PrismEvent; +using Prism.Events; using Prism.Mvvm; +using Prism.Services.Dialogs; namespace CapMachine.Wpf.Services { @@ -10,11 +13,15 @@ namespace CapMachine.Wpf.Services /// public class ConfigService : BindableBase { - public ConfigService() + public ConfigService(IEventAggregator eventAggregator, IDialogService dialogService) { CurUserDto = new UserDto(); - + + EventAggregator = eventAggregator; + + DialogService = dialogService; } + /// /// Csv文件锁 @@ -98,5 +105,13 @@ namespace CapMachine.Wpf.Services set { _CurUserDto = value; RaisePropertyChanged(); } } + public IEventAggregator EventAggregator { get; } + public PPCService PPCService { get; } + public IDialogService DialogService { get; } + + + + + } } diff --git a/CapMachine.Wpf/Services/NavigationMenuService.cs b/CapMachine.Wpf/Services/NavigationMenuService.cs index e6dd333..60c86cd 100644 --- a/CapMachine.Wpf/Services/NavigationMenuService.cs +++ b/CapMachine.Wpf/Services/NavigationMenuService.cs @@ -28,27 +28,27 @@ namespace CapMachine.Wpf.Services MenuItems.Clear(); MenuItems.Add(new NavigationItem("", "系统", "", new ObservableCollection() { - new NavigationItem("","系统配置","",new ObservableCollection() - { - new NavigationItem("ShapeCirclePlus","日志文件",""), - new NavigationItem("","快速工况","QuickMeterStepView"), - new NavigationItem("Clouds", "高速记录",""), - new NavigationItem("ShapeOvalPlus","系统配置",""), - }), + //new NavigationItem("","系统配置","",new ObservableCollection() + //{ + // new NavigationItem("ShapeCirclePlus","日志文件",""), + // new NavigationItem("","快速工况","QuickMeterStepView"), + // new NavigationItem("Clouds", "高速记录",""), + // new NavigationItem("ShapeOvalPlus","系统配置",""), + //}), new NavigationItem("", "计算信息","",new ObservableCollection() { - new NavigationItem("Circle","过热度",""), - new NavigationItem("Palette","过冷度",""), - }), - new NavigationItem("", "PID设置","",new ObservableCollection() - { - new NavigationItem("Circle","转速PID",""), - }), - new NavigationItem("", "通信配置","",new ObservableCollection() - { - new NavigationItem("Circle","CAN配置","CANConfigView"), - new NavigationItem("Circle","LIN配置",""), + new NavigationItem("SuperHeatCool","过热度/过冷度配置","DialogSuperHeatCoolConfigView"), + //new NavigationItem("Palette","过冷度",""), }), + //new NavigationItem("", "PID设置","",new ObservableCollection() + //{ + // new NavigationItem("Circle","转速PID",""), + //}), + //new NavigationItem("", "通信配置","",new ObservableCollection() + //{ + // new NavigationItem("Circle","CAN配置","CANConfigView"), + // new NavigationItem("Circle","LIN配置",""), + //}), new NavigationItem("","版本信息","",new ObservableCollection() { new NavigationItem("FormatColorText", "操作手册",""), diff --git a/CapMachine.Wpf/Services/PPCService.cs b/CapMachine.Wpf/Services/PPCService.cs index 0403a50..a02fc38 100644 --- a/CapMachine.Wpf/Services/PPCService.cs +++ b/CapMachine.Wpf/Services/PPCService.cs @@ -1,5 +1,6 @@ using CapMachine.Core; using CapMachine.Shared.Controls; +using CapMachine.Wpf.Models.PPCalc; using CapMachine.Wpf.Models.Tag; using CapMachine.Wpf.PPCalculation; using Prism.Events; @@ -66,20 +67,26 @@ namespace CapMachine.Wpf.Services //Cond1TempTag = TagManager.DicTags.GetValueOrDefault("冷凝器出口水温[℃]"); //CondInTempTag = TagManager.DicTags.GetValueOrDefault("冷凝器进口温度[℃]"); - FluidsPath = ConfigHelper.GetValue("FluidsPath"); + SuperHeatCoolConfig.FluidsPath = ConfigHelper.GetValue("FluidsPath"); + SuperHeatCoolConfig.Cryogen = ConfigHelper.GetValue("Cryogen"); RtScanDeviceStart(); } /// - /// 过热度和过冷度计算FLUID路径 - /// REFPROP - /// REFPRP64.DLL - /// - /// ****FluidsPath 路径不能太长,否则会导致错误*********** + /// 当前的配置 /// - public string FluidsPath { get; set; } = "C:\\Program Files (x86)\\REFPROP\\fluids"; + public SuperHeatCoolConfigModel SuperHeatCoolConfig { get; set; } = new SuperHeatCoolConfigModel(); + + /// + /// 保存配置信息 + /// + public void SaveSuperHeatCoolConfig() + { + ConfigHelper.SetValue("FluidsPath", SuperHeatCoolConfig.FluidsPath); + ConfigHelper.SetValue("Cryogen", SuperHeatCoolConfig.Cryogen); + } /// /// 吸气压力 @@ -112,10 +119,10 @@ namespace CapMachine.Wpf.Services /// public double Subcool { get; set; } - /// - /// 制冷剂 - /// - public string Cryogen { get; set; } = "R134a"; + ///// + ///// 制冷剂 + ///// + //public string Cryogen { get; set; } = "R134a"; /// /// 风量数据-乘以系数的后的最终结果 @@ -164,7 +171,7 @@ namespace CapMachine.Wpf.Services //textBox5.Text = ""; - string hpath = FluidsPath; + string hpath = SuperHeatCoolConfig.FluidsPath; long size = hpath.Length; hpath += new String(' ', 255 - (int)size); @@ -173,7 +180,7 @@ namespace CapMachine.Wpf.Services long numComps = 1;//冷媒个数 //string hfld = "R1234YF.FLD"; R1234YF string hfld = ""; - if (Cryogen == "R134a") + if (SuperHeatCoolConfig.Cryogen == "R134a") { hfld = "R134A.FLD"; } @@ -269,7 +276,7 @@ namespace CapMachine.Wpf.Services //string hfld = "R1234YF.FLD"; //string hfld = "R134A.FLD"; string hfld = ""; - if (Cryogen == "R134a") + if (SuperHeatCoolConfig.Cryogen == "R134a") { hfld = "R134A.FLD"; } diff --git a/CapMachine.Wpf/ViewModels/DialogExpInfoViewModel.cs b/CapMachine.Wpf/ViewModels/DialogExpInfoViewModel.cs index fd87a0c..db9301c 100644 --- a/CapMachine.Wpf/ViewModels/DialogExpInfoViewModel.cs +++ b/CapMachine.Wpf/ViewModels/DialogExpInfoViewModel.cs @@ -16,11 +16,12 @@ namespace CapMachine.Wpf.ViewModels /// public class DialogExpInfoViewModel : DialogViewModel { - public DialogExpInfoViewModel(ConfigService configService, IFreeSql freeSql, IMapper mapper, MachineRtDataService machineRtDataService) + public DialogExpInfoViewModel(ConfigService configService, IFreeSql freeSql,PPCService pPCService, IMapper mapper, MachineRtDataService machineRtDataService) { this.Title = "试验信息拓展设置"; ConfigService = configService; FreeSql = freeSql; + PPCService = pPCService; this.Mapper = mapper; MachineRtDataService = machineRtDataService; @@ -37,6 +38,7 @@ namespace CapMachine.Wpf.ViewModels /// FreeSql /// public IFreeSql FreeSql { get; } + public PPCService PPCService { get; } /// /// AutoMap映射 @@ -140,7 +142,7 @@ namespace CapMachine.Wpf.ViewModels { ExpInfoDtoItems.Add(new ExpInfoDto() { - + RfNo = PPCService.SuperHeatCoolConfig.Cryogen, }); } diff --git a/CapMachine.Wpf/ViewModels/DialogSuperHeatCoolConfigViewModel.cs b/CapMachine.Wpf/ViewModels/DialogSuperHeatCoolConfigViewModel.cs new file mode 100644 index 0000000..cde4483 --- /dev/null +++ b/CapMachine.Wpf/ViewModels/DialogSuperHeatCoolConfigViewModel.cs @@ -0,0 +1,202 @@ +using CapMachine.Core; +using CapMachine.Wpf.Models; +using CapMachine.Wpf.Models.PPCalc; +using CapMachine.Wpf.Services; +using Prism.Commands; +using Prism.Services.Dialogs; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Win32; +using System.Windows.Controls; +using System.Windows.Forms; +using NPOI.HPSF; + +namespace CapMachine.Wpf.ViewModels +{ + public class DialogSuperHeatCoolConfigViewModel : DialogViewModel + { + public DialogSuperHeatCoolConfigViewModel(PPCService pPCService) + { + Title = "过热度/过冷度设置"; + PPCService = pPCService; + + SuperHeatCoolConfig = PPCService.SuperHeatCoolConfig; + + CryogenComboBoxList = new List() + { + new ComboBoxModel(){Key="0",Text="R134a" }, + new ComboBoxModel(){Key="1",Text="R1234yf" }, + }; + } + + private List _CryogenComboBoxList; + /// + /// 制冷剂下拉框列表 + /// + public List CryogenComboBoxList + { + get { return _CryogenComboBoxList; } + set { _CryogenComboBoxList = value; RaisePropertyChanged(); } + } + + /// + /// 当前的过热度和过冷度的配置 + /// + public SuperHeatCoolConfigModel SuperHeatCoolConfig { get; set; } + + + private DelegateCommand _OpenSuperHeatCoolPathCmd; + /// + /// 打开过热度和过冷度的文件指令 + /// + public DelegateCommand OpenSuperHeatCoolPathCmd + { + set + { + _OpenSuperHeatCoolPathCmd = value; + } + get + { + if (_OpenSuperHeatCoolPathCmd == null) + { + _OpenSuperHeatCoolPathCmd = new DelegateCommand(() => OpenSuperHeatCoolPathCmdMethod()); + } + return _OpenSuperHeatCoolPathCmd; + } + } + /// + /// 打开过热度和过冷度的文件文件信息 + /// + private void OpenSuperHeatCoolPathCmdMethod() + { + //DbcFilePath + try + { + var TargetFilePath = GetFilePath(); + if (!string.IsNullOrEmpty(TargetFilePath)) + { + SuperHeatCoolConfig.FluidsPath = TargetFilePath; + } + //System.Diagnostics.Process.Start(fileName);//打开指定路径下的文件 + } + catch (Exception ex) + { + System.Windows.MessageBox.Show("可能未选择文件路径", "提示", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Hand); + } + } + + /// + /// 获取保存文件的路径 + /// + /// + public string GetFilePath() + { + using (var folderBrowserDialog = new FolderBrowserDialog()) + { + folderBrowserDialog.Description = "请选择一个文件夹"; + folderBrowserDialog.ShowNewFolderButton = true; + + if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + string selectedPath = folderBrowserDialog.SelectedPath; + // 处理选中的文件夹路径 + return selectedPath; + } + else + { + return null; + } + } + } + + + private string name; + /// + /// 名称 + /// + public string Name + { + get { return name; } + set { name = value; RaisePropertyChanged(); } + } + + + private DelegateCommand saveCmd; + /// + /// 保存命令 + /// + public DelegateCommand SaveCmd + { + set + { + saveCmd = value; + } + get + { + if (saveCmd == null) + { + saveCmd = new DelegateCommand(() => SaveCmdMethod()); + } + return saveCmd; + } + } + + /// + /// 保存命令方法 + /// + /// + private void SaveCmdMethod() + { + DialogParameters pars = new DialogParameters + { + { "Name", Name } + }; + + RaiseRequestClose(new Prism.Services.Dialogs.DialogResult(ButtonResult.OK, pars)); + } + + private DelegateCommand cancelCmd; + /// + /// 保存命令 + /// + public DelegateCommand CancelCmd + { + set + { + cancelCmd = value; + } + get + { + if (cancelCmd == null) + { + cancelCmd = new DelegateCommand(() => CancelCmdMethod()); + } + return cancelCmd; + } + } + + public PPCService PPCService { get; } + + + /// + /// 取消命令方法 + /// + /// + private void CancelCmdMethod() + { + RaiseRequestClose(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel)); + } + + /// + /// 窗口打开时的传递的参数 + /// + /// + public override void OnDialogOpened(IDialogParameters parameters) + { + //Name = parameters.GetValue("Name"); + } + } +} diff --git a/CapMachine.Wpf/ViewModels/MainViewModel.cs b/CapMachine.Wpf/ViewModels/MainViewModel.cs index 0f7bc63..9b37bb1 100644 --- a/CapMachine.Wpf/ViewModels/MainViewModel.cs +++ b/CapMachine.Wpf/ViewModels/MainViewModel.cs @@ -1,24 +1,29 @@ using CapMachine.Core; using CapMachine.Core.IService; using CapMachine.Wpf.Models; +using CapMachine.Wpf.PrismEvent; using CapMachine.Wpf.Services; using Prism.Commands; +using Prism.Events; using Prism.Regions; +using System.Windows.Input; namespace CapMachine.Wpf.ViewModels { public class MainViewModel : NavigationViewModel { - public MainViewModel(IRegionManager region, INavigationMenuService menuService, SysRunService sysService) + public MainViewModel(IRegionManager region, INavigationMenuService menuService, SysRunService sysService, IEventAggregator eventAggregator) { this.region = region; MenuService = menuService; SysService = sysService; + EventAggregator = eventAggregator; NavigateCommand = new DelegateCommand(Navigate); } public INavigationMenuService MenuService { get; } public SysRunService SysService { get; } + public IEventAggregator EventAggregator { get; } public DelegateCommand NavigateCommand { get; private set; } private int selectedIndex = -1; @@ -59,6 +64,38 @@ namespace CapMachine.Wpf.ViewModels IsTopDrawerOpen = false; } + private DelegateCommand _TopDrawerCmd; + /// + /// 顶部弹窗按钮命令 + /// + public DelegateCommand TopDrawerCmd + { + set + { + _TopDrawerCmd = value; + } + get + { + if (_TopDrawerCmd == null) + { + _TopDrawerCmd = new DelegateCommand((p) => TopDrawerCmdCall(p)); + } + return _TopDrawerCmd; + } + } + /// + /// 弹窗数据 + /// + /// + private void TopDrawerCmdCall(string Name) + { + //测试数据 + IsTopDrawerOpen = false; + + EventAggregator.GetEvent().Publish(new ComDialogMsg() { Name = Name, Par = null }); + + } + /// /// 导航到页面信息 diff --git a/CapMachine.Wpf/ViewModels/MonitorViewModel.cs b/CapMachine.Wpf/ViewModels/MonitorViewModel.cs index baf197a..9ad8bdb 100644 --- a/CapMachine.Wpf/ViewModels/MonitorViewModel.cs +++ b/CapMachine.Wpf/ViewModels/MonitorViewModel.cs @@ -26,7 +26,7 @@ namespace CapMachine.Wpf.ViewModels /// /// public MonitorViewModel(ConfigService configService, IEventAggregator eventAggregator, - DataRecordService dataRecordService, SysRunService sysRunService, AlarmService alarmService, + DataRecordService dataRecordService, SysRunService sysRunService, AlarmService alarmService,PPCService pPCService, MachineRtDataService machineRtDataService, IDialogService dialogService) { ConfigService = configService; @@ -35,6 +35,7 @@ namespace CapMachine.Wpf.ViewModels DataRecordService = dataRecordService; SysRunServer = sysRunService; AlarmService = alarmService; + PPCService = pPCService; MachineRtDataService = machineRtDataService; DialogService = dialogService; TagManager = MachineRtDataService.TagManger; @@ -69,6 +70,7 @@ namespace CapMachine.Wpf.ViewModels public DataRecordService DataRecordService { get; } public SysRunService SysRunServer { get; } public AlarmService AlarmService { get; } + public PPCService PPCService { get; } public MachineRtDataService MachineRtDataService { get; } public IDialogService DialogService { get; } public List ListChartRtValue { get; set; } = new List() @@ -239,11 +241,14 @@ namespace CapMachine.Wpf.ViewModels MachineRtDataService.SysMute(); - //ShowDialogExpInfo(); + //ShowDialogExpInfo(); break; case "试验信息": ShowDialogExpInfo(); break; + case "SuperHeatCool": + //ShowSuperHeatCool(); + break; default: break; } @@ -441,7 +446,9 @@ namespace CapMachine.Wpf.ViewModels } - + /// + /// 试验信息弹窗 + /// private void ShowDialogExpInfo() { //弹窗 @@ -463,6 +470,7 @@ namespace CapMachine.Wpf.ViewModels }); } + /// /// 获取曲线的实时值 /// 数据是发布过来 diff --git a/CapMachine.Wpf/Views/CANConfigView.xaml b/CapMachine.Wpf/Views/CANConfigView.xaml index 5c9df9d..a2a5314 100644 --- a/CapMachine.Wpf/Views/CANConfigView.xaml +++ b/CapMachine.Wpf/Views/CANConfigView.xaml @@ -59,7 +59,7 @@ VerticalAlignment="Center" FontFamily="/Assets/Fonts/#iconfont" FontSize="18" - Text="" /> + Text=" " /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +