123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using MECF.Framework.Common.Routine;
- using CyberX8_Core;
- using CyberX8_RT.Devices.AXIS;
- using CyberX8_RT.Devices.PUF;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using MECF.Framework.Common.Utilities;
- namespace CyberX8_RT.Modules.PUF
- {
- public class PufPlaceVacuumCheckRoutine : RoutineBase, IRoutine
- {
- private enum PlaceVacuumStep
- {
- ChuckOut,
- CheckChuckOut,
- VacuumOff,
- VacuumDelay,
- ChuckIn,
- CheckChuckIn,
- VacuumOn,
- Delay,
- VacuumCheck,
- End
- }
- #region 常量
- private const string SideA = "SideA";
- private const string SideB = "SideB";
- private const string WAFER_ABSENT = "WaferAbsent";
- #endregion
- #region 内部变量
- private PufVacuum _vacuum;
- private PufChuckRoutine _chuckRoutine;
- private string _side = "SideA";
- /// <summary>
- /// 是否显示Routine错误
- /// </summary>
- private bool _showError = true;
- /// <summary>
- /// 第几次
- /// </summary>
- private int _times=1;
- /// <summary>
- /// 延迟时间
- /// </summary>
- private int _chuckValveSwitchingTimeDelayInMilliSeconds = 100;
- /// <summary>
- /// 是否处于模拟器
- /// </summary>
- private bool _isSimulator = false;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public PufPlaceVacuumCheckRoutine(string module) : base(module)
- {
- _isSimulator = SC.GetValue<bool>("System.IsSimulatorMode");
- _chuckRoutine = new PufChuckRoutine(module);
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- Runner.Stop("Manual abort");
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- 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)
- .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)
- .Delay(PlaceVacuumStep.Delay, _chuckValveSwitchingTimeDelayInMilliSeconds)
- .Run(PlaceVacuumStep.VacuumCheck, CheckWaferPresent,NullFun, _delay_1ms,_showError)
- .End(PlaceVacuumStep.End, NullFun, _delay_1ms);
- return Runner.Status;
- }
- /// <summary>
- /// 关闭Vacuum
- /// </summary>
- /// <returns></returns>
- private bool VacuumOff()
- {
- if (_side == SideA)
- {
- return _vacuum.VacuumAOff();
- }
- else if (_side == SideB)
- {
- return _vacuum.VacuumBOff();
- }
- return false;
- }
- /// <summary>
- /// 打开Vacuum
- /// </summary>
- /// <returns></returns>
- private bool VacuumOn()
- {
- if (_side == SideA)
- {
- return _vacuum.VacuumAOn();
- }
- else if (_side == SideB)
- {
- return _vacuum.VacuumBOn();
- }
- return false;
- }
- /// <summary>
- /// 检验存在Wafer
- /// </summary>
- /// <returns></returns>
- private bool CheckWaferPresent()
- {
- if(_isSimulator)
- {
- return true;
- }
- if (_side == SideA)
- {
- return _vacuum.ChuckAVacuumStatus == WAFER_ABSENT;
- }
- else if (_side == SideB)
- {
- return _vacuum.ChuckBVacuumStatus == WAFER_ABSENT;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- _side = objs[0].ToString();
- _showError = objs.Length > 1 ? (bool)objs[1] : true;
- _times = objs.Length > 2 ? (int)objs[2] : 1;
- _vacuum = DEVICE.GetDevice<PufVacuum>($"{Module}.Vacuum");
- _chuckValveSwitchingTimeDelayInMilliSeconds = SC.GetValue<int>($"{Module}.ChuckValveSwitchingTimeDelayInMilliSeconds");
- return Runner.Start(Module, $"Start {_times} Place Vacuum Check");
- }
- }
- }
|