Selaa lähdekoodia

PUF/Loader/Transport check all axis is homed then enter idle state

chenkui 2 kuukautta sitten
vanhempi
commit
0d497c6f55

+ 20 - 0
CyberX8_RT/Devices/AXIS/JetAxisBase.cs

@@ -1295,6 +1295,26 @@ namespace CyberX8_RT.Devices.AXIS
             return false;
         }
         /// <summary>
+        /// 检验电机已经完成了Homed
+        /// </summary>
+        /// <returns></returns>
+        public bool CheckAxisIsAreadyHomed()
+        {
+            if (!_isSwitchOn)
+            {
+                return false;
+            }
+            if (CheckPositionIsEmpty(MotionData.MotorPosition))
+            {
+                return false;
+            }
+            if (!_isHomed)
+            {
+                _isHomed = true;
+            }
+            return true;
+        }
+        /// <summary>
         /// 检验位置(忽略WaferSize)
         /// </summary>
         /// <param name="position"></param>

+ 90 - 1
CyberX8_RT/Modules/Loader/LoaderEntity.cs

@@ -298,11 +298,100 @@ namespace CyberX8_RT.Modules.Loader
             DATA.Subscribe($"{Module}.Task", () => WaferHolderInfo?.CurrentControlJobId, SubscriptionAttribute.FLAG.IgnoreSaveDB);
         }
         /// <summary>
+        /// 检验所有电机是否已经完成Home
+        /// </summary>
+        /// <returns></returns>
+        private bool CheckAllAxisIsHomed()
+        {
+            bool shuttleAIsHomed = _shuttleAAxis.CheckAxisIsAreadyHomed();
+            if (!shuttleAIsHomed)
+            {
+                return false;
+            }
+            bool shuttleAMid = _shuttleAAxis.CheckPositionIsInStation(_shuttleAAxis.MotionData.MotorPosition, "MID");
+            if (!shuttleAMid)
+            {
+                return false;
+            }
+            bool shuttleBIsHomed = _shuttleBAxis.CheckAxisIsAreadyHomed();
+            if (!shuttleAIsHomed)
+            {
+                return false;
+            }
+            bool shuttleBMid = _shuttleBAxis.CheckPositionIsInStation(_shuttleBAxis.MotionData.MotorPosition, "MID");
+            if (!shuttleAMid)
+            {
+                return false;
+            }
+            bool tiltAIsHomed = _tiltAAxis.CheckAxisIsAreadyHomed();
+            if (!tiltAIsHomed)
+            {
+                return false;
+            }
+
+            bool tiltAVert = _tiltAAxis.CheckPositionIsInStation(_tiltAAxis.MotionData.MotorPosition, "VERT");
+            if (!tiltAVert)
+            {
+                return false;
+            }
+            bool tiltBIsHomed = _tiltBAxis.CheckAxisIsAreadyHomed();
+            if (!tiltBIsHomed)
+            {
+                return false;
+            }
+
+            bool tiltBVert = _tiltBAxis.CheckPositionIsInStation(_tiltBAxis.MotionData.MotorPosition, "VERT");
+            if (!tiltBVert)
+            {
+                return false;
+            }
+            bool crsAIsHomed = _crsAAxis.CheckAxisIsAreadyHomed();
+            if (!crsAIsHomed)
+            {
+                return false;
+            }
+            bool crsASetUp = _crsAAxis.CheckPositionInStationIgnoreWaferSize(_crsAAxis.MotionData.MotorPosition, "Setup");
+            if (!crsASetUp)
+            {
+                return false;
+            }
+            bool crsBIsHomed = _crsBAxis.CheckAxisIsAreadyHomed();
+            if (!crsBIsHomed)
+            {
+                return false;
+            }
+            bool crsBSetUp = _crsBAxis.CheckPositionInStationIgnoreWaferSize(_crsBAxis.MotionData.MotorPosition, "Setup");
+            if (!crsBSetUp)
+            {
+                return false;
+            }
+            bool rotationIsHomed = _rotationAxis.CheckAxisIsAreadyHomed();
+            if (!rotationIsHomed)
+            {
+                return false;
+            }
+
+            bool rotationClosed = _rotationAxis.CheckPositionIsInStation(_rotationAxis.MotionData.MotorPosition, "TRNPA");
+            if (!crsASetUp)
+            {
+                return false;
+            }
+            return true;
+        }
+        /// <summary>
         /// 初始化状态机
         /// </summary>
         private void InitialFsm()
         {
-            fsm = new StateMachine<LoaderEntity>(Module.ToString(), (int)LOADERSTATE.Init, 100);
+            if (CheckAllAxisIsHomed())
+            {
+                _isHomed = true;
+                fsm = new StateMachine<LoaderEntity>(Module.ToString(), (int)LOADERSTATE.Idle, 100);
+            }
+            else
+            {
+                fsm = new StateMachine<LoaderEntity>(Module.ToString(), (int)LOADERSTATE.Init, 100);
+            }
             fsm.EnableRepeatedMsg(true);
 
             AnyStateTransition(LoaderMSG.Error, EnterError, LOADERSTATE.Error);

+ 66 - 41
CyberX8_RT/Modules/Metal/ReservoirRunRecipeRoutine.cs

@@ -9,6 +9,8 @@ using CyberX8_RT.Devices.Metal;
 using CyberX8_RT.Devices.PowerSupplier;
 using CyberX8_RT.Devices.Reservoir;
 using CyberX8_RT.Devices.Temperature;
+using CyberX8_RT.Modules.Metal;
+using CyberX8_RT.Modules;
 using MECF.Framework.Common.Alarm;
 using MECF.Framework.Common.CommonData;
 using MECF.Framework.Common.CommonData.Metal;
@@ -23,7 +25,7 @@ using System.Diagnostics;
 
 namespace CyberX8_RT.Modules.Metal
 {
-    public class ReservoirRunRecipeRoutine : RoutineBase,IRoutine
+    public class ReservoirRunRecipeRoutine : RoutineBase, IRoutine
     {
         #region 常量
         private const int LOTTRACK_TIME = 1000;
@@ -181,7 +183,7 @@ namespace CyberX8_RT.Modules.Metal
         /// <summary>
         /// 构造函数
         /// </summary>
-        public ReservoirRunRecipeRoutine(string moduleName):base(moduleName)
+        public ReservoirRunRecipeRoutine(string moduleName) : base(moduleName)
         {
 
         }
@@ -191,7 +193,7 @@ namespace CyberX8_RT.Modules.Metal
         /// </summary>
         public void Abort()
         {
-            if (_device != null) 
+            if (_device != null)
             {
                 _device.SideAPowerSupplier.DisableOperation("", null);
                 _device.SideBPowerSupplier.DisableOperation("", null);
@@ -202,7 +204,7 @@ namespace CyberX8_RT.Modules.Metal
                     _device.StopLinmot();
                 }
             }
-            
+
             Runner.Stop("Manual Abort");
         }
         /// <summary>
@@ -213,13 +215,13 @@ namespace CyberX8_RT.Modules.Metal
         {
             LottrackRecord();
             Runner.Run(RecipeStep.PlatingDelay, PlatingDelay, _delay_1ms)
-                .WaitWithStopCondition(RecipeStep.PlatingDelayCheck,()=>{ return _device.CheckLinmotRoutineEnd(); }, () => { return _device.CheckLinmotRoutineError(); } )
+                .WaitWithStopCondition(RecipeStep.PlatingDelayCheck, () => { return _device.CheckLinmotRoutineEnd(); }, () => { return _device.CheckLinmotRoutineError(); })
                 .RunIf(RecipeStep.HotPlating, _recipe.HotPlatingCurrentOn, HotPlating, _delay_1ms)
                 .RunIf(RecipeStep.WaitPlatingDelay, !_recipe.HotPlatingCurrentOn, NullFun, WaitPlatingDelay, _recipe.PlatingDelaySeconds * 1000 + 10000)
                 .RunIf(RecipeStep.RunPowerStep, !_recipe.HotPlatingCurrentOn, StartPowerStep, _delay_1ms)
-                .WaitWithStopCondition(RecipeStep.RunPowerStepWait,CheckRecipeStepEndStatus,CheckRecipeStepStopStatus,_delay_5s)
+                .WaitWithStopCondition(RecipeStep.RunPowerStepWait, CheckRecipeStepEndStatus, CheckRecipeStepStopStatus, _delay_5s)
                 .LoopStart(RecipeStep.LoopStart, "Loop update linmot speed", _powerSupplierStepPeriodDatas.Count, NullFun, _delay_1ms)
-                .LoopRunWithStopStatus(RecipeStep.LoopCheckRun, CheckStepComplete, () => { return false; })
+                .LoopRunWithStopStatus(RecipeStep.LoopCheckRun, CheckStepComplete, () => { return false; }, 24 * 60 * 60 * 1000)
                 .LoopEnd(RecipeStep.LoopEnd, NullFun, _delay_1ms)
                 .Run(RecipeStep.StopLinmot, StopLinmot, _delay_1ms)
                 .Run(RecipeStep.StopPowerSuppliers, StopPowerSupplier, _delay_1ms)
@@ -247,7 +249,7 @@ namespace CyberX8_RT.Modules.Metal
         public void AddLotTrackData()
         {
             MetalLotTrackData data = new MetalLotTrackData();
-            if(_metalType == STRATUS)
+            if (_metalType == STRATUS)
             {
                 data.Flow = _standardHotMetalDevice.MetalDeviceData.CellFlow;
                 data.ANLevel = 0;
@@ -314,7 +316,7 @@ namespace CyberX8_RT.Modules.Metal
             {
                 if (_recipe.HotPlatingCurrentOn)
                 {
-                    if(DateTime.Now.Subtract(_hotPlatingRunTime).TotalSeconds <= _recipe.PlatingDelaySeconds)
+                    if (DateTime.Now.Subtract(_hotPlatingRunTime).TotalSeconds <= _recipe.PlatingDelaySeconds)
                     {
                         data.RunTime = DateTime.Now.Subtract(_hotPlatingRunTime).TotalSeconds;
                         data.DurationRef = _recipe.PlatingDelaySeconds;
@@ -322,17 +324,18 @@ namespace CyberX8_RT.Modules.Metal
                     }
                     else
                     {
-                        if(data.StepNum == 1) data.DurationRef -= _recipe.PlatingDelaySeconds;
-                        data.RunTime = (data.StepNum == 1)?(DateTime.Now.Subtract(_startStepTime).TotalSeconds - _recipe.PlatingDelaySeconds): DateTime.Now.Subtract(_startStepTime).TotalSeconds;
+                        if (data.StepNum == 1) data.DurationRef -= _recipe.PlatingDelaySeconds;
+                        data.RunTime = (data.StepNum == 1) ? (DateTime.Now.Subtract(_startStepTime).TotalSeconds - _recipe.PlatingDelaySeconds) : DateTime.Now.Subtract(_startStepTime).TotalSeconds;
                     }
-                    
+
                 }
                 else
                 {
                     data.RunTime = DateTime.Now.Subtract(_startStepTime).TotalSeconds;
                 }
-               
+
             }
+
             _datas.Add(data);
         }
         /// <summary>
@@ -346,7 +349,7 @@ namespace CyberX8_RT.Modules.Metal
             if (result)
             {
                 _platingDelayTime = DateTime.Now;
-                if(!_recipe.HotPlatingCurrentOn) _hotPlatingRunTime = DateTime.Now;
+                if (!_recipe.HotPlatingCurrentOn) _hotPlatingRunTime = DateTime.Now;
             }
             return result;
         }
@@ -420,7 +423,7 @@ namespace CyberX8_RT.Modules.Metal
                 if (string.IsNullOrEmpty(_side))
                 {
                     bool resultA = _device.SideAPowerSupplier.Status == RState.End;
-                    bool resultB=_device.SideBPowerSupplier.Status == RState.End;
+                    bool resultB = _device.SideBPowerSupplier.Status == RState.End;
                     return resultA && resultB;
                 }
                 else
@@ -442,14 +445,14 @@ namespace CyberX8_RT.Modules.Metal
             {
                 if (string.IsNullOrEmpty(_side))
                 {
-                    bool resultA = _device.SideAPowerSupplier.Status == RState.Failed||_device.SideAPowerSupplier.Status==RState.Timeout;
-                    bool resultB = _device.SideBPowerSupplier.Status == RState.Failed||_device.SideBPowerSupplier.Status==RState.Timeout;
+                    bool resultA = _device.SideAPowerSupplier.Status == RState.Failed || _device.SideAPowerSupplier.Status == RState.Timeout;
+                    bool resultB = _device.SideBPowerSupplier.Status == RState.Failed || _device.SideBPowerSupplier.Status == RState.Timeout;
                     return resultA && resultB;
                 }
                 else
                 {
                     CellPowerSupplier cellPowerSupplier = GetSidePowerSupplier();
-                    return cellPowerSupplier.Status == RState.Failed||cellPowerSupplier.Status==RState.Timeout;
+                    return cellPowerSupplier.Status == RState.Failed || cellPowerSupplier.Status == RState.Timeout;
                 }
             }
             return false;
@@ -520,9 +523,10 @@ namespace CyberX8_RT.Modules.Metal
                 PowerSupplierStepPeriodData step = new PowerSupplierStepPeriodData();
                 step.Current = item.ForwardAmps;
                 step.Hour = (ushort)(item.CurrentRampDurartionSeconds / 3600);
-                step.Minute = (ushort)(item.CurrentRampDurartionSeconds / 60);
+                step.Minute = (ushort)((item.CurrentRampDurartionSeconds - step.Hour * 3600) / 60);
                 step.Second = (ushort)(item.CurrentRampDurartionSeconds % 60);
                 step.Microsecond = 0;
+                step.Voltage = _recipe.VoltageWarningLevel;
                 _powerSupplierStepPeriodDatas.Add(step);
             }
         }
@@ -543,14 +547,19 @@ namespace CyberX8_RT.Modules.Metal
         /// </summary>
         /// <returns></returns>
         private bool CheckStepComplete()
-        {            
+        {
             if (_stepIndex >= _powerSupplierStepPeriodDatas.Count)
             {
                 _stepWatch.Stop();
                 LOG.WriteLog(eEvent.INFO_METAL, Module, $"step {_stepIndex} is over step count {_powerSupplierStepPeriodDatas.Count}");
                 return true;
             }
-            if (DateTime.Now.Subtract(_startStepTime).TotalMilliseconds >= 2000)
+            int firstDelay = 2000;
+            if (_stepIndex == 0)
+            {
+                firstDelay = SC.GetValue<int>("Metal.CurrentCheckDelay") * 1000;
+            }
+            if (DateTime.Now.Subtract(_startStepTime).TotalMilliseconds >= firstDelay)
             {
                 bool abnormal = CheckMetalDisable();
                 if (abnormal)
@@ -558,11 +567,11 @@ namespace CyberX8_RT.Modules.Metal
                     return false;
                 }
             }
-            
+
             int length = _powerSupplierStepPeriodDatas[_stepIndex].Hour * 3600 + _powerSupplierStepPeriodDatas[_stepIndex].Minute * 60 +
                 _powerSupplierStepPeriodDatas[_stepIndex].Second;
             if (DateTime.Now.Subtract(_startStepTime).TotalSeconds >= length)
-            {                
+            {
                 _stepIndex++;
                 if (_stepIndex >= _powerSupplierStepPeriodDatas.Count)
                 {
@@ -585,7 +594,7 @@ namespace CyberX8_RT.Modules.Metal
                 _anodeAUsage += _device.SideAPowerSupplier.PowerSupplierData.Current * second / 3600;
                 _anodeBUsage += _device.SideBPowerSupplier.PowerSupplierData.Current * second / 3600;
             }
-            else if(_side==SIDE_A)
+            else if (_side == SIDE_A)
             {
                 _anodeAUsage += _device.SideAPowerSupplier.PowerSupplierData.Current * second / 3600;
             }
@@ -604,7 +613,7 @@ namespace CyberX8_RT.Modules.Metal
         {
 
             if (string.IsNullOrEmpty(_side))
-            {                
+            {
                 if (!_device.SideAPowerSupplier.PowerSupplierData.Enabled)
                 {
                     LOG.WriteLog(eEvent.ERR_METAL, Module, "PowerA disable");
@@ -740,7 +749,7 @@ namespace CyberX8_RT.Modules.Metal
                 if (!_isCurrentWarningA && ((_device.SideAPowerSupplier.PowerSupplierData.Current > _powerSupplierStepPeriodDatas[_stepIndex].Current + currentWarningFault && _device.SideAPowerSupplier.PowerSupplierData.Current < _powerSupplierStepPeriodDatas[_stepIndex].Current + currentErrorFault)
                     || (_device.SideAPowerSupplier.PowerSupplierData.Current < _powerSupplierStepPeriodDatas[_stepIndex].Current - currentWarningFault && _device.SideAPowerSupplier.PowerSupplierData.Current > _powerSupplierStepPeriodDatas[_stepIndex].Current - currentErrorFault)))
                 {
-                    _isCurrentWarningA  = true;
+                    _isCurrentWarningA = true;
                     LOG.WriteLog(eEvent.WARN_METAL, Module, $"Current SideA Current {_device.SideAPowerSupplier.PowerSupplierData.Current} is not in " +
                         $"recipe Range {_powerSupplierStepPeriodDatas[_stepIndex].Current - currentWarningFault} ~ {_powerSupplierStepPeriodDatas[_stepIndex].Current + currentWarningFault}");
                 }
@@ -898,11 +907,11 @@ namespace CyberX8_RT.Modules.Metal
         /// <param name="voltage"></param>
         /// <param name="side"></param>
         /// <returns></returns>
-        private bool CheckSidePowerInvalid(double current,double voltage,string side)
+        private bool CheckSidePowerInvalid(double current, double voltage, string side)
         {
             double maxVoltage = _recipe.VolatageLimitMax;
             double warnVoltage = _recipe.VoltageWarningLevel;
-            double minVoltage=_recipe.VolatageLimitMin;
+            double minVoltage = _recipe.VolatageLimitMin;
             if (voltage > maxVoltage)
             {
                 LOG.WriteLog(eEvent.ERR_METAL, Module, $"{side} voltage {voltage} is large than recipe max voltage {maxVoltage}");
@@ -1015,6 +1024,8 @@ namespace CyberX8_RT.Modules.Metal
                 _side = objs[1].ToString();
             }
             _startRecipeStep = false;
+            _anodeAUsage = 0;
+            _anodeBUsage = 0;
             _device = DEVICE.GetDevice<MetalCellDevice>(Module);
             _metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(Module);
             UpdatePowerStepDatas();
@@ -1022,7 +1033,7 @@ namespace CyberX8_RT.Modules.Metal
 
             _header.SoftWareVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
             _header.Recipe = $"{_recipe.Ppid}.dep.rcp";
-            if(SC.ContainsItem("System.ToolID")) _header.ToolID = SC.GetStringValue("System.ToolID");
+            if (SC.ContainsItem("System.ToolID")) _header.ToolID = SC.GetStringValue("System.ToolID");
 
             //lotTract记录SequenceRecipe
             MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(Module);
@@ -1045,30 +1056,51 @@ namespace CyberX8_RT.Modules.Metal
             _metalType = metalItem.SubType;
             if (_metalType == STRATUS)
             {
-                _standardHotReservoirDevice = DEVICE.GetDevice<StandardHotReservoirDevice>(reservoirName);              
+                _standardHotReservoirDevice = DEVICE.GetDevice<StandardHotReservoirDevice>(reservoirName);
                 _standardHotMetalDevice = DEVICE.GetDevice<StandardHotMetalDevice>(Module);
-                if (_standardHotReservoirDevice == null || _standardHotMetalDevice == null) 
+                if (_standardHotReservoirDevice == null || _standardHotMetalDevice == null)
                 {
                     LOG.WriteLog(eEvent.ERR_METAL, Module, $"metal or reservoir device is null");
                     return RState.Failed;
                 }
+                if (_standardHotMetalDevice.MetalDeviceData.CellFlow <= 0) //检查cell flow
+                {
+                    LOG.WriteLog(eEvent.ERR_METAL, Module, $"reservoir metal cell flow is 0");
+                    return RState.Failed;
+                }
             }
             else
             {
                 _compactMembranReservoirDevice = DEVICE.GetDevice<CompactMembranReservoirDevice>(reservoirName);
                 _compactMembranMetalDevice = DEVICE.GetDevice<CompactMembranMetalDevice>(Module);
-                if(_compactMembranMetalDevice == null || _compactMembranReservoirDevice == null)
+                if (_compactMembranMetalDevice == null || _compactMembranReservoirDevice == null)
                 {
                     LOG.WriteLog(eEvent.ERR_METAL, Module, $"metal or reservoir device is null");
                     return RState.Failed;
                 }
+                if (_compactMembranMetalDevice.MetalDeviceData.CellFlow <= 0) //检查cell flow
+                {
+                    LOG.WriteLog(eEvent.ERR_METAL, Module, $"reservoir metal cell flow is 0");
+                    return RState.Failed;
+                }
+                if (_compactMembranMetalDevice.ANACellFlow.CounterValue <= 0) //检查hold flow
+                {
+                    LOG.WriteLog(eEvent.ERR_METAL, Module, $"reservoir metal AnodeA flow is 0");
+                    return RState.Failed;
+                }
+                if (_compactMembranMetalDevice.ANBCellFlow.CounterValue <= 0)
+                {
+                    LOG.WriteLog(eEvent.ERR_METAL, Module, $"reservoir metal AnodeB flow is 0");
+                    return RState.Failed;
+                }
+
             }
             ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(reservoirName);
             _temperatureController = DEVICE.GetDevice<TemperatureController>(reservoirItem.TCID);
             if (_temperatureController == null)
-            {                
+            {
                 LOG.WriteLog(eEvent.ERR_METAL, Module, $"Temperature controller is null");
-                return RState.Failed;               
+                return RState.Failed;
             }
             _persistentValue = MetalPersistentManager.Instance.GetMetalPersistentValue(Module);
             if (_persistentValue == null)
@@ -1079,16 +1111,9 @@ namespace CyberX8_RT.Modules.Metal
             _lotTackTime = DateTime.Now;
             return Runner.Start(Module, "Metal run recipe");
         }
-
         public void clearLotTrack()
         {
             _datas.Clear();
         }
-
-        public void resetMetalUsage()
-        {
-            _anodeAUsage = 0;
-            _anodeBUsage = 0;
-        }
     }
 }

+ 50 - 1
CyberX8_RT/Modules/PUF/PUFEntity.cs

@@ -237,11 +237,60 @@ namespace CyberX8_RT.Modules.PUF
             _backToParkRoutine=new PufBackToParkRoutine(Module.ToString());
         }
         /// <summary>
+        /// 检验所有电机是否已经完成Home
+        /// </summary>
+        /// <returns></returns>
+        private bool CheckAllAxisIsHomed()
+        {
+            bool verticalIsHomed = _verticalAxis.CheckAxisIsAreadyHomed();
+            if (!verticalIsHomed)
+            {
+                return false;
+            }
+            bool flipIsHomed = _flipAxis.CheckAxisIsAreadyHomed();
+            if (!flipIsHomed)
+            {
+                return false;
+            }
+            bool rotationIsHomed = _rotationAxis.CheckAxisIsAreadyHomed();
+            if (!rotationIsHomed)
+            {
+                return false;
+            }
+            return true;
+        }
+        /// <summary>
+        /// 检验所有电机的位置
+        /// </summary>
+        /// <returns></returns>
+        private bool CheckAllAxisStation()
+        {
+            bool flipSideA = _flipAxis.CheckPositionIsInStation(_flipAxis.MotionData.MotorPosition, "SideA");
+            if (!flipSideA)
+            {
+                return false;
+            }
+            bool rotationPark = _rotationAxis.CheckPositionIsInStation(_rotationAxis.MotionData.MotorPosition, "Home");
+            if (!rotationPark)
+            {
+                return false;
+            }
+            return true;
+        }
+        /// <summary>
         /// 初始化状态机
         /// </summary>
         private void InitialFsm()
         {
-            fsm = new StateMachine<PUFEntity>(Module.ToString(), (int)PUFSTATE.Init, 20);
+            if (CheckAllAxisIsHomed() && CheckAllAxisStation())
+            {
+                _isHomed = true;
+                fsm = new StateMachine<PUFEntity>(Module.ToString(), (int)PUFSTATE.Idle, 20);
+            }
+            else
+            {
+                fsm = new StateMachine<PUFEntity>(Module.ToString(), (int)PUFSTATE.Init, 20);
+            }
             fsm.EnableRepeatedMsg(true);
 
             AnyStateTransition(PUFMSG.Error, EnterError, PUFSTATE.Error);

+ 1 - 1
CyberX8_RT/Modules/PUF/PufPlaceVacuumCheckRoutine.cs

@@ -84,7 +84,7 @@ namespace CyberX8_RT.Modules.PUF
             Runner.Run(PlaceVacuumStep.ChuckOut, () => { return _chuckRoutine.Start(true) == RState.Running; }, NullFun, 100)
                 .WaitWithStopCondition(PlaceVacuumStep.CheckChuckOut, () => CommonFunction.CheckRoutineEndState(_chuckRoutine), () => CommonFunction.CheckRoutineStopState(_chuckRoutine))
                 .Run(PlaceVacuumStep.VacuumOff, VacuumOff, _delay_1ms)
-                .Delay(PlaceVacuumStep.VacuumDelay,500)
+                .Delay(PlaceVacuumStep.VacuumDelay,_delay_1s)
                 .Run(PlaceVacuumStep.ChuckIn, () => { return _chuckRoutine.Start(false) == RState.Running; }, NullFun, 100)
                 .WaitWithStopCondition(PlaceVacuumStep.CheckChuckIn, () => CommonFunction.CheckRoutineEndState(_chuckRoutine), () => CommonFunction.CheckRoutineStopState(_chuckRoutine))
                 .Run(PlaceVacuumStep.VacuumOn, VacuumOn, _delay_1ms)

+ 36 - 1
CyberX8_RT/Modules/Transporter/TransporterEntity.cs

@@ -187,11 +187,46 @@ namespace CyberX8_RT.Modules.Transporter
             return true;
         }
         /// <summary>
+        /// 检验所有电机是否已经完成Home
+        /// </summary>
+        /// <returns></returns>
+        private bool CheckAllAxisIsHomed()
+        {
+            bool gantryIsHomed = _gantryAxis.CheckAxisIsAreadyHomed();
+            if (!gantryIsHomed)
+            {
+                return false;
+            }
+            bool elevatorIsHomed = _elevatorAxis.CheckAxisIsAreadyHomed();
+            if (!elevatorIsHomed)
+            {
+                return false;
+            }
+            bool elevatoeUp = _elevatorAxis.CheckPositionIsInStation(_elevatorAxis.MotionData.MotorPosition, "UP");
+            if (!elevatorIsHomed)
+            {
+                return false;
+            }
+            if (WaferHolderInfo != null)
+            {
+                return false;
+            }
+            return true;
+        }
+        /// <summary>
         /// 初始化状态机
         /// </summary>
         private void InitialFsm()
         {
-            fsm = new StateMachine<TransporterEntity>(Module.ToString(), (int)TransporterState.Init, 100);
+            if (CheckAllAxisIsHomed())
+            {
+                _isHomed = true;
+                fsm = new StateMachine<TransporterEntity>(Module.ToString(), (int)TransporterState.Idle, 100);
+            }
+            else
+            {
+                fsm = new StateMachine<TransporterEntity>(Module.ToString(), (int)TransporterState.Init, 100);
+            }
             fsm.EnableRepeatedMsg(true);
 
             AnyStateTransition(TransporterMSG.Error, EnterError, TransporterState.Error);

+ 33 - 28
Framework/Common/Device/PowerSupplier/PowerSupplierModbusDevice.cs

@@ -42,13 +42,14 @@ namespace MECF.Framework.Common.Device.PowerSupplier
         #region 内部变量
         private string _name;
         private string _lastErrorMsg = "";
+        private bool _isFirstConnected = false;
         #endregion
         /// <summary>
         /// 构造函数
         /// </summary>
         /// <param name="ip"></param>
         /// <param name="port"></param>
-        public PowerSupplierModbusDevice(string name,string ip, int port) : base(ip, port)
+        public PowerSupplierModbusDevice(string name, string ip, int port) : base(ip, port)
         {
             ReceiveTimeout = 1000;
             SendTimeout = 1000;
@@ -63,6 +64,10 @@ namespace MECF.Framework.Common.Device.PowerSupplier
         public void Start()
         {
             Connect();
+            if (!_isFirstConnected)
+            {
+                _isFirstConnected = true;
+            }
         }
         /// <summary>
         /// 设置通道输出开关控制
@@ -86,7 +91,7 @@ namespace MECF.Framework.Common.Device.PowerSupplier
         /// <param name="channel"></param>
         /// <param name="currentValue"></param>
         /// <returns></returns>
-        public bool SetChannelPowerControl(byte channel,byte remoteControl)
+        public bool SetChannelPowerControl(byte channel, byte remoteControl)
         {
             PowerSupplierCommand command = new PowerSupplierCommand();
             command.Channel = channel;
@@ -101,7 +106,7 @@ namespace MECF.Framework.Common.Device.PowerSupplier
         /// <param name="channel"></param>
         /// <param name="currentValue"></param>
         /// <returns></returns>
-        public bool SetChannelPowerRunmodelControl(byte channel,byte model)
+        public bool SetChannelPowerRunmodelControl(byte channel, byte model)
         {
             PowerSupplierCommand command = new PowerSupplierCommand();
             command.Channel = channel;
@@ -115,25 +120,25 @@ namespace MECF.Framework.Common.Device.PowerSupplier
         /// </summary>
         /// <param name="channel"></param>
         /// <param name="stepDatas"></param>
-        public bool SetStepPeriod(byte channel,List<PowerSupplierStepPeriodData> stepDatas,int scale)
+        public bool SetStepPeriod(byte channel, List<PowerSupplierStepPeriodData> stepDatas, int scale)
         {
             PowerSupplierCommand command = new PowerSupplierCommand();
             command.Channel = channel;
             command.CommandCode = 0x10;
             command.Address = (ushort)STEP_PERIOD_ADDRESS;
-            command.RegisterCount =(ushort)(STEP_PERIOD_LENGTH * stepDatas.Count);
+            command.RegisterCount = (ushort)(STEP_PERIOD_LENGTH * stepDatas.Count);
             command.Datas = new ushort[STEP_PERIOD_LENGTH * stepDatas.Count];
-            for(int i = 0;i<stepDatas.Count;i++)
+            for (int i = 0; i < stepDatas.Count; i++)
             {
                 PowerSupplierStepPeriodData data = stepDatas[i];
-                command.Datas[0 + STEP_PERIOD_LENGTH * i] = (ushort)6000;
-                command.Datas[1 + STEP_PERIOD_LENGTH * i] = (ushort)Math.Round(stepDatas[i].Current*scale,0);
+                command.Datas[0 + STEP_PERIOD_LENGTH * i] = (ushort)(data.Voltage * 1000);
+                command.Datas[1 + STEP_PERIOD_LENGTH * i] = (ushort)Math.Round(stepDatas[i].Current * scale, 0);
                 command.Datas[2 + STEP_PERIOD_LENGTH * i] = stepDatas[i].Hour;
-                command.Datas[3+STEP_PERIOD_LENGTH*i]= stepDatas[i].Minute;
-                command.Datas[4+STEP_PERIOD_LENGTH*i]= stepDatas[i].Second;
+                command.Datas[3 + STEP_PERIOD_LENGTH * i] = stepDatas[i].Minute;
+                command.Datas[4 + STEP_PERIOD_LENGTH * i] = stepDatas[i].Second;
                 command.Datas[5 + STEP_PERIOD_LENGTH * i] = stepDatas[i].Microsecond;
             }
-            return SetOperation(command);            
+            return SetOperation(command);
         }
         /// <summary>
         /// 启动步阶
@@ -142,14 +147,14 @@ namespace MECF.Framework.Common.Device.PowerSupplier
         /// <param name="startStep"></param>
         /// <param name="endStep"></param>
         /// <param name="cycle"></param>
-        public bool StartStepPeriod(byte channel,ushort startStep,ushort endStep,ushort cycle)
+        public bool StartStepPeriod(byte channel, ushort startStep, ushort endStep, ushort cycle)
         {
             PowerSupplierCommand command = new PowerSupplierCommand();
             command.Channel = channel;
             command.CommandCode = 0x10;
             command.Address = (ushort)STEP_PERIOD_START_ADDRESS;
             command.RegisterCount = 3;
-            command.Datas = new ushort[3] { startStep,endStep,cycle };
+            command.Datas = new ushort[3] { startStep, endStep, cycle };
             return SetOperation(command);
         }
 
@@ -159,7 +164,7 @@ namespace MECF.Framework.Common.Device.PowerSupplier
         /// <param name="channel"></param>
         /// <param name="currentValue"></param>
         /// <returns></returns>
-        public bool SetCurrentValue(byte channel,ushort currentValue)
+        public bool SetCurrentValue(byte channel, ushort currentValue)
         {
             PowerSupplierCommand command = new PowerSupplierCommand();
             command.Channel = channel;
@@ -196,7 +201,7 @@ namespace MECF.Framework.Common.Device.PowerSupplier
             applyCommand.CommandCode = 0x03;
             applyCommand.Address = (ushort)(OUTPUT_CONTROL_ADDRESS);
             applyCommand.RegisterCount = 1;
-            applyCommand.Variables.Add(ENABLED,(0,1));
+            applyCommand.Variables.Add(ENABLED, (0, 1));
             ApplyDataOperation(applyCommand);
         }
         /// <summary>
@@ -226,7 +231,7 @@ namespace MECF.Framework.Common.Device.PowerSupplier
             applyCommand.CommandCode = 0x03;
             applyCommand.Address = (ushort)(CURRENT_SETTING_ADDRESS);
             applyCommand.RegisterCount = 1;
-            applyCommand.Variables.Add(SET_POINT,(0,1));
+            applyCommand.Variables.Add(SET_POINT, (0, 1));
             ApplyDataOperation(applyCommand);
         }
 
@@ -242,7 +247,7 @@ namespace MECF.Framework.Common.Device.PowerSupplier
             applyCommand.CommandCode = 0x03;
             applyCommand.Address = (ushort)(POWER_STATUS_ADDRESS);
             applyCommand.RegisterCount = 1;
-            applyCommand.Variables.Add(POWER_STATUS, (0,1));
+            applyCommand.Variables.Add(POWER_STATUS, (0, 1));
             ApplyDataOperation(applyCommand);
         }
 
@@ -273,8 +278,8 @@ namespace MECF.Framework.Common.Device.PowerSupplier
             applyCommand.CommandCode = 0x03;
             applyCommand.Address = (ushort)(VOLTAGE_OUTPUT_ADDRESS);
             applyCommand.RegisterCount = 4;
-            applyCommand.Variables.Add(VOLTAGE,(0,2));
-            applyCommand.Variables.Add(CURRENT,(2,2));
+            applyCommand.Variables.Add(VOLTAGE, (0, 2));
+            applyCommand.Variables.Add(CURRENT, (2, 2));
             ApplyDataOperation(applyCommand);
         }
         /// <summary>
@@ -297,7 +302,7 @@ namespace MECF.Framework.Common.Device.PowerSupplier
             else
             {
                 NetResult netResult = Connect();
-                if(netResult.IsSuccess)
+                if (netResult.IsSuccess)
                 {
                     netResult = SetData(command);
                     if (!netResult.IsSuccess)
@@ -335,26 +340,26 @@ namespace MECF.Framework.Common.Device.PowerSupplier
                 WriteErrMsg($"apply {command.Address.ToString("X2")} failed,{netResult.Message}");
                 return;
             }
-            if(netResult.Data.Datas!=null)
+            if (netResult.Data.Datas != null)
             {
-                Dictionary<string, (int,int)> dictionary = command.Variables;
+                Dictionary<string, (int, int)> dictionary = command.Variables;
                 List<string> keys = dictionary.Keys.ToList();
-                foreach(string item in keys)
+                foreach (string item in keys)
                 {
                     var result = dictionary[item];
-                    if(item==ENABLED)
+                    if (item == ENABLED)
                     {
                         PowerSupplierDeviceConfigManager.Instance.UpdateModuleVariable(_name, command.Channel, ENABLED, netResult.Data.Datas[result.Item1] == 0x01);
                     }
                     else
                     {
-                        if(result.Item2==1)
+                        if (result.Item2 == 1)
                         {
                             PowerSupplierDeviceConfigManager.Instance.UpdateModuleVariable(_name, command.Channel, item, netResult.Data.Datas[result.Item1]);
                         }
-                        else if(result.Item2==2)
+                        else if (result.Item2 == 2)
                         {
-                            int value = netResult.Data.Datas[result.Item1] * 0xFFFF + netResult.Data.Datas[result.Item1+1];
+                            int value = netResult.Data.Datas[result.Item1] * 0xFFFF + netResult.Data.Datas[result.Item1 + 1];
                             PowerSupplierDeviceConfigManager.Instance.UpdateModuleVariable(_name, command.Channel, item, value);
                         }
                     }
@@ -367,7 +372,7 @@ namespace MECF.Framework.Common.Device.PowerSupplier
         /// <param name="msg"></param>
         private void WriteErrMsg(string msg)
         {
-            if (msg!=_lastErrorMsg)
+            if (msg != _lastErrorMsg)
             {
                 _lastErrorMsg = msg;