|
@@ -9,6 +9,9 @@ using PunkHPX8_RT.Modules.Transporter;
|
|
|
using MECF.Framework.Common.Beckhoff.ModuleIO;
|
|
|
using MECF.Framework.Common.Equipment;
|
|
|
using MECF.Framework.Common.Routine;
|
|
|
+using MECF.Framework.Common.Utilities;
|
|
|
+using System.Runtime.InteropServices;
|
|
|
+using PunkHPX8_RT.Devices.AXIS;
|
|
|
|
|
|
namespace PunkHPX8_RT.Devices.Safety
|
|
|
{
|
|
@@ -16,17 +19,22 @@ namespace PunkHPX8_RT.Devices.Safety
|
|
|
{
|
|
|
private enum SafetyAllOnStep
|
|
|
{
|
|
|
- Ready,
|
|
|
- SwitchOnProcessTransporter,
|
|
|
- WaitSwitchOnProcessTransporter,
|
|
|
- SwitchOnLoaderTransporter,
|
|
|
- WaitSwitchOnLoaderTransporter,
|
|
|
- SwitchOnLoader,
|
|
|
- WaitSwitchOnLoader,
|
|
|
- SwitchOnPuf1,
|
|
|
- WaitSwitchOnPuf1,
|
|
|
- SwitchOnPuf2,
|
|
|
- WaitSwitchOnPuf2,
|
|
|
+ VpwCell1SwitchOn,
|
|
|
+ WaitSwitchOnVpwCell1,
|
|
|
+ VpwCell2SwitchOn,
|
|
|
+ WaitSwitchOnVpwCell2,
|
|
|
+ PlatingCell1RotationSwitchOn,
|
|
|
+ WaitSwitchOnPlatingCell1Rotation,
|
|
|
+ PlatingCell2RotationSwitchOn,
|
|
|
+ WaitSwitchOnPlatingCell2Rotation,
|
|
|
+ PlatingCell3RotationSwitchOn,
|
|
|
+ WaitSwitchOnPlatingCell3Rotation,
|
|
|
+ PlatingCell4RotationSwitchOn,
|
|
|
+ WaitSwitchOnPlatingCell4Rotation,
|
|
|
+ PlatingCell12LiftSwitchOn,
|
|
|
+ WaitSwitchOnPlatingCell12Lift,
|
|
|
+ PlatingCell34LiftSwitchOn,
|
|
|
+ WaitSwitchOnPlatingCell34Lift,
|
|
|
SwitchOnSRD1,
|
|
|
WaitSwitchOnSRD1,
|
|
|
SwitchOnSRD2,
|
|
@@ -35,14 +43,16 @@ namespace PunkHPX8_RT.Devices.Safety
|
|
|
}
|
|
|
#region 内部变量
|
|
|
private SafetyDevice _device;
|
|
|
- /// <summary>
|
|
|
- /// SRD1
|
|
|
- /// </summary>
|
|
|
- private SRDEntity _srd1Entity;
|
|
|
- /// <summary>
|
|
|
- /// SRD2
|
|
|
- /// </summary>
|
|
|
- private SRDEntity _srd2Entity;
|
|
|
+ private JetAxisBase _vpwCell1Rotation;
|
|
|
+ private JetAxisBase _vpwCell2Rotation;
|
|
|
+ private JetAxisBase _platingCell1Rotation;
|
|
|
+ private JetAxisBase _platingCell2Rotation;
|
|
|
+ private JetAxisBase _platingCell3Rotation;
|
|
|
+ private JetAxisBase _platingCell4Rotation;
|
|
|
+ private JetAxisBase _platingCell12Lift;
|
|
|
+ private JetAxisBase _platingCell34Lift;
|
|
|
+ private JetAxisBase _srd1Rotation;
|
|
|
+ private JetAxisBase _srd2Rotation;
|
|
|
#endregion
|
|
|
/// <summary>
|
|
|
/// 构造函数
|
|
@@ -65,112 +75,45 @@ namespace PunkHPX8_RT.Devices.Safety
|
|
|
/// <returns></returns>
|
|
|
public RState Monitor()
|
|
|
{
|
|
|
- Runner.Run(SafetyAllOnStep.Ready, CheckReady, _delay_1ms)
|
|
|
- .RunIf(SafetyAllOnStep.SwitchOnSRD1, _srd1Entity!=null, SwitchOnSRD1, _delay_1ms)
|
|
|
- .WaitWithStopCondition(SafetyAllOnStep.WaitSwitchOnSRD1, CheckSwitchOnSRD1Complete, CheckSwitchOnSRD1Error)
|
|
|
- .RunIf(SafetyAllOnStep.SwitchOnSRD2, _srd2Entity!=null, SwitchOnSRD2, _delay_1ms)
|
|
|
- .WaitWithStopCondition(SafetyAllOnStep.WaitSwitchOnSRD2, CheckSwitchOnSRD2Complete, CheckSwitchOnSRD2Error)
|
|
|
+ Runner.RunIf(SafetyAllOnStep.VpwCell1SwitchOn,ModuleHelper.IsInstalled(ModuleName.VPW1),()=>SwitchOnAxis(_vpwCell1Rotation),_delay_1ms)
|
|
|
+ .WaitWithStopConditionIf(SafetyAllOnStep.WaitSwitchOnVpwCell1, ModuleHelper.IsInstalled(ModuleName.VPW1),
|
|
|
+ ()=>CheckSwitchOn(_vpwCell1Rotation),()=>CheckSwitchOnStopStatus(_vpwCell1Rotation))
|
|
|
+ .RunIf(SafetyAllOnStep.VpwCell2SwitchOn, ModuleHelper.IsInstalled(ModuleName.VPW2), () => SwitchOnAxis(_vpwCell2Rotation), _delay_1ms)
|
|
|
+ .WaitWithStopConditionIf(SafetyAllOnStep.WaitSwitchOnVpwCell2, ModuleHelper.IsInstalled(ModuleName.VPW2),
|
|
|
+ () => CheckSwitchOn(_vpwCell2Rotation), () => CheckSwitchOnStopStatus(_vpwCell2Rotation))
|
|
|
.End(SafetyAllOnStep.End, NullFun, _delay_1ms);
|
|
|
|
|
|
return Runner.Status;
|
|
|
}
|
|
|
-
|
|
|
- private bool CheckReady()
|
|
|
- {
|
|
|
- _srd1Entity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(ModuleName.SRD1.ToString());
|
|
|
- _srd2Entity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(ModuleName.SRD2.ToString());
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- #region SRD1
|
|
|
- /// <summary>
|
|
|
- /// Switch on SRD1 Motors
|
|
|
- /// </summary>
|
|
|
- /// <returns></returns>
|
|
|
- private bool SwitchOnSRD1()
|
|
|
- {
|
|
|
- return _srd1Entity.CheckToPostMessage<SRDState,SRDMSG>(eEvent.ERR_SRD, ModuleName.SRD1.ToString(), (int)SRDMSG.SwitchOn);
|
|
|
- }
|
|
|
/// <summary>
|
|
|
- /// 检查SRD1 Motors switchon是否完成
|
|
|
+ /// 电机SwitchOn
|
|
|
/// </summary>
|
|
|
+ /// <param name="axis"></param>
|
|
|
/// <returns></returns>
|
|
|
- private bool CheckSwitchOnSRD1Complete()
|
|
|
+ private bool SwitchOnAxis(JetAxisBase axis)
|
|
|
{
|
|
|
- if(_srd1Entity==null)
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
- if (_srd1Entity.IsRotationSwitchOn && _srd1Entity.IsArmSwitchOn)
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
+ return axis.SwitchOn();
|
|
|
}
|
|
|
/// <summary>
|
|
|
- /// 检查SRD1 Motors switchon是否出错
|
|
|
+ /// 检验电机是否上电
|
|
|
/// </summary>
|
|
|
+ /// <param name="axis"></param>
|
|
|
/// <returns></returns>
|
|
|
- private bool CheckSwitchOnSRD1Error()
|
|
|
+ private bool CheckSwitchOn(JetAxisBase axis)
|
|
|
{
|
|
|
- if (_srd1Entity == null)
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (_srd1Entity.IsError)
|
|
|
- {
|
|
|
- LOG.WriteLog(eEvent.ERR_SAFETY, Module, $"Switching On SRD1 Motors is failed");
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
+ return axis.IsSwitchOn && axis.Status == RState.End;
|
|
|
}
|
|
|
- #endregion
|
|
|
|
|
|
- #region SRD2
|
|
|
/// <summary>
|
|
|
- /// Switch on SRD2 Motors
|
|
|
+ /// 检验电机上电是否异常
|
|
|
/// </summary>
|
|
|
+ /// <param name="axis"></param>
|
|
|
/// <returns></returns>
|
|
|
- private bool SwitchOnSRD2()
|
|
|
+ private bool CheckSwitchOnStopStatus(JetAxisBase axis)
|
|
|
{
|
|
|
- return _srd2Entity.CheckToPostMessage<SRDState,SRDMSG>(eEvent.ERR_SRD, ModuleName.SRD2.ToString(), (int)SRDMSG.SwitchOn);
|
|
|
+ return axis.Status == RState.Failed;
|
|
|
}
|
|
|
/// <summary>
|
|
|
- /// 检查SRD2 Motors switchon是否完成
|
|
|
- /// </summary>
|
|
|
- /// <returns></returns>
|
|
|
- private bool CheckSwitchOnSRD2Complete()
|
|
|
- {
|
|
|
- if(_srd2Entity == null)
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
- if (_srd2Entity.IsRotationSwitchOn && _srd2Entity.IsArmSwitchOn)
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 检查SRD2 Motors switchon是否出错
|
|
|
- /// </summary>
|
|
|
- /// <returns></returns>
|
|
|
- private bool CheckSwitchOnSRD2Error()
|
|
|
- {
|
|
|
- if(_srd2Entity == null)
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (_srd2Entity.IsError)
|
|
|
- {
|
|
|
- LOG.WriteLog(eEvent.ERR_SAFETY, Module, $"Switching On SRD2 Motors is failed");
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
- /// <summary>
|
|
|
/// 启动
|
|
|
/// </summary>
|
|
|
/// <param name="objs"></param>
|
|
@@ -178,6 +121,8 @@ namespace PunkHPX8_RT.Devices.Safety
|
|
|
public RState Start(params object[] objs)
|
|
|
{
|
|
|
_device = DEVICE.GetDevice<SafetyDevice>(Module);
|
|
|
+ _vpwCell1Rotation = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.VPW1}.Rotation");
|
|
|
+ _vpwCell2Rotation = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.VPW2}.Rotation");
|
|
|
return Runner.Start(Module, $"Safety All On");
|
|
|
}
|
|
|
}
|