| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226 | 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<InterlockBase> _interlockTreePM = new ObservableCollection<InterlockBase>();        public ObservableCollection<InterlockBase> 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<InterlockBase> _interlockTreeMF = new ObservableCollection<InterlockBase>();        public ObservableCollection<InterlockBase> InterlockTreeMF        {            get => _interlockTreeMF;            set            {                _interlockTreeMF = value;                NotifyOfPropertyChange(nameof(InterlockTreeMF));            }        }        private ObservableCollection<InterlockBase> _interlockTreeEdit = new ObservableCollection<InterlockBase>();        public ObservableCollection<InterlockBase> InterlockTreeEdit        {            get => _interlockTreeEdit;            set            {                _interlockTreeEdit = value;                NotifyOfPropertyChange(nameof(InterlockTreeEdit));            }        }        public InterlockBase CurrentInterlock = new InterlockBase();        public ObservableCollection<InterlockLimit> InterlockLimits { get; set; } = new ObservableCollection<InterlockLimit>();        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<string> _interlockEditAction = new List<string>();        public List<string> 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<string> _interlockEditLimit = new List<string>();        public List<string> 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<string> _moduleName = new List<string>() { "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<string, string> _editInterlockIOReferenceDic;        private Dictionary<string, string> _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<string, string>()            {                {"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<string, string>()            {                { ">=", "H" },                { "<", "L" },            };        }        private void InitActionLists()        {            _interlockEditAction = new List<string>();            foreach (var name in _moduleName)            {                GetActionList(name);            }        }        private void InitLimitLists()        {            _interlockEditLimit = new List<string>();            foreach (var name in _moduleName)            {                GetLimitDiList(name);            }            GetLimitAiList(_moduleName[0]);            foreach (var name in _moduleName)            {                GetLimitDoList(name);            }        }        private void GetActionList(string module)        {            List<NotifiableIoItem> notifiableIoItems = new List<NotifiableIoItem>();            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<NotifiableIoItem> notifiableIoItems = new List<NotifiableIoItem>();            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<NotifiableIoItem> notifiableIoItems = new List<NotifiableIoItem>();            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<NotifiableIoItem> notifiableIoItems = new List<NotifiableIoItem>();            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());                //<Action do="DO_RF_power_on_off" value="true" tip="" tip.zh-CN="" tip.en-US="">                //  <Limit di="DI_RF_hardware_interlock"  value="true" tip="" tip.zh-CN="" tip.en-US="" />                //  <Limit di="DI_Chamber_door_sw"  value="true" tip="" tip.zh-CN="" tip.en-US="" />                //</Action>                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());                //<Action do="DO_RF_power_on_off" value="true" tip="" tip.zh-CN="" tip.en-US="">                //  <Limit di="DI_RF_hardware_interlock"  value="true" tip="" tip.zh-CN="" tip.en-US="" />                //  <Limit di="DI_Chamber_door_sw"  value="true" tip="" tip.zh-CN="" tip.en-US="" />                //</Action>                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<string, object> 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<string, List<NotifiableIoItem>> keyValuePairs = new Dictionary<string, List<NotifiableIoItem>>();            List<NotifiableIoItem> notifiableIoItems = new List<NotifiableIoItem>();            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> 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<IWindowManager>();            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<IWindowManager>();            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<IWindowManager>();            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<IWindowManager>();            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<bool> 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<InterlockBase> _children;        public ObservableCollection<InterlockBase> Children        {            get => _children;            set            {                _children = value;                NotifyOfPropertyChange(nameof(Children));            }        }        public InterlockBase()        {            Children = new ObservableCollection<InterlockBase>();        }    }}
 |