using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Threading; using Aitex.Core.Common; 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.Fsm; using Aitex.Core.RT.Log; using Aitex.Core.RT.OperationCenter; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using EFEM.RT.Devices; using EFEM.RT.Modules; using EFEM.RT.Tasks; using Aitex.Sorter.Common; using Efem; using Efem.Protocol; using EFEMSC; using MECF.Framework.Common.Device.Bases; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.SubstrateTrackings; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts; using IEntity = Aitex.Core.RT.Fsm.IEntity; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.BufferStations; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots; namespace EFEM.RT { public class EfemModuleStatus { private bool _isInitialized; public bool IsInitialized { get { return _isInitialized; } set { _isInitialized = value; TrigInitialized.CLK = value; } } public R_TRIG TrigInitialized { get; set; } public ModuleName Module { get; set; } public EfemModuleStatus(ModuleName module) { Module = module; TrigInitialized = new R_TRIG(); } } public class EfemEntity : Entity, IEntity, IServerCallback { public enum ServerState { Init, Listening, Connected, } public enum MSG { Online, Offline, NewSessionConnected, Listening, Reset, Error, Disconnect, ReceiveData, SendData, } private SocketServer _socket = null; private string _sessionId; private List _activeTaskList = new List(); private TaskFactory _factory = new TaskFactory(); public string Name { get; set; } public bool IsCommunicationOk { get; set; } public bool IsOnlineMode { get; private set; } private bool IsSystemHold { get; set; } DeviceTimer _sendReadyTimer = new DeviceTimer(); private List LPs; private List LLs; private Dictionary _trigLpPresent = new Dictionary(); private Dictionary> _sigData = new Dictionary>(); private Dictionary _efemModuleStatus = new Dictionary(); private readonly bool _MaintenanceMode = DeviceDefineManager.Instance.GetValue("MaintenanceSignal") ?? false; private readonly bool _EfemDoorOpen = DeviceDefineManager.Instance.GetValue("EfemDoorOpenSignal") ?? false; public EfemEntity() { Name = "Efem"; IsOnlineMode = true; LPs = new List(Singleton.Instance.LpNames); foreach (var moduleName in LPs) { _trigLpPresent[moduleName] = new RD_TRIG(); } LLs = new List(Singleton.Instance.LLNames); int port = 13000; if (!SC.ContainsItem("System.EfemPortNumber")) { LOG.Write("Not define System.EfemPortNumber"); } else { port = SC.GetValue("System.EfemPortNumber"); } _socket = new SocketServer(this, port); fsm = new StateMachine(Name, (int)ServerState.Init, 50); Singleton.Instance.OnEvent += Instance_OnEvent; _eventError = new FixSizeQueue(100); BuildTransitionTable(); Subscribe(); } public FixSizeQueue EventError { get { return _eventError;} } private bool IsErrorReportEnable { get { if (SC.ContainsItem("System.IsErrorReportEnable")) return SC.GetValue("System.IsErrorReportEnable"); return false; } } public string EFemNum { get { if (SC.ContainsItem("System.EFEMNUM")) return SC.GetStringValue("System.EFEMNUM"); return "001"; } } public bool IsEnableMultiWaferSize { get { if (SC.ContainsItem("System.IsEnableMultiWaferSize")) return SC.GetValue("System.IsEnableMultiWaferSize"); return false; } } private FixSizeQueue _eventError; private void Instance_OnEvent(EventItem obj) { if (obj.Level == EventLevel.Alarm) // (obj.Level == EventLevel.Warning || { _eventError.Enqueue(obj); } } public void SetEfemData() { foreach (var module in GetInstallModules()) { _efemModuleStatus[module] = new EfemModuleStatus(module); } } public IEnumerable GetInstallModules() { return new List() { ModuleName.System, ModuleName.Robot, ModuleName.Buffer1, ModuleName.LP1, ModuleName.LP2, ModuleName.LP3, ModuleName.LP4, ModuleName.LL1, ModuleName.LL2, }; } public void SetInitialize(ModuleName module, bool initialized) { if (_efemModuleStatus.ContainsKey(module)) { _efemModuleStatus[module].IsInitialized = initialized; } } private void Subscribe() { DATA.Subscribe("Efem.IsCommunicationReady", () => fsm.State == (int)ServerState.Connected); DATA.Subscribe("System.IsHold", () => IsSystemHold); DATA.Subscribe("System.IsOnlineMode", () => IsOnlineMode); DATA.Subscribe("System.ServerStatus", () => ((ServerState)fsm.State).ToString()); OP.Subscribe(OperationName.Online, (cmd, param) => { if (IsOnlineMode) return true; if (Singleton.Instance.IsRunning) { EV.PostWarningLog("Server", "System is busy, can not switch to online"); return true; } return CheckToPostMsg(MSG.Online); }); OP.Subscribe(OperationName.Offline, (cmd, param) => { if (!IsOnlineMode) return true; return CheckToPostMsg(MSG.Offline); }); } private void BuildTransitionTable() { //online offline AnyStateTransition(MSG.Offline, FsmSetOffline, FSM_STATE.SAME); AnyStateTransition(MSG.Online, FsmSetOnline, FSM_STATE.SAME); //init EnterExitTransition(ServerState.Init, FsmEnterInit, FSM_MSG.NONE, null); Transition(ServerState.Init, MSG.Listening, null, ServerState.Listening); Transition(ServerState.Init, MSG.Reset, FsmEnterInit, ServerState.Init); //listening Transition(ServerState.Listening, MSG.Error, null, ServerState.Init); Transition(ServerState.Listening, MSG.NewSessionConnected, FsmNewSessionConnected, ServerState.Connected); //Connected Transition(ServerState.Connected, MSG.Disconnect, FsmDisconnect, ServerState.Listening); Transition(ServerState.Connected, MSG.Error, null, ServerState.Init); Transition(ServerState.Connected, MSG.NewSessionConnected, FsmNewSessionConnected, ServerState.Connected); Transition(ServerState.Connected, MSG.ReceiveData, FsmReceiveData, ServerState.Connected); Transition(ServerState.Connected, MSG.SendData, FsmSendData, ServerState.Connected); Transition(ServerState.Connected, FSM_MSG.TIMER, FsmMonitor, ServerState.Connected); } ~EfemEntity() { _socket?.Stop(); } public bool SetSystemHold() { if (IsSystemHold) { return false; } IsSystemHold = true; return true; } public bool SetSystemUnHold() { if (!IsSystemHold) { return true; } IsSystemHold = false; return true; } #region FSM Functions public bool CheckToPostMsg(MSG msg) { if (!fsm.FindTransition(fsm.State, (int)msg)) { EV.PostWarningLog("System", string.Format("{0} is in {1} state,can not do {2}", Name, (ServerState)fsm.State, (MSG)msg)); return false; } PostMsg(msg); return true; } public bool CheckToPostMsg(MSG msg, object param1) { if (!fsm.FindTransition(fsm.State, (int)msg)) { EV.PostWarningLog("System", string.Format("{0} is in {1} state,can not do {2}", Name, (ServerState)fsm.State, (MSG)msg)); return false; } PostMsg(msg, param1); return true; } private bool FsmNewSessionConnected(object[] param) { _sessionId = (string)param[0]; _activeTaskList.Clear(); IsCommunicationOk = false; if (IsOnlineMode) { IoSignalTower tower = DEVICE.GetDevice(DeviceName.SignalTower); tower.HostControl = true; } return true; } private bool FsmDisconnect(object[] param) { var sessionId = (string)param[0]; if (sessionId != _sessionId) return false; return true; } private bool FsmEnterInit(object[] param) { string ip = SC.GetStringValue("System.EfemServerLocalIp"); int port = SC.GetValue("System.EfemPortNumber"); _sendReadyTimer.Start(0); if (string.IsNullOrEmpty(ip)) ip = "127.0.0.1"; if (_socket.Start(ip, port)) { PostMsg(MSG.Listening); return true; } return false; } private bool FsmSendData(object[] param) { _socket.Send((string)param[0]); return true; } public string commandrecive = null; private bool FsmReceiveData(object[] param) { try { commandrecive= (string)param[0]; string rawMessage = (string)param[0]; string[] words = rawMessage.Split(new char[5] { ':', '/', '>', '|', ';' }, StringSplitOptions.RemoveEmptyEntries); if (rawMessage.Contains("SET:CSTID")) { words = new string[] { words[0], words[1], words[2], rawMessage.Remove(0, 13) }; } if (!Enum.TryParse(words[0], out EfemCommandType type)) { LOG.Write($"{rawMessage} is not a valid EFEM message format"); SendMessage("NAK:" + rawMessage.Split(':')[1]); return true; } if (!Enum.TryParse(words[1], out EfemCommand cmd)) { LOG.Write($"{rawMessage} is not a valid EFEM message format"); SendMessage("NAK:" + rawMessage.Split(':')[1]); return true; } string commandData = rawMessage.Substring(rawMessage.IndexOf(':')); if (type == EfemCommandType.ACK) { //special for handshake if (!IsCommunicationOk && (rawMessage == "ACK:READY/COMM")) { IsCommunicationOk = true; return true; } foreach (ITaskT active in _activeTaskList) { if (active.CommandData == commandData && active.CommandType == type && active.CommandName == cmd) { active.Ack(type, cmd, words.Skip(2).Take(words.Length).ToArray()); } } return true; } if (_factory.UnSupport(type, cmd)) { LOG.Write($"{rawMessage} is not a valid EFEM message format"); SendMessage("NAK:" + rawMessage.Split(':')[1]); return true; } ITaskT task = _factory.Create(type, cmd); task.CommandData = commandData; foreach (ITaskT active in _activeTaskList) { if (active.CommandData == commandData && active.CommandType == type && active.CommandName == cmd) { EV.PostWarningLog("EFEM", $"ignored {rawMessage}, already active"); return true; } } if (task.Execute(out string resp, rawMessage, words.Skip(2).Take(words.Length).ToArray())) { _activeTaskList.Add(task); } SendMessage(resp); } catch (Exception ex) { LOG.Write(ex); } return true; } private bool FsmSetOnline(object[] param) { IsOnlineMode = true; IoSignalTower tower = DEVICE.GetDevice(DeviceName.SignalTower); tower.HostControl = true; tower.Reset(); return true; } private bool FsmSetOffline(object[] param) { IsOnlineMode = false; IoSignalTower tower = DEVICE.GetDevice(DeviceName.SignalTower); tower.HostControl = false; tower.Reset(); return true; } #endregion #region Server Callback public void OnConnected(string sessionId) { CheckToPostMsg(MSG.NewSessionConnected, sessionId); } public void OnDisconnected(string sessionId) { CheckToPostMsg(MSG.Disconnect, sessionId); } public void OnReceived(string msg) { CheckToPostMsg(MSG.ReceiveData, msg); } #endregion #region Server Monitor public void SendMessage(string msg) { if (IsCommunicationOk || msg == "INF:READY/COMM") { CheckToPostMsg(MSG.SendData, msg); } } private bool FsmMonitor(object[] objs) { if (!IsCommunicationOk) { if (_sendReadyTimer.GetElapseTime() > SC.GetValue(ScPathName.Server_SendReadyInterval)) { _sendReadyTimer.Start(0); SendMessage("INF:READY/COMM"); } return true; } MonitorRunningTask(); MonitorEvent(); return true; } private void MonitorRunningTask() { List tobeRemoved = new List(); foreach (ITaskT task in _activeTaskList) { if (!task.HasInfoMessage) { tobeRemoved.Add(task); continue; } string msg = string.Empty; bool? ret = task.Monitor(out msg); if (ret.HasValue) { SendMessage(msg); tobeRemoved.Add(task); break; } } if (tobeRemoved.Any()) { foreach (var task in tobeRemoved) { _activeTaskList.Remove(task); } } } private void MonitorEvent() { // if (_efemData.IsSigStatEventMode) // { MonitorSigStatEvent(); MonitorErrorEvent(); return; //} //if (LPs.Any() && ((SystemServerModule)Singleton.Instance.GetEntity(DeviceName.System)).IsEventEnabled(EfemEventType.PORT)) //{ // foreach (var lpName in LPs) // { // var lp = DEVICE.GetDevice(lpName.ToString()); // _trigLpPresent[lpName].CLK = lp.IsPresent && lp.IsPlacement; // if (_trigLpPresent[lpName].T || _trigLpPresent[lpName].R) // { // Thread.Sleep(300); // SendSigStatEvent(lpName); // } // } //} } private void MonitorErrorEvent() { if (IsErrorReportEnable && _eventError != null && _eventError.Count > 0) { EventItem ev; //while (_eventError.TryDequeue(out ev)) if (_eventError.TryDequeue(out ev)) { string source = "System"; if (ev.Source.Contains("Robot")) source = "ROB"; if (ev.Source.Contains("LP")) source = ev.Source.Replace("L",""); SendMessage($"INF:ERROR/{ev.Description}/{source}");// Level: ({ ev.Level}), } // SendMessage($"EVT:ERROR/{ev.Source}/{ev.Level}/{ev.Description}"); } } private void MonitorSigStatEvent() { bool allEnable = ((SystemServerModule)Singleton.Instance.GetEntity(DeviceName.System)).IsEventEnabled(EfemEventType.ALL); if (!allEnable) return; bool lpEnable = ((SystemServerModule)Singleton.Instance.GetEntity(DeviceName.System)).IsEventEnabled(EfemEventType.PORT); bool sysEnable = ((SystemServerModule)Singleton.Instance.GetEntity(DeviceName.System)).IsEventEnabled(EfemEventType.SYSTEM); Dictionary> sigDatas = GetSigStatData(); if (sigDatas == null) return; foreach (var sigData in sigDatas) { if (sigData.Key.StartsWith("P") && !lpEnable) continue; if (sigData.Key.StartsWith(EfemParameter.SYS) && !sysEnable) continue; ModuleName module = ProtocolName2ModuleName(sigData.Key); if ((!_efemModuleStatus[module].IsInitialized)) continue; if (_efemModuleStatus[module].TrigInitialized.Q) { _efemModuleStatus[module].TrigInitialized.CLK = true; _sigData.Remove(sigData.Key); continue; } if (_sigData.ContainsKey(sigData.Key) && _sigData[sigData.Key].Item1 == sigData.Value.Item1 && _sigData[sigData.Key].Item2 == sigData.Value.Item2) { continue; } _sigData[sigData.Key] = sigData.Value; if((!commandrecive.Contains("INIT/SYSTEM")&& (sigData.Key.Equals("P1")|| sigData.Key.Equals("P2")) || sigData.Key.Equals("System"))) SendMessage($"EVT:SIGSTAT/{sigData.Key}/{_sigData[sigData.Key].Item1:X8}/{_sigData[sigData.Key].Item2:X8}"); //if(commandrecive.Contains("INIT/SYSTEM")) //commandrecive = ""; } } #endregion public Dictionary> GetSigStatData() { var result = new Dictionary>(); ModuleName[] lstModule = new ModuleName[] { ModuleName.System, ModuleName.LP1, ModuleName.LP2 }; foreach (var moduleName in lstModule) { if (DeviceDefineManager.Instance.GetValue("LoadPortQuantity") == 1) { if(moduleName != ModuleName.LP2) result[ModuleName2ProtocolName(moduleName)] = Tuple.Create(GetSigStatData1(moduleName), GetSigStatData2(moduleName)); } else { result[ModuleName2ProtocolName(moduleName)] = Tuple.Create(GetSigStatData1(moduleName), GetSigStatData2(moduleName)); } } return result; } private ModuleName ProtocolName2ModuleName(string protocol) { ModuleName module = ModuleName.System; Dictionary map = new Dictionary() { {"P1", ModuleName.LP1},{"P2", ModuleName.LP2}, {"SYS", ModuleName.System}, }; if (map.ContainsKey(protocol)) module = map[protocol]; return module; } protected override bool Init() { return true; } protected override void Term() { if (_socket != null) _socket.Stop(); } public bool Check(int msg, out string reason, params object[] args) { if (!fsm.FindTransition(fsm.State, msg)) { reason = String.Format("{0} is in {1} state,can not do {2}", Name, (ServerState)fsm.State, (MSG)msg); return false; } reason = ""; return true; } public void Reset() { if (fsm.State == (int)ServerState.Init) { string ip = SC.GetStringValue("System.EfemServerLocalIp"); int port = SC.GetValue("System.EfemPortNumber"); _sendReadyTimer.Start(0); if (_socket.Start(ip, port)) { PostMsg(MSG.Listening); } } } public bool IsSlotShowOpposite { get { if (SC.ContainsItem("System.IsSlotShowOpposite")) return SC.GetValue("System.IsSlotShowOpposite"); return false; } } public void SendMapEvent(LoadPortBaseDevice lp) { WaferInfo[] wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(lp.Name)); string slot = ""; for (int i = 0; i < lp.ValidSlotsNumber; i++) { switch (wafers[i].Status)//IsSlotShowOpposite? wafers[lp.ValidSlotsNumber - i - 1].Status: { case WaferStatus.Empty: slot += "0"; break; case WaferStatus.Normal: slot += "1"; break; case WaferStatus.Crossed: slot += "3"; break; case WaferStatus.Double: slot += "7"; break; case WaferStatus.Unknown: slot += "8"; break; case WaferStatus.Dummy: slot += "4"; break; } } var slotmap = slot; if (lp.IsError) { slotmap = string.Empty; } string message = string.Format("EVT:MAPDT/{0}/{1}", ModuleName2ProtocolName(ModuleHelper.Converter(lp.Name)), slotmap); SendMessage(message); } public void SendMapEvent(BufferStation lp) { WaferInfo[] wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(lp.Name)); string slot = ""; for (int i = 0; i < lp.ValidSlotsNumber; i++) { switch (wafers[i].Status) { case WaferStatus.Empty: slot += "0"; break; case WaferStatus.Normal: slot += "1"; break; case WaferStatus.Crossed: slot += "3"; break; case WaferStatus.Double: slot += "7"; break; case WaferStatus.Unknown: slot += "8"; break; case WaferStatus.Dummy: slot += "4"; break; } } var slotmap = slot; //if (lp.IsError) //{ // slotmap = string.Empty; //} string message = string.Format("EVT:MAPDT/{0}/{1}", ModuleName2ProtocolName(ModuleHelper.Converter(lp.Name)), slotmap); SendMessage(message); } public void SendSigStatEvent(ModuleName module) { uint data1 = GetSigStatData1(module); uint data2 = GetSigStatData2(module); string message = message = string.Format("EVT:SIGSTAT/{0}/{1:X8}/{2:X8}", ModuleName2ProtocolName(module), data1, data2); SendMessage(message); } public uint GetSigStatData1(string device) { uint data1 = 0x0u; if (IsLoadPort(device)) { //Loadport inputs var lp = DEVICE.GetDevice(device); if (lp != null) { data1 |= GetLpData1(lp); } var e84Lp = DEVICE.GetDevice(GetE84LpName(device)); if (e84Lp != null) { data1 |= GetE84Data1(e84Lp); } } else if (ModuleHelper.IsLoadLock(ModuleHelper.Converter(device))) { data1 = GetLlData1(); } else { data1 = GetSystemData1(); } return data1; } public uint GetSigStatData1(ModuleName module) { uint data1 = 0x0u; if (ModuleHelper.IsLoadPort(module)) { //Loadport inputs var lp = DEVICE.GetDevice(module.ToString()); if (lp != null) { //if(!commandrecive.Contains("INIT/SYSTEM")) data1 |= GetLpData1(lp); } var e84Lp = DEVICE.GetDevice(GetE84LpName(module.ToString())); if (e84Lp != null) { // if (!commandrecive.Contains("INIT/SYSTEM")) data1 |= GetE84Data1(e84Lp); } } else if (ModuleHelper.IsLoadLock(module)) { data1 = GetLlData1(); } else { data1 = GetSystemData1(); } return data1; } public uint GetSigStatData2(string device) { uint data2 = 0x0u; if (IsLoadPort(device)) { // Loadport outputs var lp = DEVICE.GetDevice(device); if (lp != null) { //if (!commandrecive.Contains("INIT/SYSTEM")) data2 |= GetLpData2(lp); } var e84Lp = DEVICE.GetDevice(GetE84LpName(device)); if (e84Lp != null) { //if (!commandrecive.Contains("INIT/SYSTEM")) data2 |= GetE84Data2(e84Lp); } } else if (ModuleHelper.IsLoadLock(ModuleHelper.Converter(device))) { data2 = GetLlData2(); } else { data2 = GetSystemData2(); } return data2; } public uint GetSigStatData2(ModuleName module) { uint data2 = 0x0u; if (ModuleHelper.IsLoadPort(module)) { // Loadport outputs var lp = DEVICE.GetDevice(module.ToString()); if (lp != null) { data2 |= GetLpData2(lp); } var e84Lp = DEVICE.GetDevice(GetE84LpName(module.ToString())); if (e84Lp != null) { data2 |= GetE84Data2(e84Lp); } } else if (ModuleHelper.IsLoadLock(module)) { data2 = GetLlData2(); } else { data2 = GetSystemData2(); } return data2; } private uint GetLpData1(LoadPortBaseDevice lp) { uint data1 = 0x0u; if (lp != null) { //if(lp is OpenStageWithWaferSizeLoadPort) { data1 |= (lp.IsPlacement ? 0x00000001u : 0x0); data1 |= (!lp.IsPresent ? 0x00000002u : 0x0); data1 |= (lp.ClampState == FoupClampState.Close ? 0x00000008u : 0x0); switch (IsEnableMultiWaferSize?lp.GetCurrentWaferSize():WaferSize.WS6) { case WaferSize.WS3: //data1 |= 0x00000040u; data1 |= 0x00000080u; data1 |= 0x00000100u; break; case WaferSize.WS4: data1 |= 0x00000040u; //data1 |= 0x00000080u; data1 |= 0x00000100u; break; case WaferSize.WS6: data1 |= 0x00000040u; data1 |= 0x00000080u; //data1 |= 0x00000100u; break; case WaferSize.WS8: data1 |= 0x00000040u; data1 |= 0x00000080u; data1 |= 0x00000100u; break; } data1 |= (!lp.IsWaferProtrude) ? 0x00000200u : 0x0; data1 |= (lp.IsError||lp.CurrentState==LoadPortStateEnum.Error) ? 0x00000400u : 0x0; data1 |=(lp.Name=="LP1"? (DeviceModel.SensorSMIF1PODOPEN==null?0x0:(DeviceModel.SensorSMIF1PODOPEN.Value ? 0x00000800u : 0x0)) :(DeviceModel.SensorSMIF2PODOPEN==null?0x0:(DeviceModel.SensorSMIF2PODOPEN.Value? 0x00000800u : 0x0))); data1 |= (lp.Name == "LP1" ? (DeviceModel.SensorSMIF1READY == null ? 0x0 : (DeviceModel.SensorSMIF1READY.Value ? 0x00001000u : 0x0)) : (DeviceModel.SensorSMIF2READY == null ? 0x0 : (DeviceModel.SensorSMIF2READY.Value ? 0x00001000u : 0x0))); } } return data1; } private uint GetLpData2(LoadPortBaseDevice lp) { uint data2 = 0x0u; if (lp != null) { // if (!(lp is OpenStageWithWaferSizeLoadPort)) // if (!(lp is OpenStageWithWaferSizeLoadPort)) { data2 |= (lp.IndicatiorPresence == IndicatorState.ON ? 0x00000001U : 0x0); data2 |= (lp.IndicatiorPlacement == IndicatorState.ON ? 0x00000002U : 0x0); data2 |= (lp.IndicatiorLoad == IndicatorState.ON ? 0x00000004U : 0x0); data2 |= (lp.IndicatiorUnload == IndicatorState.ON ? 0x00000008U : 0x0); data2 |= (lp.IndicatiorManualMode == IndicatorState.ON ? 0x00000010U : 0x0); data2 |= (lp.IndicatorAlarm == IndicatorState.ON ? 0x00000020U : 0x0); data2 |= (lp.IndicatiorClampUnclamp == IndicatorState.ON ? 0x00000040U : 0x0); data2 |= (lp.IndicatiorDockUndock == IndicatorState.ON ? 0x00000080U : 0x0); data2 |= (lp.IndicatiorOpAccess == IndicatorState.ON ? 0x00000100U : 0x0); } } return data2; } private uint GetE84Data1(E84Passiver e84Lp) { uint data1 = 0x0u; if (e84Lp != null) { data1 |= (e84Lp.DiValid ? 0x01000000u : 0x0); data1 |= (e84Lp.DiCS0 ? 0x02000000u : 0x0); data1 |= (e84Lp.DiCS1 ? 0x04000000u : 0x0); data1 |= (e84Lp.DiTrReq ? 0x10000000u : 0x0); data1 |= (e84Lp.DiBusy ? 0x20000000u : 0x0); data1 |= (e84Lp.DiCompt ? 0x40000000u : 0x0); data1 |= (e84Lp.DiCont ? 0x80000000u : 0x0); } return data1; } private uint GetE84Data2(E84Passiver e84Lp) { uint data2 = 0x0u; if (e84Lp != null) { data2 |= (e84Lp.DoLoadReq ? 0x01000000U : 0x0); data2 |= (e84Lp.DoUnloadReq ? 0x02000000U : 0x0); data2 |= (e84Lp.DoReady ? 0x08000000U : 0x0); data2 |= (e84Lp.DoHOAvbl ? 0x40000000U : 0x0); data2 |= (e84Lp.DoES ? 0x80000000U : 0x0); } return data2; } //a 1 for SIGSTAT/SYSTEM //Bit Name of Input Signal Signal ON Signal OFF Initial Value //0 System vacuum source pressure 1 Normal //1 //2 System compressed air pressure 1 Normal //3 //4 Flow gauge Sensor Warning //5 Leakage Sensor Warning //6 Door switch Door close //7 Drive power Normal //8 Differential pressure sensor setting 1 Normal //9 Differential pressure sensor setting 2 Normal //10 Ionizer alarm Normal //11 FFU alarm Normal //12 Area sensor(Reserved) Not blocked //13 Mode switch RUN //14 Robot Wafer Present No presence //15 Cassette Door Door Closed private uint GetSystemData1() { uint data1 = 0x0u; //0: if (DeviceModel.SensorVACPressureSW != null) data1 |= (DeviceModel.SensorVACPressureSW.Value ? 0x00000001u : 0x0); //1: if (DeviceModel.SensorIONCDAPressureSW != null) data1 |= (DeviceModel.SensorIONCDAPressureSW.Value ? 0x00000002u : 0x0); //2: if (DeviceModel.SensorCDAPressureSW != null) data1 |= (DeviceModel.SensorCDAPressureSW.Value ? 0x00000004u : 0x0); //3: //data1 |= 0x00000800u; //data1 |= (DeviceModel.SensorAirPressureErrorForRobot.Value ? 0x00000004u : 0x0); //4 Flow gauge Sensor Warning (默认bit=1 Normal) data1 |= (DeviceModel.SensorWaterFlowSW != null ? (DeviceModel.SensorWaterFlowSW.Value ? 0x00000010u : 0x0) : 0x00000010u); //5 Leakage Sensor Warning (默认bit=1 Normal) data1 |= (DeviceModel.SensorWaterLeakSW != null ? (DeviceModel.SensorWaterLeakSW.Value ? 0x00000020u : 0x0) : 0x00000020u); //6:Door switch Door close if (DeviceModel.SensorEFEMSideDoorClosed != null) data1 |= (_EfemDoorOpen? !DeviceModel.SensorEFEMSideDoorClosed.Value : DeviceModel.SensorEFEMSideDoorClosed.Value) ? 0x00000040u : 0x0; //7 Drive power Normal if (DeviceModel.SensorFFUalarm != null) data1 |= (DeviceModel.SensorFFUalarm.Value ? 0x00000080u : 0x0); //8 Differential pressure sensor setting 1 Normal //data1 |= (DeviceModel.SensorIONAlarmSIGNAL.Value ? 0x00000100u : 0x0); //9 Differential pressure sensor setting 1 Normal // data1 |= (DeviceModel.SensorEFEMPowerON.Value ? 0x00000400u : 0x0); //10 Ionizer alarm Normal if (DeviceModel.TrigIonizerInterrupt != null) data1 |= (DeviceModel.TrigIonizerInterrupt != null ? (DeviceModel.TrigIonizerInterrupt.Value? 0x00000400u : (DeviceModel.SensorIONAlarmSIGNAL.Value ? 0x00000400u : 0x0)) : (DeviceModel.SensorIONAlarmSIGNAL.Value ? 0x00000400u : 0x0)); //11 FFU alarm Normal if (DeviceModel.SensorFFUalarm != null) data1 |= (DeviceModel.SensorFFUalarm.Value ? 0x00000800u : 0x0); //12 data1 |= 0x00001000u;//(!DeviceModel.SensorRBlowerArmhavewafer.Value ? 0x00001000u : 0x0); //13 Mode switch RUN if (DeviceModel.SensorMaintenanceMode != null) { bool isRun = (_MaintenanceMode ? !DeviceModel.SensorMaintenanceMode.Value : DeviceModel.SensorMaintenanceMode.Value) && IsOnlineMode; data1 |= (isRun ? 0x00002000u : 0x0); } //14 Robot Wafer Present No presence data1 |= 0x00004000u; //data1 |= (DeviceModel.SensorRobotFork1WaferOn.Value ? 0x00004000u : 0x0); // 15 Sensor Grating SensorIN data1 |= DeviceModel.SensorGratingSensorIN1==null ? 0x0 :(DeviceModel.SensorGratingSensorIN1.Value ? 0x00008000u : 0x0); // 16 robot IsError var robot = DEVICE.GetDevice(ModuleName.Robot.ToString()); data1 |= (robot.IsError || robot.RobotState == RobotStateEnum.Error ? 0x00010000u : 0x0); // 17 buffer1 MapError var buffer1 = DEVICE.GetDevice(ModuleName.Buffer1.ToString()); data1 |= (buffer1!=null&& buffer1.MapError) ? 0x00020000u : 0x0; // 18 buffer2 MapError var buffer2 = DEVICE.GetDevice(ModuleName.Buffer2.ToString()); data1 |= ( buffer2 != null && buffer2.MapError) ? 0x00040000u : 0x0; // 19 Cassette Door Door Closed data1 |= DeviceModel.SensorCstDoorClosed == null ? 0x00080000u : (DeviceModel.SensorCstDoorClosed.Value ? 0x00080000u : 0x0); // 20 PMA System Interlock data1 |= DeviceModel.SensorPMASystemInterlock == null ? 0x0 : (DeviceModel.SensorPMASystemInterlock.Value ? 0x00100000u : 0x0); // 21 PMB System Interlock data1 |= DeviceModel.SensorPMBSystemInterlock == null ? 0x0 : (DeviceModel.SensorPMBSystemInterlock.Value ? 0x00200000u : 0x0); data1 |= DeviceModel.SensorRBNotExtendPMA == null ? 0x0 : (DeviceModel.SensorRBNotExtendPMA.Value ? 0x00400000u : 0x0); data1 |= DeviceModel.SensorRBNotExtendPMB == null ? 0x0 : (DeviceModel.SensorRBNotExtendPMB.Value ? 0x00800000u : 0x0); return data1; } private uint GetSystemData2() { uint data2 = 0x0u; if (DeviceModel.SignalTower != null) { if (DeviceModel.SignalTower.Red != null) data2 |= (DeviceModel.SignalTower.Red.StateSetPoint == TowerLightStatus.On ? 0x00000001u : 0); if (DeviceModel.SignalTower.Green != null) data2 |= (DeviceModel.SignalTower.Green.StateSetPoint == TowerLightStatus.On ? 0x00000002u : 0); if (DeviceModel.SignalTower.Yellow != null) data2 |= (DeviceModel.SignalTower.Yellow.StateSetPoint == TowerLightStatus.On ? 0x00000004u : 0); if (DeviceModel.SignalTower.Blue != null) data2 |= (DeviceModel.SignalTower.Blue.StateSetPoint == TowerLightStatus.On ? 0x00000008u : 0); if (DeviceModel.SignalTower.White != null) data2 |= (DeviceModel.SignalTower.White.StateSetPoint == TowerLightStatus.On ? 0x00000010u : 0); if (DeviceModel.SignalTower.Red != null) data2 |= (DeviceModel.SignalTower.Red.StateSetPoint == TowerLightStatus.Blinking ? 0x00000020u : 0); if (DeviceModel.SignalTower.Green != null) data2 |= (DeviceModel.SignalTower.Green.StateSetPoint == TowerLightStatus.Blinking ? 0x00000040u : 0); if (DeviceModel.SignalTower.Yellow != null) data2 |= (DeviceModel.SignalTower.Yellow.StateSetPoint == TowerLightStatus.Blinking ? 0x00000080u : 0); if (DeviceModel.SignalTower.Blue != null) data2 |= (DeviceModel.SignalTower.Blue.StateSetPoint == TowerLightStatus.Blinking ? 0x00000100u : 0); if (DeviceModel.SignalTower.White != null) data2 |= (DeviceModel.SignalTower.White.StateSetPoint == TowerLightStatus.Blinking ? 0x00000200u : 0); if (DeviceModel.SignalTower.Buzzer1 != null) data2 |= (DeviceModel.SignalTower.Buzzer1.StateSetPoint == TowerLightStatus.On ? 0x00000400u : 0); if (DeviceModel.SignalTower.Buzzer2 != null) data2 |= (DeviceModel.SignalTower.Buzzer2.StateSetPoint == TowerLightStatus.On ? 0x00000800u : 0); } return data2; } private uint GetLlData1() { //DIW1 meter pulse bit 0 //DIW2 meter pulse bit 1 //DIW3 meter pulse bit 2 //DIW4 meter pulse bit 3 //In Shutter Opened bit 4 //Out Shutter Opened bit 5 //Leak Sensor bit 6 uint data1 = 0x0u; data1 |= (LoadLockDevice.LoadLockAtmDoorState == LoadLockDoorState.Opened ? 0x00000010u : 0x0); data1 |= (LoadLockDevice.LoadLockVtmDoorState == LoadLockDoorState.Opened ? 0x00000020u : 0x0); return data1; } private uint GetLlData2() { uint data2 = 0x0u; return data2; } private bool IsLoadPort(string device) { if (device == "P1" || device == "P2" || device == "P3" || device == "P4"|| device == "LP1" || device == "LP2" || device == "LP3" || device == "LP4") { return true; } return false; } public string GetE84LpName(string device) { string e84 = string.Empty; switch (device) { case "P1": case "LP1": e84 = "Loadport1E84"; break; case "P2": case "LP2": e84 = "Loadport2E84"; break; case "P3": case "LP3": e84 = "Loadport3E84"; break; case "P4": case "LP4": e84 = "Loadport4E84"; break; case "P5": case "LP5": e84 = "Loadport5E84"; break; case "P6": case "LP6": e84 = "Loadport6E84"; break; case "P7": case "LP7": e84 = "Loadport7E84"; break; case "P8": case "LP8": e84 = "Loadport8E84"; break; case "P9": case "LP9": e84 = "Loadport9E84"; break; case "P10": case "LP10": e84 = "Loadport10E84"; break; } return e84; } private string ModuleName2ProtocolName(ModuleName module) { string protocol = "System"; switch (module) { case ModuleName.LP1: protocol = "P1"; break; case ModuleName.LP2: protocol = "P2"; break; case ModuleName.LP3: protocol = "P3"; break; case ModuleName.LP4: protocol = "P4"; break; case ModuleName.LP5: protocol = "P5"; break; case ModuleName.LP6: protocol = "P6"; break; case ModuleName.LP7: protocol = "P7"; break; case ModuleName.LP8: protocol = "P8"; break; case ModuleName.LP9: protocol = "P9"; break; case ModuleName.LP10: protocol = "P10"; break; case ModuleName.LL1: protocol = "LLA"; break; case ModuleName.LL2: protocol = "LLB"; break; case ModuleName.LL3: protocol = "LLC"; break; case ModuleName.LL4: protocol = "LLD"; break; case ModuleName.LL5: protocol = "LLE"; break; case ModuleName.LL6: protocol = "LLF"; break; case ModuleName.LL7: protocol = "LLG"; break; case ModuleName.LL8: protocol = "LLH"; break; } return protocol; } } }