| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164 | using Aitex.Sorter.Common;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 Microsoft.VisualBasic;using OpenSEMI.ClientBase;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;namespace Venus_MainPages.ViewModels{        public enum TMModule    {        PMA, PMB, PMC, PMD, LLA, LLB    }    public enum TMBlade    {        Blade1, Blade2    }       internal class TMViewModel : BindableBase    {        #region 私有字段        //private ModuleInfo m_PMAWafer;        private ModuleInfo m_LLAModuleInfo;        private ModuleInfo m_LLBModuleInfo;        private bool m_TMIsOFFline;        private bool m_LLIsOFFline;        private WaferInfo m_PMAWafer;        private WaferInfo m_PMBWafer;         private WaferInfo m_PMCWafer;         private WaferInfo m_PMDWafer;        private WaferInfo m_LLAWafer;        private WaferInfo m_LLBWafer;        private WaferInfo m_BladeAWafer;        private WaferInfo m_BladeBWafer;        private bool m_PMADoorIsOpen;        //private bool m_PMBDoorIsOpen;         //private bool m_PMCDoorIsOpen;         //private bool m_PMDDoorIsOpen;        private bool m_LLADoorIsOpen;        private WaferRobotTAction m_WaferRobotTAction;        private WaferRobotTAction m_Robot1TAction;        private WaferRobotXAction m_Robot1XAction;        private WaferRobotTAction m_Robot2TAction;        private WaferRobotXAction m_Robot2XAction;        private TMModule m_PickSelectedModule;        private TMModule m_PlaceSelectedModule;        private TMModule m_ExtendSelectedModule;        private TMModule m_RetractSelectedModule;        private TMBlade m_PickSelectedBlade;        private TMBlade m_PlaceSelectedBlade;        private TMBlade m_ExtendSelectedBlade;        private TMBlade m_RetractSelectedBlade;        private TMBlade m_GoToSelectedBlade;        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 List<string> m_RtDataKeys=new List<string> ();        private Dictionary<string, object> m_RtDataValues;        private string m_ModuleCheckedName="TM";        private string m_RobotAction;        private string m_RobotTarget;        private string m_RobotArm;        private bool m_PMAIsInstalled;        private bool m_PMBIsInstalled;        private bool m_PMCIsInstalled;        private bool m_PMDIsInstalled;        private bool m_LLAIsInstalled;        private bool m_LLBIsInstalled;        private List<string> m_OriginalCycle=new List<string> ();        private List<string> m_ToCycle = new List<string>();        private List<TMModule> m_TMModules= new List<TMModule>();        private bool m_CycleEnable;        private string m_OriginalCycleSelectedItem;        private string m_ToCycleSelectedItem;        private bool m_PMAIsCycle;        private bool m_PMBIsCycle;        private bool m_PMCIsCycle;        private bool m_PMDIsCycle;        private int m_CycleCount;        #endregion        #region 属性        public List<string> OriginalCycle        {            get { return m_OriginalCycle; }            set { SetProperty(ref m_OriginalCycle, value); }        }        public List<string> ToCycle        {            get { return m_ToCycle; }            set { SetProperty(ref m_ToCycle, value); }        }        public string RobotAction2        {            get { return m_RobotAction; }            set             {                //RobotActiont(m_RobotAction, value);                                SetProperty(ref m_RobotAction, value);            }        }        public RobotMoveInfo m_robotMoveInfo;        public RobotMoveInfo RobotMoveInfo        {            get { return m_robotMoveInfo; }            set             {                RobotMoveInfoChanged(m_robotMoveInfo, value);                m_robotMoveInfo = value;             }        }        public string RobotTarget        {            get { return m_RobotTarget; }            set            {                SetProperty(ref m_RobotTarget, value);            }        }        public string RobotArm        {            get { return m_RobotArm; }            set            {                 SetProperty(ref m_RobotArm, value);            }        }        int arm1oldWaferStatus = 100;        int arm2oldWaferStatus = 100;        private async void RobotMoveInfoChanged(RobotMoveInfo oldValue,RobotMoveInfo newValue)        {            if (oldValue == null ||newValue==null)            {                return;            }            #region pick 和 place LL            if (oldValue.Action == RobotAction.None && (newValue.Action == RobotAction.Placing || newValue.Action == RobotAction.Picking))            {                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")                {                    Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    await Task.Delay(1500);                    Robot1XAction = WaferRobotXAction.Extend;                    await Task.Delay(3000);                    Robot1XAction = WaferRobotXAction.Retract;                }                else if (arm == "ArmB")                {                    Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    await Task.Delay(1500);                    Robot2XAction = WaferRobotXAction.Extend;                    await Task.Delay(3000);                    Robot2XAction = WaferRobotXAction.Retract;                }            }                      //if ((oldValue.Action==RobotAction.Placing||oldValue.Action==RobotAction.Picking) && newValue.Action==RobotAction.None)            //{            //    var TMRobotMoveActionBladeTarget = oldValue.BladeTarget;            //    if (TMRobotMoveActionBladeTarget != null)            //    {            //        RobotTarget = TMRobotMoveActionBladeTarget.ToString();            //    }            //    else            //    {            //        return;            //    }            //    var values = RobotTarget.Split('.');            //    var arm = values[0];            //    var module = values[1];            //    if (arm == "ArmA")            //    {            //        Robot1XAction = WaferRobotXAction.Retract;            //    }            //    else if (arm == "ArmB")            //    {            //        Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);            //        await Task.Delay(1500);            //        Robot2XAction = WaferRobotXAction.Retract;            //    }            //}            #endregion            #region pick 和 place pm            if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Extending)            {                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")                {                    Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    await Task.Delay(1500);                    Robot1XAction = WaferRobotXAction.Extend;                }                else if (arm == "ArmB")                {                    Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    await Task.Delay(1500);                    Robot2XAction = WaferRobotXAction.Extend;                }            }            if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Retracting)            {                var TMRobotMoveActionBladeTarget = newValue.BladeTarget;                if (TMRobotMoveActionBladeTarget != null)                {                    RobotTarget = TMRobotMoveActionBladeTarget.ToString();                }                else                {                    return;                }                var values = RobotTarget.Split('.');                var arm = values[0];                if (arm == "ArmA")                {                    Robot1XAction = WaferRobotXAction.Retract;                }                else if (arm == "ArmB")                {                    Robot2XAction = WaferRobotXAction.Retract;                }            }            #endregion            arm1oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus;            arm2oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus;        }        private async void RobotActiont(string oldValue,string newValue)        {                        if (oldValue == "None" && newValue == "Placing" && ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus==1)            {                var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");                if (TMRobotMoveActionBladeTarget != null)                {                    RobotTarget = TMRobotMoveActionBladeTarget.ToString();                }                else                {                    return;                }                var values = RobotTarget.Split('.');                var arm = values[0];                var module = values[1];                Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                await Task.Delay(1500);                Robot1XAction = WaferRobotXAction.Extend;                if (arm == "ArmA")                {                    Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    await Task.Delay(1500);                    Robot1XAction = WaferRobotXAction.Extend;                }                else if (arm == "ArmB")                {                    Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    await Task.Delay(1500);                    Robot2XAction = WaferRobotXAction.Extend;                }            }            if (oldValue == "None" && newValue == "Placing" && ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus == 1)            {                var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");                if (TMRobotMoveActionBladeTarget != null)                {                    RobotTarget = TMRobotMoveActionBladeTarget.ToString();                }                else                {                    return;                }                var values = RobotTarget.Split('.');                var arm = values[0];                var module = values[1];                if (arm == "ArmA")                {                    Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    await Task.Delay(1500);                    Robot1XAction = WaferRobotXAction.Extend;                }                else if (arm == "ArmB")                {                    Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    await Task.Delay(1500);                    Robot2XAction = WaferRobotXAction.Extend;                }                //Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                //await Task.Delay(1500);                //Robot2XAction = WaferRobotXAction.Extend;                           }            if (arm1oldWaferStatus != ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus)            {                                     Robot1XAction = WaferRobotXAction.Retract;                         }            if (arm2oldWaferStatus != ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus)            {                Robot2XAction = WaferRobotXAction.Retract;            }                       if (oldValue == "None" && newValue == "Picking" && ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus == 0)            {                var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");                if (TMRobotMoveActionBladeTarget != null)                {                    RobotTarget = TMRobotMoveActionBladeTarget.ToString();                }                else                {                    return;                }                var values = RobotTarget.Split('.');                var arm = values[0];                var module = values[1];                if (arm == "ArmA")                {                    Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    await Task.Delay(1500);                    Robot1XAction = WaferRobotXAction.Extend;                }                else if (arm == "ArmB")                {                    Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    await Task.Delay(1500);                    Robot2XAction = WaferRobotXAction.Extend;                }                                  }            #region pick 和 place pm            if (oldValue == "None" && newValue == "Extending")            {                var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");                if (TMRobotMoveActionBladeTarget != null)                {                    RobotTarget = TMRobotMoveActionBladeTarget.ToString();                }                else                {                    return;                }                var values = RobotTarget.Split('.');                var arm = values[0];                var module = values[1];                if (arm == "ArmA")                {                    Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    await Task.Delay(1500);                    Robot1XAction = WaferRobotXAction.Extend;                }                else if (arm == "ArmB")                {                    Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    await Task.Delay(1500);                    Robot2XAction = WaferRobotXAction.Extend;                }            }            if (oldValue == "None" && newValue == "Retracting")            {                var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");                if (TMRobotMoveActionBladeTarget != null)                {                    RobotTarget = TMRobotMoveActionBladeTarget.ToString();                }                else                {                    return;                }                var values = RobotTarget.Split('.');                var arm = values[0];                if (arm == "ArmA")                {                    Robot1XAction = WaferRobotXAction.Retract;                }                else if (arm == "ArmB")                {                    Robot2XAction = WaferRobotXAction.Retract;                }            }            #endregion            arm1oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus;            arm2oldWaferStatus = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1].WaferStatus;        }        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 WaferInfo PMAWafer        {            get { return m_PMAWafer; }            set { SetProperty(ref m_PMAWafer, value); }        }        public WaferInfo PMBWafer        {            get { return m_PMBWafer; }            set { SetProperty(ref m_PMBWafer, value); }        }        public WaferInfo PMCWafer        {            get { return m_PMCWafer; }            set { SetProperty(ref m_PMCWafer, value); }        }        public WaferInfo PMDWafer        {            get { return m_PMDWafer; }            set { SetProperty(ref m_PMDWafer, 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 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 bool TMIsOFFline        {            get { return m_TMIsOFFline; }            set { SetProperty(ref m_TMIsOFFline, value); }        }        public bool LLIsOFFline        {            get { return m_LLIsOFFline; }            set { SetProperty(ref m_LLIsOFFline, value); }        }        public bool PMADoorIsOpen        {            get { return m_PMADoorIsOpen; }            set { SetProperty(ref m_PMADoorIsOpen, value); }        }        public bool LLADoorIsOpen        {            get { return m_LLADoorIsOpen; }            set { SetProperty(ref m_LLADoorIsOpen, value); }        }        public WaferRobotTAction WaferRobotTAction        {            get { return m_WaferRobotTAction; }            set { SetProperty(ref m_WaferRobotTAction, 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); }        }        public TMModule PickSelectedModule        {            get { return m_PickSelectedModule; }            set { SetProperty(ref m_PickSelectedModule, value); }        }        public TMModule PlaceSelectedModule        {            get { return m_PlaceSelectedModule; }            set { SetProperty(ref m_PlaceSelectedModule, value); }        }        public TMModule ExtendSelectedModule        {            get { return m_ExtendSelectedModule; }            set { SetProperty(ref m_ExtendSelectedModule, value); }        }        public TMModule RetractSelectedModule        {            get { return m_RetractSelectedModule; }            set { SetProperty(ref m_RetractSelectedModule, value); }        }        public TMBlade PickSelectedBlade        {            get { return m_PickSelectedBlade; }            set { SetProperty(ref m_PickSelectedBlade, value); }        }        public TMBlade PlaceSelectedBlade        {            get { return m_PlaceSelectedBlade; }            set { SetProperty(ref m_PlaceSelectedBlade, value); }        }        public TMBlade ExtendSelectedBlade        {            get { return m_ExtendSelectedBlade; }            set { SetProperty(ref m_ExtendSelectedBlade, value); }        }        public TMBlade RetractSelectedBlade        {            get { return m_RetractSelectedBlade; }            set { SetProperty(ref m_RetractSelectedBlade, value); }        }        public TMBlade GoToSelectedBlade        {            get { return m_GoToSelectedBlade; }            set { SetProperty(ref m_GoToSelectedBlade, 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 Dictionary<string, object> RtDataValues        {            get { return m_RtDataValues; }            set { SetProperty(ref m_RtDataValues, value); }        }        public bool PMAIsInstalled        {            get { return m_PMAIsInstalled; }            set { SetProperty(ref m_PMAIsInstalled, value); }        }        public bool PMBIsInstalled        {            get { return m_PMBIsInstalled; }            set { SetProperty(ref m_PMBIsInstalled, value); }        }        public bool PMCIsInstalled        {            get { return m_PMCIsInstalled; }            set { SetProperty(ref m_PMCIsInstalled, value); }        }        public bool PMDIsInstalled        {            get { return m_PMDIsInstalled; }            set { SetProperty(ref m_PMDIsInstalled, value); }        }        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 List<TMModule> TMModules        {            get { return m_TMModules; }            set { SetProperty(ref m_TMModules, value); }        }        public bool CycleEnable        {            get { return m_CycleEnable; }            set { SetProperty(ref m_CycleEnable, value); }        }        public string OriginalCycleSelectedItem        {            get { return m_OriginalCycleSelectedItem; }            set { SetProperty(ref m_OriginalCycleSelectedItem, value); }        }        public string ToCycleSelectedItem        {            get { return m_ToCycleSelectedItem; }            set { SetProperty(ref m_ToCycleSelectedItem, value); }        }        public bool PMAIsCycle        {            get { return m_PMAIsCycle; }            set { SetProperty(ref m_PMAIsCycle, value); }        }        public bool PMBIsCycle        {            get { return m_PMBIsCycle; }            set { SetProperty(ref m_PMBIsCycle, value); }        }        public bool PMCIsCycle        {            get { return m_PMCIsCycle; }            set { SetProperty(ref m_PMCIsCycle, value); }        }        public bool PMDIsCycle        {            get { return m_PMDIsCycle; }            set { SetProperty(ref m_PMDIsCycle, value); }        }        public int CycleCount        {            get { return m_CycleCount; }            set { SetProperty(ref m_CycleCount, value); }        }                #endregion        #region 命令        private DelegateCommand _GotoCommand;        public DelegateCommand GotoCommand =>            _GotoCommand ?? (_GotoCommand = new DelegateCommand(OnGoto));        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 _HomeCommand;        public DelegateCommand HomeCommand =>            _HomeCommand ?? (_HomeCommand = new DelegateCommand(OnHome));        private DelegateCommand _VentCommand;        public DelegateCommand VentCommand =>            _VentCommand ?? (_VentCommand = new DelegateCommand(OnVent));        private DelegateCommand _PumpCommand;        public DelegateCommand PumpCommand =>            _PumpCommand ?? (_PumpCommand = new DelegateCommand(OnPump));        private DelegateCommand _PurgeCommand;        public DelegateCommand PurgeCommand =>            _PurgeCommand ?? (_PurgeCommand = new DelegateCommand(OnPurge));        private DelegateCommand<object> _ModuleCheckedCommand;        public DelegateCommand<object> ModuleCheckedCommand =>            _ModuleCheckedCommand ?? (_ModuleCheckedCommand = new DelegateCommand<object>(OnModuleChecked));        private DelegateCommand _AbortCommand;        public DelegateCommand AbortCommand =>            _AbortCommand ?? (_AbortCommand = new DelegateCommand(OnAbort));        private DelegateCommand _StartCycleCommand;        public DelegateCommand StartCycleCommand =>            _StartCycleCommand ?? (_StartCycleCommand = new DelegateCommand(OnStartCycle));        private DelegateCommand _StopCycleCommand;        public DelegateCommand StopCycleCommand =>            _StopCycleCommand ?? (_StopCycleCommand = new DelegateCommand(OnStopCycle));        private DelegateCommand _SystemHomeCommand;        public DelegateCommand SystemHomeCommand =>            _SystemHomeCommand ?? (_SystemHomeCommand = new DelegateCommand(OnSystemHome));        #endregion        #region 构造函数        public TMViewModel()        {            string[] allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString().Split(',');            PMAIsInstalled = allModules.Contains("PMA");            PMBIsInstalled = allModules.Contains("PMB");            PMCIsInstalled = allModules.Contains("PMC");            PMDIsInstalled = allModules.Contains("PMD");            LLAIsInstalled = allModules.Contains("LLA");            LLBIsInstalled = allModules.Contains("LLB");            if (PMAIsInstalled == true)            {                TMModules.Add(TMModule.PMA);            }            if (PMBIsInstalled == true)            {                TMModules.Add(TMModule.PMB);            }            if (PMCIsInstalled == true)            {                TMModules.Add(TMModule.PMC);            }            if (PMDIsInstalled == true)            {                TMModules.Add(TMModule.PMD);            }            if (LLAIsInstalled == true)            {                OriginalCycle.Add("LLA");                ToCycle.Add("LLA");                TMModules.Add(TMModule.LLA);            }            if (LLBIsInstalled == true)            {                OriginalCycle.Add("LLB");                ToCycle.Add("LLB");                TMModules.Add(TMModule.LLB);            }            addDataKeys();            DispatcherTimer timer = new DispatcherTimer();            timer.Interval = TimeSpan.FromSeconds(0.5);            timer.Tick += Timer_Tick;            timer.Start();            PickSoltItemsSource.Add(1);            PlaceSoltItemsSource.Add(1);            ExtendSoltItemsSource.Add(1);            RetractSoltItemsSource.Add(1);            //Robot1TAction = WaferRobotTAction.PMA;            //Robot2TAction = WaferRobotTAction.PMD;        }               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"];            }            if (PMAIsInstalled == true)            {                PMAWafer = ModuleManager.ModuleInfos["PMA"].WaferManager.Wafers[0];            }            if (PMBIsInstalled == true)            {                PMBWafer = ModuleManager.ModuleInfos["PMB"].WaferManager.Wafers[0];            }            if (PMCIsInstalled == true)            {                PMCWafer = ModuleManager.ModuleInfos["PMC"].WaferManager.Wafers[0];            }            if (PMDIsInstalled == true)            {                PMDWafer = ModuleManager.ModuleInfos["PMD"].WaferManager.Wafers[0];            }            BladeAWafer = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0];            BladeBWafer = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[1];            RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);            var TMRobotMoveActionArmTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.ArmTarget");            if (TMRobotMoveActionArmTarget != null)            {                RobotArm = ModuleManager.ModuleInfos["TM"].WaferManager.Wafers[0].WaferStatus.ToString();            }            var TMRobotMoveActionBladeTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.BladeTarget");            if (TMRobotMoveActionBladeTarget != null)            {                 RobotTarget = TMRobotMoveActionBladeTarget.ToString();            }            var TMRobotMoveActionRobotAction = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.RobotAction");            if (TMRobotMoveActionRobotAction != null)            {                RobotAction2 = TMRobotMoveActionRobotAction.ToString();            }            RobotMoveInfo = (RobotMoveInfo)QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction");        }        #endregion        #region 命令方法        private void OnGoto()        {            if (GoToSelectedBlade == TMBlade.Blade1)            {                Robot1TAction = WaferRobotTAction;            }            else if (GoToSelectedBlade == TMBlade.Blade2)            {                 Robot2TAction = WaferRobotTAction;            }                   }        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($"TM.{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($"TM.{RtOperation.Retract}", moduleName, 0, selectedHand);        }        private void OnModuleChange(object obj)        {            var value = obj.ToString();            switch (value)            {                case "Pick":                    PickSoltItemsSource.Clear();                    if ((int)PickSelectedModule == 4)                    {                                               for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)                        {                            PickSoltItemsSource.Add(i);                        }                    }                    else if ((int)PickSelectedModule == 5)                    {                        for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)                        {                            PickSoltItemsSource.Add(i);                        }                    }                    else                    {                        PickSoltItemsSource.Add(1);                    }                    PickSoltSelectedIndex = 0;                    break;                case "Place":                    PlaceSoltItemsSource.Clear();                    if ((int)PlaceSelectedModule == 4)                    {                        for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)                        {                            PlaceSoltItemsSource.Add(i);                        }                    }                    else if ((int)PlaceSelectedModule == 5)                    {                        for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)                        {                            PlaceSoltItemsSource.Add(i);                        }                    }                    else                    {                        PlaceSoltItemsSource.Add(1);                    }                    PlaceSoltSelectedIndex = 0;                    break;                case "Extend":                    ExtendSoltItemsSource.Clear();                    if ((int)ExtendSelectedModule == 4)                    {                        for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)                        {                            ExtendSoltItemsSource.Add(i);                        }                    }                    else if ((int)ExtendSelectedModule == 5)                    {                        for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)                        {                            ExtendSoltItemsSource.Add(i);                        }                    }                    else                    {                        ExtendSoltItemsSource.Add(1);                    }                    ExtendSoltSelectedIndex = 0;                    break;                case "Retract":                    RetractSoltItemsSource.Clear();                    if ((int)RetractSelectedModule == 4)                    {                        for (int i = 1; i <= LLAModuleInfo.WaferManager.Wafers.Count; i++)                        {                            RetractSoltItemsSource.Add(i);                        }                        //RetractSoltItemsSource = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8 };                    }                    else if ((int)RetractSelectedModule == 5)                    {                        for (int i = 1; i <= LLBModuleInfo.WaferManager.Wafers.Count; i++)                        {                            RetractSoltItemsSource.Add(i);                        }                    }                    else                    {                        RetractSoltItemsSource.Add(1);                    }                    RetractSoltSelectedIndex = 0;                    break;            }                 }        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, 0, 0, selectedHand);            moveItems.Enqueue(moveItem);            if ((int)PickSelectedModule > 3)            {                           InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.LLPick}", moveItems);            }            else            {                InvokeClient.Instance.Service.DoOperation($"TM.{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(0,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);            }        }        private void OnHome()        {            InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.Home");        }        private void OnVent()        {            InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Vent}");        }        private void OnPump()        {            InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Pump}");        }        private void OnPurge()        {            InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Purge}");        }        private void OnModuleChecked(object obj)        {            m_ModuleCheckedName=obj.ToString();        }        private void OnAbort()        {            InvokeClient.Instance.Service.DoOperation($"{m_ModuleCheckedName}.{RtOperation.Abort}");        }        private void OnStartCycle()        {            if (CycleEnable == false)            {                return;            }            List<string> strings = new List<string>();            if (OriginalCycleSelectedItem != "")            {                strings.Add(OriginalCycleSelectedItem);            }            else            {                return;            }                       if (PMAIsCycle==true)            {                strings.Add("PMA");            }            if (PMBIsCycle == true)            {                strings.Add("PMB");            }            if (PMCIsCycle == true)            {                strings.Add("PMC");            }            if (PMDIsCycle == true)            {                strings.Add("PMD");            }            if (ToCycleSelectedItem != "")            {                strings.Add(ToCycleSelectedItem);            }            else            {                return;            }            InvokeClient.Instance.Service.DoOperation("TMCycle.Start", strings.ToArray(),CycleCount);        }        private void OnStopCycle()        {            InvokeClient.Instance.Service.DoOperation("TMCycle.Abort");        }        private void OnSystemHome()        {             InvokeClient.Instance.Service.DoOperation("System.Home");        }        #endregion        #region 私有方法        private void addDataKeys()        {            m_RtDataKeys.Add("PMA.IsSlitDoorClosed");            m_RtDataKeys.Add("PMB.IsSlitDoorClosed");            m_RtDataKeys.Add("PMC.IsSlitDoorClosed");            m_RtDataKeys.Add("PMD.IsSlitDoorClosed");            m_RtDataKeys.Add("TM.LLATSlitDoor.IsClosed");            m_RtDataKeys.Add("TM.LLBTSlitDoor.IsClosed");            m_RtDataKeys.Add("TMCycle.CycleIndex");        }        #endregion    }}
 |