using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using Aitex.Core.Common; using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.Device; using Aitex.Core.RT.Event; using Aitex.Core.RT.Fsm; using Aitex.Core.RT.OperationCenter; using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using EFEM.RT.Devices; using EFEM.RT.Routines; using EFEM.RT.Routines.LP; using EFEM.RT.Tasks; using Aitex.Sorter.Common; using EFEMSC; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.SubstrateTrackings; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot; using IEntity = Aitex.Core.RT.Fsm.IEntity; using Aitex.Sorter.RT.Module; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase; using Aitex.Core.RT.Log; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.BufferStations; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Flipper.FlipperBase; using static EFEM.RT.Devices.FlipperEntity; namespace EFEM.RT.Modules { public class RouteManager : Entity, IEntity, IModuleEntity { public enum MSG { MultiMoveWafer, MoveWafer, ReturnWafer, SetSpeed, HomeUnit, ReadID, WriteID, ReadAndLoad, LOAD, UNLOAD, Pause, Resume, Stop, StartCycle, Init, HOME, RESET, ABORT, ERROR, StartRecipe, StopRecipe, PauseRecipe, ResumeRecipe, SetAutoMode, SetManualMode, //SetLocalMode, //SetRemoteMode, SetMaintenanceMode, MapWafer, Pick, Place, MPNTPick, MPNTPlace, RobotActionDone, LoadPortActionDone, ChangeCassette } //routine private readonly bool _isInterferencePrevent = DeviceDefineManager.Instance.GetValue("InterferencePrevent") ?? false; private IEfemRoutine initRoutine = null; private SetSpeedRoutine setspeedRoutine = null; private WaferMappingRoutine _waferMapRoutine; private LoadFoupRoutine _loadFoupRoutine; private PickRoutine _pickRoutine; private PickExtendRoutine _pickExtendRoutine; private PlaceRoutine _placeRoutine; private PlaceExtendRoutine _placeExtendRoutine; private SorterCycleManager _cycle = new SorterCycleManager(); //TrigRobotSafetyToLP1 Locker //private static readonly object _robotSafetyToLP1Locker = new object(); //TrigRobotSafetyToLP2 Locker //private static readonly object _robotSafetyToLP2Locker = new object(); private int LoadPortQuantity = DeviceDefineManager.Instance.GetValue("LoadPortQuantity") ?? 0; //private int LoadLockQuantity = DeviceDefineManager.Instance.GetValue("LoadLockQuantity") ?? 0; private static readonly bool FlipperIsDisable = SC.ContainsItem("System.FlipperDisable") ? SC.GetValue("System.FlipperDisable") : true; public bool IsTransferMode { get; private set; } public bool IsAutoMode { get; private set; } public bool IsFFUOk { get; set; } public bool IsEMSStop { get; set; } public string Name { get; set; } public bool IsInit { get { return fsm.State == (int)RtState.Init; } } public bool IsIdle { get { return fsm.State == (int)RtState.Idle; } } public bool IsError { get { return fsm.State == (int)RtState.Error; } } public bool IsMaintenanceMode { get { return fsm.State == (int)RtState.Maintenance; } } public bool IsCycle { get { return fsm.State == (int)RtState.Cycle; } } public bool Initializing { get { return fsm.State == (int)RtState.Initializing; } } public bool IsRunning { get { return !IsIdle && !IsInit && !IsError && !IsMaintenanceMode; } } public int RTStatus { get { return fsm.State; } } private double lastTime = 0; private double elapsedTime = 0; public double TransferTime { get { elapsedTime = 0; if (!_timerTransfer.IsIdle()) { elapsedTime = (_timerTransfer.GetElapseTime() / 1000); } return lastTime + elapsedTime; } } private static LoadPortEntity _lp1 = new LoadPortEntity(ModuleName.LP1.ToString()); private static LoadPortEntity _lp2 = new LoadPortEntity(ModuleName.LP2.ToString()); private static LoadPortEntity _lp3 = new LoadPortEntity(ModuleName.LP3.ToString()); private static LoadPortEntity _lp4 = new LoadPortEntity(ModuleName.LP4.ToString()); private static LoadPortEntity _lp5 = new LoadPortEntity(ModuleName.LP5.ToString()); private static LoadPortEntity _lp6 = new LoadPortEntity(ModuleName.LP6.ToString()); private static LoadPortEntity _lp7 = new LoadPortEntity(ModuleName.LP7.ToString()); private static LoadPortEntity _lp8 = new LoadPortEntity(ModuleName.LP8.ToString()); private static LoadPortEntity _lp9 = new LoadPortEntity(ModuleName.LP9.ToString()); private static LoadPortEntity _lp10 = new LoadPortEntity(ModuleName.LP10.ToString()); private static FlipperEntity _flp = new FlipperEntity(ModuleName.Flipper); private LoadPortEntity[] _loadportEntities = { _lp1, _lp2, _lp3, _lp4, _lp5, _lp6, _lp7, _lp8, _lp9, _lp10 }; public bool IsBusy { get { return !IsInit && !IsError && !IsIdle; } } public bool IsOnline { get; set; } private DeviceTimer _timerTransfer = new DeviceTimer(); private TransferManager _transferManager = new TransferManager(); private StaticTransfer _staticTransfer = new StaticTransfer(); private IMoveManager _mover = null; private DualArmMoveManager _dualMover = new DualArmMoveManager(); private SingleArmMoveManager _singleMover = new SingleArmMoveManager(); private RobotBaseDevice _robot = null; public bool ClearEventLogEnable; public Result GetTaskState(string task) { if (_taskState.ContainsKey(task)) return _taskState[task]; return Result.DONE; } public string EFemNum { get { if(SC.ContainsItem("System.EFEMNUM")) return SC.GetStringValue("System.EFEMNUM"); return "001"; } } public string DeviceType { get { if (SC.ContainsItem("System.DeviceType")) return SC.GetStringValue("System.DeviceType").Remove(0, 6); return "001"; } } Dictionary _taskState = new Dictionary(); #region Module Insatlled public bool IsLP1Disable { get; set; } public bool IsLP2Disable { get; set; } public bool IsAligner1Disable { get; set; } public bool IsAligner2Disable { get; set; } public bool IsPMADisable { get; set; } public bool IsPMBDisable { get; set; } public bool IsBufferDisable { get; set; } public bool IsBuffer1Disable { get; set; } public bool IsBuffer2Disable { get; set; } public bool IsCoolingBuffer1Disable { get; set; } public bool IsCoolingBuffer2Disable { get; set; } public bool IsFlipperDisable { get; set; } #endregion #region Flipper /// /// Flipper Entity /// public FlipperEntity FLPEntity => _flp; #endregion public RouteManager() { Name = "System"; switch(EFemNum) { case "001": { DeviceModel.SensorPMASystemInterlock.OnSignalChanged += SensorPMASystemInterlock_OnSignalChanged; DeviceModel.SensorPMBSystemInterlock.OnSignalChanged += SensorPMBSystemInterlock_OnSignalChanged; DeviceModel.SensorRBNotExtendSIMF1.OnSignalChanged += SensorRBNotExtendSIMF1_OnSignalChanged; DeviceModel.SensorRBNotExtendSIMF2.OnSignalChanged += SensorRBNotExtendSIMF2_OnSignalChanged; DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += SensorSMIF1PODOPEN_OnSignalChanged; DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += SensorSMIF2PODOPEN_OnSignalChanged; DeviceModel.SensorWaterLeakSW.OnSignalChanged += SensorWaterLeakSW_OnSignalChanged; DeviceModel.SensorGratingSensorIN1.OnSignalChanged += SensorGratingSensorIN1_OnSignalChanged; } break; case "002": { DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += SensorSMIF1PODOPEN_OnSignalChanged; DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += SensorSMIF2PODOPEN_OnSignalChanged; DeviceModel.SensorWaterLeakSW.OnSignalChanged += SensorWaterLeakSW_OnSignalChanged; DeviceModel.SensorGratingSensorIN1.OnSignalChanged += SensorGratingSensorIN1_OnSignalChanged; } break; case "003": { DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += SensorSMIF1PODOPEN_OnSignalChanged; DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += SensorSMIF2PODOPEN_OnSignalChanged; DeviceModel.SensorWaterLeakSW.OnSignalChanged += SensorWaterLeakSW_OnSignalChanged; DeviceModel.SensorGratingSensorIN1.OnSignalChanged += SensorGratingSensorIN1_OnSignalChanged; } break; case "004": { DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += SensorSMIF1PODOPEN_OnSignalChanged; DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += SensorSMIF2PODOPEN_OnSignalChanged; DeviceModel.SensorWaterLeakSW.OnSignalChanged += SensorWaterLeakSW_OnSignalChanged; DeviceModel.SensorGratingSensorIN1.OnSignalChanged += SensorGratingSensorIN1_OnSignalChanged; } break; case "005": { DeviceModel.SensorWaterLeakSW.OnSignalChanged += SensorWaterLeakSW_OnSignalChanged; DeviceModel.SensorCDAPressureSW.OnSignalChanged += SensorCDAPressureSW_OnSignalChanged; ///DeviceModel.SensorRBNotExtendSIMF1.OnSignalChanged += SensorRBNotExtendSIMF1_OnSignalChanged1; } break; case "006": { ; } break; default: { DeviceModel.SensorPMASystemInterlock.OnSignalChanged += SensorPMASystemInterlock_OnSignalChanged; DeviceModel.SensorPMBSystemInterlock.OnSignalChanged += SensorPMBSystemInterlock_OnSignalChanged; DeviceModel.SensorRBNotExtendSIMF1.OnSignalChanged += SensorRBNotExtendSIMF1_OnSignalChanged; DeviceModel.SensorRBNotExtendSIMF2.OnSignalChanged += SensorRBNotExtendSIMF2_OnSignalChanged; DeviceModel.SensorSMIF1PODOPEN.OnSignalChanged += SensorSMIF1PODOPEN_OnSignalChanged; DeviceModel.SensorSMIF2PODOPEN.OnSignalChanged += SensorSMIF2PODOPEN_OnSignalChanged; DeviceModel.SensorWaterLeakSW.OnSignalChanged += SensorWaterLeakSW_OnSignalChanged; DeviceModel.SensorGratingSensorIN1.OnSignalChanged += SensorGratingSensorIN1_OnSignalChanged; } break; } Singleton.Instance.OnAlarmEvent += Instance_OnAlarmEvent; InitRouterManager(); } private void SensorRBNotExtendSIMF1_OnSignalChanged1(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2) { if (arg2) DeviceModel.TrigSafetytoSMIF1.SetTrigger(true, out _); else DeviceModel.TrigSafetytoSMIF1.SetTrigger(false, out _); } private void SensorCDAPressureSW_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2) { if (arg2) DeviceModel.TrigCDAPressureOkToPM.SetTrigger(true,out _); else DeviceModel.TrigCDAPressureOkToPM.SetTrigger(false, out _); } private void Instance_OnAlarmEvent(EventItem obj) { //if (obj.Level == EventLevel.Alarm && !obj.Source.StartsWith("LP")) //{ // if (!obj.Description.Contains("Has c Error.")|| obj.Description.Contains("PLM Error")) // { // CheckToPostMsg(MSG.ERROR); // } // //if (fsm.State == (int)RtState.Cycle||fsm.State==(int)RtState.Transfer || fsm.State == (int)RtState.Picking || fsm.State == (int)RtState.Placing) // //{ // // _tazmoRobot.Stop(); // //} //} if (obj.Level == EventLevel.Alarm) { if(!CheckIsLpAlarmInfo(obj))//||!obj.Description.Contains("obj.Source.StartsWith("LP")"))!string.IsNullOrEmpty(obj.Source) && CheckToPostMsg(MSG.ERROR); } } public bool CheckIsLpAlarmInfo(EventItem obj) { try { if (string.IsNullOrEmpty(obj.Source)) { if (obj.EventEnum.Equals("UnloadFOUPFailed")) return true; else if (obj.EventEnum.Equals("LoadFOUPFailed")) return true; } else if (obj.Source.StartsWith("LP")) return true; else if (obj.Source.Contains("LoadPort")) return true; } catch(Exception ex) { LOG.Write(ex); return false; } return false; } private void SensorRBNotExtendSIMF2_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2) { if (!arg2) { DeviceModel.TrigRBbusytoSIMF2.SetTrigger(true, out _); LOG.Write("SensorRBNotExtendSIMF2 signal change,set TrigRBbusytoSIMF2 signal on."); } else { DeviceModel.TrigRBbusytoSIMF2.SetTrigger(false, out _); LOG.Write("SensorRBNotExtendSIM2 signal change,set TrigRBbusytoSIMF2 signal off."); } } private void SensorRBNotExtendSIMF1_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2) { if (!arg2) { DeviceModel.TrigRBbusytoSIMF1.SetTrigger(true, out _); LOG.Write("SensorRBNotExtendSIMF1 signal change,set TrigRBbusytoSIMF1 signal on."); } else { DeviceModel.TrigRBbusytoSIMF1.SetTrigger(false, out _); LOG.Write("SensorRBNotExtendSIMF1 signal change,set TrigRBbusytoSIMF1 signal off."); } } private void SensorGratingSensorIN1_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2) { if (!arg2) { if(fsm.State==(int)RtState.Cycle|| fsm.State == (int)RtState.Transfer || fsm.State == (int)RtState.Placing||fsm.State == (int)RtState.Picking) DeviceModel.TrigPauseResumetoRobot.SetTrigger(true, out _); } else { DeviceModel.TrigPauseResumetoRobot.SetTrigger(false, out _); } } private void SensorWaterLeakSW_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2) { if (!arg2) { if (EFemNum != "005") { if (fsm.State == (int)RtState.Cycle || fsm.State == (int)RtState.Transfer || fsm.State == (int)RtState.Placing || fsm.State == (int)RtState.Picking) DeviceModel.TrigPauseResumetoRobot.SetTrigger(true, out _); } else { DeviceModel.TrigWaterLeakOkToPM.SetTrigger(false, out _); } } else { if (EFemNum != "005") { DeviceModel.TrigPauseResumetoRobot.SetTrigger(false, out _); } else { DeviceModel.TrigWaterLeakOkToPM.SetTrigger(true, out _); } } } private void SensorSMIF2PODOPEN_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2) { if (arg2) { DeviceModel.TrigSafetytoSMIF2.SetTrigger(true, out _); LOG.Write("SensorSMIF2PODOPEN signal change,set TrigSafetytoSMIF2 signal on."); } else { DeviceModel.TrigSafetytoSMIF2.SetTrigger(false, out _); LOG.Write("SensorSMIF2PODOPEN signal change,set TrigSafetytoSMIF2 signal off."); } } private void SensorSMIF1PODOPEN_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2) { if (arg2) { DeviceModel.TrigSafetytoSMIF1.SetTrigger(true, out _); LOG.Write("SensorSMIF1PODOPEN signal change,set TrigSafetytoSMIF1 signal on."); } else { DeviceModel.TrigSafetytoSMIF1.SetTrigger(false, out _); LOG.Write("SensorSMIF1PODOPEN signal change,set TrigSafetytoSMIF1 signal off."); } } private void SensorPMBSystemInterlock_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2) { if (arg2) { DeviceModel.TrigSafetytoPMB.SetTrigger(true, out _); LOG.Write("SensorPMBSystemInterlock signal change,set TrigSafetytoPMB signal on."); } else { DeviceModel.TrigSafetytoPMB.SetTrigger(false, out _); LOG.Write("SensorPMBSystemInterlock signal change,set TrigSafetytoPMA signal off."); } } private void SensorPMASystemInterlock_OnSignalChanged(Aitex.Core.RT.Device.Unit.IoSensor arg1, bool arg2) { if (arg2) { DeviceModel.TrigSafetytoPMA.SetTrigger(true, out _); LOG.Write("SensorPMASystemInterlock signal change,set TrigSafetytoPMB signal on."); } else { DeviceModel.TrigSafetytoPMA.SetTrigger(false, out _); LOG.Write("SensorPMASystemInterlock signal change,set TrigSafetytoPMB signal off."); } } public void InitRouterManager() { BuildTransitionTable(); InitModuleInstallment(); SubscribeDataVariable(); SubscribeOperation(); _robot = DEVICE.GetDevice(DeviceName.Robot); Running = false; IsAutoMode = false; } #region Initialization private void BuildTransitionTable() { fsm = new StateMachine(Name, (int)RtState.Init, 50); //Init sequence Transition(RtState.Init, MSG.Init, null, RtState.Idle); //Init sequence Transition(RtState.Init, MSG.HOME, fStartInit, RtState.Initializing); Transition(RtState.Idle, MSG.HOME, fStartInit, RtState.Initializing); Transition(RtState.Error, MSG.HOME, fStartInit, RtState.Initializing); // EnterExitTransition(RtState.Initializing, fStartInit, FSM_MSG.NONE, null); Transition(RtState.Initializing, FSM_MSG.TIMER, fInit, RtState.Idle); Transition(RtState.Initializing, MSG.ERROR, fError, RtState.Error); Transition(RtState.Initializing, MSG.ABORT, null, RtState.Init); EnterExitTransition(RtState.Idle, fIdle, FSM_MSG.NONE, null); //Reset AnyStateTransition(MSG.RESET, fStartReset, RtState.Idle); AnyStateTransition(MSG.ERROR, fError, RtState.Error); AnyStateTransition((int)FSM_MSG.ALARM, fError, (int)RtState.Error); //MaintanceMode Transition(RtState.Maintenance, MSG.SetManualMode, null, RtState.Idle); AnyStateTransition(MSG.SetMaintenanceMode, fSetMaintenanceMode, RtState.Maintenance); //Auto/manual sequence Transition(RtState.Idle, MSG.SetAutoMode, fSetAutoMode, RtState.Idle); Transition(RtState.Idle, MSG.SetManualMode, fSetManualMode, RtState.Idle); //Loadport operation Transition(RtState.Idle, MSG.LOAD, fLoad, RtState.Idle); Transition(RtState.Idle, MSG.ReadAndLoad, fReadAndLoad, RtState.Idle); Transition(RtState.Idle, MSG.UNLOAD, fUnload, RtState.Idle); Transition(RtState.Idle, MSG.ReadID, fReadID, RtState.Idle); Transition(RtState.Idle, MSG.WriteID, fWriteID, RtState.Idle); //SetSpeed Transition(RtState.Idle, MSG.SetSpeed, fStartSetSpeed, RtState.SetSpeed); Transition(RtState.SetSpeed, FSM_MSG.TIMER, fSetSpeed, RtState.Idle); //Wafer Map Routine Transition(RtState.Init, MSG.MapWafer, FsmStartMapWafer, RtState.WaferMapping); Transition(RtState.Idle, MSG.MapWafer, FsmStartMapWafer, RtState.WaferMapping); Transition(RtState.WaferMapping, FSM_MSG.TIMER, FsmMonitorWaferMapping, RtState.Idle); Transition(RtState.WaferMapping, MSG.ChangeCassette, FsmChangeCassette, RtState.Error); //Transfer sequence Transition(RtState.Idle, MSG.MoveWafer, fStartTransfer, RtState.Transfer); Transition(RtState.Transfer, FSM_MSG.TIMER, fTransfer, RtState.Idle); Transition(RtState.Transfer, MSG.ABORT, fAbortTransfer, RtState.Idle); EnterExitTransition(RtState.Transfer, null, FSM_MSG.NONE, fExitTransfer); //Return sequence Transition(RtState.Idle, MSG.ReturnWafer, fStartReturn, RtState.Transfer); Transition(RtState.Transfer, FSM_MSG.TIMER, fTransfer, RtState.Idle); Transition(RtState.Transfer, MSG.ChangeCassette, FsmChangeCassette, RtState.Error); //Cycle sequence Transition(RtState.Idle, MSG.StartCycle, fStartCycle, RtState.Cycle); Transition(RtState.Cycle, FSM_MSG.TIMER, fCycle, RtState.Idle); Transition(RtState.Cycle, MSG.Stop, fCycleStop, RtState.Cycle); EnterExitTransition(RtState.Cycle, FsmEnterCycle, FSM_MSG.NONE, FsmExitCycle); Transition(RtState.Cycle, MSG.ABORT, fAbortRunProcess, RtState.Idle); Transition(RtState.Cycle, MSG.ChangeCassette, FsmChangeCassette, RtState.Error); Transition(RtState.Cycle, MSG.RobotActionDone, fCycle, RtState.Cycle); //robot pick Transition(RtState.Idle, MSG.Pick, FsmStartRobotPick, RtState.Picking); Transition(RtState.Picking, FSM_MSG.TIMER, FsmMonitorPick, RtState.Idle); Transition(RtState.Picking, MSG.ABORT, FsmAbortTask, RtState.Idle); Transition(RtState.Picking, MSG.ChangeCassette, FsmChangeCassette, RtState.Error); //robot place Transition(RtState.Idle, MSG.Place, FsmStartRobotPlace, RtState.Placing); Transition(RtState.Placing, FSM_MSG.TIMER, FsmMonitorPlace, RtState.Idle); Transition(RtState.Placing, MSG.ABORT, FsmAbortTask, RtState.Idle); Transition(RtState.Placing, MSG.ChangeCassette, FsmChangeCassette, RtState.Error); //robot mpnt pick Transition(RtState.Idle, MSG.MPNTPick, FsmStartRobotMpntPick, RtState.PickingPM); Transition(RtState.PickingPM, FSM_MSG.TIMER, FsmMonitorMpntPick, RtState.Idle); Transition(RtState.PickingPM, MSG.ABORT, FsmAbortTask, RtState.Idle); //robot mpnt place Transition(RtState.Idle, MSG.MPNTPlace, FsmStartRobotMpntPlace, RtState.PlacingPM); Transition(RtState.PlacingPM, FSM_MSG.TIMER, FsmMonitorMpntPlace, RtState.Idle); Transition(RtState.PlacingPM, MSG.ABORT, FsmAbortTask, RtState.Idle); } void InitModuleInstallment() { IsBufferDisable = SC.ContainsItem("System.BufferDisable") ? SC.GetValue("System.BufferDisable") : true; IsBuffer1Disable = SC.ContainsItem("System.Buffer1Disable") ? SC.GetValue("System.Buffer1Disable") : true; IsBuffer2Disable = SC.ContainsItem("System.Buffer2Disable") ? SC.GetValue("System.Buffer2Disable") : true; IsAligner1Disable = SC.ContainsItem("System.Aligner1Disable") ? SC.GetValue("System.Aligner1Disable") : true; IsAligner2Disable = SC.ContainsItem("System.Aligner2Disable") ? SC.GetValue("System.Aligner2Disable") : true; IsPMADisable = SC.ContainsItem("System.PMADisable") ? SC.GetValue("System.PMADisable") : true; IsPMBDisable = SC.ContainsItem("System.PMBDisable") ? SC.GetValue("System.PMBDisable") : true; IsCoolingBuffer1Disable = SC.ContainsItem("System.CoolingBuffer1Disable") ? SC.GetValue("System.CoolingBuffer1Disable") : true; IsCoolingBuffer2Disable = SC.ContainsItem("System.CoolingBuffer2Disable") ? SC.GetValue("System.CoolingBuffer2Disable") : true; IsLP1Disable = SC.ContainsItem("LoadPort.LP1.Disable") ? SC.GetValue("LoadPort.LP1.Disable") : true; IsLP2Disable = SC.ContainsItem("LoadPort.LP2.Disable") ? SC.GetValue("LoadPort.LP2.Disable") : true; IsFlipperDisable = SC.ContainsItem("System.FlipperDisable") ? SC.GetValue("System.FlipperDisable") : true; } void SubscribeDataVariable() { //Parameter Register DATA.Subscribe(ModuleName.System.ToString(), ParamName.RTStatus, () => fsm.State); DATA.Subscribe(ModuleName.System.ToString(), ParamName.SystemIdle, () => IsIdle || IsInit); DATA.Subscribe(ModuleName.System.ToString(), ParamName.SystemRunning, () => IsRunning); DATA.Subscribe(ModuleName.System.ToString(), ParamName.SystemAlarm, () => IsError); DATA.Subscribe(ModuleName.System.ToString(), ParamName.IsProcessPaused, () => _mover != null && _mover.IsPaused); DATA.Subscribe(ModuleName.System.ToString(), ParamName.FFUOk, () => IsFFUOk); // DATA.Subscribe(ModuleName.System.ToString(), ParamName.TransferCount, () => TransferCount); // DATA.Subscribe(ModuleName.System.ToString(), ParamName.TransferTime, () => TransferTime); // DATA.Subscribe(ModuleName.System.ToString(), ParamName.TranserThroughput, () => TranserThroughput); // DATA.Subscribe(ModuleName.System.ToString(), ParamName.TotalWaferCount, () => SC.GetValue(SorterCommon.ScPathName.System_TotalWaferCount)); DATA.Subscribe(string.Format("{0}.{1}", ChamberSetString.System, ParamName.AlarmEvent), EV.GetAlarmEvent); // DATA.Subscribe(ModuleName.System.ToString(), ParamName.CycleCount, () => CycleCount); DATA.Subscribe(ParamName.System.IsAlarm, () => IsError); DATA.Subscribe(ParamName.System.IsManualMode, () => !IsAutoMode); DATA.Subscribe(ParamName.System.IsAutoMode, () => IsAutoMode); DATA.Subscribe(ParamName.System.IsMaintenanceMode, () => IsMaintenanceMode); DATA.Subscribe(ParamName.System.IsRunning, () => IsRunning); DATA.Subscribe(ParamName.System.IsIdle, () => IsIdle); DATA.Subscribe("System.IsNoRunning", () => !IsRunning); DATA.Subscribe("System.CoolingBuffer1Disable",()=>SC.GetValue("System.CoolingBuffer1Disable")); DATA.Subscribe("System.CoolingBuffer2Disable", () => SC.GetValue("System.CoolingBuffer2Disable")); DATA.Subscribe("System.Aligner1Disable", () => SC.GetValue("System.Aligner1Disable")); DATA.Subscribe("System.Aligner2Disable", () => SC.GetValue("System.Aligner2Disable")); DATA.Subscribe("LP1.WaferThickness", () => SC.GetStringValue("CarrierInfo.LP1ThicknessType")); DATA.Subscribe("LP2.WaferThickness", () => SC.GetStringValue("CarrierInfo.LP2ThicknessType")); DATA.Subscribe("Cooling1.WaferThickness", () => SC.GetStringValue("CarrierInfo.CoolingBuffer1ThicknessType")); DATA.Subscribe("Cooling2.WaferThickness", () => SC.GetStringValue("CarrierInfo.CoolingBuffer2ThicknessType")); DATA.Subscribe("LL1.WaferThickness", () => SC.GetStringValue("CarrierInfo.LL1ThicknessType")); DATA.Subscribe("LL2.WaferThickness", () => SC.GetStringValue("CarrierInfo.LL2ThicknessType")); DATA.Subscribe("Buffer1.WaferThickness", () => SC.GetStringValue("CarrierInfo.Buffer1ThicknessType")); DATA.Subscribe("Buffer2.WaferThickness", () => SC.GetStringValue("CarrierInfo.Buffer2ThicknessType")); DATA.Subscribe("Aligner1.WaferThickness", () => SC.GetStringValue("CarrierInfo.Aligner1ThicknessType")); DATA.Subscribe("Aligner2.WaferThickness", () => SC.GetStringValue("CarrierInfo.Aligner2ThicknessType")); DATA.Subscribe("Upper.WaferThickness", () => SC.GetStringValue("CarrierInfo.UpperThicknessType")); DATA.Subscribe("Lower.WaferThickness", () => SC.GetStringValue("CarrierInfo.LowerThicknessType")); DATA.Subscribe($"System.IsEnableBufferMap", () => SC.GetValue("System.IsEnableBufferMap")); DATA.Subscribe("System.IsEnableIdentifyThickness", () => SC.GetValue("System.IsEnableIdentifyThickness")); DATA.Subscribe("System.IsEnableMultiWaferSize", () => SC.GetValue("System.IsEnableMultiWaferSize")); DATA.Subscribe("System.IsEnableMultiWaferSizeShow", () => SC.GetValue("System.IsEnableMultiWaferSizeShow")); DATA.Subscribe("System.IsSlotShowOpposite", () => SC.GetValue("System.IsSlotShowOpposite")); DATA.Subscribe("System.ClearEventLogEnable", () => ClearEventLogEnable); var robot = DEVICE.GetDevice(DeviceName.Robot); robot.ActionDone += Robot_ActionDone; //foreach (var moduleName in Singleton.Instance.LpNames) //{ // LoadPort lp = DEVICE.GetDevice(moduleName.ToString()); // lp.ActionDone += Lp_ActionDone; //} DATA.Subscribe("LP1.IsEnable", () => !IsLP1Disable); DATA.Subscribe("LP2.IsEnable", () => !IsLP2Disable); DATA.Subscribe("Aligner1.IsEnable", () => !IsAligner1Disable); DATA.Subscribe("Aligner2.IsEnable", () => !IsAligner2Disable); DATA.Subscribe("Buffer.IsEnable", () => !IsBufferDisable); DATA.Subscribe("Buffer1.IsEnable", () => !IsBuffer1Disable); DATA.Subscribe("Buffer2.IsEnable", () => !IsBuffer2Disable); DATA.Subscribe("CoolingBuffer1.IsEnable", () => !IsCoolingBuffer1Disable); DATA.Subscribe("CoolingBuffer2.IsEnable", () => !IsCoolingBuffer2Disable); DATA.Subscribe("PMA.IsEnable", () => !IsPMADisable); DATA.Subscribe("PMB.IsEnable", () => !IsPMBDisable); DATA.Subscribe("Flipper.IsEnable", () => !IsFlipperDisable); DATA.Subscribe("System.IsPMADoorOpen", () => DeviceModel.SensorPMASystemInterlock.Value); DATA.Subscribe("System.IsPMBDoorOpen", () => DeviceModel.SensorPMBSystemInterlock.Value); } private void Lp_ActionDone(bool obj) { if (fsm.State == (int)RtState.Cycle) { EV.PostInfoLog("System", "Notified LoadPort action done"); CheckToPostMsg(MSG.LoadPortActionDone); } } private void Robot_ActionDone(bool obj) { if (fsm.State == (int) RtState.Cycle) { EV.PostInfoLog("System", "Notified robot action done"); CheckToPostMsg(MSG.RobotActionDone); } if (obj == false && (fsm.State == (int) RtState.Picking || fsm.State == (int) RtState.Placing)) { CheckToPostMsg(MSG.ERROR); } } void SubscribeOperation() { OP.Subscribe(OperationName.CreatWafer, InvokeCreateWafer); OP.Subscribe(OperationName.DeleteWafer, InvokeDeleteWafer); OP.Subscribe(OperationName.ResetRouteManager, InvokeResetRouteManager); //OP.Subscribe(OperationName.SetSpeed, InvokeSetSpeed); OP.Subscribe(OperationName.HomeUnit, InvokeHomeUnit); OP.Subscribe(OperationName.LoadFoup, InvokeLoadFoup); OP.Subscribe(OperationName.UnloadFoup, InvokeUnloadFoup); OP.Subscribe(OperationName.ReadFoupID, InvokeReadFoupID); OP.Subscribe(OperationName.WriteFoupID, InvokeWriteFoupID); OP.Subscribe(OperationName.MoveWafer, InvokeMoveWafer); OP.Subscribe(OperationName.ReturnWafer, InvokeReturnWafer); OP.Subscribe(OperationName.MultiMoveWafer, InvokeMultiMoveWafer); OP.Subscribe(OperationName.Stop, InvokeStop); OP.Subscribe("Benchmark", InvokeBenchmark); OP.Subscribe("System.StartCycle", InvokeCycle); OP.Subscribe(OperationName.SetAutoMode, InvokeSetAutoMode); OP.Subscribe(OperationName.SetManualMode, InvokeSetManualMode); OP.Subscribe(OperationName.HomeAll, InvokeHomeAll); OP.Subscribe(OperationName.AbortHomeAll, InvokeAbortHomeAll); OP.Subscribe(OperationName.SelectRecipe, InvokeSelectRecipe); OP.Subscribe(OperationName.StartRecipe, (string cmd, object[] args) => { if (args.Length > 1) { return CheckToPostMsg(MSG.StartRecipe, args[0], args[1]); } return CheckToPostMsg(MSG.StartRecipe, args[0]); }); OP.Subscribe(OperationName.PauseRecipe, InvokePauseRecipe); OP.Subscribe(OperationName.ResumeRecipe, InvokeResumeRecipe); OP.Subscribe(OperationName.StopRecipe, InvokeStopRecipe); OP.Subscribe("MapWafer", InvokeMapWafer); OP.Subscribe(ParamName.System.OPName.Reset, (string cmd, object[] args) => { EV.ClearAlarmEvent(); Singleton.Instance.PostMsg(DeviceEntity.MSG.RESET); Singleton.Instance.PostMsg(EfemEntity.MSG.Reset); return CheckToPostMsg(MSG.RESET); }); OP.Subscribe("System.SetWaferSize3", (string cmd, object[] args) => { string module = (string)args[0]; if (module == "Lower") { WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 0, WaferSize.WS3); return true; } if (module == "Upper") { WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 1, WaferSize.WS3); return true; } if (ModuleHelper.IsBuffer(ModuleHelper.Converter(module))) { var buffer = DEVICE.GetDevice(module); if (buffer != null) { for (int i = 0; i < buffer.ValidSlotsNumber; i++) { WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), i, WaferSize.WS3); } } SC.SetItemValue($"System.{module}WaferSize", 3); return true; } WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS3); //string module = (string) args[0]; //WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS3); //if (ModuleHelper.Converter(module) == ModuleName.Robot) //{ // WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 1, WaferSize.WS3); //} return true; }); OP.Subscribe("System.SetWaferSize4", (string cmd, object[] args) => { string module = (string)args[0]; if (module == "Lower") { WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 0, WaferSize.WS4); return true; } if (module == "Upper") { WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 1, WaferSize.WS4); return true; } if(ModuleHelper.IsBuffer(ModuleHelper.Converter(module))) { var buffer = DEVICE.GetDevice(module); if (buffer != null) { for (int i=0;i { string module = (string)args[0]; if (module == "Lower") { WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 0, WaferSize.WS6); return true; } if (module == "Upper") { WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 1, WaferSize.WS6); return true; } if (ModuleHelper.IsBuffer(ModuleHelper.Converter(module))) { var buffer = DEVICE.GetDevice(module); if (buffer != null) { for (int i = 0; i < buffer.ValidSlotsNumber; i++) { WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), i, WaferSize.WS6); } } SC.SetItemValue($"System.{module}WaferSize", 6); return true; } WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS6); //string module = (string)args[0]; //WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS6); //if (ModuleHelper.Converter(module) == ModuleName.Robot) //{ // WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 1, WaferSize.WS6); //} return true; }); OP.Subscribe("System.SetWaferSize8", (string cmd, object[] args) => { string module = (string)args[0]; if (module == "Lower") { WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 0, WaferSize.WS8); return true; } if (module == "Upper") { WaferManager.Instance.UpdateWaferSize(ModuleName.Robot, 1, WaferSize.WS8); return true; } if (ModuleHelper.IsBuffer(ModuleHelper.Converter(module))) { var buffer = DEVICE.GetDevice(module); if (buffer != null) { for (int i = 0; i < buffer.ValidSlotsNumber; i++) { WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), i, WaferSize.WS8); } } return true; SC.SetItemValue($"System.{module}WaferSize", 8); } WaferManager.Instance.UpdateWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS8); //string module = (string)args[0]; //WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 0, WaferSize.WS6); //if (ModuleHelper.Converter(module) == ModuleName.Robot) //{ // WaferManager.Instance.CheckWaferSize(ModuleHelper.Converter(module), 1, WaferSize.WS6); //} return true; }); OP.Subscribe("System.SetWaferThick", (string cmd, object[] args) => { string module = (string)args[0]; SC.SetItemValueFromString($"CarrierInfo.{module}ThicknessType", "THICK"); return true; }); OP.Subscribe("System.SetWaferThin", (string cmd, object[] args) => { string module = (string)args[0]; SC.SetItemValueFromString($"CarrierInfo.{module}ThicknessType", "THIN"); return true; }); OP.Subscribe("System.SetSlot13", (string cmd, object[] args) => { string module = (string)args[0]; //SC.SetItemValue($"CarrierInfo.Carrier0.CarrierSlotsNumber", 13); SC.SetItemValue($"LoadPort.{module}.SlotsNumber", 13); return true; }); OP.Subscribe("System.SetSlot25", (string cmd, object[] args) => { string module = (string)args[0]; // SC.SetItemValue($"CarrierInfo.Carrier0.CarrierSlotsNumber", 25); SC.SetItemValue($"LoadPort.{module}.SlotsNumber", 25); return true; }); OP.Subscribe("System.ClearEventLogEnable", (string cmd, object[] args) => { ClearEventLogEnable = false; return true; }); } private bool InvokeMapWafer(string arg1, object[] arg2) { return CheckToPostMsg(MSG.MapWafer, arg2[0].ToString()); } private bool InvokeStopRecipe(string arg1, object[] arg2) { return CheckToPostMsg(MSG.StopRecipe); } private bool InvokeResumeRecipe(string arg1, object[] arg2) { //ret = PostMsg(RouteManager.MSG.ResumeRecipe, out reason); return true; } private bool InvokePauseRecipe(string arg1, object[] arg2) { //ret = PostMsg(RouteManager.MSG.PauseRecipe, out reason); return true; } private bool InvokeSelectRecipe(string arg1, object[] arg2) { //JobManager.Instance.SelectRecipe(arg2[0].ToString()); //ret = true; return true; } private bool InvokeAbortHomeAll(string arg1, object[] arg2) { return CheckToPostMsg(MSG.ABORT); } private bool InvokeHomeAll(string arg1, object[] arg2) { return CheckToPostMsg(MSG.HOME); } private bool InvokeSetManualMode(string arg1, object[] arg2) { return CheckToPostMsg(MSG.SetManualMode); } private bool InvokeSetAutoMode(string arg1, object[] arg2) { if (!CheckEnableAuto()) { return false; } return CheckToPostMsg(MSG.SetAutoMode); ; } private bool InvokeCycle(string arg1, object[] arg2) { string reason; if (!checkCycle(out reason)) { EV.PostWarningLog("System", $"Can not start cycle, {reason}"); return false; } return CheckToPostMsg(MSG.StartCycle, arg2[0], arg2[1], arg2[2]); } private bool InvokeBenchmark(string arg1, object[] arg2) { string reason; if (!checkCycle(out reason)) { EV.PostWarningLog("System", $"Can not start cycle, {reason}"); return false; } return CheckToPostMsg(MSG.StartCycle, arg2[0], arg2[1], arg2[2], "Benchmark"); } private bool InvokeStop(string arg1, object[] arg2) { return CheckToPostMsg(MSG.Stop); } private bool InvokeMultiMoveWafer(string arg1, object[] arg2) { Running = false; string reason = ""; bool ret = CheckMultiMove(out reason, arg2); if (ret) { MoveType type = (MoveType)arg2[0]; MoveOption option = (MoveOption)arg2[1]; Hand blade = (Hand)arg2[2]; ModuleName schamber1 = (ModuleName)arg2[3]; int sslot1 = (int)arg2[4]; ModuleName dchamber1 = (ModuleName)arg2[5]; int dslot1 = (int)arg2[6]; ModuleName schamber2 = (ModuleName)arg2[3]; int sslot2 = (int)arg2[4]; ModuleName dchamber2 = (ModuleName)arg2[5]; int dslot2 = (int)arg2[6]; if (type != MoveType.Move) { schamber2 = (ModuleName)arg2[7]; sslot2 = (int)arg2[8]; dchamber2 = (ModuleName)arg2[9]; dslot2 = (int)arg2[10]; } _taskState[arg1] = Result.RUN; PostMsg(RouteManager.MSG.MoveWafer, type, option, blade, schamber1, sslot1, dchamber1, dslot1, schamber2, sslot2, dchamber2, dslot2 ); } else { _taskState[arg1] = Result.FAIL; return false; } return true; } private bool InvokeReturnWafer(string arg1, object[] arg2) { return CheckToPostMsg(MSG.ReturnWafer); } public bool InvokeMoveWafer(string arg1, object[] args) { Running = false; string reason = ""; bool ret = checkMove(out reason, args); if (ret) { MoveType type = (MoveType)args[0]; MoveOption option = (MoveOption)args[1]; Hand blade = (Hand)args[2]; ModuleName schamber1 = (ModuleName)args[3]; int sslot1 = (int)args[4]; ModuleName dchamber1 = (ModuleName)args[5]; int dslot1 = (int)args[6]; ModuleName schamber2 = (ModuleName)args[3]; int sslot2 = (int)args[4]; ModuleName dchamber2 = (ModuleName)args[5]; int dslot2 = (int)args[6]; if (type != MoveType.Move) { schamber2 = (ModuleName)args[7]; sslot2 = (int)args[8]; dchamber2 = (ModuleName)args[9]; dslot2 = (int)args[10]; } _taskState[arg1] = Result.RUN; PostMsg(RouteManager.MSG.MoveWafer, type, option, blade, schamber1, sslot1, dchamber1, dslot1, schamber2, sslot2, dchamber2, dslot2 ); } else { _taskState[arg1] = Result.FAIL; } return true; } private bool InvokeWriteFoupID(string arg1, object[] arg2) { //{ // ret = true; // ret = PostMsg(RouteManager.MSG.WriteID, out reason, args); //} return true; } private bool InvokeReadFoupID(string arg1, object[] arg2) { return CheckToPostMsg(MSG.ReadID, arg2[0]); } private bool InvokeUnloadFoup(string arg1, object[] arg2) { return CheckToPostMsg(MSG.UNLOAD, arg2[0]); } private bool InvokeLoadFoup(string arg1, object[] arg2) { return CheckToPostMsg(MSG.LOAD, arg2[0]); //var lp = DEVICE.GetDevice(arg2[0].ToString()); //return lp.Load(out _); } private bool InvokeHomeUnit(string arg1, object[] arg2) { var lp = DEVICE.GetDevice(arg2[0].ToString()); return lp.Unload(out _); } private bool InvokeSetSpeed(string arg1, object[] args) { int speed = 3; string reason; if (int.TryParse((string)args[0], out speed)) { if (!(speed <= 3 || speed >= 1)) { EV.PostWarningLog(ModuleName.Robot.ToString(), "Error Parameter,speed should be range in 1, 3"); } PostMsg(MSG.SetSpeed, int.Parse((string)args[0])); return true; } EV.PostWarningLog(ModuleName.Robot.ToString(), $"invalid parameters. {args[0]}"); return false; } private bool InvokeResetRouteManager(string arg1, object[] arg2) { PostMsg(MSG.RESET); return true; } private bool InvokeDeleteWafer(string arg1, object[] args) { ModuleName chamber = (ModuleName)args[0]; int slot = (int)args[1]; if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot)) { if (WaferManager.Instance.CheckHasWafer(chamber, slot)) { WaferManager.Instance.DeleteWafer(chamber, slot); EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferDelete, chamber.ToString(), slot + 1); } else { EV.PostInfoLog("System", string.Format("No wafer at {0} {1}, delete not valid", chamber.ToString(), slot + 1)); } } else { EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString())); return false; } return true; } private bool InvokeCreateWafer(string arg1, object[] args) { ModuleName chamber = (ModuleName)args[0]; int slot = (int)args[1]; WaferStatus state = (WaferStatus)args[2]; if (WaferManager.Instance.IsWaferSlotLocationValid(chamber, slot)) { if (WaferManager.Instance.CheckHasWafer(chamber, slot)) { EV.PostInfoLog("System", string.Format("{0} slot {1} already has wafer.create wafer is not valid", chamber, slot)); } else { if (ModuleHelper.IsLoadPort(chamber)) { var lp = DEVICE.GetDevice(chamber.ToString()); if (WaferManager.Instance.CreateWafer(chamber, slot, state, lp.GetCurrentWaferSize()) != null) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferCreate, chamber.ToString(), slot + 1, state.ToString()); } } else if (WaferManager.Instance.CreateWafer(chamber, slot, state, WaferSize.WS8) != null) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.WaferCreate, chamber.ToString(), slot + 1, state.ToString()); } } } else { EV.PostWarningLog("System", string.Format("Invalid position,{0},{1}", chamber.ToString(), slot.ToString())); return false; } return true; } #endregion protected override bool Init() { for (var i = 0; i < LoadPortQuantity; i++) { _loadportEntities[i].Initialize(); } if(!FlipperIsDisable) _flp.Initialize(); _cycle.Initialize(); setspeedRoutine = new SetSpeedRoutine("System", "Set Speed"); setspeedRoutine.Initalize(); initRoutine = _isInterferencePrevent ? (IEfemRoutine)new InitRoutine2Step("System", "Init") : (IEfemRoutine)new InitRoutine("System", "Init"); initRoutine.Initalize(); _waferMapRoutine = new WaferMappingRoutine(); _waferMapRoutine.Initalize(); _staticTransfer.Initialize(); _dualMover.Initialize(); _singleMover.Initialize(); _loadFoupRoutine = new LoadFoupRoutine(ModuleName.LP1.ToString(), "Load"); _loadFoupRoutine.Initalize(); _pickRoutine = new PickRoutine("System", "Pick"); _pickRoutine.Initalize(); _placeRoutine = new PlaceRoutine("System", "Place"); _placeRoutine.Initalize(); _pickExtendRoutine = new PickExtendRoutine("System", "PickExtend"); _pickExtendRoutine.Initalize(); _placeExtendRoutine = new PlaceExtendRoutine("System", "PlaceExtend"); _placeExtendRoutine.Initalize(); return true; } protected override void Term() { //_loadportA.Terminate(); //_loadportB.Terminate(); } #region Mode change private bool fSetAutoMode(object[] objs) { IsAutoMode = true; EV.PostMessage(ChamberSetString.System, EventEnum.RunningModeChanged, "AutoMode"); return true; } private bool fSetManualMode(object[] objs) { IsAutoMode = false; EV.PostMessage(ChamberSetString.System, EventEnum.RunningModeChanged, "ManualMode"); return true; } private bool fSetMaintenanceMode(object[] param) { IsAutoMode = false; EV.PostMessage(ChamberSetString.System, EventEnum.RunningModeChanged, "Maintenance"); return true; } #endregion #region Init private bool fStartInit(object[] objs) { Result ret = initRoutine.Start(objs); if (ret == Result.DONE) { return false; } else if (ret == Result.FAIL) { return false; //do noting } return true; } private bool fInit(object[] objs) { Result ret = initRoutine.Monitor(); if (ret == Result.DONE) { //state = (int)STATE.IDLE; return true; } else if (ret == Result.FAIL) { //do nothing //state = (int)STATE.ERROR; PostMsg(MSG.ERROR); return false; } return false; ; } private bool fError(object[] objs) { for (int i = 0; i < _taskState.Count; i++) { _taskState[_taskState.ElementAt(i).Key] = Result.FAIL; } return true; } private bool fIdle(object[] objs) { _taskState.Clear(); return true; } #endregion #region setspeed private bool fStartSetSpeed(object[] objs) { Result ret = setspeedRoutine.Start(objs); setspeedRoutine.Speed = (int)objs[0]; if (ret == Result.DONE) { return false; } else if (ret == Result.FAIL) { return false; //do noting } return true; } private bool fSetSpeed(object[] objs) { Result ret = setspeedRoutine.Monitor(); if (ret == Result.DONE) { //state = (int)STATE.IDLE; return true; } else if (ret == Result.FAIL) { //do nothing //state = (int)STATE.ERROR; return true; } return false; } #endregion #region Transfer private bool fStartTransfer(object[] objs) { Running = true; return _staticTransfer.Start(objs); } private bool fStartReturn(object[] objs) { return _staticTransfer.Return(objs); } private bool fTransfer(object[] objs) { return _staticTransfer.Monitor(objs); } private bool fExitTransfer(object[] objs) { _staticTransfer.Clear(); _taskState.Remove("MoveWafer"); return true; } private void ProcessFinished() { } private IMoveManager GetMoveManager(bool bAligner) { if (!_robot.Blade1Enable) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.DefaultWarning, "Robot arm1 is disable, can't execute transfer"); return null; } if (bAligner) { _singleMover.Blade = Hand.Blade1; return _singleMover; } if (_robot.Blade1Enable && _robot.Blade2Enable && SC.GetValue(SorterCommon.ScPathName.Robot_DualBlade1TransferEnable)) return _dualMover; _singleMover.Blade = Hand.Blade1; return _singleMover; } private bool fAbortTransfer(object[] objs) { return true; } private bool FsmStartRobotPick(object[] param) { Result ret = Result.DONE; if (param.Length == 3) { _pickRoutine.Source = ModuleHelper.Converter((string)param[0]); _pickRoutine.Slot = (int)param[1]; _pickRoutine.Blade = (Hand)param[2]; ret = _pickRoutine.Start(); } else { return false; } if (ret == Result.FAIL || ret == Result.DONE) return false; return ret == Result.RUN; } private bool FsmStartRobotMpntPick(object[] param) { Result ret = Result.DONE; if (param.Length == 4) { _pickExtendRoutine.Source = ModuleHelper.Converter((string)param[0]); _pickExtendRoutine.Slot = (int)param[1]; _pickExtendRoutine.Blade = (Hand)param[2]; _pickExtendRoutine.TaskEnum = (MpntTaskEnum)param[3]; ret = _pickExtendRoutine.Start(); } else { return false; } if (ret == Result.FAIL || ret == Result.DONE) return false; return ret == Result.RUN; } private bool FsmStartRobotPlace(object[] param) { Result ret = Result.DONE; if (param.Length == 3) { _placeRoutine.Station = ModuleHelper.Converter((string)param[0]); _placeRoutine.Slot = (int)param[1]; _placeRoutine.Blade = (Hand)param[2]; ret = _placeRoutine.Start(); } else { return false; } if (ret == Result.FAIL || ret == Result.DONE) return false; return ret == Result.RUN; } private bool FsmStartRobotMpntPlace(object[] param) { Result ret = Result.DONE; if (param.Length == 4) { _placeExtendRoutine.Station = ModuleHelper.Converter((string)param[0]); _placeExtendRoutine.Slot = (int)param[1]; _placeExtendRoutine.Blade = (Hand)param[2]; _placeExtendRoutine.TaskEnum = (MpntTaskEnum)param[3]; ret = _placeExtendRoutine.Start(); } else { return false; } if (ret == Result.FAIL || ret == Result.DONE) return false; return ret == Result.RUN; } private bool FsmChangeCassette(object[] param) { var lp = param[0].ToString(); switch (fsm.State) { case (int)RtState.Cycle when lp == _cycle.OriginStation.ToString() || lp == _cycle.ToStation.ToString(): _transferManager.Clear(); IsTransferMode = false; _robot.Stop(); EV.PostWarningLog("System", "Cassette changed during cycle"); return true; case (int)RtState.Transfer when lp == _staticTransfer.TargetStation.ToString() || lp == _staticTransfer.SourceStation.ToString(): _transferManager.Clear(); _staticTransfer.Clear(); IsTransferMode = false; _robot.Stop(); EV.PostWarningLog("System", "Cassette changed during transfer"); return true; case (int)RtState.WaferMapping when lp == _waferMapRoutine.Source.ToString(): _transferManager.Clear(); _staticTransfer.Clear(); IsTransferMode = false; _robot.Stop(); EV.PostWarningLog("System", "Cassette changed during wafer mapping"); return true; case (int)RtState.Picking when lp == _pickRoutine.Source.ToString(): case (int)RtState.Placing when lp == _placeRoutine.Station.ToString(): _transferManager.Clear(); IsTransferMode = false; _robot.Stop(); EV.PostWarningLog("System", "Cassette changed during transfer"); return true; default: return false; } } private bool FsmAbortTask(object[] param) { return true; } private bool FsmMonitorPick(object[] param) { Result ret = _pickRoutine.Monitor(); if (ret == Result.FAIL) { PostMsg(MSG.ERROR); return false; } return ret == Result.DONE; } private bool FsmMonitorMpntPick(object[] param) { Result ret = _pickExtendRoutine.Monitor(); if (ret == Result.FAIL) { PostMsg(MSG.ERROR); return false; } return ret == Result.DONE; } private bool FsmMonitorPlace(object[] param) { Result ret = _placeRoutine.Monitor(); if (ret == Result.FAIL) { PostMsg(MSG.ERROR); return false; } return ret == Result.DONE; } private bool FsmMonitorMpntPlace(object[] param) { Result ret = _placeExtendRoutine.Monitor(); if (ret == Result.FAIL) { PostMsg(MSG.ERROR); return false; } return ret == Result.DONE; } #endregion #region reset private bool fStartReset(object[] objs) { Singleton.Instance.EventError?.Clear(); if(DEVICE.GetDevice(ModuleName.LP1.ToString())!=null&& DEVICE.GetDevice(ModuleName.LP1.ToString()).State==DeviceState.Error) DEVICE.GetDevice(ModuleName.LP1.ToString()).CheckToPostMessage((int)LoadPortMsg.Reset, null); ; if (DEVICE.GetDevice(ModuleName.LP2.ToString()) != null && DEVICE.GetDevice(ModuleName.LP2.ToString()).State == DeviceState.Error) DEVICE.GetDevice(ModuleName.LP2.ToString()).CheckToPostMessage((int)LoadPortMsg.Reset, null); ; if (fsm.State == (int)RtState.Error) return true; return false; } #endregion #region cycle private bool bCycle = false; private bool bReturn = false; private ModuleName _cycleSource; private ModuleName _cycleTarget; private bool bMappingSource = false; private bool _bUnload = false; private MoveOption _moveOption; private bool fStartCycle(object[] objs) { if (objs.Length < 2) { EV.PostWarningLog("System", "Cycle parameter is not valid, should be 2 LP modules"); return false; } if (!Enum.TryParse((string)objs[0], out ModuleName from) || !Enum.TryParse((string)objs[1], out ModuleName to)) { EV.PostWarningLog(ChamberSetString.System, ("Cycle parameter error, please check source and destination.")); return false; } Result ret = Result.FAIL; if (objs.Length >= 3) { string[] _moveOption = (string[])objs[2]; ret = _cycle.Start(from, to, (string[])objs[2]); } if (ret == Result.FAIL) { EV.PostWarningLog(ChamberSetString.System, ("There is wafer on the passing route")); return false; } return ret == Result.RUN; } private bool fCycle(object[] objs) { Result ret = _cycle.Monitor(); if (ret == Result.DONE) return true; if (ret == Result.FAIL) { PostMsg(MSG.ERROR); return false; } return false; //continue } private bool fAbortRunProcess(object[] objs) { if (fsm.State == (int)RtState.Cycle) { bool _swapHand = false; if (SC.ContainsItem("Process.CycleSwapHand")) { _swapHand = SC.GetValue("Process.CycleSwapHand"); } if (_swapHand && ((_moveOption & MoveOption.LoadLock1) == MoveOption.LoadLock1 || (_moveOption & MoveOption.LoadLock2) == MoveOption.LoadLock2 || (_moveOption & MoveOption.LoadLock3) == MoveOption.LoadLock3 || (_moveOption & MoveOption.LoadLock4) == MoveOption.LoadLock4 || (_moveOption & MoveOption.LoadLock5) == MoveOption.LoadLock5 || (_moveOption & MoveOption.LoadLock6) == MoveOption.LoadLock6 || (_moveOption & MoveOption.LoadLock7) == MoveOption.LoadLock7 || (_moveOption & MoveOption.LoadLock8) == MoveOption.LoadLock8 || (_moveOption & MoveOption.Buffer) == MoveOption.Buffer)) { SC.SetItemValue(ScPathName.Robot_Blade1Enable, true); SC.SetItemValue(ScPathName.Robot_Blade2Enable, true); } _moveOption = MoveOption.None; } _transferManager.Clear(); IsTransferMode = false; return true; } private bool fCycleStop(object[] objs) { _cycle.Stop(); bool _swapHand = false; if (SC.ContainsItem("Process.CycleSwapHand")) { _swapHand = SC.GetValue("Process.CycleSwapHand"); } if (_swapHand && ((_moveOption & MoveOption.LoadLock1) == MoveOption.LoadLock1 || (_moveOption & MoveOption.LoadLock2) == MoveOption.LoadLock2 || (_moveOption & MoveOption.LoadLock3) == MoveOption.LoadLock3 || (_moveOption & MoveOption.LoadLock4) == MoveOption.LoadLock4 || (_moveOption & MoveOption.LoadLock5) == MoveOption.LoadLock5 || (_moveOption & MoveOption.LoadLock6) == MoveOption.LoadLock6 || (_moveOption & MoveOption.LoadLock7) == MoveOption.LoadLock7 || (_moveOption & MoveOption.LoadLock8) == MoveOption.LoadLock8 || (_moveOption & MoveOption.Buffer) == MoveOption.Buffer)) { SC.SetItemValue(ScPathName.Robot_Blade1Enable, true); SC.SetItemValue(ScPathName.Robot_Blade2Enable, true); } _moveOption = MoveOption.None; return true; } private bool FsmExitCycle(object[] param) { _cycle.Stop(); EV.PostInfoLog("System", "Stop Cycle"); bool _swapHand = false; if (SC.ContainsItem("Process.CycleSwapHand")) { _swapHand = SC.GetValue("Process.CycleSwapHand"); } if (_swapHand && ((_moveOption & MoveOption.LoadLock1) == MoveOption.LoadLock1 || (_moveOption & MoveOption.LoadLock2) == MoveOption.LoadLock2 || (_moveOption & MoveOption.LoadLock3) == MoveOption.LoadLock3 || (_moveOption & MoveOption.LoadLock4) == MoveOption.LoadLock4 || (_moveOption & MoveOption.LoadLock5) == MoveOption.LoadLock5 || (_moveOption & MoveOption.LoadLock6) == MoveOption.LoadLock6 || (_moveOption & MoveOption.LoadLock7) == MoveOption.LoadLock7 || (_moveOption & MoveOption.LoadLock8) == MoveOption.LoadLock8 || (_moveOption & MoveOption.Buffer) == MoveOption.Buffer)) { SC.SetItemValue(ScPathName.Robot_Blade1Enable, true); SC.SetItemValue(ScPathName.Robot_Blade2Enable, true); } _moveOption = MoveOption.None; return true; } private bool FsmEnterCycle(object[] param) { EV.PostInfoLog("System", "Start Cycle"); return true; } #endregion #region Loadport private bool fHome(object[] objs) { ModuleName chamber = (ModuleName)(objs[0]); Post(chamber, LoadPortEntity.MSG.HOME); return true; } private bool fLoad(object[] objs) { ModuleName chamber = (ModuleName)(objs[0]); Post(chamber, LoadPortEntity.MSG.Load); return true; } private bool fReadAndLoad(object[] objs) { ModuleName chamber = (ModuleName)(objs[0]); Post(chamber, LoadPortEntity.MSG.ReadAndLoad); return true; } private bool fUnload(object[] objs) { ModuleName chamber = (ModuleName)(objs[0]); Post(chamber, LoadPortEntity.MSG.Unload); return true; } private bool fReadID(object[] objs) { ModuleName chamber = (ModuleName)(objs[0]); Post(chamber, LoadPortEntity.MSG.ReadRFID); return true; } private bool fWriteID(object[] objs) { ModuleName chamber = (ModuleName)(objs[0]); Post(chamber, LoadPortEntity.MSG.WriteRFID); return true; } private bool Post(ModuleName chamber, LoadPortEntity.MSG msg, params object[] objs) { string pattern = "[1-9]\\d*"; Regex rgx = new Regex(pattern); var match = int.Parse(rgx.Match(chamber.ToString()).ToString()); if (match <= LoadPortQuantity) _loadportEntities[match - 1].PostMsg(msg, objs); return true; } #endregion #region validation /// /// /// /// /// /// /// public bool CheckMsg(int msg, out string reason, bool eventOutReason, params object[] args) { Running = true; if (!fsm.FindTransition(fsm.State, msg)) { reason = String.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg); if (eventOutReason) { EV.PostMessage("System", EventEnum.DefaultWarning, reason); } Running = false; return false; } if (msg == (int)MSG.StartRecipe || msg == (int)MSG.StartCycle) { if (!IsAutoMode) { reason = String.Format("can not do {0}, isn't auto mode.", msg.ToString()); if (eventOutReason) { EV.PostMessage("System", EventEnum.DefaultWarning, reason); } Running = false; return false; } } reason = ""; return true; } public bool CheckToPostMsg(MSG msg) { if (!fsm.FindTransition(fsm.State, (int)msg)) { EV.PostMessage("System", EventEnum.DefaultWarning, string.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg)); return false; } PostMsg(msg); return true; } public bool CheckToPostMsg(MSG msg, object param1) { if (!fsm.FindTransition(fsm.State, (int)msg)) { EV.PostMessage("System", EventEnum.DefaultWarning, string.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg)); return false; } PostMsg(msg, param1); return true; } public bool CheckToPostMsg(MSG msg, object param1, object param2) { if (!fsm.FindTransition(fsm.State, (int)msg)) { EV.PostMessage("System", EventEnum.DefaultWarning, string.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg)); return false; } PostMsg(msg, param1, param2); return true; } public bool CheckToPostMsg(MSG msg, object param1, object param2, object param3) { if (!fsm.FindTransition(fsm.State, (int)msg)) { EV.PostMessage("System", EventEnum.DefaultWarning, string.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg)); return false; } PostMsg(msg, param1, param2, param3); return true; } public bool CheckToPostMsg(MSG msg, object param1, object param2, object param3, object param4) { if (!fsm.FindTransition(fsm.State, (int)msg)) { EV.PostMessage("System", EventEnum.DefaultWarning, string.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg)); return false; } PostMsg(msg, param1, param2, param3, param4); return true; } private bool check(ModuleName source, int slot, ModuleName dest, int dslot, Hand blade, MoveOption option, out string reason) { reason = string.Empty; if (!checkFoup(source, out reason)) { return false; } if (!checkFoup(dest, out reason)) { return false; } if (!WaferManager.Instance.IsWaferSlotLocationValid(source, slot)) { reason = string.Format("Invalid source parameter, {0}:{1:D2}", source.ToString(), slot); return false; } if (!WaferManager.Instance.IsWaferSlotLocationValid(dest, dslot)) { reason = string.Format("Invalid destination parameter, {0}:{1:D2}", dest.ToString(), dslot); return false; } if (!WaferManager.Instance.CheckWafer(source, slot, WaferStatus.Normal)) { if (ModuleHelper.IsLoadLock(source) && Singleton.Instance.IsOnlineMode) { //online mode, CreateWafer in LoadLock WaferManager.Instance.CreateWafer(source, slot, WaferStatus.Normal); } else { reason = string.Format("Source no normal wafer, {0}:{1:D2}", source.ToString(), slot); return false; } } if (!WaferManager.Instance.CheckWafer(dest, dslot, WaferStatus.Empty)) { reason = string.Format("destination has wafer, {0}:{1:D2}", dest.ToString(), dslot); return false; } if (source != ModuleName.Robot && dest != ModuleName.Robot) { if (!WaferManager.Instance.CheckWafer(ModuleName.Robot, (int)blade, WaferStatus.Empty)) { reason = string.Format("robot has wafer on arm"); return false; } } bool bAligner = ((option & MoveOption.Align) == MoveOption.Align) || ((option & MoveOption.ReadID) == MoveOption.ReadID) || ((option & MoveOption.ReadID2) == MoveOption.ReadID2); if (bAligner) { if (source != ModuleName.Aligner && dest != ModuleName.Aligner) { if (!WaferManager.Instance.CheckWafer(ModuleName.Aligner, 0, WaferStatus.Empty)) { reason = string.Format("aligner has wafer on"); return false; } } } return true; } private bool check(ModuleName source, int slot, ModuleName dest, int dslot, out string reason) { reason = string.Empty; if (!checkFoup(source, out reason)) { return false; } if (!checkFoup(dest, out reason)) { return false; } if (!WaferManager.Instance.IsWaferSlotLocationValid(source, slot)) { reason = string.Format("非法的参数。{0}:{1:D2}", source.ToString(), slot); return false; } if (!WaferManager.Instance.IsWaferSlotLocationValid(dest, dslot)) { reason = string.Format("非法的参数。{0}:{1:D2}", dest.ToString(), dslot); return false; } if (!WaferManager.Instance.CheckWafer(source, slot, WaferStatus.Normal)) { reason = string.Format("源位置没有wafer。{0}:{1:D2}", source.ToString(), slot); return false; } if (!WaferManager.Instance.CheckWafer(dest, dslot, WaferStatus.Empty)) { reason = string.Format("目标位置有wafer。{0}:{1:D2}", dest.ToString(), dslot); return false; } return true; } private bool checkCycle(out string reason, params object[] args) { reason = string.Empty; //bool isAutoMode = (bool)DATA.Poll(ModuleName.System.ToString(), ParamName.IsAutoMode); //if (!isAutoMode) //{ // reason = String.Format("can not cycle, isn't auto mode."); // return false; //} if (!WaferManager.Instance.CheckWafer(ModuleName.Robot, 0, WaferStatus.Empty)) { reason = string.Format("Upper arm has wafer"); return false; } if (!WaferManager.Instance.CheckWafer(ModuleName.Robot, 1, WaferStatus.Empty)) { reason = string.Format("Lower arm has wafer"); return false; } if (DeviceModel.SensorRBupperArmhavewafer != null && !DeviceModel.SensorRBupperArmhavewafer.Value) { reason = string.Format("Upper arm has wafer"); return false; } if (DeviceModel.SensorRBlowerArmhavewafer != null && !DeviceModel.SensorRBlowerArmhavewafer.Value) { reason = string.Format("Lower arm has wafer"); return false; } return true; } private bool CheckEnableAuto() { string reason = string.Empty; DeviceState state = (DeviceState)DATA.Poll(ModuleName.Robot.ToString(), ParamName.RobotState); if (state != DeviceState.Idle) { EV.PostMessage("System", EventEnum.DefaultWarning, "can not change auto mode, Robot isn't ready."); return false; } if (!Singleton.Instance.IsAnyLPIdle()) { EV.PostMessage("System", EventEnum.DefaultWarning, "can not change auto mode, no loadport is ready."); return false; } if (!WaferManager.Instance.CheckWafer(ModuleName.Robot, 0, WaferStatus.Empty)) { EV.PostMessage("System", EventEnum.DefaultWarning, "Upper arm has wafer"); return false; } if (!WaferManager.Instance.CheckWafer(ModuleName.Robot, 1, WaferStatus.Empty)) { EV.PostMessage("System", EventEnum.DefaultWarning, "Lower arm has wafer"); return false; } if (!SC.GetValue(SorterCommon.ScPathName.System_IsSimulatorMode)) { if (!DeviceModel.SensorRBupperArmhavewafer.Value) { EV.PostMessage("System", EventEnum.DefaultWarning, "Upper arm has wafer"); return false; } if (!DeviceModel.SensorRBlowerArmhavewafer.Value) { EV.PostMessage("System", EventEnum.DefaultWarning, "Lower arm has wafer"); return false; } } return true; } private bool checkMove(out string reason, params object[] args) { MoveType type = (MoveType)args[0]; MoveOption option = (MoveOption)args[1]; Hand blade = (Hand)args[2]; ModuleName schamber1 = (ModuleName)args[3]; int sslot1 = (int)args[4]; ModuleName dchamber1 = (ModuleName)args[5]; int dslot1 = (int)args[6]; ModuleName schamber2 = (ModuleName)args[3]; int sslot2 = (int)args[4]; ModuleName dchamber2 = (ModuleName)args[5]; int dslot2 = (int)args[6]; if (type != MoveType.Move) { schamber2 = (ModuleName)args[7]; sslot2 = (int)args[8]; dchamber2 = (ModuleName)args[9]; dslot2 = (int)args[10]; } if (!check(type, blade, out reason)) { EV.PostWarningLog("System", "Can not move wafer, " + reason); return false; } if (!check(schamber1, sslot1, dchamber1, dslot1, blade, option, out reason)) { EV.PostWarningLog("System", "Can not move wafer, " + reason); return false; } if (type != MoveType.Move) { if (!check(schamber2, sslot2, dchamber2, dslot2, out reason)) { EV.PostWarningLog("System", "Can not move wafer, " + reason); return false; } } return true; } private bool CheckMultiMove(out string reason, params object[] args) { MoveType type = (MoveType)args[0]; MoveOption option = (MoveOption)args[1]; Hand blade = (Hand)args[2]; ModuleName schamber1 = (ModuleName)args[3]; int sslot1 = (int)args[4]; ModuleName dchamber1 = (ModuleName)args[5]; int dslot1 = (int)args[6]; ModuleName schamber2 = (ModuleName)args[3]; int sslot2 = (int)args[4]; ModuleName dchamber2 = (ModuleName)args[5]; int dslot2 = (int)args[6]; if (type != MoveType.Move) { schamber2 = (ModuleName)args[7]; sslot2 = (int)args[8]; dchamber2 = (ModuleName)args[9]; dslot2 = (int)args[10]; } if (!check(type, blade, out reason)) { EV.PostWarningLog("System", "Can not move wafer, " + reason); return false; } //检查双臂, *若该机器人类型为下手臂1上手臂2 if (!check(schamber1, sslot1, dchamber1, dslot1, Hand.Blade1, option, out reason)) { EV.PostWarningLog("System", "Can not move wafer, " + reason); return false; } if (!check(schamber1, sslot1 + 1, dchamber1, dslot1 + 1, Hand.Blade2, option, out reason)) { EV.PostWarningLog("System", "Can not move wafer, " + reason); return false; } if (type != MoveType.Move) { if (!check(schamber2, sslot2, dchamber2, dslot2, out reason)) { EV.PostWarningLog("System", "Can not move wafer, " + reason); return false; } } return true; } private bool check(MoveType type, Hand blade, out string reason) { reason = string.Empty; if (type != MoveType.Move && blade == Hand.Both) { reason = string.Format("非法的参数。单片传盘时,不能指定Both blade"); return false; } return true; } private bool checkFoup(ModuleName chamber, out string reason) { reason = string.Empty; if (ModuleHelper.IsLoadPort(chamber)) { LoadPortBaseDevice loadport = DEVICE.GetDevice(chamber.ToString()); if (!loadport.IsEnableTransferWafer(out reason)) { reason = string.Format("{0} isn't Ready, {1}", chamber.ToString(), reason); return false; } return true; } //reason = string.Format("Not Foup, parameter {0} is not valid.", chamber.ToString()); return true; } public bool Check(int msg, out string reason, params object[] args) { if (!fsm.FindTransition(fsm.State, msg)) { reason = String.Format("{0} is in {1} state,can not do {2}", Name, (RtState)fsm.State, (MSG)msg); return false; } if (msg == (int)MSG.StartRecipe || msg == (int)MSG.StartCycle) { if (!IsAutoMode) { reason = String.Format("can not do {0}, isn't auto mode.", msg.ToString()); return false; } } reason = ""; return true; } #endregion #region Map Wafer private bool FsmStartMapWafer(object[] param) { Running = false; Result ret = _waferMapRoutine.Start(param); if (ret == Result.DONE || (ret == Result.FAIL)) { return false; //do noting } return true; } private bool FsmMonitorWaferMapping(object[] param) { Result ret = _waferMapRoutine.Monitor(); if (ret == Result.DONE) { return true; } else if (ret == Result.FAIL) { return true; } return false; } public void MapBuffer() { var sensors = new List { false,false,false,false,false, //DeviceModel.SensorCoolingStageSLOT2WaferON.Value, //DeviceModel.SensorCoolingStageSLOT3WaferON.Value, //DeviceModel.SensorCoolingStageSLOT4WaferON.Value, //DeviceModel.SensorCoolingStageSLOT5WaferON.Value, //DeviceModel.SensorCoolingStageSLOT6WaferON.Value }; var index = 0; foreach (var sensor in sensors) { if (!sensor && WaferManager.Instance.CheckNoWafer(ModuleName.Buffer, index)) { WaferManager.Instance.CreateWafer(ModuleName.Buffer, index, WaferStatus.Normal); } else if (sensor && WaferManager.Instance.CheckHasWafer(ModuleName.Buffer, index)) { WaferManager.Instance.DeleteWafer(ModuleName.Buffer, index); } index++; } var robotSensors = new List { DeviceModel.SensorRBlowerArmhavewafer.Value, DeviceModel.SensorRBupperArmhavewafer.Value }; index = 0; foreach (var sensor in robotSensors) { if (!sensor && WaferManager.Instance.CheckNoWafer(ModuleName.Robot, index)) { WaferManager.Instance.CreateWafer(ModuleName.Robot, index, WaferStatus.Normal); } else if (sensor && WaferManager.Instance.CheckHasWafer(ModuleName.Robot, index)) { WaferManager.Instance.DeleteWafer(ModuleName.Robot, index); } index++; } } public int Invoke(string function, params object[] args) { switch (function) { case "Place": CheckToPostMsg(MSG.Place, args[0], args[1], args[2]); return (int)MSG.Place; case "Pick": CheckToPostMsg(MSG.Pick, args[0], args[1], args[2]); return (int)MSG.Pick; case "MPNTPick": CheckToPostMsg(MSG.MPNTPick, args[0], args[1], args[2], args[3]); return (int)MSG.MPNTPick; case "MPNTPlace": CheckToPostMsg(MSG.MPNTPlace, args[0], args[1], args[2], args[3]); return (int)MSG.MPNTPlace; case "Reset": CheckToPostMsg(MSG.RESET ); return (int)MSG.RESET; } return (int)FSM_MSG.NONE; } public bool CheckAcked(int msg) { return fsm.CheckExecuted(msg); } #endregion } }