HongHuVce.cs 29 KB

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