using Aitex.Core.Common; using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.Device; using Aitex.Core.RT.Device.Unit; using Aitex.Core.RT.Fsm; using Aitex.Core.RT.OperationCenter; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using Aitex.Sorter.Common; using athosRT.Devices; using athosRT.Devices.EFEM; using athosRT.Devices.EFEM.Task; using athosRT.tool; using MECF.Framework.Common.Device.Bases; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.SubstrateTrackings; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using DATA = Common.DataCenter.DATA; using IoSignalTower = athosRT.Devices.IoSignalTower; using OP = Common.OP.OP; namespace athosRT.Modules.EFEMs { public class EfemEntity : Entity, IEntity, IServerCallback { private SocketServer _socket = (SocketServer)null; private string _sessionId; private List _activeTaskList = new List(); private TaskFactory _factory = new TaskFactory(); private 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(); public string Name { get; set; } public string GetFsmState => fsm.State.ToString(); public bool IsCommunicationOk { get; set; } public bool IsOnlineMode { get; private set; } private bool IsSystemHold { get; set; } public EfemEntity() { Name = "Efem"; IsOnlineMode = false; LPs = new List(Singleton.Instance.LpNames); foreach (ModuleName lp in LPs) _trigLpPresent[lp] = new RD_TRIG(); LLs = new List((IEnumerable)Singleton.Instance.LLNames); int port = 13000; if (!SC.ContainsItem("System.EfemPortNumber")) LogObject.Error("EFEM", "Not define System.EfemPortNumber"); else port = SC.GetValue("System.EfemPortNumber"); //获取端口 用于服务的发布 _socket = new SocketServer((IServerCallback)this, port); fsm = (IStateMachine)new StateMachine(Name, 0, 50); BuildTransitionTable(); Subscribe(); } public void SetEfemData() { foreach (ModuleName installModule in GetInstallModules()) _efemModuleStatus[installModule] = new EfemModuleStatus(installModule); } public IEnumerable GetInstallModules() => (IEnumerable)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)) return; _efemModuleStatus[module].IsInitialized = initialized; } private void Subscribe() { DATA.Subscribe("Efem.IsCommunicationReady", (Func)(() => (object)(fsm.State == 2)), SubscriptionAttribute.FLAG.SaveDB); DATA.Subscribe("System.IsHold", (Func)(() => (object)IsSystemHold), SubscriptionAttribute.FLAG.SaveDB); DATA.Subscribe("System.IsOnlineMode", (Func)(() => (object)IsOnlineMode), SubscriptionAttribute.FLAG.SaveDB); DATA.Subscribe("System.ServerStatus", (Func)(() => (object)((EfemEntity.ServerState)fsm.State).ToString()), SubscriptionAttribute.FLAG.SaveDB); DATA.Subscribe($"Server.Status", () => ((ServerState)fsm.State).ToString()); OP.Subscribe("Online", (Func)((cmd, param) => { Trace.WriteLine("执行Online"); if (IsOnlineMode) return true; if (!Singleton.Instance.IsRunning) { if (CheckToPostMsg(EfemEntity.MSG.Online)) { LogObject.Info("EFEM", $"Switch to Online Mode.The Address is {SC.GetStringValue("System.EfemServerLocalIp")}:{SC.GetValue("System.EfemPortNumber")}."); return true; } else { LogObject.Warning("EFEM", "Cannot Switch to Online Mode."); return false; } } EV.PostWarningLog("EFEM", "Server", "System is busy, can not switch to online."); return true; })); OP.Subscribe("Offline", (Func)((cmd, param) => { if (!IsOnlineMode) return true; if (CheckToPostMsg(EfemEntity.MSG.Offline)) { LogObject.Info("EFEM", "Switch to Offline Mode."); return true; } else { LogObject.Warning("EFEM", "Cannot Switch to Offline Mode."); return true; } })); } private void BuildTransitionTable() { AnyStateTransition(MSG.Offline, FsmSetOffline, FSM_STATE.SAME); AnyStateTransition(MSG.Online, FsmSetOnline, FSM_STATE.SAME); EnterExitTransition(ServerState.Init, FsmEnterInit, new FSM_MSG?(FSM_MSG.NONE), null); Transition(ServerState.Init, MSG.Listening, null, EfemEntity.ServerState.Listening); Transition(ServerState.Init, MSG.Reset, FsmEnterInit, EfemEntity.ServerState.Init); Transition(ServerState.Listening, MSG.Error, null, EfemEntity.ServerState.Init); Transition(ServerState.Listening, MSG.NewSessionConnected, FsmNewSessionConnected, EfemEntity.ServerState.Connected); Transition(ServerState.Connected, MSG.Disconnect, FsmDisconnect, EfemEntity.ServerState.Listening); Transition(ServerState.Connected, MSG.Error, null, EfemEntity.ServerState.Init); Transition(ServerState.Connected, MSG.NewSessionConnected, FsmNewSessionConnected, EfemEntity.ServerState.Connected); Transition(ServerState.Connected, MSG.ReceiveData, FsmReceiveData, EfemEntity.ServerState.Connected); Transition(ServerState.Connected, MSG.SendData, FsmSendData, EfemEntity.ServerState.Connected); Transition(ServerState.Connected, FSM_MSG.TIMER, FsmMonitor, EfemEntity.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; } public bool CheckToPostMsg(EfemEntity.MSG msg) { if (!fsm.FindTransition(fsm.State, (int)msg)) { EV.PostWarningLog("EFEM", "System", string.Format("{0} is in {1} state,can not do {2}", (object)Name, (object)(EfemEntity.ServerState)fsm.State, (object)msg)); return false; } PostMsg(msg); return true; } public bool CheckToPostMsg(EfemEntity.MSG msg, object param1) { if (!fsm.FindTransition(fsm.State, (int)msg)) { EV.PostWarningLog("EFEM", "System", string.Format("{0} is in {1} state,can not do {2}", (object)Name, (object)(EfemEntity.ServerState)fsm.State, (object)msg)); return false; } PostMsg(msg, param1); return true; } private bool FsmNewSessionConnected(object[] param) { _sessionId = (string)param[0]; _activeTaskList.Clear(); IsCommunicationOk = false; if (IsOnlineMode) DEVICE.GetDevice("SignalTower").HostControl = true; return true; } private bool FsmDisconnect(object[] param) => !((string)param[0] != _sessionId); private bool FsmEnterInit(object[] param) { string server = SC.GetStringValue("System.EfemServerLocalIp"); int port = SC.GetValue("System.EfemPortNumber"); _sendReadyTimer.Start(0.0); if (string.IsNullOrEmpty(server)) server = "127.0.0.1"; if (!_socket.Start(server, port)) return false; PostMsg(EfemEntity.MSG.Listening); return true; } private bool FsmSendData(object[] param) { _socket.Send((string)param[0]); return true; } private bool FsmReceiveData(object[] param) { try { string cmd = (string)param[0]; string[] source = cmd.Split(new char[5] { ':', '/', '>', '|', ';' }, StringSplitOptions.RemoveEmptyEntries); if (cmd.Contains("SET:CSTID")) source = new string[4] { source[0], source[1], source[2], cmd.Remove(0, 13) }; EfemCommandType result1; //验证是否是EFEM协议的命令类型 SET MOV GET ACK if (!Enum.TryParse(source[0], out result1)) { LogObject.Error("EFEM", cmd + " is not a valid EFEM message format"); //LOG.Write(cmd + " is not a valid EFEM message format", file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Servers\\EfemEntity.cs", member: nameof(FsmReceiveData), line: 398); SendMessage("NAK:" + cmd.Split(':')[1]); return true; } EfemCommand result2; //验证 if (!Enum.TryParse(source[1], out result2)) { LogObject.Error("EFEM", cmd + " is not a valid EFEM message format"); //LOG.Write(cmd + " is not a valid EFEM message format", file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Servers\\EfemEntity.cs", member: nameof(FsmReceiveData), line: 405); SendMessage("NAK:" + cmd.Split(':')[1]); return true; } string str = cmd.Substring(cmd.IndexOf(':')); if (result1 == EfemCommandType.ACK) { if (!IsCommunicationOk && cmd == "ACK:READY/COMM") { IsCommunicationOk = true; return true; } foreach (ITaskT activeTask in _activeTaskList) { if (activeTask.CommandData == str && activeTask.CommandType == result1 && activeTask.CommandName == result2) activeTask.Ack(result1, result2, ((IEnumerable)source).Skip(2).Take(source.Length).ToArray()); } return true; } if (_factory.UnSupport(result1, result2)) { LogObject.Error("EFEM", cmd + " is not a valid EFEM message format"); //LOG.Write(cmd + " is not a valid EFEM message format", file: "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Servers\\EfemEntity.cs", member: nameof(FsmReceiveData), line: 433); SendMessage("NAK:" + cmd.Split(':')[1]); return true; } ITaskT taskT = _factory.Create(result1, result2); taskT.CommandData = str; foreach (ITaskT activeTask in _activeTaskList) { if (activeTask.CommandData == str && activeTask.CommandType == result1 && activeTask.CommandName == result2) { EV.PostWarningLog("EFEM", "EFEM", "ignored " + cmd + ", already active"); return true; } } string result3; string[] arr = ((IEnumerable)source).Skip(2).Take(source.Length).ToArray(); if (taskT.Execute(out result3, cmd, arr)) _activeTaskList.Add(taskT); SendMessage(result3); } catch (Exception ex) { LogObject.Error("EFEM", ex); //LOG.Write(ex, 2, "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Servers\\EfemEntity.cs", nameof(FsmReceiveData), 459); } return true; } private bool FsmSetOnline(object[] param) { IsOnlineMode = true; IoSignalTower device = DEVICE.GetDevice("SignalTower"); device.HostControl = true; device.Reset(); return true; } private bool FsmSetOffline(object[] param) { IsOnlineMode = false; IoSignalTower device = DEVICE.GetDevice("SignalTower"); device.HostControl = false; device.Reset(); return true; } public void OnConnected(string sessionId) => CheckToPostMsg(EfemEntity.MSG.NewSessionConnected, (object)sessionId); public void OnDisconnected(string sessionId) => CheckToPostMsg(EfemEntity.MSG.Disconnect, (object)sessionId); public void OnReceived(string msg) => CheckToPostMsg(EfemEntity.MSG.ReceiveData, (object)msg); public void SendMessage(string msg) { if (!IsCommunicationOk && !(msg == "INF:READY/COMM")) return; CheckToPostMsg(EfemEntity.MSG.SendData, (object)msg); } private bool FsmMonitor(object[] objs) { if (!IsCommunicationOk) { if (_sendReadyTimer.GetElapseTime() > (double)SC.GetValue("Server.SendReadyInterval")) { _sendReadyTimer.Start(0.0); SendMessage("INF:READY/COMM"); } return true; } MonitorRunningTask(); MonitorEvent(); return true; } private void MonitorRunningTask() { List source = new List(); foreach (ITaskT activeTask in _activeTaskList) { if (!activeTask.HasInfoMessage) { source.Add(activeTask); } else { string result = string.Empty; if (activeTask.Monitor(out result).HasValue) { SendMessage(result); source.Add(activeTask); break; } } } if (!source.Any()) return; foreach (ITaskT taskT in source) _activeTaskList.Remove(taskT); } private void MonitorEvent() => MonitorSigStatEvent(); private void MonitorSigStatEvent() { if (!((SystemServerModule)Singleton.Instance.GetEntity("System")).IsEventEnabled(EfemEventType.ALL)) return; bool flag1 = ((SystemServerModule)Singleton.Instance.GetEntity("System")).IsEventEnabled(EfemEventType.PORT); bool flag2 = ((SystemServerModule)Singleton.Instance.GetEntity("System")).IsEventEnabled(EfemEventType.SYSTEM); Dictionary> sigStatData = GetSigStatData(); if (sigStatData == null) return; foreach (KeyValuePair> keyValuePair in sigStatData) { if ((!keyValuePair.Key.StartsWith("P") || flag1) && (!keyValuePair.Key.StartsWith("SYS") || flag2)) { ModuleName key = ProtocolName2ModuleName(keyValuePair.Key); if (_efemModuleStatus[key].IsInitialized) { if (_efemModuleStatus[key].TrigInitialized.Q) { _efemModuleStatus[key].TrigInitialized.CLK = true; _sigData.Remove(keyValuePair.Key); } else if (!_sigData.ContainsKey(keyValuePair.Key) || (int)_sigData[keyValuePair.Key].Item1 != (int)keyValuePair.Value.Item1 || (int)_sigData[keyValuePair.Key].Item2 != (int)keyValuePair.Value.Item2) { _sigData[keyValuePair.Key] = keyValuePair.Value; SendMessage(string.Format("EVT:SIGSTAT/{0}/{1:X8}/{2:X8}", (object)keyValuePair.Key, (object)_sigData[keyValuePair.Key].Item1, (object)_sigData[keyValuePair.Key].Item2)); } } } } } public Dictionary> GetSigStatData() { Dictionary> sigStatData = new Dictionary>(); ModuleName[] moduleNameArray = new ModuleName[3] { ModuleName.System, ModuleName.LP1, ModuleName.LP2 }; foreach (ModuleName module in moduleNameArray) sigStatData[ModuleName2ProtocolName(module)] = Tuple.Create(GetSigStatData1(module), GetSigStatData2(module)); return sigStatData; } private ModuleName ProtocolName2ModuleName(string protocol) { ModuleName moduleName = ModuleName.System; Dictionary dictionary = new Dictionary() { { "P1", ModuleName.LP1 }, { "P2", ModuleName.LP2 }, { "SYS", ModuleName.System } }; if (dictionary.ContainsKey(protocol)) moduleName = dictionary[protocol]; return moduleName; } protected override bool Init() => true; protected override void Term() { if (_socket == null) return; _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}", (object)Name, (object)(EfemEntity.ServerState)fsm.State, (object)(EfemEntity.MSG)msg); return false; } reason = ""; return true; } public void Reset() { if (fsm.State != 0) return; string stringValue = SC.GetStringValue("System.EfemServerLocalIp"); int port = SC.GetValue("System.EfemPortNumber"); _sendReadyTimer.Start(0.0); if (_socket.Start(stringValue, port)) PostMsg(EfemEntity.MSG.Listening); } /// /// 此处将wafermanager中对应lp数据进行发送 /// /// public void SendMapEvent(LoadPortBaseDevice lp) { WaferInfo[] wafers = Singleton.Instance.GetWafers(ModuleHelper.Converter(lp.Name)); string str1 = ""; for (int index = 0; index < 25; ++index) { switch (wafers[index].Status) { case WaferStatus.Empty: str1 += "0"; break; case WaferStatus.Normal: str1 += "1"; break; case WaferStatus.Crossed: str1 += "3"; break; case WaferStatus.Double: str1 += "7"; break; case WaferStatus.Unknown: str1 += "8"; break; case WaferStatus.Dummy: str1 += "4"; break; } } string str2 = str1; if (lp.IsError) str2 = string.Empty; SendMessage(string.Format("EVT:MAPDT/{0}/{1}", (object)ModuleName2ProtocolName(ModuleHelper.Converter(lp.Name)), (object)str2)); } public void SendSigStatEvent(ModuleName module) { uint sigStatData1 = GetSigStatData1(module); uint sigStatData2 = GetSigStatData2(module); SendMessage(string.Format("EVT:SIGSTAT/{0}/{1:X8}/{2:X8}", (object)ModuleName2ProtocolName(module), (object)sigStatData1, (object)sigStatData2)); } public uint GetSigStatData1(string device) { uint sigStatData1 = 0; if (IsLoadPort(device)) { LoadPortBaseDevice device1 = DEVICE.GetDevice("L" + device); if (device1 != null) sigStatData1 |= GetLpData1(device1); E84Passiver device2 = DEVICE.GetDevice(GetE84LpName(device)); if (device2 != null) sigStatData1 |= GetE84Data1(device2); } else sigStatData1 = !ModuleHelper.IsLoadLock(ModuleHelper.Converter(device)) ? GetSystemData1() : GetLlData1(); return sigStatData1; } public uint GetSigStatData1(ModuleName module) { uint sigStatData1 = 0; if (ModuleHelper.IsLoadPort(module)) { LoadPortBaseDevice device1 = DEVICE.GetDevice(module.ToString()); if (device1 != null) sigStatData1 |= GetLpData1(device1); E84Passiver device2 = DEVICE.GetDevice(GetE84LpName(module.ToString())); if (device2 != null) sigStatData1 |= GetE84Data1(device2); } else sigStatData1 = !ModuleHelper.IsLoadLock(module) ? GetSystemData1() : GetLlData1(); return sigStatData1; } public uint GetSigStatData2(string device) { uint sigStatData2 = 0; if (IsLoadPort(device)) { LoadPortBaseDevice device1 = DEVICE.GetDevice("L" + device); if (device1 != null) sigStatData2 |= GetLpData2(device1); E84Passiver device2 = DEVICE.GetDevice(GetE84LpName(device)); if (device2 != null) sigStatData2 |= GetE84Data2(device2); } else sigStatData2 = !ModuleHelper.IsLoadLock(ModuleHelper.Converter(device)) ? GetSystemData2() : GetLlData2(); return sigStatData2; } public uint GetSigStatData2(ModuleName module) { uint sigStatData2 = 0; if (ModuleHelper.IsLoadPort(module)) { LoadPortBaseDevice device1 = DEVICE.GetDevice(module.ToString()); if (device1 != null) sigStatData2 |= GetLpData2(device1); E84Passiver device2 = DEVICE.GetDevice(GetE84LpName(module.ToString())); if (device2 != null) sigStatData2 |= GetE84Data2(device2); } else sigStatData2 = !ModuleHelper.IsLoadLock(module) ? GetSystemData2() : GetLlData2(); return sigStatData2; } private uint GetLpData1(LoadPortBaseDevice lp) { uint lpData1 = 0; if (lp != null) lpData1 = (uint)((int)lpData1 | (lp.IsPlacement ? 1 : 0) | (!lp.IsPresent ? 2 : 0)) | 64U | 128U | (!lp.IsWaferProtrude ? 512U : 0U); return lpData1; } private uint GetLpData2(LoadPortBaseDevice lp) { uint lpData2 = 0; if (lp != null) lpData2 = (uint)((int)lpData2 | (lp.IndicatiorPresence == IndicatorState.ON ? 1 : 0) | (lp.IndicatiorPlacement == IndicatorState.ON ? 2 : 0) | (lp.IndicatiorLoad == IndicatorState.ON ? 4 : 0) | (lp.IndicatiorUnload == IndicatorState.ON ? 8 : 0) | (lp.IndicatiorManualMode == IndicatorState.ON ? 16 : 0) | (lp.IndicatorAlarm == IndicatorState.ON ? 32 : 0) | (lp.IndicatiorClampUnclamp == IndicatorState.ON ? 64 : 0) | (lp.IndicatiorDockUndock == IndicatorState.ON ? 128 : 0) | (lp.IndicatiorOpAccess == IndicatorState.ON ? 256 : 0)); return lpData2; } private uint GetE84Data1(E84Passiver e84Lp) { uint e84Data1 = 0; if (e84Lp != null) e84Data1 = (uint)((int)e84Data1 | (e84Lp.DiValid ? 16777216 : 0) | (e84Lp.DiCS0 ? 33554432 : 0) | (e84Lp.DiCS1 ? 67108864 : 0) | (e84Lp.DiTrReq ? 268435456 : 0) | (e84Lp.DiBusy ? 536870912 : 0) | (e84Lp.DiCompt ? 1073741824 : 0) | (e84Lp.DiCont ? int.MinValue : 0)); return e84Data1; } private uint GetE84Data2(E84Passiver e84Lp) { uint e84Data2 = 0; if (e84Lp != null) e84Data2 = (uint)((int)e84Data2 | (e84Lp.DoLoadReq ? 16777216 : 0) | (e84Lp.DoUnloadReq ? 33554432 : 0) | (e84Lp.DoReady ? 134217728 : 0) | (e84Lp.DoHOAvbl ? 1073741824 : 0) | (e84Lp.DoES ? int.MinValue : 0)); return e84Data2; } //private uint GetSystemData1() => (uint)(0 | // (DeviceModel.SensorVACPressureSW.Value ? 1 : 0)| // (DeviceModel.SensorIONCDAPressureSW.Value ? 2 : 0) | // (DeviceModel.SensorCDAPressureSW.Value ? 4 : 0) | // (DeviceModel.SensorWaterFlowSW.Value ? 16 : 0) | // (DeviceModel.SensorWaterLeakSW.Value ? 32 : 0) | // (DeviceModel.SensorEFEMSideDoorClosed.Value ? 64 : 0) | // (DeviceModel.SensorFFUalarm.Value ? 128 : 0) | // (DeviceModel.SensorIONAlarmSIGNAL.Value ? 1024 : 0) | // (DeviceModel.SensorFFUalarm.Value ? 2048 : 0)) | 4096U | // (!DeviceModel.SensorMaintenanceMode.Value && IsOnlineMode ? 8192U : 0U) | // 16384U | (DeviceModel.SensorGratingSensorIN1.Value ? 32768U : 0U); private uint GetSystemData1() => (uint)(0 | (DeviceModel.SensorVACPressureSW.Value ? 1 : 0) | (DeviceModel.SensorIONCDAPressureSW.Value ? 2 : 0) | (DeviceModel.SensorCDAPressureSW.Value ? 4 : 0) | 16 | 32| (!DeviceModel.SensorEFEMSideDoorClosed.Value ? 64 : 0) |128|256|512|1024 | 2048 | 4096U | (IsOnlineMode ? 8192U : 0U) | 16384U | (DeviceModel.SensorGratingSensorIN1.Value ? 32768U : 0U)); private uint GetSystemData2() { uint systemData2 = 0; if (DeviceModel.SignalTower != null) { if (DeviceModel.SignalTower.Red != null) systemData2 |= DeviceModel.SignalTower.Red.StateSetPoint == TowerLightStatus.On ? 1U : 0U; if (DeviceModel.SignalTower.Green != null) systemData2 |= DeviceModel.SignalTower.Green.StateSetPoint == TowerLightStatus.On ? 2U : 0U; if (DeviceModel.SignalTower.Yellow != null) systemData2 |= DeviceModel.SignalTower.Yellow.StateSetPoint == TowerLightStatus.On ? 4U : 0U; if (DeviceModel.SignalTower.Blue != null) systemData2 |= DeviceModel.SignalTower.Blue.StateSetPoint == TowerLightStatus.On ? 8U : 0U; if (DeviceModel.SignalTower.White != null) systemData2 |= DeviceModel.SignalTower.White.StateSetPoint == TowerLightStatus.On ? 16U : 0U; if (DeviceModel.SignalTower.Red != null) systemData2 |= DeviceModel.SignalTower.Red.StateSetPoint == TowerLightStatus.Blinking ? 32U : 0U; if (DeviceModel.SignalTower.Green != null) systemData2 |= DeviceModel.SignalTower.Green.StateSetPoint == TowerLightStatus.Blinking ? 64U : 0U; if (DeviceModel.SignalTower.Yellow != null) systemData2 |= DeviceModel.SignalTower.Yellow.StateSetPoint == TowerLightStatus.Blinking ? 128U : 0U; if (DeviceModel.SignalTower.Blue != null) systemData2 |= DeviceModel.SignalTower.Blue.StateSetPoint == TowerLightStatus.Blinking ? 256U : 0U; if (DeviceModel.SignalTower.White != null) systemData2 |= DeviceModel.SignalTower.White.StateSetPoint == TowerLightStatus.Blinking ? 512U : 0U; if (DeviceModel.SignalTower.Buzzer1 != null) systemData2 |= DeviceModel.SignalTower.Buzzer1.StateSetPoint == TowerLightStatus.On ? 1024U : 0U; if (DeviceModel.SignalTower.Buzzer2 != null) systemData2 |= DeviceModel.SignalTower.Buzzer2.StateSetPoint == TowerLightStatus.On ? 2048U : 0U; } return systemData2; } private uint GetLlData1() => (uint)(0 | (LoadLockDevice.LoadLockAtmDoorState == LoadLockDoorState.Opened ? 16 : 0) | (LoadLockDevice.LoadLockVtmDoorState == LoadLockDoorState.Opened ? 32 : 0)); private uint GetLlData2() => 0; private bool IsLoadPort(string device) => device == "P1" || device == "P2" || device == "P3" || device == "P4"; public string GetE84LpName(string device) { string e84LpName = string.Empty; switch (device) { case "LP1": case "P1": e84LpName = "Loadport1E84"; break; case "LP10": case "P10": e84LpName = "Loadport10E84"; break; case "LP2": case "P2": e84LpName = "Loadport2E84"; break; case "LP3": case "P3": e84LpName = "Loadport3E84"; break; case "LP4": case "P4": e84LpName = "Loadport4E84"; break; case "LP5": case "P5": e84LpName = "Loadport5E84"; break; case "LP6": case "P6": e84LpName = "Loadport6E84"; break; case "LP7": case "P7": e84LpName = "Loadport7E84"; break; case "LP8": case "P8": e84LpName = "Loadport8E84"; break; case "LP9": case "P9": e84LpName = "Loadport9E84"; break; } return e84LpName; } private string ModuleName2ProtocolName(ModuleName module) { string str = "System"; switch (module) { case ModuleName.LP1: str = "P1"; break; case ModuleName.LP2: str = "P2"; break; case ModuleName.LP3: str = "P3"; break; case ModuleName.LP4: str = "P4"; break; case ModuleName.LP5: str = "P5"; break; case ModuleName.LP6: str = "P6"; break; case ModuleName.LP7: str = "P7"; break; case ModuleName.LP8: str = "P8"; break; case ModuleName.LP9: str = "P9"; break; case ModuleName.LP10: str = "P10"; break; case ModuleName.LL1: str = "LLA"; break; case ModuleName.LL2: str = "LLB"; break; case ModuleName.LL3: str = "LLC"; break; case ModuleName.LL4: str = "LLD"; break; case ModuleName.LL5: str = "LLE"; break; case ModuleName.LL6: str = "LLF"; break; case ModuleName.LL7: str = "LLG"; break; case ModuleName.LL8: str = "LLH"; break; } return str; } public enum ServerState { Init, Listening, Connected, } public enum MSG { Online, Offline, NewSessionConnected, Listening, Reset, Error, Disconnect, ReceiveData, SendData, } } }