Browse Source

1revise platingcell init routine

chenzk 1 day ago
parent
commit
0f907ac87e

+ 1 - 1
PunkHPX8_RT/Config/Devices/AxisProviderCfg.xml

@@ -70,7 +70,7 @@
     <!-- <Driver>Sim</Driver> -->
     <Units>mm</Units>
     <!-- Old gear head ScaleFactor>47784.1</ScaleFactor-->
-    <ScaleFactor>1</ScaleFactor>
+    <ScaleFactor>1000000</ScaleFactor>
     <JogLimit>25</JogLimit>
 	<MinMoveTime>1.0</MinMoveTime>
     <Inputs>

+ 12 - 8
PunkHPX8_RT/Devices/PlatingCell/PlatingCellDevice.cs

@@ -184,6 +184,17 @@ namespace PunkHPX8_RT.Devices.PlatingCell
             {
                 _verticalAxis.OnTimer();
             }
+            else
+            {
+                if ("PlatingCell1".Equals(Module) || "PlatingCell2".Equals(Module))
+                {
+                    _verticalAxis = DEVICE.GetDevice<JetAxisBase>("PlatingCell1_2.Vertical");
+                }
+                else
+                {
+                    _verticalAxis = DEVICE.GetDevice<JetAxisBase>("PlatingCell3_4.Vertical");
+                }
+            }
             if (_rotationAxis != null) 
             { 
                 _rotationAxis.OnTimer();
@@ -216,14 +227,7 @@ namespace PunkHPX8_RT.Devices.PlatingCell
 
             _reservoirData = GetReservoirDevice().ReservoirData;
             _reservoirName = GetReservoirDevice().Module;
-            if("PlatingCell1".Equals(Module) || "PlatingCell2".Equals(Module))
-            {
-                _verticalAxis = DEVICE.GetDevice<JetAxisBase>("PlatingCell1_2.Vertical");
-            }
-            else
-            {
-                _verticalAxis = DEVICE.GetDevice<JetAxisBase>("PlatingCell3_4.Vertical");
-            }
+            
             _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
         }
         protected virtual void SubscribeValueAction()

+ 2 - 2
PunkHPX8_RT/Modules/PlatingCell/PlatingCellCCRRoutine.cs

@@ -70,7 +70,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         /// </summary>
         private JetAxisBase _rotationAxis;
         /// <summary>
-        /// SRD rotation Provider对象
+        /// rotation Provider对象
         /// </summary>
         private BeckhoffProviderAxis _rotationProviderAxis;
         /// <summary>
@@ -441,7 +441,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
             _rotationProviderAxis = BeckhoffAxisProviderManager.Instance.GetAxisProvider($"{Module}.Rotation");
             if (_rotationProviderAxis == null)
             {
-                NotifyError(eEvent.ERR_SRD, $"{Module}.Rotation Provider is not exist", 0);
+                NotifyError(eEvent.ERR_PLATINGCELL, $"{Module}.Rotation Provider is not exist", 0);
                 return RState.Failed;
             }
             return Runner.Start(Module, "Start Reservoir Initialize");

+ 16 - 38
PunkHPX8_RT/Modules/PlatingCell/PlatingCellInitializeRoutine.cs

@@ -2,6 +2,7 @@
 using Aitex.Core.RT.Log;
 using Aitex.Core.RT.Routine;
 using Aitex.Core.RT.SCCore;
+using Aitex.Core.Util;
 using MECF.Framework.Common.Persistent.Reservoirs;
 using MECF.Framework.Common.RecipeCenter;
 using MECF.Framework.Common.Routine;
@@ -59,11 +60,10 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         /// Reservoir Recipe
         /// </summary>
         private ResRecipe _resRecipe;
-
         /// <summary>
-        /// vertical axis
+        /// vetical entity
         /// </summary>
-        private JetAxisBase _verticalAxis; 
+        private PlatingCellVerticalEntity _verticalEntity;
         /// <summary>
         /// Rotation axis
         /// </summary>
@@ -109,9 +109,9 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         {
             Runner.Run(InitializeStep.CheckPowerSupplierConnected, CheckPowerSupplierStatus, _delay_1ms)
                 .Run(InitializeStep.CheckClamShellClosed, () => _platingCellDevice.ClamShellClose(), CheckClamShellClosed, _delay_1ms)
-                .Run(InitializeStep.VerticalGotoLoad, VerticalGotoLoad, NullFun, 100)
+                .Run(InitializeStep.VerticalGotoLoad, VerticalGotoLoad,100)
                 .WaitWithStopCondition(InitializeStep.VerticalGotoLoadCheck, CheckVerticalPositionStatus, CheckVerticalPositionRunStop)
-                .Run(InitializeStep.RotationHome, RotationGotoHome, NullFun, 100)
+                .Run(InitializeStep.RotationHome, RotationGotoHome, 100)
                 .WaitWithStopCondition(InitializeStep.RotationHomeCheck, CheckRotationPositionStatus, CheckRotationPositionRunStop)
                 .Run(InitializeStep.AngleEntryTilt, () => _platingCellDevice.HeadtTiltAction(), CheckAngleTilt, _delay_1ms)
                 .Run(InitializeStep.AngleEntryVertical, () => _platingCellDevice.HeadtVerticalAction(), CheckAngleVertical, _delay_1ms)
@@ -191,20 +191,9 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         /// <returns></returns>
         private bool VerticalGotoLoad()
         {
-            if(_verticalAxis != null )
+            if(_verticalEntity != null )
             {
-                if (!_verticalAxis.IsSwitchOn)
-                {
-                    LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Vertical is not Power On");
-                    return false;
-                }
-                else if (!_verticalAxis.IsHomed)
-                {
-                    LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Vertical is not Home,Home vertical first");
-                    return false;
-                }
-                return _verticalAxis.PositionStation("Load", true);
-
+                return _verticalEntity.CheckToPostMessage<PlatingCellVerticalState,PlatingCellVerticalEntity.VerticalMsg>(eEvent.INFO_PLATINGCELL, Module, (int)PlatingCellVerticalEntity.VerticalMsg.Initialize);
             }
             else
             {
@@ -213,7 +202,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
             }   
         }
         /// <summary>
-        /// vertical 运动到Load位置
+        /// rotation home
         /// </summary>
         /// <returns></returns>
         private bool RotationGotoHome()
@@ -225,12 +214,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
                     LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Roation is not Power On");
                     return false;
                 }
-                else if (!_rotationAxis.IsHomed)
-                {
-                    LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Rotation is not Home,Home Rotation first");
-                    return false;
-                }
-                return _rotationAxis.PositionStation("Home", true);
+                return _rotationAxis.Home();
 
             }
             else
@@ -290,7 +274,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         /// <returns></returns>
         private bool CheckVerticalPositionStatus()
         {
-            return _verticalAxis.Status == RState.End;
+            return _verticalEntity.IsIdle;
         }
         /// <summary>
         /// 检验Vertical是否还在运动
@@ -298,10 +282,10 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         /// <returns></returns>
         private bool CheckVerticalPositionRunStop()
         {
-            return _verticalAxis.Status == RState.Failed;
+            return _verticalEntity.IsError;
         }
         /// <summary>
-        /// 检验Rotation移动状态
+        /// 检验Rotation home是否完成
         /// </summary>
         /// <returns></returns>
         private bool CheckRotationPositionStatus()
@@ -309,12 +293,12 @@ namespace PunkHPX8_RT.Modules.PlatingCell
             return _rotationAxis.Status == RState.End;
         }
         /// <summary>
-        /// 检验Rotaion是否还在运动
+        /// 检验Rotaion 是否home 失败
         /// </summary>
         /// <returns></returns>
         private bool CheckRotationPositionRunStop()
         {
-            return _rotationAxis.Status == RState.Failed;
+            return _rotationAxis.Status == RState.Failed || _rotationAxis.Status == RState.Timeout;
         }
 
         /// <summary>
@@ -340,14 +324,8 @@ namespace PunkHPX8_RT.Modules.PlatingCell
             _rinseDripIdlePeriod = SC.GetValue<int>("PlatingCell.RinseDripIdlePeriod");
             _cellFlowStartLowLimit = SC.GetValue<double>("PlatingCell.CellFlowStartLowLimit");
             _anFlowStartLowLimit = SC.GetValue<double>("PlatingCell.ANFlowStartLowLimit");
-            if("PlatingCell1".Equals(Module) || "PlatingCell2".Equals(Module))
-            {
-                _verticalAxis = DEVICE.GetDevice<JetAxisBase>("PlatingCell1_2.Vertical");
-            }
-            else
-            {
-                _verticalAxis = DEVICE.GetDevice<JetAxisBase>("PlatingCell3_4.Vertical");
-            }
+            string verticalModule = ModuleMatcherManager.Instance.GetPlatingVerticalByCell(Module);
+            _verticalEntity=Singleton<RouteManager>.Instance.GetModule<PlatingCellVerticalEntity>(verticalModule);
             _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
             string reservoir = ReservoirItemManager.Instance.GetReservoirByPlatingCell(Module.ToString());
             ReservoirDevice reservoirDevice = DEVICE.GetDevice<ReservoirDevice>(reservoir);

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

@@ -1,8 +1,14 @@
-using Aitex.Core.RT.Routine;
+using Aitex.Core.RT.Device;
+using Aitex.Core.RT.Log;
+using Aitex.Core.RT.Routine;
 using Aitex.Core.Util;
+using MECF.Framework.Common.Beckhoff.AxisProvider;
+using MECF.Framework.Common.RecipeCenter;
 using MECF.Framework.Common.Routine;
 using MECF.Framework.Common.Utilities;
 using PunkHPX8_Core;
+using PunkHPX8_RT.Devices.AXIS;
+using PunkHPX8_RT.Devices.PlatingCell;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -22,7 +28,38 @@ namespace PunkHPX8_RT.Modules.PlatingCell
             CheckVertical,
             End
         }
+        #region 常量 
+        private const int ALL_DAY_MILLOSECONDS = 24 * 60 * 60 * 1000;
+        #endregion
+
         #region 内部变量
+        /// <summary>
+        /// recipe
+        /// </summary>
+        private DepRecipe _recipe;
+        /// <summary>
+        /// Platingcell device
+        /// </summary>
+        private PlatingCellDevice _device;
+        /// <summary>
+        /// Rotation axis
+        /// </summary>
+        private JetAxisBase _rotationAxis;
+        /// <summary>
+        ///rotation Provider对象
+        /// </summary>
+        private BeckhoffProviderAxis _rotationProviderAxis;
+        /// cycle次数
+        /// </summary>
+        private int _cycle;
+        /// <summary>
+        /// 当前完成的Cycle次数
+        /// </summary>
+        private int _currentCycle;
+
+
+
+
         private PlatingCellInterRinseRoutine _interRinseRoutine;
         private PlatingCellVerticalEntity _verticalEntity;
         #endregion
@@ -32,7 +69,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         /// <param name="module"></param>
         public PlatingCellRunRecipeRoutine(string module) : base(module)
         {
-            _interRinseRoutine=new PlatingCellInterRinseRoutine(module);
+            _interRinseRoutine = new PlatingCellInterRinseRoutine(module);
         }
         /// <summary>
         /// 中止
@@ -49,10 +86,10 @@ 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))
-                .Run(RunRecipeStep.Vertical,StartVertical)
-                .WaitWithStopCondition(RunRecipeStep.CheckVertical,CheckVerticalEnd,CheckVerticalError)
+                .WaitWithStopCondition(RunRecipeStep.CheckInterRinse, () => CommonFunction.CheckRoutineEndState(_interRinseRoutine),
+                () => CommonFunction.CheckRoutineStopState(_interRinseRoutine))
+                .Run(RunRecipeStep.Vertical, StartVertical)
+                .WaitWithStopCondition(RunRecipeStep.CheckVertical, CheckVerticalEnd, CheckVerticalError)
                 .End(RunRecipeStep.End, NullFun);
             return Runner.Status;
         }
@@ -63,8 +100,8 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         private bool StartVertical()
         {
             double position = 101;
-            return _verticalEntity.CheckToPostMessage<PlatingCellVerticalState, VerticalMsg>(Aitex.Core.RT.Log.eEvent.INFO_PLATINGCELL,
-                Module, (int)VerticalMsg.Position, position);
+            return _verticalEntity.CheckToPostMessage<PlatingCellVerticalState, PlatingCellVerticalEntity.VerticalMsg>(Aitex.Core.RT.Log.eEvent.INFO_PLATINGCELL,
+                Module, (int)PlatingCellVerticalEntity.VerticalMsg.Position, position);
         }
         /// <summary>
         /// 检验垂直电机是否运动完成
@@ -89,9 +126,87 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         /// <returns></returns>
         public RState Start(params object[] objs)
         {
+            _recipe = objs[0] as DepRecipe;
+            if (_recipe == null)
+            {
+                LOG.WriteLog(eEvent.ERR_METAL, Module, "recipe is null");
+                return RState.Failed;
+            }
+            if (objs.Length > 1)
+            {
+                _cycle = (int)objs[1];
+            }
+            _device = DEVICE.GetDevice<PlatingCellDevice>(Module);
+            _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
+            _rotationProviderAxis = BeckhoffAxisProviderManager.Instance.GetAxisProvider($"{Module}.Rotation");
+            if (_rotationProviderAxis == null)
+            {
+                NotifyError(eEvent.ERR_PLATINGCELL, $"{Module}.Rotation Provider is not exist", 0);
+                return RState.Failed;
+            }
+           
             string vertical = ModuleMatcherManager.Instance.GetPlatingVerticalByCell(Module);
             _verticalEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellVerticalEntity>(vertical);
+            if (!CheckPreCondition())
+            {
+                return RState.Failed;
+            }
+            _currentCycle = 0;
+
+ 
             return Runner.Start(Module, "Run Recipe");
         }
+        /// <summary>
+        /// 检验前置条件
+        /// </summary>
+        /// <returns></returns>
+        private bool CheckPreCondition()
+        {
+            if (_recipe == null)
+            {
+                LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Recipe is null");
+                return false;
+            }
+
+            if (_recipe.DepSteps.Count == 0)
+            {
+                LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Recipe DepSteps count is 0");
+                return false;
+            }
+            CheckAxisHome();
+            CheckFacility();
+            return true;
+        }
+        /// <summary>
+        /// 检查马达是否上电且home
+        /// </summary>
+        /// <returns></returns>
+        private bool CheckAxisHome()
+        {
+            if (!_rotationAxis.IsSwitchOn)
+            {
+                LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Rotation Axis is off");
+                return false;
+            }
+            if (!_rotationAxis.IsHomed)
+            {
+                LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Rotation Axis is not home");
+                return false;
+            }
+            if (!_verticalEntity.IsIdle)
+            {
+                LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Vertical Axis is not home");
+                return false;
+            }
+            return true;
+        }
+        /// <summary>
+        /// 检查facility
+        /// </summary>
+        /// <returns></returns>
+        private bool CheckFacility()
+        {
+            return true;
+        }
     }
 }

+ 11 - 10
PunkHPX8_RT/Modules/PlatingCell/PlatingCellVerticalEntity.cs

@@ -18,18 +18,19 @@ using static PunkHPX8_RT.Modules.PlatingCell.PlatingCellEntity;
 
 namespace PunkHPX8_RT.Modules.PlatingCell
 {
-    public enum VerticalMsg
-    {
-        NONE,
-        Error,
-        ResumeError,
-        Initialize,
-        Abort,
-        Init,
-        Position
-    }
+
     public class PlatingCellVerticalEntity : Entity, IEntity, IModuleEntity
     {
+        public enum VerticalMsg
+        {
+            NONE,
+            Error,
+            ResumeError,
+            Initialize,
+            Abort,
+            Init,
+            Position
+        }
 
         #region 内部变量
         private PlatingCellVerticalInitializeRoutine _initializeRoutine;

+ 1 - 1
PunkHPX8_RT/Modules/PlatingCell/PlatingCellVerticalInitializeRoutine.cs

@@ -129,7 +129,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         /// <returns></returns>
         private bool CheckVerticalPositionRunStop()
         {
-            return _verticalAxis.Status == RState.Failed;
+            return _verticalAxis.Status == RState.Failed || _verticalAxis.Status == RState.Timeout;
         }
         /// <summary>
         /// 启动