123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832 |
- 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<ITaskT> _activeTaskList = new List<ITaskT>();
- private TaskFactory _factory = new TaskFactory();
- private DeviceTimer _sendReadyTimer = new DeviceTimer();
- private List<ModuleName> LPs;
- private List<string> LLs;
- private Dictionary<ModuleName, RD_TRIG> _trigLpPresent = new Dictionary<ModuleName, RD_TRIG>();
- private Dictionary<string, Tuple<uint, uint>> _sigData = new Dictionary<string, Tuple<uint, uint>>();
- private Dictionary<ModuleName, EfemModuleStatus> _efemModuleStatus = new Dictionary<ModuleName, EfemModuleStatus>();
- 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<ModuleName>(Singleton<DeviceManager>.Instance.LpNames);
- foreach (ModuleName lp in LPs)
- _trigLpPresent[lp] = new RD_TRIG();
- LLs = new List<string>((IEnumerable<string>)Singleton<DeviceManager>.Instance.LLNames);
- int port = 13000;
- if (!SC.ContainsItem("System.EfemPortNumber"))
- LogObject.Error("EFEM", "Not define System.EfemPortNumber");
- else
- port = SC.GetValue<int>("System.EfemPortNumber");
- //获取端口 用于服务的发布
- _socket = new SocketServer((IServerCallback)this, port);
- fsm = (IStateMachine)new StateMachine<EfemEntity>(Name, 0, 50);
- BuildTransitionTable();
- Subscribe();
- }
- public void SetEfemData()
- {
- foreach (ModuleName installModule in GetInstallModules())
- _efemModuleStatus[installModule] = new EfemModuleStatus(installModule);
- }
- public IEnumerable<ModuleName> GetInstallModules() => (IEnumerable<ModuleName>)new List<ModuleName>()
- {
- 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>)(() => (object)(fsm.State == 2)), SubscriptionAttribute.FLAG.SaveDB);
- DATA.Subscribe("System.IsHold", (Func<object>)(() => (object)IsSystemHold), SubscriptionAttribute.FLAG.SaveDB);
- DATA.Subscribe("System.IsOnlineMode", (Func<object>)(() => (object)IsOnlineMode), SubscriptionAttribute.FLAG.SaveDB);
- DATA.Subscribe("System.ServerStatus", (Func<object>)(() => (object)((EfemEntity.ServerState)fsm.State).ToString()), SubscriptionAttribute.FLAG.SaveDB);
- DATA.Subscribe($"Server.Status", () => ((ServerState)fsm.State).ToString());
- OP.Subscribe("Online", (Func<string, object[], bool>)((cmd, param) =>
- {
- Trace.WriteLine("执行Online");
- if (IsOnlineMode)
- return true;
- if (!Singleton<RouteManager1>.Instance.IsRunning)
- {
- if (CheckToPostMsg(EfemEntity.MSG.Online))
- {
- LogObject.Info("EFEM", $"Switch to Online Mode.The Address is {SC.GetStringValue("System.EfemServerLocalIp")}:{SC.GetValue<int>("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<string, object[], bool>)((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<EfemEntity.MSG>(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<EfemEntity.MSG>(msg, param1);
- return true;
- }
- private bool FsmNewSessionConnected(object[] param)
- {
- _sessionId = (string)param[0];
- _activeTaskList.Clear();
- IsCommunicationOk = false;
- if (IsOnlineMode)
- DEVICE.GetDevice<Devices.IoSignalTower>("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<int>("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>(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<EfemCommandType>(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<EfemCommand>(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<string>)source).Skip<string>(2).Take<string>(source.Length).ToArray<string>());
- }
- 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<string>)source).Skip<string>(2).Take<string>(source.Length).ToArray<string>();
- 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<IoSignalTower>("SignalTower");
- device.HostControl = true;
- device.Reset();
- return true;
- }
- private bool FsmSetOffline(object[] param)
- {
- IsOnlineMode = false;
- IoSignalTower device = DEVICE.GetDevice<IoSignalTower>("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<int>("Server.SendReadyInterval"))
- {
- _sendReadyTimer.Start(0.0);
- SendMessage("INF:READY/COMM");
- }
- return true;
- }
- MonitorRunningTask();
- MonitorEvent();
- return true;
- }
- private void MonitorRunningTask()
- {
- List<ITaskT> source = new List<ITaskT>();
- 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<ITaskT>())
- return;
- foreach (ITaskT taskT in source)
- _activeTaskList.Remove(taskT);
- }
- private void MonitorEvent() => MonitorSigStatEvent();
- private void MonitorSigStatEvent()
- {
- if (!((SystemServerModule)Singleton<EntityFactory>.Instance.GetEntity("System")).IsEventEnabled(EfemEventType.ALL))
- return;
- bool flag1 = ((SystemServerModule)Singleton<EntityFactory>.Instance.GetEntity("System")).IsEventEnabled(EfemEventType.PORT);
- bool flag2 = ((SystemServerModule)Singleton<EntityFactory>.Instance.GetEntity("System")).IsEventEnabled(EfemEventType.SYSTEM);
- Dictionary<string, Tuple<uint, uint>> sigStatData = GetSigStatData();
- if (sigStatData == null)
- return;
- foreach (KeyValuePair<string, Tuple<uint, uint>> 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<string, Tuple<uint, uint>> GetSigStatData()
- {
- Dictionary<string, Tuple<uint, uint>> sigStatData = new Dictionary<string, Tuple<uint, uint>>();
- ModuleName[] moduleNameArray = new ModuleName[3]
- {
- ModuleName.System,
- ModuleName.LP1,
- ModuleName.LP2
- };
- foreach (ModuleName module in moduleNameArray)
- sigStatData[ModuleName2ProtocolName(module)] = Tuple.Create<uint, uint>(GetSigStatData1(module), GetSigStatData2(module));
- return sigStatData;
- }
- private ModuleName ProtocolName2ModuleName(string protocol)
- {
- ModuleName moduleName = ModuleName.System;
- Dictionary<string, ModuleName> dictionary = new Dictionary<string, ModuleName>()
- {
- {
- "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<int>("System.EfemPortNumber");
- _sendReadyTimer.Start(0.0);
- if (_socket.Start(stringValue, port))
- PostMsg<EfemEntity.MSG>(EfemEntity.MSG.Listening);
- }
- /// <summary>
- /// 此处将wafermanager中对应lp数据进行发送
- /// </summary>
- /// <param name="lp"></param>
- public void SendMapEvent(LoadPortBaseDevice lp)
- {
- WaferInfo[] wafers = Singleton<WaferManager>.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<LoadPortBaseDevice>("L" + device);
- if (device1 != null)
- sigStatData1 |= GetLpData1(device1);
- E84Passiver device2 = DEVICE.GetDevice<E84Passiver>(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<LoadPortBaseDevice>(module.ToString());
- if (device1 != null)
- sigStatData1 |= GetLpData1(device1);
- E84Passiver device2 = DEVICE.GetDevice<E84Passiver>(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<LoadPortBaseDevice>("L" + device);
- if (device1 != null)
- sigStatData2 |= GetLpData2(device1);
- E84Passiver device2 = DEVICE.GetDevice<E84Passiver>(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<LoadPortBaseDevice>(module.ToString());
- if (device1 != null)
- sigStatData2 |= GetLpData2(device1);
- E84Passiver device2 = DEVICE.GetDevice<E84Passiver>(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,
- }
- }
- }
|