HongHuVce.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Core.RT.Log;
  5. using Aitex.Core.RT.SCCore;
  6. using Aitex.Core.Util;
  7. using MECF.Framework.Common.Communications;
  8. using MECF.Framework.Common.Equipment;
  9. using MECF.Framework.Common.SubstrateTrackings;
  10. using MECF.Framework.RT.ModuleLibrary.VceModules;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.IO.Ports;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Text.RegularExpressions;
  17. using System.Threading.Tasks;
  18. using Venus_Core;
  19. using Venus_RT.Devices.EFEM;
  20. using Venus_RT.Devices.TM;
  21. namespace Venus_RT.Devices.VCE
  22. {
  23. //定义Vce动作
  24. public enum VceCommand
  25. {
  26. Home,
  27. DoorClose,
  28. DoorOpen,
  29. CheckGoto,
  30. Goto,
  31. GotoLP,
  32. Load,
  33. UnLoad,
  34. Map,
  35. ReadMap,
  36. ClearError,
  37. }
  38. public enum VceMessageHead
  39. {
  40. Action,
  41. Read,
  42. Set,
  43. Petrify
  44. }
  45. public sealed class VceMessage
  46. {
  47. private Dictionary<VceCommand, string> _Command2Msg = new Dictionary<VceCommand, string>()
  48. {
  49. //Action
  50. {VceCommand.Home, "HM" },
  51. {VceCommand.Load, "LOAD" },
  52. {VceCommand.UnLoad, "UNLOAD"},
  53. {VceCommand.Map, "MP" },
  54. {VceCommand.CheckGoto, "GC" },
  55. {VceCommand.Goto, "GO" },
  56. {VceCommand.GotoLP, "LP" },
  57. {VceCommand.DoorOpen, "DO" },
  58. {VceCommand.DoorClose, "DC" },
  59. //Read
  60. {VceCommand.ReadMap, "MI" },
  61. //Set
  62. {VceCommand.ClearError, "ER" },
  63. };
  64. private Dictionary<VceMessageHead, string> _Type2Head = new Dictionary<VceMessageHead, string>()
  65. {
  66. {VceMessageHead.Action, "A"},
  67. {VceMessageHead.Read, "R"},
  68. {VceMessageHead.Set, "S"},
  69. {VceMessageHead.Petrify, "P"},
  70. };
  71. public VceMessageHead Head { get; set; }
  72. public VceCommand Command { get; set; }
  73. public string Param { get; set; }
  74. public string toString()
  75. {
  76. if (string.IsNullOrEmpty(Param))//含尾参
  77. return $"00,{_Type2Head[Head]},{_Command2Msg[Command]}";
  78. else//不含尾参 目前只允许一个
  79. return $"00,{_Type2Head[Head]},{_Command2Msg[Command]},{Param}";
  80. }
  81. }
  82. /// <summary>
  83. /// 泓浒Vce驱动 下发指令等
  84. /// </summary>
  85. public class HongHuVce : VCEModuleBase
  86. {
  87. #region 私有变量
  88. private AsyncSerialPort _serialport;
  89. private string _portname;
  90. private string _newline = "\r";//终止符 0D
  91. private object _locker = new object();
  92. private bool _IsAsciiMode;
  93. private LinkedList<string> _lstAsciiMsgs = new LinkedList<string>();
  94. private PeriodicJob _thread;
  95. private Regex _match_ReadMsg = new Regex(@"\d\d,X,.*");
  96. private Regex _matchErrorCode = new Regex(@"(?<=_BKGERR )(.*)");
  97. private ModuleName _moduleName;
  98. private RState _status;
  99. private string _currentMsg;
  100. private VceMessage _currentVceMessage;
  101. private bool _HasReceiveMsg;
  102. private bool _IsDashWaferError;
  103. private Loadport[] _LPMs = new Loadport[1];
  104. public override ILoadport this[ModuleName mod]
  105. {
  106. get
  107. {
  108. if (!ModuleHelper.IsLoadPort(mod))
  109. throw new ApplicationException($"{mod} is NOT Loadport");
  110. return _LPMs[mod - ModuleName.LP1];
  111. }
  112. }
  113. //待补充
  114. private Dictionary<string, string> _ErrorCode2Reason = new Dictionary<string, string>()
  115. {
  116. {"A1","Action Timeout" },
  117. {"A3","Hardware (CAN or VCN) or configuration failed" },
  118. {"A4","Open Door Prevented Motion" },
  119. {"A5","Platform Action Time-out" },
  120. {"A6","Door Action Timeout" },
  121. {"A7","由于动作连锁导致的异常" },
  122. {"A8","Wafer Slideout" },
  123. {"A9","Door safety LED is blocked" },
  124. {"A11","载台上没有料盒,看一下载台上是否有料盒" },
  125. {"A12","Cassette present prior PICK" },
  126. {"A13","Cassette NOT present during PICK" },
  127. {"A14","Cassette NOT present prior PLACE" },
  128. {"A15","Cassette present after PLACE" },
  129. {"A16","Cassette Present on VCE platform (Servo Arm)" },
  130. {"A17","No new cassette at station after Load" },
  131. {"A18","Proximity sensor blocked but Cassette A not present" },
  132. {"A19","载台上料盒没有取走,请把料盒取走" },
  133. {"A20","Proximity sensor A is blocked (Fixed Buffer)" },
  134. {"A21","Cassette NOT at station A" },
  135. {"A34","Door Clamped sensor is not ON after clamp (only VCE4!)" },
  136. {"A36","Door Not Covered (sensor)" },
  137. {"C0","Illegal Slot Number" },
  138. {"C1","设备收到非法的操作指令" },
  139. {"C2","Illegal pitch value (too big)" },
  140. {"C3","Illegal Cassette type offset" },
  141. {"C4","Illegal number of Slots" },
  142. {"C5","Illegal Partial step size" },
  143. {"C7","Illegal Find Bias" },
  144. {"C8","Unknown Configuration" },
  145. {"C9","Bad command: command cannot be executed with current HW configuration" },
  146. {"C10","VCE is busy" },
  147. {"C12","Bad Fixture Thickness" },
  148. {"C13","Command is NOT executable (file's operation exception)" },
  149. {"C19","VCEConfig.xml is corrupted" },
  150. {"C20","VCEDefaultSettting.xml is corrupted" },
  151. {"CAN1","CAN Error,Replace the board (MCC2B or MCC-GEN5 or MCC-GEN5 EN)" },
  152. {"CAN2","CAN Abort,Replace the board (MCC2B or MCC-GEN5 or MCC-GEN5 EN)" },
  153. {"CAN3","CAN Timeout,Replace the board (MCC2B or MCC-GEN5 or MCC-GEN5 EN)" },
  154. {"H1","Two hand safety switch are not OFF before R-axis motion" },
  155. {"H2","Two hands safety switch timeout" },
  156. {"H3","One or both safety switches are release before R-axis motion is complete" },
  157. {"M0","VCE is NOT Referenced" },
  158. {"M1","Motion Timeout" },
  159. {"M4","Door over speed" },
  160. {"M10","设备中断,设备被外部停止" },
  161. {"M11","FET over Temperature" },
  162. {"M12","FET over Current" },
  163. {"M13","Torque Limit" },
  164. {"M14","Hard Track Error Codes" },
  165. {"M16","Hardware (servo) Motion Error Codes" },
  166. {"M17","Safety Motion Button was Pushed" },
  167. {"M20","Z-brake request before ENABLE_Z_MOVE" },
  168. {"M21","CPLD Detected a difference from the Dual Up Sensors" },
  169. {"M22","Door Closed Error" },
  170. {"M23","Z-brake chip U8 has an output fault" },
  171. {"M24","Unsafe to move: See a safety node (ENABLE_Z_MOVE) or servo following error" },
  172. {"M25","Servo Following Error" },
  173. {"NO_ACT","No actions" },
  174. {"P2","Map NOT Available" },
  175. {"P3","SPS Excessive Offset" },
  176. {"P4","SPS Excessive Thickness" },
  177. {"P12","FB is too large to map" },
  178. {"P13","FB is too small to map" },
  179. {"R1","R-axis is not referenced" },
  180. {"R2","Extended position is NOT defined" },
  181. {"R3","Door NOT Opened" },
  182. {"R4","Wrong Z-axis position: platform must be between UP and DOWN position" },
  183. {"R5","R-axis Limit is exceeded" },
  184. {"R6","R-axis is NOT Homed (it is not IN)" },
  185. {"R7","R-axis Orientation is NOT set" },
  186. {"R9","R-axis is NOT Extended" },
  187. {"S0","Cannot configure Main VCN" },
  188. {"S1","Cannot configure R-axis VCN" },
  189. {"S4","Command String Error: Bad command or parameter, invalid value, etc." },
  190. {"S5","Illegal data entry" },
  191. {"S10","VCEDefaultSetting.XML file is corrupted. Configuration stop" },
  192. {"S11","Not valid for current configuration" },
  193. {"S20","MiscOutput is already in use" },
  194. {"S21","MiscOutput is used by current configuration" },
  195. {"S22","MiscOutput was deleted: it is used by current configuration" },
  196. {"T5","VCN timeout" },
  197. {"U1","USB not found or ‘Upgrade’ directory doesn’t exist" },
  198. {"U2","Script file couldn't be opened" },
  199. {"U3","Script file not found" },
  200. {"U4","File from the list is not found" },
  201. {"U5","Couldn’t create ‘Upgrade’ directory" },
  202. {"U6","Couldn’t copy files" },
  203. {"U10"," upgrade.txt file is missing" },
  204. {"V2","Cannot disable VCN" },
  205. {"230","Robot Extended" },
  206. {"231","Front buffer extended" },
  207. {"232","Valve drive fault" },
  208. {"236","Door Safety LED is broken" },
  209. {"250","FET Q10 is open circuit" },
  210. {"251","FET Q10 is shorted" },
  211. {"260","Atmospheric Robot is Extended" },
  212. {"261","ERGO Obstructs the Door" },
  213. {"262","Door drive fault" },
  214. {"263","Vacuum Robot is Extended" },
  215. {"264","User Misc Output Drive Fault" },
  216. {"265","Safety Hub Output Fault" },
  217. {"306","Illegal command ID number" },
  218. {"309","Command ID is not supported in thatCOMM FLOW" },
  219. {"390","Invalid Checksum" },
  220. {"414","Command ID in use" },
  221. {"673","GEN5 EN: inputs are in ERROR state" },
  222. {"674","GEN5 EN: inputs are in HALT state" },
  223. {"675","GEN5 EN: inputs are in illegal transition" },
  224. {"L13","由于检测到突片,动作被禁止" },
  225. {"L14","防夹光栅报警,检查舱门关闭路径上是否存在遮挡" },
  226. {"K114","防夹光栅报警" },
  227. {"K115","舱门上限报警" },
  228. {"K116","舱门下限报警 " },
  229. {"K117","急停报警 " },
  230. {"K118","位置未被引用,对设备进行初始化" },
  231. {"K119","Z 轴报警" },
  232. {"K120","R 轴报警 " },
  233. {"K121","Z 轴超限位报警" },
  234. {"K122","机械手不在安全位" },
  235. {"K123","Z 轴未使能" },
  236. {"K124","R 轴未使能" },
  237. {"K125","盒子状态互锁报警" },
  238. {"K158","左凸片" },
  239. {"K159","右凸片" },
  240. {"K160","门没有关好" },
  241. {"K161","盖板缺失" },
  242. {"K162","R轴不在原位" },
  243. {"K163","Z轴不在上下料位" },
  244. {"K164","门未打开" },
  245. };
  246. //
  247. #endregion
  248. #region 暴露变量
  249. public override bool IsConnected => _serialport.IsOpen();
  250. public override RState Status => _status;
  251. public override bool IsReady => _status == RState.Init || _status == RState.End;
  252. public override bool IsError => _status == RState.Failed || _status == RState.Timeout;
  253. public override bool IsInit => _status == RState.Init;
  254. public override bool IsDashWaferError => _IsDashWaferError;
  255. private string[] _slotMap = new string[25];
  256. public string SlotMap
  257. {
  258. get
  259. {
  260. WaferInfo[] wafers = WaferManager.Instance.GetWafers(ModuleHelper.Converter(Name));
  261. string slot = "";
  262. for (int i = 0; i < 25; i++)
  263. {
  264. slot += wafers[i].IsEmpty ? "0" : "1";
  265. }
  266. return slot;
  267. }
  268. }
  269. private bool _OutDoorIsOpen
  270. {
  271. get
  272. {
  273. switch (_moduleName)
  274. {
  275. case ModuleName.VCE1:
  276. //2024-05-20 16:35:34 泓浒四边形硬件还未实现
  277. //DEVICE.GetDevice<HongHuTM>("SETM").VCEACassPresent
  278. return true;
  279. case ModuleName.VCEA:
  280. if (DEVICE.GetDevice<HongHuDETM>("DETM").VCEACassPresent)
  281. {
  282. _LPMs[0].HasCassette = true;
  283. return true;
  284. }
  285. else
  286. {
  287. _LPMs[0].HasCassette = false;
  288. WaferManager.Instance.DeleteWafer(_LPMs[0].Module, 0, 25);
  289. return false;
  290. }
  291. case ModuleName.VCEB:
  292. if (DEVICE.GetDevice<HongHuDETM>("DETM").VCEBCassPresent)
  293. {
  294. _LPMs[0].HasCassette = true;
  295. return true;
  296. }
  297. else
  298. {
  299. _LPMs[0].HasCassette = false;
  300. WaferManager.Instance.DeleteWafer(_LPMs[0].Module, 0, 25);
  301. return false;
  302. }
  303. default:
  304. return false;
  305. }
  306. }
  307. }
  308. public override bool OutDoorIsOpen => _OutDoorIsOpen;
  309. private bool _hasProtrusion
  310. {
  311. get
  312. {
  313. switch (_moduleName)
  314. {
  315. case ModuleName.VCE1:
  316. //2024-05-20 16:35:34 泓浒四边形硬件还未实现
  317. //DEVICE.GetDevice<HongHuTM>("SETM").VCEProtrusion
  318. return true;
  319. case ModuleName.VCEA:
  320. if (DEVICE.GetDevice<HongHuDETM>("DETM").VCEAProtrusion)
  321. {
  322. _LPMs[0].Protrusion = true;
  323. return true;
  324. }
  325. else
  326. {
  327. _LPMs[0].Protrusion = false;
  328. return false;
  329. }
  330. case ModuleName.VCEB:
  331. if (DEVICE.GetDevice<HongHuDETM>("DETM").VCEBProtrusion)
  332. {
  333. _LPMs[0].Protrusion = true;
  334. return true;
  335. }
  336. else
  337. {
  338. _LPMs[0].Protrusion = false;
  339. return false;
  340. }
  341. default:
  342. return false;
  343. }
  344. }
  345. }
  346. #endregion
  347. //传入slot数量
  348. public HongHuVce(int slot, ModuleName moduleName) : base(slot, moduleName)
  349. {
  350. _moduleName = moduleName;
  351. _IsAsciiMode = true;
  352. _portname = SC.GetStringValue($"{moduleName}.Port");
  353. _serialport = new AsyncSerialPort(_portname, 9600, 8, Parity.None, StopBits.One, _newline, _IsAsciiMode);
  354. _serialport.Open();
  355. _status = RState.Init;
  356. _serialport.OnDataChanged += onDataChange;
  357. _thread = new PeriodicJob(50, fnTimer, _moduleName.ToString(), true);
  358. if(moduleName == ModuleName.VCE1)
  359. _LPMs[0] = new Loadport(ModuleName.LP1);
  360. else
  361. _LPMs[0] = new Loadport((moduleName - ModuleName.VCEA) + ModuleName.LP1);
  362. CarrierManager.Instance.DeleteCarrier(_LPMs[0].Module.ToString());
  363. WaferManager.Instance.DeleteWafer(_LPMs[0].Module, 0, 25);
  364. CarrierManager.Instance.SubscribeLocation(_LPMs[0].Module.ToString(), 1);
  365. Action<ModuleName, int> _subscribeLoc = (ModuleName module, int waferCount) => {
  366. if (ModuleHelper.IsInstalled(module))
  367. {
  368. WaferManager.Instance.SubscribeLocation(module, waferCount);
  369. }
  370. };
  371. _subscribeLoc(_LPMs[0].Module, slot);
  372. }
  373. /// <summary>
  374. /// 对处理过的数据list进行处理
  375. /// 将每条数据进行解析
  376. /// </summary>
  377. /// <returns></returns>
  378. private bool fnTimer()
  379. {
  380. lock (_locker)
  381. {
  382. //采用ascii传输
  383. if (_IsAsciiMode)
  384. {
  385. //有数据尚未处理
  386. while (_lstAsciiMsgs.Count > 0)
  387. {
  388. string _needHandle = _lstAsciiMsgs.First.Value;
  389. HandleSingleMsg(_needHandle);
  390. _lstAsciiMsgs.RemoveFirst();
  391. }
  392. }
  393. //采用binary
  394. else
  395. {
  396. }
  397. }
  398. return true;
  399. }
  400. /// <summary>
  401. /// 处理单条信息的函数
  402. /// 1、判断结束 2、判断错误
  403. /// </summary>
  404. /// <param name="msg">需要处理的单条回复</param>
  405. private void HandleSingleMsg(string msg)
  406. {
  407. //
  408. msg = msg.Trim();
  409. if (!string.IsNullOrEmpty(msg))
  410. {
  411. //action set petrify _BKGRDY结束
  412. switch (_currentVceMessage.Head)
  413. {
  414. case VceMessageHead.Action:
  415. case VceMessageHead.Set:
  416. case VceMessageHead.Petrify:
  417. switch (msg)
  418. {
  419. //设备收到 开始运行 目前状态在下发
  420. case "_RDY":
  421. LOG.Write(eEvent.EV_VCE_COMMON_INFO, _moduleName, $"vce start {_currentVceMessage.Head}");
  422. break;
  423. //设备执行完毕
  424. case "_BKGRDY":
  425. LOG.Write(eEvent.EV_VCE_COMMON_INFO, _moduleName, $"vce {_currentVceMessage.Head} over");
  426. _status = RState.End;
  427. break;
  428. //异常处理
  429. default:
  430. _status = RState.Failed;
  431. string reason;
  432. Errorhandle(msg, out reason);
  433. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, _moduleName, reason);
  434. break;
  435. }
  436. break;
  437. case VceMessageHead.Read:
  438. //如果收到的信息符合
  439. if (_match_ReadMsg.IsMatch(msg))
  440. {
  441. //收到消息 用于结束
  442. _HasReceiveMsg = true;
  443. switch (_currentVceMessage.Command)
  444. {
  445. //处理wafer 信息为map数据
  446. case VceCommand.ReadMap:
  447. ReadMapData(msg);
  448. break;
  449. }
  450. }
  451. //_RDY查询结束
  452. else
  453. {
  454. if (msg == "_RDY")
  455. {
  456. if (_HasReceiveMsg)
  457. {
  458. _status = RState.End;
  459. }
  460. else
  461. {
  462. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, _moduleName, $"Read Message is over but not receive msg! raw message:{_currentMsg}");
  463. _status = RState.Failed;
  464. }
  465. }
  466. else
  467. {
  468. _status = RState.Failed;
  469. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, _moduleName, $"Read Message is invalid: receive message {msg} and send message {_currentMsg}");
  470. }
  471. }
  472. break;
  473. }
  474. }
  475. }
  476. private void ReadMapData(string msg)
  477. {
  478. string waferinfo = "";
  479. string[] waferitems = msg.Split(',');
  480. //智能模式 可以识别叠片
  481. for (int i = 3; i < waferitems.Length - 1; ++i)
  482. {
  483. //如果包含只需要逐个检查
  484. if (waferitems[i].Contains('?'))
  485. {
  486. foreach (char j in waferitems[i])
  487. {
  488. if (waferinfo.Length >= 25)
  489. break;
  490. else
  491. waferinfo += j;
  492. }
  493. }
  494. else
  495. waferinfo += waferitems[i];
  496. }
  497. for (int i = 0; i < waferinfo.Length; ++i)
  498. {
  499. int slotnum = i;
  500. if (slotnum < 25)
  501. {
  502. switch (waferinfo[i])
  503. {
  504. case '0':
  505. WaferManager.Instance.CreateWafer(_LPMs[0].Module, slotnum, WaferStatus.Empty);
  506. break;
  507. case 'X':
  508. WaferManager.Instance.CreateWafer(_LPMs[0].Module, slotnum, WaferStatus.Normal);
  509. break;
  510. case 'C':
  511. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, _moduleName, $"Slot {i+1}:double or dummy wafer.");
  512. WaferManager.Instance.CreateWafer(_LPMs[0].Module, slotnum, WaferStatus.Double);
  513. break;
  514. case '?':
  515. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, _moduleName, $"Slot {i + 1}:Crossed wafer.");
  516. WaferManager.Instance.CreateWafer(_LPMs[0].Module, slotnum, WaferStatus.Crossed);
  517. break;
  518. }
  519. }
  520. }
  521. _LPMs[0].IsMapped = true;
  522. }
  523. private void Errorhandle(string msg,out string reason)
  524. {
  525. if (_matchErrorCode.IsMatch(msg))
  526. {
  527. //若是匹配
  528. //包含原因
  529. string errorcode = _matchErrorCode.Match(msg).Value;
  530. if (_ErrorCode2Reason.ContainsKey(errorcode))
  531. {
  532. if(errorcode == "L13")
  533. _IsDashWaferError = true;
  534. reason = _ErrorCode2Reason[errorcode];
  535. }
  536. else
  537. {
  538. reason = "未找到相关Error Code";
  539. }
  540. }
  541. else
  542. {
  543. //若不匹配
  544. reason = "回复消息不符合标准格式";
  545. }
  546. }
  547. /// <summary>
  548. /// 处理新到的数据
  549. /// 利用linkedlist处理拆包 粘包情况
  550. /// </summary>
  551. /// <param name="newline">新到数据</param>
  552. private void onDataChange(string oneLineMessage)
  553. {
  554. lock (_locker)
  555. {
  556. if (string.IsNullOrEmpty(_newline))//没有CR
  557. {
  558. _lstAsciiMsgs.AddLast(oneLineMessage);//将消息添加到最后
  559. return;
  560. }
  561. string[] array = oneLineMessage.Split(_newline.ToCharArray());//按照cr分开通讯数据
  562. foreach (string text in array)
  563. {
  564. if (!string.IsNullOrEmpty(text))
  565. {
  566. _lstAsciiMsgs.AddLast(text + _newline);//存进list中等待处理
  567. }
  568. }
  569. }
  570. }
  571. public override bool HomeALL()
  572. {
  573. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.Home ,Param = "ALL" };
  574. _currentMsg = _currentVceMessage.toString() + _newline ;
  575. _status = RState.Running;
  576. return _serialport.Write(_currentMsg);
  577. }
  578. public override bool Home(string axis)
  579. {
  580. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.Home, Param = axis };
  581. _currentMsg = _currentVceMessage.toString() + _newline;
  582. _status = RState.Running;
  583. return _serialport.Write(_currentMsg);
  584. }
  585. public override bool CloseDoor()
  586. {
  587. if (!CheckVceStatus())
  588. return false;
  589. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.DoorClose };
  590. _currentMsg = _currentVceMessage.toString() + _newline;
  591. _status = RState.Running;
  592. return _serialport.Write(_currentMsg);
  593. }
  594. /// <summary>
  595. /// 开门提示
  596. /// 在honghuVCE中没有ATM信号的内部卡控 可能会导致开门的压差
  597. /// 因此每一次都要增加判断,只要引用此处功能的,前面都需要有判断
  598. ///
  599. /// </summary>
  600. /// <returns></returns>
  601. public override bool OpenDoor()
  602. {
  603. //如果其他指令正在执行 且
  604. //if (!CheckVceStatus())
  605. // return false;
  606. if (_IsDashWaferError)
  607. _IsDashWaferError = false;
  608. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.DoorOpen };
  609. _currentMsg = _currentVceMessage.toString() + _newline;
  610. _status = RState.Running;
  611. return _serialport.Write(_currentMsg);
  612. }
  613. public override bool Load()
  614. {
  615. if (!CheckVceStatus())
  616. return false;
  617. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.Load };
  618. _currentMsg = _currentVceMessage.toString() + _newline;
  619. _status = RState.Running;
  620. return _serialport.Write(_currentMsg);
  621. }
  622. public override bool UnLoad()
  623. {
  624. if (!CheckVceStatus())
  625. return false;
  626. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.UnLoad };
  627. _currentMsg = _currentVceMessage.toString() + _newline;
  628. _status = RState.Running;
  629. return _serialport.Write(_currentMsg);
  630. }
  631. public override bool Map()
  632. {
  633. if (!CheckVceStatus())
  634. return false;
  635. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.Map };
  636. _currentMsg = _currentVceMessage.toString() + _newline;
  637. _status = RState.Running;
  638. return _serialport.Write(_currentMsg);
  639. }
  640. public override bool ReadMap()
  641. {
  642. if (!CheckVceStatus())
  643. return false;
  644. _currentVceMessage = new VceMessage { Head = VceMessageHead.Read, Command = VceCommand.ReadMap, Param = "S" };
  645. _currentMsg = _currentVceMessage.toString() + _newline;
  646. _status = RState.Running;
  647. _HasReceiveMsg = false;
  648. return _serialport.Write(_currentMsg);
  649. }
  650. public override bool Goto(int Targetslot)
  651. {
  652. if (!CheckVceStatus())
  653. return false;
  654. LOG.Write(eEvent.EV_VCE_COMMON_INFO,ModuleName.VCE1, $"SlotNum:{Targetslot}");
  655. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.Goto, Param = (Targetslot+1).ToString().PadLeft(2,'0') };
  656. _currentMsg = _currentVceMessage.toString() + _newline;
  657. _status = RState.Running;
  658. return _serialport.Write(_currentMsg);
  659. }
  660. public override bool GotoLP()
  661. {
  662. if (!CheckVceStatus())
  663. return false;
  664. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.GotoLP };
  665. _currentMsg = _currentVceMessage.toString() + _newline;
  666. _status = RState.Running;
  667. return _serialport.Write(_currentMsg);
  668. }
  669. public override bool ClearError()
  670. {
  671. _currentVceMessage = new VceMessage { Head = VceMessageHead.Set, Command = VceCommand.ClearError };
  672. _currentMsg = _currentVceMessage.toString() + _newline;
  673. _status = RState.Running;
  674. return _serialport.Write(_currentMsg);
  675. }
  676. }
  677. }