123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
- using MECF.Framework.RT.ModuleLibrary.Commons;
- using MECF.Framework.RT.ModuleLibrary.VceModules;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Venus_Core;
- using Venus_RT.Devices;
- using Venus_RT.Devices.TM;
- using Venus_RT.Devices.VCE;
- using Venus_RT.Modules.TM.VenusEntity;
- namespace Venus_RT.Modules.VCE
- {
- public class LoadRoutine : ModuleRoutineBase, IRoutine
- {
- private enum LoadStep
- {
- CloseOutDoor,
- GotoLP,
- Mapping,
- ReadMap,
- VcePumpDown,
- OpenInnerDoor,
- NotifyOver
- }
- VceModuleBase _vce;
- TMBase _tm;
- int _timeout;
- SEMFPumpRoutine pumpRoutine;
- bool _isATMMode = false;
- public LoadRoutine(ModuleName module, VceModuleBase vce) : base(module)
- {
- _vce = vce;
- if (module == ModuleName.VCE1)
- _tm = DEVICE.GetDevice<HongHuTM>("SETM");
- else
- _tm = DEVICE.GetDevice<HongHuDETM>("DETM");
- pumpRoutine = new SEMFPumpRoutine(_tm, module);
- _isATMMode = SC.GetValue<bool>("System.IsATMMode");
- }
- public RState Start(params object[] objs)
- {
- _timeout = SC.GetValue<int>($"{Module}.MotionTimeout") *1000;
- //if vce inner door not close cannot do it as it will pump
- if (!Singleton<RouteManager>.Instance.seTM.IsVCESlitDoorClosed(Module))
- {
- LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE Inner Door is open! Please close it First!");
- return RState.Failed;
- }
- Reset();
- return Runner.Start(Module,"Vce Load Routine");
- }
- public RState Monitor()
- {
- Runner.Run(LoadStep.CloseOutDoor, CloseOutDoor, CheckVceIdle, _timeout)
- .Run(LoadStep.GotoLP, _vce.GotoLP, CheckVceIdle, _timeout)
- .RunIf(LoadStep.VcePumpDown, !_isATMMode, PumpDown, CheckPumpOver)
- .Run(LoadStep.Mapping, Mapping, CheckVceIdle, 25 *1000)
- .Run(LoadStep.ReadMap, ReadMap, CheckVceIdle, _timeout)
- .Run(LoadStep.OpenInnerDoor, OpenInnerDoor, CheckInnerDoorOpen)
- .End(LoadStep.NotifyOver, NullFun, 100);
- return Runner.Status;
- }
- private bool CheckInnerDoorOpen()
- {
- return !_tm.VCESlitDoorClosed(Module);
- }
- private bool OpenInnerDoor()
- {
- return _tm.TurnSlitDoor(Module,true);
- }
- //
- private bool CheckPumpOver()
- {
- RState ret = pumpRoutine.Monitor();
- if (ret == RState.Failed || ret == RState.Timeout)
- {
- Singleton<RouteManager>.Instance.VCE.PostMsg(VceMSG.Error);
- }
- return ret == RState.End;
- }
- private bool PumpDown()
- {
- return pumpRoutine.Start() == RState.Running;
- }
- private bool ReadMap()
- {
- return _vce.ReadMap();
- }
- private bool Mapping()
- {
- return _vce.Map();
- }
- private bool CloseOutDoor()
- {
- return _vce.CloseDoor();
- }
- private bool CheckVceIdle()
- {
- if (_vce.Status == RState.Failed || _vce.Status == RState.Timeout)
- {
- Singleton<RouteManager>.Instance.GetVCE(Module).PostMsg(VceMSG.Error);
- return false;
- }
- return _vce.Status == RState.End;
- }
- public void Abort()
- {
- }
- }
- }
|