EfemEntity.cs 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Collections.Specialized;
  5. using System.Linq;
  6. using System.Threading;
  7. using Aitex.Core.Common;
  8. using Aitex.Core.RT.DataCenter;
  9. using Aitex.Core.RT.Device;
  10. using Aitex.Core.RT.Device.Unit;
  11. using Aitex.Core.RT.Event;
  12. using Aitex.Core.RT.Fsm;
  13. using Aitex.Core.RT.Log;
  14. using Aitex.Core.RT.OperationCenter;
  15. using Aitex.Core.RT.SCCore;
  16. using Aitex.Core.Util;
  17. using EFEM.RT.Devices;
  18. using EFEM.RT.Modules;
  19. using EFEM.RT.Tasks;
  20. using Aitex.Sorter.Common;
  21. using Efem;
  22. using Efem.Protocol;
  23. using EFEMSC;
  24. using MECF.Framework.Common.Device.Bases;
  25. using MECF.Framework.Common.Equipment;
  26. using MECF.Framework.Common.SubstrateTrackings;
  27. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  28. using IEntity = Aitex.Core.RT.Fsm.IEntity;
  29. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  30. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  31. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.BufferStations;
  32. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
  33. namespace EFEM.RT
  34. {
  35. public class EfemModuleStatus
  36. {
  37. private bool _isInitialized;
  38. public bool IsInitialized
  39. {
  40. get
  41. {
  42. return _isInitialized;
  43. }
  44. set
  45. {
  46. _isInitialized = value;
  47. TrigInitialized.CLK = value;
  48. }
  49. }
  50. public R_TRIG TrigInitialized { get; set; }
  51. public ModuleName Module { get; set; }
  52. public EfemModuleStatus(ModuleName module)
  53. {
  54. Module = module;
  55. TrigInitialized = new R_TRIG();
  56. }
  57. }
  58. public class EfemEntity : Entity, IEntity, IServerCallback
  59. {
  60. public enum ServerState
  61. {
  62. Init,
  63. Listening,
  64. Connected,
  65. }
  66. public enum MSG
  67. {
  68. Online,
  69. Offline,
  70. NewSessionConnected,
  71. Listening,
  72. Reset,
  73. Error,
  74. Disconnect,
  75. ReceiveData,
  76. SendData,
  77. }
  78. private SocketServer _socket = null;
  79. private string _sessionId;
  80. private List<ITaskT> _activeTaskList = new List<ITaskT>();
  81. private TaskFactory _factory = new TaskFactory();
  82. public string Name { get; set; }
  83. public bool IsCommunicationOk { get; set; }
  84. public bool IsOnlineMode { get; private set; }
  85. private bool IsSystemHold { get; set; }
  86. DeviceTimer _sendReadyTimer = new DeviceTimer();
  87. private List<ModuleName> LPs;
  88. private List<string> LLs;
  89. private Dictionary<ModuleName, RD_TRIG> _trigLpPresent = new Dictionary<ModuleName, RD_TRIG>();
  90. private Dictionary<string, Tuple<uint, uint>> _sigData = new Dictionary<string, Tuple<uint, uint>>();
  91. private Dictionary<ModuleName, EfemModuleStatus> _efemModuleStatus = new Dictionary<ModuleName, EfemModuleStatus>();
  92. private readonly bool _MaintenanceMode = DeviceDefineManager.Instance.GetValue<bool>("MaintenanceSignal") ?? false;
  93. private readonly bool _EfemDoorOpen = DeviceDefineManager.Instance.GetValue<bool>("EfemDoorOpenSignal") ?? false;
  94. public EfemEntity()
  95. {
  96. Name = "Efem";
  97. IsOnlineMode = true;
  98. LPs = new List<ModuleName>(Singleton<DeviceManager>.Instance.LpNames);
  99. foreach (var moduleName in LPs)
  100. {
  101. _trigLpPresent[moduleName] = new RD_TRIG();
  102. }
  103. LLs = new List<string>(Singleton<DeviceManager>.Instance.LLNames);
  104. int port = 13000;
  105. if (!SC.ContainsItem("System.EfemPortNumber"))
  106. {
  107. LOG.Write("Not define System.EfemPortNumber");
  108. }
  109. else
  110. {
  111. port = SC.GetValue<int>("System.EfemPortNumber");
  112. }
  113. _socket = new SocketServer(this, port);
  114. fsm = new StateMachine<EfemEntity>(Name, (int)ServerState.Init, 50);
  115. Singleton<EventManager>.Instance.OnEvent += Instance_OnEvent;
  116. _eventError = new FixSizeQueue<EventItem>(100);
  117. BuildTransitionTable();
  118. Subscribe();
  119. }
  120. public FixSizeQueue<EventItem> EventError
  121. {
  122. get { return _eventError;}
  123. }
  124. private bool IsErrorReportEnable
  125. {
  126. get
  127. {
  128. if (SC.ContainsItem("System.IsErrorReportEnable"))
  129. return SC.GetValue<bool>("System.IsErrorReportEnable");
  130. return false;
  131. }
  132. }
  133. public string EFemNum
  134. {
  135. get
  136. {
  137. if (SC.ContainsItem("System.EFEMNUM"))
  138. return SC.GetStringValue("System.EFEMNUM");
  139. return "001";
  140. }
  141. }
  142. public bool IsEnableMultiWaferSize
  143. {
  144. get
  145. {
  146. if (SC.ContainsItem("System.IsEnableMultiWaferSize"))
  147. return SC.GetValue<bool>("System.IsEnableMultiWaferSize");
  148. return false;
  149. }
  150. }
  151. private FixSizeQueue<EventItem> _eventError;
  152. private void Instance_OnEvent(EventItem obj)
  153. {
  154. if (obj.Level == EventLevel.Alarm) // (obj.Level == EventLevel.Warning ||
  155. {
  156. _eventError.Enqueue(obj);
  157. }
  158. }
  159. public void SetEfemData()
  160. {
  161. foreach (var module in GetInstallModules())
  162. {
  163. _efemModuleStatus[module] = new EfemModuleStatus(module);
  164. }
  165. }
  166. public IEnumerable<ModuleName> GetInstallModules()
  167. {
  168. return new List<ModuleName>()
  169. {
  170. ModuleName.System, ModuleName.Robot, ModuleName.Buffer1,
  171. ModuleName.LP1, ModuleName.LP2, ModuleName.LP3, ModuleName.LP4,
  172. ModuleName.LL1, ModuleName.LL2,
  173. };
  174. }
  175. public void SetInitialize(ModuleName module, bool initialized)
  176. {
  177. if (_efemModuleStatus.ContainsKey(module))
  178. {
  179. _efemModuleStatus[module].IsInitialized = initialized;
  180. }
  181. }
  182. private void Subscribe()
  183. {
  184. DATA.Subscribe("Efem.IsCommunicationReady", () => fsm.State == (int)ServerState.Connected);
  185. DATA.Subscribe("System.IsHold", () => IsSystemHold);
  186. DATA.Subscribe("System.IsOnlineMode", () => IsOnlineMode);
  187. DATA.Subscribe("System.ServerStatus", () => ((ServerState)fsm.State).ToString());
  188. OP.Subscribe(OperationName.Online, (cmd, param) =>
  189. {
  190. if (IsOnlineMode)
  191. return true;
  192. if (Singleton<RouteManager>.Instance.IsRunning)
  193. {
  194. EV.PostWarningLog("Server", "System is busy, can not switch to online");
  195. return true;
  196. }
  197. return CheckToPostMsg(MSG.Online);
  198. });
  199. OP.Subscribe(OperationName.Offline, (cmd, param) =>
  200. {
  201. if (!IsOnlineMode)
  202. return true;
  203. return CheckToPostMsg(MSG.Offline);
  204. });
  205. }
  206. private void BuildTransitionTable()
  207. {
  208. //online offline
  209. AnyStateTransition(MSG.Offline, FsmSetOffline, FSM_STATE.SAME);
  210. AnyStateTransition(MSG.Online, FsmSetOnline, FSM_STATE.SAME);
  211. //init
  212. EnterExitTransition<ServerState, FSM_MSG>(ServerState.Init, FsmEnterInit, FSM_MSG.NONE, null);
  213. Transition(ServerState.Init, MSG.Listening, null, ServerState.Listening);
  214. Transition(ServerState.Init, MSG.Reset, FsmEnterInit, ServerState.Init);
  215. //listening
  216. Transition(ServerState.Listening, MSG.Error, null, ServerState.Init);
  217. Transition(ServerState.Listening, MSG.NewSessionConnected, FsmNewSessionConnected, ServerState.Connected);
  218. //Connected
  219. Transition(ServerState.Connected, MSG.Disconnect, FsmDisconnect, ServerState.Listening);
  220. Transition(ServerState.Connected, MSG.Error, null, ServerState.Init);
  221. Transition(ServerState.Connected, MSG.NewSessionConnected, FsmNewSessionConnected, ServerState.Connected);
  222. Transition(ServerState.Connected, MSG.ReceiveData, FsmReceiveData, ServerState.Connected);
  223. Transition(ServerState.Connected, MSG.SendData, FsmSendData, ServerState.Connected);
  224. Transition(ServerState.Connected, FSM_MSG.TIMER, FsmMonitor, ServerState.Connected);
  225. }
  226. ~EfemEntity()
  227. {
  228. _socket?.Stop();
  229. }
  230. public bool SetSystemHold()
  231. {
  232. if (IsSystemHold)
  233. {
  234. return false;
  235. }
  236. IsSystemHold = true;
  237. return true;
  238. }
  239. public bool SetSystemUnHold()
  240. {
  241. if (!IsSystemHold)
  242. {
  243. return true;
  244. }
  245. IsSystemHold = false;
  246. return true;
  247. }
  248. #region FSM Functions
  249. public bool CheckToPostMsg(MSG msg)
  250. {
  251. if (!fsm.FindTransition(fsm.State, (int)msg))
  252. {
  253. EV.PostWarningLog("System", string.Format("{0} is in {1} state,can not do {2}", Name, (ServerState)fsm.State, (MSG)msg));
  254. return false;
  255. }
  256. PostMsg(msg);
  257. return true;
  258. }
  259. public bool CheckToPostMsg(MSG msg, object param1)
  260. {
  261. if (!fsm.FindTransition(fsm.State, (int)msg))
  262. {
  263. EV.PostWarningLog("System", string.Format("{0} is in {1} state,can not do {2}", Name, (ServerState)fsm.State, (MSG)msg));
  264. return false;
  265. }
  266. PostMsg(msg, param1);
  267. return true;
  268. }
  269. private bool FsmNewSessionConnected(object[] param)
  270. {
  271. _sessionId = (string)param[0];
  272. _activeTaskList.Clear();
  273. IsCommunicationOk = false;
  274. if (IsOnlineMode)
  275. {
  276. IoSignalTower tower = DEVICE.GetDevice<IoSignalTower>(DeviceName.SignalTower);
  277. tower.HostControl = true;
  278. }
  279. return true;
  280. }
  281. private bool FsmDisconnect(object[] param)
  282. {
  283. var sessionId = (string)param[0];
  284. if (sessionId != _sessionId)
  285. return false;
  286. return true;
  287. }
  288. private bool FsmEnterInit(object[] param)
  289. {
  290. string ip = SC.GetStringValue("System.EfemServerLocalIp");
  291. int port = SC.GetValue<int>("System.EfemPortNumber");
  292. _sendReadyTimer.Start(0);
  293. if (string.IsNullOrEmpty(ip))
  294. ip = "127.0.0.1";
  295. if (_socket.Start(ip, port))
  296. {
  297. PostMsg(MSG.Listening);
  298. return true;
  299. }
  300. return false;
  301. }
  302. private bool FsmSendData(object[] param)
  303. {
  304. _socket.Send((string)param[0]);
  305. return true;
  306. }
  307. public string commandrecive = null;
  308. private bool FsmReceiveData(object[] param)
  309. {
  310. try
  311. {
  312. commandrecive= (string)param[0];
  313. string rawMessage = (string)param[0];
  314. string[] words = rawMessage.Split(new char[5] { ':', '/', '>', '|', ';' }, StringSplitOptions.RemoveEmptyEntries);
  315. if (rawMessage.Contains("SET:CSTID"))
  316. {
  317. words = new string[] { words[0], words[1], words[2], rawMessage.Remove(0, 13) };
  318. }
  319. if (!Enum.TryParse<EfemCommandType>(words[0], out EfemCommandType type))
  320. {
  321. LOG.Write($"{rawMessage} is not a valid EFEM message format");
  322. SendMessage("NAK:" + rawMessage.Split(':')[1]);
  323. return true;
  324. }
  325. if (!Enum.TryParse<EfemCommand>(words[1], out EfemCommand cmd))
  326. {
  327. LOG.Write($"{rawMessage} is not a valid EFEM message format");
  328. SendMessage("NAK:" + rawMessage.Split(':')[1]);
  329. return true;
  330. }
  331. string commandData = rawMessage.Substring(rawMessage.IndexOf(':'));
  332. if (type == EfemCommandType.ACK)
  333. {
  334. //special for handshake
  335. if (!IsCommunicationOk && (rawMessage == "ACK:READY/COMM"))
  336. {
  337. IsCommunicationOk = true;
  338. return true;
  339. }
  340. foreach (ITaskT active in _activeTaskList)
  341. {
  342. if (active.CommandData == commandData && active.CommandType == type && active.CommandName == cmd)
  343. {
  344. active.Ack(type, cmd, words.Skip(2).Take(words.Length).ToArray());
  345. }
  346. }
  347. return true;
  348. }
  349. if (_factory.UnSupport(type, cmd))
  350. {
  351. LOG.Write($"{rawMessage} is not a valid EFEM message format");
  352. SendMessage("NAK:" + rawMessage.Split(':')[1]);
  353. return true;
  354. }
  355. ITaskT task = _factory.Create(type, cmd);
  356. task.CommandData = commandData;
  357. foreach (ITaskT active in _activeTaskList)
  358. {
  359. if (active.CommandData == commandData && active.CommandType == type && active.CommandName == cmd)
  360. {
  361. EV.PostWarningLog("EFEM", $"ignored {rawMessage}, already active");
  362. return true;
  363. }
  364. }
  365. if (task.Execute(out string resp, rawMessage, words.Skip(2).Take(words.Length).ToArray()))
  366. {
  367. _activeTaskList.Add(task);
  368. }
  369. SendMessage(resp);
  370. }
  371. catch (Exception ex)
  372. {
  373. LOG.Write(ex);
  374. }
  375. return true;
  376. }
  377. private bool FsmSetOnline(object[] param)
  378. {
  379. IsOnlineMode = true;
  380. IoSignalTower tower = DEVICE.GetDevice<IoSignalTower>(DeviceName.SignalTower);
  381. tower.HostControl = true;
  382. tower.Reset();
  383. return true;
  384. }
  385. private bool FsmSetOffline(object[] param)
  386. {
  387. IsOnlineMode = false;
  388. IoSignalTower tower = DEVICE.GetDevice<IoSignalTower>(DeviceName.SignalTower);
  389. tower.HostControl = false;
  390. tower.Reset();
  391. return true;
  392. }
  393. #endregion
  394. #region Server Callback
  395. public void OnConnected(string sessionId)
  396. {
  397. CheckToPostMsg(MSG.NewSessionConnected, sessionId);
  398. }
  399. public void OnDisconnected(string sessionId)
  400. {
  401. CheckToPostMsg(MSG.Disconnect, sessionId);
  402. }
  403. public void OnReceived(string msg)
  404. {
  405. CheckToPostMsg(MSG.ReceiveData, msg);
  406. }
  407. #endregion
  408. #region Server Monitor
  409. public void SendMessage(string msg)
  410. {
  411. if (IsCommunicationOk || msg == "INF:READY/COMM")
  412. {
  413. CheckToPostMsg(MSG.SendData, msg);
  414. }
  415. }
  416. private bool FsmMonitor(object[] objs)
  417. {
  418. if (!IsCommunicationOk)
  419. {
  420. if (_sendReadyTimer.GetElapseTime() > SC.GetValue<int>(ScPathName.Server_SendReadyInterval))
  421. {
  422. _sendReadyTimer.Start(0);
  423. SendMessage("INF:READY/COMM");
  424. }
  425. return true;
  426. }
  427. MonitorRunningTask();
  428. MonitorEvent();
  429. return true;
  430. }
  431. private void MonitorRunningTask()
  432. {
  433. List<ITaskT> tobeRemoved = new List<ITaskT>();
  434. foreach (ITaskT task in _activeTaskList)
  435. {
  436. if (!task.HasInfoMessage)
  437. {
  438. tobeRemoved.Add(task);
  439. continue;
  440. }
  441. string msg = string.Empty;
  442. bool? ret = task.Monitor(out msg);
  443. if (ret.HasValue)
  444. {
  445. SendMessage(msg);
  446. tobeRemoved.Add(task);
  447. break;
  448. }
  449. }
  450. if (tobeRemoved.Any())
  451. {
  452. foreach (var task in tobeRemoved)
  453. {
  454. _activeTaskList.Remove(task);
  455. }
  456. }
  457. }
  458. private void MonitorEvent()
  459. {
  460. // if (_efemData.IsSigStatEventMode)
  461. // {
  462. MonitorSigStatEvent();
  463. MonitorErrorEvent();
  464. return;
  465. //}
  466. //if (LPs.Any() && ((SystemServerModule)Singleton<EntityFactory>.Instance.GetEntity(DeviceName.System)).IsEventEnabled(EfemEventType.PORT))
  467. //{
  468. // foreach (var lpName in LPs)
  469. // {
  470. // var lp = DEVICE.GetDevice<LoadPortBaseDevice>(lpName.ToString());
  471. // _trigLpPresent[lpName].CLK = lp.IsPresent && lp.IsPlacement;
  472. // if (_trigLpPresent[lpName].T || _trigLpPresent[lpName].R)
  473. // {
  474. // Thread.Sleep(300);
  475. // SendSigStatEvent(lpName);
  476. // }
  477. // }
  478. //}
  479. }
  480. private void MonitorErrorEvent()
  481. {
  482. if (IsErrorReportEnable && _eventError != null && _eventError.Count > 0)
  483. {
  484. EventItem ev;
  485. //while (_eventError.TryDequeue(out ev))
  486. if (_eventError.TryDequeue(out ev))
  487. {
  488. string source = "System";
  489. if (ev.Source.Contains("Robot"))
  490. source = "ROB";
  491. if (ev.Source.Contains("LP"))
  492. source = ev.Source.Replace("L","");
  493. SendMessage($"INF:ERROR/{ev.Description}/{source}");// Level: ({ ev.Level}),
  494. }
  495. // SendMessage($"EVT:ERROR/{ev.Source}/{ev.Level}/{ev.Description}");
  496. }
  497. }
  498. private void MonitorSigStatEvent()
  499. {
  500. bool allEnable = ((SystemServerModule)Singleton<EntityFactory>.Instance.GetEntity(DeviceName.System)).IsEventEnabled(EfemEventType.ALL);
  501. if (!allEnable)
  502. return;
  503. bool lpEnable = ((SystemServerModule)Singleton<EntityFactory>.Instance.GetEntity(DeviceName.System)).IsEventEnabled(EfemEventType.PORT);
  504. bool sysEnable = ((SystemServerModule)Singleton<EntityFactory>.Instance.GetEntity(DeviceName.System)).IsEventEnabled(EfemEventType.SYSTEM);
  505. Dictionary<string, Tuple<uint, uint>> sigDatas = GetSigStatData();
  506. if (sigDatas == null)
  507. return;
  508. foreach (var sigData in sigDatas)
  509. {
  510. if (sigData.Key.StartsWith("P") && !lpEnable)
  511. continue;
  512. if (sigData.Key.StartsWith(EfemParameter.SYS) && !sysEnable)
  513. continue;
  514. ModuleName module = ProtocolName2ModuleName(sigData.Key);
  515. if ((!_efemModuleStatus[module].IsInitialized))
  516. continue;
  517. if (_efemModuleStatus[module].TrigInitialized.Q)
  518. {
  519. _efemModuleStatus[module].TrigInitialized.CLK = true;
  520. _sigData.Remove(sigData.Key);
  521. continue;
  522. }
  523. if (_sigData.ContainsKey(sigData.Key)
  524. && _sigData[sigData.Key].Item1 == sigData.Value.Item1
  525. && _sigData[sigData.Key].Item2 == sigData.Value.Item2)
  526. {
  527. continue;
  528. }
  529. _sigData[sigData.Key] = sigData.Value;
  530. if((!commandrecive.Contains("INIT/SYSTEM")&& (sigData.Key.Equals("P1")|| sigData.Key.Equals("P2")) || sigData.Key.Equals("System")))
  531. SendMessage($"EVT:SIGSTAT/{sigData.Key}/{_sigData[sigData.Key].Item1:X8}/{_sigData[sigData.Key].Item2:X8}");
  532. //if(commandrecive.Contains("INIT/SYSTEM"))
  533. //commandrecive = "";
  534. }
  535. }
  536. #endregion
  537. public Dictionary<string, Tuple<uint, uint>> GetSigStatData()
  538. {
  539. var result = new Dictionary<string, Tuple<uint, uint>>();
  540. ModuleName[] lstModule = new ModuleName[] { ModuleName.System, ModuleName.LP1, ModuleName.LP2 };
  541. foreach (var moduleName in lstModule)
  542. {
  543. if (DeviceDefineManager.Instance.GetValue<int>("LoadPortQuantity") == 1)
  544. {
  545. if(moduleName != ModuleName.LP2)
  546. result[ModuleName2ProtocolName(moduleName)] = Tuple.Create(GetSigStatData1(moduleName), GetSigStatData2(moduleName));
  547. }
  548. else
  549. {
  550. result[ModuleName2ProtocolName(moduleName)] = Tuple.Create(GetSigStatData1(moduleName), GetSigStatData2(moduleName));
  551. }
  552. }
  553. return result;
  554. }
  555. private ModuleName ProtocolName2ModuleName(string protocol)
  556. {
  557. ModuleName module = ModuleName.System;
  558. Dictionary<string, ModuleName> map = new Dictionary<string, ModuleName>()
  559. {
  560. {"P1", ModuleName.LP1},{"P2", ModuleName.LP2},
  561. {"SYS", ModuleName.System},
  562. };
  563. if (map.ContainsKey(protocol))
  564. module = map[protocol];
  565. return module;
  566. }
  567. protected override bool Init()
  568. {
  569. return true;
  570. }
  571. protected override void Term()
  572. {
  573. if (_socket != null)
  574. _socket.Stop();
  575. }
  576. public bool Check(int msg, out string reason, params object[] args)
  577. {
  578. if (!fsm.FindTransition(fsm.State, msg))
  579. {
  580. reason = String.Format("{0} is in {1} state,can not do {2}", Name, (ServerState)fsm.State, (MSG)msg);
  581. return false;
  582. }
  583. reason = "";
  584. return true;
  585. }
  586. public void Reset()
  587. {
  588. if (fsm.State == (int)ServerState.Init)
  589. {
  590. string ip = SC.GetStringValue("System.EfemServerLocalIp");
  591. int port = SC.GetValue<int>("System.EfemPortNumber");
  592. _sendReadyTimer.Start(0);
  593. if (_socket.Start(ip, port))
  594. {
  595. PostMsg(MSG.Listening);
  596. }
  597. }
  598. }
  599. public bool IsSlotShowOpposite
  600. {
  601. get
  602. {
  603. if (SC.ContainsItem("System.IsSlotShowOpposite"))
  604. return SC.GetValue<bool>("System.IsSlotShowOpposite");
  605. return false;
  606. }
  607. }
  608. public void SendMapEvent(LoadPortBaseDevice lp)
  609. {
  610. WaferInfo[] wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(lp.Name));
  611. string slot = "";
  612. for (int i = 0; i < lp.ValidSlotsNumber; i++)
  613. {
  614. switch (wafers[i].Status)//IsSlotShowOpposite? wafers[lp.ValidSlotsNumber - i - 1].Status:
  615. {
  616. case WaferStatus.Empty:
  617. slot += "0";
  618. break;
  619. case WaferStatus.Normal:
  620. slot += "1";
  621. break;
  622. case WaferStatus.Crossed:
  623. slot += "3";
  624. break;
  625. case WaferStatus.Double:
  626. slot += "7";
  627. break;
  628. case WaferStatus.Unknown:
  629. slot += "8";
  630. break;
  631. case WaferStatus.Dummy:
  632. slot += "4";
  633. break;
  634. }
  635. }
  636. var slotmap = slot;
  637. if (lp.IsError)
  638. {
  639. slotmap = string.Empty;
  640. }
  641. string message = string.Format("EVT:MAPDT/{0}/{1}", ModuleName2ProtocolName(ModuleHelper.Converter(lp.Name)), slotmap);
  642. SendMessage(message);
  643. }
  644. public void SendMapEvent(BufferStation lp)
  645. {
  646. WaferInfo[] wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(lp.Name));
  647. string slot = "";
  648. for (int i = 0; i < lp.ValidSlotsNumber; i++)
  649. {
  650. switch (wafers[i].Status)
  651. {
  652. case WaferStatus.Empty:
  653. slot += "0";
  654. break;
  655. case WaferStatus.Normal:
  656. slot += "1";
  657. break;
  658. case WaferStatus.Crossed:
  659. slot += "3";
  660. break;
  661. case WaferStatus.Double:
  662. slot += "7";
  663. break;
  664. case WaferStatus.Unknown:
  665. slot += "8";
  666. break;
  667. case WaferStatus.Dummy:
  668. slot += "4";
  669. break;
  670. }
  671. }
  672. var slotmap = slot;
  673. //if (lp.IsError)
  674. //{
  675. // slotmap = string.Empty;
  676. //}
  677. string message = string.Format("EVT:MAPDT/{0}/{1}", ModuleName2ProtocolName(ModuleHelper.Converter(lp.Name)), slotmap);
  678. SendMessage(message);
  679. }
  680. public void SendSigStatEvent(ModuleName module)
  681. {
  682. uint data1 = GetSigStatData1(module);
  683. uint data2 = GetSigStatData2(module);
  684. string message = message = string.Format("EVT:SIGSTAT/{0}/{1:X8}/{2:X8}", ModuleName2ProtocolName(module), data1, data2);
  685. SendMessage(message);
  686. }
  687. public uint GetSigStatData1(string device)
  688. {
  689. uint data1 = 0x0u;
  690. if (IsLoadPort(device))
  691. {
  692. //Loadport inputs
  693. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(device);
  694. if (lp != null)
  695. {
  696. data1 |= GetLpData1(lp);
  697. }
  698. var e84Lp = DEVICE.GetDevice<E84Passiver>(GetE84LpName(device));
  699. if (e84Lp != null)
  700. {
  701. data1 |= GetE84Data1(e84Lp);
  702. }
  703. }
  704. else if (ModuleHelper.IsLoadLock(ModuleHelper.Converter(device)))
  705. {
  706. data1 = GetLlData1();
  707. }
  708. else
  709. {
  710. data1 = GetSystemData1();
  711. }
  712. return data1;
  713. }
  714. public uint GetSigStatData1(ModuleName module)
  715. {
  716. uint data1 = 0x0u;
  717. if (ModuleHelper.IsLoadPort(module))
  718. {
  719. //Loadport inputs
  720. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(module.ToString());
  721. if (lp != null)
  722. {
  723. //if(!commandrecive.Contains("INIT/SYSTEM"))
  724. data1 |= GetLpData1(lp);
  725. }
  726. var e84Lp = DEVICE.GetDevice<E84Passiver>(GetE84LpName(module.ToString()));
  727. if (e84Lp != null)
  728. {
  729. // if (!commandrecive.Contains("INIT/SYSTEM"))
  730. data1 |= GetE84Data1(e84Lp);
  731. }
  732. }
  733. else if (ModuleHelper.IsLoadLock(module))
  734. {
  735. data1 = GetLlData1();
  736. }
  737. else
  738. {
  739. data1 = GetSystemData1();
  740. }
  741. return data1;
  742. }
  743. public uint GetSigStatData2(string device)
  744. {
  745. uint data2 = 0x0u;
  746. if (IsLoadPort(device))
  747. {
  748. // Loadport outputs
  749. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(device);
  750. if (lp != null)
  751. {
  752. //if (!commandrecive.Contains("INIT/SYSTEM"))
  753. data2 |= GetLpData2(lp);
  754. }
  755. var e84Lp = DEVICE.GetDevice<E84Passiver>(GetE84LpName(device));
  756. if (e84Lp != null)
  757. {
  758. //if (!commandrecive.Contains("INIT/SYSTEM"))
  759. data2 |= GetE84Data2(e84Lp);
  760. }
  761. }
  762. else if (ModuleHelper.IsLoadLock(ModuleHelper.Converter(device)))
  763. {
  764. data2 = GetLlData2();
  765. }
  766. else
  767. {
  768. data2 = GetSystemData2();
  769. }
  770. return data2;
  771. }
  772. public uint GetSigStatData2(ModuleName module)
  773. {
  774. uint data2 = 0x0u;
  775. if (ModuleHelper.IsLoadPort(module))
  776. {
  777. // Loadport outputs
  778. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(module.ToString());
  779. if (lp != null)
  780. {
  781. data2 |= GetLpData2(lp);
  782. }
  783. var e84Lp = DEVICE.GetDevice<E84Passiver>(GetE84LpName(module.ToString()));
  784. if (e84Lp != null)
  785. {
  786. data2 |= GetE84Data2(e84Lp);
  787. }
  788. }
  789. else if (ModuleHelper.IsLoadLock(module))
  790. {
  791. data2 = GetLlData2();
  792. }
  793. else
  794. {
  795. data2 = GetSystemData2();
  796. }
  797. return data2;
  798. }
  799. private uint GetLpData1(LoadPortBaseDevice lp)
  800. {
  801. uint data1 = 0x0u;
  802. if (lp != null)
  803. {
  804. //if(lp is OpenStageWithWaferSizeLoadPort)
  805. {
  806. data1 |= (lp.IsPlacement ? 0x00000001u : 0x0);
  807. data1 |= (!lp.IsPresent ? 0x00000002u : 0x0);
  808. data1 |= (lp.ClampState == FoupClampState.Close ? 0x00000008u : 0x0);
  809. switch (IsEnableMultiWaferSize?lp.GetCurrentWaferSize():WaferSize.WS6)
  810. {
  811. case WaferSize.WS3:
  812. //data1 |= 0x00000040u;
  813. data1 |= 0x00000080u;
  814. data1 |= 0x00000100u;
  815. break;
  816. case WaferSize.WS4:
  817. data1 |= 0x00000040u;
  818. //data1 |= 0x00000080u;
  819. data1 |= 0x00000100u;
  820. break;
  821. case WaferSize.WS6:
  822. data1 |= 0x00000040u;
  823. data1 |= 0x00000080u;
  824. //data1 |= 0x00000100u;
  825. break;
  826. case WaferSize.WS8:
  827. data1 |= 0x00000040u;
  828. data1 |= 0x00000080u;
  829. data1 |= 0x00000100u;
  830. break;
  831. }
  832. data1 |= (!lp.IsWaferProtrude) ? 0x00000200u : 0x0;
  833. data1 |= (lp.IsError||lp.CurrentState==LoadPortStateEnum.Error) ? 0x00000400u : 0x0;
  834. data1 |=(lp.Name=="LP1"? (DeviceModel.SensorSMIF1PODOPEN==null?0x0:(DeviceModel.SensorSMIF1PODOPEN.Value ? 0x00000800u : 0x0)) :(DeviceModel.SensorSMIF2PODOPEN==null?0x0:(DeviceModel.SensorSMIF2PODOPEN.Value? 0x00000800u : 0x0)));
  835. data1 |= (lp.Name == "LP1" ? (DeviceModel.SensorSMIF1READY == null ? 0x0 : (DeviceModel.SensorSMIF1READY.Value ? 0x00001000u : 0x0)) : (DeviceModel.SensorSMIF2READY == null ? 0x0 : (DeviceModel.SensorSMIF2READY.Value ? 0x00001000u : 0x0)));
  836. }
  837. }
  838. return data1;
  839. }
  840. private uint GetLpData2(LoadPortBaseDevice lp)
  841. {
  842. uint data2 = 0x0u;
  843. if (lp != null)
  844. {
  845. // if (!(lp is OpenStageWithWaferSizeLoadPort))
  846. // if (!(lp is OpenStageWithWaferSizeLoadPort))
  847. {
  848. data2 |= (lp.IndicatiorPresence == IndicatorState.ON ? 0x00000001U : 0x0);
  849. data2 |= (lp.IndicatiorPlacement == IndicatorState.ON ? 0x00000002U : 0x0);
  850. data2 |= (lp.IndicatiorLoad == IndicatorState.ON ? 0x00000004U : 0x0);
  851. data2 |= (lp.IndicatiorUnload == IndicatorState.ON ? 0x00000008U : 0x0);
  852. data2 |= (lp.IndicatiorManualMode == IndicatorState.ON ? 0x00000010U : 0x0);
  853. data2 |= (lp.IndicatorAlarm == IndicatorState.ON ? 0x00000020U : 0x0);
  854. data2 |= (lp.IndicatiorClampUnclamp == IndicatorState.ON ? 0x00000040U : 0x0);
  855. data2 |= (lp.IndicatiorDockUndock == IndicatorState.ON ? 0x00000080U : 0x0);
  856. data2 |= (lp.IndicatiorOpAccess == IndicatorState.ON ? 0x00000100U : 0x0);
  857. }
  858. }
  859. return data2;
  860. }
  861. private uint GetE84Data1(E84Passiver e84Lp)
  862. {
  863. uint data1 = 0x0u;
  864. if (e84Lp != null)
  865. {
  866. data1 |= (e84Lp.DiValid ? 0x01000000u : 0x0);
  867. data1 |= (e84Lp.DiCS0 ? 0x02000000u : 0x0);
  868. data1 |= (e84Lp.DiCS1 ? 0x04000000u : 0x0);
  869. data1 |= (e84Lp.DiTrReq ? 0x10000000u : 0x0);
  870. data1 |= (e84Lp.DiBusy ? 0x20000000u : 0x0);
  871. data1 |= (e84Lp.DiCompt ? 0x40000000u : 0x0);
  872. data1 |= (e84Lp.DiCont ? 0x80000000u : 0x0);
  873. }
  874. return data1;
  875. }
  876. private uint GetE84Data2(E84Passiver e84Lp)
  877. {
  878. uint data2 = 0x0u;
  879. if (e84Lp != null)
  880. {
  881. data2 |= (e84Lp.DoLoadReq ? 0x01000000U : 0x0);
  882. data2 |= (e84Lp.DoUnloadReq ? 0x02000000U : 0x0);
  883. data2 |= (e84Lp.DoReady ? 0x08000000U : 0x0);
  884. data2 |= (e84Lp.DoHOAvbl ? 0x40000000U : 0x0);
  885. data2 |= (e84Lp.DoES ? 0x80000000U : 0x0);
  886. }
  887. return data2;
  888. }
  889. //a 1 for SIGSTAT/SYSTEM
  890. //Bit Name of Input Signal Signal ON Signal OFF Initial Value
  891. //0 System vacuum source pressure 1 Normal
  892. //1
  893. //2 System compressed air pressure 1 Normal
  894. //3
  895. //4 Flow gauge Sensor Warning
  896. //5 Leakage Sensor Warning
  897. //6 Door switch Door close
  898. //7 Drive power Normal
  899. //8 Differential pressure sensor setting 1 Normal
  900. //9 Differential pressure sensor setting 2 Normal
  901. //10 Ionizer alarm Normal
  902. //11 FFU alarm Normal
  903. //12 Area sensor(Reserved) Not blocked
  904. //13 Mode switch RUN
  905. //14 Robot Wafer Present No presence
  906. //15 Cassette Door Door Closed
  907. private uint GetSystemData1()
  908. {
  909. uint data1 = 0x0u;
  910. //0:
  911. if (DeviceModel.SensorVACPressureSW != null)
  912. data1 |= (DeviceModel.SensorVACPressureSW.Value ? 0x00000001u : 0x0);
  913. //1:
  914. if (DeviceModel.SensorIONCDAPressureSW != null)
  915. data1 |= (DeviceModel.SensorIONCDAPressureSW.Value ? 0x00000002u : 0x0);
  916. //2:
  917. if (DeviceModel.SensorCDAPressureSW != null)
  918. data1 |= (DeviceModel.SensorCDAPressureSW.Value ? 0x00000004u : 0x0);
  919. //3:
  920. //data1 |= 0x00000800u; //data1 |= (DeviceModel.SensorAirPressureErrorForRobot.Value ? 0x00000004u : 0x0);
  921. //4 Flow gauge Sensor Warning (默认bit=1 Normal)
  922. data1 |= (DeviceModel.SensorWaterFlowSW != null ? (DeviceModel.SensorWaterFlowSW.Value ? 0x00000010u : 0x0) : 0x00000010u);
  923. //5 Leakage Sensor Warning (默认bit=1 Normal)
  924. data1 |= (DeviceModel.SensorWaterLeakSW != null ? (DeviceModel.SensorWaterLeakSW.Value ? 0x00000020u : 0x0) : 0x00000020u);
  925. //6:Door switch Door close
  926. if (DeviceModel.SensorEFEMSideDoorClosed != null)
  927. data1 |= (_EfemDoorOpen? !DeviceModel.SensorEFEMSideDoorClosed.Value : DeviceModel.SensorEFEMSideDoorClosed.Value) ? 0x00000040u : 0x0;
  928. //7 Drive power Normal
  929. if (DeviceModel.SensorFFUalarm != null)
  930. data1 |= (DeviceModel.SensorFFUalarm.Value ? 0x00000080u : 0x0);
  931. //8 Differential pressure sensor setting 1 Normal
  932. //data1 |= (DeviceModel.SensorIONAlarmSIGNAL.Value ? 0x00000100u : 0x0);
  933. //9 Differential pressure sensor setting 1 Normal
  934. // data1 |= (DeviceModel.SensorEFEMPowerON.Value ? 0x00000400u : 0x0);
  935. //10 Ionizer alarm Normal
  936. if (DeviceModel.TrigIonizerInterrupt != null)
  937. data1 |= (DeviceModel.TrigIonizerInterrupt != null ? (DeviceModel.TrigIonizerInterrupt.Value? 0x00000400u : (DeviceModel.SensorIONAlarmSIGNAL.Value ? 0x00000400u : 0x0)) : (DeviceModel.SensorIONAlarmSIGNAL.Value ? 0x00000400u : 0x0));
  938. //11 FFU alarm Normal
  939. if (DeviceModel.SensorFFUalarm != null)
  940. data1 |= (DeviceModel.SensorFFUalarm.Value ? 0x00000800u : 0x0);
  941. //12
  942. data1 |= 0x00001000u;//(!DeviceModel.SensorRBlowerArmhavewafer.Value ? 0x00001000u : 0x0);
  943. //13 Mode switch RUN
  944. if (DeviceModel.SensorMaintenanceMode != null)
  945. {
  946. bool isRun = (_MaintenanceMode ? !DeviceModel.SensorMaintenanceMode.Value : DeviceModel.SensorMaintenanceMode.Value) && IsOnlineMode;
  947. data1 |= (isRun ? 0x00002000u : 0x0);
  948. }
  949. //14 Robot Wafer Present No presence
  950. data1 |= 0x00004000u; //data1 |= (DeviceModel.SensorRobotFork1WaferOn.Value ? 0x00004000u : 0x0);
  951. // 15 Sensor Grating SensorIN
  952. data1 |= DeviceModel.SensorGratingSensorIN1==null ? 0x0 :(DeviceModel.SensorGratingSensorIN1.Value ? 0x00008000u : 0x0);
  953. // 16 robot IsError
  954. var robot = DEVICE.GetDevice<RobotBaseDevice>(ModuleName.Robot.ToString());
  955. data1 |= (robot.IsError || robot.RobotState == RobotStateEnum.Error ? 0x00010000u : 0x0);
  956. // 17 buffer1 MapError
  957. var buffer1 = DEVICE.GetDevice<BufferStation>(ModuleName.Buffer1.ToString());
  958. data1 |= (buffer1!=null&& buffer1.MapError) ? 0x00020000u : 0x0;
  959. // 18 buffer2 MapError
  960. var buffer2 = DEVICE.GetDevice<BufferStation>(ModuleName.Buffer2.ToString());
  961. data1 |= ( buffer2 != null && buffer2.MapError) ? 0x00040000u : 0x0;
  962. // 19 Cassette Door Door Closed
  963. data1 |= DeviceModel.SensorCstDoorClosed == null ? 0x00080000u : (DeviceModel.SensorCstDoorClosed.Value ? 0x00080000u : 0x0);
  964. // 20 PMA System Interlock
  965. data1 |= DeviceModel.SensorPMASystemInterlock == null ? 0x0 : (DeviceModel.SensorPMASystemInterlock.Value ? 0x00100000u : 0x0);
  966. // 21 PMB System Interlock
  967. data1 |= DeviceModel.SensorPMBSystemInterlock == null ? 0x0 : (DeviceModel.SensorPMBSystemInterlock.Value ? 0x00200000u : 0x0);
  968. data1 |= DeviceModel.SensorRBNotExtendPMA == null ? 0x0 : (DeviceModel.SensorRBNotExtendPMA.Value ? 0x00400000u : 0x0);
  969. data1 |= DeviceModel.SensorRBNotExtendPMB == null ? 0x0 : (DeviceModel.SensorRBNotExtendPMB.Value ? 0x00800000u : 0x0);
  970. return data1;
  971. }
  972. private uint GetSystemData2()
  973. {
  974. uint data2 = 0x0u;
  975. if (DeviceModel.SignalTower != null)
  976. {
  977. if (DeviceModel.SignalTower.Red != null)
  978. data2 |= (DeviceModel.SignalTower.Red.StateSetPoint == TowerLightStatus.On ? 0x00000001u : 0);
  979. if (DeviceModel.SignalTower.Green != null)
  980. data2 |= (DeviceModel.SignalTower.Green.StateSetPoint == TowerLightStatus.On ? 0x00000002u : 0);
  981. if (DeviceModel.SignalTower.Yellow != null)
  982. data2 |= (DeviceModel.SignalTower.Yellow.StateSetPoint == TowerLightStatus.On ? 0x00000004u : 0);
  983. if (DeviceModel.SignalTower.Blue != null)
  984. data2 |= (DeviceModel.SignalTower.Blue.StateSetPoint == TowerLightStatus.On ? 0x00000008u : 0);
  985. if (DeviceModel.SignalTower.White != null)
  986. data2 |= (DeviceModel.SignalTower.White.StateSetPoint == TowerLightStatus.On ? 0x00000010u : 0);
  987. if (DeviceModel.SignalTower.Red != null)
  988. data2 |= (DeviceModel.SignalTower.Red.StateSetPoint == TowerLightStatus.Blinking ? 0x00000020u : 0);
  989. if (DeviceModel.SignalTower.Green != null)
  990. data2 |= (DeviceModel.SignalTower.Green.StateSetPoint == TowerLightStatus.Blinking ? 0x00000040u : 0);
  991. if (DeviceModel.SignalTower.Yellow != null)
  992. data2 |= (DeviceModel.SignalTower.Yellow.StateSetPoint == TowerLightStatus.Blinking ? 0x00000080u : 0);
  993. if (DeviceModel.SignalTower.Blue != null)
  994. data2 |= (DeviceModel.SignalTower.Blue.StateSetPoint == TowerLightStatus.Blinking ? 0x00000100u : 0);
  995. if (DeviceModel.SignalTower.White != null)
  996. data2 |= (DeviceModel.SignalTower.White.StateSetPoint == TowerLightStatus.Blinking ? 0x00000200u : 0);
  997. if (DeviceModel.SignalTower.Buzzer1 != null)
  998. data2 |= (DeviceModel.SignalTower.Buzzer1.StateSetPoint == TowerLightStatus.On ? 0x00000400u : 0);
  999. if (DeviceModel.SignalTower.Buzzer2 != null)
  1000. data2 |= (DeviceModel.SignalTower.Buzzer2.StateSetPoint == TowerLightStatus.On ? 0x00000800u : 0);
  1001. }
  1002. return data2;
  1003. }
  1004. private uint GetLlData1()
  1005. {
  1006. //DIW1 meter pulse bit 0
  1007. //DIW2 meter pulse bit 1
  1008. //DIW3 meter pulse bit 2
  1009. //DIW4 meter pulse bit 3
  1010. //In Shutter Opened bit 4
  1011. //Out Shutter Opened bit 5
  1012. //Leak Sensor bit 6
  1013. uint data1 = 0x0u;
  1014. data1 |= (LoadLockDevice.LoadLockAtmDoorState == LoadLockDoorState.Opened ? 0x00000010u : 0x0);
  1015. data1 |= (LoadLockDevice.LoadLockVtmDoorState == LoadLockDoorState.Opened ? 0x00000020u : 0x0);
  1016. return data1;
  1017. }
  1018. private uint GetLlData2()
  1019. {
  1020. uint data2 = 0x0u;
  1021. return data2;
  1022. }
  1023. private bool IsLoadPort(string device)
  1024. {
  1025. if (device == "P1" || device == "P2" || device == "P3" || device == "P4"|| device == "LP1" || device == "LP2" || device == "LP3" || device == "LP4")
  1026. {
  1027. return true;
  1028. }
  1029. return false;
  1030. }
  1031. public string GetE84LpName(string device)
  1032. {
  1033. string e84 = string.Empty;
  1034. switch (device)
  1035. {
  1036. case "P1":
  1037. case "LP1":
  1038. e84 = "Loadport1E84";
  1039. break;
  1040. case "P2":
  1041. case "LP2":
  1042. e84 = "Loadport2E84";
  1043. break;
  1044. case "P3":
  1045. case "LP3":
  1046. e84 = "Loadport3E84";
  1047. break;
  1048. case "P4":
  1049. case "LP4":
  1050. e84 = "Loadport4E84";
  1051. break;
  1052. case "P5":
  1053. case "LP5":
  1054. e84 = "Loadport5E84";
  1055. break;
  1056. case "P6":
  1057. case "LP6":
  1058. e84 = "Loadport6E84";
  1059. break;
  1060. case "P7":
  1061. case "LP7":
  1062. e84 = "Loadport7E84";
  1063. break;
  1064. case "P8":
  1065. case "LP8":
  1066. e84 = "Loadport8E84";
  1067. break;
  1068. case "P9":
  1069. case "LP9":
  1070. e84 = "Loadport9E84";
  1071. break;
  1072. case "P10":
  1073. case "LP10":
  1074. e84 = "Loadport10E84";
  1075. break;
  1076. }
  1077. return e84;
  1078. }
  1079. private string ModuleName2ProtocolName(ModuleName module)
  1080. {
  1081. string protocol = "System";
  1082. switch (module)
  1083. {
  1084. case ModuleName.LP1:
  1085. protocol = "P1";
  1086. break;
  1087. case ModuleName.LP2:
  1088. protocol = "P2";
  1089. break;
  1090. case ModuleName.LP3:
  1091. protocol = "P3";
  1092. break;
  1093. case ModuleName.LP4:
  1094. protocol = "P4";
  1095. break;
  1096. case ModuleName.LP5:
  1097. protocol = "P5";
  1098. break;
  1099. case ModuleName.LP6:
  1100. protocol = "P6";
  1101. break;
  1102. case ModuleName.LP7:
  1103. protocol = "P7";
  1104. break;
  1105. case ModuleName.LP8:
  1106. protocol = "P8";
  1107. break;
  1108. case ModuleName.LP9:
  1109. protocol = "P9";
  1110. break;
  1111. case ModuleName.LP10:
  1112. protocol = "P10";
  1113. break;
  1114. case ModuleName.LL1:
  1115. protocol = "LLA";
  1116. break;
  1117. case ModuleName.LL2:
  1118. protocol = "LLB";
  1119. break;
  1120. case ModuleName.LL3:
  1121. protocol = "LLC";
  1122. break;
  1123. case ModuleName.LL4:
  1124. protocol = "LLD";
  1125. break;
  1126. case ModuleName.LL5:
  1127. protocol = "LLE";
  1128. break;
  1129. case ModuleName.LL6:
  1130. protocol = "LLF";
  1131. break;
  1132. case ModuleName.LL7:
  1133. protocol = "LLG";
  1134. break;
  1135. case ModuleName.LL8:
  1136. protocol = "LLH";
  1137. break;
  1138. }
  1139. return protocol;
  1140. }
  1141. }
  1142. }