| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 | 
							- using LiveCharts;
 
- using MECF.Framework.Common.DataCenter;
 
- using MECF.Framework.Common.OperationCenter;
 
- using Microsoft.Win32;
 
- using Prism.Commands;
 
- using Prism.Mvvm;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Collections.ObjectModel;
 
- using System.IO;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Windows.Threading;
 
- using Venus_Core;
 
- //using Venus_Core;
 
- using Venus_MainPages.Unity;
 
- using Venus_Unity;
 
- namespace Venus_MainPages.ViewModels
 
- {
 
-     internal class PartialPressureViewModel : BindableBase
 
-     {
 
-         #region 私有字段
 
-         private Dictionary<int, string> m_GasFlows = new Dictionary<int, string>();
 
-         //private object[] m_GasPressures = new object[10];
 
-         public string ModuleName;
 
-         private int m_GasIndex;
 
-         ChartValues<double> m_CurrentLineSeries= new ChartValues<double>();
 
-         ChartValues<double> m_ReferenceLineSeries = new ChartValues<double>();
 
-         Dictionary<int, string> CurrentGasFlows = new Dictionary<int, string>();
 
-         DispatcherTimer timer = new DispatcherTimer();
 
-         private int m_GasTime;
 
-         private string m_GasName;
 
-         private PartialPressureResult m_partialPressureResult;
 
-         string value;
 
-         int maxScale;
 
-         ObservableCollection<string> m_ReferenceFlow = new ObservableCollection<string>();
 
-         private bool m_MFC7IsEnable;
 
-         private bool m_MFC8IsEnable;
 
-         private bool m_MFC9IsEnable;
 
-         private bool m_MFC10IsEnable;
 
-         private bool m_MFC11IsEnable;
 
-         private bool m_MFC12IsEnable;
 
-         private bool m_IsAutoMode;
 
-         private PressureType m_PressureType;
 
-         #endregion
 
-         #region 属性
 
-         public PressureType PressureType
 
-         {
 
-             get { return m_PressureType; }
 
-             set { SetProperty(ref m_PressureType, value); }
 
-         }
 
-         public ObservableCollection<string> ReferenceFlow
 
-         {
 
-             get { return m_ReferenceFlow; }
 
-             set { SetProperty(ref m_ReferenceFlow, value); }
 
-         }
 
-         public Dictionary<int, string> GasFlows
 
-         {
 
-             get { return m_GasFlows; }
 
-             set { SetProperty(ref m_GasFlows, value); }
 
-         }
 
-         public ChartValues<double> CurrentLineSeries
 
-         {
 
-             get { return m_CurrentLineSeries; }
 
-             set { SetProperty(ref m_CurrentLineSeries, value); }
 
-         }
 
-         public ChartValues<double> ReferenceLineSeries
 
-         {
 
-             get { return m_ReferenceLineSeries; }
 
-             set { SetProperty(ref m_ReferenceLineSeries, value); }
 
-         }
 
-         public int GasTime
 
-         {
 
-             get { return m_GasTime; }
 
-             set { SetProperty(ref m_GasTime, value); }
 
-         }
 
-         public string GasName
 
-         {
 
-             get { return m_GasName; }
 
-             set { SetProperty(ref m_GasName, value); }
 
-         }
 
-         public bool MFC7IsEnable
 
-         {
 
-             get { return m_MFC7IsEnable; }
 
-             set { SetProperty(ref m_MFC7IsEnable, value); }
 
-         }
 
-         public bool MFC8IsEnable
 
-         {
 
-             get { return m_MFC8IsEnable; }
 
-             set { SetProperty(ref m_MFC8IsEnable, value); }
 
-         }
 
-         public bool MFC9IsEnable
 
-         {
 
-             get { return m_MFC9IsEnable; }
 
-             set { SetProperty(ref m_MFC9IsEnable, value); }
 
-         }
 
-         public bool MFC10IsEnable
 
-         {
 
-             get { return m_MFC10IsEnable; }
 
-             set { SetProperty(ref m_MFC10IsEnable, value); }
 
-         }
 
-         public bool MFC11IsEnable
 
-         {
 
-             get { return m_MFC11IsEnable; }
 
-             set { SetProperty(ref m_MFC11IsEnable, value); }
 
-         }
 
-         public bool MFC12IsEnable
 
-         {
 
-             get { return m_MFC12IsEnable; }
 
-             set { SetProperty(ref m_MFC12IsEnable, value); }
 
-         }
 
-         public bool IsAutoMode
 
-         {
 
-             get { return m_IsAutoMode; }
 
-             set { SetProperty(ref m_IsAutoMode, value); }
 
-         }
 
-         #endregion
 
-         #region 命令
 
-         private DelegateCommand<object> _SelectGasCommand;
 
-         public DelegateCommand<object> SelectGasCommand =>
 
-             _SelectGasCommand ?? (_SelectGasCommand = new DelegateCommand<object>(OnSelectGas));
 
-         private DelegateCommand _StartCommand;
 
-         public DelegateCommand StartCommand =>
 
-             _StartCommand ?? (_StartCommand = new DelegateCommand(OnStart));
 
-         private DelegateCommand _SaveCommand;
 
-         public DelegateCommand SaveCommand =>
 
-             _SaveCommand ?? (_SaveCommand = new DelegateCommand(OnSave));
 
-         private DelegateCommand _LoadReferenceCommand;
 
-         public DelegateCommand LoadReferenceCommand =>
 
-             _LoadReferenceCommand ?? (_LoadReferenceCommand = new DelegateCommand(OnLoadReference));
 
-         private DelegateCommand _AbortCommand;
 
-         public DelegateCommand AbortCommand =>
 
-             _AbortCommand ?? (_AbortCommand = new DelegateCommand(OnAbort));
 
-         private DelegateCommand _LoadCommand;
 
-         public DelegateCommand LoadCommand =>
 
-             _LoadCommand ?? (_LoadCommand = new DelegateCommand(OnLoad));
 
-         #endregion
 
-         #region 构造函数
 
-         public PartialPressureViewModel()
 
-         {
 
-             GasTime = 60;
 
-             for (int i = 1; i < 11; i++)
 
-             {
 
-                 GasFlows.Add(i, (10 * i).ToString());
 
-             }
 
-             timer.Interval = TimeSpan.FromSeconds(1);
 
-             timer.Tick += Timer_Tick;           
 
-         }
 
-         #endregion
 
-         #region 命令方法
 
-         private void OnLoad()
 
-         {
 
-             var jetChamber = (JetChamber)Enum.Parse(typeof(JetChamber), QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.ChamberType").ToString());
 
-             if (jetChamber == JetChamber.Kepler2200A || jetChamber == JetChamber.Kepler2200B)
 
-             {
 
-                 PressureType = PressureType.Pa;
 
-             }
 
-         }
 
-         private void OnSelectGas(object obj)
 
-         {
 
-             CurrentGasFlows.Clear();
 
-             value = $"MfcGas{obj.ToString()}";
 
-             maxScale= Convert.ToInt32(QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.{value}.MfcN2Scale"));
 
-             var xishu = Convert.ToDouble(QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.{value}.MfcScaleFactor"));
 
-             GasName = QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.{value}.GasName").ToString();
 
-             for (int i = 1; i < 11; i++)
 
-             {
 
-                 CurrentGasFlows.Add(i, (maxScale * xishu / 10 * i).ToString());
 
-             }
 
-             GasFlows = CurrentGasFlows;
 
-             m_GasIndex = Convert.ToInt32(obj);
 
-         }
 
-         private  void OnStart()
 
-         {
 
-             timer.Start();
 
-             InvokeClient.Instance.Service.DoOperation($"{ModuleName}.PartialPressureTest", m_GasIndex,1000* GasTime);         
 
-         }
 
-         private void OnSave()
 
-         {
 
-             SerializeHelper.Instance.WriteToJsonFile<PartialPressureResult>(m_partialPressureResult, $"PartialPressureResult/{m_partialPressureResult.GasName}/{DateTime.Now.ToString("yyyyMMddHHmm")}.json");
 
-         }
 
-         private void OnLoadReference()
 
-         {
 
-             OpenFileDialog dialog = new OpenFileDialog();
 
-             dialog.Filter = ".json|*.json";
 
-             dialog.InitialDirectory = Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "PartialPressureResult");
 
-             if (dialog.ShowDialog() == true)
 
-             {
 
-                 string SelectedPath = dialog.FileName;
 
-                 var value = SerializeHelper.Instance.ReadFromJsonFile<PartialPressureResult>(SelectedPath);
 
-                 ReferenceLineSeries.Clear();
 
-                 ReferenceFlow.Clear();
 
-                 value.ValuePairs.ForEach(x =>
 
-                 {
 
-                     ReferenceFlow.Add(x.Flow);
 
-                     ReferenceLineSeries.Add(x.Pressure);
 
-                 });
 
-             }
 
-             else
 
-             {
 
-                 ReferenceLineSeries.Clear();
 
-                 //ReferenceLineSeries.Insert(20, 0);
 
-                 ReferenceLineSeries.Add(0);
 
-                 ReferenceFlow.Clear();
 
-             }       
 
-         }
 
-         private void OnAbort()
 
-         {
 
-             timer.Stop();
 
-             InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Abort");
 
-             CurrentLineSeries = new ChartValues<double>();
 
-         }
 
-         #endregion
 
-         #region 私有方法
 
-         private void Timer_Tick(object sender, EventArgs e)
 
-         {           
 
-             CurrentLineSeries.Clear();
 
-             var values = QueryDataClient.Instance.Service.GetData($"{ModuleName}.PartialPressureResult").ToString();
 
-             values.Split(',').ToList().ForEach(x =>
 
-             {
 
-                 if (x != "")
 
-                 {
 
-                     CurrentLineSeries.Add(Math.Round(Convert.ToDouble(x), 3));
 
-                 }
 
-             });
 
-             if (CurrentLineSeries.Count == 10)
 
-             {
 
-                 timer.Stop();
 
-             }
 
-             IsAutoMode = (bool)QueryDataClient.Instance.Service.GetData($"{ModuleName}.IsOnline");
 
-         }
 
-         public void Init()
 
-         {                
 
-            
 
-             var jetChamber = (JetChamber)Enum.Parse(typeof(JetChamber), QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.ChamberType").ToString());
 
-             if (jetChamber != JetChamber.Kepler2200A && jetChamber != JetChamber.Kepler2200B)
 
-             {
 
-                 MFC7IsEnable = (bool)QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.MfcGas7.Enable");
 
-                 MFC8IsEnable = (bool)QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.MfcGas8.Enable");
 
-             }
 
-             if (jetChamber == JetChamber.VenusSE|| jetChamber == JetChamber.VenusDE)
 
-             {
 
-                 MFC9IsEnable = (bool)QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.MfcGas9.Enable");
 
-                 MFC10IsEnable = (bool)QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.MfcGas10.Enable");
 
-                 MFC11IsEnable = (bool)QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.MfcGas11.Enable");
 
-                 MFC12IsEnable = (bool)QueryDataClient.Instance.Service.GetConfig($"{ModuleName}.MfcGas12.Enable");
 
-             }
 
-         }
 
-         #endregion
 
-     }
 
- }
 
 
  |