using System; using System.Collections.Generic; using System.Windows; using System.Windows.Input; using Aitex.Core.Common.DeviceData; using Aitex.Core.RT.SCCore; 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 DiagnoseViewModel : UIViewModelBase { public ICommand LeakCheckCommand { get; private set; } public ICommand AbortCommand { get; private set; } public ICommand DeleteCommand { get; private set; } public ICommand RfCommand { 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(TritonDevice.Rf, SystemDeviceModule)] public AITRfData RfData { 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; } } public bool IsRfPowerOn { get { return RfData.IsRfOn; } } public bool IsRfPowerOff { get { return !RfData.IsRfOn; } } public bool IsMatchManualMode { get { return RfData.MatchMode == (int)TritonRfMatchMode.Manual; } } public bool IsMatchAutoMode { get { return RfData.MatchMode == (int)TritonRfMatchMode.Auto; } } [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; } [IgnorePropertyChange] public AITRfData RfDataSetPoint { 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 DiagnoseViewModel() : base("DiagnoseViewModel") { LeakCheckCommand = new DelegateCommand(LeakCheck); AbortCommand = new DelegateCommand(AbortLeakCheck); DeleteCommand = new DelegateCommand(DeleteLeakCheck); RfCommand = new DelegateCommand(DoRfOperation, CanDoRfOperation); 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"); RfDataSetPoint = new AITRfData(); RfData = new AITRfData(); } public void UpdateLeakCheckResult() { LeakCheckResultList = Triton160UiSystem.Instance.WCF.Query.GetHistoryLeakCheck(); InvokePropertyChanged("LeakCheckResultList"); } protected override void InvokeBeforeUpdateProperty(Dictionary data) { if (RfData!=null && string.IsNullOrEmpty(RfDataSetPoint.DeviceName) && !string.IsNullOrEmpty(RfData.DeviceName)) { RfDataSetPoint.DeviceName = RfData.DeviceName; RfDataSetPoint.MatchPositionC1SetPoint = RfData.MatchPositionC1SetPoint; RfDataSetPoint.MatchPositionC2SetPoint = RfData.MatchPositionC2SetPoint; RfDataSetPoint.PowerSetPoint = RfData.PowerSetPoint; RfDataSetPoint.InvokePropertyChanged("MatchPositionC1SetPoint"); RfDataSetPoint.InvokePropertyChanged("MatchPositionC2SetPoint"); RfDataSetPoint.InvokePropertyChanged("PowerSetPoint"); } _trigLeakCheckFinished.CLK = IsLeakCheck; if (_trigLeakCheckFinished.Q) { Application.Current.Dispatcher.Invoke(new Action(() => { UpdateLeakCheckResult(); })); } } private bool CanDoRfOperation(string param) { switch (param) { case "SetC1LowLow": return RfDataSetPoint.MatchPositionC1SetPoint > 4; case "SetC1Low": return RfDataSetPoint.MatchPositionC1SetPoint > 0; case "SetC1High": return RfDataSetPoint.MatchPositionC1SetPoint < 100; case "SetC1HighHigh": return RfDataSetPoint.MatchPositionC1SetPoint < 96; case "SetC2LowLow": return RfDataSetPoint.MatchPositionC2SetPoint > 4; case "SetC2Low": return RfDataSetPoint.MatchPositionC2SetPoint > 0; case "SetC2High": return RfDataSetPoint.MatchPositionC2SetPoint < 100; case "SetC2HighHigh": return RfDataSetPoint.MatchPositionC2SetPoint < 96; } return true; } private void DoRfOperation(string param) { switch (param) { case "PowerOn": WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetPowerOnOff.ToString(), "true" }); break; case "PowerOff": WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetPowerOnOff.ToString(), "false" }); break; case "SetPower": WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetPower.ToString(), RfDataSetPoint.PowerSetPoint.ToString() }); break; case "SetMatchManualMode": WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchMode.ToString(), ((int)TritonRfMatchMode.Manual).ToString() }); SetConfig(SCName.System_MatchMode, ((int)TritonRfMatchMode.Manual).ToString()); break; case "SetMatchAutoMode": WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchMode.ToString(), ((int)TritonRfMatchMode.Auto).ToString() }); SetConfig(SCName.System_MatchMode, ((int)TritonRfMatchMode.Auto).ToString()); break; case "SetC1": if (RfDataSetPoint.MatchPositionC1SetPoint<0 || RfDataSetPoint.MatchPositionC1SetPoint>100) { MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_C1ValueShouldBe0100CurrentSetting + RfDataSetPoint.MatchPositionC1SetPoint, Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_Warning, MessageBoxButton.OK); return; } WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC1.ToString(), (RfDataSetPoint.MatchPositionC1SetPoint).ToString() }); SetConfig(SCName.System_MatchPositionC1, (RfDataSetPoint.MatchPositionC1SetPoint).ToString()); break; case "SetC1LowLow": RfDataSetPoint.MatchPositionC1SetPoint = Math.Max(0,RfDataSetPoint.MatchPositionC1SetPoint-5); RfDataSetPoint.InvokePropertyChanged("MatchPositionC1SetPoint"); if (RfDataSetPoint.MatchPositionC1SetPoint < 0 || RfDataSetPoint.MatchPositionC1SetPoint > 100) { MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_C1ValueShouldBe0100CurrentSetting + RfDataSetPoint.MatchPositionC1SetPoint, Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_Warning, MessageBoxButton.OK); return; } WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC1.ToString(), (RfDataSetPoint.MatchPositionC1SetPoint).ToString() }); SetConfig(SCName.System_MatchPositionC1, (RfDataSetPoint.MatchPositionC1SetPoint).ToString()); break; case "SetC1Low": RfDataSetPoint.MatchPositionC1SetPoint = Math.Max(0, RfDataSetPoint.MatchPositionC1SetPoint - 1); RfDataSetPoint.InvokePropertyChanged("MatchPositionC1SetPoint"); if (RfDataSetPoint.MatchPositionC1SetPoint < 0 || RfDataSetPoint.MatchPositionC1SetPoint > 100) { MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_C1ValueShouldBe0100CurrentSetting + RfDataSetPoint.MatchPositionC1SetPoint, Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_Warning, MessageBoxButton.OK); return; } WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC1.ToString(), (RfDataSetPoint.MatchPositionC1SetPoint).ToString() }); SetConfig(SCName.System_MatchPositionC1, (RfDataSetPoint.MatchPositionC1SetPoint).ToString()); break; case "SetC1High": RfDataSetPoint.MatchPositionC1SetPoint = Math.Min(100, RfDataSetPoint.MatchPositionC1SetPoint +1); RfDataSetPoint.InvokePropertyChanged("MatchPositionC1SetPoint"); if (RfDataSetPoint.MatchPositionC1SetPoint < 0 || RfDataSetPoint.MatchPositionC1SetPoint > 100) { MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_C1ValueShouldBe0100CurrentSetting + RfDataSetPoint.MatchPositionC1SetPoint, Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_Warning, MessageBoxButton.OK); return; } WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC1.ToString(), (RfDataSetPoint.MatchPositionC1SetPoint).ToString() }); SetConfig(SCName.System_MatchPositionC1, (RfDataSetPoint.MatchPositionC1SetPoint).ToString()); break; case "SetC1HighHigh": RfDataSetPoint.MatchPositionC1SetPoint = Math.Min(100, RfDataSetPoint.MatchPositionC1SetPoint + 5); RfDataSetPoint.InvokePropertyChanged("MatchPositionC1SetPoint"); if (RfDataSetPoint.MatchPositionC1SetPoint < 0 || RfDataSetPoint.MatchPositionC1SetPoint > 100) { MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_C1ValueShouldBe0100CurrentSetting + RfDataSetPoint.MatchPositionC1SetPoint, Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_Warning, MessageBoxButton.OK); return; } WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC1.ToString(), (RfDataSetPoint.MatchPositionC1SetPoint).ToString() }); SetConfig(SCName.System_MatchPositionC1, (RfDataSetPoint.MatchPositionC1SetPoint).ToString()); break; case "SetC2": if (RfDataSetPoint.MatchPositionC2SetPoint < 0 || RfDataSetPoint.MatchPositionC2SetPoint > 100) { MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_C2ValueShouldBe0100CurrentSetting + RfDataSetPoint.MatchPositionC2SetPoint, Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_Warning, MessageBoxButton.OK); return; } WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC2.ToString(), (RfDataSetPoint.MatchPositionC2SetPoint).ToString() }); SetConfig(SCName.System_MatchPositionC2, (RfDataSetPoint.MatchPositionC2SetPoint).ToString()); break; case "SetC2LowLow": RfDataSetPoint.MatchPositionC2SetPoint = Math.Max(0, RfDataSetPoint.MatchPositionC2SetPoint - 5); RfDataSetPoint.InvokePropertyChanged("MatchPositionC2SetPoint"); if (RfDataSetPoint.MatchPositionC2SetPoint < 0 || RfDataSetPoint.MatchPositionC2SetPoint > 100) { MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_C2ValueShouldBe0100CurrentSetting + RfDataSetPoint.MatchPositionC2SetPoint, Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_Warning, MessageBoxButton.OK); return; } WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC2.ToString(), (RfDataSetPoint.MatchPositionC2SetPoint).ToString() }); SetConfig(SCName.System_MatchPositionC2, (RfDataSetPoint.MatchPositionC2SetPoint).ToString()); break; case "SetC2Low": RfDataSetPoint.MatchPositionC2SetPoint = Math.Max(0, RfDataSetPoint.MatchPositionC2SetPoint - 1); RfDataSetPoint.InvokePropertyChanged("MatchPositionC2SetPoint"); if (RfDataSetPoint.MatchPositionC2SetPoint < 0 || RfDataSetPoint.MatchPositionC2SetPoint > 100) { MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_C2ValueShouldBe0100CurrentSetting + RfDataSetPoint.MatchPositionC2SetPoint, Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_Warning, MessageBoxButton.OK); return; } WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC2.ToString(), (RfDataSetPoint.MatchPositionC2SetPoint).ToString() }); SetConfig(SCName.System_MatchPositionC2, (RfDataSetPoint.MatchPositionC2SetPoint).ToString()); break; case "SetC2High": RfDataSetPoint.MatchPositionC2SetPoint = Math.Min(100, RfDataSetPoint.MatchPositionC2SetPoint +1); RfDataSetPoint.InvokePropertyChanged("MatchPositionC2SetPoint"); if (RfDataSetPoint.MatchPositionC2SetPoint < 0 || RfDataSetPoint.MatchPositionC2SetPoint > 100) { MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_C2ValueShouldBe0100CurrentSetting + RfDataSetPoint.MatchPositionC2SetPoint, Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_Warning, MessageBoxButton.OK); return; } WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC2.ToString(), (RfDataSetPoint.MatchPositionC2SetPoint).ToString() }); SetConfig(SCName.System_MatchPositionC2, (RfDataSetPoint.MatchPositionC2SetPoint).ToString()); break; case "SetC2HighHigh": RfDataSetPoint.MatchPositionC2SetPoint = Math.Min(100, RfDataSetPoint.MatchPositionC2SetPoint + 5); RfDataSetPoint.InvokePropertyChanged("MatchPositionC2SetPoint"); if (RfDataSetPoint.MatchPositionC2SetPoint < 0 || RfDataSetPoint.MatchPositionC2SetPoint > 100) { MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_C2ValueShouldBe0100CurrentSetting + RfDataSetPoint.MatchPositionC2SetPoint, Aitex.Triton160.UI.Properties.Resources.DiagnoseViewModel_DoRfOperation_Warning, MessageBoxButton.OK); return; } WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeviceOperation.ToString(), new object[] { TritonDevice.Rf.ToString(), AITRfOperation.SetMatchPositionC2.ToString(), (RfDataSetPoint.MatchPositionC2SetPoint).ToString() }); SetConfig(SCName.System_MatchPositionC2, (RfDataSetPoint.MatchPositionC2SetPoint).ToString()); break; } } void SetConfig(string config, string value) { Triton160UiSystem.Instance.WCF.Invoker.DoOperation(TritonOperation.SetConfig.ToString(), config, value ); } 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(); } } }