123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- using System.Threading;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.IOCore;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- namespace EFEM.RT.Devices
- {
- public enum LoadLockDoorState
- {
- Opened,
- Closed,
- Unknown
- }
- public class LoadLockDevice : BaseDevice, IDevice
- {
- private IoSensor _sensorDoorOpen;
- private IoSensor _sensorArmExtendEnable;
- private IoTrigger _triggerSafetytoPM;
- private IoTrigger _triggerRBNotExtendPM;
- private static DOAccessor _openAtmDoorSignal;
- private static DOAccessor _closeAtmDoorSignal;
- private static DIAccessor _openAtmDoorFeedback;
- private static DIAccessor _closeAtmDoorFeedback;
-
- private static DOAccessor _openVtmDoorSignal;
- private static DOAccessor _closeVtmDoorSignal;
- private static DIAccessor _openVtmDoorFeedback;
- private static DIAccessor _closeVtmDoorFeedback;
- private bool _isDoorControledByStation;
- private static RD_TRIG atmDoorTrig = new RD_TRIG();
- private static RD_TRIG vtmDoorTrig = new RD_TRIG();
- private static LoadLockDoorState atmDoorState = LoadLockDoorState.Unknown;
- private static LoadLockDoorState vtmDoorState = LoadLockDoorState.Unknown;
- private static bool isIdle;
- public bool IsDoorOpen => !_sensorDoorOpen.Value && _sensorArmExtendEnable.Value;
- public static bool IsDoorOpenedByStation => _openAtmDoorFeedback.Value && !_closeAtmDoorFeedback.Value;
- public static bool IsDoorClosedByStation => _closeAtmDoorFeedback.Value && !_openAtmDoorFeedback.Value;
- public static bool IsOuterDoorOpenedByStation => _openVtmDoorFeedback.Value && !_closeVtmDoorFeedback.Value;
- public static bool IsOuterDoorClosedByStation => _closeVtmDoorFeedback.Value && !_openVtmDoorFeedback.Value;
-
- public static bool IsIdle => isIdle;
- private static bool isSimulator = SC.GetValue<bool>("System.IsSimulatorMode");
- private static bool isDoorAlwaysOpen = SC.GetValue<bool>("System.IsLoadLockDoorAlwaysOpen");
- public static RD_TRIG AtmDoorTrig
- {
- get
- {
- return atmDoorTrig;
- }
- }
- public static RD_TRIG VtmDoorTrig
- {
- get
- {
- return vtmDoorTrig;
- }
- }
- public static LoadLockDoorState LoadLockAtmDoorState
- {
- get
- {
- if(isDoorAlwaysOpen)
- {
- return LoadLockDoorState.Opened;
- }
- if(isSimulator)
- {
- if (_openAtmDoorSignal != null && _openAtmDoorSignal.Value && _closeAtmDoorSignal!= null && !_closeAtmDoorSignal.Value)
- {
- //Thread.Sleep(2000);
- return LoadLockDoorState.Opened;
- }
- if (_closeAtmDoorSignal != null && _closeAtmDoorSignal.Value && _openAtmDoorSignal != null && !_openAtmDoorSignal.Value)
- {
- //Thread.Sleep(2000);
- return LoadLockDoorState.Closed;
- }
- return LoadLockDoorState.Unknown;
- }
- else
- {
- if (_openAtmDoorFeedback != null && _openAtmDoorFeedback.Value && _closeAtmDoorFeedback != null && !_closeAtmDoorFeedback.Value)
- return LoadLockDoorState.Opened;
- if (_closeAtmDoorFeedback != null && _closeAtmDoorFeedback.Value && _openAtmDoorFeedback != null && !_openAtmDoorFeedback.Value)
- return LoadLockDoorState.Closed;
- return LoadLockDoorState.Unknown;
- }
-
- }
- }
-
- public static LoadLockDoorState LoadLockVtmDoorState
- {
- get
- {
- if (isDoorAlwaysOpen)
- {
- return LoadLockDoorState.Opened;
- }
- if (isSimulator)
- {
- if (_openVtmDoorSignal != null &&_openVtmDoorSignal.Value && _closeVtmDoorSignal != null && !_closeVtmDoorSignal.Value)
- {
- //Thread.Sleep(2000);
- return LoadLockDoorState.Opened;
- }
- if (_closeVtmDoorSignal != null && _closeVtmDoorSignal.Value && _openVtmDoorSignal != null && !_openVtmDoorSignal.Value)
- {
- //Thread.Sleep(2000);
- return LoadLockDoorState.Closed;
- }
- return LoadLockDoorState.Unknown;
- }
- else
- {
- if (_openVtmDoorFeedback != null && _openVtmDoorFeedback.Value && _closeVtmDoorFeedback != null && !_closeVtmDoorFeedback.Value)
- return LoadLockDoorState.Opened;
- if (_closeVtmDoorFeedback != null && _closeVtmDoorFeedback.Value && _openVtmDoorFeedback != null && !_openVtmDoorFeedback.Value)
- return LoadLockDoorState.Closed;
- return LoadLockDoorState.Unknown;
- }
-
- }
- }
- public LoadLockDevice(string module, string name, int slotNumber, IoSensor sensorDoorOpen,
- IoSensor sensorArmExtendEnable, DOAccessor openAtmDoorSignal, DOAccessor closeAtmDoorSignal,
- DIAccessor openAtmDoorFeedback, DIAccessor closeAtmDoorFeedback, DOAccessor openVtmDoorSignal,DOAccessor closeVtmDoorSignal,
- DIAccessor openVtmDoorFeedback, DIAccessor closeVtmDoorFeedback)
- {
- Module = module;
- Name = name;
- _sensorDoorOpen = sensorDoorOpen;
- _sensorArmExtendEnable = sensorArmExtendEnable;
- _openAtmDoorSignal = openAtmDoorSignal;
- _closeAtmDoorSignal = closeAtmDoorSignal;
- _openAtmDoorFeedback = openAtmDoorFeedback;
- _closeAtmDoorFeedback = closeAtmDoorFeedback;
-
- _openVtmDoorSignal = openVtmDoorSignal;
- _closeVtmDoorSignal = closeVtmDoorSignal;
- _openVtmDoorFeedback = openVtmDoorFeedback;
- _closeVtmDoorFeedback = closeVtmDoorFeedback;
- WaferManager.Instance.SubscribeLocation(name, slotNumber);
- _isDoorControledByStation = true;
- }
- public LoadLockDevice(string module, string name, int slotNumber, IoSensor sensorDoorOpen, IoSensor sensorArmExtendEnable,IoTrigger triggerSafetytoPM, IoTrigger triggerRBNotExtendPM)
- {
- Module = module;
- Name = name;
- _sensorDoorOpen = sensorDoorOpen;
- _sensorArmExtendEnable = sensorArmExtendEnable;
- _triggerRBNotExtendPM = triggerRBNotExtendPM;
- _triggerSafetytoPM = triggerSafetytoPM;
- WaferManager.Instance.SubscribeLocation(name, slotNumber);
- _isDoorControledByStation = false;
- // SafeytoPm(true);
- }
- public bool Initialize()
- {
- isIdle = true;
- DATA.Subscribe($"{Name}.WaferSize", () => WaferManager.Instance.GetWaferSize(ModuleHelper.Converter(Name), 0));//WaferManager.Instance.GetWafer(ModuleHelper.Converter(Name), 0).Size.ToString());
- return true;
- }
- public void Monitor()
- {
- atmDoorTrig.CLK = LoadLockAtmDoorState == LoadLockDoorState.Closed;
- vtmDoorTrig.CLK = LoadLockVtmDoorState == LoadLockDoorState.Closed;
- if(atmDoorTrig.R || atmDoorTrig.T || vtmDoorTrig.R || vtmDoorTrig.T)
- {
- if ((DeviceDefineManager.Instance.GetValue<bool>("LLDoorControlByStation") ?? false) && Singleton<EfemEntity>.Instance.IsOnlineMode)
- {
- Singleton<EfemEntity>.Instance.SendSigStatEvent(ModuleName.LL1);
- }
- }
- }
- public void Terminate()
- {
- }
-
- public void Reset()
- {
- }
-
- public static bool OpenAtmDoor(out string reason)
- {
- isIdle = false;
- reason = string.Empty;
- EV.PostInfoLog("LoadLock",$"Open Atm Door");
- if (_openAtmDoorSignal.Value && !_closeAtmDoorSignal.Value)
- {
- reason = "Atm door opened, can't open again";
- isIdle = true;
- return true;
- }
- _closeAtmDoorSignal.SetValue(false, out _);
- _openAtmDoorSignal.SetValue(true, out _);
- isIdle = true;
- return true;
- }
- public static bool CloseAtmDoor(out string reason)
- {
- isIdle = false;
- reason = string.Empty;
- EV.PostInfoLog("LoadLock", "Close Atm Door");
- if (_closeAtmDoorSignal.Value && !_openAtmDoorSignal.Value)
- {
- reason = "Atm door closed, can't open again";
- isIdle = true;
- return true;
- }
- _openAtmDoorSignal.SetValue(false, out _);
- _closeAtmDoorSignal.SetValue(true, out _);
- isIdle = true;
- return true;
- }
-
- public static bool OpenVtmDoor(out string reason)
- {
- isIdle = false;
- reason = string.Empty;
- EV.PostInfoLog("LoadLock",$"Open Vtm Door");
- if (_openVtmDoorSignal.Value && !_closeVtmDoorSignal.Value)
- {
- reason = "Vtm door opened, can't open again";
- isIdle = true;
- return true;
- }
- _closeVtmDoorSignal.SetValue(false, out _);
- _openVtmDoorSignal.SetValue(true, out _);
- isIdle = true;
- return true;
- }
- public static bool CloseVtmDoor(out string reason)
- {
- isIdle = false;
- reason = string.Empty;
- EV.PostInfoLog("LoadLock", "Close Vtm Door");
- if (_closeVtmDoorSignal.Value && !_openVtmDoorSignal.Value)
- {
- reason = "Vtm door closed, can't open again";
- isIdle = true;
- return true;
- }
- _openVtmDoorSignal.SetValue(false, out _);
- _closeVtmDoorSignal.SetValue(true, out _);
- isIdle = true;
- return true;
- }
- public void SafeytoPm(bool value)
- {
- isIdle = false;
- EV.PostInfoLog("LoadLock", $"set SafeytoPm{value}");
- _triggerSafetytoPM.SetTrigger(value,out _);
- isIdle = true;
- }
- public void NotExtendtoPm(bool value)
- {
- isIdle = false;
- EV.PostInfoLog("LoadLock", $"set NotExtendtoPm {value}");
- _triggerSafetytoPM.SetTrigger(value, out _);
- isIdle = true;
- }
- public bool IsEnableTransferWafer(out string reason)
- {
- reason = string.Empty;
- if (_isDoorControledByStation)
- {
- return LoadLockAtmDoorState == LoadLockDoorState.Opened;
- }
- else
- {
- if(!isDoorAlwaysOpen)
- {
- if ((_sensorDoorOpen != null && !_sensorDoorOpen.Value)) //|| (_sensorArmExtendEnable != null && !_sensorArmExtendEnable.Value))
- {
- reason = $"{Name} is not ready for transfer";
- return false;
- }
- }
- }
- reason = "";
- return true;
- }
-
- }
- }
|