using System; using System.Collections.Generic; using Aitex.Core.Common.DeviceData; using Aitex.Core.Util; using Aitex.Sorter.Common; using Bolt.Toolkit.Wpf.Data; using Bolt.Toolkit.Wpf.Data.Enum; using Caliburn.Micro.Core; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.OperationCenter; using VirgoCommon; using VirgoUI.Client.Models.Sys; namespace VirgoUI.Client.Models.Platform.EFEM { public class EFEMViewModel : UiViewModelBase { private int MenuPermission; #region Properties [Subscription("LP1.Status")] public string LP1Status { get; set; } public string LP1StatusBackground { get { return GetUnitStatusBackground(LP1Status); } } [Subscription("LP1.IsMapped")] public bool IsLP1Mapped { get; set; } [Subscription("LP2.Status")] public string LP2Status { get; set; } public string LP2StatusBackground { get { return GetUnitStatusBackground(LP2Status); } } [Subscription("LP2.IsMapped")] public bool IsLP2Mapped { get; set; } [Subscription("EFEM.FsmState")] public string EfemStatus { get; set; } public string EfemStatusBackground { get { return GetUnitStatusBackground(EfemStatus); } } [Subscription("PMA.IsAutoMode")] public bool PMAIsAutoMode { get; set; } [Subscription("PMB.IsAutoMode")] public bool PMBIsAutoMode { get; set; } [Subscription("PMA.IsOnline")] public bool PMAIsOnline { get; set; } [Subscription("PMB.IsOnline")] public bool PMBIsOnline { get; set; } public string PMAState { get { return "PMA/" + (PMAIsAutoMode ? "Auto/" : "Manual/") + (PMAIsOnline ? "Online" : "Offline"); } } public string PMBState { get { return "PMB/" + (PMBIsAutoMode ? "Auto/" : "Manual/") + (PMBIsOnline ? "Online" : "Offline"); } } private string _SelectedModule; public string SelectedModule { get { return _SelectedModule; } set { _SelectedModule = value; Slots = GetSlotsByModule(_SelectedModule); SelectedSlot = 1; NotifyOfPropertyChange("SelectedModule"); } } private string _PickSelectedModule; public string PickSelectedModule { get { return _PickSelectedModule; } set { _PickSelectedModule = value; PickSlots = GetSlotsByModule(_PickSelectedModule); PickSelectedSlot = 1; NotifyOfPropertyChange("PickSelectedModule"); } } private string _PlaceSelectedModule; public string PlaceSelectedModule { get { return _PlaceSelectedModule; } set { _PlaceSelectedModule = value; PlaceSlots = GetSlotsByModule(_PlaceSelectedModule); PlaceSelectedSlot = 1; NotifyOfPropertyChange("PlaceSelectedModule"); } } private string _ExtendSelectedModule; public string ExtendSelectedModule { get { return _ExtendSelectedModule; } set { _ExtendSelectedModule = value; ExtendSlots = GetExtendPos(); NotifyOfPropertyChange("ExtendSelectedModule"); } } private List GetExtendPos() { //return new List { "G1", "GB", "G4", "P1", "PB", "P4" }; return new List { "GoIntoGet", "GoBackGet", "GoIntoPut", "GoBackPut" }; } private static Dictionary ExtendParam = new Dictionary() { {"GoIntoGet","GB" }, {"GoBackGet","G4" }, {"GoIntoPut","PB" }, {"GoBackPut","P4" } }; private string _RetractSelectedModule; public string RetractSelectedModule { get { return _RetractSelectedModule; } set { _RetractSelectedModule = value; RetractSlots = GetExtendPos(); NotifyOfPropertyChange("RetractSelectedModule"); } } private string _MapSelectedModule; public string MapSelectedModule { get { return _MapSelectedModule; } set { _MapSelectedModule = value; //MapSlots = GetSlotsByModule(_MapSelectedModule); MapSelectedSlot = 1; NotifyOfPropertyChange("MapSelectedModule"); } } [Subscription("EfemRobot.RobotMoveAction")] public string EfemRobotMoveAction { get; set; } //[Subscription("EFEM.CassetteDoor")] //public AITSensorData CassetteDoorStatus //{ // get; // set; //} [Subscription("EFEM.CassetteDoor")] public LidState CassetteDoorStatus { get; set; } public bool IsLP1PresentFeedback { get { return LP1CassetteState == LoadportCassetteState.Normal; } } public bool IsLP2PresentFeedback { get { return LP2CassetteState == LoadportCassetteState.Normal; } } [Subscription("LP1.CassetteState")] public LoadportCassetteState LP1CassetteState { get; set; } [Subscription("LP2.CassetteState")] public LoadportCassetteState LP2CassetteState { get; set; } public bool Foup1Present { get { return LP1CassetteState == LoadportCassetteState.Normal; } } public bool Foup2Present { get { return LP2CassetteState == LoadportCassetteState.Normal; } } public RobotMoveInfo EfemRobotMoveInfo { get { RobotMoveInfo _moveInfo = new RobotMoveInfo() { BladeTarget = "System" }; if (!string.IsNullOrEmpty(EfemRobotMoveAction)) { var action = EfemRobotMoveAction.Split('.'); _moveInfo.BladeTarget = action[0]; _moveInfo.Action = (RobotAction)Enum.Parse(typeof(RobotAction), action[1]); } return _moveInfo; } } private List _blades = new List() { "Blade1", "Blade2" }; public List Blades { get { return _blades; } set { _blades = value; NotifyOfPropertyChange("Blades"); } } private int _SelectedSlot; public int SelectedSlot { get { return _SelectedSlot; } set { _SelectedSlot = value; NotifyOfPropertyChange("SelectedSlot"); } } private int _PickSelectedSlot; public int PickSelectedSlot { get { return _PickSelectedSlot; } set { _PickSelectedSlot = value; NotifyOfPropertyChange("PickSelectedSlot"); } } private string _pickSelectedBlade; public string PickSelectedBlade { get { return _pickSelectedBlade; } set { _pickSelectedBlade = value; NotifyOfPropertyChange("PickSelectedBlade"); } } private int _PlaceSelectedSlot; public int PlaceSelectedSlot { get { return _PlaceSelectedSlot; } set { _PlaceSelectedSlot = value; NotifyOfPropertyChange("PlaceSelectedSlot"); } } private string _placeSelectedBlade; public string PlaceSelectedBlade { get { return _placeSelectedBlade; } set { _placeSelectedBlade = value; NotifyOfPropertyChange("PlaceSelectedBlade"); } } private string _ExtendSelectedSlot; public string ExtendSelectedSlot { get { return _ExtendSelectedSlot; } set { _ExtendSelectedSlot = value; NotifyOfPropertyChange("ExtendSelectedSlot"); } } private string _extendSelectedBlade; public string ExtendSelectedBlade { get { return _extendSelectedBlade; } set { _extendSelectedBlade = value; NotifyOfPropertyChange("ExtendSelectedBlade"); } } private string _gripSelectedBlade; public string GripSelectedBlade { get { return _gripSelectedBlade; } set { _gripSelectedBlade = value; NotifyOfPropertyChange("GripSelectedBlade"); } } private string _ungripSelectedBlade; public string UngripSelectedBlade { get { return _ungripSelectedBlade; } set { _ungripSelectedBlade = value; NotifyOfPropertyChange("UngripSelectedBlade"); } } private int _RetractSelectedSlot; public int RetractSelectedSlot { get { return _RetractSelectedSlot; } set { _RetractSelectedSlot = value; NotifyOfPropertyChange("RetractSelectedSlot"); } } private int _MapSelectedSlot; public int MapSelectedSlot { get { return _MapSelectedSlot; } set { _MapSelectedSlot = value; NotifyOfPropertyChange("MapSelectedSlot"); } } private List _pickModules; public List PickPlaceModules { get { return _pickModules; } set { _pickModules = value; NotifyOfPropertyChange("PickPlaceModules"); } } private List _mapModules; public List MapModules { get { return _mapModules; } set { _mapModules = value; NotifyOfPropertyChange("MapModules"); } } private List _extendModules; public List ExtendRetractModules { get { return _extendModules; } set { _extendModules = value; NotifyOfPropertyChange("ExtendRetractModules"); } } private List _slots; public List Slots { get { return _slots; } set { _slots = value; NotifyOfPropertyChange("Slots"); } } private List _Pickslots; public List PickSlots { get { return _Pickslots; } set { _Pickslots = value; NotifyOfPropertyChange("PickSlots"); } } private List _Placeslots; public List PlaceSlots { get { return _Placeslots; } set { _Placeslots = value; NotifyOfPropertyChange("PlaceSlots"); } } private List _Extendslots; public List ExtendSlots { get { return _Extendslots; } set { _Extendslots = value; NotifyOfPropertyChange("ExtendSlots"); } } private List _Retractslots; public List RetractSlots { get { return _Retractslots; } set { _Retractslots = value; NotifyOfPropertyChange("RetractSlots"); } } [Subscription("LP1.WaferSize")] public string LP1WaferSize { get; set; } public string WaferSizeLP1 { get { return LP1CassetteState == LoadportCassetteState.Normal ? GetWaferSize(LP1WaferSize) : "--"; } } [Subscription("LP2.WaferSize")] public string LP2WaferSize { get; set; } public string WaferSizeLP2 { get { return LP2CassetteState == LoadportCassetteState.Normal ? GetWaferSize(LP2WaferSize) : "--"; } } [Subscription("Aligner1.WaferSize")] public string Aligner1WaferSize { get; set; } public string WaferSizeAligner1 { get { return GetWaferSize(Aligner1WaferSize); } } [Subscription("Aligner2.WaferSize")] public string Aligner2WaferSize { get; set; } public string WaferSizeAligner2 { get { return GetWaferSize(Aligner2WaferSize); } } [Subscription("Cooling1.WaferSize")] public string Cooling1WaferSize { get; set; } public string WaferSizeCooling1 { get { return GetWaferSize(Cooling1WaferSize); } } [Subscription("Cooling2.WaferSize")] public string Cooling2WaferSize { get; set; } public string WaferSizeCooling2 { get { return GetWaferSize(Cooling2WaferSize); } } [Subscription("EfemRobot.WaferSize")] public string EfemRobotWaferSize { get; set; } public string WaferSizeEfemRobot { get { return GetWaferSize(EfemRobotWaferSize); } } [Subscription("PMA.WaferSize")] public string PMAWaferSize { get; set; } public string WaferSizePMA { get { return GetWaferSize(PMAWaferSize); } } [Subscription("PMB.WaferSize")] public string PMBWaferSize { get; set; } public string WaferSizePMB { get { return GetWaferSize(PMBWaferSize); } } [Subscription("EFEM.SmallWafer")] public int SmallWafer { get; set; } [Subscription("EFEM.MidWafer")] public int MidWafer { get; set; } [Subscription("EFEM.BigWafer")] public int BigWafer { get; set; } #region public bool WaferSizePMA_3 { set { } get { return PMAWaferSize == "WS3"; } } public bool WaferSizePMA_4 { set { } get { return PMAWaferSize == "WS4"; } } public bool WaferSizePMA_6 { set { } get { return PMAWaferSize == "WS6"; } } public bool WaferSizePMB_3 { set { } get { return PMBWaferSize == "WS3"; } } public bool WaferSizePMB_4 { set { } get { return PMBWaferSize == "WS4"; } } public bool WaferSizePMB_6 { set { } get { return PMBWaferSize == "WS6"; } } public bool WaferSizeCooling2_3 { set { } get { return Cooling2WaferSize == "WS3"; } } public bool WaferSizeCooling2_4 { set { } get { return Cooling2WaferSize == "WS4"; } } public bool WaferSizeCooling2_6 { set { } get { return Cooling2WaferSize == "WS6"; } } public bool WaferSizeCooling1_3 { set { } get { return Cooling1WaferSize == "WS3"; } } public bool WaferSizeCooling1_4 { set { } get { return Cooling1WaferSize == "WS4"; } } public bool WaferSizeCooling1_6 { set { } get { return Cooling1WaferSize == "WS6"; } } public bool WaferSizeAligner2_3 { set { } get { return Aligner2WaferSize == "WS3"; } } public bool WaferSizeAligner2_4 { set { } get { return Aligner2WaferSize == "WS4"; } } public bool WaferSizeAligner2_6 { set { } get { return Aligner2WaferSize == "WS6"; } } public bool WaferSizeAligner1_3 { set { } get { return Aligner1WaferSize == "WS3"; } } public bool WaferSizeAligner1_4 { set { } get { return Aligner1WaferSize == "WS4"; } } public bool WaferSizeAligner1_6 { set { } get { return Aligner1WaferSize == "WS6"; } } public bool WaferSizeEfemRobot_3 { set { } get { return EfemRobotWaferSize == "WS3"; } } public bool WaferSizeEfemRobot_4 { set { } get { return EfemRobotWaferSize == "WS4"; } } public bool WaferSizeEfemRobot_6 { set { } get { return EfemRobotWaferSize == "WS6"; } } #endregion public bool PMASlitValveIsOpen { get { return SlitDoorDataA != null && SlitDoorDataA.OpenFeedback && !SlitDoorDataA.CloseFeedback; } } [Subscription("PMA.SlitDoor.DeviceData")] public AITCylinderData SlitDoorDataA { get; set; } public bool PMBSlitValveIsOpen { get { return SlitDoorDataB != null && SlitDoorDataB.OpenFeedback && !SlitDoorDataB.CloseFeedback; } } [Subscription("PMB.SlitDoor.DeviceData")] public AITCylinderData SlitDoorDataB { get; set; } public Dictionary _waferSizeMap = new Dictionary() { {"WS3", "3'"},{"WS4", "4'"},{"WS6", "6'"} }; private string GetWaferSize(string size) { if (size != null && _waferSizeMap.ContainsKey(size)) switch (size) { case "WS3": return SmallWafer.ToString(); case "WS4": return MidWafer.ToString(); case "WS6": return BigWafer.ToString(); default: return ""; } //return _waferSizeMap[size]; return ""; } [Subscription("EfemRobot.GripStateBlade1")] public string GripStateBlade1 { get; set; } public string Blade1GripStateColor { get { switch (GripStateBlade1) { case "ON": return "Lime"; case "OFF": return "Gray"; default: return "Yellow"; } } } [Subscription("EfemRobot.GripStateBlade2")] public string GripStateBlade2 { get; set; } public string Blade2GripStateColor { get { switch (GripStateBlade2) { case "ON": return "Lime"; case "OFF": return "Gray"; default: return "Yellow"; } } } public Aitex.Core.Common.WaferSize SmallPinWaferSize { get; set; } public Aitex.Core.Common.WaferSize MediumPinWaferSize { get; set; } public Aitex.Core.Common.WaferSize BigPinWaferSize { get; set; } #endregion Properties public EFEMViewModel() { this.DisplayName = "EFEM"; _pickModules = new List() { "LP1", "LP2", "Aligner1", "Aligner2", "Cooling1", "Cooling2" }; _mapModules = new List() { "LP1", "LP2" }; _extendModules = new List() { "PMA", "PMB" }; PickSelectedModule = "LP1"; PlaceSelectedModule = "LP1"; ExtendSelectedModule = "PMA"; RetractSelectedModule = "PMA"; MapSelectedModule = "LP1"; PickSelectedBlade = PlaceSelectedBlade = ExtendSelectedBlade = GripSelectedBlade = UngripSelectedBlade = "Blade1"; } protected override void OnActivate() { SmallPinWaferSize = MapWaferSize((int)QueryDataClient.Instance.Service.GetConfig($"System.SmallWafer")); MediumPinWaferSize = MapWaferSize((int)QueryDataClient.Instance.Service.GetConfig($"System.MidWafer")); BigPinWaferSize = MapWaferSize((int)QueryDataClient.Instance.Service.GetConfig($"System.BigWafer")); NotifyOfPropertyChange(nameof(SmallPinWaferSize)); NotifyOfPropertyChange(nameof(MediumPinWaferSize)); NotifyOfPropertyChange(nameof(BigPinWaferSize)); base.OnActivate(); } private Aitex.Core.Common.WaferSize MapWaferSize(int value) { switch (value) { case 3: return Aitex.Core.Common.WaferSize.WS3; case 4: return Aitex.Core.Common.WaferSize.WS4; case 6: return Aitex.Core.Common.WaferSize.WS6; case 8: return Aitex.Core.Common.WaferSize.WS8; } return Aitex.Core.Common.WaferSize.WS0; } private List GetSlotsByModule(string module) { List slots = new List(); int num = 0; switch (module) { case "LP1": case "LP2": num = 25; break; case "Aligner1": case "Aligner2": case "Cooling1": case "Cooling2": case "PMA": case "PMB": num = 1; break; } int j = 0; while (j < num) { slots.Add(j + 1); j++; } return slots; } protected override void OnInitialize() { MenuPermission = ClientApp.Instance.GetPermission("EFEM"); base.OnInitialize(); base.InitModules(); } #region Operation public void SetWaferSize(string module, string size) { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation("System.SetWaferSize", module, size); } public void HomeAligner(string module) { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation($"{module}.{EfemOperation.Home}"); } public void AlignAligner(string module) { if (MenuPermission != 3) return; string size = Aligner1WaferSize; if (module == ModuleName.Aligner2.ToString()) size = Aligner2WaferSize; if (module == ModuleName.Cooling1.ToString()) size = Cooling1WaferSize; if (module == ModuleName.Cooling2.ToString()) size = Cooling2WaferSize; InvokeClient.Instance.Service.DoOperation($"{module}.{EfemOperation.Align}", size); } public void LiftAligner(string module) { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation($"{module}.{EfemOperation.Lift}"); } public void HomeEfem() { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation($"{ModuleName.EFEM}.{EfemOperation.Home}"); } public void ResetEfem() { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation($"{ModuleName.EFEM}.Reset"); } public void ClearError() { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation($"{ModuleName.EFEM}.{EfemOperation.ClearError}"); } public void HomeRobot() { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Home}"); } public void AbortRobot() { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Abort}"); } public void RobotPick() { if (MenuPermission != 3) return; string ws = PickSelectedModule == ModuleName.LP1.ToString() ? LP1WaferSize : PickSelectedModule == ModuleName.LP2.ToString() ? LP2WaferSize : PickSelectedModule == ModuleName.Aligner1.ToString() ? Aligner1WaferSize : PickSelectedModule == ModuleName.Aligner2.ToString() ? Aligner2WaferSize : PickSelectedModule == ModuleName.Cooling2.ToString() ? Cooling2WaferSize : PickSelectedModule == ModuleName.Cooling1.ToString() ? Cooling1WaferSize : throw new ArgumentOutOfRangeException(); InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Pick}", PickSelectedModule, PickSelectedSlot - 1, ws, PickSelectedBlade); } public void RobotPlace() { if (MenuPermission != 3) return; string ws = PlaceSelectedModule == ModuleName.LP1.ToString() ? LP1WaferSize : PlaceSelectedModule == ModuleName.LP2.ToString() ? LP2WaferSize : PlaceSelectedModule == ModuleName.Aligner1.ToString() ? Aligner1WaferSize : PlaceSelectedModule == ModuleName.Aligner2.ToString() ? Aligner2WaferSize : PlaceSelectedModule == ModuleName.Cooling1.ToString() ? Cooling1WaferSize : PlaceSelectedModule == ModuleName.Cooling2.ToString() ? Cooling2WaferSize : throw new ArgumentOutOfRangeException(); InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Place}", PlaceSelectedModule, PlaceSelectedSlot - 1, ws, PlaceSelectedBlade); } public void RobotExtend() { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Extend}", ExtendSelectedModule, ExtendParam[ExtendSelectedSlot], ExtendSelectedBlade); } public void RobotRetract() { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Retract}", RetractSelectedModule, RetractSlots[RetractSelectedSlot]); } public void RobotMap() { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation($"{MapSelectedModule}.{EfemOperation.Map}"); } public void RobotGrip() { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Grip}", "ON", GripSelectedBlade); } public void RobotUngrip() { if (MenuPermission != 3) return; InvokeClient.Instance.Service.DoOperation($"{ModuleName.EfemRobot}.{EfemOperation.Grip}", "OFF", UngripSelectedBlade); } #endregion Operation } }