| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using MECF.Framework.Common.Beckhoff.ModuleIO;
- using MECF.Framework.Common.CommonData.PlatingCell;
- using MECF.Framework.Common.IOCore;
- using MECF.Framework.Common.Routine;
- using PunkHPX8_Core;
- using PunkHPX8_RT.Devices.SRD;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- namespace PunkHPX8_RT.Devices.PlatingCell
- {
- public class ClamShellCloseRoutine : RoutineBase, IRoutine
- {
- private enum ClamshellClose
- {
- ClamShellClose,
- End
- }
- #region 常量
- private const string CLAMSHELL_CLOSE = "ClamShellClose";
- #endregion
- #region 内部变量
- private bool _close;
- private PlatingCellDevice _device;
- private int _openSensor = 55;
- private int _closeSensor = 5;
- private int _sensorCheckTime = 1000;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public ClamShellCloseRoutine(string module):base(module)
- {
- }
- public void Abort()
- {
- Runner.Stop("Manual Abort");
- }
- public RState Monitor()
- {
- Runner.Run(ClamshellClose.ClamShellClose, ClamShellClose, CheckClamShellClose, _sensorCheckTime)
- .End(ClamshellClose.End, NullFun, 100);
- return Runner.Status;
- }
- private bool ClamShellClose()
- {
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{CLAMSHELL_CLOSE}");
- return IOModuleManager.Instance.WriteIoValue(ioName, _close);
- }
- private bool CheckClamShellClose()
- {
- if (_close)
- {
- if (_device.PlatingCellDeviceData.ClamShellDistance >= _closeSensor) //大于close sensor就算关
- {
- LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module, $"ClamShell is Closed");
- //_device.PlatingCellDeviceData.ClamShellClosed = true;
- //_device.PlatingCellDeviceData.ClamShellOpened = false;
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- if (_device.PlatingCellDeviceData.ClamShellDistance <= _openSensor) //open sensor就算开
- {
- LOG.WriteLog(eEvent.INFO_PLATINGCELL, Module, $"ClamShell is Opened");
- //_device.PlatingCellDeviceData.ClamShellClosed = false;
- //_device.PlatingCellDeviceData.ClamShellOpened = true;
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- public RState Start(params object[] objs)
- {
- _close = (bool)objs[0];
- _device = DEVICE.GetDevice<PlatingCellDevice>($"{Module}");
- _openSensor = SC.GetValue<int>("PlatingCell.ClamShellOpenDistanceThreshold");
- _closeSensor = SC.GetValue<int>("PlatingCell.ClamShellCloseDistanceThreshold");
- _sensorCheckTime = SC.GetValue<int>("PlatingCell.ClamShellOpenCheckDelay");
- if (_close)
- {
- return Runner.Start(Module, "ClamShell Close");
- }
- else
- {
- return Runner.Start(Module, "ClamShell Open");
- }
- }
- }
- }
|