using Aitex.Common.Util; using Aitex.Core.Util; using Aitex.Core.RT.SCCore; using Aitex.Core.Common.DeviceData; using Caliburn.Micro; using MECF.Framework.Common.IOCore; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.OperationCenter; using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig; using MECF.Framework.UI.Client.CenterViews.Dialogs; using OpenSEMI.ClientBase; using Caliburn.Micro.Core; using OpenSEMI.ClientBase.Command; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Xml; using System.Windows.Media; using MECF.Framework.Common.CommonData; using MECF.Framework.Common.Utilities; using Aitex.Core.RT.Log; using MECF.Framework.UI.Client.ClientBase; namespace MECF.Framework.UI.Client.CenterViews.Parameter { public class InterlockViewModel : ModuleUiViewModelBase { public bool IsPermission { get => this.Permission == 3; } private ObservableCollection _interlockTreePM = new ObservableCollection(); public ObservableCollection InterlockTreePM { get => _interlockTreePM; set { _interlockTreePM = value; NotifyOfPropertyChange(nameof(InterlockTreePM)); } } private SolidColorBrush _greenFill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF07FF07")); private SolidColorBrush _redFill = new SolidColorBrush(Colors.Red); private ObservableCollection _interlockTreeMF = new ObservableCollection(); public ObservableCollection InterlockTreeMF { get => _interlockTreeMF; set { _interlockTreeMF = value; NotifyOfPropertyChange(nameof(InterlockTreeMF)); } } private ObservableCollection _interlockTreeEdit = new ObservableCollection(); public ObservableCollection InterlockTreeEdit { get => _interlockTreeEdit; set { _interlockTreeEdit = value; NotifyOfPropertyChange(nameof(InterlockTreeEdit)); } } public InterlockBase CurrentInterlock = new InterlockBase(); public ObservableCollection InterlockLimits { get; set; } = new ObservableCollection(); private int _interlockLimitsSelectIndex; public int InterlockLimitSelectIndex { get => _interlockLimitsSelectIndex; set { _interlockLimitsSelectIndex = value; NotifyOfPropertyChange(nameof(InterlockLimitSelectIndex)); } } private bool _isShowInterlockMF = true; public bool IsShowInterlockMF { get => _isShowInterlockMF; set { _isShowInterlockMF = value; NotifyOfPropertyChange(nameof(IsShowInterlockMF)); } } private bool _isShowInterlockPM = false; public bool IsShowInterlockPM { get => _isShowInterlockPM; set { _isShowInterlockPM = value; NotifyOfPropertyChange(nameof(IsShowInterlockPM)); } } private bool _isShowInterlockEdit = false; public bool IsShowInterlockEdit { get => _isShowInterlockEdit; set { _isShowInterlockEdit = value; NotifyOfPropertyChange(nameof(IsShowInterlockEdit)); } } private bool _isShowInterlockEditDetail = false; public bool IsShowInterlockEditDetail { get => _isShowInterlockEditDetail; set { _isShowInterlockEditDetail = value; NotifyOfPropertyChange(nameof(IsShowInterlockEditDetail)); } } private List _interlockEditAction = new List(); public List InterlockEditAction { get => _interlockEditAction; set { _interlockEditAction = value; NotifyOfPropertyChange(nameof(InterlockEditAction)); } } private string _interlockEditActionSelect; public string InterLockEditActionSelect { get => _interlockEditActionSelect; set { _interlockEditActionSelect = value; NotifyOfPropertyChange(nameof(InterLockEditActionSelect)); } } private List _interlockEditLimit = new List(); public List InterlockEditLimit { get => _interlockEditLimit; set { _interlockEditLimit = value; NotifyOfPropertyChange(nameof(InterlockEditLimit)); } } private string _interlockEditLimitSelect; public string InterLockEditLimitSelect { get => _interlockEditLimitSelect; set { _interlockEditLimitSelect = value; NotifyOfPropertyChange(nameof(InterLockEditLimitSelect)); } } private int _interlockEditLimitSelectIndex; public int InterlockEditLimitSelectIndex { get => _interlockEditLimitSelectIndex; set { _interlockEditLimitSelectIndex = value; NotifyOfPropertyChange(nameof(InterlockEditLimitSelectIndex)); } } private bool _actionValueTrue; public bool ActionValueTrue { get => _actionValueTrue; set { _actionValueTrue = value; NotifyOfPropertyChange(nameof(ActionValueTrue)); } } private bool _actionValueFalse; public bool ActionValueFalse { get => _actionValueFalse; set { _actionValueFalse = value; NotifyOfPropertyChange(nameof(ActionValueFalse)); } } private bool _limitValueTrue; public bool LimitValueTrue { get => _limitValueTrue; set { _limitValueTrue = value; NotifyOfPropertyChange(nameof(LimitValueTrue)); } } private bool _limitValueFalse; public bool LimitValueFalse { get => _limitValueFalse; set { _limitValueFalse = value; NotifyOfPropertyChange(nameof(LimitValueFalse)); } } private string _limitValueTrueName = "true"; public string LimitValueTrueName { get => _limitValueTrueName; set { _limitValueTrueName = value; NotifyOfPropertyChange(nameof(LimitValueTrueName)); } } private string _limitValueFalseName = "false"; public string LimitValueFalseName { get => _limitValueFalseName; set { _limitValueFalseName = value; NotifyOfPropertyChange(nameof(LimitValueFalseName)); } } private bool _limitConditionAND; public bool LimitConditionAND { get => _limitConditionAND; set { _limitConditionAND = value; NotifyOfPropertyChange(nameof(LimitConditionAND)); } } private bool _limitConditionOR; public bool LimitConditionOR { get => _limitConditionOR; set { _limitConditionOR = value; NotifyOfPropertyChange(nameof(LimitConditionOR)); } } private Visibility _isShowLimitValue = Visibility.Hidden; public Visibility IsShowLimitValue { get => _isShowLimitValue; set { _isShowLimitValue = value; NotifyOfPropertyChange(nameof(IsShowLimitValue)); } } private bool _isInterlockEdit; public bool IsInterlockEdit { get => _isInterlockEdit; set { _isInterlockEdit = value; NotifyOfPropertyChange(nameof(IsInterlockEdit)); } } private bool _isInterlockEditCancel; public bool IsInterlockEditCancel { get => _isInterlockEditCancel; set { _isInterlockEditCancel = value; NotifyOfPropertyChange(nameof(IsInterlockEditCancel)); } } private bool _isInterlockEditSet = false; private List _moduleName = new List() { "PM1" }; private string _actionItem = "BLANK"; public string ActionItem { get => _actionItem; set { _actionItem = value; NotifyOfPropertyChange(nameof(ActionItem)); } } private string _actionCheck = "BLANK"; public string ActionCheck { get => _actionCheck; set { _actionCheck = value; NotifyOfPropertyChange(nameof(ActionCheck)); } } private string _actionTimeCheck = "BLANK"; public string ActionTimeCheck { get => _actionTimeCheck; set { _actionTimeCheck = value; NotifyOfPropertyChange(nameof(ActionTimeCheck)); } } private string _actionValue; public string ActionValue { get => _actionValue; set { _actionValue = value; NotifyOfPropertyChange(nameof(ActionValue)); } } private string _actionTimeValue = "0"; public string ActionTimeValue { get => _actionTimeValue; set { _actionTimeValue = value; NotifyOfPropertyChange(nameof(ActionTimeValue)); } } private string _actionAuto = "Auto"; public string ActionAuto { get => _actionAuto; set { _actionAuto = value; NotifyOfPropertyChange(nameof(ActionAuto)); } } private bool _isEnabledActionTimeValue; public bool IsEnabledActionTimeValue { get => _isEnabledActionTimeValue; set { _isEnabledActionTimeValue = value; NotifyOfPropertyChange(nameof(IsEnabledActionTimeValue)); } } private string _limitItem = "BLANK"; public string LimitItem { get => _limitItem; set { _limitItem = value; NotifyOfPropertyChange(nameof(LimitItem)); } } private string _limitCondition = "AND"; public string LimitCondition { get => _limitCondition; set { _limitCondition = value; NotifyOfPropertyChange(nameof(LimitCondition)); } } private string _limitCheck = "BLANK"; public string LimitCheck { get => _limitCheck; set { _limitCheck = value; NotifyOfPropertyChange(nameof(LimitCheck)); } } private string _limitValue = "0"; public string LimitValue { get => _limitValue; set { _limitValue = value; NotifyOfPropertyChange(nameof(LimitValue)); } } private string _limitUnit; public string LimitUnit { get => _limitUnit; set { _limitUnit = value; NotifyOfPropertyChange(nameof(LimitUnit)); } } private bool _isEnabledLimitValue; public bool IsEnabledLimitValue { get => _isEnabledLimitValue; set { _isEnabledLimitValue = value; NotifyOfPropertyChange(nameof(IsEnabledLimitValue)); } } private Dictionary _editInterlockIOReferenceDic; private Dictionary _editLimitCheckReferenceDic; #region PM [Subscription("IO.PM1.DI_CAPClosePosition")] public bool PM1_DI_PumpDI_CAPClosePosition { get; set; } [Subscription("IO.PM1.DI_PumpON")] public bool DI_PumpON { get; set; } [Subscription("IO.PM1.DO_MVValveOpen")] public bool PM1_DO_MVValveOpen { get; set; } [Subscription("IO.PM1.DO_J11ValveOpen")] public bool PM1_DO_J11ValveOpen { get; set; } [Subscription("IO.PM1.DI_J11REALOUT")] public bool PM1_DI_J11REALOUT { get; set; } [Subscription("IO.PM1.DI_HeaterMCON")] public bool PM1_DI_HeaterMCON { get; set; } [Subscription("IO.PM1.DI_GASDetectorOK")] public bool PM1_DI_GASDetectorOK { get; set; } [Subscription("IO.PM1.DI_CAPClosePosition")] public bool PM1_DI_CAPClosePosition { get; set; } [Subscription("IO.PM1.DI_M11REALOUT")] public bool PM1_DI_M11REALOUT { get; set; } [Subscription("IO.PM1.DI_M21REALOUT")] public bool PM1_DI_M21REALOUT { get; set; } [Subscription("IO.PM1.DO_M11ValveOpen")] public bool PM1_DO_M11ValveOpen { get; set; } [Subscription("IO.PM1.DO_M21ValveOpen")] public bool PM1_DO_M21ValveOpen { get; set; } [Subscription("IO.PM1.DO_D11ValveOpen")] public bool PM1_DO_D11ValveOpen { get; set; } [Subscription("IO.PM1.DI_D11REALOUT")] public bool PM1_DI_D11REALOUT { get; set; } [Subscription("IO.PM1.DI_TubeATMPressure")] public bool PM1_DI_TubeATMPressure { get; set; } [Subscription("IO.PM1.DI_HeaterWaterFlowOK")] public bool PM1_DI_HeaterWaterFlowOK { get; set; } [Subscription("IO.PM1.DI_MFWaterFlowOK")] public bool PM1_DI_MFWaterFlowOK { get; set; } [Subscription("IO.PM1.DI_CAPWaterFlowOK")] public bool PM1_DI_CAPWaterFlowOK { get; set; } [Subscription("IO.PM1.DI_A_SWaterFlowOK")] public bool PM1_DI_A_SWaterFlowOK { get; set; } [Subscription("IO.PM1.DI_SpareWaterFlowOK")] public bool PM1_DI_SpareWaterFlowOK { get; set; } [Subscription("IO.PM1.DI_HeaterTempOK")] public bool PM1_DI_HeaterTempOK { get; set; } [Subscription("IO.PM1.DI_ChamberTempOK")] public bool PM1_DI_ChamberTempOK { get; set; } [Subscription("IO.PM1.DI_SCRTempOK")] public bool PM1_DI_SCRTempOK { get; set; } [Subscription("IO.PM1.DI_FNCPanelClose")] public bool PM1_DI_FNCPanelClose { get; set; } [Subscription("IO.PM1.DI_HeaterControllerOK")] public bool PM1_DI_HeaterControllerOK { get; set; } [Subscription("IO.PM1.DI_CAPOpenPosition")] public bool PM1_DI_CAPOpenPosition { get; set; } [Subscription("IO.PM1.DI_HtRCUPowerON")] public bool PM1_DI_HtRCUPowerON { get; set; } [Subscription("IO.PM1.DI_HECDoorClosed")] public bool PM1_DI_HECDoorClosed { get; set; } [Subscription("IO.PM1.DI_HECWaterLeakDetectOK")] public bool PM1_DI_HECWaterLeakDetectOK { get; set; } [Subscription("IO.PM1.DI_HECWaterLevelOK")] public bool PM1_DI_HECWaterLevelOK { get; set; } [Subscription("IO.PM1.DI_HECTempOK")] public bool PM1_DI_HECTempOK { get; set; } #endregion #region MF [Subscription("IO.MF.DI_ASOpenPosition")] public bool MF_DI_ASOpenPosition { get; set; } [Subscription("IO.MF.DI_ASDownPosition")] public bool MF_DI_ASDownPosition { get; set; } [Subscription("IO.MF.DI_BEHumanInterlockSensor")] public bool MF_DI_BEHumanInterlockSensor { get; set; } [Subscription("IO.MF.DI_ASTiltStatus")] public bool MF_DI_ASTiltStatus { get; set; } [Subscription("IO.MF.DI_R5ArmNotExtendToBE")] public bool MF_DI_R5ArmNotExtendToBE { get; set; } [Subscription("IO.EFEM.DI_Stage1LockPosition")] public bool EFEM_DI_Stage1LockPosition { get; set; } [Subscription("IO.EFEM.DI_Stage1CASSPresenceSensor")] public bool EFEM_DI_Stage1CASSPresenceSensor { get; set; } [Subscription("IO.EFEM.DI_R3NotExtendToStage1")] public bool EFEM_DI_R3NotExtendToStage1 { get; set; } [Subscription("IO.EFEM.DI_Stage2LockPosition")] public bool EFEM_DI_Stage2LockPosition { get; set; } [Subscription("IO.EFEM.DI_Stage2CASSPresenceSensor")] public bool EFEM_DI_Stage2CASSPresenceSensor { get; set; } [Subscription("IO.EFEM.DI_R3NotExtendToStage2")] public bool EFEM_DI_R3NotExtendToStage2 { get; set; } [Subscription("IO.EFEM.DI_Stage1UnlockPosition")] public bool EFEM_DI_Stage1UnlockPosition { get; set; } [Subscription("IO.EFEM.DI_R5NotExtendToStage1")] public bool EFEM_DI_R5NotExtendToStage1 { get; set; } [Subscription("IO.EFEM.DI_Stage2UnlockPosition")] public bool EFEM_DI_Stage2UnlockPosition { get; set; } [Subscription("IO.EFEM.DI_R5NotExtendToStage2")] public bool EFEM_DI_R5NotExtendToStage2 { get; set; } [Subscription("IO.MF.DI_ZAxisUpLimit")] public bool MF_DI_ZAxisUpLimit { get; set; } [Subscription("IO.MF.DI_ZAxisDownLimit")] public bool MF_DI_ZAxisDownLimit { get; set; } [Subscription("IO.MF.DI_TAxisHome")] public bool MF_DI_TAxisHome { get; set; } [Subscription("IO.MF.DI_Smif1SlideAxisRetractSensor")] public bool MF_DI_Smif1SlideAxisRetractSensor { get; set; } [Subscription("IO.MF.DO_R3ExtendToSmif1Enable")] public bool MF_DO_R3ExtendToSmif1Enable { get; set; } [Subscription("IO.MF.DI_Smif2SlideAxisRetractSensor")] public bool MF_DI_Smif2SlideAxisRetractSensor { get; set; } [Subscription("IO.MF.DO_R3ExtendToSmif2Enable")] public bool MF_DO_R3ExtendToSmif2Enable { get; set; } [Subscription("IO.MF.DI_ASUpPosition")] public bool MF_DI_ASUpPosition { get; set; } [Subscription("IO.MF.DI_ASOpenStatus")] public bool MF_DI_ASOpenStatus { get; set; } [Subscription("IO.SMIF.DI_Smif1PodUnlockPositionSersor")] public bool SMIF_DI_Smif1PodUnlockPositionSersor { get; set; } [Subscription("IO.SMIF.DI_Smif1PodPresenceSensor")] public bool SMIF_DI_Smif1PodPresenceSensor { get; set; } [Subscription("IO.SMIF.DI_Smif1PodLockPosition")] public bool SMIF_DI_Smif1PodLockPosition { get; set; } [Subscription("IO.SMIF.DI_Smif1PodClosePositionSensor")] public bool SMIF_DI_Smif1PodClosePositionSensor { get; set; } [Subscription("IO.SMIF.DI_Smif1PodOpenPositionSensor")] public bool SMIF_DI_Smif1PodOpenPositionSensor { get; set; } [Subscription("IO.SMIF.DI_Smif1ZAxisPosition1Sensor")] public bool SMIF_DI_Smif1ZAxisPosition1Sensor { get; set; } [Subscription("IO.SMIF.DI_Smif1RotateAxisCheckSensor2")] public bool SMIF_DI_Smif1RotateAxisCheckSensor2 { get; set; } [Subscription("IO.SMIF.DI_R3ArmNotExtendToSmif1")] public bool SMIF_DI_R3ArmNotExtendToSmif1 { get; set; } [Subscription("IO.SMIF.DI_Smif1RotateAxisCheckSensor1")] public bool SMIF_DI_Smif1RotateAxisCheckSensor1 { get; set; } [Subscription("IO.SMIF.DI_Smif1ZAxisPosition2Sensor")] public bool SMIF_DI_Smif1ZAxisPosition2Sensor { get; set; } [Subscription("IO.SMIF.DI_Smif1SlideAxisRetractSensor")] public bool SMIF_DI_Smif1SlideAxisRetractSensor { get; set; } [Subscription("IO.SMIF.DI_Smif1SlideAxisExtendSensor")] public bool SMIF_DI_Smif1SlideAxisExtendSensor { get; set; } [Subscription("IO.SMIF.DI_Smif1ProtrudedWaferSensor")] public bool SMIF_DI_Smif1ProtrudedWaferSensor { get; set; } [Subscription("IO.SMIF.DI_Smif1ZAxisUnloadPositionSensor")] public bool SMIF_DI_Smif1ZAxisUnloadPositionSensor { get; set; } [Subscription("IO.SMIF.DI_Smif1ZAxisLoadPositionSensor")] public bool SMIF_DI_Smif1ZAxisLoadPositionSensor { get; set; } [Subscription("IO.SMIF.DI_Smif2PodUnlockPositionSersor")] public bool SMIF_DI_Smif2PodUnlockPositionSersor { get; set; } [Subscription("IO.SMIF.DI_Smif2PodPresenceSensor")] public bool SMIF_DI_Smif2PodPresenceSensor { get; set; } [Subscription("IO.SMIF.DI_Smif2PodLockPosition")] public bool SMIF_DI_Smif2PodLockPosition { get; set; } [Subscription("IO.SMIF.DI_Smif2PodClosePositionSensor")] public bool SMIF_DI_Smif2PodClosePositionSensor { get; set; } [Subscription("IO.SMIF.DI_Smif2PodOpenPositionSensor")] public bool SMIF_DI_Smif2PodOpenPositionSensor { get; set; } [Subscription("IO.SMIF.DI_Smif2ZAxisPosition1Sensor")] public bool SMIF_DI_Smif2ZAxisPosition1Sensor { get; set; } [Subscription("IO.SMIF.DI_Smif2RotateAxisCheckSensor2")] public bool SMIF_DI_Smif2RotateAxisCheckSensor2 { get; set; } [Subscription("IO.SMIF.DI_R3ArmNotExtendToSmif2")] public bool SMIF_DI_R3ArmNotExtendToSmif2 { get; set; } [Subscription("IO.SMIF.DI_Smif2RotateAxisCheckSensor1")] public bool SMIF_DI_Smif2RotateAxisCheckSensor1 { get; set; } [Subscription("IO.SMIF.DI_Smif2ZAxisPosition2Sensor")] public bool SMIF_DI_Smif2ZAxisPosition2Sensor { get; set; } [Subscription("IO.SMIF.DI_Smif2SlideAxisExtendSensor")] public bool SMIF_DI_Smif2SlideAxisExtendSensor { get; set; } [Subscription("IO.SMIF.DI_Smif2ProtrudedWaferSensor")] public bool SMIF_DI_Smif2ProtrudedWaferSensor { get; set; } [Subscription("IO.SMIF.DI_Smif2ZAxisUnloadPositionSensor")] public bool SMIF_DI_Smif2ZAxisUnloadPositionSensor { get; set; } [Subscription("IO.SMIF.DI_Smif2ZAxisLoadPositionSensor")] public bool SMIF_DI_Smif2ZAxisLoadPositionSensor { get; set; } #endregion public InterlockViewModel() { } protected override void OnInitialize() { base.OnInitialize(); InitEditInterlockIODic(); InitMFTree(""); InitPMTree(""); InitEditTree(""); InitActionLists(); InitLimitLists(); } private void InitEditInterlockIODic() { _editInterlockIOReferenceDic = new Dictionary() { {"EXTIN001", "PM1.DI_FNCPowerLatchON" }, {"EXTIN002", "PM1.DI_HeaterPowerONSW" }, {"EXTIN003", "PM1.DI_PCMCON" }, {"EXTIN004", "PM1.DI_HeaterMCON" }, {"EXTIN005", "PM1.DI_FNCBreakTrip" }, {"EXTIN006", "PM1.DI_HeaterBreakTrip" }, {"EXTIN007", "PM1.DI_HeaterPowerOK" }, {"EXTIN008", "PM1.DI_SCRFAN1OK" }, {"EXTIN009", "PM1.DI_SCRFAN2OK" }, {"EXTIN010", "PM1.DI_EXHFanOK" }, {"EXTIN011", "PM1.DI_EnvironmentTempOK" }, {"EXTIN012", "PM1.DI_HeaterOHOK" }, {"EXTIN013", "PM1.DI_FNCWaterLeakDetOK" }, {"EXTIN014", "PM1.DI_CKDMVInnerTemp" }, {"EXTIN015", "PM1.DI_CKDMVOuterTemp" }, {"EXTIN016", "PM1.DI_HeaterBreakOK" }, {"EXTIN017", "PM1.DI_HeaterWaterFlowOK" }, {"EXTIN018", "PM1.DI_HeaterWaterFlowOK1" }, {"EXTIN019", "PM1.DI_MFWaterFlowOK" }, {"EXTIN020", "PM1.DI_MFWaterFlowOK1" }, {"EXTIN021", "PM1.DI_CAPWaterFlowOK" }, {"EXTIN022", "PM1.DI_CAPWaterFlowOK1" }, {"EXTIN023", "PM1.DI_ASWaterFlowOK" }, {"EXTIN024", "PM1.DI_ASWaterFlowOK1" }, {"EXTIN025", "PM1.DI_FNCPanelClose" }, {"EXTIN026", "PM1.DI_APCVLVCLOSE" }, {"EXTIN027", "PM1.DI_APCSTATUSOK" }, {"EXTIN028", "PM1.DI_EXTIN1" }, {"EXTIN029", "PM1.DI_EXTIN2" }, {"EXTIN030", "PM1.DI_EXTIN3" }, {"EXTIN031", "PM1.DI_EXTIN4" }, {"EXTIN032", "PM1.DI_EXTIN5" }, {"EXTIN033", "PM1.DI_EXTIN6" }, {"EXTIN034", "PM1.DI_EXTIN7" }, {"EXTIN035", "PM1.DI_EXTIN8" }, {"EXTIN036", "PM1.DI_PT1OK" }, {"EXTIN037", "PM1.DI_PT2OK" }, {"EXTIN038", "PM1.DI_PT3OK" }, {"EXTIN039", "PM1.DI_PT4OK" }, {"EXTIN040", "PM1.DI_PT5OK" }, {"EXTIN041", "PM1.DI_PSW1LOW" }, {"EXTIN042", "PM1.DI_PSW2LOW" }, {"EXTIN043", "PM1.DI_PT6OK" }, {"EXTIN044", "PM1.DI_GUEXHOK" }, {"EXTIN046", "PM1.DI_GUUDoorOK" }, {"EXTIN047", "PM1.DI_H2Leak" }, {"EXTIN048", "PM1.DI_NO2Leak" }, {"EXTIN049", "PM1.DI_GASDetectorOK" }, {"EXTIN050", "PM1.DI_H2Density" }, {"EXTIN051", "PM1.DI_H2AIRFlowOK" }, {"EXTIN052", "PM1.DI_O2Density" }, {"EXTIN053", "PM1.DI_O2AIRFlowOK" }, {"EXTIN054", "PM1.DI_SCVEXHOK" }, {"EXTIN055", "PM1.DI_CAPClosePosition" }, {"EXTIN056", "PM1.DI_TubeATMPressure" }, {"EXTIN057", "PM1.DI_TubeOverPressure" }, {"EXTIN058", "PM1.DI_VG2OK" }, {"EXTIN059", "PM1.DI_VG1OK" }, {"EXTIN060", "PM1.DI_ALYCAPATMPressure" }, {"EXTIN061", "PM1.DI_CAPHWILKOK" }, {"EXTIN062", "PM1.DI_PumpON" }, {"EXTIN063", "PM1.DI_PumpRunning" }, {"EXTIN064", "PM1.DI_PumpRemote" }, {"EXTIN065", "PM1.DI_PumpNotWarning" }, {"EXTIN066", "PM1.DI_PumpNotAlarm" }, {"EXTIN067", "PM1.APC.IsPositionControlMode" }, {"EXTIN068", "PM1.APC.IsCloseControlMode" }, {"EXTIN069", "PM1.APC.IsOpenControlMode" }, {"EXTIN070", "PM1.APC.IsVG1ControlMode" }, {"EXTIN071", "PM1.APC.IsVG2ControlMode" }, {"EXTIN072", "PM1.APC.IsSlowControlMode" }, {"EXTOUT001", "PM1.DO_HeaterPowerONLamp" }, {"EXTOUT002", "PM1.DO_HeaterPowerEN" }, {"EXTOUT003", "PM1.DO_EXTOut1" }, {"EXTOUT004", "PM1.DO_EXTOut2" }, {"EXTOUT005", "PM1.DO_EXTOut3" }, {"EXTOUT006", "PM1.DO_EXTOut4" }, {"EXTOUT007", "PM1.DO_EXTOut5" }, {"EXTOUT008", "PM1.DO_EXTOut6" }, {"EXTOUT009", "PM1.DO_EXTOut7" }, {"EXTOUT010", "PM1.DO_EXTOut8" }, {"EXTOUT011", "PM1.DO_MFCN1ForceOpen" }, {"EXTOUT012", "PM1.DO_MFCN2ForceOpen" }, {"EXTOUT013", "PM1.DO_MFCN3ForceOpen" }, {"EXTOUT014", "PM1.DO_MFCH1ForceOpen" }, {"EXTOUT015", "PM1.DO_MFCJ1ForceOpen" }, {"EXTOUT016", "PM1.DO_MFCXN1ForceOpen" }, {"EXTOUT017", "PM1.DO_MFCN1ForceClose" }, {"EXTOUT018", "PM1.DO_MFCN2ForceClose" }, {"EXTOUT019", "PM1.DO_MFCN3ForceClose" }, {"EXTOUT020", "PM1.DO_MFCH1ForceClose" }, {"EXTOUT021", "PM1.DO_MFCJ1ForceClose" }, {"EXTOUT022", "PM1.DO_MFCXN1ForceClose" }, {"EXTOUT023", "PM1.DO_PumpON" }, {"EXTOUT024", "PM1.DO_CAPSOFTILKOK" }, {"EXTOUT025", "PM1.APC.SetClose1ControlMode" }, {"EXTOUT026", "PM1.APC.SetClose2ControlMode" }, {"EXTOUT027", "PM1.APC.SetClose3ControlMode" }, {"EXTOUT028", "PM1.APC.SetOpenControlMode" }, {"EXTOUT029", "PM1.APC.SetSlowControlMode" }, {"EXTOUT030", "PM1.APC.SetVG1ControlMode" }, {"EXTOUT031", "PM1.APC.SetVG2ControlMode" }, {"ILKALM001", "PM1.SetSoftwareInterlockAlarm001" }, {"ILKALM002", "PM1.SetSoftwareInterlockAlarm002" }, {"ILKALM003", "PM1.SetSoftwareInterlockAlarm003" }, {"MFCN1", "PM1.AI_MFCN1FlowFeedback" }, {"MFCN2", "PM1.AI_MFCN2FlowFeedback" }, {"MFCN3", "PM1.AI_MFCN3FlowFeedback" }, {"MFCH1", "PM1.AI_MFCH1FlowFeedback" }, {"MFCJ1", "PM1.AI_MFCJ1FlowFeedback" }, {"MFCXN1", "PM1.AI_MFCXN1FlowFeedback" }, {"MFMH2", "PM1.AI_MFMH2PRGFlowFeedback" }, {"MFMO2", "PM1.AI_MFMO2PRGFlowFeedback" }, {"VG01", "PM1.APC.Pressure1Feedback" }, {"VG02", "PM1.APC.Pressure2Feedback" }, {"TEMP01", "PM1.HeaterTemp" }, {"TEMP02", "PM1.HeaterTemp" }, {"TEMP03", "PM1.HeaterTemp" }, {"TEMP04", "PM1.HeaterTemp" }, {"TEMP05", "PM1.HeaterTemp" }, {"ALLTEMP", "PM1.HeaterTemp" }, {"VLV001", "PM1.DO_H12ValveOpen" }, {"VLV002", "PM1.DO_J11ValveOpen" }, {"VLV003", "PM1.DO_XN11ValveOpen" }, {"VLV004", "PM1.DO_N32ValveOpen" }, {"VLV005", "PM1.DO_N12ValveOpen" }, {"VLV006", "PM1.DO_N22ValveOpen" }, {"VLV007", "PM1.DO_J12ValveOpen" }, {"VLV008", "PM1.DO_J13ValveOpen" }, {"VLV009", "PM1.DO_J14ValveOpen" }, {"VLV010", "PM1.DO_XN12ValveOpen" }, {"VLV011", "PM1.DO_XN13ValveOpen" }, {"VLV012", "PM1.D0_XN14ValveOpen" }, {"VLV013", "PM1.DO_TS3ValveOpen" }, {"VLV014", "PM1.DO_GD1ValveOpen" }, {"VLV015", "PM1.D0_GD2ValveOpen" }, {"VLV016", "PM1.DO_SVValveOpen" }, {"VLV017", "PM1.DO_IV1ValveOpen" }, {"VLV018", "PM1.DO_VV1ValveOpen" }, {"VLV019", "PM1.DO_TS4ValveOpen" }, }; _editLimitCheckReferenceDic = new Dictionary() { { ">=", "H" }, { "<", "L" }, }; } private void InitActionLists() { _interlockEditAction = new List(); foreach (var name in _moduleName) { GetActionList(name); } } private void InitLimitLists() { _interlockEditLimit = new List(); foreach (var name in _moduleName) { GetLimitDiList(name); } GetLimitAiList(_moduleName[0]); foreach (var name in _moduleName) { GetLimitDoList(name); } } private void GetActionList(string module) { List notifiableIoItems = new List(); notifiableIoItems = QueryDataClient.Instance.Service.GetDoList($"System.{module}"); for (int i = 0; i < notifiableIoItems.Count; i++) { _interlockEditAction.Add(notifiableIoItems[i].Name); } } private void GetLimitDiList(string module) { List notifiableIoItems = new List(); notifiableIoItems = QueryDataClient.Instance.Service.GetDiList($"System.{module}"); for (int i = 0; i < notifiableIoItems.Count; i++) { _interlockEditLimit.Add(notifiableIoItems[i].Name); } } private void GetLimitAiList(string module) { List notifiableIoItems = new List(); notifiableIoItems = QueryDataClient.Instance.Service.GetAiList($"System.{module}"); for (int i = 0; i < notifiableIoItems.Count; i++) { _interlockEditLimit.Add(notifiableIoItems[i].Name); } } private void GetLimitDoList(string module) { List notifiableIoItems = new List(); notifiableIoItems = QueryDataClient.Instance.Service.GetDoList($"System.{module}"); for (int i = 0; i < notifiableIoItems.Count; i++) { _interlockEditLimit.Add(notifiableIoItems[i].Name); } } private void InitMFTree(string key) { try { XmlDocument xmlConfig = new XmlDocument(); xmlConfig.LoadXml(QueryDataClient.Instance.Service.GetInterlockConfigContent()); // // // // XmlNode nodeInterlock = xmlConfig.SelectSingleNode("Interlock"); InterlockTreeMF.Clear(); foreach (XmlNode item in nodeInterlock.ChildNodes) { InterlockBase interlock = new InterlockBase(); if (item.NodeType == XmlNodeType.Comment) continue; XmlElement actionNode = item as XmlElement; if (actionNode == null) continue; if (actionNode.Name != "Action") { continue; } if (actionNode.GetAttribute("do").Contains("PM1")) continue; if (!string.IsNullOrEmpty(key) && !actionNode.GetAttribute("do").Contains(key)) continue; interlock.Name = actionNode.GetAttribute("tip"); interlock.SetValue = actionNode.GetAttribute("value"); string condition = actionNode.GetAttribute("condition"); condition = string.IsNullOrEmpty(condition) ? "AND" : condition; interlock.InterlockOKFill = _greenFill; //string doName = actionNode.GetAttribute("do"); //bool value = Convert.ToBoolean(actionNode.GetAttribute("value")); //string tip = actionNode.GetAttribute("tip"); foreach (XmlElement limitNode in actionNode.ChildNodes) { if (limitNode.Name != "Limit") { continue; } string action = string.Empty; if (limitNode.HasAttribute("di")) { action = limitNode.GetAttribute("di"); } if (limitNode.HasAttribute("do")) { action = limitNode.GetAttribute("do"); } interlock.Children.Add(new InterlockBase() { Action = action, Name = limitNode.GetAttribute("tip"), LimitValue = limitNode.GetAttribute("value"), Condition = condition, InterlockOKFill = _greenFill }); } InterlockTreeMF.Add(interlock); } } catch (Exception ex) { } } private void InitPMTree(string key) { try { XmlDocument xmlConfig = new XmlDocument(); xmlConfig.LoadXml(QueryDataClient.Instance.Service.GetInterlockConfigContent()); // // // // XmlNode nodeInterlock = xmlConfig.SelectSingleNode("Interlock"); InterlockTreePM.Clear(); foreach (XmlNode item in nodeInterlock.ChildNodes) { InterlockBase interlock = new InterlockBase(); if (item.NodeType == XmlNodeType.Comment) continue; XmlElement actionNode = item as XmlElement; if (actionNode == null) continue; if (actionNode.Name != "Action") { continue; } if (!actionNode.GetAttribute("do").Contains("PM1")) continue; if (!string.IsNullOrEmpty(key) && !actionNode.GetAttribute("do").Contains(key)) continue; interlock.Name = actionNode.GetAttribute("tip"); interlock.SetValue = actionNode.GetAttribute("value"); string condition = actionNode.GetAttribute("condition"); condition = string.IsNullOrEmpty(condition) ? "AND" : condition; interlock.InterlockOKFill = _greenFill; //string doName = actionNode.GetAttribute("do"); //bool value = Convert.ToBoolean(actionNode.GetAttribute("value")); //string tip = actionNode.GetAttribute("tip"); foreach (XmlElement limitNode in actionNode.ChildNodes) { if (limitNode.Name != "Limit") { continue; } string action = string.Empty; if (limitNode.HasAttribute("di")) { action = limitNode.GetAttribute("di"); } if (limitNode.HasAttribute("do")) { action = limitNode.GetAttribute("do"); } interlock.Children.Add(new InterlockBase() { Action = action, Name = limitNode.GetAttribute("tip"), LimitValue = limitNode.GetAttribute("value"), Condition = condition, InterlockOKFill = _greenFill }); } InterlockTreePM.Add(interlock); } } catch (Exception ex) { } } private void InitEditTree(string key) { try { XmlDocument xmlConfig = new XmlDocument(); xmlConfig.LoadXml(QueryDataClient.Instance.Service.GetInterlockUserDefineConfigContent()); XmlNode nodeInterlock = xmlConfig.SelectSingleNode("Interlock"); InterlockTreeEdit.Clear(); foreach (XmlNode item in nodeInterlock.ChildNodes) { InterlockBase interlock = new InterlockBase(); if (item.NodeType == XmlNodeType.Comment) continue; XmlElement actionNode = item as XmlElement; if (actionNode == null) continue; if (actionNode.Name != "Action") { continue; } if (!string.IsNullOrEmpty(key) && !actionNode.GetAttribute("Name").Contains(key)) continue; //interlock.Action= actionNode.GetAttribute("Name"); //interlock.Name = actionNode.GetAttribute("Name"); if (actionNode.GetAttribute("Name").Contains("FLAG")) interlock.Action = actionNode.GetAttribute("Name"); else interlock.Action = _editInterlockIOReferenceDic.Where(x => x.Value == actionNode.GetAttribute("Name"))?.FirstOrDefault().Key; interlock.Name = interlock.Action; interlock.SetValue = actionNode.GetAttribute("Value"); interlock.InterlockOKFill = _greenFill; //string doName = actionNode.GetAttribute("do"); //bool value = Convert.ToBoolean(actionNode.GetAttribute("value")); //string tip = actionNode.GetAttribute("tip"); foreach (XmlElement limitNode in actionNode.ChildNodes) { if (limitNode.Name != "Limit") { continue; } string action = string.Empty; if (limitNode.HasAttribute("Name")) { //action = limitNode.GetAttribute("Name"); if (limitNode.GetAttribute("Name").Contains("FLAG")) action = limitNode.GetAttribute("Name"); else action = _editInterlockIOReferenceDic.Where(x => x.Value == limitNode.GetAttribute("Name"))?.FirstOrDefault().Key; } string condition = limitNode.GetAttribute("Condition"); condition = string.IsNullOrEmpty(condition) ? "AND" : condition; interlock.Children.Add(new InterlockBase() { Action = action, Name = action, LimitValue = limitNode.GetAttribute("Value"), Condition = condition, InterlockOKFill = _greenFill }); } InterlockTreeEdit.Add(interlock); } } catch (Exception ex) { } } protected override void InvokeAfterUpdateProperty(Dictionary data) { base.InvokeAfterUpdateProperty(data); try { foreach (var key in data.Keys) { for (int i = 0; i < InterlockTreeMF.Count; i++) { bool setValue = false; if (InterlockTreeMF[i].Children[0].Condition.ToLower() == "or") { setValue = false; } else { setValue = true; } for (int j = 0; j < InterlockTreeMF[i].Children.Count; j++) { if (key.Contains(InterlockTreeMF[i].Children[j].Action)) { InterlockTreeMF[i].Children[j].InterlockOK = data[key].ToString().ToLower() == InterlockTreeMF[i].Children[j].LimitValue.ToLower(); InterlockTreeMF[i].Children[j].InterlockOKFill = InterlockTreeMF[i].Children[j].InterlockOK ? _greenFill : _redFill; } if (InterlockTreeMF[i].Children[j].Condition.ToLower() == "or") { setValue = setValue || InterlockTreeMF[i].Children[j].InterlockOK; } else { setValue = setValue && InterlockTreeMF[i].Children[j].InterlockOK; } } InterlockTreeMF[i].InterlockOK = setValue.ToString().ToLower() == InterlockTreeMF[i].SetValue.ToLower(); InterlockTreeMF[i].InterlockOKFill = InterlockTreeMF[i].InterlockOK ? _greenFill : _redFill; } for (int i = 0; i < InterlockTreePM.Count; i++) { bool setValue = false; if (InterlockTreePM[i].Children[0].Condition.ToLower() == "or") { setValue = false; } else { setValue = true; } for (int j = 0; j < InterlockTreePM[i].Children.Count; j++) { if (key.Contains(InterlockTreePM[i].Children[j].Action)) { InterlockTreePM[i].Children[j].InterlockOK = data[key].ToString().ToLower() == InterlockTreePM[i].Children[j].LimitValue.ToLower(); InterlockTreePM[i].Children[j].InterlockOKFill = InterlockTreePM[i].Children[j].InterlockOK ? _greenFill : _redFill; } if (InterlockTreePM[i].Children[j].Condition.ToLower() == "or") { setValue = setValue || InterlockTreePM[i].Children[j].InterlockOK; } else { setValue = setValue && InterlockTreePM[i].Children[j].InterlockOK; } } InterlockTreePM[i].InterlockOK = setValue.ToString().ToLower() == InterlockTreePM[i].SetValue.ToLower(); ; InterlockTreePM[i].InterlockOKFill = InterlockTreePM[i].InterlockOK ? _greenFill : _redFill; } } //RefreshInterlockEdit(); } catch (Exception ex) { } } private void RefreshInterlockEdit() { if (InterlockTreeEdit.Count == 0) return; Dictionary> keyValuePairs = new Dictionary>(); List notifiableIoItems = new List(); foreach (var name in _moduleName) { notifiableIoItems = QueryDataClient.Instance.Service.GetDiList($"System.{name}"); keyValuePairs.Add($"{name}.DI_", notifiableIoItems); notifiableIoItems = QueryDataClient.Instance.Service.GetDoList($"System.{name}"); keyValuePairs.Add($"{name}.DO_", notifiableIoItems); } notifiableIoItems = QueryDataClient.Instance.Service.GetAiList($"System.PM1"); keyValuePairs.Add($"PM1.AI_", notifiableIoItems); for (int i = 0; i < InterlockTreeEdit.Count; i++) { bool setValue = false; if (InterlockTreeEdit[i].Children[0].Condition.ToLower() == "or") { setValue = false; } else { setValue = true; } for (int j = 0; j < InterlockTreeEdit[i].Children.Count; j++) { var action = InterlockTreeEdit[i].Children[j].Action; var limitValue = InterlockTreeEdit[i].Children[j].LimitValue; foreach (var key in keyValuePairs.Keys) { if (action.Contains(key)) { var values = keyValuePairs[key].Where(x => x.Name == InterlockTreeEdit[i].Children[j].Action).FirstOrDefault(); if (values != null) { if (action.Contains("AI_")) { if (limitValue.Contains(">=")) { limitValue = limitValue.Replace(">=", ""); InterlockTreeEdit[i].Children[j].InterlockOK = values.ShortValue >= short.Parse(limitValue); InterlockTreeEdit[i].Children[j].InterlockOKFill = InterlockTreeEdit[i].Children[j].InterlockOK ? _greenFill : _redFill; } else { limitValue = limitValue.Replace("<", ""); InterlockTreeEdit[i].Children[j].InterlockOK = values.ShortValue < short.Parse(limitValue); InterlockTreeEdit[i].Children[j].InterlockOKFill = InterlockTreeEdit[i].Children[j].InterlockOK ? _greenFill : _redFill; } } else { InterlockTreeEdit[i].Children[j].InterlockOK = values.BoolValue.ToString().ToLower() == InterlockTreeEdit[i].Children[j].LimitValue.ToLower(); InterlockTreeEdit[i].Children[j].InterlockOKFill = InterlockTreeEdit[i].Children[j].InterlockOK ? _greenFill : _redFill; } } } } if (InterlockTreeEdit[i].Children[j].Condition.ToLower() == "or") { setValue = setValue || InterlockTreeEdit[i].Children[j].InterlockOK; } else { setValue = setValue && InterlockTreeEdit[i].Children[j].InterlockOK; } } InterlockTreeEdit[i].InterlockOK = setValue.ToString().ToLower() == InterlockTreeEdit[i].SetValue.ToLower(); InterlockTreeEdit[i].InterlockOKFill = InterlockTreeEdit[i].InterlockOK ? _greenFill : _redFill; } } public void CollapseAll() { SetExpand(InterlockTreePM, false); SetExpand(InterlockTreeMF, false); SetExpand(InterlockTreeEdit, false); } public void ExpandAll() { SetExpand(InterlockTreePM, true); SetExpand(InterlockTreeMF, true); SetExpand(InterlockTreeEdit, true); } public void SetExpand(ObservableCollection interlockbase, bool expand) { if (interlockbase == null) return; foreach (var interlock in interlockbase) { interlock.IsExpanded = expand; if (interlock.Children != null) SetExpand(interlock.Children, expand); } } public void EditTreeSelectChanged(InterlockBase interlock) { CurrentInterlock = interlock; if (CurrentInterlock != null && CurrentInterlock.Children.Count > 0) { InterlockLimits.Clear(); foreach (var limit in CurrentInterlock.Children) { InterlockLimits.Add(new InterlockLimit() { LimitName = limit.Action, LimitValue = limit.LimitValue, LimitCondition = limit.Condition }); } InterlockLimitSelectIndex = 0; SelectLimit(); ActionItem = CurrentInterlock.Action; var value = CurrentInterlock.SetValue.Split(';').ToList(); if (value.Count > 2) { if (value[0].Contains("KEEP")) { ActionTimeCheck = "KEEP"; ActionTimeValue = value[0].Replace("KEEP", ""); IsEnabledActionTimeValue = true; } else { ActionTimeCheck = "DELAY"; ActionTimeValue = value[0].Replace("DELAY", ""); IsEnabledActionTimeValue = true; } ActionCheck = value[1]; ActionAuto = value[2]; } else if (value.Count == 2) { if (CurrentInterlock.SetValue.Contains("KEEP") || CurrentInterlock.SetValue.Contains("DELAY")) { if (value[0].Contains("KEEP")) { ActionTimeCheck = "KEEP"; ActionTimeValue = value[0].Replace("KEEP", ""); IsEnabledActionTimeValue = true; } else { ActionTimeCheck = "DELAY"; ActionTimeValue = value[0].Replace("DELAY", ""); IsEnabledActionTimeValue = true; } ActionCheck = value[1]; } else { ActionCheck = value[0]; ActionAuto = value[1]; ActionTimeCheck = "BLANK"; ActionTimeValue = "0"; IsEnabledActionTimeValue = false; } } else { ActionCheck = value[0]; ActionTimeCheck = "BLANK"; ActionTimeValue = "0"; IsEnabledActionTimeValue = false; } } } public void InterlockEdit() { if (!_isInterlockEditSet) { _isInterlockEditSet = !_isInterlockEditSet; IsInterlockEdit = true; } else { IsInterlockEdit = false; IsInterlockEditCancel = true; _isInterlockEditSet = !_isInterlockEditSet; } } public void ActionSelect() { var temp = InterlockTreeEdit.Where(x => x.Action == InterLockEditActionSelect).FirstOrDefault(); if (temp == null) { InterlockLimits.Clear(); InterlockEditLimitSelectIndex = -1; } else { InterlockLimits.Clear(); foreach (var limit in temp.Children) { InterlockLimits.Add(new InterlockLimit() { LimitName = limit.Action, LimitValue = limit.LimitValue, LimitCondition = limit.Condition }); } InterlockEditLimitSelectIndex = InterlockEditLimit.IndexOf(InterlockLimits.First().LimitName); } } public void LimitSelect() { if (string.IsNullOrEmpty(InterLockEditLimitSelect)) return; if (InterLockEditLimitSelect.Contains("AI_")) { LimitValueTrueName = ">="; LimitValueFalseName = "<"; IsShowLimitValue = Visibility.Visible; } else { LimitValueTrueName = "true"; LimitValueFalseName = "false"; IsShowLimitValue = Visibility.Hidden; } } public void SelectItem(string itemType) { var windowManager = IoC.Get(); InterlockSelectItemViewModel interlockSelectItemViewModel = new InterlockSelectItemViewModel(itemType); (windowManager as WindowManager)?.ShowDialogWithTitle(interlockSelectItemViewModel, null, "Interlock SelectItem View"); string selectedItem = interlockSelectItemViewModel.SelectedItem; if (!string.IsNullOrEmpty(selectedItem)) { switch (itemType) { case "Action": if (!_editInterlockIOReferenceDic.Keys.Contains(selectedItem) && !selectedItem.Contains("FLAG")) { DialogBox.ShowWarning($"{selectedItem} item is not exist!"); return; } ActionItem = selectedItem; break; case "Limit": if (selectedItem.Contains("FLAG")) { if (InterlockTreeEdit.Where(x => x.Action == selectedItem).FirstOrDefault() == null) { DialogBox.ShowWarning($"{selectedItem} item is not exist!"); return; } } else { if (!_editInterlockIOReferenceDic.Keys.Contains(selectedItem)) { DialogBox.ShowWarning($"{selectedItem} item is not exist!"); return; } } LimitItem = selectedItem; if (LimitItem.Contains("MFC") || LimitItem.Contains("MFM") || LimitItem.Contains("APC") || LimitItem.Contains("TEMP") || LimitItem.Contains("VG")) { IsEnabledLimitValue = true; if (LimitCheck.Contains("ON") || LimitCheck.Contains("OFF")) LimitCheck = "BLANK"; } else { IsEnabledLimitValue = false; LimitValue = ""; if (LimitCheck.Contains(">=") || LimitCheck.Contains("<")) LimitCheck = "BLANK"; } if (LimitItem.Contains("MFC") || LimitItem.Contains("MFM")) { LimitUnit = "SCCM"; } else if (LimitItem.Contains("APC")) { LimitUnit = "Torr"; } else if (LimitItem.Contains("TEMP")) { LimitUnit = "℃"; } else if (LimitItem.Contains("VG")) { LimitUnit = "Torr"; } else { LimitUnit = ""; } break; } } } public void SelectCheck(string value) { string itemType = string.Empty; switch (value) { case "Action": itemType = ActionItem; break; case "Limit": itemType = LimitItem; break; case "TIME": itemType = value; break; } var windowManager = IoC.Get(); InterlockCheckViewModel interlockCheckViewModel = new InterlockCheckViewModel(itemType); if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(interlockCheckViewModel, null, "Interlock Check View")) { if (value == "Action") { ActionCheck = interlockCheckViewModel.CheckSelected; } else if (value == "Limit") { LimitCheck = interlockCheckViewModel.CheckSelected; if (LimitCheck == ">=" || LimitCheck == "<") IsEnabledLimitValue = true; else IsEnabledLimitValue = false; } else { ActionTimeCheck = interlockCheckViewModel.CheckSelected; if (ActionTimeCheck == "DELAY" || ActionTimeCheck == "KEEP") IsEnabledActionTimeValue = true; else IsEnabledActionTimeValue = false; } } } public void SelectAuto() { var windowManager = IoC.Get(); InterlockActionAutoViewModel interlockActionAutoViewModel = new InterlockActionAutoViewModel(); if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(interlockActionAutoViewModel, null, "Interlock Auto View")) { ActionAuto = interlockActionAutoViewModel.AutoSelected; } } public void SelectCondition() { var windowManager = IoC.Get(); InterlockConditionViewModel interlockConditionViewModel = new InterlockConditionViewModel(); if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(interlockConditionViewModel, null, "Interlock Condition View")) { LimitCondition = interlockConditionViewModel.ConditionSelected; } } public void SelectLimit() { if (InterlockLimitSelectIndex != -1 && InterlockLimits.Count > 0) { LimitItem = InterlockLimits[InterlockLimitSelectIndex].LimitName; LimitCondition = InterlockLimits[InterlockLimitSelectIndex].LimitCondition; var value = InterlockLimits[InterlockLimitSelectIndex].LimitValue; if (value.Contains("H")) { LimitCheck = ">="; LimitValue = value.Replace("H", ""); IsEnabledLimitValue = true; } else if (value.Contains("L")) { LimitCheck = "<"; LimitValue = value.Replace("L", ""); IsEnabledLimitValue = true; } else { LimitCheck = value; LimitValue = "0"; IsEnabledLimitValue = false; } if (LimitItem.Contains("MFC") || LimitItem.Contains("MFM")) { LimitUnit = "SCCM"; } else if (LimitItem.Contains("APC")) { LimitUnit = "Torr"; } else if (LimitItem.Contains("TEMP")) { LimitUnit = "℃"; } else { LimitUnit = ""; } } } public void ChangeLimit() { if (InterlockLimitSelectIndex != -1 && InterlockLimits.Count > 0) { if (string.IsNullOrEmpty(LimitItem) || LimitItem == "BLANK") { DialogBox.ShowWarning("Limit item is empty,can not add!"); return; } if (string.IsNullOrEmpty(LimitCondition)) { DialogBox.ShowWarning("Limit condition is empty,can not add!"); return; } if (string.IsNullOrEmpty(LimitCheck) || LimitCheck == "BLANK") { DialogBox.ShowWarning("Limit check is empty,can not add!"); return; } if (IsEnabledLimitValue && string.IsNullOrEmpty(LimitValue)) { DialogBox.ShowWarning("Limit value is empty,can not add!"); return; } //if (InterlockLimits.Any(x => x.LimitCondition == "BLANK") && LimitCondition == "BLANK" && InterlockLimits[InterlockLimitSelectIndex].LimitCondition != "BLANK") //{ // DialogBox.ShowWarning("Alreay have condition is BLANK,can not add!"); // return; //} InterlockLimits[InterlockLimitSelectIndex].LimitName = LimitItem; InterlockLimits[InterlockLimitSelectIndex].LimitCondition = LimitCondition; //InterlockLimits[InterlockLimitSelectIndex].LimitValue = IsEnabledLimitValue ? LimitCheck + LimitValue : LimitCheck; InterlockLimits[InterlockLimitSelectIndex].LimitValue = IsEnabledLimitValue ? LimitValue + _editLimitCheckReferenceDic[LimitCheck] : LimitCheck; } } public void AddLimit() { if (string.IsNullOrEmpty(LimitItem) || LimitItem == "BLANK") { DialogBox.ShowWarning("Limit item is empty,can not add!"); return; } if (string.IsNullOrEmpty(LimitCondition)) { DialogBox.ShowWarning("Limit condition is empty,can not add!"); return; } if (string.IsNullOrEmpty(LimitCheck) || LimitCheck == "BLANK") { DialogBox.ShowWarning("Limit check is empty,can not add!"); return; } if (IsEnabledLimitValue && string.IsNullOrEmpty(LimitValue)) { DialogBox.ShowWarning("Limit value is empty,can not add!"); return; } //if (InterlockLimits.Any(x => x.LimitCondition == "BLANK") && LimitCondition == "BLANK") //{ // DialogBox.ShowWarning("Alreay have condition is BLANK,can not add!"); // return; //} InterlockLimit interlockLimit = new InterlockLimit(); interlockLimit.LimitName = LimitItem; interlockLimit.LimitCondition = LimitCondition; //interlockLimit.LimitValue = IsEnabledLimitValue ? LimitCheck + LimitValue : LimitCheck; interlockLimit.LimitValue = IsEnabledLimitValue ? LimitValue + _editLimitCheckReferenceDic[LimitCheck] : LimitCheck; if (InterlockLimits.Where(x => x.LimitName == LimitItem).FirstOrDefault() != null) { DialogBox.ShowWarning($"Limit [{LimitItem}] is already existed"); return; } else { InterlockLimits.Add(interlockLimit); } } public void DeleteLimit() { if (InterlockLimitSelectIndex != -1 && InterlockLimits.Count > 0) { if (!DialogBox.Confirm($"Are you sure delete limit [{InterlockLimits[InterlockLimitSelectIndex].LimitName}]")) return; InterlockLimits.RemoveAt(InterlockLimitSelectIndex); if (InterlockLimits.Count == 0) { LimitItem = "BLANK"; LimitCheck = "BLANK"; LimitValue = "0"; LimitUnit = ""; LimitCondition = "AND"; IsEnabledLimitValue = false; } } } public void Update() { if (CurrentInterlock == null) return; if (InterlockLimits.Count == 0) { DialogBox.ShowWarning("Condition is empty,can not save!"); return; } if (string.IsNullOrEmpty(ActionItem) || ActionItem == "BLANK") { DialogBox.ShowWarning("Action item is empty,can not save!"); return; } if (string.IsNullOrEmpty(ActionCheck) || ActionCheck == "BLANK") { DialogBox.ShowWarning("Action check is empty,can not save!"); return; } if (IsEnabledActionTimeValue && string.IsNullOrEmpty(ActionTimeValue)) { DialogBox.ShowWarning("Time value is empty,can not save!"); return; } //if (InterlockLimits[InterlockLimits.Count - 1].LimitCondition != "BLANK") //{ // DialogBox.ShowWarning("The last condition must be 'BLANK',can not save!"); // return; //} InterlockBase interlock = new InterlockBase(); interlock.Action = ActionItem; interlock.SetValue = IsEnabledActionTimeValue ? $"{ActionTimeCheck}{ActionTimeValue};" : ""; interlock.SetValue += $"{ActionCheck};{ActionAuto}"; interlock.InterlockOKFill = _greenFill; for (int i = 0; i < InterlockLimits.Count; i++) { interlock.Children.Add(new InterlockBase() { Action = InterlockLimits[i].LimitName, LimitValue = InterlockLimits[i].LimitValue, Condition = InterlockLimits[i].LimitCondition, InterlockOKFill = _greenFill }); } InterlockTreeEdit.Where(x => x.Action == CurrentInterlock.Action && x.SetValue == CurrentInterlock.SetValue).FirstOrDefault().SetValue = interlock.SetValue; InterlockTreeEdit.Where(x => x.Action == CurrentInterlock.Action && x.SetValue == CurrentInterlock.SetValue).FirstOrDefault().InterlockOKFill = interlock.InterlockOKFill; InterlockTreeEdit.Where(x => x.Action == CurrentInterlock.Action && x.SetValue == CurrentInterlock.SetValue).FirstOrDefault().Children = interlock.Children; QueryDataClient.Instance.Service.SetInterlockConfigContent(GetXmlString()); InvokeClient.Instance.Service.DoOperation($"System.UpdateUserDefineInterlock", ""); InterlockLimits.Clear(); InterlockParamClear(); } public void Save() { if (InterlockLimits.Count == 0) { DialogBox.ShowWarning("Condition is empty,can not save!"); return; } if (string.IsNullOrEmpty(ActionItem) || ActionItem == "BLANK") { DialogBox.ShowWarning("Action item is empty,can not save!"); return; } if (string.IsNullOrEmpty(ActionCheck) || ActionCheck == "BLANK") { DialogBox.ShowWarning("Action check is empty,can not save!"); return; } if (IsEnabledActionTimeValue && string.IsNullOrEmpty(ActionTimeValue)) { DialogBox.ShowWarning("Time value is empty,can not save!"); return; } //if (InterlockLimits[InterlockLimits.Count - 1].LimitCondition != "BLANK") //{ // DialogBox.ShowWarning("The last condition must be 'BLANK',can not save!"); // return; //} InterlockBase interlock = new InterlockBase(); interlock.Action = ActionItem; interlock.SetValue = IsEnabledActionTimeValue ? $"{ActionTimeCheck}{ActionTimeValue};" : ""; interlock.SetValue += $"{ActionCheck};{ActionAuto}"; interlock.InterlockOKFill = _greenFill; for (int i = 0; i < InterlockLimits.Count; i++) { interlock.Children.Add(new InterlockBase() { Action = InterlockLimits[i].LimitName, LimitValue = InterlockLimits[i].LimitValue, Condition = InterlockLimits[i].LimitCondition, InterlockOKFill = _greenFill }); } if (InterlockTreeEdit.Any(x => x.Action == interlock.Action && x.SetValue == interlock.SetValue)) { DialogBox.ShowWarning($"Action [{interlock.Action}] condition {interlock.SetValue} is already existed"); return; } else { InterlockTreeEdit.Add(interlock); } QueryDataClient.Instance.Service.SetInterlockConfigContent(GetXmlString()); InvokeClient.Instance.Service.DoOperation($"System.UpdateUserDefineInterlock", ""); InterlockLimits.Clear(); InterlockParamClear(); } private string GetXmlString() { if (InterlockTreeEdit == null) return string.Empty; XmlDocument doc = new XmlDocument(); XmlElement node = doc.CreateElement("Interlock"); doc.AppendChild(node); XmlNode nodeData = doc.SelectSingleNode("Interlock"); foreach (InterlockBase interlock in InterlockTreeEdit) { XmlElement actionnode = doc.CreateElement("Action"); if (interlock.Action.Contains("FLAG")) actionnode.SetAttribute("Name", interlock.Action); else actionnode.SetAttribute("Name", _editInterlockIOReferenceDic[interlock.Action]); actionnode.SetAttribute("Value", interlock.SetValue); nodeData.AppendChild(actionnode); foreach (InterlockBase limit in interlock.Children) { XmlElement limitnode = doc.CreateElement("Limit"); if (limit.Action.Contains("FLAG")) limitnode.SetAttribute("Name", limit.Action); else limitnode.SetAttribute("Name", _editInterlockIOReferenceDic[limit.Action]); limitnode.SetAttribute("Value", limit.LimitValue); limitnode.SetAttribute("Condition", limit.Condition); actionnode.AppendChild(limitnode); } } return doc.OuterXml; } public void Export() { try { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.DefaultExt = ".xml"; // Default file extension dlg.FileName = $"InterlockUserDefine_{DateTime.Now:yyyyMMdd_HHmmss}"; dlg.Filter = "xml数据文件(*.xml)|*.xml"; // Filter files by extension Nullable result = dlg.ShowDialog();// Show open file dialog box if (result == true) // Process open file dialog box results { XmlDocument xml = new XmlDocument(); xml.LoadXml(GetXmlString()); xml.Save(dlg.FileName); MessageBox.Show($"Export succeed, file save as {dlg.FileName}", "Export", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { LOG.Write(ex); MessageBox.Show("导出自定义Interlock发生错误", "导出失败", MessageBoxButton.OK, MessageBoxImage.Warning); } } public void Import() { try { string filepath = ""; System.Windows.Forms.OpenFileDialog fd = new System.Windows.Forms.OpenFileDialog(); fd.Multiselect = false; fd.Title = "Please Select File"; fd.Filter = "xml⽂件|*.xml"; if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { filepath = fd.FileName; } XmlDocument xmlConfig = new XmlDocument(); xmlConfig.Load(filepath); XmlNode nodeInterlock = xmlConfig.SelectSingleNode("Interlock"); foreach (XmlNode item in nodeInterlock.ChildNodes) { InterlockBase interlock = new InterlockBase(); if (item.NodeType == XmlNodeType.Comment) continue; XmlElement actionNode = item as XmlElement; if (actionNode == null) continue; if (actionNode.Name != "Action") { continue; } if (IsSameActionName(actionNode.GetAttribute("Name"))) continue; interlock.Action = actionNode.GetAttribute("Name"); interlock.Name = actionNode.GetAttribute("Name"); interlock.SetValue = actionNode.GetAttribute("Value"); interlock.InterlockOKFill = _greenFill; //string doName = actionNode.GetAttribute("do"); //bool value = Convert.ToBoolean(actionNode.GetAttribute("value")); //string tip = actionNode.GetAttribute("tip"); foreach (XmlElement limitNode in actionNode.ChildNodes) { if (limitNode.Name != "Limit") { continue; } string action = string.Empty; if (limitNode.HasAttribute("Name")) { action = limitNode.GetAttribute("Name"); } string condition = limitNode.GetAttribute("Condition"); condition = string.IsNullOrEmpty(condition) ? "AND" : condition; interlock.Children.Add(new InterlockBase() { Action = action, Name = limitNode.GetAttribute("Name"), LimitValue = limitNode.GetAttribute("Value"), Condition = condition, InterlockOKFill = _greenFill }); } InterlockTreeEdit.Add(interlock); } } catch (Exception ex) { LOG.Write(ex); MessageBox.Show("导入自定义Interlock发生错误", "导入失败", MessageBoxButton.OK, MessageBoxImage.Warning); } } private bool IsSameActionName(string actionName) { bool isSame = false; foreach (InterlockBase interlock in InterlockTreeEdit) { if (interlock.Action == actionName) { isSame = true; break; } } return isSame; } public void Delete() { if (CurrentInterlock == null) return; var interlock = InterlockTreeEdit.Where(x => x.Action == CurrentInterlock.Action).FirstOrDefault(); if (interlock != null) { if (!DialogBox.Confirm($"Are you sure delete Interlock [{CurrentInterlock.Action}]")) return; InterlockTreeEdit.Remove(CurrentInterlock); QueryDataClient.Instance.Service.SetInterlockConfigContent(GetXmlString()); InvokeClient.Instance.Service.DoOperation($"System.UpdateUserDefineInterlock", ""); InterlockLimits.Clear(); InterlockParamClear(); } } private void InterlockParamClear() { LimitItem = "BLANK"; LimitCheck = "BLANK"; LimitValue = "0"; LimitUnit = ""; LimitCondition = "AND"; ActionTimeCheck = "BLANK"; ActionTimeValue = "0"; ActionItem = "BLANK"; ActionCheck = "BLANK"; IsEnabledLimitValue = false; IsEnabledActionTimeValue = false; } public void InterlockFind(string findKey) { if (string.IsNullOrWhiteSpace(findKey) || string.IsNullOrEmpty(findKey)) { if (IsShowInterlockMF) { InitMFTree(""); } if (IsShowInterlockPM) { InitPMTree(""); } if (IsShowInterlockEdit || IsShowInterlockEditDetail) { InitEditTree(""); } } else { if (IsShowInterlockMF) { InitMFTree(findKey); } if (IsShowInterlockPM) { InitPMTree(findKey); } if (IsShowInterlockEdit || IsShowInterlockEditDetail) { InitEditTree(findKey); } } } } public class InterlockLimit : NotifiableItem { private string _limitName; public string LimitName { get => _limitName; set { _limitName = value; InvokePropertyChanged(nameof(LimitName)); } } private string _limitCondition; public string LimitCondition { get => _limitCondition; set { _limitCondition = value; InvokePropertyChanged(nameof(LimitCondition)); } } private string _limitValue; public string LimitValue { get => _limitValue; set { _limitValue = value; InvokePropertyChanged(nameof(LimitValue)); } } } public class InterlockBase : PropertyChangedBase { private string _name; public string Name { get => _name; set { _name = value; NotifyOfPropertyChange(nameof(Name)); } } private string _action; public string Action { get => _action; set { _action = value; NotifyOfPropertyChange(nameof(Action)); } } private string _setValue; public string SetValue { get => _setValue; set { _setValue = value; NotifyOfPropertyChange(nameof(SetValue)); } } private string _limitValue; public string LimitValue { get => _limitValue; set { _limitValue = value; NotifyOfPropertyChange(nameof(LimitValue)); } } private bool _interlockOK; public bool InterlockOK { get => _interlockOK; set { _interlockOK = value; NotifyOfPropertyChange(nameof(InterlockOK)); } } private SolidColorBrush _interlockOKFill; public SolidColorBrush InterlockOKFill { get => _interlockOKFill; set { _interlockOKFill = value; NotifyOfPropertyChange(nameof(InterlockOKFill)); } } private string _condition; public string Condition { get => _condition; set { _condition = value; NotifyOfPropertyChange(nameof(Condition)); } } private bool _isExpanded; public bool IsExpanded { get => _isExpanded; set { _isExpanded = value; NotifyOfPropertyChange(nameof(IsExpanded)); } } private ObservableCollection _children; public ObservableCollection Children { get => _children; set { _children = value; NotifyOfPropertyChange(nameof(Children)); } } public InterlockBase() { Children = new ObservableCollection(); } } }