HongHuVce.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  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. return false;
  289. }
  290. case ModuleName.VCEB:
  291. if (DEVICE.GetDevice<HongHuDETM>("DETM").VCEBCassPresent)
  292. {
  293. _LPMs[0].HasCassette = true;
  294. return true;
  295. }
  296. else
  297. {
  298. _LPMs[0].HasCassette = false;
  299. return false;
  300. }
  301. default:
  302. return false;
  303. }
  304. }
  305. }
  306. public override bool OutDoorIsOpen => _OutDoorIsOpen;
  307. private bool _hasProtrusion
  308. {
  309. get
  310. {
  311. switch (_moduleName)
  312. {
  313. case ModuleName.VCE1:
  314. //2024-05-20 16:35:34 泓浒四边形硬件还未实现
  315. //DEVICE.GetDevice<HongHuTM>("SETM").VCEProtrusion
  316. return true;
  317. case ModuleName.VCEA:
  318. if (DEVICE.GetDevice<HongHuDETM>("DETM").VCEAProtrusion)
  319. {
  320. _LPMs[0].Protrusion = true;
  321. return true;
  322. }
  323. else
  324. {
  325. _LPMs[0].Protrusion = false;
  326. return false;
  327. }
  328. case ModuleName.VCEB:
  329. if (DEVICE.GetDevice<HongHuDETM>("DETM").VCEBProtrusion)
  330. {
  331. _LPMs[0].Protrusion = true;
  332. return true;
  333. }
  334. else
  335. {
  336. _LPMs[0].Protrusion = false;
  337. return false;
  338. }
  339. default:
  340. return false;
  341. }
  342. }
  343. }
  344. #endregion
  345. //传入slot数量
  346. public HongHuVce(int slot, ModuleName moduleName) : base(slot, moduleName)
  347. {
  348. _moduleName = moduleName;
  349. _IsAsciiMode = true;
  350. _portname = SC.GetStringValue($"{moduleName}.Port");
  351. _serialport = new AsyncSerialPort(_portname, 9600, 8, Parity.None, StopBits.One, _newline, _IsAsciiMode);
  352. _serialport.Open();
  353. _status = RState.Init;
  354. _serialport.OnDataChanged += onDataChange;
  355. _thread = new PeriodicJob(50, fnTimer, _moduleName.ToString(), true);
  356. if(moduleName == ModuleName.VCE1)
  357. _LPMs[0] = new Loadport(ModuleName.LP1);
  358. else
  359. _LPMs[0] = new Loadport((moduleName - ModuleName.VCEA) + ModuleName.LP1);
  360. CarrierManager.Instance.DeleteCarrier(_LPMs[0].Module.ToString());
  361. WaferManager.Instance.DeleteWafer(_LPMs[0].Module, 0, 25);
  362. CarrierManager.Instance.SubscribeLocation(_LPMs[0].Module.ToString(), 1);
  363. Action<ModuleName, int> _subscribeLoc = (ModuleName module, int waferCount) => {
  364. if (ModuleHelper.IsInstalled(module))
  365. {
  366. WaferManager.Instance.SubscribeLocation(module, waferCount);
  367. }
  368. };
  369. _subscribeLoc(_LPMs[0].Module, slot);
  370. }
  371. /// <summary>
  372. /// 对处理过的数据list进行处理
  373. /// 将每条数据进行解析
  374. /// </summary>
  375. /// <returns></returns>
  376. private bool fnTimer()
  377. {
  378. lock (_locker)
  379. {
  380. //采用ascii传输
  381. if (_IsAsciiMode)
  382. {
  383. //有数据尚未处理
  384. while (_lstAsciiMsgs.Count > 0)
  385. {
  386. string _needHandle = _lstAsciiMsgs.First.Value;
  387. HandleSingleMsg(_needHandle);
  388. _lstAsciiMsgs.RemoveFirst();
  389. }
  390. }
  391. //采用binary
  392. else
  393. {
  394. }
  395. }
  396. return true;
  397. }
  398. /// <summary>
  399. /// 处理单条信息的函数
  400. /// 1、判断结束 2、判断错误
  401. /// </summary>
  402. /// <param name="msg">需要处理的单条回复</param>
  403. private void HandleSingleMsg(string msg)
  404. {
  405. //
  406. msg = msg.Trim();
  407. if (!string.IsNullOrEmpty(msg))
  408. {
  409. //action set petrify _BKGRDY结束
  410. switch (_currentVceMessage.Head)
  411. {
  412. case VceMessageHead.Action:
  413. case VceMessageHead.Set:
  414. case VceMessageHead.Petrify:
  415. switch (msg)
  416. {
  417. //设备收到 开始运行 目前状态在下发
  418. case "_RDY":
  419. LOG.Write(eEvent.EV_VCE_COMMON_INFO, _moduleName, $"vce start {_currentVceMessage.Head}");
  420. break;
  421. //设备执行完毕
  422. case "_BKGRDY":
  423. LOG.Write(eEvent.EV_VCE_COMMON_INFO, _moduleName, $"vce {_currentVceMessage.Head} over");
  424. _status = RState.End;
  425. break;
  426. //异常处理
  427. default:
  428. _status = RState.Failed;
  429. string reason;
  430. Errorhandle(msg, out reason);
  431. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, _moduleName, reason);
  432. break;
  433. }
  434. break;
  435. case VceMessageHead.Read:
  436. //如果收到的信息符合
  437. if (_match_ReadMsg.IsMatch(msg))
  438. {
  439. //收到消息 用于结束
  440. _HasReceiveMsg = true;
  441. switch (_currentVceMessage.Command)
  442. {
  443. //处理wafer 信息为map数据
  444. case VceCommand.ReadMap:
  445. ReadMapData(msg);
  446. break;
  447. }
  448. }
  449. //_RDY查询结束
  450. else
  451. {
  452. if (msg == "_RDY")
  453. {
  454. if (_HasReceiveMsg)
  455. {
  456. _status = RState.End;
  457. }
  458. else
  459. {
  460. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, _moduleName, $"Read Message is over but not receive msg! raw message:{_currentMsg}");
  461. _status = RState.Failed;
  462. }
  463. }
  464. else
  465. {
  466. _status = RState.Failed;
  467. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, _moduleName, $"Read Message is invalid: receive message {msg} and send message {_currentMsg}");
  468. }
  469. }
  470. break;
  471. }
  472. }
  473. }
  474. private void ReadMapData(string msg)
  475. {
  476. string waferinfo = "";
  477. string[] waferitems = msg.Split(',');
  478. //智能模式 可以识别叠片
  479. for (int i = 3; i < waferitems.Length - 1; ++i)
  480. {
  481. //如果包含只需要逐个检查
  482. if (waferitems[i].Contains('?'))
  483. {
  484. foreach (char j in waferitems[i])
  485. {
  486. if (waferinfo.Length >= 25)
  487. break;
  488. else
  489. waferinfo += j;
  490. }
  491. }
  492. else
  493. waferinfo += waferitems[i];
  494. }
  495. for (int i = 0; i < waferinfo.Length; ++i)
  496. {
  497. int slotnum = i;
  498. if (slotnum < 25)
  499. {
  500. switch (waferinfo[i])
  501. {
  502. case '0':
  503. WaferManager.Instance.CreateWafer(_LPMs[0].Module, slotnum, WaferStatus.Empty);
  504. break;
  505. case 'X':
  506. WaferManager.Instance.CreateWafer(_LPMs[0].Module, slotnum, WaferStatus.Normal);
  507. break;
  508. case 'C':
  509. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, _moduleName, $"Slot {i+1}:double or dummy wafer.");
  510. WaferManager.Instance.CreateWafer(_LPMs[0].Module, slotnum, WaferStatus.Double);
  511. break;
  512. case '?':
  513. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, _moduleName, $"Slot {i + 1}:Crossed wafer.");
  514. WaferManager.Instance.CreateWafer(_LPMs[0].Module, slotnum, WaferStatus.Crossed);
  515. break;
  516. }
  517. }
  518. }
  519. _LPMs[0].IsMapped = true;
  520. }
  521. private void Errorhandle(string msg,out string reason)
  522. {
  523. if (_matchErrorCode.IsMatch(msg))
  524. {
  525. //若是匹配
  526. //包含原因
  527. string errorcode = _matchErrorCode.Match(msg).Value;
  528. if (_ErrorCode2Reason.ContainsKey(errorcode))
  529. {
  530. if(errorcode == "L13")
  531. _IsDashWaferError = true;
  532. reason = _ErrorCode2Reason[errorcode];
  533. }
  534. else
  535. {
  536. reason = "未找到相关Error Code";
  537. }
  538. }
  539. else
  540. {
  541. //若不匹配
  542. reason = "回复消息不符合标准格式";
  543. }
  544. }
  545. /// <summary>
  546. /// 处理新到的数据
  547. /// 利用linkedlist处理拆包 粘包情况
  548. /// </summary>
  549. /// <param name="newline">新到数据</param>
  550. private void onDataChange(string oneLineMessage)
  551. {
  552. lock (_locker)
  553. {
  554. if (string.IsNullOrEmpty(_newline))//没有CR
  555. {
  556. _lstAsciiMsgs.AddLast(oneLineMessage);//将消息添加到最后
  557. return;
  558. }
  559. string[] array = oneLineMessage.Split(_newline.ToCharArray());//按照cr分开通讯数据
  560. foreach (string text in array)
  561. {
  562. if (!string.IsNullOrEmpty(text))
  563. {
  564. _lstAsciiMsgs.AddLast(text + _newline);//存进list中等待处理
  565. }
  566. }
  567. }
  568. }
  569. public override bool HomeALL()
  570. {
  571. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.Home ,Param = "ALL" };
  572. _currentMsg = _currentVceMessage.toString() + _newline ;
  573. _status = RState.Running;
  574. return _serialport.Write(_currentMsg);
  575. }
  576. public override bool Home(string axis)
  577. {
  578. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.Home, Param = axis };
  579. _currentMsg = _currentVceMessage.toString() + _newline;
  580. _status = RState.Running;
  581. return _serialport.Write(_currentMsg);
  582. }
  583. public override bool CloseDoor()
  584. {
  585. if (!CheckVceStatus())
  586. return false;
  587. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.DoorClose };
  588. _currentMsg = _currentVceMessage.toString() + _newline;
  589. _status = RState.Running;
  590. return _serialport.Write(_currentMsg);
  591. }
  592. /// <summary>
  593. /// 开门提示
  594. /// 在honghuVCE中没有ATM信号的内部卡控 可能会导致开门的压差
  595. /// 因此每一次都要增加判断,只要引用此处功能的,前面都需要有判断
  596. ///
  597. /// </summary>
  598. /// <returns></returns>
  599. public override bool OpenDoor()
  600. {
  601. //如果其他指令正在执行 且
  602. //if (!CheckVceStatus())
  603. // return false;
  604. if (_IsDashWaferError)
  605. _IsDashWaferError = false;
  606. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.DoorOpen };
  607. _currentMsg = _currentVceMessage.toString() + _newline;
  608. _status = RState.Running;
  609. return _serialport.Write(_currentMsg);
  610. }
  611. public override bool Load()
  612. {
  613. if (!CheckVceStatus())
  614. return false;
  615. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.Load };
  616. _currentMsg = _currentVceMessage.toString() + _newline;
  617. _status = RState.Running;
  618. return _serialport.Write(_currentMsg);
  619. }
  620. public override bool UnLoad()
  621. {
  622. if (!CheckVceStatus())
  623. return false;
  624. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.UnLoad };
  625. _currentMsg = _currentVceMessage.toString() + _newline;
  626. _status = RState.Running;
  627. return _serialport.Write(_currentMsg);
  628. }
  629. public override bool Map()
  630. {
  631. if (!CheckVceStatus())
  632. return false;
  633. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.Map };
  634. _currentMsg = _currentVceMessage.toString() + _newline;
  635. _status = RState.Running;
  636. return _serialport.Write(_currentMsg);
  637. }
  638. public override bool ReadMap()
  639. {
  640. if (!CheckVceStatus())
  641. return false;
  642. _currentVceMessage = new VceMessage { Head = VceMessageHead.Read, Command = VceCommand.ReadMap, Param = "S" };
  643. _currentMsg = _currentVceMessage.toString() + _newline;
  644. _status = RState.Running;
  645. _HasReceiveMsg = false;
  646. return _serialport.Write(_currentMsg);
  647. }
  648. public override bool Goto(int Targetslot)
  649. {
  650. if (!CheckVceStatus())
  651. return false;
  652. LOG.Write(eEvent.EV_VCE_COMMON_INFO,ModuleName.VCE1, $"SlotNum:{Targetslot}");
  653. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.Goto, Param = (Targetslot+1).ToString().PadLeft(2,'0') };
  654. _currentMsg = _currentVceMessage.toString() + _newline;
  655. _status = RState.Running;
  656. return _serialport.Write(_currentMsg);
  657. }
  658. public override bool GotoLP()
  659. {
  660. if (!CheckVceStatus())
  661. return false;
  662. _currentVceMessage = new VceMessage { Head = VceMessageHead.Action, Command = VceCommand.GotoLP };
  663. _currentMsg = _currentVceMessage.toString() + _newline;
  664. _status = RState.Running;
  665. return _serialport.Write(_currentMsg);
  666. }
  667. public override bool ClearError()
  668. {
  669. _currentVceMessage = new VceMessage { Head = VceMessageHead.Set, Command = VceCommand.ClearError };
  670. _currentMsg = _currentVceMessage.toString() + _newline;
  671. _status = RState.Running;
  672. return _serialport.Write(_currentMsg);
  673. }
  674. }
  675. }