123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915 |
- using Aitex.Core.Common;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using Aitex.Sorter.Common;
- using Efem.Protocol;
- using EFEM.RT.Devices.Aligner;
- using EFEM.RT.Devices.Flipper;
- using EFEM.RT.Modules;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.BufferStations;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Threading;
- namespace EFEM.RT.Tasks
- {
- public interface IData
- {
- bool Error { get; }
- bool IsLinkOk { get; }
- bool Busy { get; }
- //bool Moving { get; }
- bool Disabled { get; set; }
- bool Initialized { get; set; }
- bool OriginSearched { get; set; }
- bool InUsed { get; set; }
- }
- public interface IFunction
- {
- bool Reset(out string reason);
- bool Init(out string reason);
- bool Home(out string reason);
- }
- public interface IServerModule : IData, IFunction
- {
- string Name { get; set; }
- }
- public class SystemServerModule : IServerModule
- {
- //public bool Communication { get { return Singleton<EfemManager>.Instance.IsConnected; } set { } }
- public string Name { get; set; }
- public bool Busy
- { get { return Singleton<RouteManager>.Instance.IsRunning; } }
- public bool Moving { get; set; }
- public bool Error
- {
- get { return Singleton<RouteManager>.Instance.IsError; }
- }
- public bool IsLinkOk
- {
- get { return Singleton<EfemEntity>.Instance.IsCommunicationOk; }
- }
- public bool Disabled { get; set; }
- public bool Initialized { get; set; }
- public bool OriginSearched { get; set; }
- public bool InUsed { get; set; }
- private Dictionary<EfemEventType, EfemEventValue> _dicEventStatus = new Dictionary<EfemEventType, EfemEventValue>();
- public SystemServerModule(string name)
- {
- Name = name;
- foreach (var value in Enum.GetValues(typeof(EfemEventType)))
- {
- _dicEventStatus[(EfemEventType)value] = EfemEventValue.ON;
- }
- }
- public bool Reset(out string reason)
- {
- reason = string.Empty;
- if (!Singleton<RouteManager>.Instance.CheckToPostMsg(RouteManager.MSG.RESET))
- {
- reason = "BUSY";
- return false;
- }
- Thread.Sleep(100);//can not remove
- //Initialized = true;
- return true;
- }
- public bool Init(out string reason)
- {
- reason = string.Empty;
- if (!Singleton<RouteManager>.Instance.CheckToPostMsg(RouteManager.MSG.HOME))
- {
- reason = "BUSY";
- return false;
- }
- Thread.Sleep(100);//can not remove
- Initialized = true;
- return true;
- }
- public bool Home(out string reason)
- {
- reason = string.Empty;
- if (!Singleton<RouteManager>.Instance.CheckToPostMsg(RouteManager.MSG.HOME))
- {
- reason = "BUSY";
- return false;
- }
- Initialized = true;
- return true;
- }
- public bool MapWafer(string device, out string reason)
- {
- reason = string.Empty;
- if (!Singleton<RouteManager>.Instance.CheckToPostMsg(RouteManager.MSG.MapWafer, device))
- {
- reason = "BUSY";
- return false;
- }
- return true;
- }
- public bool SetEvent(EfemEventType type, EfemEventValue value)
- {
- _dicEventStatus[type] = value;
- return true;
- }
- public bool IsEventEnabled(EfemEventType type)
- {
- return _dicEventStatus[type] == EfemEventValue.ON;
- }
- public bool Hold()
- {
- return true;
- }
- public bool Resume()
- {
- return true;
- }
- public bool Abort()
- {
- return true;
- }
- public bool Stop()
- {
- return true;
- }
- public bool ClearError()
- {
- //InvokeClient.Instance.Service.DoOperation("System.Reset");
- //Singleton<EventManager>.Instance.ClearAlarmEvent();
- if (Singleton<RouteManager>.Instance.IsError || (DEVICE.GetDevice<LoadPortBaseDevice>(ModuleName.LP1.ToString()) != null && DEVICE.GetDevice<LoadPortBaseDevice>(ModuleName.LP1.ToString()).State == DeviceState.Error) || (DEVICE.GetDevice<LoadPortBaseDevice>(ModuleName.LP2.ToString()) != null && DEVICE.GetDevice<LoadPortBaseDevice>(ModuleName.LP2.ToString()).State == DeviceState.Error))
- {
- // Singleton<RouteManager>.Instance.Invoke("Reset");
- //OP.DoOperation("System.Reset");
- //Thread.Sleep(1000);
- Singleton<RouteManager>.Instance.ClearEventLogEnable = true;
- //Singleton<EventManager>.Instance.ClearAlarmEvent();
- }
- return true;
- }
- public string GetLastError()
- {
- return string.Empty;
- }
- }
- public class AlignerServerModule : IServerModule
- {
- public bool IsLinkOk
- {
- get { return _aligner != null && _aligner.Communication; }
- }
- public bool Busy
- {
- get { return _aligner.Busy; }
- }
- public bool Moving
- {
- get { return _aligner.Moving; }
- }
- public bool Error
- {
- get { return _aligner.Error; }
- }
- public string Name { get; set; }
- public bool Disabled { get; set; }
- public bool Initialized { get; set; }
- public bool OriginSearched { get; set; }
- public bool InUsed { get; set; }
- private double _angle = 0;
- public Aligner GetDevice()
- {
- return _aligner;
- }
- protected Aligner _aligner = null;
- public AlignerServerModule(string name)
- {
- Name = name;
- _aligner = DEVICE.GetDevice<Aligner>(DeviceName.Aligner);
- }
- public bool Init(out string reason)
- {
- return _aligner.Init(out reason);
- }
- public bool Home(out string reason)
- {
- return _aligner.Home(out reason);
- }
- public bool Align(out string reason)
- {
- return _aligner.Align(_angle, out reason);
- }
- public bool SetAlign(string target, out string reason)
- {
- reason = string.Empty;
- if (target.StartsWith("P1"))
- {
- _angle = 0;
- }
- else if (target.StartsWith("P2"))
- {
- _angle = 0;
- }
- else if (target.StartsWith("P3"))
- {
- _angle = 0;
- }
- else if (target.StartsWith("P4"))
- {
- _angle = 0;
- }
- else if (target.StartsWith("LLA"))
- {
- _angle = 0;
- }
- else if (target.StartsWith("LLB"))
- {
- _angle = 0;
- }
- else
- {
- target = target.Replace("D", "");//D***.**, ***.** is angle. (0 to 360.00°)
- if (!double.TryParse(target, out _angle))
- {
- return false;
- }
- }
- return true;
- }
- bool IFunction.Reset(out string reason)
- {
- reason = string.Empty;
- return true;
- }
- }
- public class RobotServerModule : IServerModule
- {
- public bool IsLinkOk
- {
- get { return _robot != null; }
- }
- public bool Busy
- {
- get { return _robot.IsBusy; }
- }
- //public bool Moving
- //{
- // get { return _robot.Moving; }
- //}
- public bool Error
- {
- get { return _robot.IsError; }
- }
- public bool Disabled { get; set; }
- public bool Initialized { get; set; }
- public bool OriginSearched { get; set; }
- public bool InUsed { get; set; }
- public string Name { get; set; }
- public RobotBaseDevice GetDevice()
- {
- return _robot;
- }
- protected RobotBaseDevice _robot = null;
- public RobotServerModule(string name)
- {
- Name = name;
- _robot = DEVICE.GetDevice<RobotBaseDevice>(DeviceName.Robot);
- }
- public bool Reset(out string reason)
- {
- reason = null;
- return _robot.RobotReset();
- }
- public bool Init(out string reason)
- {
- reason = null;
- return _robot.Init(null);
- }
- public bool Home(out string reason)
- {
- reason = null;
- return _robot.Home(null);
- }
- }
- public class LoadPortServerModule : IServerModule
- {
- public bool IsLinkOk
- {
- get { return _loadport != null; }
- }
- public bool Busy
- {
- get { return _loadport.IsBusy; }
- }
- //public bool Moving
- //{
- // get { return _loadport.IsMoving; }
- //}
- public bool Error
- {
- get { return _loadport.IsError; }
- }
- public FoupDockState DockState
- {
- get { return _loadport.DockState; }
- }
- public bool Disabled { get; set; }
- public bool Initialized { get; set; }
- public bool OriginSearched { get; set; }
- public bool InUsed { get; set; }
- public string Name { get; set; }
- public string SlotMap => _loadport.SlotMap;
- public LoadPortBaseDevice GetDevice()
- {
- return _loadport;
- }
- protected LoadPortBaseDevice _loadport = null;
- public LoadPortServerModule(string name)
- {
- Name = name;
- _loadport = DEVICE.GetDevice<LoadPortBaseDevice>(name);
- }
- public bool Reset(out string reason)
- {
- return _loadport.LoadportReset(out reason);
- }
- public bool Init(out string reason)
- {
- return _loadport.Home(out reason);
- }
- public bool Home(out string reason)
- {
- return _loadport.Home(out reason);
- }
- public bool Lock(out string reason)
- {
- return _loadport.Clamp(out reason);
- }
- public bool Unlock(out string reason)
- {
- return _loadport.Unclamp(out reason);
- }
- public bool Dock(out string reason)
- {
- return _loadport.Dock(out reason);
- }
- public bool Undock(out string reason)
- {
- return _loadport.Undock(out reason);
- }
- public bool OpenDoor(out string reason)
- {
- return _loadport.OpenDoor(out reason);
- }
- public bool CloseDoor(out string reason)
- {
- return _loadport.CloseDoor(out reason);
- }
- public bool Open(out string reason)
- {
- return _loadport.Load(out reason);
- }
- public bool Read(out string reason)
- {
- reason = null;
- return _loadport.ReadCarrierID(0, 16);
- }
- public bool Read()
- {
- return _loadport.ReadCarrierID();
- }
- public bool Read(string type, out string reason)
- {
- reason = null;
- string filename = "LCDFILE.TXT";
- if (type == "LID") filename = "LCDFILE.TXT";
- if (type == "CID") filename = "CARRIER.TXT";
- return _loadport.ReadCarrierID(new object[] { filename });
- }
- public bool Write(string cid)
- {
- return _loadport.WriteCarrierID(cid, 0, 16, "", out _);
- }
- public bool Write(string cid, out string reason)
- {
- reason = null;
- return SC.GetValue<Boolean>("System.OnlyLotId") ? _loadport.WriteCarrierIDByIndex(cid, 0, 16, 0) : _loadport.WriteCarrierID(cid, 0, 16);
- }
- public bool Close(out string reason)
- {
- return _loadport.Unload(out reason);
- }
- public bool QueryWaferMap(out string reason)
- {
- return _loadport.QueryWaferMap(out reason);
- }
- }
- public class BufferServerModule : IServerModule
- {
- public bool IsLinkOk
- {
- get { return _buffer != null; }
- }
- public bool Busy
- {
- get { return _buffer.Busy; }
- }
- //public bool Moving
- //{
- // get { return _buffer.Moving; }
- //}
- public bool Error
- {
- get { return _buffer.Error; }
- }
- public bool Disabled { get; set; }
- public bool Initialized { get; set; }
- public bool OriginSearched { get; set; }
- public bool InUsed { get; set; }
- public string Name { get; set; }
- public IoCoolingBuffer GetDevice()
- {
- return _buffer;
- }
- protected IoCoolingBuffer _buffer = null;
- public BufferServerModule(string name)
- {
- Name = name;
- _buffer = DEVICE.GetDevice<IoCoolingBuffer>(name);
- }
- public bool Init(out string reason)
- {
- return _buffer.Home(out reason);
- }
- public bool Home(out string reason)
- {
- return _buffer.Home(out reason);
- }
- public bool LiftUp(WaferSize size, out string reason)
- {
- return _buffer.Move(size, true, out reason);
- }
- public bool LiftDown(WaferSize size, out string reason)
- {
- return _buffer.Move(size, false, out reason);
- }
- public bool Align(WaferSize size, out string reason)
- {
- return _buffer.Move(size, false, out reason);
- }
- public bool Reset(out string reason)
- {
- reason = string.Empty;
- return true;
- }
- }
- public class BufferStationServerModule : IServerModule
- {
- public bool IsLinkOk
- {
- get { return _buffer != null; }
- }
- public bool Busy
- {
- get { return false; }
- }
- public bool Error
- {
- get { return false; }
- }
- public bool Disabled { get; set; }
- public bool Initialized { get; set; }
- public bool OriginSearched { get; set; }
- public bool InUsed { get; set; }
- public string Name { get; set; }
- public BufferStation GetDevice()
- {
- return _buffer;
- }
- protected BufferStation _buffer = null;
- public BufferStationServerModule(string name)
- {
- OriginSearched = true;
- Initialized = true;
- Name = name;
- _buffer = DEVICE.GetDevice<BufferStation>(name);
- }
- public bool Init(out string reason)
- {
- reason = string.Empty;
- return true;
- }
- public bool Home(out string reason)
- {
- reason = string.Empty;
- return true;
- }
- public bool Reset(out string reason)
- {
- reason = string.Empty;
- return true;
- }
- }
- public class MechanicalAlignerServerModule : IServerModule
- {
- public bool IsLinkOk
- {
- get { return _mechanicalAligner != null; }
- }
- public bool Busy
- {
- get { return false; }
- }
- public bool Error
- {
- get { return false; }
- }
- public bool Disabled { get; set; }
- public bool Initialized { get; set; }
- public bool OriginSearched { get; set; }
- public bool InUsed { get; set; }
- public string Name { get; set; }
- public MechanicalAligner GetDevice()
- {
- return _mechanicalAligner;
- }
- protected MechanicalAligner _mechanicalAligner = null;
- public MechanicalAlignerServerModule(string name)
- {
- OriginSearched = true;
- Initialized = true;
- Name = name;
- _mechanicalAligner = DEVICE.GetDevice<MechanicalAligner>(name);
- }
- public bool Init(out string reason)
- {
- reason = string.Empty;
- return true;
- }
- public bool Home(out string reason)
- {
- reason = string.Empty;
- return true;
- }
- public bool Reset(out string reason)
- {
- reason = string.Empty;
- return true;
- }
- }
- public class FlipperStationServerModule : IServerModule
- {
- public bool IsLinkOk
- {
- get { return _flipper != null; }
- }
- public bool Busy
- {
- get { return false; }
- }
- public bool Error
- {
- get { return false; }
- }
- public bool Disabled { get; set; }
- public bool Initialized { get; set; }
- public bool OriginSearched { get; set; }
- public bool InUsed { get; set; }
- public string Name { get; set; }
- public FlipperBase GetDevice()
- {
- return _flipper;
- }
- protected FlipperBase _flipper = null;
- public FlipperStationServerModule(string name)
- {
- OriginSearched = true;
- Initialized = true;
- Name = name;
- _flipper = DEVICE.GetDevice<JetFlipper>(name);
- }
- public bool Init(out string reason)
- {
- reason = string.Empty;
- return true;
- }
- public bool Home(out string reason)
- {
- reason = string.Empty;
- return true;
- }
- public bool Reset(out string reason)
- {
- reason = string.Empty;
- return true;
- }
- }
- public class EntityFactory
- {
- private SystemServerModule _system = null;
- private AlignerServerModule _aligner = null;
- private RobotServerModule _robot = null;
- private LoadPortServerModule _loadportA = null;
- private LoadPortServerModule _loadportB = null;
- private LoadPortServerModule _loadportC = null;
- private LoadPortServerModule _loadportD = null;
- private LoadPortServerModule _loadportE = null;
- private LoadPortServerModule _loadportF = null;
- private LoadPortServerModule _loadportG = null;
- private LoadPortServerModule _loadportH = null;
- private LoadPortServerModule _loadportI = null;
- private LoadPortServerModule _loadportJ = null;
- private BufferServerModule _buffer1 = null;
- private BufferServerModule _buffer2 = null;
- private BufferServerModule _aligner1 = null;
- private BufferServerModule _aligner2 = null;
- private MechanicalAlignerServerModule _mechanicalAligner1 = null;
- private MechanicalAlignerServerModule _mechanicalAligner2 = null;
-
- private BufferStationServerModule _bufferStation = null;
- private BufferStationServerModule _bufferStation1 = null;
- private BufferStationServerModule _bufferStation2 = null;
- private FlipperStationServerModule _flipper = null;
- public EntityFactory()
- {
- _system = new SystemServerModule(DeviceName.System);
- _aligner = new AlignerServerModule(DeviceName.Aligner);
- _robot = new RobotServerModule(DeviceName.Robot);
- _loadportA = new LoadPortServerModule(DeviceName.LP1);
- _loadportB = new LoadPortServerModule(DeviceName.LP2);
- _loadportC = new LoadPortServerModule(DeviceName.LP3);
- _loadportD = new LoadPortServerModule(DeviceName.LP4);
- _loadportE = new LoadPortServerModule(DeviceName.LP5);
- _loadportF = new LoadPortServerModule(DeviceName.LP6);
- _loadportG = new LoadPortServerModule(DeviceName.LP7);
- _loadportH = new LoadPortServerModule(DeviceName.LP8);
- _loadportI = new LoadPortServerModule(DeviceName.LP9);
- _loadportJ = new LoadPortServerModule(DeviceName.LP10);
- _aligner1 = new BufferServerModule(DeviceName.Aligner1);
- _aligner2 = new BufferServerModule(DeviceName.Aligner2);
- _mechanicalAligner1 = new MechanicalAlignerServerModule(DeviceName.Aligner1);
- _mechanicalAligner2 = new MechanicalAlignerServerModule(DeviceName.Aligner2);
- _buffer1 = new BufferServerModule(DeviceName.CoolingBuffer1);
- _buffer2 = new BufferServerModule(DeviceName.CoolingBuffer2);
- _bufferStation = new BufferStationServerModule(DeviceName.Buffer);
- _bufferStation1 = new BufferStationServerModule(DeviceName.Buffer1);
- _bufferStation2 = new BufferStationServerModule(DeviceName.Buffer2);
- _flipper = new FlipperStationServerModule(DeviceName.Flipper);
- }
- public IServerModule GetEntity(string name)
- {
- if (string.IsNullOrEmpty(name))
- return null;
- if (ModuleHelper.IsLoadPort((ModuleName)Enum.Parse(typeof(ModuleName), name)))
- {
- string pattern = "[1-9]\\d*";
- Regex rgx = new Regex(pattern);
- var match = int.Parse(rgx.Match(name).ToString());
- if (match > DeviceDefineManager.Instance.GetValue<int>("LoadPortQuantity"))
- {
- return null;
- }
- }
- switch (name)
- {
- case DeviceName.System:
- return _system;
- case DeviceName.Aligner:
- return _aligner;
- case DeviceName.Robot:
- return _robot;
- case DeviceName.LP1:
- return _loadportA;
- case DeviceName.LP2:
- return _loadportB;
- case DeviceName.LP3:
- return _loadportC;
- case DeviceName.LP4:
- return _loadportD;
- case DeviceName.LP5:
- return _loadportE;
- case DeviceName.LP6:
- return _loadportF;
- case DeviceName.LP7:
- return _loadportG;
- case DeviceName.LP8:
- return _loadportH;
- case DeviceName.LP9:
- return _loadportI;
- case DeviceName.LP10:
- return _loadportJ;
- case DeviceName.Aligner1:
- if (SC.ContainsItem("Aligner.AlignerType") && SC.GetValue<int>("Aligner.AlignerType") == 1)
- {
- return _aligner1;
- }
- else
- {
- return _mechanicalAligner1;
- }
- case DeviceName.Aligner2:
- if (SC.ContainsItem("Aligner.AlignerType") && SC.GetValue<int>("Aligner.AlignerType") == 1)
- {
- return _aligner2;
- }
- else
- {
- return _mechanicalAligner2;
- }
- case DeviceName.Aligner3:
- return _aligner1;
- case DeviceName.Aligner4:
- return _aligner2;
- case DeviceName.CoolingBuffer1:
- return _buffer1;
- case DeviceName.CoolingBuffer2:
- return _buffer2;
- case DeviceName.Buffer1:
- return _bufferStation1;
- case DeviceName.Buffer2:
- return _bufferStation2;
- case DeviceName.Buffer:
- return _bufferStation;
- case DeviceName.Flipper:
- return _flipper;
- }
- return null;
- }
- }
- }
|