Browse Source

revise platingcell run recipe bug

chenzk 1 week ago
parent
commit
5ab36c422a

+ 2 - 2
PunkHPX8_RT/Devices/AXIS/JetAxisBase.cs

@@ -1143,13 +1143,13 @@ namespace PunkHPX8_RT.Devices.AXIS
         /// <param name="sourceLocation"></param>
         /// <param name="destinationLocation"></param>
         /// <returns>返回值单位毫秒</returns>
-        public int CalculateVerticaMoveTime(string AxisName,string sourceLocation, string destinationLocation)
+        public int CalculateVerticaMoveTime(string AxisName,string sourceLocation, string destinationLocation,double sourceOffset=0,double destinationOffset = 0)
         {
             Station sourceStation = _stationAxis.Stations.FirstOrDefault(p => p.Name == $"{AxisName}.{sourceLocation}");
             Station destinationStation = _stationAxis.Stations.FirstOrDefault(p => p.Name == $"{AxisName}.{destinationLocation}");
             Double.TryParse(sourceStation.Position, out double sourcePosition);
             Double.TryParse(destinationStation.Position, out double destinationPosition);
-            double time = Math.Abs(destinationPosition - sourcePosition) / MotionData.ProfileVelocity * 1000;
+            double time = Math.Abs(destinationPosition + destinationOffset - sourcePosition - sourceOffset) / _profileVelocity * 1000;
             if (time <= 0)
             {
                 return 0;

+ 17 - 2
PunkHPX8_RT/Devices/PowerSupplier/CellPowerSupplier.cs

@@ -539,7 +539,22 @@ namespace PunkHPX8_RT.Devices.PowerSupplier
                 LOG.WriteLog(eEvent.ERR_POWERSUPPLIER, Module, "Power Supplier is local control");
                 return false;
             }
-            bool result= PowerSupplierDeviceConfigManager.Instance.SetChannelOutputSwitchControl(Module, _channel, true);
+            if( PowerSupplierData.SetPoint > 0.02 && PowerSupplierData.PowerGrade == 0)
+            {
+                LOG.WriteLog(eEvent.ERR_POWERSUPPLIER, Module, $"Power grade is low,Current setpoint{PowerSupplierData.SetPoint} large than 0.02A");
+                return false;
+            }
+            if (PowerSupplierData.SetPoint > 0.6 && PowerSupplierData.PowerGrade == 1)
+            {
+                LOG.WriteLog(eEvent.ERR_POWERSUPPLIER, Module, $"Power grade is middle,Current setpoint{PowerSupplierData.SetPoint} large than 0.6A");
+                return false;
+            }
+            if (PowerSupplierData.SetPoint > 20 && PowerSupplierData.PowerGrade == 2)
+            {
+                LOG.WriteLog(eEvent.ERR_POWERSUPPLIER, Module, $"Power grade high,Current setpoint{PowerSupplierData.SetPoint} large than 20A");
+                return false;
+            }
+            bool result = PowerSupplierDeviceConfigManager.Instance.SetChannelOutputSwitchControl(Module, _channel, true);
             _sendDateTime = DateTime.Now;
             _readCommandList.Enqueue(ENABLED);
             _readCommandList.Enqueue(POWER_STATUS);
@@ -627,7 +642,7 @@ namespace PunkHPX8_RT.Devices.PowerSupplier
             byte grade = (byte)args[0];
             PowerSupplierDeviceConfigManager.Instance.SetPowerRunmodelControl(Module, _channel, (byte)PowerRunModelEnum.Normal);
             bool result = PowerSupplierDeviceConfigManager.Instance.SetPowerGrade(Module, _channel, grade);
-            if (result) //挡位设置成功则默认当前挡位
+            if (result) //挡位设置成功则默认当前是设置的挡位
             {
                 PowerSupplierData.PowerGrade = grade;
             }

+ 3 - 3
PunkHPX8_RT/Modules/PlatingCell/PlatingCellDepositionRoutine.cs

@@ -116,9 +116,9 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         {               //没有上电保护,此刻给电
             Runner.RunIf(RunRecipeStep.RunPowerStep, _recipe.IsEntryTypeCold, StartPowerStep, _delay_1ms)
                 .LoopStart(RunRecipeStep.LoopRotationStart, "Start rotation cycle",_recipe.DepStepCount,NullFun)
-                //vertical 调整位置
-                .LoopRunIf(RunRecipeStep.LoopVerticalGotoOffSet, _recipe.DepSteps[_depositionStepIndex].PlatingZoffset!=0, () => StartVertical("Plate", _recipe.DepSteps[_depositionStepIndex].PlatingZoffset),_delay_1ms)
-                .LoopRunIf(RunRecipeStep.LoopVerticalGotoOffSetCheck, _recipe.DepSteps[_depositionStepIndex].PlatingZoffset!=0, CheckVerticalEnd, CheckVerticalError)
+                //vertical 调整位置(第一步不用调,entry过程已经走到位置了)
+                .LoopRunIf(RunRecipeStep.LoopVerticalGotoOffSet, _recipe.DepSteps[_depositionStepIndex].PlatingZoffset!=0 && _depositionStepIndex!=0, () => StartVertical("Plate", _recipe.DepSteps[_depositionStepIndex].PlatingZoffset),_delay_1ms)
+                .LoopRunIf(RunRecipeStep.LoopVerticalGotoOffSetCheck, _recipe.DepSteps[_depositionStepIndex].PlatingZoffset!=0 && _depositionStepIndex != 0, CheckVerticalEnd, CheckVerticalError)
                 
                 //不带双向旋转,时间到了直接变速(如果当前电机是停止状态,启动起来)
                 .LoopRunIf(RunRecipeStep.LoopRotationStartIfCurrentIsStoped, CheckRotationIsIdle() && !_recipe.DepSteps[_depositionStepIndex].BiDireaction,

+ 5 - 5
PunkHPX8_RT/Modules/PlatingCell/PlatingCellEntryRoutine.cs

@@ -100,7 +100,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
                 //Angle tilt 操作
                 .Run(RunRecipeStep.AngleTilt, _device.HeadtTiltAction, () => { return _device.PlatingCellDeviceData.IsHeadTilt; }, _delay_1s)
                 //vertical goto plate
-                .Run(RunRecipeStep.VerticalGotoPlate, () => { return StartVertical("Plate", _recipe.EntryZoffset); }, _delay_1ms)
+                .Run(RunRecipeStep.VerticalGotoPlate, () => { return StartVertical("Plate", _recipe.DepSteps[0].PlatingZoffset); }, _delay_1ms)
                 //vertical 到达entry位置前110ms (多10ms)
                 .Delay(RunRecipeStep.WaitEntryCurrentProtectedFromRinse, CalculatePowerDelayTime())
                 //有上电保护,此刻给电
@@ -110,7 +110,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
                 //Angle vertical操作
                 .Run(RunRecipeStep.AngleVertical, _device.HeadtVerticalAction, () => { return _device.PlatingCellDeviceData.IsHeadVertical; }, _delay_1s)
                 //如果不需要上电保护,执行plating delay
-                .RunIf(RunRecipeStep.WaitPlatingDelay, _recipe.IsEntryTypeCold, NullFun, _recipe.PlatingDelay)
+                .DelayIf(RunRecipeStep.WaitPlatingDelay, _recipe.IsEntryTypeCold, _recipe.PlatingDelay * 1000)
                 .End(RunRecipeStep.End, NullFun);
             return Runner.Status;
         }
@@ -121,13 +121,13 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         private int CalculatePowerDelayTime()
         {
             int delayTime = 0;
-            if (!_recipe.RinseBeforeEntryEnable)
+            if (_recipe.RinseBeforeEntryEnable)
             {
-                delayTime = _verticalAxis.CalculateVerticaMoveTime($"{_verticalAxis.Module}.Vertical", "Rinse", "Entry") - 110;
+                delayTime = _verticalAxis.CalculateVerticaMoveTime($"{_verticalAxis.Module}.Vertical", "Rinse", "Entry", 0 ,_recipe.EntryZoffset) - 110;
             }
             else
             {
-                delayTime = _verticalAxis.CalculateVerticaMoveTime($"{_verticalAxis.Module}.Vertical", "Home", "Entry") - 110;
+                delayTime = _verticalAxis.CalculateVerticaMoveTime($"{_verticalAxis.Module}.Vertical", "Load", "Entry", 0, _recipe.EntryZoffset) - 110;
 
             }
             return delayTime;

+ 7 - 5
PunkHPX8_RT/Modules/PlatingCell/PlatingCellRunRecipeRoutine.cs

@@ -342,10 +342,12 @@ namespace PunkHPX8_RT.Modules.PlatingCell
                 return RState.Failed;
             }
             CalculatVerticalPosition(_recipe);
-            UpdatePowerStepDatas();
+            if (!UpdatePowerStepDatas())
+            {
+                NotifyError(eEvent.ERR_PLATINGCELL, $"Update Power StepDatas Failed!", 0);
+                return RState.Failed;
+            }
             _currentCycle = 0;
-
- 
             return Runner.Start(Module, "PlatingCell Run Recipe");
         }
         /// <summary>
@@ -354,6 +356,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
         private bool UpdatePowerStepDatas()
         {
             _isZeroCurrent = false;
+            _isRecipeContainsRevserseRotation = false;
             double current = 0;
             _totalMicrosecond = 0;
             _powerSupplierStepPeriodDatas.Clear();
@@ -395,7 +398,7 @@ namespace PunkHPX8_RT.Modules.PlatingCell
             }
             else
             {
-                return  _device.PowerSupplier.SetPowerGrade("set power grade high", new object[] { (byte)1 });
+                return  _device.PowerSupplier.SetPowerGrade("set power grade middle", new object[] { (byte)1 });
             }
         }
         /// <summary>
@@ -427,7 +430,6 @@ namespace PunkHPX8_RT.Modules.PlatingCell
                 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");