BrooksSMIF.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO.Ports;
  4. using System.Linq;
  5. using System.Text;
  6. using Aitex.Core.Common.DeviceData;
  7. using Aitex.Core.RT.Device;
  8. using Aitex.Core.RT.Device.Unit;
  9. using Aitex.Core.RT.Event;
  10. using Aitex.Core.RT.Log;
  11. using Aitex.Core.RT.OperationCenter;
  12. using Aitex.Core.RT.SCCore;
  13. using Aitex.Core.Util;
  14. using MECF.Framework.Common.Communications;
  15. using MECF.Framework.Common.Device.Bases;
  16. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Common;
  17. using Newtonsoft.Json;
  18. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.SMIFs.Brooks
  19. {
  20. public class BrooksSMIF : SerialPortDevice, IConnection
  21. {
  22. public string Address { get { return _address; } }
  23. public bool IsConnected { get; }
  24. public bool Connect()
  25. {
  26. return true;
  27. }
  28. public bool Disconnect()
  29. {
  30. return true;
  31. }
  32. public string PortStatus { get; set; } = "Closed";
  33. private BrooksSMIFConnection _connection;
  34. public BrooksSMIFConnection Connection
  35. {
  36. get { return _connection; }
  37. }
  38. public List<IOResponse> IOResponseList { get; set; } = new List<IOResponse>();
  39. public int Axis { get; private set; }
  40. public bool IsIdle { get; private set; }
  41. public bool IsHomed { get; private set; }
  42. public bool IsPodPresent { get; private set; }
  43. public bool IsArmRetract { get; private set; }
  44. public bool IsAlarm { get; private set; }
  45. private R_TRIG _trigError = new R_TRIG();
  46. private R_TRIG _trigCommunicationError = new R_TRIG();
  47. private R_TRIG _trigRetryConnect = new R_TRIG();
  48. private PeriodicJob _thread;
  49. private LinkedList<HandlerBase> _lstHandler = new LinkedList<HandlerBase>();
  50. private LinkedList<HandlerBase> _lstMonitorHandler = new LinkedList<HandlerBase>();
  51. private object _locker = new object();
  52. private bool _enableLog;
  53. private string _errorCode="";
  54. private DeviceTimer _setStatusTimer = new DeviceTimer();
  55. private int SetStatusTime = 800;
  56. private string _scRoot;
  57. public BrooksSMIF(string module, string name, string scRoot) : base(module, name)
  58. {
  59. _scRoot = scRoot;
  60. }
  61. private void ResetPropertiesAndResponses()
  62. {
  63. Connected = null;
  64. RobotStatus = null;
  65. IsOnLine = null;
  66. IsManual = null;
  67. IsES = null;
  68. MovingCompleted = null;
  69. ACalCompleted = null;
  70. AddressOutSide = null;
  71. PositionOutSide = null;
  72. EmergencyStop = null;
  73. XLowerSide = null;
  74. XUpperSide = null;
  75. YLowerSide = null;
  76. YUpperSide = null;
  77. ZLowerSide = null;
  78. ZUpperSide = null;
  79. foreach (var ioResponse in IOResponseList)
  80. {
  81. ioResponse.ResonseContent = null;
  82. ioResponse.ResonseRecievedTime = DateTime.Now;
  83. }
  84. }
  85. internal void OnEventArrived(string eventData)
  86. {
  87. if (eventData == "POD_ARRIVED")
  88. {
  89. PodArrived = true;
  90. }
  91. else if (eventData == "POD_REMOVED")
  92. {
  93. PodRemoved = true;
  94. }
  95. else if (eventData == "BEGIN_FETCH")
  96. {
  97. FetchBegun = true;
  98. }
  99. else if (eventData == "CMPL_FETCH")
  100. {
  101. FetchCompleted = true;
  102. }
  103. else if (eventData == "BEGIN_LOAD")
  104. {
  105. LoadBegun = true;
  106. }
  107. else if (eventData == "ABORT_LOAD")
  108. {
  109. LoadAbort = true;
  110. }
  111. else if (eventData == "CMPL_LOAD")
  112. {
  113. LoadCompleted = true;
  114. }
  115. else if (eventData == "BEGIN_RECV_CASSETTE")
  116. {
  117. UnloadBegun = true;
  118. }
  119. else if (eventData == "ABORT_UNLOAD")
  120. {
  121. UnloadAbort = true;
  122. }
  123. else if (eventData == "RECV_CASSETTE")
  124. {
  125. UnloadCompleted = true;
  126. }
  127. else if (eventData == "BEGIN_HOME")
  128. {
  129. HomeBegun = true;
  130. }
  131. else if (eventData == "REACH_HOME")
  132. {
  133. HomeCompleted = true;
  134. }
  135. else if (eventData == "BEGIN_OPEN")
  136. {
  137. OpenBegun = true;
  138. }
  139. else if (eventData == "CMPL_OPEN")
  140. {
  141. OpenCompleted = true;
  142. }
  143. else if (eventData == "BEGIN_UNLOAD")
  144. {
  145. CloseBegun = true;
  146. }
  147. else if (eventData == "CMPL_UNLOAD")
  148. {
  149. CloseCompleted = true;
  150. }
  151. }
  152. private static Dictionary<string, string> _RealyMessageDict = new Dictionary<string, string>()
  153. {
  154. {"OK","Comment accepted" },
  155. {"BUSY","Command rejected, LPI is busy" },
  156. {"ALARM","Command rejected, LPI in alarm state" },
  157. {"NO_POD","Command rejected, Pod not on LPI" },
  158. {"NOT_READY","Command rejected, Host interlock not enabled" },
  159. {"INVALID_ARG","Command rejected, at least one invalid parameter" },
  160. {"CANNOT_PERFORM","LPI not in the proper state to perform the Host command" },
  161. {"DENIED","Command rejected for other reason" },
  162. };
  163. private static Dictionary<string, string> _AlarmTimeCodeDict = new Dictionary<string, string>()
  164. {
  165. {"00","No alarm" },
  166. {"41","Alarm occurred during a fetch or open operation" },
  167. {"42","Alarm occurred during a cassette placement on the process tool" },
  168. {"43","Alarm occurred during a returning of the minienvironment to Home" },
  169. {"44","Alarm occurred during a retrieval of the cassette from the Tool" },
  170. {"45","Alarm occurred during a placement of the cassette on the Pod door" },
  171. {"46","Non-recoverable fatal error" }
  172. };
  173. private static Dictionary<string, string> _ErrorCodeDict = new Dictionary<string, string>()
  174. {
  175. {"00","No error" },
  176. {"01","Position following error" },
  177. {"02","LPI not Home" },
  178. {"03","LPI busy" },
  179. {"04","Pod removed/missing elevator door" },
  180. {"05","Aborted by user" },
  181. {"07","Protrusion sensor failure" },
  182. {"08","Slot sensor failure" },
  183. {"09","Wafer presence sensor failure" },
  184. {"10","Flash sensor failure" },
  185. {"11"," Elevator over-travel limit trip" },
  186. {"13","Excessive wafer protrusion" },
  187. {"14","System internal time-out" },
  188. {"15","Servo command error" },
  189. {"16","Pod door open time-out" },
  190. {"17","Pod door close time-out" },
  191. {"18","Pod hold-down open time-out" },
  192. {"19","Pod hold-down close time-out" },
  193. {"20","Wafer seater failed to move toward wafer" },
  194. {"21","Wafer seater failed to return to Home" },
  195. {"22","Elevator failed to reach target position" },
  196. {"24","System error" },
  197. {"27","Loss of configuration data" },
  198. {"28","Cassette not present" },
  199. {"29","Loss of air flow" },
  200. {"31","Gripper open time out" },
  201. {"32","Gripper close time out" },
  202. {"33","Interprocessor communication error" },
  203. {"34","Gripper overtravel" },
  204. {"35","Cassette found during unload" },
  205. };
  206. internal void OnAlarmArrived(string alarmData)
  207. {
  208. var alarmArray = alarmData.Split(' ');
  209. if (alarmArray.Count() != 2)
  210. return;
  211. string alarmTimeCode = alarmArray[0].Substring(0, 2);
  212. string alarmInfoCode = alarmArray[0].Substring(2, 2);
  213. AlarmOccurTime = alarmTimeCode + "=" + _AlarmTimeCodeDict[alarmTimeCode];
  214. AlarmInfo = alarmInfoCode + "=" + alarmArray[1];
  215. IsAlarm = true;
  216. }
  217. public void SetError(string errorCode)
  218. {
  219. string alarmTimeCode = errorCode.Substring(0, 2);
  220. string alarmInfoCode = errorCode.Substring(2, 2);
  221. if (_AlarmTimeCodeDict.ContainsKey(alarmTimeCode))
  222. AlarmOccurTime = _AlarmTimeCodeDict[alarmTimeCode];
  223. else
  224. AlarmOccurTime = alarmTimeCode;
  225. if (_ErrorCodeDict.ContainsKey(alarmInfoCode))
  226. AlarmInfo = _ErrorCodeDict[alarmInfoCode];
  227. else
  228. AlarmInfo = alarmInfoCode;
  229. if(_errorCode != errorCode)
  230. {
  231. EV.PostAlarmLog(Module, $"{Module} {AlarmOccurTime}, for {AlarmInfo}");
  232. }
  233. _errorCode = errorCode;
  234. IsAlarm = true;
  235. }
  236. public void SetStatus(bool isReady, bool isHomed, bool isPodPresent, bool isArmRetract)
  237. {
  238. if(_setStatusTimer.IsIdle() || _setStatusTimer.GetElapseTime() > SetStatusTime)
  239. {
  240. IsIdle = isReady;
  241. IsHomed = isHomed;
  242. IsPodPresent = isPodPresent;
  243. IsArmRetract = isArmRetract;
  244. }
  245. }
  246. private string _address = "";
  247. public override bool Initialize()
  248. {
  249. ResetPropertiesAndResponses();
  250. if (_connection != null && _connection.IsConnected)
  251. return true;
  252. if(string.IsNullOrEmpty(_scRoot))
  253. {
  254. PortName = SC.GetStringValue($"{Module}.DeviceAddress");
  255. _enableLog = SC.GetValue<bool>($"{Module}.EnableLogMessage");
  256. }
  257. else
  258. {
  259. PortName = SC.GetStringValue($"{_scRoot}.{Module}.{Name}.DeviceAddress");
  260. _enableLog = SC.GetValue<bool>($"{_scRoot}.{Module}.{Name}.EnableLogMessage");
  261. }
  262. _connection = new BrooksSMIFConnection(this, PortName);
  263. _connection.EnableLog(_enableLog);
  264. base.Initialize(PortName);
  265. if (_connection.Connect())
  266. {
  267. PortStatus = "Open";
  268. EV.PostInfoLog(Module, $"{Module}.{Name} connected");
  269. }
  270. _thread = new PeriodicJob(400, OnTimer, $"{Module}.{Name} MonitorHandler", true);
  271. RequestStatus();
  272. OP.Subscribe($"{Module}.Home", (string cmd, object[] args) =>
  273. {
  274. HomeSmif(out _);
  275. return true;
  276. });
  277. OP.Subscribe($"{Module}.Abort", (string cmd, object[] args) =>
  278. {
  279. Stop();
  280. return true;
  281. });
  282. OP.Subscribe($"{Module}.Reset", (string cmd, object[] args) =>
  283. {
  284. Reset();
  285. return true;
  286. });
  287. OP.Subscribe($"{Module}.Unload", (string cmd, object[] args) =>
  288. {
  289. UnloadCassette(out _);
  290. return true;
  291. });
  292. OP.Subscribe($"{Module}.Load", (string cmd, object[] args) =>
  293. {
  294. LoadCassette(out _);
  295. return true;
  296. });
  297. return true;
  298. }
  299. internal void NoteConstant(string constantResult)
  300. {
  301. var constantResultArray = constantResult.Split('=');
  302. if(constantResultArray.Count() != 2)
  303. {
  304. return;
  305. }
  306. if(constantResultArray[0] == "P13")
  307. {
  308. MSCInterlockMode = constantResultArray[1];
  309. }
  310. //else if....
  311. }
  312. private bool OnTimer()
  313. {
  314. try
  315. {
  316. //return true;
  317. _connection.MonitorTimeout();
  318. if (!_connection.IsConnected || _connection.IsCommunicationError)
  319. {
  320. lock (_locker)
  321. {
  322. _lstHandler.Clear();
  323. }
  324. _trigRetryConnect.CLK = !_connection.IsConnected;
  325. if (_trigRetryConnect.Q)
  326. {
  327. if (string.IsNullOrEmpty(_scRoot))
  328. {
  329. _connection.SetPortAddress(SC.GetStringValue($"{Module}.DeviceAddress"));
  330. }
  331. else
  332. {
  333. _connection.SetPortAddress(SC.GetStringValue($"{_scRoot}.{Module}.{Name}.DeviceAddress"));
  334. }
  335. if (!_connection.Connect())
  336. {
  337. EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}");
  338. }
  339. else
  340. {
  341. //_lstHandler.AddLast(new BrooksSMIFQueryPinHandler(this, _deviceAddress));
  342. //_lstHandler.AddLast(new BrooksSMIFSetCommModeHandler(this, _deviceAddress, EnumRfPowerCommunicationMode.Host));
  343. }
  344. }
  345. return true;
  346. }
  347. HandlerBase handler = null;
  348. if (!_connection.IsBusy)
  349. {
  350. lock (_locker)
  351. {
  352. if (_lstHandler.Count == 0)
  353. {
  354. foreach (var monitorHandler in _lstMonitorHandler)
  355. {
  356. _lstHandler.AddLast(monitorHandler);
  357. }
  358. }
  359. if (_lstHandler.Count > 0)
  360. {
  361. handler = _lstHandler.First.Value;
  362. _lstHandler.RemoveFirst();
  363. }
  364. }
  365. if (handler != null)
  366. {
  367. _connection.Execute(handler);
  368. }
  369. }
  370. }
  371. catch (Exception ex)
  372. {
  373. LOG.Write(ex);
  374. }
  375. return true;
  376. }
  377. internal void NoteStatus(string formCode, string status)
  378. {
  379. if(formCode == "FSD0")
  380. {
  381. SmifStatus = status;
  382. }
  383. else if (formCode == "FSD2")
  384. {
  385. CassetteMapInfo = status;
  386. }
  387. }
  388. internal void NoteEnable(string parameter, bool isEnable)
  389. {
  390. if(parameter == "FETCH")
  391. {
  392. FetchEnable = isEnable;
  393. }
  394. else if (parameter == "LOAD")
  395. {
  396. LoadEnable = isEnable;
  397. }
  398. else if (parameter == "HOME")
  399. {
  400. HomeEnable = isEnable;
  401. }
  402. else if (parameter == "OPEN")
  403. {
  404. OpenEnable = isEnable;
  405. }
  406. else if (parameter == "UNLOAD")
  407. {
  408. UnloadEnable = isEnable;
  409. }
  410. else if (parameter == "CLOSE")
  411. {
  412. CloseEnable = isEnable;
  413. }
  414. }
  415. public override void Monitor()
  416. {
  417. try
  418. {
  419. //_connection.EnableLog(_enableLog);
  420. _trigCommunicationError.CLK = _connection.IsCommunicationError;
  421. if (_trigCommunicationError.Q)
  422. {
  423. EV.PostAlarmLog(Module, $"{Module}.{Name} communication error, {_connection.LastCommunicationError}");
  424. }
  425. }
  426. catch (Exception ex)
  427. {
  428. LOG.Write(ex);
  429. }
  430. }
  431. public override void Reset()
  432. {
  433. _trigError.RST = true;
  434. _connection.SetCommunicationError(false, "");
  435. _trigCommunicationError.RST = true;
  436. //_enableLog = SC.GetValue<bool>($"{ScBasePath}.{Name}.EnableLogMessage");
  437. _trigRetryConnect.RST = true;
  438. if(IsAlarm)
  439. {
  440. lock (_locker)
  441. {
  442. _lstHandler.AddFirst(new BrooksSMIFResetHandler(this));
  443. }
  444. }
  445. IsAlarm = false;
  446. base.Reset();
  447. }
  448. public override bool Home(out string reason)
  449. {
  450. return base.Home(out reason);
  451. }
  452. #region Command Functions
  453. public void PerformRawCommand(string commandType,string command, string completeEvent, string comandArgument)
  454. {
  455. lock (_locker)
  456. {
  457. _lstHandler.AddLast(new BrooksSMIFRawCommandHandler(this, commandType, command, completeEvent, comandArgument));
  458. }
  459. }
  460. public void EnableAction(string action, string isEnable)
  461. {
  462. lock (_locker)
  463. {
  464. _lstHandler.AddLast(new BrooksSMIFEnableActionHandler(this, action, bool.Parse(isEnable)));
  465. }
  466. }
  467. public void FetchCassette()
  468. {
  469. lock (_locker)
  470. {
  471. if(!PodArrived || !FetchEnable )
  472. {
  473. EV.PostAlarmLog(Module, $"{Module}.{Name} Fetch Cassette conditon error");
  474. return;
  475. }
  476. _lstHandler.AddFirst(new BrooksSMIFFetchCassetteHandler(this));
  477. }
  478. if (!_setStatusTimer.IsIdle())
  479. _setStatusTimer.Stop();
  480. _setStatusTimer.Start(0);
  481. }
  482. public bool LoadCassette(out string reason)
  483. {
  484. reason = string.Empty;
  485. if (!IsIdle)
  486. {
  487. reason = $"{Module} is busy";
  488. return false;
  489. }
  490. lock (_locker)
  491. {
  492. //if (!LoadEnable)
  493. //{
  494. // EV.PostAlarmLog(Module, $"{Module}.{Name} Load Cassette conditon error");
  495. // return;
  496. //}
  497. _lstHandler.AddFirst(new BrooksSMIFLoadCassetteHandler(this));
  498. }
  499. IsIdle = false;
  500. IsArmRetract = false;
  501. IsPodPresent = false;
  502. if (!_setStatusTimer.IsIdle())
  503. _setStatusTimer.Stop();
  504. _setStatusTimer.Start(0);
  505. return true;
  506. }
  507. public bool HomeSmif(out string reason)
  508. {
  509. reason = string.Empty;
  510. if(!IsIdle)
  511. {
  512. reason = $"{Module} is busy";
  513. return false;
  514. }
  515. lock (_locker)
  516. {
  517. //if (!HomeEnable)
  518. //{
  519. // EV.PostAlarmLog(Module, $"{Module}.{Name} Home conditon error");
  520. // return;
  521. //}
  522. //_lstHandler.AddLast(new BrooksSMIFHomeHandler(this));
  523. _lstHandler.AddFirst(new BrooksSMIFRecoveryHandler(this));
  524. }
  525. IsIdle = false;
  526. IsArmRetract = false;
  527. IsHomed = false;
  528. if (!_setStatusTimer.IsIdle())
  529. _setStatusTimer.Stop();
  530. _setStatusTimer.Start(0);
  531. return true;
  532. }
  533. public void Stop()
  534. {
  535. lock (_locker)
  536. {
  537. _lstHandler.AddFirst(new BrooksSMIFStopHandler(this));
  538. }
  539. IsIdle = false;
  540. if (!_setStatusTimer.IsIdle())
  541. _setStatusTimer.Stop();
  542. }
  543. public void OpenPod()
  544. {
  545. lock (_locker)
  546. {
  547. if (!PodArrived || !OpenEnable)
  548. {
  549. EV.PostAlarmLog(Module, $"{Module}.{Name} OpenPod conditon error");
  550. return;
  551. }
  552. _lstHandler.AddFirst(new BrooksSMIFOpenPodHandler(this));
  553. }
  554. IsIdle = false;
  555. if (!_setStatusTimer.IsIdle())
  556. _setStatusTimer.Stop();
  557. _setStatusTimer.Start(0);
  558. if (!_setStatusTimer.IsIdle())
  559. _setStatusTimer.Stop();
  560. _setStatusTimer.Start(0);
  561. }
  562. public bool UnloadCassette(out string reason)
  563. {
  564. reason = string.Empty;
  565. if (!IsIdle)
  566. {
  567. reason = $"{Module} is busy";
  568. return false;
  569. }
  570. lock (_locker)
  571. {
  572. //if (!UnloadEnable)
  573. //{
  574. // EV.PostAlarmLog(Module, $"{Module}.{Name} Unload Cassette conditon error");
  575. // return;
  576. //}
  577. _lstHandler.AddFirst(new BrooksSMIFUnloadCassetteHandler(this));
  578. }
  579. IsIdle = false;
  580. IsArmRetract = false;
  581. IsPodPresent = false;
  582. if (!_setStatusTimer.IsIdle())
  583. _setStatusTimer.Stop();
  584. _setStatusTimer.Start(0);
  585. if (!_setStatusTimer.IsIdle())
  586. _setStatusTimer.Stop();
  587. _setStatusTimer.Start(0);
  588. return true;
  589. }
  590. public void ClosePod()
  591. {
  592. lock (_locker)
  593. {
  594. if (!CloseEnable)
  595. {
  596. EV.PostAlarmLog(Module, $"{Module}.{Name} ClosePod conditon error");
  597. return;
  598. }
  599. _lstHandler.AddFirst(new BrooksSMIFClosePodHandler(this));
  600. }
  601. IsIdle = false;
  602. if (!_setStatusTimer.IsIdle())
  603. _setStatusTimer.Stop();
  604. _setStatusTimer.Start(0);
  605. }
  606. public void SendEvent(string command)
  607. {
  608. _connection.SendMessage("AERS " + command + "\r\n");
  609. }
  610. public void MonitorRawCommand(bool isSelected, string commandType, string command, string commandArgument)
  611. {
  612. lock (_locker)
  613. {
  614. var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksSMIFRawCommandHandler)
  615. && ((BrooksSMIFRawCommandHandler)handler)._commandType == commandType
  616. && ((BrooksSMIFRawCommandHandler)handler)._command == command
  617. );
  618. if (isSelected)
  619. {
  620. if (!existHandlers.Any())
  621. _lstMonitorHandler.AddFirst(new BrooksSMIFRawCommandHandler(this, commandType, command, commandArgument));
  622. }
  623. else
  624. {
  625. if (existHandlers.Any())
  626. {
  627. _lstMonitorHandler.Remove(existHandlers.First());
  628. }
  629. }
  630. }
  631. }
  632. public void RequestConstant(bool isSelected, string constantId)
  633. {
  634. lock (_locker)
  635. {
  636. var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksSMIFRequestConstantHandler));
  637. if (isSelected)
  638. {
  639. if (!existHandlers.Any())
  640. _lstMonitorHandler.AddFirst(new BrooksSMIFRequestConstantHandler(this, constantId));
  641. }
  642. else
  643. {
  644. if (existHandlers.Any())
  645. {
  646. _lstMonitorHandler.Remove(existHandlers.First());
  647. }
  648. }
  649. }
  650. }
  651. public void RequestStatus(bool isSelected = true)
  652. {
  653. lock (_locker)
  654. {
  655. var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksSMIFRequestStatusHandler)
  656. && ((BrooksSMIFRequestStatusHandler)handler)._parameter.Contains("0"));
  657. if (isSelected)
  658. {
  659. if (!existHandlers.Any())
  660. _lstMonitorHandler.AddFirst(new BrooksSMIFRequestStatusHandler(this, 0));
  661. }
  662. else
  663. {
  664. if (existHandlers.Any())
  665. {
  666. _lstMonitorHandler.Remove(existHandlers.First());
  667. }
  668. }
  669. }
  670. }
  671. public void RequestCassetteMap(bool isSelected)
  672. {
  673. lock (_locker)
  674. {
  675. var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksSMIFRequestStatusHandler)
  676. && ((BrooksSMIFRequestStatusHandler)handler)._parameter.Contains("2"));
  677. if (isSelected)
  678. {
  679. if (!existHandlers.Any())
  680. _lstMonitorHandler.AddFirst(new BrooksSMIFRequestStatusHandler(this, 2));
  681. }
  682. else
  683. {
  684. if (existHandlers.Any())
  685. {
  686. _lstMonitorHandler.Remove(existHandlers.First());
  687. }
  688. }
  689. }
  690. }
  691. #endregion
  692. #region Properties
  693. public string Connected { get; private set; }
  694. public string RobotStatus { get; private set; }
  695. public string IsOnLine { get; private set; }
  696. public string IsManual { get; private set; }
  697. public string IsStop { get; private set; }
  698. public string IsES { get; private set; }
  699. public string MovingCompleted { get; private set; }
  700. public string ACalCompleted { get; private set; }
  701. public string AddressOutSide { get; private set; }
  702. public string PositionOutSide { get; private set; }
  703. public string EmergencyStop { get; private set; }
  704. public string XLowerSide { get; private set; }
  705. public string XUpperSide { get; private set; }
  706. public string YLowerSide { get; private set; }
  707. public string YUpperSide { get; private set; }
  708. public string ZLowerSide { get; private set; }
  709. public string ZUpperSide { get; private set; }
  710. public bool PodArrived { get; private set; }
  711. public bool PodRemoved { get; private set; }
  712. public bool FetchBegun { get; private set; }
  713. public bool FetchCompleted { get; private set; }
  714. public bool FetchEnable { get; private set; }
  715. public bool LoadEnable { get; private set; }
  716. public bool LoadBegun { get; private set; }
  717. public bool LoadAbort { get; private set; }
  718. public bool LoadCompleted { get; private set; }
  719. public bool UnloadEnable { get; private set; }
  720. public bool UnloadBegun { get; private set; }
  721. public bool UnloadAbort { get; private set; }
  722. public bool UnloadCompleted { get; private set; }
  723. public bool HomeEnable { get; private set; }
  724. public bool HomeBegun { get; private set; }
  725. public bool HomeCompleted { get; private set; }
  726. public bool OpenEnable { get; private set; }
  727. public bool OpenBegun { get; private set; }
  728. public bool OpenCompleted { get; private set; }
  729. public bool CloseEnable { get; private set; }
  730. public bool CloseBegun { get; private set; }
  731. public bool CloseCompleted { get; private set; }
  732. public string AlarmOccurTime { get; private set; }
  733. public string AlarmInfo { get; private set; }
  734. public string MSCInterlockMode { get; private set; }
  735. public string SmifStatus { get; private set; }
  736. public string CassetteMapInfo { get; private set; }
  737. #endregion
  738. #region Note Functions
  739. private R_TRIG _trigWarningMessage = new R_TRIG();
  740. public void NoteError(string errorData)
  741. {
  742. if (errorData != null)
  743. {
  744. _trigWarningMessage.CLK = true;
  745. if (_trigWarningMessage.Q)
  746. {
  747. EV.PostWarningLog(Module, $"{Module} error, {(_RealyMessageDict.ContainsKey(errorData) ? _RealyMessageDict[errorData] : errorData)}");
  748. }
  749. if (errorData.ToUpper() == "ALARM")
  750. IsAlarm = true;
  751. }
  752. }
  753. internal void NoteRawCommandInfo(string commandType, string command, string data, bool isAck)
  754. {
  755. var curIOResponse = IOResponseList.Find(res => res.SourceCommandType == commandType && res.SourceCommand == command);
  756. if (curIOResponse != null)
  757. {
  758. IOResponseList.Remove(curIOResponse);
  759. }
  760. IOResponseList.Add(new IOResponse() { SourceCommandType = commandType, SourceCommand = command, ResonseContent = data, IsAck = isAck, ResonseRecievedTime = DateTime.Now });
  761. }
  762. #endregion
  763. }
  764. }