123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- using System;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.UI.MVVM;
- using MECF.Framework.Common.CommonData;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Net.Configuration;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- using DocumentFormat.OpenXml.Presentation;
- using MECF.Framework.Common.Equipment;
- using FurnaceRT.Equipments.PMs;
- using FurnaceRT.Equipments.Systems;
- namespace FurnaceRT.Backends
- {
- /// <summary>
- /// BackendPressureTuneView.xaml 的交互逻辑
- /// </summary>
- public partial class BackendPressureTuneView : UserControl
- {
- public BackendPressureTuneView()
- {
- InitializeComponent();
- this.Loaded += SCConfigView_Loaded;
- this.IsVisibleChanged += BackendSCConfigView_IsVisibleChanged;
- }
- private void BackendSCConfigView_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
- {
- if (this.DataContext == null)
- {
- DataContext = new BackendPressureTuneViewModel();
- }
- (this.DataContext as BackendPressureTuneViewModel).Reload("");
- }
- private void SCConfigView_Loaded(object sender, RoutedEventArgs e)
- {
- if (this.DataContext == null)
- {
- DataContext = new BackendPressureTuneViewModel();
- }
- }
- }
- public class BackendPressureTuneViewModel : ViewModelBase
- {
-
- public ICommand SaveCommand { get; set; }
- public ICommand ReloadCommand { get; set; }
- public bool IsEnable1
- {
- get;
- set;
- }
- public bool IsEnable2
- {
- get;
- set;
- }
- public string Tuning1
- {
- get;
- set;
- }
- public string Tuning2
- {
- get;
- set;
- }
-
- public BackendPressureTuneViewModel()
- {
-
- Init();
- SaveCommand = new DelegateCommand<string>(PerformSave);
- ReloadCommand = new DelegateCommand<string>(Reload);
- }
- private void PerformSave(string obj)
- {
- try
- {
-
- SC.SetItemValue($"PM.PM1.LeakCheck.EnableTuning", IsEnable1);
- SC.SetItemValue($"PM.PM2.LeakCheck.EnableTuning", IsEnable2);
- SC.SetItemValue($"PM.PM1.LeakCheck.TuningPercent", double.Parse(Tuning1));
- SC.SetItemValue($"PM.PM2.LeakCheck.TuningPercent", double.Parse(Tuning2));
- MessageBox.Show("Tune setting Saved");
- }
- catch (Exception ex)
- {
- MessageBox.Show("value not valid, failed save setting");
- LOG.Write(ex);
- }
- }
- public void Reload( string obj)
- {
- Init();
- }
- void Init()
- {
- IsEnable1 = SC.GetValue<bool>($"PM.PM1.LeakCheck.EnableTuning");
- Tuning1 = SC.GetValue<double>($"PM.PM1.LeakCheck.TuningPercent").ToString("F2");
- IsEnable2 = SC.GetValue<bool>($"PM.PM2.LeakCheck.EnableTuning");
- Tuning2 = SC.GetValue<double>($"PM.PM2.LeakCheck.TuningPercent").ToString("F2");
- InvokeAllPropertyChanged();
- }
- }
- }
|