Browse Source

update plating cell run recipe

chenkui 4 days ago
parent
commit
4feb3d9e24

+ 2 - 1
PunkHPX8_Core/RtState.cs

@@ -179,6 +179,7 @@ namespace PunkHPX8_Core
         Init,
         Initializing,
         Initialized,
-        Idle
+        Idle,
+        Positioning
     }
 }

+ 1 - 9
PunkHPX8_RT/Dispatch/WaferTask.cs

@@ -173,14 +173,6 @@ namespace PunkHPX8_RT.Dispatch
                 }
                 return;
             }
-            if(sequence.MaterialType==MaterialType.WaferHolder)
-            {
-                if(sequence.State==RState.End)
-                {
-                    _currentSequenceIndex++;
-                }
-                return;
-            }
             if (_currentSequenceIndex < _schedulerSequences.Count)
             {
                 if (sequence.State == RState.Init)
@@ -220,7 +212,7 @@ namespace PunkHPX8_RT.Dispatch
                 }
                 else if (sequence.State == RState.Running)
                 {
-                    bool hasMatched=!string.IsNullOrEmpty(WaferTaskManager.Instance.GetMatchWaferIdByWaferId(this.WaferId));
+                    bool hasMatched=!string.IsNullOrEmpty(WaferTaskManager.Instance.GetMatchWaferIdByWaferId(WaferId));
                     sequence.SchedulerModule.MonitorProcess(sequence,hasMatched);
                     _sequenceErrorTigger.CLK = sequence.SchedulerModule.IsError;
                     if (sequence.SchedulerModule.IsIdle)

+ 1 - 0
PunkHPX8_RT/Modules/PlatingCell/PlatingCellEntity.cs

@@ -456,6 +456,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         {
             RState state = _runRecipeRoutine.Monitor();
             _currentStepState = _runRecipeRoutine.CurrentStep;
+            LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module.ToString(), _currentStepState);
             if (state == RState.Failed || state == RState.Timeout)
             {
                 PostMsg(PlatingCellMsg.Error);

+ 16 - 8
PunkHPX8_RT/Modules/PlatingCell/PlatingCellRunRecipeRoutine.cs

@@ -67,7 +67,6 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         /// 对应reservoir entity
         /// </summary>
         private ReservoirEntity _reservoirEntity;
-
         private PlatingCellInterRinseRoutine _interRinseRoutine;
         private PlatingCellVerticalEntity _verticalEntity;
         #endregion
@@ -94,13 +93,20 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         {
             Runner.Delay(RunRecipeStep.Delay, 5000)
                 .Run(RunRecipeStep.InterRinse, () => { return _interRinseRoutine.Start() == RState.Running; })
-                .WaitWithStopCondition(RunRecipeStep.CheckInterRinse, () => CommonFunction.CheckRoutineEndState(_interRinseRoutine),
-                () => CommonFunction.CheckRoutineStopState(_interRinseRoutine))
+                .WaitWithStopCondition(RunRecipeStep.CheckInterRinse, CheckInterRinseEndStatus,
+                        () => CommonFunction.CheckRoutineStopState(_interRinseRoutine))
                 .Run(RunRecipeStep.Vertical, StartVertical)
                 .WaitWithStopCondition(RunRecipeStep.CheckVertical, CheckVerticalEnd, CheckVerticalError)
                 .End(RunRecipeStep.End, NullFun);
             return Runner.Status;
         }
+
+        private bool CheckInterRinseEndStatus()
+        {
+            bool result = CommonFunction.CheckRoutineEndState(_interRinseRoutine);
+            SubRoutineStep = _interRinseRoutine.CurrentStep;
+            return result;
+        }
         /// <summary>
         /// 垂直电机运行(仅示例只做参考)
         /// </summary>
@@ -111,6 +117,8 @@ namespace PunkHPX8_RT.Modules.PlatingCell
             return _verticalEntity.CheckToPostMessage<PlatingCellVerticalState, PlatingCellVerticalEntity.VerticalMsg>(Aitex.Core.RT.Log.eEvent.INFO_PLATINGCELL,
                 Module, (int)PlatingCellVerticalEntity.VerticalMsg.Position, position);
         }
+
+
         /// <summary>
         /// 检验垂直电机是否运动完成
         /// </summary>
@@ -181,11 +189,11 @@ namespace PunkHPX8_RT.Modules.PlatingCell
                 return false;
             }
 
-            if (_recipe.DepSteps.Count == 0)
-            {
-                LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Recipe DepSteps count is 0");
-                return false;
-            }
+            //if (_recipe.DepSteps.Count == 0)
+            //{
+            //    LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Recipe DepSteps count is 0");
+            //    return false;
+            //}
             CheckAxisHome();
             CheckFacility();
             CheckModuleAndReservoir();

+ 59 - 1
PunkHPX8_RT/Modules/PlatingCell/PlatingCellVerticalEntity.cs

@@ -34,6 +34,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
 
         #region 内部变量
         private PlatingCellVerticalInitializeRoutine _initializeRoutine;
+        private PlatingCellVerticalPositionRoutine _positionRoutine;
         #endregion
 
         #region 属性
@@ -110,21 +111,29 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         private void InitializeRoutine()
         {
             _initializeRoutine = new PlatingCellVerticalInitializeRoutine(Module.ToString());
+            _positionRoutine=new PlatingCellVerticalPositionRoutine(Module.ToString());
         }
 
         /// 初始化状态机
         /// </summary>
         private void InitialFsm()
         {
-            fsm = new StateMachine<PlatingCellVerticalEntity>(Module.ToString(), (int)PlatingCellVerticalState.Init, 100);
+            fsm = new StateMachine<PlatingCellVerticalEntity>(Module.ToString(), (int)PlatingCellVerticalState.Idle, 100);
             fsm.EnableRepeatedMsg(true);
 
             AnyStateTransition(VerticalMsg.Initialize, InitializeAll, PlatingCellVerticalState.Initializing);
             Transition(PlatingCellVerticalState.Initializing, FSM_MSG.TIMER, InitializeAllMonitor, PlatingCellVerticalState.Idle);
+            Transition(PlatingCellVerticalState.Initializing, VerticalMsg.Abort, HomeAbort, PlatingCellVerticalState.Init);
             AnyStateTransition(VerticalMsg.Error, NullFunc, PlatingCellVerticalState.Error);
             //Enter Init
             Transition(PlatingCellVerticalState.Idle, VerticalMsg.Init, NullFunc, PlatingCellVerticalState.Init);
 
+            //Position
+            Transition(PlatingCellVerticalState.Idle,VerticalMsg.Position,Position,PlatingCellVerticalState.Positioning);
+            Transition(PlatingCellVerticalState.Positioning, VerticalMsg.Position, NullFunc, PlatingCellVerticalState.Positioning);
+            Transition(PlatingCellVerticalState.Positioning, FSM_MSG.TIMER, PositionMonitor, PlatingCellVerticalState.Idle);
+            Transition(PlatingCellVerticalState.Positioning, VerticalMsg.Abort, PositionAbort, PlatingCellVerticalState.Idle);
+
             EnumLoop<PlatingCellVerticalState>.ForEach((item) => { fsm.MapState((int)item, item.ToString()); });
 
             EnumLoop<VerticalMsg>.ForEach((item) => { fsm.MapMessage((int)item, item.ToString()); });
@@ -158,7 +167,56 @@ namespace PunkHPX8_RT.Modules.PlatingCell
             }
             return false;
         }
+        /// <summary>
+        /// 中止Home
+        /// </summary>
+        /// <param name="param"></param>
+        /// <returns></returns>
+        private bool HomeAbort(object[] param)
+        {
+            _initializeRoutine.Abort();
+            return true;
+        }
+        #endregion
 
+        #region Position
+        /// <summary>
+        /// Position
+        /// </summary>
+        /// <returns></returns>
+        private bool Position(object[] param)
+        {
+            return _positionRoutine.Start(param) == RState.Running;
+        }
+        /// <summary>
+        /// Position 监控
+        /// </summary>
+        /// <param name="param"></param>
+        /// <returns></returns>
+        private bool PositionMonitor(object[] param)
+        {
+            RState rsstate = _positionRoutine.Monitor();
+            if (rsstate == RState.End)
+            {
+                return true;
+            }
+            else if (rsstate == RState.Failed || rsstate == RState.Timeout)
+            {
+                PostMsg(VerticalMsg.Error);
+                return false;
+            }
+            return false;
+        }
+        /// <summary>
+        /// 中止
+        /// </summary>
+        /// <param name="param"></param>
+        /// <returns></returns>
+        private bool PositionAbort(object[] param)
+        {
+            _positionRoutine.Abort();
+            return true; ;
+        }
         #endregion
 
 

+ 2 - 1
PunkHPX8_RT/Modules/PlatingCell/PlatingCellVerticalPositionRoutine.cs

@@ -45,7 +45,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         /// <summary>
         /// cell集合
         /// </summary>
-        private List<PlatingCellEntity> _cellEntities;
+        private List<PlatingCellEntity> _cellEntities=new List<PlatingCellEntity>();
         /// <summary>
         /// 位置 
         /// </summary>
@@ -161,6 +161,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         {
             _position=(double)objs[0];
             _matcher = ModuleMatcherManager.Instance.GetMatcherListByVertical(Module);
+            _cellEntities.Clear();
             foreach (string str in _matcher) 
             {
                 if(!Enum.TryParse(str, out ModuleName moduleName))

+ 89 - 2
PunkHPX8_RT/Schedulers/EfemRobot/SchedulerRobot.cs

@@ -17,6 +17,10 @@ using PunkHPX8_RT.Modules.VpwMain;
 using PunkHPX8_RT.Modules.VpwCell;
 using MECF.Framework.Common.RecipeCenter;
 using PunkHPX8_RT.Modules.PlatingCell;
+using Aitex.Sorter.Common;
+using PunkHPX8_RT.Dispatch;
+using MECF.Framework.Common.ToolLayout;
+using Aitex.Core.Common;
 
 namespace PunkHPX8_RT.Schedulers.EfemRobot
 {
@@ -127,9 +131,21 @@ namespace PunkHPX8_RT.Schedulers.EfemRobot
             }
 
             MoveItem moveItem = (MoveItem)parameter;
-            if(WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot,(int)moveItem.RobotHand))
+            if(WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)Hand.Blade1))
             {
-                reason = "robot has wafer";
+                reason = "robot lower hand has wafer";
+                return false;
+            }
+
+            if (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, (int)Hand.Blade2))
+            {
+                reason = "robot upper hand has wafer";
+                return false;
+            }
+
+            if (!CheckPreTaskComplete(materialId,schedulerSequences,sequenceIndex))
+            {
+                reason = "last wafer task has not completed";
                 return false;
             }
 
@@ -281,6 +297,77 @@ namespace PunkHPX8_RT.Schedulers.EfemRobot
             }
             return true;
         }
+        /// <summary>
+        /// 检验上一个任务是否完成
+        /// </summary>
+        /// <param name="materialId"></param>
+        /// <returns></returns>
+        private bool CheckPreTaskComplete(string materialId, List<SchedulerSequence> schedulerSequences, int sequenceIndex)
+        {
+            WaferTask waferTask = WaferTaskManager.Instance.GetWaferTask(materialId);
+            if(waferTask == null)
+            {
+                return true;
+            }
+            WaferInfo waferInfo = WaferManager.Instance.GetWaferByWaferId(materialId);
+            if (waferInfo == null || waferInfo.IsEmpty)
+            {
+                return true;
+            }
+            if (!string.IsNullOrEmpty(waferTask.MateWaferTask))
+            {
+                return true;
+            }
+
+            if (sequenceIndex < 1)
+            {
+                return true;
+            }
+            SchedulerSequence preSequence=schedulerSequences[sequenceIndex-1];
+            if (preSequence==null)
+            {
+                return true;
+            }
+            if (preSequence.ModuleName!=ModuleName.Aligner1)
+            {
+                return true;
+            }
+            List<string> platingCells = PlatingCellItemManager.Instance.InstalledModules;
+            foreach(string item in platingCells)
+            {
+                PlatingCellEntity platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(item);
+                if (!platingCellEntity.IsAuto)
+                {
+                    continue;
+                }
+                if (platingCellEntity.MetalWaferSize != (int)waferInfo.Size)
+                {
+                    continue;
+                }
+                if (WaferManager.Instance.CheckHasWafer(item, 0))
+                {
+                    return false;
+                }
+            }
+            List<string> vpwCells = VpwCellItemManager.Instance.InstalledModules;
+            foreach (string item in vpwCells)
+            {
+                VpwCellEntity entity = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(item);
+                if (!entity.IsAuto)
+                {
+                    continue;
+                }
+                if (entity.VpwWaferSize != (int)waferInfo.Size)
+                {
+                    continue;
+                }
+                if (WaferManager.Instance.CheckHasWafer(item, 0))
+                {
+                    return false;
+                }
+            }
+            return true;
+        }
 
         public override void ResetTask()
         {