浏览代码

update transporter safe move interlock

chenkui 2 周之前
父节点
当前提交
975152ef49
共有 1 个文件被更改,包括 30 次插入13 次删除
  1. 30 13
      CyberX8_RT/Modules/Transporter/TransporterEntity.cs

+ 30 - 13
CyberX8_RT/Modules/Transporter/TransporterEntity.cs

@@ -394,8 +394,10 @@ namespace CyberX8_RT.Modules.Transporter
         /// <returns></returns>
         private bool ResumeError(object[] param)
         {
-            if(_isHomed)
+            bool result = CheckAllAxisIsHomed();
+            if (result)
             {
+                _isHomed = true;
                 PostMsg(TransporterMSG.ReturnIdle);
                 return false;
             }
@@ -679,7 +681,8 @@ namespace CyberX8_RT.Modules.Transporter
             {
                 _targetCell = param[0].ToString();
                 _sourceCell = "";
-                _currentRoutine = _moveToRoutine;
+                _currentRoutine = _moveToRoutine; 
+                LOG.WriteLog(eEvent.INFO_TRANSPORTER, Module.ToString(), $"Module Axis move to {_targetCell}");
             }
             return result;
         }
@@ -696,6 +699,7 @@ namespace CyberX8_RT.Modules.Transporter
             {
                 _currentRoutine = _moveToRoutine;
                 _targetCell = _moveToRoutine.TargetCell;
+                LOG.WriteLog(eEvent.INFO_TRANSPORTER, Module.ToString(), $"Module Axis retry moveto {_targetCell}");
             }
             return result;
         }
@@ -776,7 +780,8 @@ namespace CyberX8_RT.Modules.Transporter
             if(result)
             {
                 _currentRoutine = _placeRoutine;
-                _targetCell = param[0].ToString();
+                _targetCell = param[0].ToString(); 
+                LOG.WriteLog(eEvent.INFO_TRANSPORTER, Module.ToString(), $"Module Axis place to {_targetCell}");
             }
             return result;
         }
@@ -793,6 +798,7 @@ namespace CyberX8_RT.Modules.Transporter
             {
                 _currentRoutine = _placeRoutine;
                 _targetCell = _placeRoutine.TargetCell;
+                LOG.WriteLog(eEvent.INFO_TRANSPORTER, Module.ToString(), $"Module Axis retry place to {_targetCell}");
             }
             return result;
         }
@@ -998,6 +1004,7 @@ namespace CyberX8_RT.Modules.Transporter
                 _sourceCell=param[0].ToString();
                 _targetCell = param[1].ToString();
                 _currentRoutine = _transferRoutine;
+                LOG.WriteLog(eEvent.INFO_TRANSPORTER, Module.ToString(), $"Module Axis transfer from {_sourceCell} to {_targetCell}");
             }
             return result;
         }
@@ -1024,7 +1031,8 @@ namespace CyberX8_RT.Modules.Transporter
             {
                 _currentRoutine = _transferRoutine;
                 _sourceCell=_transferRoutine.SourceCell;
-                _targetCell=_transferRoutine.TargetCell;
+                _targetCell=_transferRoutine.TargetCell; 
+                LOG.WriteLog(eEvent.INFO_TRANSPORTER, Module.ToString(), $"Module Axis retry transfer from {_sourceCell} to {_targetCell}");
             }
             return result;
         }
@@ -1175,37 +1183,42 @@ namespace CyberX8_RT.Modules.Transporter
         /// 检验当前模块与另一个模块是否存在冲突
         /// </summary>
         /// <returns></returns>
-        private bool CheckModuleWithOtherModuleConflict(TransporterEntity otherEntity,string otherModule,bool positive,string targetCell)
+        private bool CheckModuleWithOtherModuleConflict(TransporterEntity otherEntity, string otherModule, bool positive, string targetCell)
         {
             int transporterMinimumDistance = SC.GetValue<int>("Transporter.TransporterMinimumDistance");
             double motorPosition = _gantryAxis.MotionData.MotorPosition;
-            if(targetCell==ModuleName.Loader1.ToString())
+            if (targetCell == ModuleName.Loader1.ToString())
             {
                 targetCell = "Loader";
             }
             var result = AnalyseTargetCellPosition(Module.ToString(), targetCell);
-            if(!result.result)
+            if (!result.result)
             {
                 return false;
             }
-            double targetPosition=result.targetPosition;
+            double targetPosition = result.targetPosition;
             JetAxisBase otherGantryAxis = DEVICE.GetDevice<JetAxisBase>($"{otherModule}.Gantry");
-            if(otherGantryAxis==null)
+            if (otherGantryAxis == null)
             {
                 return false;
             }
             double otherPosition = otherGantryAxis.MotionData.MotorPosition;
+            bool targetConflict = false;
             if (!string.IsNullOrEmpty(otherEntity.TargetCell))
             {
-                return CheckOtherModuleCellConflict(otherModule, otherEntity.TargetCell,otherPosition, positive, targetPosition, motorPosition);
+                targetConflict = CheckOtherModuleCellConflict(otherModule, otherEntity.TargetCell, otherPosition, positive, targetPosition, motorPosition);
+                if (targetConflict)
+                {
+                    return true;
+                }
             }
-            if(!string.IsNullOrEmpty(otherEntity.SourceCell))
+            if (!string.IsNullOrEmpty(otherEntity.SourceCell))
             {
-                bool conflict= CheckOtherModuleCellConflict(otherModule, otherEntity.SourceCell,otherPosition, positive, targetPosition, motorPosition);
+                bool conflict = CheckOtherModuleCellConflict(otherModule, otherEntity.SourceCell, otherPosition, positive, targetPosition, motorPosition);
                 if (conflict)
                 {
                     //另一个Entity已经到达了目标位置
-                    if (!string.IsNullOrEmpty(otherEntity.TargetCell)&&CheckOtherEntityAlreadyInTargetCell(otherEntity, otherEntity.TargetCell))
+                    if (!string.IsNullOrEmpty(otherEntity.TargetCell) && CheckOtherEntityAlreadyInTargetCell(otherEntity, otherEntity.TargetCell))
                     {
                         return false;
                     }
@@ -1325,6 +1338,7 @@ namespace CyberX8_RT.Modules.Transporter
                 _sourceCell = param[0].ToString();
                 _targetCell = param[1].ToString();
                 _currentRoutine = _pickUpMoveToRoutine;
+                LOG.WriteLog(eEvent.INFO_TRANSPORTER, Module.ToString(), $"Module Axis PickupMoveTo from {_sourceCell} to {_targetCell}");
             }
             return result;
         }
@@ -1352,6 +1366,7 @@ namespace CyberX8_RT.Modules.Transporter
                 _currentRoutine = _pickUpMoveToRoutine;
                 _sourceCell = _pickUpMoveToRoutine.SourceCell;
                 _targetCell= _pickUpMoveToRoutine.TargetCell;
+                LOG.WriteLog(eEvent.INFO_TRANSPORTER, Module.ToString(), $"Module Axis retry PickupMoveTo from {_sourceCell} to {_targetCell}");
             }
             return result;
         }
@@ -1437,6 +1452,7 @@ namespace CyberX8_RT.Modules.Transporter
             {
                 _sourceCell = param[0].ToString();
                 _currentRoutine = _pickUpValidateRoutine;
+                LOG.WriteLog(eEvent.INFO_TRANSPORTER, Module.ToString(), $"Module Axis PickUpValidate from {_sourceCell}");
             }
             return result;
         }
@@ -1458,6 +1474,7 @@ namespace CyberX8_RT.Modules.Transporter
             {
                 _currentRoutine = _pickUpValidateRoutine;
                 _sourceCell = _pickUpValidateRoutine.SourceCell;
+                LOG.WriteLog(eEvent.INFO_TRANSPORTER, Module.ToString(), $"Module Axis retry PickupValidate from {_sourceCell}");
             }
             return result;
         }