| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957 | using Aitex.Sorter.Common;using ExcelLibrary.BinaryFileFormat;using MECF.Framework.Common.CommonData;using MECF.Framework.Common.DataCenter;using MECF.Framework.Common.Equipment;using MECF.Framework.Common.OperationCenter;using MECF.Framework.Common.Schedulers;using OpenSEMI.ClientBase;using OpenSEMI.Ctrlib.Controls;using Prism.Commands;using Prism.Mvvm;using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using System.Threading.Tasks;using System.Windows.Threading;using Venus_Core;using Venus_MainPages.Unity;using Venus_Themes.CustomControls;using Venus_Themes.Unity;using static Venus_Core.NiceRobotAction;using static Venus_Themes.UserControls.EFEM;namespace Venus_MainPages.ViewModels{    public enum EFEMModule    {        LLA, LLB,LP1,LP2,LP3,Aligner1    }    public enum EFEMBlade    {        Blade1, Blade2    }    internal class EfemViewModel:BindableBase    {        #region 私有字段               private bool m_LLAIsInstalled;        private bool m_LLBIsInstalled;        private ModuleInfo m_LLAModuleInfo;        private ModuleInfo m_LLBModuleInfo;        private ModuleInfo m_LP1ModuleInfo;        private ModuleInfo m_LP2ModuleInfo;        private ModuleInfo m_LP3ModuleInfo;        private ModuleInfo m_EFEMModuleInfo;        private List<EFEMModule> m_EFEMModules = new List<EFEMModule>();        private EFEMBlade m_PickSelectedBlade;        private EFEMBlade m_PlaceSelectedBlade;        private EFEMBlade m_ExtendSelectedBlade;        private EFEMBlade m_RetractSelectedBlade;        private ObservableCollection<int> m_PlaceSoltItemsSource = new ObservableCollection<int>();        private ObservableCollection<int> m_PickSoltItemsSource = new ObservableCollection<int>();        private ObservableCollection<int> m_ExtendSoltItemsSource = new ObservableCollection<int>();        private ObservableCollection<int> m_RetractSoltItemsSource = new ObservableCollection<int>();        private int m_PickSoltSelectedIndex;        private int m_PlaceSoltSelectedIndex;        private int m_ExtendSoltSelectedIndex;        private int m_RetractSoltSelectedIndex;        private EFEMModule m_PickSelectedModule;        private EFEMModule m_PlaceSelectedModule;        private EFEMModule m_ExtendSelectedModule;        private EFEMModule m_RetractSelectedModule;        private WaferInfo m_BladeAWafer;        private WaferInfo m_BladeBWafer;        private WaferInfo m_LLAWafer;        private WaferInfo m_LLBWafer;        private WaferInfo m_Aligner1Wafer;        private string m_LP1Status;        private string m_LP2Status;        private string m_LP3Status;        private List<string> m_RtDataKeys=new List<string>();        private Dictionary<string, object> m_RtDataValues;        private int m_AlignValue;        private WaferRobotTAction m_Robot1TAction;        private WaferRobotXAction m_Robot1XAction;        private WaferRobotTAction m_Robot2TAction;        private WaferRobotXAction m_Robot2XAction;        private NiceGuangChuanWaferRobotTAction m_BladeNiceGuangChuanWaferRobotTAction;        //private NiceGuangChuanWaferRobotTAction m_Blade2NiceGuangChuanWaferRobotTAction;        private NiceGuangChuanWaferRobotXAction m_Blade1NiceGuangChuanWaferRobotXAction = NiceGuangChuanWaferRobotXAction.Retract1;        private NiceGuangChuanWaferRobotXAction m_Blade2NiceGuangChuanWaferRobotXAction = NiceGuangChuanWaferRobotXAction.Retract2;        //int arm1oldWaferStatus = 100;        //int arm2oldWaferStatus = 100;        private RobotPosition m_CurrentRobotPosition;        DispatcherTimer timer;        #endregion        #region 属性        public bool LLAIsInstalled        {            get { return m_LLAIsInstalled; }            set { SetProperty(ref m_LLAIsInstalled, value); }        }        public bool LLBIsInstalled        {            get { return m_LLBIsInstalled; }            set { SetProperty(ref m_LLBIsInstalled, value); }        }        public ModuleInfo LLAModuleInfo        {            get { return m_LLAModuleInfo; }            set { SetProperty(ref m_LLAModuleInfo, value); }        }        public ModuleInfo LLBModuleInfo        {            get { return m_LLBModuleInfo; }            set { SetProperty(ref m_LLBModuleInfo, value); }        }        public ModuleInfo LP1ModuleInfo        {            get { return m_LP1ModuleInfo; }            set { SetProperty(ref m_LP1ModuleInfo, value); }        }        public ModuleInfo LP2ModuleInfo        {            get { return m_LP2ModuleInfo; }            set { SetProperty(ref m_LP2ModuleInfo, value); }        }        public ModuleInfo LP3ModuleInfo        {            get { return m_LP3ModuleInfo; }            set { SetProperty(ref m_LP3ModuleInfo, value); }        }        public ModuleInfo EFEMModuleInfo        {            get { return m_EFEMModuleInfo; }            set { SetProperty(ref m_EFEMModuleInfo, value); }        }        public List<EFEMModule> EFEMModules        {            get { return m_EFEMModules; }            set { SetProperty(ref m_EFEMModules, value); }        }        public EFEMBlade PickSelectedBlade        {            get { return m_PickSelectedBlade; }            set { SetProperty(ref m_PickSelectedBlade, value); }        }        public EFEMBlade PlaceSelectedBlade        {            get { return m_PlaceSelectedBlade; }            set { SetProperty(ref m_PlaceSelectedBlade, value); }        }        public EFEMBlade ExtendSelectedBlade        {            get { return m_ExtendSelectedBlade; }            set { SetProperty(ref m_ExtendSelectedBlade, value); }        }        public EFEMBlade RetractSelectedBlade        {            get { return m_RetractSelectedBlade; }            set { SetProperty(ref m_RetractSelectedBlade, value); }        }        public ObservableCollection<int> PickSoltItemsSource        {            get { return m_PickSoltItemsSource; }            set { SetProperty(ref m_PickSoltItemsSource, value); }        }        public ObservableCollection<int> PlaceSoltItemsSource        {            get { return m_PlaceSoltItemsSource; }            set { SetProperty(ref m_PlaceSoltItemsSource, value); }        }        public ObservableCollection<int> ExtendSoltItemsSource        {            get { return m_ExtendSoltItemsSource; }            set { SetProperty(ref m_ExtendSoltItemsSource, value); }        }        public ObservableCollection<int> RetractSoltItemsSource        {            get { return m_RetractSoltItemsSource; }            set { SetProperty(ref m_RetractSoltItemsSource, value); }        }        public int PickSoltSelectedIndex        {            get { return m_PickSoltSelectedIndex; }            set { SetProperty(ref m_PickSoltSelectedIndex, value); }        }        public int PlaceSoltSelectedIndex        {            get { return m_PlaceSoltSelectedIndex; }            set { SetProperty(ref m_PlaceSoltSelectedIndex, value); }        }        public int ExtendSoltSelectedIndex        {            get { return m_ExtendSoltSelectedIndex; }            set { SetProperty(ref m_ExtendSoltSelectedIndex, value); }        }        public int RetractSoltSelectedIndex        {            get { return m_RetractSoltSelectedIndex; }            set { SetProperty(ref m_RetractSoltSelectedIndex, value); }        }        public EFEMModule PickSelectedModule        {            get { return m_PickSelectedModule; }            set { SetProperty(ref m_PickSelectedModule, value); }        }        public EFEMModule PlaceSelectedModule        {            get { return m_PlaceSelectedModule; }            set { SetProperty(ref m_PlaceSelectedModule, value); }        }        public EFEMModule ExtendSelectedModule        {            get { return m_ExtendSelectedModule; }            set { SetProperty(ref m_ExtendSelectedModule, value); }        }        public EFEMModule RetractSelectedModule        {            get { return m_RetractSelectedModule; }            set { SetProperty(ref m_RetractSelectedModule, value); }        }        public WaferInfo BladeAWafer        {            get { return m_BladeAWafer; }            set { SetProperty(ref m_BladeAWafer, value); }        }        public WaferInfo BladeBWafer        {            get { return m_BladeBWafer; }            set { SetProperty(ref m_BladeBWafer, value); }        }        public WaferInfo Aligner1Wafer        {            get { return m_Aligner1Wafer; }            set { SetProperty(ref m_Aligner1Wafer, value); }        }        public WaferInfo LLAWafer        {            get { return m_LLAWafer; }            set { SetProperty(ref m_LLAWafer, value); }        }        public WaferInfo LLBWafer        {            get { return m_LLBWafer; }            set { SetProperty(ref m_LLBWafer, value); }        }        public string LP1Status        {            get { return m_LP1Status; }            set { SetProperty(ref m_LP1Status, value); }        }        public string LP2Status        {            get { return m_LP2Status; }            set { SetProperty(ref m_LP2Status, value); }        }        public string LP3Status        {            get { return m_LP3Status; }            set { SetProperty(ref m_LP3Status, value); }        }        public Dictionary<string, object> RtDataValues        {            get { return m_RtDataValues; }            set { SetProperty(ref m_RtDataValues, value); }        }        public int AlignValue        {            get { return m_AlignValue; }            set { SetProperty(ref m_AlignValue, value); }        }        public WaferRobotTAction Robot1TAction        {            get { return m_Robot1TAction; }            set { SetProperty(ref m_Robot1TAction, value); }        }        public WaferRobotXAction Robot1XAction        {            get { return m_Robot1XAction; }            set { SetProperty(ref m_Robot1XAction, value); }        }        public WaferRobotTAction Robot2TAction        {            get { return m_Robot2TAction; }            set { SetProperty(ref m_Robot2TAction, value); }        }        public WaferRobotXAction Robot2XAction        {            get { return m_Robot2XAction; }            set { SetProperty(ref m_Robot2XAction, value); }        }        private string m_RobotTarget;        public string RobotTarget        {            get { return m_RobotTarget; }            set            {                SetProperty(ref m_RobotTarget, value);            }        }        public RobotMoveInfo m_robotMoveInfo;        public RobotMoveInfo RobotMoveInfo        {            get { return m_robotMoveInfo; }            set            {                EFEMRobotMoveInfoChanged(m_robotMoveInfo, value);                m_robotMoveInfo = value;            }        }        public RobotPosition CurrentRobotPosition        {            get { return m_CurrentRobotPosition; }            set { SetProperty(ref m_CurrentRobotPosition, value); }        }        public NiceGuangChuanWaferRobotTAction BladeNiceGuangChuanWaferRobotTAction        {            get { return m_BladeNiceGuangChuanWaferRobotTAction; }            set            {                SetProperty(ref m_BladeNiceGuangChuanWaferRobotTAction, value);            }        }        //public NiceGuangChuanWaferRobotTAction Blade2NiceGuangChuanWaferRobotTAction        //{        //    get { return m_Blade2NiceGuangChuanWaferRobotTAction; }        //    set        //    {        //        SetProperty(ref m_Blade2NiceGuangChuanWaferRobotTAction, value);        //    }        //}        public NiceGuangChuanWaferRobotXAction Blade1NiceGuangChuanWaferRobotXAction        {            get { return m_Blade1NiceGuangChuanWaferRobotXAction; }            set            {                SetProperty(ref m_Blade1NiceGuangChuanWaferRobotXAction, value);            }        }        public NiceGuangChuanWaferRobotXAction Blade2NiceGuangChuanWaferRobotXAction        {            get { return m_Blade2NiceGuangChuanWaferRobotXAction; }            set            {                SetProperty(ref m_Blade2NiceGuangChuanWaferRobotXAction, value);            }        }        #endregion        #region 命令        private DelegateCommand _ExtendCommand;        public DelegateCommand ExtendCommand =>            _ExtendCommand ?? (_ExtendCommand = new DelegateCommand(OnExtend));        private DelegateCommand _RetractCommand;        public DelegateCommand RetractCommand =>            _RetractCommand ?? (_RetractCommand = new DelegateCommand(OnRetract));        private DelegateCommand<object> _ModuleChangeCommand;        public DelegateCommand<object> ModuleChangeCommand =>            _ModuleChangeCommand ?? (_ModuleChangeCommand = new DelegateCommand<object>(OnModuleChange));        private DelegateCommand _PickCommand;        public DelegateCommand PickCommand =>            _PickCommand ?? (_PickCommand = new DelegateCommand(OnPick));        private DelegateCommand _PlaceCommand;        public DelegateCommand PlaceCommand =>            _PlaceCommand ?? (_PlaceCommand = new DelegateCommand(OnPlace));        private DelegateCommand _HomeAllCommand;        public DelegateCommand HomeAllCommand =>            _HomeAllCommand ?? (_HomeAllCommand = new DelegateCommand(OnHomeAll));        private DelegateCommand _ClearErrorCommand;        public DelegateCommand ClearErrorCommand =>            _ClearErrorCommand ?? (_ClearErrorCommand = new DelegateCommand(OnClearError));        private DelegateCommand _AbortCommand;        public DelegateCommand AbortCommand =>            _AbortCommand ?? (_AbortCommand = new DelegateCommand(OnAbort));        private DelegateCommand _Align1HomeCommand;        public DelegateCommand Align1HomeCommand =>            _Align1HomeCommand ?? (_Align1HomeCommand = new DelegateCommand(OnAlign1Home));        private DelegateCommand _Align1UpCommand;        public DelegateCommand Align1UpCommand =>            _Align1UpCommand ?? (_Align1UpCommand = new DelegateCommand(OnAlign1Up));        private DelegateCommand _Align1DownCommand;        public DelegateCommand Align1DownCommand =>            _Align1DownCommand ?? (_Align1DownCommand = new DelegateCommand(OnAlign1Down));        private DelegateCommand _Align1AlignCommand;        public DelegateCommand Align1AlignCommand =>            _Align1AlignCommand ?? (_Align1AlignCommand = new DelegateCommand(OnAlign1Align));        private DelegateCommand _RobotHomeCommand;        public DelegateCommand RobotHomeCommand =>            _RobotHomeCommand ?? (_RobotHomeCommand = new DelegateCommand(OnRobotHome));        private DelegateCommand<object> _LPHomeCommand;        public DelegateCommand<object> LPHomeCommand =>            _LPHomeCommand ?? (_LPHomeCommand = new DelegateCommand<object>(OnLPHome));        private DelegateCommand<object> _LPAbortCommand;        public DelegateCommand<object> LPAbortCommand =>            _LPAbortCommand ?? (_LPAbortCommand = new DelegateCommand<object>(OnLPAbort));        private DelegateCommand<object> _LPResetCommand;        public DelegateCommand<object> LPResetCommand =>            _LPResetCommand ?? (_LPResetCommand = new DelegateCommand<object>(OnLPReset));        private DelegateCommand<object> _LPLoadCommand;        public DelegateCommand<object> LPLoadCommand =>            _LPLoadCommand ?? (_LPLoadCommand = new DelegateCommand<object>(OnLPLoad));        private DelegateCommand<object> _LPUnLoadCommand;        public DelegateCommand<object> LPUnLoadCommand =>            _LPUnLoadCommand ?? (_LPUnLoadCommand = new DelegateCommand<object>(OnLPUnLoad));        private DelegateCommand<object> _LPReadIDCommand;        public DelegateCommand<object> LPReadIDCommand =>            _LPReadIDCommand ?? (_LPReadIDCommand = new DelegateCommand<object>(OnLPReadID));        private DelegateCommand<object> _LPClampCommand;        public DelegateCommand<object> LPClampCommand =>            _LPClampCommand ?? (_LPClampCommand = new DelegateCommand<object>(OnLPClamp));        private DelegateCommand<object> _LPUnClampCommand;        public DelegateCommand<object> LPUnClampCommand =>            _LPUnClampCommand ?? (_LPUnClampCommand = new DelegateCommand<object>(OnLPUnClamp));        private DelegateCommand<object> _LPDockCommand;        public DelegateCommand<object> LPDockCommand =>            _LPDockCommand ?? (_LPDockCommand = new DelegateCommand<object>(OnLPDock));        private DelegateCommand<object> _LPUnDockCommand;        public DelegateCommand<object> LPUnDockCommand =>            _LPUnDockCommand ?? (_LPUnDockCommand = new DelegateCommand<object>(OnLPUnDock));        private DelegateCommand<object> _LPOpenDoorCommand;        public DelegateCommand<object> LPOpenDoorCommand =>            _LPOpenDoorCommand ?? (_LPOpenDoorCommand = new DelegateCommand<object>(OnLPOpenDoor));        private DelegateCommand<object> _LPCloseDoorCommand;        public DelegateCommand<object> LPCloseDoorCommand =>            _LPCloseDoorCommand ?? (_LPCloseDoorCommand = new DelegateCommand<object>(OnLPCloseDoor));        private DelegateCommand _OnlineCommand;        public DelegateCommand OnlineCommand =>            _OnlineCommand ?? (_OnlineCommand = new DelegateCommand(OnOnline));        private DelegateCommand _OfflineCommand;        public DelegateCommand OfflineCommand =>            _OfflineCommand ?? (_OfflineCommand = new DelegateCommand(OnOffline));        #endregion        #region 构造函数        public EfemViewModel()        {            string[] allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(',');                        LLAIsInstalled = allModules.Contains("LLA");            LLBIsInstalled = allModules.Contains("LLB");            timer = new DispatcherTimer();            timer.Interval = TimeSpan.FromSeconds(0.5);            timer.Tick += Timer_Tick;            timer.Start();            EFEMModules.Add(EFEMModule.LLA);            EFEMModules.Add(EFEMModule.LLB);            EFEMModules.Add(EFEMModule.LP1);            EFEMModules.Add(EFEMModule.LP2);            EFEMModules.Add(EFEMModule.LP3);            EFEMModules.Add(EFEMModule.Aligner1);            OnModuleChange("Pick");            OnModuleChange("Place");            Init();        }        #endregion        #region 命令方法        private void OnModuleChange(object obj)        {            var value = obj.ToString();            switch (value)            {                case "Pick":                     PickSoltItemsSource.Clear();                    switch (PickSelectedModule)                    {                        case EFEMModule.LLA:                        case EFEMModule.LLB:                            PickSoltItemsSource.Add(1);                            PickSoltItemsSource.Add(2);                            break;                        case EFEMModule.LP1:                        case EFEMModule.LP2:                        case EFEMModule.LP3:                            for (int i = 1; i < 26; i++)                            {                                PickSoltItemsSource.Add(i);                            }                            break;                        default:                            PickSoltItemsSource.Add(1);                            break;                    }                    PickSoltSelectedIndex = 0;                    break;                case "Place":                    PlaceSoltItemsSource.Clear();                    switch (PlaceSelectedModule)                    {                        case EFEMModule.LLA:                        case EFEMModule.LLB:                            PlaceSoltItemsSource.Add(1);                            PlaceSoltItemsSource.Add(2);                            break;                        case EFEMModule.LP1:                        case EFEMModule.LP2:                        case EFEMModule.LP3:                            for (int i = 1; i < 26; i++)                            {                                PlaceSoltItemsSource.Add(i);                            }                            break;                        default:                            PlaceSoltItemsSource.Add(1);                            break;                    }                    PlaceSoltSelectedIndex = 0;                    break;                //case "Extend":                //    ExtendSoltItemsSource.Clear();                //    switch (ExtendSelectedModule)                //    {                //        case EFEMModule.LLA:                //        case EFEMModule.LLB:                //            ExtendSoltItemsSource.Add(1);                //            ExtendSoltItemsSource.Add(2);                //            break;                //        case EFEMModule.LP1:                //        case EFEMModule.LP2:                //        case EFEMModule.LP3:                //            for (int i = 1; i < 26; i++)                //            {                //                ExtendSoltItemsSource.Add(i);                //            }                //            break;                //        default:                //            ExtendSoltItemsSource.Add(1);                //            break;                //    }                //    ExtendSoltSelectedIndex = 0;                //    break;                //case "Retract":                //    RetractSoltItemsSource.Clear();                //    switch (RetractSelectedModule)                //    {                //        case EFEMModule.LLA:                //        case EFEMModule.LLB:                //            RetractSoltItemsSource.Add(1);                //            RetractSoltItemsSource.Add(2);                //            break;                //        case EFEMModule.LP1:                //        case EFEMModule.LP2:                //        case EFEMModule.LP3:                //            for (int i = 1; i < 26; i++)                //            {                //                RetractSoltItemsSource.Add(i);                //            }                //            break;                //        default:                //            RetractSoltItemsSource.Add(1);                //            break;                //    }                //    RetractSoltSelectedIndex = 0;                //    break;            }        }        private void OnExtend()        {            var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);            var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);            InvokeClient.Instance.Service.DoOperation($"EFEM.{RtOperation.Extend}", moduleName, 0, selectedHand);        }        private void OnRetract()        {            var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);            var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);            InvokeClient.Instance.Service.DoOperation($"EFEM.{RtOperation.Retract}", moduleName, 0, selectedHand);        }        private void OnPick()        {            Queue<MoveItem> moveItems = new Queue<MoveItem>();            var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PickSelectedModule.ToString(), true);            var selectedHand = (Hand)Enum.Parse(typeof(Hand), PickSelectedBlade.ToString(), true);            MoveItem moveItem = new MoveItem(moduleName, PickSoltItemsSource[PickSoltSelectedIndex]-1, ModuleName.EfemRobot, 0, selectedHand);            moveItems.Enqueue(moveItem);            if (PickSelectedModule == EFEMModule.LLA || PickSelectedModule == EFEMModule.LLB)            {                InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Swap}", moveItems);            }            else            {             InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Pick}", moveItems);            }            //if ((int)PickSelectedModule > 3)            //{            //    InvokeClient.Instance.Service.DoOperation($"EFEM.{RtOperation.LLPick}", moveItems);            //}            //else            //{            //    InvokeClient.Instance.Service.DoOperation($"EFEM.{RtOperation.PMPick}", moveItems);            //}        }        private void OnPlace()        {            Queue<MoveItem> moveItems = new Queue<MoveItem>();            var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), PlaceSelectedModule.ToString(), true);            var selectedHand = (Hand)Enum.Parse(typeof(Hand), PlaceSelectedBlade.ToString(), true);            MoveItem moveItem = new MoveItem(ModuleName.EfemRobot, 0, moduleName, PlaceSoltItemsSource[PlaceSoltSelectedIndex]-1, selectedHand);            moveItems.Enqueue(moveItem);            //if ((int)PlaceSelectedModule > 3)            //{            //    InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.LLPlace}", moveItems);            //}            //else            //{            //    InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.PMPlace}", moveItems);            //}            if (PlaceSelectedModule == EFEMModule.LLA || PlaceSelectedModule == EFEMModule.LLB)            {                InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Swap}", moveItems);            }            else            {                 InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Place}", moveItems);            }        }        private void OnHomeAll()        {            InvokeClient.Instance.Service.DoOperation($"EFEM.{EfemOperation.Home}");        }        private void OnClearError()        {            InvokeClient.Instance.Service.DoOperation($"EFEM.{EfemOperation.ClearError}");        }        private void OnAbort()        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Abort}");                    }        private void OnAlign1Home()        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName.Aligner1}.{EfemOperation.Home}");        }        private void OnAlign1Up()        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName.Aligner1}.{EfemOperation.Lift}", true);        }        private void OnAlign1Down()        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName.Aligner1}.{EfemOperation.Lift}", false);        }        private void OnAlign1Align()        {             InvokeClient.Instance.Service.DoOperation($"{ModuleName.Aligner1}.{EfemOperation.Align}",0, AlignValue);        }        private void OnRobotHome()        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Home}");        }        private void OnLPHome(object obj)        {            InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Home");        }        private void OnLPAbort(object obj)        {            InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Abort");        }        private void OnLPReset(object obj)        {            //InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.ReSet");        }        private void OnLPLoad(object obj)        {             InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Load");        }        private void OnLPUnLoad(object obj)        {            InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Unload");        }        private void OnLPReadID(object obj)        {            InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.ReadCarrierId");        }        private void OnLPClamp(object obj)        {            InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Clamp");        }        private void OnLPUnClamp(object obj)        {            InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Unclamp");        }        private void OnLPDock(object obj)        {            InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Dock");        }        private void OnLPUnDock(object obj)        {            InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.Undock");        }        private void OnLPOpenDoor(object obj)        {            InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.OpenDoor");        }        private void OnLPCloseDoor(object obj)        {            InvokeClient.Instance.Service.DoOperation($"{obj.ToString()}.CloseDoor");        }        private void OnOnline()        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName.EFEM}.Online",true);        }        private void OnOffline()        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName.EFEM}.Online", false);        }        #endregion        #region 私有方法        private void Timer_Tick(object sender, EventArgs e)        {            if (LLAIsInstalled == true)            {                LLAWafer = ModuleManager.ModuleInfos["LLA"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0);                LLAModuleInfo = ModuleManager.ModuleInfos["LLA"];            }            if (LLBIsInstalled == true)            {                LLBWafer = ModuleManager.ModuleInfos["LLB"].WaferManager.Wafers.FirstOrDefault(x => x.WaferStatus != 0);                LLBModuleInfo = ModuleManager.ModuleInfos["LLB"];            }            LP1ModuleInfo = ModuleManager.ModuleInfos["LP1"];            LP2ModuleInfo = ModuleManager.ModuleInfos["LP2"];            LP3ModuleInfo = ModuleManager.ModuleInfos["LP3"];            EFEMModuleInfo = ModuleManager.ModuleInfos["EfemRobot"];            BladeAWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0];            BladeBWafer = ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[1];            Aligner1Wafer= ModuleManager.ModuleInfos["Aligner1"].WaferManager.Wafers[0];            RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);            RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("EFEM.RobotMoveAction");        }        private void Init()        {            m_RtDataKeys.Add("LP1.Status");            m_RtDataKeys.Add("LP2.Status");            m_RtDataKeys.Add("LP3.Status");            m_RtDataKeys.Add("LP1.IsLoaded");            m_RtDataKeys.Add("LP2.IsLoaded");            m_RtDataKeys.Add("LP3.IsLoaded");            m_RtDataKeys.Add("LP1.CarrierId");            m_RtDataKeys.Add("LP2.CarrierId");            m_RtDataKeys.Add("LP3.CarrierId");            m_RtDataKeys.Add("LP1.IsClamped");            m_RtDataKeys.Add("LP2.IsClamped");            m_RtDataKeys.Add("LP3.IsClamped");            m_RtDataKeys.Add("LP1.IsDocked");            m_RtDataKeys.Add("LP2.IsDocked");            m_RtDataKeys.Add("LP3.IsDocked");            m_RtDataKeys.Add("TM.LLATSlitDoor.IsClosed");            m_RtDataKeys.Add("TM.LLBTSlitDoor.IsClosed");            m_RtDataKeys.Add("TM.LLAESlitDoor.IsClosed");            m_RtDataKeys.Add("TM.LLBESlitDoor.IsClosed");            m_RtDataKeys.Add("LP1.CassettePlaced");            m_RtDataKeys.Add("LP2.CassettePlaced");            m_RtDataKeys.Add("LP3.CassettePlaced");            m_RtDataKeys.Add("EFEM.IsOnline");        }        public void EnterExitView(bool isEnter)        {            //if (isEnter)            //{            //    Timer_Tick(null, null);            //    timer.Start();            //}            //else            //{            //    timer.Stop();            //}        }        //private void UIEvents_PMDoorRaiseChangedEvent(DoorPara obj)        //{        //    InvokeClient.Instance.Service.DoOperation($"{obj?.ModuleName}.SlitDoor.{obj?.IsOpen}");        //}        //private void UIEvents_LLTDoorRaiseChangedEvent(DoorPara obj)        //{        //    InvokeClient.Instance.Service.DoOperation($"TM.{obj.ModuleName}TSlitDoor.{obj?.IsOpen}");        //}        //private void UIEvents_LLEDoorRaiseChangedEvent(DoorPara obj)        //{        //    InvokeClient.Instance.Service.DoOperation($"TM.{obj.ModuleName}ESlitDoor.{obj?.IsOpen}");        //}        private async void EFEMRobotMoveInfoChanged(RobotMoveInfo oldValue, RobotMoveInfo newValue)        {            string RobotTarget;            if (oldValue == null || newValue == null)            {                return;            }            #region pick 和 place LL            if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget))            {                var TMRobotMoveActionBladeTarget = newValue.BladeTarget;                if (TMRobotMoveActionBladeTarget != null)                {                    RobotTarget = TMRobotMoveActionBladeTarget.ToString();                }                else                {                    return;                }                var values = RobotTarget.Split('.');                var arm = values[0];                var module = values[1];                                if (arm == "ArmA")                {                    var bladeWaferRobotTAction = (NiceGuangChuanWaferRobotTAction)Enum.Parse(typeof(NiceGuangChuanWaferRobotTAction), module, true);                    if (BladeNiceGuangChuanWaferRobotTAction != bladeWaferRobotTAction)                    {                        BladeNiceGuangChuanWaferRobotTAction = bladeWaferRobotTAction;                        await Task.Delay(1500);                    }                    Blade1NiceGuangChuanWaferRobotXAction = NiceGuangChuanWaferRobotXAction.Extend1;                    //Robot3XAction = WaferRobotXAction.Extend;                    while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[0].WaferStatus == 0))                    {                        await Task.Delay(100);                    }                    //Robot3XAction = WaferRobotXAction.Retract;                    Blade1NiceGuangChuanWaferRobotXAction = NiceGuangChuanWaferRobotXAction.Retract1;                }                else if (arm == "ArmB")                {                    var bladeWaferRobotTAction = (NiceGuangChuanWaferRobotTAction)Enum.Parse(typeof(NiceGuangChuanWaferRobotTAction), module, true);                    if (BladeNiceGuangChuanWaferRobotTAction != bladeWaferRobotTAction)                    {                        BladeNiceGuangChuanWaferRobotTAction = bladeWaferRobotTAction;                        await Task.Delay(1500);                    }                    Blade2NiceGuangChuanWaferRobotXAction = NiceGuangChuanWaferRobotXAction.Extend2;                    while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[1].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["EfemRobot"].WaferManager.Wafers[1].WaferStatus == 0))                    {                        await Task.Delay(100);                    }                    // Robot4XAction = WaferRobotXAction.Retract;                    Blade2NiceGuangChuanWaferRobotXAction = NiceGuangChuanWaferRobotXAction.Retract2;                }            }            #endregion                    #region Home            else if (oldValue.Action == RobotAction.Homing && newValue.Action == RobotAction.None)            {                Blade1NiceGuangChuanWaferRobotXAction = NiceGuangChuanWaferRobotXAction.Retract1;                Blade2NiceGuangChuanWaferRobotXAction = NiceGuangChuanWaferRobotXAction.Retract2;                await Task.Delay(1000);                BladeNiceGuangChuanWaferRobotTAction = NiceGuangChuanWaferRobotTAction.T_Origin;                //Blade2NiceGuangChuanWaferRobotTAction = NiceGuangChuanWaferRobotTAction.T_Origin;            }            #endregion        }        private async Task ChangePosition(WaferRobotTAction waferRobotTAction)        {            //CurrentRobotPosition = RobotPosition.Origin;            //await Task.Delay(1000);            if (waferRobotTAction == WaferRobotTAction.LP1)            {                CurrentRobotPosition = RobotPosition.Left;            }            else if (waferRobotTAction == WaferRobotTAction.LP3)            {                CurrentRobotPosition = RobotPosition.Right;            }            else if (waferRobotTAction == WaferRobotTAction.LP2)            {                CurrentRobotPosition = RobotPosition.Middle;            }            else            {                 CurrentRobotPosition = RobotPosition.Origin;            }            await Task.Delay(600);        }        #endregion    }}
 |