|  | @@ -44,6 +44,7 @@ namespace CyberX8_RT.Modules
 | 
												
													
														
															|  |          //private int _smallWafer = 0;
 |  |          //private int _smallWafer = 0;
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |          private bool _isVacuume = false;
 |  |          private bool _isVacuume = false;
 | 
												
													
														
															|  | 
 |  | +        private bool _isPause = false;
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |          public enum STATE
 |  |          public enum STATE
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
											
												
													
														
															|  | @@ -75,7 +76,9 @@ namespace CyberX8_RT.Modules
 | 
												
													
														
															|  |              ErrorPicking,
 |  |              ErrorPicking,
 | 
												
													
														
															|  |              ErrorPlacing,
 |  |              ErrorPlacing,
 | 
												
													
														
															|  |              RobotCycleing,
 |  |              RobotCycleing,
 | 
												
													
														
															|  | -            ErrorInitingAL
 |  | 
 | 
												
													
														
															|  | 
 |  | +            ErrorInitingAL,
 | 
												
													
														
															|  | 
 |  | +            Pause,
 | 
												
													
														
															|  | 
 |  | +            Resumeing
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |          public enum MSG
 |  |          public enum MSG
 | 
												
											
												
													
														
															|  | @@ -128,7 +131,9 @@ namespace CyberX8_RT.Modules
 | 
												
													
														
															|  |              WriteCarrierID,
 |  |              WriteCarrierID,
 | 
												
													
														
															|  |              ReadTagData,
 |  |              ReadTagData,
 | 
												
													
														
															|  |              WriteTagData,
 |  |              WriteTagData,
 | 
												
													
														
															|  | -            RobotCycle
 |  | 
 | 
												
													
														
															|  | 
 |  | +            RobotCycle,
 | 
												
													
														
															|  | 
 |  | +            Pause,
 | 
												
													
														
															|  | 
 |  | +            Resume
 | 
												
													
														
															|  |          
 |  |          
 | 
												
													
														
															|  |             
 |  |             
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
											
												
													
														
															|  | @@ -226,6 +231,9 @@ namespace CyberX8_RT.Modules
 | 
												
													
														
															|  |          private readonly EfemMapDummyRoutine _mapDummyRoutine;
 |  |          private readonly EfemMapDummyRoutine _mapDummyRoutine;
 | 
												
													
														
															|  |          private readonly EfemVacuumRoutine _vacuumRoutine;
 |  |          private readonly EfemVacuumRoutine _vacuumRoutine;
 | 
												
													
														
															|  |          private readonly CycleRobotCycleNewRoutine _cycleRobotCycleRoutine;
 |  |          private readonly CycleRobotCycleNewRoutine _cycleRobotCycleRoutine;
 | 
												
													
														
															|  | 
 |  | +        
 | 
												
													
														
															|  | 
 |  | +        private readonly EfemSafeOpenRoutine _efemSafeOpenRoutine;
 | 
												
													
														
															|  | 
 |  | +        private readonly EfemSafeCloseRoutine _efemSafeCloseRoutine;
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |          private string LiftMessage;
 |  |          private string LiftMessage;
 | 
												
													
														
															|  |  
 |  |  
 | 
												
											
												
													
														
															|  | @@ -267,6 +275,8 @@ namespace CyberX8_RT.Modules
 | 
												
													
														
															|  |              _vacuumRoutine = new EfemVacuumRoutine(_efem);
 |  |              _vacuumRoutine = new EfemVacuumRoutine(_efem);
 | 
												
													
														
															|  |              _cycleRobotCycleRoutine =   new CycleRobotCycleNewRoutine(_efem);
 |  |              _cycleRobotCycleRoutine =   new CycleRobotCycleNewRoutine(_efem);
 | 
												
													
														
															|  |              _autoMessageProcessor =new EfemAutoMessageProcessor(_efem);
 |  |              _autoMessageProcessor =new EfemAutoMessageProcessor(_efem);
 | 
												
													
														
															|  | 
 |  | +            _efemSafeOpenRoutine = new EfemSafeOpenRoutine(_efem);
 | 
												
													
														
															|  | 
 |  | +            _efemSafeCloseRoutine = new EfemSafeCloseRoutine(_efem);
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |          public LoadPortModule GetLoadportModule(int lpNumber)
 |  |          public LoadPortModule GetLoadportModule(int lpNumber)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
											
												
													
														
															|  | @@ -346,6 +356,9 @@ namespace CyberX8_RT.Modules
 | 
												
													
														
															|  |              //OP.Subscribe($"{ModuleName.Aligner1}.{EfemOperation.Vacuum}",    (cmd, args) => { CheckToPostMessage<STATE,MSG>(eEvent.ERR_EFEM_COMMON_FAILED,ModuleName.EFEM.ToString(),(int)MSG.Vacuum, args); return true; });            
 |  |              //OP.Subscribe($"{ModuleName.Aligner1}.{EfemOperation.Vacuum}",    (cmd, args) => { CheckToPostMessage<STATE,MSG>(eEvent.ERR_EFEM_COMMON_FAILED,ModuleName.EFEM.ToString(),(int)MSG.Vacuum, args); return true; });            
 | 
												
													
														
															|  |              OP.Subscribe($"{ModuleName.Aligner1}.{EfemOperation.Vacuum}", (cmd, args) => { return VacuumAction(args); });            
 |  |              OP.Subscribe($"{ModuleName.Aligner1}.{EfemOperation.Vacuum}", (cmd, args) => { return VacuumAction(args); });            
 | 
												
													
														
															|  |              OP.Subscribe($"{Name}.DoorUnlock", (cmd, args) => { return DoorUnlock(args); });
 |  |              OP.Subscribe($"{Name}.DoorUnlock", (cmd, args) => { return DoorUnlock(args); });
 | 
												
													
														
															|  | 
 |  | +            
 | 
												
													
														
															|  | 
 |  | +            OP.Subscribe($"{Name}.SafeOpen", (cmd, args) => { return SafeOpenAction(args); });
 | 
												
													
														
															|  | 
 |  | +            OP.Subscribe($"{Name}.SafeClose", (cmd, args) => { return SafeCloseAction(args); });
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |              DATA.Subscribe($"{Name}.FsmState", () => ((STATE)fsm.State).ToString(),SubscriptionAttribute.FLAG.IgnoreSaveDB);
 |  |              DATA.Subscribe($"{Name}.FsmState", () => ((STATE)fsm.State).ToString(),SubscriptionAttribute.FLAG.IgnoreSaveDB);
 | 
												
													
														
															|  |              DATA.Subscribe($"{Name}.FsmPrevState", () => ((STATE)fsm.PrevState).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
 |  |              DATA.Subscribe($"{Name}.FsmPrevState", () => ((STATE)fsm.PrevState).ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
 | 
												
											
												
													
														
															|  | @@ -408,7 +421,14 @@ namespace CyberX8_RT.Modules
 | 
												
													
														
															|  |              AnyStateTransition(MSG.ToInit,                  fnToInit,           STATE.Init);
 |  |              AnyStateTransition(MSG.ToInit,                  fnToInit,           STATE.Init);
 | 
												
													
														
															|  |              AnyStateTransition(MSG.BackroundCmd,            fnBackroundCommand, FSM_STATE.SAME);
 |  |              AnyStateTransition(MSG.BackroundCmd,            fnBackroundCommand, FSM_STATE.SAME);
 | 
												
													
														
															|  |              AnyStateTransition(MSG.CloseBuzzer,          fnCloseBuzzer, FSM_STATE.SAME);
 |  |              AnyStateTransition(MSG.CloseBuzzer,          fnCloseBuzzer, FSM_STATE.SAME);
 | 
												
													
														
															|  | 
 |  | +            AnyStateTransition(MSG.CloseBuzzer,          fnCloseBuzzer, FSM_STATE.SAME);
 | 
												
													
														
															|  |              
 |  |              
 | 
												
													
														
															|  | 
 |  | +            AnyStateTransition(MSG.Pause, EnterPause, STATE.Pause);
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +            //Resume
 | 
												
													
														
															|  | 
 |  | +            Transition(STATE.Pause, MSG.Resume, EnterResume, STATE.Resumeing);
 | 
												
													
														
															|  | 
 |  | +            Transition(STATE.Resumeing, FSM_MSG.TIMER, fnResumeTimeout, STATE.Init);
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  |              Transition(STATE.Unknown,MSG.CommReady, fnCommReady, STATE.Init);
 |  |              Transition(STATE.Unknown,MSG.CommReady, fnCommReady, STATE.Init);
 | 
												
													
														
															|  |              //Error
 |  |              //Error
 | 
												
													
														
															|  |              Transition(STATE.Error, MSG.Recover, fnRecover, STATE.Idle);
 |  |              Transition(STATE.Error, MSG.Recover, fnRecover, STATE.Idle);
 | 
												
											
												
													
														
															|  | @@ -475,7 +495,7 @@ namespace CyberX8_RT.Modules
 | 
												
													
														
															|  |              Transition(STATE.Idle,          MSG.Ungrip,             fnUngrip,           STATE.Ungripping);
 |  |              Transition(STATE.Idle,          MSG.Ungrip,             fnUngrip,           STATE.Ungripping);
 | 
												
													
														
															|  |              Transition(STATE.Ungripping,    MSG.ActionDone,         fnActionDone,       STATE.Idle);
 |  |              Transition(STATE.Ungripping,    MSG.ActionDone,         fnActionDone,       STATE.Idle);
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -            // Aligner
 |  | 
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |              Transition(STATE.Idle,          MSG.Lift,               fnLift,             STATE.Lifting);
 |  |              Transition(STATE.Idle,          MSG.Lift,               fnLift,             STATE.Lifting);
 | 
												
													
														
															|  |              //Transition(STATE.Lifting,       MSG.LiftActionDone,     fnActionDone,       STATE.Idle);
 |  |              //Transition(STATE.Lifting,       MSG.LiftActionDone,     fnActionDone,       STATE.Idle);
 | 
												
											
												
													
														
															|  | @@ -488,6 +508,9 @@ namespace CyberX8_RT.Modules
 | 
												
													
														
															|  |              Transition(STATE.Idle, MSG.MapDummy, MapDummy, STATE.Mapping);
 |  |              Transition(STATE.Idle, MSG.MapDummy, MapDummy, STATE.Mapping);
 | 
												
													
														
															|  |              Transition(STATE.Mapping, FSM_MSG.TIMER, MapDummyTimeout, STATE.Idle);
 |  |              Transition(STATE.Mapping, FSM_MSG.TIMER, MapDummyTimeout, STATE.Idle);
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +            //Resume
 | 
												
													
														
															|  | 
 |  | +            Transition(STATE.Idle, MSG.MapDummy, MapDummy, STATE.Mapping);
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  |              //Vacuum
 |  |              //Vacuum
 | 
												
													
														
															|  |              //Transition(STATE.Init, MSG.Vacuum, VacuumAction, STATE.Vacuuming);
 |  |              //Transition(STATE.Init, MSG.Vacuum, VacuumAction, STATE.Vacuuming);
 | 
												
													
														
															|  |              //Transition(STATE.Idle, MSG.Vacuum, VacuumAction, STATE.Vacuuming);
 |  |              //Transition(STATE.Idle, MSG.Vacuum, VacuumAction, STATE.Vacuuming);
 | 
												
											
												
													
														
															|  | @@ -526,7 +549,40 @@ namespace CyberX8_RT.Modules
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
													
														
															|  |              return _efem.CloseBuzzer();
 |  |              return _efem.CloseBuzzer();
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  | -        
 |  | 
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        /// <summary>
 | 
												
													
														
															|  | 
 |  | +        /// 
 | 
												
													
														
															|  | 
 |  | +        /// </summary>
 | 
												
													
														
															|  | 
 |  | +        /// <param name="param"></param>
 | 
												
													
														
															|  | 
 |  | +        /// <returns></returns>
 | 
												
													
														
															|  | 
 |  | +        private bool EnterPause(object[] param)
 | 
												
													
														
															|  | 
 |  | +        {
 | 
												
													
														
															|  | 
 |  | +            return true;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        private bool EnterResume(object[] param)
 | 
												
													
														
															|  | 
 |  | +        {
 | 
												
													
														
															|  | 
 |  | +            return true;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        private bool fnResumeTimeout(object[] param)
 | 
												
													
														
															|  | 
 |  | +        {
 | 
												
													
														
															|  | 
 |  | +            _currentRoutine = _efemSafeCloseRoutine;
 | 
												
													
														
															|  | 
 |  | +            RState ret = _efemSafeCloseRoutine.Monitor();
 | 
												
													
														
															|  | 
 |  | +            if (ret == RState.Failed || ret == RState.Timeout)
 | 
												
													
														
															|  | 
 |  | +            {
 | 
												
													
														
															|  | 
 |  | +                _currentRoutine = null;
 | 
												
													
														
															|  | 
 |  | +                PostMsg(MSG.Error);
 | 
												
													
														
															|  | 
 |  | +                return false;
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            bool result = ret == RState.End;
 | 
												
													
														
															|  | 
 |  | +            if (result)
 | 
												
													
														
															|  | 
 |  | +            {
 | 
												
													
														
															|  | 
 |  | +                _currentRoutine = null;
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            return result;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  |          private bool fnHomeAll(object[] param)
 |  |          private bool fnHomeAll(object[] param)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
													
														
															|  |              _isHomed = false;
 |  |              _isHomed = false;
 | 
												
											
												
													
														
															|  | @@ -642,8 +698,19 @@ namespace CyberX8_RT.Modules
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
													
														
															|  |              if (_isVacuume)
 |  |              if (_isVacuume)
 | 
												
													
														
															|  |              {
 |  |              {
 | 
												
													
														
															|  | -                VacuumActionTimeout();
 |  | 
 | 
												
													
														
															|  | -                _isVacuume = false;
 |  | 
 | 
												
													
														
															|  | 
 |  | +                bool result = VacuumActionTimeout();
 | 
												
													
														
															|  | 
 |  | +                if (result)
 | 
												
													
														
															|  | 
 |  | +                {
 | 
												
													
														
															|  | 
 |  | +                    _isVacuume = false;
 | 
												
													
														
															|  | 
 |  | +                }
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            if (_isPause)
 | 
												
													
														
															|  | 
 |  | +            {
 | 
												
													
														
															|  | 
 |  | +                bool result = SafeOpenActionTimeout();
 | 
												
													
														
															|  | 
 |  | +                if (result)
 | 
												
													
														
															|  | 
 |  | +                {
 | 
												
													
														
															|  | 
 |  | +                    _isPause = false;
 | 
												
													
														
															|  | 
 |  | +                }
 | 
												
													
														
															|  |              }
 |  |              }
 | 
												
													
														
															|  |              // robot idle check
 |  |              // robot idle check
 | 
												
													
														
															|  |              _robotIdleTrigger.CLK = _efem.Status != RState.Running;
 |  |              _robotIdleTrigger.CLK = _efem.Status != RState.Running;
 | 
												
											
												
													
														
															|  | @@ -1123,6 +1190,17 @@ namespace CyberX8_RT.Modules
 | 
												
													
														
															|  |              return ret == RState.End;
 |  |              return ret == RState.End;
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +        private bool SafeOpenActionTimeout()
 | 
												
													
														
															|  | 
 |  | +        {
 | 
												
													
														
															|  | 
 |  | +            RState ret = _efemSafeOpenRoutine.Monitor();
 | 
												
													
														
															|  | 
 |  | +            if (ret == RState.Failed || ret == RState.Timeout)
 | 
												
													
														
															|  | 
 |  | +            {
 | 
												
													
														
															|  | 
 |  | +                LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EFEM, "SafeOpen");
 | 
												
													
														
															|  | 
 |  | +                return false;
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            return ret == RState.End;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  |          private bool fnMap(object[] param)
 |  |          private bool fnMap(object[] param)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
													
														
															|  |              // module
 |  |              // module
 | 
												
											
												
													
														
															|  | @@ -1157,7 +1235,24 @@ namespace CyberX8_RT.Modules
 | 
												
													
														
															|  |              return result;
 |  |              return result;
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -        private bool DoorUnlock(object[] param)
 |  | 
 | 
												
													
														
															|  | 
 |  | +        private bool SafeOpenAction(object[] param)
 | 
												
													
														
															|  | 
 |  | +        {
 | 
												
													
														
															|  | 
 |  | +            PostMsg(MSG.Pause);
 | 
												
													
														
															|  | 
 |  | +            bool result = _efemSafeOpenRoutine.Start() == RState.Running;
 | 
												
													
														
															|  | 
 |  | +            if (result)
 | 
												
													
														
															|  | 
 |  | +            {
 | 
												
													
														
															|  | 
 |  | +                _isPause = true;
 | 
												
													
														
															|  | 
 |  | +            }
 | 
												
													
														
															|  | 
 |  | +            return result;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        private bool SafeCloseAction(object[] param)
 | 
												
													
														
															|  | 
 |  | +        {
 | 
												
													
														
															|  | 
 |  | +            CheckToPostMessage<STATE, MSG>(eEvent.ERR_EFEM_COMMON_FAILED, "EFEM", (int)MSG.Resume);
 | 
												
													
														
															|  | 
 |  | +            return _efemSafeCloseRoutine.Start() == RState.Running;
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +        public bool DoorUnlock(object[] param)
 | 
												
													
														
															|  |          {
 |  |          {
 | 
												
													
														
															|  |              bool unlock = (bool)param[0];
 |  |              bool unlock = (bool)param[0];
 | 
												
													
														
															|  |              string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{DOOR_UNLOCK}");
 |  |              string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{DOOR_UNLOCK}");
 |