123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737 |
- using System;
- using System.Text.RegularExpressions;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- using Aitex.Sorter.Common;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.BufferStations;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
- namespace Aitex.Sorter.RT.EFEMs.Servers
- {
- /// <summary>
- /// Communication establish is not completed
- /// </summary>
- public class InitNoReadyPolicy : CheckImp, IPolicy
- {
- public InitNoReadyPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- var isReady = Singleton<EfemEntity>.Instance.IsCommunicationOk;
- if (!isReady)
- {
- reason = "NOREADY";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- /// Communication establish is not completed
- /// </summary>
- public class NoReadyPolicy : CheckImp, IPolicy
- {
- public NoReadyPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- var isReady = Singleton<EfemEntity>.Instance.IsCommunicationOk;
- if (!isReady)
- {
- reason = "NOREADY";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- /// NOINITCMPL No Initialize Completed - EFEM is not initialized.
- /// </summary>
- public class NoInitCompletedPolicy : CheckImp, IPolicy
- {
- public NoInitCompletedPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (device == DeviceName.SignalTower)
- {
- return true;
- }
- var entity = GetEntity(device);
- if (entity == null)
- {
- return true;
- }
- if (device == DeviceName.Buffer1 || device == DeviceName.Buffer2 || device == DeviceName.Buffer3 ||
- device == DeviceName.Buffer4)
- {
- entity = GetEntity(DeviceName.System);
- }
- if (!entity.Initialized)
- {
- reason = "NOINITCMPL";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- /// NOORGCMPL No Origin Search Completed - Robot origin search is not performed.
- /// </summary>
- public class NoOriginCompletedPolicy : CheckImp, IPolicy
- {
- public NoOriginCompletedPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- IServerModule entity = GetEntity(device);
- if (entity == null)
- {
- return true;
- }
- if (device == DeviceName.Buffer1 || device == DeviceName.Buffer2 || device == DeviceName.Buffer3 ||
- device == DeviceName.Buffer4)
- {
- entity = GetEntity(DeviceName.System);
- }
- if (!entity.OriginSearched)
- {
- reason = "NOORGCMPL";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- /// Insufficient vacuum source pressure
- /// </summary>
- public class VacPolicy : CheckImp, IPolicy
- {
- public VacPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
-
- if (Singleton<EfemEntity>.Instance.EfemDevice.CheckVacuumError())
- {
- reason = "VAC";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- /// AIR Insufficient air source pressure
- /// </summary>
- public class AirPolicy : CheckImp, IPolicy
- {
- public AirPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (device == DeviceName.SignalTower)
- {
- return true;
- }
- if (!Enum.TryParse(device, out ModuleName moduleName))
- {
- reason = PARAM_NG;
- return false;
- }
- if (ModuleHelper.IsLoadPort(moduleName))
- {
- var sensor = DEVICE.GetDevice<IoSensor>("SensorAirPressureErrorForLoadport");
- if (sensor == null || sensor.Value)
- {
- return true;
- }
- reason = "AIR";
- return false;
- }
- if (moduleName == ModuleName.Robot || moduleName == ModuleName.System)
- {
- var sensor = DEVICE.GetDevice<IoSensor>("SensorAirPressureErrorForRobot");
- if (sensor == null || sensor.Value)
- {
- return true;
- }
- reason = "AIR";
- return false;
- }
- reason = "";
- return true;
- }
- }
- /// <summary>
- /// EMS Stop made by EMS message
- /// </summary>
- public class EMSPolicy : CheckImp, IPolicy
- {
- public EMSPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (Singleton<EfemEntity>.Instance.EfemDevice.IsEMSStop)
- {
- reason = "EMS";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- /// ERROR Error stop
- /// </summary>
- public class ErrorPolicy : CheckImp, IPolicy
- {
- public ErrorPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (Singleton<EfemEntity>.Instance.EfemDevice.CheckIsError(ModuleHelper.Converter(device)))
- {
- reason = "ERROR";
- return false;
- }
-
- return true;
- }
- }
- /// <summary>
- /// BUSY Busy (Transfer system is in use)
- /// </summary>
- public class BusyPolicy : CheckImp, IPolicy
- {
- public BusyPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (device == DeviceName.SignalTower)
- {
- return true;
- }
- IServerModule entity = GetEntity(device);
- if (entity.Busy || entity.InUsed)
- {
- if (entity.Busy)
- LOG.Write($"BusyPolicy {device} is Busy");
- if (entity.InUsed)
- LOG.Write($"BusyPolicy {device} is InUsed");
- reason = "BUSY";
- return false;
- }
- return true;
- }
- }
- public class InitBusyPolicy : CheckImp, IPolicy
- {
- public InitBusyPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (device == DeviceName.SignalTower)
- {
- return true;
- }
- IServerModule entity = GetEntity(device);
- if (entity is RobotServerModule)
- {
- if ((entity.Busy || entity.InUsed) && (!entity.Error))
- {
- if (entity.Busy)
- {
- LOG.Write($"BusyPolicy {device} is Busy");
- }
- if (entity.InUsed)
- {
- LOG.Write($"BusyPolicy {device} is InUsed");
- }
- reason = "BUSY";
- return false;
- }
- }
- else if (entity.Busy || entity.InUsed)
- {
- if (entity.Busy)
- LOG.Write($"BusyPolicy {device} is Busy");
- if (entity.InUsed)
- LOG.Write($"BusyPolicy {device} is InUsed");
- reason = "BUSY";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- /// NOLINK Communication with unit is not established
- /// </summary>
- public class LinkPolicy : CheckImp, IPolicy
- {
- public LinkPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (device == DeviceName.SignalTower)
- {
- return true;
- }
- IServerModule entity = GetEntity(device);
- if (!entity.IsLinkOk)
- {
- reason = "NOLINK";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- /// REMOVE Port is not available
- /// </summary>
- public class RemovePolicy : CheckImp, IPolicy
- {
- public RemovePolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (device == DeviceName.SignalTower)
- {
- return true;
- }
- if (ModuleHelper.IsLoadPort((ModuleName)Enum.Parse(typeof(ModuleName), device)))
- {
- string pattern = "[1-9]\\d*";
- Regex rgx = new Regex(pattern);
- var match = int.Parse(rgx.Match(device).ToString());
- if (match > LoadPortQuantity)
- {
- reason = "REMOVE";
- return false;
- }
- }
- IServerModule entity = GetEntity(device);
- if (entity == null || entity.Disabled)
- {
- reason = "REMOVE";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- /// CMPL Operation made by message is completed
- /// </summary>
- public class CMPLPolicy : CheckImp, IPolicy
- {
- public CMPLPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- IServerModule entity = GetEntity(device);
- if (!entity.Busy)
- {
- reason = "CMPL";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- /// CLOSE Pod is closed
- /// </summary>
- public class ClosePolicy : CheckImp, IPolicy
- {
- public ClosePolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (ModuleHelper.IsLoadPort(ModuleHelper.Converter(device)))
- {
- LoadPort _device = DEVICE.GetDevice<LoadPort>(device);
- if (_device.DoorState == FoupDoorState.Close)
- {
- reason = "CLOSE";
- return false;
- }
- }
- return true;
- }
- }
- /// <summary>
- /// NOMAPCMPL Wafer mapping is not completed
- /// </summary>
- public class NoWaferMappingCompletedPolicy : CheckImp, IPolicy
- {
- public NoWaferMappingCompletedPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (!Singleton<EfemEntity>.Instance.EfemDevice.CheckIsMapped(ModuleHelper.Converter(device)))
- {
- reason = "NOMAPCMPL";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- /// NONPOD No necessary pod
- /// </summary>
- public class NoPodPolicy : CheckImp, IPolicy
- {
- public NoPodPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (device == DeviceName.SignalTower)
- {
- return true;
- }
- if (ModuleHelper.IsLoadPort(ModuleHelper.Converter(device)))
- {
- LoadPort _device = DEVICE.GetDevice<LoadPort>(device);
- if (_device.CassetteState != LoadportCassetteState.Normal)
- {
- reason = "NONPOD";
- return false;
- }
- }
- return true;
- }
- }
- /// <summary>
- /// POD Unnecessary pod has already existed
- /// </summary>
- public class PodPolicy : CheckImp, IPolicy
- {
- public PodPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (ModuleHelper.IsLoadPort(ModuleHelper.Converter(device)))
- {
- LoadPort _device = DEVICE.GetDevice<LoadPort>(device);
- if (_device.CassetteState == LoadportCassetteState.Normal)
- {
- reason = "POD";
- return false;
- }
- }
- return true;
- }
- }
- /// <summary>
- /// Not in motion
- /// </summary>
- public class NoMovingPolicy : CheckImp, IPolicy
- {
- public NoMovingPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- IServerModule entity = GetEntity(device);
- if (!entity.Busy)
- {
- reason = "NOTINMOTION";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- /// HOLD Hold
- /// </summary>
- public class HoldPolicy : CheckImp, IPolicy
- {
- public HoldPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- bool isHold = (bool)DATA.Poll(ModuleName.System.ToString(), ParamName.IsHold);
- if (isHold)
- {
- reason = "HOLD";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- ///NOHOLD Not being held ○
- /// </summary>
- public class NoHoldPolicy : CheckImp, IPolicy
- {
- public NoHoldPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- bool isHold = (bool)DATA.Poll(ModuleName.System.ToString(), ParamName.IsHold);
- if (!isHold)
- {
- reason = "NOHOLD";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- ///LLCLOSE LL door is closed
- /// </summary>
- public class LLDoorClosedPolicy : CheckImp, IPolicy
- {
- public LLDoorClosedPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (Singleton<EfemEntity>.Instance.EfemDevice.CheckLoadLockDoorClosed())
- {
- reason = "LLCLOSE";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- ///LLNOEXTEND Finger cannot be inserted into LL
- /// </summary>
- public class LLNoExtenedPolicy : CheckImp, IPolicy
- {
- public LLNoExtenedPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (Singleton<EfemEntity>.Instance.EfemDevice.CheckLLCanNotExtended())
- {
- reason = "LLNOEXTEND";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- ///MAINTENANCE Key switch is set to "Mainte"
- /// </summary>
- public class MaintenancePolicy : CheckImp, IPolicy
- {
- public MaintenancePolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (Singleton<EfemEntity>.Instance.EfemDevice.IsMaintenanceMode || !Singleton<EfemEntity>.Instance.IsOnlineMode)
- {
- reason = "MAINTENANCE";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- ///ARMEXTEND Finger is being inserted in pod
- /// </summary>
- public class ArmExtendPolicy : CheckImp, IPolicy
- {
- public ArmExtendPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (Singleton<EfemEntity>.Instance.EfemDevice.CheckArmExtended(ModuleName.Robot, device))
- {
- reason = "ARMEXTEND";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- ///DRPOWERDOWN Drive power error
- /// </summary>
- public class PowerDownPolicy : CheckImp, IPolicy
- {
- public PowerDownPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (Singleton<EfemEntity>.Instance.EfemDevice.IsMaintenanceMode)
- {
- reason = "DRPOWERDOWN";
- return false;
- }
- return true;
- }
- }
- /// <summary>
- ///NOPOS Inoperable position
- /// </summary>
- public class NoPosPolicy : CheckImp, IPolicy
- {
- public NoPosPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- IServerModule entity = GetEntity(device);
- if (ModuleHelper.IsLoadLock((ModuleName)Enum.Parse(typeof(ModuleName), device)))
- {
- var loadPort = DEVICE.GetDevice<LoadPort>(ModuleName.LP1.ToString());
- if (loadPort.DoorState == FoupDoorState.Close && loadPort.ClampState == FoupClampState.Open)
- {
- reason = "NOPOS";
- return false;
- }
- }
- return true;
- }
- }
- /// <summary>
- ///NoFuncPolicy Inoperable position
- /// </summary>
- public class NoFuncPolicy : CheckImp, IPolicy
- {
- public NoFuncPolicy()
- {
- }
- public bool Check(string device, out string reason)
- {
- reason = string.Empty;
- if (Singleton<EfemEntity>.Instance.EfemDevice.IsMaintenanceMode || !Singleton<EfemEntity>.Instance.IsOnlineMode)//?
- {
- reason = "NOFUNC";
- return false;
- }
- return true;
- }
- }
- }
|