123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using Aitex.Core.Common;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.UI.Control;
- using CyberX8_Core;
- using MECF.Framework.Common.Beckhoff.ModuleIO;
- using MECF.Framework.Common.IOCore;
- using MECF.Framework.Common.Routine;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- namespace CyberX8_RT.Devices.SRD
- {
- public class SrdCommonFlipperRoutine : RoutineBase, IRoutine
- {
- #region 常量
- private const string FLIPPERS_IN_100 = "FlippersIn100";
- private const string FLIPPERS_IN_150 = "FlippersIn150";
- private const string FLIPPERS_IN_200 = "FlippersIn200";
- #endregion
- private enum FlipperStep
- {
- Flipper,
- Delay,
- CheckFlipperStatus,
- End
- }
- #region 内部变量
- private bool _flipperIn;
- private int _waferSize = 200;
- private SrdCommonDevice _srdCommon;
- private int _timeout = 3000;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public SrdCommonFlipperRoutine(string module) : base(module)
- {
- }
- public void Abort()
- {
- Runner.Stop("Manual Abort");
- }
- public RState Monitor()
- {
- Runner.Run(FlipperStep.Flipper, FlipperPosition, _delay_1ms)
- .DelayIf(FlipperStep.Delay, !_flipperIn, 500)
- .Run(FlipperStep.CheckFlipperStatus, NullFun, CheckFlipperOutEndStatus, _timeout)
- .End(FlipperStep.End, NullFun, 100);
- return Runner.Status;
- }
- public RState Start(params object[] objs)
- {
- if (objs.Length < 2) return RState.Failed;
- _flipperIn = (bool)objs[0];
- _waferSize = (int)objs[1];
- _srdCommon = DEVICE.GetDevice<SrdCommonDevice>($"{Module}.Common");
- if (_flipperIn)
- {
- return Runner.Start(Module, "Flippers In");
- }
- else
- {
- return Runner.Start(Module, "Flippers Out");
- }
- }
- /// <summary>
- /// Flipper Position
- /// </summary>
- /// <returns></returns>
- private bool FlipperPosition()
- {
- string variableName;
- switch (_waferSize)
- {
- case 100:
- variableName = FLIPPERS_IN_100;
- break;
- case 150:
- variableName = FLIPPERS_IN_150;
- break;
- case 200:
- variableName = FLIPPERS_IN_200;
- break;
- default:
- NotifyError(eEvent.ERR_SRD, $"Wafer Size {_waferSize} is invalid", 0);
- return false;
- }
- string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{variableName}");
- return IOModuleManager.Instance.WriteIoValue(ioName, _flipperIn);
- }
- /// <summary>
- /// CheckFlipperOutStatus
- /// </summary>
- /// <returns></returns>
- private bool CheckFlipperOutEndStatus()
- {
- bool result = false;
- switch (_waferSize)
- {
- case 100:
- result = _flipperIn ? (!_srdCommon.CommonData.Flipper1Out100Status && !_srdCommon.CommonData.Flipper2Out100Status && !_srdCommon.CommonData.Flipper3Out100Status)
- : (_srdCommon.CommonData.Flipper1Out100Status && _srdCommon.CommonData.Flipper2Out100Status && _srdCommon.CommonData.Flipper3Out100Status);
- break;
- case 150:
- result = _flipperIn ? (!_srdCommon.CommonData.Flipper1Out150Status && !_srdCommon.CommonData.Flipper2Out150Status && !_srdCommon.CommonData.Flipper3Out150Status)
- : (_srdCommon.CommonData.Flipper1Out150Status && _srdCommon.CommonData.Flipper2Out150Status && _srdCommon.CommonData.Flipper3Out150Status);
- break;
- case 200:
- result = _flipperIn ? (!_srdCommon.CommonData.Flipper1Out200Status && !_srdCommon.CommonData.Flipper2Out200Status && !_srdCommon.CommonData.Flipper3Out200Status)
- : (_srdCommon.CommonData.Flipper1Out200Status && _srdCommon.CommonData.Flipper2Out200Status && _srdCommon.CommonData.Flipper3Out200Status);
- break;
- default:
- NotifyError(eEvent.WARN_SRD, $"Wafer Size {_waferSize} is invalid", 0);
- result = false;
- break;
- }
- return result;
- }
- }
-
- }
|