| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288 | 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 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;using Venus_Themes.Unity;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 ModuleInfo m_TMModuleInfo;        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 bool m_TMIsInstalled;        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)        {            string RobotTarget;            if (oldValue == null || newValue == null)            {                return;            }            #region Rotating            if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (newValue.Action == RobotAction.Rotating))            {                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);                }                else if (arm == "ArmB")                {                    Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                }            }            #endregion            #region pick 和 place LL            else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && (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")                {                    var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    if (waferRobotTAction != Robot1TAction)                    {                        Robot1TAction = waferRobotTAction;                    }                    else                    {                        //await Task.Delay(100);                    }                    await Task.Delay(600);                    //Robot1TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    //await Task.Delay(600);                    Robot1XAction = WaferRobotXAction.Extend;                    while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0].WaferStatus == 0))                    {                        await Task.Delay(100);                    }                    Robot1XAction = WaferRobotXAction.Retract;                }                else if (arm == "ArmB")                {                    var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    if (waferRobotTAction != Robot2TAction)                    {                        Robot2TAction = waferRobotTAction;                    }                    else                    {                        //await Task.Delay(100);                    }                    await Task.Delay(600);                    //Robot2TAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    //await Task.Delay(600);                    Robot2XAction = WaferRobotXAction.Extend;                    while ((newValue.Action == RobotAction.Placing && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus != 0) || (newValue.Action == RobotAction.Picking && ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1].WaferStatus == 0))                    {                        await Task.Delay(100);                    }                    Robot2XAction = WaferRobotXAction.Retract;                }            }            #endregion            #region pick 和 place pm            else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && 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")                {                    var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    if (waferRobotTAction != Robot1TAction)                    {                        Robot1TAction = waferRobotTAction;                    }                    else                    {                        // await Task.Delay(100);                    }                    await Task.Delay(600);                    Robot1XAction = WaferRobotXAction.Extend;                }                else if (arm == "ArmB")                {                    var waferRobotTAction = (WaferRobotTAction)Enum.Parse(typeof(WaferRobotTAction), module, true);                    if (waferRobotTAction != Robot2TAction)                    {                        Robot2TAction = waferRobotTAction;                    }                    else                    {                        // await Task.Delay(100);                    }                    await Task.Delay(600);                    Robot2XAction = WaferRobotXAction.Extend;                }            }            else if ((oldValue.Action == RobotAction.None || oldValue.ArmTarget != newValue.ArmTarget) && 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            #region Home            else if (oldValue.Action == RobotAction.None && newValue.Action == RobotAction.Homing)            {                if (Robot1XAction == WaferRobotXAction.Extend)                {                    Robot1XAction = WaferRobotXAction.Retract;                }                if (Robot2XAction == WaferRobotXAction.Extend)                {                    Robot2XAction = WaferRobotXAction.Retract;                }                await Task.Delay(2000);                if (Robot1TAction != WaferRobotTAction.T_Origin)                {                    Robot1TAction = WaferRobotTAction.T_Origin;                }                if (Robot2TAction != WaferRobotTAction.T_Origin)                {                    Robot2TAction = WaferRobotTAction.T_Origin;                }            }            #endregion        }        private async void RobotActiont(string oldValue,string newValue)        {                        if (oldValue == "None" && newValue == "Placing" && ModuleManager.ModuleInfos["TMRobot"].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["TMRobot"].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 ModuleInfo TMModuleInfo        {            get { return m_TMModuleInfo; }            set { SetProperty(ref m_TMModuleInfo, 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 bool TMIsInstalled        {            get { return m_TMIsInstalled; }            set { SetProperty(ref m_TMIsInstalled, 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 _RobotHomeCommand;        public DelegateCommand RobotHomeCommand =>            _RobotHomeCommand ?? (_RobotHomeCommand = new DelegateCommand(OnRobotHome));        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));        private DelegateCommand<object> _ChamberDoorOpenCommand;        public DelegateCommand<object> ChamberDoorOpenCommand =>            _ChamberDoorOpenCommand ?? (_ChamberDoorOpenCommand = new DelegateCommand<object>(OnChamberDoorOpen));        private DelegateCommand<object> _ChamberDoorCloseCommand;        public DelegateCommand<object> ChamberDoorCloseCommand =>            _ChamberDoorCloseCommand ?? (_ChamberDoorCloseCommand = new DelegateCommand<object>(OnChamberDoorClose));        #endregion        #region 构造函数        public TMViewModel()        {            string allModules = QueryDataClient.Instance.Service.GetConfig($"System.InstalledModules").ToString();            PMAIsInstalled = allModules.Contains("PMA");            PMBIsInstalled = allModules.Contains("PMB");            PMCIsInstalled = allModules.Contains("PMC");            PMDIsInstalled = allModules.Contains("PMD");            LLAIsInstalled = allModules.Contains("LLA");            LLBIsInstalled = allModules.Contains("LLB");            TMIsInstalled= allModules.Contains("TM");            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.1);            timer.Tick += Timer_Tick;            timer.Start();            PickSoltItemsSource.Add(1);            PlaceSoltItemsSource.Add(1);            ExtendSoltItemsSource.Add(1);            RetractSoltItemsSource.Add(1);            //Robot1TAction = WaferRobotTAction.PMA;            //Robot2TAction = WaferRobotTAction.PMD;            //UIEvents.PMDoorRaiseChangedEvent += UIEvents_PMDoorRaiseChangedEvent;            //UIEvents.LLTDoorRaiseChangedEvent += UIEvents_LLTDoorRaiseChangedEvent;            //UIEvents.LLEDoorRaiseChangedEvent += UIEvents_LLEDoorRaiseChangedEvent;        }               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];            }            if (TMIsInstalled == true)            {                BladeAWafer = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[0];                BladeBWafer = ModuleManager.ModuleInfos["TMRobot"].WaferManager.Wafers[1];                TMModuleInfo = ModuleManager.ModuleInfos["TMRobot"];            }                        RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);            var TMRobotMoveActionArmTarget = QueryDataClient.Instance.Service.GetData("TM.RobotMoveAction.ArmTarget");            if (TMRobotMoveActionArmTarget != null)            {                RobotArm = ModuleManager.ModuleInfos["TMRobot"].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 OnRobotHome()        {            InvokeClient.Instance.Service.DoOperation($"TM.RobotHome", "TMRobot");        }        private void OnGoto()        {            //if (GoToSelectedBlade == TMBlade.Blade1)            //{            //    Robot1TAction = WaferRobotTAction;            //}            //else if (GoToSelectedBlade == TMBlade.Blade2)            //{             //    Robot2TAction = WaferRobotTAction;            //}            var moduleName = (ModuleName)Enum.Parse(typeof(ModuleName), WaferRobotTAction.ToString(), true);            var selectedHand = (Hand)Enum.Parse(typeof(Hand), GoToSelectedBlade.ToString(), true);            InvokeClient.Instance.Service.DoOperation($"TM.{RtOperation.Goto}", moduleName, 0, selectedHand);        }        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");        }        private void OnChamberDoorOpen(object obj)        {            InvokeClient.Instance.Service.DoOperation($"{obj?.ToString()}.SlitDoor.Open");        }        private void OnChamberDoorClose(object obj)        {            InvokeClient.Instance.Service.DoOperation($"{obj?.ToString()}.SlitDoor.Close");        }        #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("TM.LLAESlitDoor.IsClosed");            m_RtDataKeys.Add("TM.LLBESlitDoor.IsClosed");            m_RtDataKeys.Add("TMCycle.CycleIndex");            m_RtDataKeys.Add("PMA.CalculationPressure");            m_RtDataKeys.Add("PMB.CalculationPressure");            m_RtDataKeys.Add("PMC.CalculationPressure");            m_RtDataKeys.Add("PMD.CalculationPressure");        }        #endregion    }}
 |