HiwinRobotHandler.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. using MECF.Framework.Common.CommonData;
  2. using MECF.Framework.Common.Communications;
  3. using MECF.Framework.Common.Equipment;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.HiWin
  10. {
  11. public abstract class HiwinRobotHandler : HandlerBase
  12. {
  13. public HiwinRobot Device { get; set; }
  14. protected string _requestResponse = "";
  15. protected string _command;
  16. protected string _parameter;
  17. protected string _target;
  18. protected RobotArmEnum _blade;
  19. public HiwinRobotHandler(HiwinRobot device, string command, string parameter = null) : base(BuildMessage(command, parameter))
  20. {
  21. Device = device;
  22. _command = command;
  23. _parameter = parameter;
  24. Name = command;
  25. }
  26. public static string BuildMessage(string command, string parameter)
  27. {
  28. string msg = parameter == null ? $"{command}" : $"{command} {parameter}";
  29. return msg + "\r\n";
  30. }
  31. public override bool HandleMessage(MessageBase msg, out bool transactionComplete)
  32. {
  33. HiwinRobotMessage response = msg as HiwinRobotMessage;
  34. ResponseMessage = msg;
  35. if (response.IsError)
  36. {
  37. Device.NoteError(response.Data);
  38. }
  39. if (response.IsComplete)
  40. {
  41. SetState(EnumHandlerState.Completed);
  42. transactionComplete = true;
  43. return true;
  44. }
  45. if (response.IsResponse)
  46. {
  47. _requestResponse = response.Data;
  48. }
  49. //处理反馈信息
  50. transactionComplete = false;
  51. return false;
  52. }
  53. }
  54. /// <summary>
  55. /// 通用命令
  56. /// </summary>
  57. public class SunwayRobotRawCommandHandler : HiwinRobotHandler
  58. {
  59. public SunwayRobotRawCommandHandler(HiwinRobot device, string command, string parameter = null)
  60. : base(device, command, parameter)
  61. {
  62. }
  63. public override bool HandleMessage(MessageBase msg, out bool handled)
  64. {
  65. if (base.HandleMessage(msg, out handled))
  66. {
  67. var result = msg as HiwinRobotMessage;
  68. var rawMsg = _requestResponse != null ? _requestResponse + "$" + result.RawMessage : result.RawMessage;
  69. //Device.NoteRawCommandInfo(_command, rawMsg);
  70. }
  71. return true;
  72. }
  73. }
  74. public class HiwinRobotGetControllerStatusHandler : HiwinRobotHandler
  75. {
  76. //RESP,VAR.....
  77. public HiwinRobotGetControllerStatusHandler(HiwinRobot device, ModuleName module,int timeout=300)
  78. : base(device, "STAT")
  79. {
  80. AckTimeout = TimeSpan.FromSeconds(timeout);
  81. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  82. }
  83. public override bool HandleMessage(MessageBase msg, out bool handled)
  84. {
  85. var result = msg as HiwinRobotMessage;
  86. if (result.IsError)
  87. {
  88. Device.NoteError(result.Data);
  89. }
  90. else
  91. {
  92. Device.NoteError(null);
  93. }
  94. ResponseMessage = msg;
  95. handled = true;
  96. //Device.NoteActionCompleted();
  97. return true;
  98. }
  99. }
  100. /// <summary>
  101. /// 读取机械臂全部错误
  102. /// </summary>
  103. public class HiwinRobotGetAllErrHandler : HiwinRobotHandler
  104. {
  105. //0000, 0000, 0001, 0001, 0001, 0000, 0000, 0000
  106. //0000, 0002, 0000, 0000, 0000, 0000, 0000, 0000
  107. public HiwinRobotGetAllErrHandler(HiwinRobot device, int timeout=300)
  108. : base(device, "ERR", $"0")
  109. {
  110. AckTimeout = TimeSpan.FromSeconds(timeout);
  111. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  112. }
  113. public override bool HandleMessage(MessageBase msg, out bool handled)
  114. {
  115. var result = msg as HiwinRobotMessage;
  116. if (result.IsError)
  117. {
  118. Device.NoteError(result.Data);
  119. }
  120. else
  121. {
  122. Device.NoteError(null);
  123. }
  124. ResponseMessage = msg;
  125. handled = true;
  126. //Device.NoteActionCompleted();
  127. return true;
  128. }
  129. }
  130. /// <summary>
  131. /// 读取机械臂输入信息错误
  132. /// </summary>
  133. public class HiwinRobotGeInputErrHandler : HiwinRobotHandler
  134. {
  135. //RESP,VAR.....
  136. public HiwinRobotGeInputErrHandler(HiwinRobot device, ModuleName module,int timeout=300)
  137. : base(device, "ERR", $"1")
  138. {
  139. AckTimeout = TimeSpan.FromSeconds(timeout);
  140. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  141. }
  142. public override bool HandleMessage(MessageBase msg, out bool handled)
  143. {
  144. var result = msg as HiwinRobotMessage;
  145. if (result.IsError)
  146. {
  147. Device.NoteError(result.Data);
  148. }
  149. else
  150. {
  151. Device.NoteError(null);
  152. }
  153. ResponseMessage = msg;
  154. handled = true;
  155. //Device.NoteActionCompleted();
  156. return true;
  157. }
  158. }
  159. /// <summary>
  160. /// 要求重置控制器
  161. /// </summary>
  162. public class HiwinRobotResetControllerErrHandler : HiwinRobotHandler
  163. {
  164. //RESP,VAR.....
  165. public HiwinRobotResetControllerErrHandler(HiwinRobot device, ModuleName module,int timeout=300)
  166. : base(device, "RES")
  167. {
  168. AckTimeout = TimeSpan.FromSeconds(timeout);
  169. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  170. }
  171. public override bool HandleMessage(MessageBase msg, out bool handled)
  172. {
  173. var result = msg as HiwinRobotMessage;
  174. if (result.IsError)
  175. {
  176. Device.NoteError(result.Data);
  177. }
  178. else
  179. {
  180. Device.NoteError(null);
  181. }
  182. ResponseMessage = msg;
  183. handled = true;
  184. //Device.NoteActionCompleted();
  185. return true;
  186. }
  187. }
  188. /// <summary>
  189. /// 设置机械手轴运动速度
  190. /// </summary>
  191. public class HiwinRobotSetAxisVelocityHandler : HiwinRobotHandler
  192. {
  193. /// <summary>
  194. /// 设置机械手轴运动速度
  195. /// </summary>
  196. /// <param name="device"></param>
  197. /// <param name="module"></param>
  198. /// <param name="axis"></param>
  199. /// <param name="velocity"></param>
  200. public HiwinRobotSetAxisVelocityHandler(HiwinRobot device, ModuleName module, string axis, string velocity,int timeout=300)
  201. : base(device, "SSP", $"{axis},{velocity}")
  202. {
  203. AckTimeout = TimeSpan.FromSeconds(timeout);
  204. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  205. }
  206. public override bool HandleMessage(MessageBase msg, out bool handled)
  207. {
  208. var result = msg as HiwinRobotMessage;
  209. if (result.IsError)
  210. {
  211. Device.NoteError(result.Data);
  212. }
  213. else
  214. {
  215. Device.NoteError(null);
  216. }
  217. ResponseMessage = msg;
  218. handled = true;
  219. //Device.NoteActionCompleted();
  220. return true;
  221. }
  222. }
  223. /// <summary>
  224. /// 设置机械手轴运动速度
  225. /// </summary>
  226. public class HiwinRobotSetSpeedHandler : HiwinRobotHandler
  227. {
  228. /// <summary>
  229. /// 设置机械手运动速度
  230. /// </summary>
  231. /// <param name="device"></param>
  232. /// <param name="module"></param>
  233. /// <param name="axis"></param>
  234. /// <param name="velocity"></param>
  235. public HiwinRobotSetSpeedHandler(HiwinRobot device, float speedPercent)
  236. : base(device, "SSPP", $"A,{speedPercent},{speedPercent},{speedPercent}")
  237. {
  238. }
  239. public override bool HandleMessage(MessageBase msg, out bool handled)
  240. {
  241. var result = msg as HiwinRobotMessage;
  242. if (result.IsError)
  243. {
  244. Device.NoteError(result.Data);
  245. }
  246. else
  247. {
  248. Device.NoteError(null);
  249. }
  250. ResponseMessage = msg;
  251. handled = true;
  252. //Device.NoteActionCompleted();
  253. return true;
  254. }
  255. }
  256. /// <summary>
  257. /// 设置机械手轴运动加速
  258. /// </summary>
  259. public class HiwinRobotSetAxisAccelerationHandler : HiwinRobotHandler
  260. {
  261. /// <summary>
  262. /// 设置机械手轴运动速度
  263. /// </summary>
  264. /// <param name="device"></param>
  265. /// <param name="module"></param>
  266. /// <param name="axis"></param>
  267. /// <param name="velocity"></param>
  268. public HiwinRobotSetAxisAccelerationHandler(HiwinRobot device, ModuleName module, string axis, string acceleration,int timeout=300)
  269. : base(device, "SAD", $"{axis},{acceleration}")
  270. {
  271. AckTimeout = TimeSpan.FromSeconds(timeout);
  272. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  273. }
  274. public override bool HandleMessage(MessageBase msg, out bool handled)
  275. {
  276. var result = msg as HiwinRobotMessage;
  277. if (result.IsError)
  278. {
  279. Device.NoteError(result.Data);
  280. }
  281. else
  282. {
  283. Device.NoteError(null);
  284. }
  285. ResponseMessage = msg;
  286. handled = true;
  287. //Device.NoteActionCompleted();
  288. return true;
  289. }
  290. }
  291. /// <summary>
  292. /// 设置机械手轴运动加速
  293. /// </summary>
  294. public class HiwinRobotSetAxisDecelerationHandler : HiwinRobotHandler
  295. {
  296. /// <summary>
  297. /// 设置机械手轴运动速度
  298. /// </summary>
  299. /// <param name="device"></param>
  300. /// <param name="module"></param>
  301. /// <param name="axis"></param>
  302. /// <param name="velocity"></param>
  303. public HiwinRobotSetAxisDecelerationHandler(HiwinRobot device, ModuleName module, string axis, string deceleration,int timeout=300)
  304. : base(device, "SDL", $"{axis},{deceleration}")
  305. {
  306. AckTimeout = TimeSpan.FromSeconds(timeout);
  307. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  308. }
  309. public override bool HandleMessage(MessageBase msg, out bool handled)
  310. {
  311. var result = msg as HiwinRobotMessage;
  312. if (result.IsError)
  313. {
  314. Device.NoteError(result.Data);
  315. }
  316. else
  317. {
  318. Device.NoteError(null);
  319. }
  320. ResponseMessage = msg;
  321. handled = true;
  322. //Device.NoteActionCompleted();
  323. return true;
  324. }
  325. }
  326. /// <summary>
  327. /// 打开或关闭机械手电机
  328. /// </summary>
  329. public class HiwinRobotOpeOrCloseMotorHandler : HiwinRobotHandler
  330. {
  331. /// <summary>
  332. /// 设置机械手轴运动速度
  333. /// </summary>
  334. /// <param name="device"></param>
  335. /// <param name="module"></param>
  336. /// <param name="isOpen"></param>
  337. /// <param name="axis"></param>
  338. public HiwinRobotOpeOrCloseMotorHandler(HiwinRobot device, ModuleName module, bool isOpen, string axis,int timeout=300)
  339. : base(device, isOpen ? "SVON" : "SVOFF", axis)
  340. {
  341. AckTimeout = TimeSpan.FromSeconds(timeout);
  342. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  343. }
  344. public override bool HandleMessage(MessageBase msg, out bool handled)
  345. {
  346. var result = msg as HiwinRobotMessage;
  347. if (result.IsError)
  348. {
  349. Device.NoteError(result.Data);
  350. }
  351. else
  352. {
  353. Device.NoteError(null);
  354. }
  355. ResponseMessage = msg;
  356. handled = true;
  357. //Device.NoteActionCompleted();
  358. return true;
  359. }
  360. }
  361. /// <summary>
  362. /// 移动机械手至绝对位置
  363. /// </summary>
  364. public class HiwinRobotAxisMoveAbsoluteHandler : HiwinRobotHandler
  365. {
  366. /// <summary>
  367. /// 设置机械手轴运动速度
  368. /// </summary>
  369. /// <param name="device"></param>
  370. /// <param name="module"></param>
  371. /// <param name="axis"></param>
  372. /// <param name="position"></param>
  373. public HiwinRobotAxisMoveAbsoluteHandler(HiwinRobot device, ModuleName module, string axis, int position,int timeout=300)
  374. : base(device, "MOVA", $"{axis},{position}")
  375. {
  376. AckTimeout = TimeSpan.FromSeconds(timeout);
  377. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  378. }
  379. public override bool HandleMessage(MessageBase msg, out bool handled)
  380. {
  381. var result = msg as HiwinRobotMessage;
  382. if (result.IsError)
  383. {
  384. Device.NoteError(result.Data);
  385. }
  386. else
  387. {
  388. Device.NoteError(null);
  389. }
  390. ResponseMessage = msg;
  391. handled = true;
  392. //Device.NoteActionCompleted();
  393. return true;
  394. }
  395. }
  396. /// <summary>
  397. /// 移动机械手至相对位置
  398. /// </summary>
  399. public class HiwinRobotAxisMoveRelativeHandler : HiwinRobotHandler
  400. {
  401. /// <summary>
  402. /// 设置机械手轴运动速度
  403. /// </summary>
  404. /// <param name="device"></param>
  405. /// <param name="module"></param>
  406. /// <param name="axis"></param>
  407. /// <param name="position"></param>
  408. public HiwinRobotAxisMoveRelativeHandler(HiwinRobot device, ModuleName module, string axis, int position,int timeout=300)
  409. : base(device, "MOVR", $"{axis},{position}")
  410. {
  411. AckTimeout = TimeSpan.FromSeconds(timeout);
  412. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  413. }
  414. public override bool HandleMessage(MessageBase msg, out bool handled)
  415. {
  416. var result = msg as HiwinRobotMessage;
  417. if (result.IsError)
  418. {
  419. Device.NoteError(result.Data);
  420. }
  421. else
  422. {
  423. Device.NoteError(null);
  424. }
  425. ResponseMessage = msg;
  426. handled = true;
  427. //Device.NoteActionCompleted();
  428. return true;
  429. }
  430. }
  431. /// <summary>
  432. /// 移动机械手轴移动X,Y位置
  433. /// </summary>
  434. public class HiwinRobotAxisMoveXYHandler : HiwinRobotHandler
  435. {
  436. /// <summary>
  437. /// 设置机械手轴运动速度
  438. /// </summary>
  439. /// <param name="device"></param>
  440. /// <param name="module"></param>
  441. /// <param name="axis"></param>
  442. /// <param name="x"></param>
  443. /// <param name="y"></param>
  444. public HiwinRobotAxisMoveXYHandler(HiwinRobot device, ModuleName module, string axis, int x, int y,int timeout=300)
  445. : base(device, "MOVXY", $"{axis},{x},{y}")
  446. {
  447. AckTimeout = TimeSpan.FromSeconds(timeout);
  448. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  449. }
  450. public override bool HandleMessage(MessageBase msg, out bool handled)
  451. {
  452. var result = msg as HiwinRobotMessage;
  453. if (result.IsError)
  454. {
  455. Device.NoteError(result.Data);
  456. }
  457. else
  458. {
  459. Device.NoteError(null);
  460. }
  461. ResponseMessage = msg;
  462. handled = true;
  463. //Device.NoteActionCompleted();
  464. return true;
  465. }
  466. }
  467. /// <summary>
  468. /// 停止机械手轴移动
  469. /// </summary>
  470. public class HiwinRobotAxisStopMoveHandler : HiwinRobotHandler
  471. {
  472. /// <summary>
  473. /// 停止机械手轴移动
  474. /// </summary>
  475. /// <param name="device"></param>
  476. /// <param name="module"></param>
  477. /// <param name="axis"></param>
  478. public HiwinRobotAxisStopMoveHandler(HiwinRobot device, ModuleName module)
  479. : base(device, "ABM")
  480. {
  481. }
  482. public override bool HandleMessage(MessageBase msg, out bool handled)
  483. {
  484. var result = msg as HiwinRobotMessage;
  485. if (result.IsError)
  486. {
  487. Device.NoteError(result.Data);
  488. }
  489. else
  490. {
  491. Device.NoteError(null);
  492. }
  493. ResponseMessage = msg;
  494. handled = true;
  495. //Device.NoteActionCompleted();
  496. return true;
  497. }
  498. }
  499. /// <summary>
  500. /// 机械手特定轴归原点
  501. /// </summary>
  502. public class HiwinRobotAxisHomeHandler : HiwinRobotHandler
  503. {
  504. /// <summary>
  505. /// 停止机械手轴移动
  506. /// </summary>
  507. /// <param name="device"></param>
  508. /// <param name="module"></param>
  509. /// <param name="axis"></param>
  510. public HiwinRobotAxisHomeHandler(HiwinRobot device, ModuleName module, string axis,int timeout=300)
  511. : base(device, "HOME", $"{axis}")
  512. {
  513. AckTimeout = TimeSpan.FromSeconds(timeout);
  514. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  515. }
  516. public override bool HandleMessage(MessageBase msg, out bool handled)
  517. {
  518. var result = msg as HiwinRobotMessage;
  519. if (result.IsError)
  520. {
  521. Device.NoteError(result.Data);
  522. }
  523. else
  524. {
  525. Device.NoteError(null);
  526. }
  527. ResponseMessage = msg;
  528. handled = true;
  529. //Device.NoteActionCompleted();
  530. return true;
  531. }
  532. }
  533. /// <summary>
  534. /// 机械手全轴归原点
  535. /// </summary>
  536. public class HiwinRobotHomeALLHandler : HiwinRobotHandler
  537. {
  538. /// <summary>
  539. /// 停止机械手轴移动
  540. /// </summary>
  541. /// <param name="device"></param>
  542. /// <param name="module"></param>
  543. public HiwinRobotHomeALLHandler(HiwinRobot device, ModuleName module,int timeout=300)
  544. : base(device, "HOM")
  545. {
  546. AckTimeout = TimeSpan.FromSeconds(timeout);
  547. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  548. }
  549. public override bool HandleMessage(MessageBase msg, out bool handled)
  550. {
  551. var result = msg as HiwinRobotMessage;
  552. if (result.IsError)
  553. {
  554. Device.NoteError(result.Data);
  555. }
  556. else
  557. {
  558. Device.NoteError(null);
  559. }
  560. ResponseMessage = msg;
  561. handled = true;
  562. //Device.NoteActionCompleted();
  563. return true;
  564. }
  565. }
  566. /// <summary>
  567. /// 设置机器晶舟站点坐标(第一组坐标)
  568. /// </summary>
  569. public class HiwinRobotSetBoatStationHandler : HiwinRobotHandler
  570. {
  571. /// <summary>
  572. /// 机器晶舟站点坐标
  573. /// </summary>
  574. /// <param name="device"></param>
  575. /// <param name="module"></param>
  576. /// <param name="station">A-Z,AA-AZ---GA-GZ</param>
  577. ///<param name="coordinateT"></param>
  578. ///<param name="coordinateR"></param>
  579. ///<param name="coordinateZ"></param>
  580. public HiwinRobotSetBoatStationHandler(HiwinRobot device, ModuleName module, string station, int coordinateT, int coordinateR, int coordinateZ, int coordinateH,int timeout=300)
  581. : base(device, "SPC", $"{station},{coordinateT},{coordinateR}{coordinateZ},{coordinateH}")
  582. {
  583. AckTimeout = TimeSpan.FromSeconds(timeout);
  584. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  585. }
  586. public override bool HandleMessage(MessageBase msg, out bool handled)
  587. {
  588. var result = msg as HiwinRobotMessage;
  589. if (result.IsError)
  590. {
  591. Device.NoteError(result.Data);
  592. }
  593. else
  594. {
  595. Device.NoteError(null);
  596. }
  597. ResponseMessage = msg;
  598. handled = true;
  599. //Device.NoteActionCompleted();
  600. return true;
  601. }
  602. }
  603. /// <summary>
  604. /// 设置机器晶舟站点坐标(第一组坐标)
  605. /// </summary>
  606. public class HiwinRobotSetBoatStation2Handler : HiwinRobotHandler
  607. {
  608. /// <summary>
  609. /// 机器晶舟站点坐标
  610. /// </summary>
  611. /// <param name="device"></param>
  612. /// <param name="module"></param>
  613. /// <param name="station">A-Z,AA-AZ---GA-GZ</param>
  614. /// <param name="coordinate"></param>
  615. public HiwinRobotSetBoatStation2Handler(HiwinRobot device, ModuleName module, string station, int coordinateT, int coordinateR,int timeout=300)
  616. : base(device, "SPC2", $"{station},{coordinateT},{coordinateR}")
  617. {
  618. AckTimeout = TimeSpan.FromSeconds(timeout);
  619. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  620. }
  621. public override bool HandleMessage(MessageBase msg, out bool handled)
  622. {
  623. var result = msg as HiwinRobotMessage;
  624. if (result.IsError)
  625. {
  626. Device.NoteError(result.Data);
  627. }
  628. else
  629. {
  630. Device.NoteError(null);
  631. }
  632. ResponseMessage = msg;
  633. handled = true;
  634. //Device.NoteActionCompleted();
  635. return true;
  636. }
  637. }
  638. /// <summary>
  639. /// 机器晶元扫描坐标,例如:SVON,SOOF,MOVA,MOVR
  640. /// </summary>
  641. public class HiWinScanCoordinateHandler : HiwinRobotHandler
  642. {
  643. //
  644. public HiWinScanCoordinateHandler(HiwinRobot device, ModuleName module, string station, int coordinateT, int coordinateR, int coordinateZ,int timeout=300)
  645. : base(device, "SPSC", $"{station},{coordinateT},{coordinateR},{coordinateZ}")
  646. {
  647. AckTimeout = TimeSpan.FromSeconds(timeout);
  648. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  649. }
  650. public override bool HandleMessage(MessageBase msg, out bool handled)
  651. {
  652. var result = msg as HiwinRobotMessage;
  653. if (result.IsError)
  654. {
  655. Device.NoteError(result.Data);
  656. }
  657. else
  658. {
  659. Device.NoteError(null);
  660. }
  661. ResponseMessage = msg;
  662. handled = true;
  663. //Device.NoteActionCompleted();
  664. return true;
  665. }
  666. }
  667. public class HiwinRobotQueryWaferPresentHandler : HiwinRobotHandler
  668. {
  669. //INPUT A,1
  670. //0 = 有片
  671. //1 = 没片
  672. public HiwinRobotQueryWaferPresentHandler(HiwinRobot device)
  673. : base(device, "INPUT A,1")
  674. {
  675. }
  676. public override bool HandleMessage(MessageBase msg, out bool handled)
  677. {
  678. var result = msg as HiwinRobotMessage;
  679. if (result.IsError)
  680. {
  681. Device.NoteError(result.Data);
  682. }
  683. else
  684. {
  685. Device.NoteError(null);
  686. if (result.Data == "0")
  687. Device.IsWaferPresenceOnBlade1 = true;
  688. if (result.Data == "1")
  689. Device.IsWaferPresenceOnBlade1 = false;
  690. }
  691. ResponseMessage = msg;
  692. handled = true;
  693. //Device.NoteActionCompleted();
  694. return true;
  695. }
  696. }
  697. public class HiwinRobotGetMapResultHandler : HiwinRobotHandler
  698. {
  699. //RSR
  700. //0100001000100000000000000 2,7,11有片
  701. //0122301000100000000000000 3,4斜放;5叠片
  702. public HiwinRobotGetMapResultHandler(HiwinRobot device)
  703. : base(device, "PSR")
  704. {
  705. }
  706. public override bool HandleMessage(MessageBase msg, out bool handled)
  707. {
  708. var result = msg as HiwinRobotMessage;
  709. if (result.IsError)
  710. {
  711. Device.NoteError(result.Data);
  712. }
  713. else
  714. {
  715. Device.NoteError(null);
  716. }
  717. ResponseMessage = msg;
  718. handled = true;
  719. //Device.NoteActionCompleted();
  720. return true;
  721. }
  722. }
  723. /// <summary>
  724. /// 机器晶元扫描动作,例如:MAP,a
  725. /// </summary>
  726. public class HiWinWaferScanActionHandler : HiwinRobotHandler
  727. {
  728. //
  729. public HiWinWaferScanActionHandler(HiwinRobot device, string station,int timeout=300)
  730. : base(device, "MAP", $"{station}")
  731. {
  732. AckTimeout = TimeSpan.FromSeconds(timeout);
  733. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  734. }
  735. public override bool HandleMessage(MessageBase msg, out bool handled)
  736. {
  737. var result = msg as HiwinRobotMessage;
  738. if (result.IsError)
  739. {
  740. Device.NoteError(result.Data);
  741. }
  742. else
  743. {
  744. Device.NoteError(null);
  745. Device.MapResult = result.Data;
  746. }
  747. ResponseMessage = msg;
  748. handled = true;
  749. //Device.NoteActionCompleted();
  750. return true;
  751. }
  752. }
  753. /// <summary>
  754. /// 机器晶元扫描移动,例如:SVON,SOOF,MOVA,MOVR
  755. /// </summary>
  756. public class HiWinScanMoveHandler : HiwinRobotHandler
  757. {
  758. //
  759. public HiWinScanMoveHandler(HiwinRobot device, ModuleName module, string station,int timeout=300)
  760. : base(device, "MAPST", $"{station}")
  761. {
  762. AckTimeout = TimeSpan.FromSeconds(timeout);
  763. CompleteTimeout = TimeSpan.FromSeconds(timeout);
  764. }
  765. public override bool HandleMessage(MessageBase msg, out bool handled)
  766. {
  767. var result = msg as HiwinRobotMessage;
  768. if (result.IsError)
  769. {
  770. Device.NoteError(result.Data);
  771. }
  772. else
  773. {
  774. Device.NoteError(null);
  775. }
  776. ResponseMessage = msg;
  777. handled = true;
  778. //Device.NoteActionCompleted();
  779. return true;
  780. }
  781. }
  782. }