using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Input; using Aitex.Core.Common.DeviceData; using Aitex.Core.UI.MVVM; using Aitex.Core.Util; using Aitex.Core.Utilities; using Aitex.Triton160.Common; using Aitex.Triton160.UI.Wcf; namespace Aitex.Triton160.UI.ViewModel { class LeakCheckViewModel : UIViewModelBase { public ICommand LeakCheckCommand { get; private set; } public ICommand AbortCommand { get; private set; } public ICommand DeleteCommand { get; private set; } public List LeakCheckResultList { get; set; } #region StateData [Subscription(StateData.IsAutoMode, SystemStateModule)] public bool IsAutoMode { get; set; } [Subscription(TritonDevice.PressureMeterChamber, SystemDeviceModule)] public AITPressureMeterData ChamberPressure { get; set; } [Subscription(StateData.PMState, SystemStateModule)] public int PMStatus { get; set; } [Subscription(StateData.LeakCheckElapseTime, SystemStateModule)] public string LeakCheckElapseTime { get; set; } #endregion #region logic display public bool IsManualMode { get { return !IsAutoMode; } } public bool IsEnableLeakCheck { get { return !IsAutoMode && (PMState)PMStatus == PMState.Idle; } } [IgnorePropertyChange] public string LeakCheckModeSetPoint { get; set; } public bool IsEnableGasLine { get { return LeakCheckModeSetPoint == "ChamberAndGasLine"; } } [IgnorePropertyChange] public string LeakCheckPumpDownTimeSetPoint { get; set; } [IgnorePropertyChange] public string LeakCheckTimeSetPoint { get; set; } [IgnorePropertyChange] public bool EnableGasLine1 { get; set; } [IgnorePropertyChange] public bool EnableGasLine2 { get; set; } [IgnorePropertyChange] public bool EnableGasLine3 { get; set; } [IgnorePropertyChange] public bool EnableGasLine4 { get; set; } [IgnorePropertyChange] public bool EnableGasLine5 { get; set; } public bool IsLeakCheck { get { return (PMState)PMStatus == PMState.LeakCheck; } } public string Status { get { return ((PMState) PMStatus).ToString(); } } public string Pressure { get { return ChamberPressure==null ? "0" : ChamberPressure.FeedBack.ToString("F0") + ChamberPressure.Unit; } } [IgnorePropertyChange] public LeakCheckResultItem CurrentLeakCheckResultItem { get; set; } F_TRIG _trigLeakCheckFinished = new F_TRIG(); #endregion public LeakCheckViewModel() : base("LeakCheckViewModel") { LeakCheckCommand = new DelegateCommand(LeakCheck); AbortCommand = new DelegateCommand(AbortLeakCheck); DeleteCommand = new DelegateCommand(DeleteLeakCheck); LeakCheckModeSetPoint = LeakCheckMode.ChamberOnly.ToString(); LeakCheckPumpDownTimeSetPoint = "3"; LeakCheckTimeSetPoint = "3"; EnableGasLine1 = true; EnableGasLine2 = true; EnableGasLine3 = true; EnableGasLine4 = true; EnableGasLine5 = true; InvokePropertyChanged("LeakCheckModeSetPoint"); InvokePropertyChanged("LeakCheckPumpDownTimeSetPoint"); InvokePropertyChanged("LeakCheckTimeSetPoint"); InvokePropertyChanged("EnableGasLine1"); InvokePropertyChanged("EnableGasLine2"); InvokePropertyChanged("EnableGasLine3"); InvokePropertyChanged("EnableGasLine4"); InvokePropertyChanged("EnableGasLine5"); } public void UpdateLeakCheckResult() { LeakCheckResultList = Triton160UiSystem.Instance.WCF.Query.GetHistoryLeakCheck(); InvokePropertyChanged("LeakCheckResultList"); } protected override void InvokeBeforeUpdateProperty(Dictionary data) { _trigLeakCheckFinished.CLK = IsLeakCheck; if (_trigLeakCheckFinished.Q) { Application.Current.Dispatcher.Invoke(new Action(() => { UpdateLeakCheckResult(); })); } } private void LeakCheck(object param) { WcfClient.Instance.InvokeService_DoOperation( TritonOperation.LeakCheck.ToString(), new[] { LeakCheckPumpDownTimeSetPoint, LeakCheckTimeSetPoint, LeakCheckModeSetPoint, EnableGasLine1.ToString(), EnableGasLine2.ToString(), EnableGasLine3.ToString(), EnableGasLine4.ToString(), EnableGasLine5.ToString(), }); } private void AbortLeakCheck(object param) { if (MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.LeakCheckViewModel_AbortLeakCheck_DoYouWantToStopCurrentLeakCheckRunning, "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes) WcfClient.Instance.InvokeService_DoOperation(TritonOperation.Abort.ToString()); } private void DeleteLeakCheck(object param) { if (CurrentLeakCheckResultItem == null) { MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.LeakCheckViewModel_DeleteLeakCheck_DidNotSelectLeakCheckResult, "JetPlasma", MessageBoxButton.OK); return; } if (MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.LeakCheckViewModel_DeleteLeakCheck_DoYouWantToDeleteCurrentLeakCheckResult, "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes) WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeleteLeakCheck.ToString(), CurrentLeakCheckResultItem.Id); UpdateLeakCheckResult(); } } }