HongHuVce.cs 26 KB

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