123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592 |
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Threading;
- using Aitex.Core.RT.Device;
- 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
- {
- public interface IData
- {
- bool Error { get; }
- bool IsLinkOk { get; }
- bool Busy { get; }
-
- bool Disabled { get; set; }
- bool Initialized { get; set; }
- bool OriginSearched { get; set; }
- bool InUsed { get; set; }
- }
- public interface IFunction
- {
- bool Init(out string reason);
- bool Home(out string reason);
- }
- public interface IServerModule : IData, IFunction
- {
- }
- public class SystemServerModule : IServerModule
- {
- public string Name { get; set; }
- public bool Busy { get { return Singleton<EfemEntity>.Instance.EfemDevice.IsRunning; } }
- public bool Moving { get; set; }
- public bool Error
- {
- get { return Singleton<EfemEntity>.Instance.EfemDevice.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 Init(out string reason)
- {
- reason = string.Empty;
- if(!Singleton<EfemEntity>.Instance.EfemDevice.Init(ModuleName.System))
- {
- 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<EfemEntity>.Instance.EfemDevice.Home(ModuleName.System))
- {
- reason = "BUSY";
- return false;
- }
- Initialized = true;
- return true;
- }
- public bool MapWafer(string device, out string reason)
- {
- reason = string.Empty;
- if (!Singleton<EfemEntity>.Instance.EfemDevice.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()
- {
- if (!Singleton<EfemEntity>.Instance.EfemDevice.ClearError())
- {
- LOG.Write("call routermanager reset failed.");
- return false;
- }
- 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 bool IsGripped
- {
- get
- {
- return _aligner.StateWaferHold;
- }
- }
- public Aligner GetDevice()
- {
- return _aligner;
- }
- protected Aligner _aligner = null;
- public AlignerServerModule(string 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 Grip(out string reason)
- {
- return _aligner.Grip(Hand.Blade1, out reason);
- }
- public bool Release(out string reason)
- {
- return _aligner.Release(Hand.Blade1, 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;
- }
- }
- public class RobotServerModule : IServerModule
- {
- public bool IsLinkOk
- {
- get { return Singleton<EfemEntity>.Instance.EfemDevice.CheckIsInitialized(ModuleName.Robot); }
- }
- public bool Busy
- {
- get { return Singleton<EfemEntity>.Instance.EfemDevice.CheckIsBusy(ModuleName.Robot); }
- }
-
- public bool Error
- {
- get { return Singleton<EfemEntity>.Instance.EfemDevice.CheckIsError(ModuleName.Robot); }
- }
- public bool Disabled { get; set; }
- public bool Initialized { get; set; }
- public bool OriginSearched { get; set; }
- public bool InUsed { get; set; }
-
- public RobotServerModule(string name)
- {
-
- }
- public bool Init(out string reason)
- {
- if (!Singleton<EfemEntity>.Instance.EfemDevice.Init(ModuleName.Robot))
- {
- reason = "BUSY";
- return false;
- }
- reason = string.Empty;
- return true;
- }
- public bool Home(out string reason)
- {
- if (!Singleton<EfemEntity>.Instance.EfemDevice.Home(ModuleName.Robot))
- {
- reason = "BUSY";
- return false;
- }
- reason = string.Empty;
- return true;
- }
- }
- public class LoadPortServerModule : IServerModule
- {
- public bool IsLinkOk
- {
- get
- {
- return Singleton<EfemEntity>.Instance.EfemDevice.CheckLinkOk(_module)
- && Singleton<EfemEntity>.Instance.EfemDevice.CheckIsInitialized(_module);
- }
- }
- public bool Busy
- {
- get { return Singleton<EfemEntity>.Instance.EfemDevice.CheckIsBusy(_module); }
- }
-
- public bool Error
- {
- get { return Singleton<EfemEntity>.Instance.EfemDevice.CheckIsError(_module); }
- }
- public bool Disabled { get; set; }
- public bool Initialized { get; set; }
- public bool OriginSearched { get; set; }
- public bool InUsed { get; set; }
-
- public bool IsStateIdle
- {
- get
- {
- return Singleton<EfemEntity>.Instance.EfemDevice.CheckIsIdle(_module);
- }
- }
- public string SlotMap => Singleton<EfemEntity>.Instance.EfemDevice.GetSlotMap(_module);
- private ModuleName _module;
- public LoadPortServerModule(ModuleName module)
- {
- _module = module;
- }
- public bool Init(out string reason)
- {
- reason = string.Empty;
- return Singleton<EfemEntity>.Instance.EfemDevice.Init(_module);
- }
- public bool Home(out string reason)
- {
- reason = string.Empty;
- return Singleton<EfemEntity>.Instance.EfemDevice.Home(_module);
- }
- public bool Lock(out string reason)
- {
- reason = string.Empty;
- return Singleton<EfemEntity>.Instance.EfemDevice.Lock(_module);
- }
- public bool Unlock(out string reason)
- {
- reason = string.Empty;
- return Singleton<EfemEntity>.Instance.EfemDevice.Unlock(_module);
- }
- public bool Dock(out string reason)
- {
- reason = string.Empty;
- return Singleton<EfemEntity>.Instance.EfemDevice.Dock(_module);
- }
- public bool Undock(out string reason)
- {
- reason = string.Empty;
- return Singleton<EfemEntity>.Instance.EfemDevice.Undock(_module);
- }
- public bool OpenDoor(out string reason)
- {
- reason = string.Empty;
- return Singleton<EfemEntity>.Instance.EfemDevice.OpenDoor(_module);
- }
- public bool CloseDoor(out string reason)
- {
- reason = string.Empty;
- return Singleton<EfemEntity>.Instance.EfemDevice.CloseDoor(_module);
- }
- public bool Open(out string reason)
- {
- reason = string.Empty;
- Singleton<EfemEntity>.Instance.EfemDevice.Open(_module);
- return true;
- }
-
- public bool Close(out string reason)
- {
- reason = string.Empty;
- return Singleton<EfemEntity>.Instance.EfemDevice.Close(_module);
- }
- public bool Map(out string reason)
- {
-
- reason = string.Empty;
- Singleton<EfemEntity>.Instance.EfemDevice.Map(_module);
- return true;
- }
- }
- public class BufferServerModule : 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 BufferServerModule(string name)
- {
- 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 class EfemServerModule : Singleton<EfemServerModule>
- {
- 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 _coolbuffer1 = null;
- private BufferServerModule _coolbuffer2 = null;
- private BufferServerModule _buffer1 = null;
- private BufferServerModule _buffer2 = null;
- private BufferServerModule _buffer3 = null;
- private BufferServerModule _buffer4 = null;
- public EfemServerModule()
- {
- _system = new SystemServerModule(DeviceName.System);
- _aligner = new AlignerServerModule(DeviceName.Aligner);
- _robot = new RobotServerModule(DeviceName.Robot);
- _loadportA = new LoadPortServerModule(ModuleName.LP1);
- _loadportB = new LoadPortServerModule(ModuleName.LP2);
- _loadportC = new LoadPortServerModule(ModuleName.LP3);
- _loadportD = new LoadPortServerModule(ModuleName.LP4);
- _loadportE = new LoadPortServerModule(ModuleName.LP5);
- _loadportF = new LoadPortServerModule(ModuleName.LP6);
- _loadportG = new LoadPortServerModule(ModuleName.LP7);
- _loadportH = new LoadPortServerModule(ModuleName.LP8);
- _loadportI = new LoadPortServerModule(ModuleName.LP9);
- _loadportJ = new LoadPortServerModule(ModuleName.LP10);
- _coolbuffer1 = new BufferServerModule(DeviceName.CoolingBuffer1);
- _coolbuffer2 = new BufferServerModule(DeviceName.CoolingBuffer2);
- _buffer1 = new BufferServerModule(DeviceName.Buffer1);
- _buffer2 = new BufferServerModule(DeviceName.Buffer2);
- _buffer3 = new BufferServerModule(DeviceName.Buffer3);
- _buffer4 = new BufferServerModule(DeviceName.Buffer4);
- }
- public IServerModule GetModule(string name)
- {
- 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.CoolingBuffer1:
- return _coolbuffer1;
- case DeviceName.CoolingBuffer2:
- return _coolbuffer2;
- case DeviceName.Buffer1:
- return _buffer1;
- case DeviceName.Buffer2:
- return _buffer2;
- case DeviceName.Buffer3:
- return _buffer3;
- case DeviceName.Buffer4:
- return _buffer4;
- }
- return null;
- }
- }
- }
|