12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Routine;
- using CyberX8_Core;
- using CyberX8_RT.Devices.PUF;
- using MECF.Framework.Common.Routine;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CyberX8_RT.Modules.PUF
- {
- public class PufChuckRoutine : RoutineBase, IRoutine
- {
- private enum ChuckStep
- {
- Chuck,
- ChuckWait,
- End
- }
- #region 内部变量
- private PufVacuum _pufVacuum;
- private bool _chuck;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public PufChuckRoutine(string module) : base(module)
- {
- _pufVacuum= DEVICE.GetDevice<PufVacuum>($"{Module}.Vacuum");
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- Runner.Stop("Manual abort");
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- Runner.Run(ChuckStep.Chuck, Chuck, _delay_1ms)
- .Wait(ChuckStep.ChuckWait, CheckChuck, _delay_5s)
- .End(ChuckStep.End, NullFun, _delay_1ms);
- return Runner.Status;
- }
- /// <summary>
- /// chuck操作
- /// </summary>
- /// <returns></returns>
- private bool Chuck()
- {
- if (_chuck)
- {
- return _pufVacuum.ChuckOn();
- }
- else
- {
- return _pufVacuum.ChuckOff();
- }
- }
- /// <summary>
- /// 检验chuck
- /// </summary>
- /// <returns></returns>
- private bool CheckChuck()
- {
- if (_chuck)
- {
- return _pufVacuum.CheckChuckOut();
- }
- else
- {
- return _pufVacuum.CheckChuckIn();
- }
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- _chuck=(bool)objs[0];
- return Runner.Start(Module, "Chuck");
- }
- }
- }
|