RobotBase.cs 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.Fsm;
  5. using Aitex.Core.RT.OperationCenter;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Sorter.Common;
  8. using MECF.Framework.Common.Equipment;
  9. using MECF.Framework.Common.SubstrateTrackings;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Text.RegularExpressions;
  15. using System.Threading.Tasks;
  16. using MECF.Framework.Common.CommonData;
  17. using MECF.Framework.Common.Event;
  18. using Aitex.Core.RT.Log;
  19. using Aitex.Core.Common;
  20. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase
  21. {
  22. public abstract class RobotBaseDevice : Entity, IDevice, IRobot, IEntity
  23. {
  24. public event Action<ModuleName, string> OnSlotMapRead;
  25. public virtual string SlotMap { get; set; }
  26. public event Action<bool> ActionDone;
  27. public event Action<string, AlarmEventItem> OnDeviceAlarmStateChanged;
  28. public bool HasAlarm { get; }
  29. private bool _isBusy;
  30. public bool IsBusy
  31. {
  32. get { return _isBusy; }
  33. set
  34. {
  35. if (_isBusy != value)
  36. LOG.Write($"Set {RobotModuleName} IsBusy flag to {value}");
  37. _isBusy = value;
  38. }
  39. }
  40. public AlarmEventItem RobotHasError { get; set; }
  41. public bool IsCarrierMove { get; set; }
  42. public bool IsWaferRobot { get; set; }
  43. public string ErrorCode { get; set; } = "";
  44. public virtual bool IsReady()
  45. {
  46. return RobotState == RobotStateEnum.Idle && !IsBusy;
  47. }
  48. public virtual bool IsReady(out string reason)
  49. {
  50. reason = "";
  51. return RobotState == RobotStateEnum.Idle && !IsBusy;
  52. }
  53. public object[] CurrentParamter { get; private set; }
  54. public bool IsPause { get; set; }
  55. public bool IsOnline { get; set; }
  56. public ModuleName BladeTarget { get; set; }
  57. public ModuleName Blade1Target { get; set; }
  58. public ModuleName Blade2Target { get; set; }
  59. public BladePostureEnum Blade1Posture { get; set; } = BladePostureEnum.Degree0;
  60. public BladePostureEnum Blade1ActionPosture { get; set; }
  61. public virtual bool IsWaferPresenceOnBlade1 { get; set; }
  62. public virtual bool IsWaferPresenceOnBlade2 { get; set; }
  63. public virtual bool IsWaferPresenceOnBlade3 { get; set; }
  64. public virtual bool IsWaferPresenceOnBlade4 { get; set; }
  65. public virtual bool IsWaferPresenceOnBlade5 { get; set; }
  66. public bool IsIdle
  67. {
  68. get
  69. {
  70. return fsm.State == (int)RobotStateEnum.Idle && fsm.CheckExecuted() && !IsBusy;
  71. }
  72. }
  73. public bool IsError
  74. {
  75. get
  76. {
  77. return fsm.State == (int)RobotStateEnum.Error || fsm.State == (int)RobotStateEnum.Stopped;
  78. }
  79. }
  80. public bool IsInit
  81. {
  82. get
  83. {
  84. return fsm.State == (int)RobotStateEnum.Init;
  85. }
  86. }
  87. public virtual bool Blade1Enable
  88. {
  89. get
  90. {
  91. if (SC.ContainsItem($"{ScRoot}.{Name}.Blade1Enable"))
  92. {
  93. return SC.GetValue<bool>($"{ScRoot}.{Name}.Blade1Enable");
  94. }
  95. return SC.GetValue<bool>($"Robot.Blade1Enable");
  96. }
  97. set
  98. {
  99. if (SC.ContainsItem($"{ScRoot}.{Name}.Blade1Enable"))
  100. {
  101. SC.SetItemValue($"{ScRoot}.{Name}.Blade1Enable", value);
  102. }
  103. else if (SC.ContainsItem($"Robot.Blade1Enable"))
  104. {
  105. SC.SetItemValue($"Robot.Blade1Enable", value);
  106. }
  107. }
  108. }
  109. public virtual bool Blade2Enable
  110. {
  111. get
  112. {
  113. if (SC.ContainsItem($"{ScRoot}.{Name}.Blade2Enable"))
  114. {
  115. return SC.GetValue<bool>($"{ScRoot}.{Name}.Blade2Enable");
  116. }
  117. return SC.GetValue<bool>($"Robot.Blade2Enable");
  118. }
  119. set
  120. {
  121. if (SC.ContainsItem($"{ScRoot}.{Name}.Blade2Enable"))
  122. {
  123. SC.SetItemValue($"{ScRoot}.{Name}.Blade2Enable", value);
  124. }
  125. else if (SC.ContainsItem($"Robot.Blade2Enable"))
  126. {
  127. SC.SetItemValue($"Robot.Blade2Enable", value);
  128. }
  129. }
  130. }
  131. public int Blade2Slots
  132. {
  133. get
  134. {
  135. if (SC.ContainsItem($"{ScRoot}.{Name}.Blade2Slots"))
  136. {
  137. return Math.Max(SC.GetValue<int>($"{ScRoot}.{Name}.Blade2Slots"), 1);
  138. }
  139. if (SC.ContainsItem($"Robot.Blade2Slots"))
  140. {
  141. return Math.Max(SC.GetValue<int>($"Robot.Blade2Slots"), 1);
  142. }
  143. return 1;
  144. }
  145. }
  146. public WaferSize Size
  147. {
  148. get; set;
  149. } = WaferSize.WS12;
  150. public virtual WaferSize GetCurrentWaferSize()
  151. {
  152. return Size;
  153. }
  154. public virtual LinkedList<string> CommandMessages
  155. {
  156. get; set;
  157. } = new LinkedList<string>();
  158. private List<string> _commandMsgs
  159. {
  160. get
  161. {
  162. List<string> ret = new List<string>();
  163. foreach (var msg in CommandMessages)
  164. {
  165. ret.Add(msg);
  166. }
  167. return ret;
  168. }
  169. }
  170. public RobotMoveInfo MoveInfo { get; set; }
  171. public RobotArmEnum CmdRobotArm { get; set; }
  172. public ModuleName CmdTarget { get; set; }
  173. public int CmdTargetSlot { get; set; }
  174. public int SpeedAxis1 { set; get; }
  175. public int SpeedAxis2 { set; get; }
  176. public int SpeedAxis3 { set; get; }
  177. public int SpeedAxis4 { set; get; }
  178. public int SpeedAxis5 { set; get; }
  179. public int SpeedAxis6 { set; get; }
  180. public int Speed { set; get; }
  181. public float PositionAxis1 { get; set; }
  182. public float PositionAxis2 { get; set; }
  183. public float PositionAxis3 { get; set; }
  184. public float PositionAxis4 { get; set; }
  185. public float PositionAxis5 { get; set; }
  186. public float PositionAxis6 { get; set; }
  187. public string[] ReadMappingUpData { get; protected set; }
  188. public string[] ReadMappingDownData { get; protected set; }
  189. public virtual int RobotCommandTimeout
  190. {
  191. get
  192. {
  193. if (SC.ContainsItem($"Robot.{RobotModuleName}.TimeLimitRobotCommand"))
  194. return SC.GetValue<int>($"Robot.{RobotModuleName}.TimeLimitRobotCommand");
  195. return 90;
  196. }
  197. }
  198. public enum RobotMsg
  199. {
  200. Reset,
  201. Clear,
  202. ResetToReady,
  203. Stop,
  204. StartInit,
  205. InitComplete,
  206. ERROR,
  207. ActionDone = 7,
  208. Abort,
  209. StartHome,
  210. HomeComplete,
  211. StartMaintenance,
  212. CompleteMaintenance,
  213. ReadData,
  214. ReadDataComplete,
  215. SetParameters,
  216. SetParametersComplete,
  217. Move,
  218. MoveComplete,
  219. PickWafer,
  220. PickComplete,
  221. PlaceWafer,
  222. PlaceComplete,
  223. SwapWafer,
  224. SwapComplete,
  225. MapWafer,
  226. MapComplete,
  227. GoToPosition,
  228. ArrivedPosition,
  229. Grip,
  230. GripComplete,
  231. UnGrip,
  232. UnGripComplete,
  233. ExtendForPlace,
  234. ExtendForPick,
  235. ExtendComplete,
  236. RetractFromPlace,
  237. RetractFromPick,
  238. RetractComplete,
  239. TransferWafer,
  240. TransferComplete,
  241. PickCassette,
  242. PickCassetteComplete,
  243. PlaceCassette,
  244. PlaceCassetteComplete,
  245. ExecuteCommand,
  246. }
  247. protected RobotBaseDevice(string module, string name, string scRoot = "Robot")
  248. : base()
  249. {
  250. Module = module;
  251. Name = name;
  252. ScRoot = scRoot;
  253. RobotModuleName = (ModuleName)Enum.Parse(typeof(ModuleName), Name);
  254. InitializeRobot();
  255. }
  256. protected override bool Init()
  257. {
  258. return base.Init();
  259. }
  260. public virtual void InitializeRobot()
  261. {
  262. BuildTransitionTable();
  263. SubscribeDataVariable();
  264. SubscribeOperation();
  265. SubscribeDeviceOperation();
  266. MoveInfo = new RobotMoveInfo()
  267. {
  268. Action = RobotAction.Moving,
  269. ArmTarget = RobotArm.Both,
  270. BladeTarget = "ArmA.System",
  271. };
  272. SubscribeWaferLocation();
  273. Running = true;
  274. }
  275. protected virtual void SubscribeWaferLocation()
  276. {
  277. WaferManager.Instance.SubscribeLocation(Name, 2);
  278. }
  279. protected virtual void SubscribeOperation()
  280. {
  281. OP.Subscribe(String.Format("{0}.{1}", Name, "MapWafer"), (out string reason, int time, object[] param) =>
  282. {
  283. ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), param[0].ToString(), true);
  284. bool ret = WaferMapping(chamber);
  285. if (ret)
  286. {
  287. reason = string.Format("{0} {1}", Name, "Map wafer succesfully");
  288. return true;
  289. }
  290. reason = $"{Name} map wafer failed";
  291. return false;
  292. });
  293. OP.Subscribe(String.Format("{0}.{1}", Name, "ExecuteCommand"), (out string reason, int time, object[] param) =>
  294. {
  295. bool ret = ExecuteCommand(param);
  296. if (ret)
  297. {
  298. reason = string.Format("{0} {1}", Name, "Execute command succesfully");
  299. return true;
  300. }
  301. reason = $"{Name} execute failed";
  302. return false;
  303. });
  304. OP.Subscribe(String.Format("{0}.{1}", Name, "RobotFlippe"), (out string reason, int time, object[] param) =>
  305. {
  306. bool isto0 = Convert.ToBoolean(param[0]);
  307. bool ret = RobotFlippe(isto0);
  308. if (ret)
  309. {
  310. reason = string.Format("{0} {1}", Name, $"Flippe to {(isto0 ? "0 degree" : "180 Degree")} command succesfully");
  311. return true;
  312. }
  313. reason = $"{Name} Flippe failed";
  314. return false;
  315. });
  316. OP.Subscribe(String.Format("{0}.{1}", Name, "SetWaferSize"), (out string reason, int time, object[] param) =>
  317. {
  318. RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), param[0].ToString());
  319. WaferSize size = (WaferSize)Enum.Parse(typeof(WaferSize), param[1].ToString());
  320. bool ret = SetWaferSize(arm, size);
  321. if (ret)
  322. {
  323. reason = string.Format("{0} {1}", Name, "Set Wafer size");
  324. return true;
  325. }
  326. reason = $"{Name} not ready";
  327. return false;
  328. });
  329. OP.Subscribe(String.Format("{0}.{1}", Name, "PickCassette"), (out string reason, int time, object[] param) =>
  330. {
  331. bool ret = PickCassette(RobotArmEnum.Blade1, param[0].ToString(), 0);
  332. if (ret)
  333. {
  334. reason = string.Format("{0} {1}", Name, "Pick cassette");
  335. return true;
  336. }
  337. reason = $"{Name} not ready";
  338. return false;
  339. });
  340. OP.Subscribe(String.Format("{0}.{1}", Name, "PlaceCassette"), (out string reason, int time, object[] param) =>
  341. {
  342. bool ret = PlaceCassette(RobotArmEnum.Blade1, param[0].ToString(), 0);
  343. if (ret)
  344. {
  345. reason = string.Format("{0} {1}", Name, "Pick cassette");
  346. return true;
  347. }
  348. reason = $"{Name} not ready";
  349. return false;
  350. });
  351. OP.Subscribe(String.Format("{0}.{1}", Name, "Init"), (out string reason, int time, object[] param) =>
  352. {
  353. bool ret = Home(param);
  354. if (ret)
  355. {
  356. reason = string.Format("{0} {1}", Name, "Initializing");
  357. return true;
  358. }
  359. reason = "";
  360. return false;
  361. });
  362. OP.Subscribe(String.Format("{0}.{1}", Name, "Abort"), (out string reason, int time, object[] param) =>
  363. {
  364. bool ret = Abort();
  365. if (ret)
  366. {
  367. reason = string.Format("{0} {1}", Name, "Abort");
  368. return true;
  369. }
  370. reason = "";
  371. return false;
  372. });
  373. OP.Subscribe(String.Format("{0}.{1}", Name, "Home"), (out string reason, int time, object[] param) =>
  374. {
  375. bool ret = Home(param);
  376. if (ret)
  377. {
  378. reason = string.Format("{0} {1}", Name, "Homing");
  379. return true;
  380. }
  381. reason = "";
  382. return false;
  383. });
  384. OP.Subscribe(String.Format("{0}.{1}", Name, "RobotHome"), (out string reason, int time, object[] param) =>
  385. {
  386. bool ret = Home(param);
  387. if (ret)
  388. {
  389. reason = string.Format("{0} {1}", Name, "Homing");
  390. return true;
  391. }
  392. reason = "";
  393. return false;
  394. });
  395. OP.Subscribe(String.Format("{0}.{1}", Name, "HomeModule"), (out string reason, int time, object[] param) =>
  396. {
  397. bool ret = HomeModule(param);
  398. if (ret)
  399. {
  400. reason = string.Format("{0} {1}", Name, "ModuleHoming");
  401. return true;
  402. }
  403. reason = "";
  404. return false;
  405. });
  406. OP.Subscribe(String.Format("{0}.{1}", Name, "RobotHomeModule"), (out string reason, int time, object[] param) =>
  407. {
  408. bool ret = HomeModule(param);
  409. if (ret)
  410. {
  411. reason = string.Format("{0} {1}", Name, "ModuleHomingHoming");
  412. return true;
  413. }
  414. reason = "";
  415. return false;
  416. });
  417. OP.Subscribe(String.Format("{0}.{1}", Name, "Reset"), (out string reason, int time, object[] param) =>
  418. {
  419. RobotReset();
  420. reason = "";
  421. return true;
  422. });
  423. OP.Subscribe(String.Format("{0}.{1}", Name, "RobotReset"), (out string reason, int time, object[] param) =>
  424. {
  425. RobotReset();
  426. reason = "";
  427. return true;
  428. });
  429. OP.Subscribe(String.Format("{0}.{1}", Name, "Grip"), (out string reason, int time, object[] param) =>
  430. {
  431. Hand hand = (Hand)Enum.Parse(typeof(Hand), param[0].ToString(), true);
  432. RobotArmEnum arm = (RobotArmEnum)((int)hand);
  433. bool ret = Grip(arm);
  434. if (ret)
  435. {
  436. reason = string.Format("{0} {1}", Name, "Grip");
  437. return true;
  438. }
  439. reason = $"{Name} busy";
  440. return false;
  441. });
  442. OP.Subscribe(String.Format("{0}.{1}", Name, "RobotGrip"), (out string reason, int time, object[] param) =>
  443. {
  444. //Hand hand = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), (string)param[0], );
  445. string strarm = Regex.Replace(param[0].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
  446. RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
  447. bool ret = Grip(arm);
  448. if (ret)
  449. {
  450. reason = string.Format("{0} {1}", Name, "Grip");
  451. return true;
  452. }
  453. reason = $"{Name} busy";
  454. return false;
  455. });
  456. OP.Subscribe(String.Format("{0}.{1}", Name, "Release"), (out string reason, int time, object[] param) =>
  457. {
  458. Hand hand = (Hand)Enum.Parse(typeof(Hand), param[0].ToString(), true);
  459. RobotArmEnum arm = (RobotArmEnum)((int)hand);
  460. bool ret = Release(arm);
  461. if (ret)
  462. {
  463. reason = string.Format("{0} {1}", Name, "Release");
  464. return true;
  465. }
  466. reason = $"{Name} busy";
  467. return false;
  468. });
  469. OP.Subscribe(String.Format("{0}.{1}", Name, "RobotRelease"), (out string reason, int time, object[] param) =>
  470. {
  471. //Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
  472. string strarm = Regex.Replace(param[0].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
  473. RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
  474. bool ret = Release(arm);
  475. if (ret)
  476. {
  477. reason = string.Format("{0} {1}", Name, "Release");
  478. return true;
  479. }
  480. reason = $"{Name} busy";
  481. return false;
  482. });
  483. OP.Subscribe(String.Format("{0}.{1}", Name, "Stop"), (out string reason, int time, object[] param) =>
  484. {
  485. bool ret = Stop();
  486. if (ret)
  487. {
  488. reason = string.Format("{0} {1}", Name, "Stopping");
  489. return true;
  490. }
  491. reason = $"{Name} busy";
  492. return false;
  493. });
  494. OP.Subscribe(String.Format("{0}.{1}", Name, "RobotStop"), (out string reason, int time, object[] param) =>
  495. {
  496. bool ret = Stop();
  497. if (ret)
  498. {
  499. reason = string.Format("{0} {1}", Name, "Stopping");
  500. return true;
  501. }
  502. reason = $"{Name} busy";
  503. return false;
  504. });
  505. OP.Subscribe(String.Format("{0}.{1}", Name, "Pick"), (out string reason, int time, object[] param) =>
  506. {
  507. //ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
  508. string station = (string)param[0];
  509. int slot = int.Parse(param[1].ToString());
  510. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  511. RobotArmEnum arm = (RobotArmEnum)((int)hand);
  512. bool ret = Pick(arm, station, slot);
  513. if (ret)
  514. {
  515. reason = string.Format("{0} {1}", Name, "Pick wafer");
  516. return true;
  517. }
  518. reason = $"{Name} busy";
  519. return false;
  520. });
  521. OP.Subscribe(String.Format("{0}.{1}", Name, "RobotPick"), (out string reason, int time, object[] param) =>
  522. {
  523. string station = (string)param[0];
  524. int slot = int.Parse((string)param[1]);
  525. string strarm = Regex.Replace(param[2].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
  526. RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
  527. bool ret = Pick(arm, station, slot);
  528. if (ret)
  529. {
  530. reason = string.Format("{0} {1}", Name, "Pick wafer");
  531. return true;
  532. }
  533. reason = $"{Name} busy";
  534. return false;
  535. });
  536. OP.Subscribe(String.Format("{0}.{1}", Name, "Place"), (out string reason, int time, object[] param) =>
  537. {
  538. string station = (string)param[0];
  539. int slot = int.Parse(param[1].ToString());
  540. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  541. RobotArmEnum arm = (RobotArmEnum)((int)hand);
  542. bool ret = Place(arm, station, slot);
  543. if (ret)
  544. {
  545. reason = string.Format("{0} {1}", Name, "Place wafer");
  546. return true;
  547. }
  548. reason = $"{Name} busy";
  549. return false;
  550. });
  551. OP.Subscribe(String.Format("{0}.{1}", Name, "RobotPlace"), (out string reason, int time, object[] param) =>
  552. {
  553. string station = (string)param[0];
  554. int slot = int.Parse((string)param[1]);
  555. string strarm = Regex.Replace(param[2].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
  556. RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
  557. bool ret = Place(arm, station, slot);
  558. if (ret)
  559. {
  560. reason = string.Format("{0} {1}", Name, "Place wafer");
  561. return true;
  562. }
  563. reason = $"{Name} busy";
  564. return false;
  565. });
  566. OP.Subscribe(String.Format("{0}.{1}", Name, "Exchange"), (out string reason, int time, object[] param) =>
  567. {
  568. string station = (string)param[0];
  569. int slot = int.Parse((string)param[1]);
  570. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  571. RobotArmEnum arm = (RobotArmEnum)((int)hand);
  572. bool ret = Swap(arm, station, slot);//, slot, hand, out reason);
  573. if (ret)
  574. {
  575. reason = string.Format("{0} {1}", Name, "Swap wafer");
  576. return true;
  577. }
  578. reason = $"{Name} busy";
  579. return false;
  580. });
  581. OP.Subscribe(String.Format("{0}.{1}", Name, "RobotExchange"), (out string reason, int time, object[] param) =>
  582. {
  583. string station = (string)param[0];
  584. int slot = int.Parse((string)param[1]);
  585. string strarm = Regex.Replace(param[2].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
  586. RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
  587. bool ret = Swap(arm, station, slot);//, slot, hand, out reason);
  588. if (ret)
  589. {
  590. reason = string.Format("{0} {1}", Name, "Swap wafer");
  591. return true;
  592. }
  593. reason = $"{Name} busy";
  594. return false;
  595. });
  596. OP.Subscribe(String.Format("{0}.{1}", Name, "Goto"), (out string reason, int time, object[] param) =>
  597. {
  598. bool ret = GoTo(param);
  599. if (ret)
  600. {
  601. reason = string.Format("{0}{1}", Name, "Goto");
  602. return true;
  603. }
  604. reason = $"{Name} busy";
  605. return false;
  606. });
  607. OP.Subscribe(String.Format("{0}.{1}", Name, "RobotGoto"), (out string reason, int time, object[] param) =>
  608. {
  609. bool ret = GoTo(param);
  610. if (ret)
  611. {
  612. reason = string.Format("{0}{1}", Name, "Goto");
  613. return true;
  614. }
  615. reason = $"{Name} busy";
  616. return false;
  617. });
  618. OP.Subscribe(String.Format("{0}.{1}", Name, "SetSpeed"), (out string reason, int time, object[] param) =>
  619. {
  620. bool ret = SetSpeed(param);
  621. if (ret)
  622. {
  623. reason = string.Format("{0}{1}", Name, "SetSpeed");
  624. return true;
  625. }
  626. reason = $"{Name} busy";
  627. return false;
  628. });
  629. OP.Subscribe(String.Format("{0}.{1}", Name, "SetParameter"), (out string reason, int time, object[] param) =>
  630. {
  631. bool ret = SetParameter(param);
  632. if (ret)
  633. {
  634. reason = string.Format("{0}{1}", Name, "SetParameter");
  635. return true;
  636. }
  637. reason = $"{Name} busy";
  638. return false;
  639. });
  640. OP.Subscribe(String.Format("{0}.{1}", Name, "ReadParameter"), (out string reason, int time, object[] param) =>
  641. {
  642. bool ret = ReadParameter(param);
  643. if (ret)
  644. {
  645. reason = string.Format("{0}{1}", Name, "ReadData");
  646. return true;
  647. }
  648. reason = $"{Name} busy";
  649. return false;
  650. });
  651. OP.Subscribe(String.Format("{0}.{1}", Name, "RobotMove"), (out string reason, int time, object[] param) =>
  652. {
  653. bool ret = Move(param);
  654. if (ret)
  655. {
  656. reason = string.Format("{0}{1}", Name, "MovePostion");
  657. return true;
  658. }
  659. reason = $"{Name} busy";
  660. return false;
  661. });
  662. OP.Subscribe(String.Format("{0}.{1}", Name, "SetRobotParameters"), (out string reason, int time, object[] param) =>
  663. {
  664. bool ret = SetRobotParameters(param);
  665. if (ret)
  666. {
  667. reason = string.Format("{0}{1}", Name, param[0]);
  668. return true;
  669. }
  670. reason = $"{Name} busy";
  671. return false;
  672. });
  673. OP.Subscribe(String.Format("{0}.{1}", Name, "ReadRobotParameters"), (out string reason, int time, object[] param) =>
  674. {
  675. bool ret = ReadParameter(param);
  676. if (ret)
  677. {
  678. reason = string.Format("{0}{1}", Name, "ReadRobotParameters");
  679. return true;
  680. }
  681. reason = $"{Name} busy";
  682. return false;
  683. });
  684. }
  685. protected virtual void SubscribeDeviceOperation()
  686. {
  687. DEVICE.Register(String.Format("{0}.{1}", Name, "Init"), (out string reason, int time, object[] param) =>
  688. {
  689. bool ret = Home(param);
  690. if (ret)
  691. {
  692. reason = string.Format("{0} {1}", Name, "Initializing");
  693. return true;
  694. }
  695. reason = "";
  696. return false;
  697. });
  698. DEVICE.Register(String.Format("{0}.{1}", Name, "Home"), (out string reason, int time, object[] param) =>
  699. {
  700. bool ret = Home(param);
  701. if (ret)
  702. {
  703. reason = string.Format("{0} {1}", Name, "Homing");
  704. return true;
  705. }
  706. reason = "";
  707. return false;
  708. });
  709. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotHome"), (out string reason, int time, object[] param) =>
  710. {
  711. bool ret = Home(param);
  712. if (ret)
  713. {
  714. reason = string.Format("{0} {1}", Name, "Homing");
  715. return true;
  716. }
  717. reason = "";
  718. return false;
  719. });
  720. DEVICE.Register(String.Format("{0}.{1}", Name, "HomeModule"), (out string reason, int time, object[] param) =>
  721. {
  722. bool ret = HomeModule(param);
  723. if (ret)
  724. {
  725. reason = string.Format("{0} {1}", Name, "Homing");
  726. return true;
  727. }
  728. reason = "";
  729. return false;
  730. });
  731. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotHomeModule"), (out string reason, int time, object[] param) =>
  732. {
  733. bool ret = HomeModule(param);
  734. if (ret)
  735. {
  736. reason = string.Format("{0} {1}", Name, "Homing");
  737. return true;
  738. }
  739. reason = "";
  740. return false;
  741. });
  742. DEVICE.Register(String.Format("{0}.{1}", Name, "Reset"), (out string reason, int time, object[] param) =>
  743. {
  744. RobotReset();
  745. reason = "";
  746. return true;
  747. });
  748. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotReset"), (out string reason, int time, object[] param) =>
  749. {
  750. RobotReset();
  751. reason = "";
  752. return true;
  753. });
  754. DEVICE.Register(String.Format("{0}.{1}", Name, "Grip"), (out string reason, int time, object[] param) =>
  755. {
  756. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
  757. RobotArmEnum arm = (RobotArmEnum)((int)hand);
  758. bool ret = Grip(arm);
  759. if (ret)
  760. {
  761. reason = string.Format("{0} {1}", Name, "Grip");
  762. return true;
  763. }
  764. reason = "";
  765. return false;
  766. });
  767. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotGrip"), (out string reason, int time, object[] param) =>
  768. {
  769. //Hand hand = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), (string)param[0], );
  770. string strarm = Regex.Replace(param[0].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
  771. RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
  772. bool ret = Grip(arm);
  773. if (ret)
  774. {
  775. reason = string.Format("{0} {1}", Name, "Grip");
  776. return true;
  777. }
  778. reason = "";
  779. return false;
  780. });
  781. DEVICE.Register(String.Format("{0}.{1}", Name, "Release"), (out string reason, int time, object[] param) =>
  782. {
  783. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
  784. RobotArmEnum arm = (RobotArmEnum)((int)hand);
  785. bool ret = Release(arm);
  786. if (ret)
  787. {
  788. reason = string.Format("{0} {1}", Name, "Release");
  789. return true;
  790. }
  791. reason = "";
  792. return false;
  793. });
  794. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotRelease"), (out string reason, int time, object[] param) =>
  795. {
  796. //Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[0], true);
  797. string strarm = Regex.Replace(param[0].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
  798. RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
  799. bool ret = Release(arm);
  800. //bool ret = QueryWaferMap(ModuleName.LP1, out reason);
  801. if (ret)
  802. {
  803. reason = string.Format("{0} {1}", Name, "Release");
  804. return true;
  805. }
  806. reason = "";
  807. return false;
  808. });
  809. DEVICE.Register(String.Format("{0}.{1}", Name, "Stop"), (out string reason, int time, object[] param) =>
  810. {
  811. bool ret = Stop();
  812. if (ret)
  813. {
  814. reason = string.Format("{0} {1}", Name, "Stopping");
  815. return true;
  816. }
  817. reason = "";
  818. return false;
  819. });
  820. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotStop"), (out string reason, int time, object[] param) =>
  821. {
  822. bool ret = Stop();
  823. if (ret)
  824. {
  825. reason = string.Format("{0} {1}", Name, "Stopping");
  826. return true;
  827. }
  828. reason = "";
  829. return false;
  830. });
  831. DEVICE.Register(String.Format("{0}.{1}", Name, "Pick"), (out string reason, int time, object[] param) =>
  832. {
  833. //ModuleName chamber = (ModuleName)Enum.Parse(typeof(ModuleName), (string)param[0], true);
  834. string station = (string)param[0];
  835. int slot = int.Parse((string)param[1]);
  836. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  837. RobotArmEnum arm = (RobotArmEnum)((int)hand);
  838. bool ret = Pick(arm, station, slot);
  839. if (ret)
  840. {
  841. reason = string.Format("{0} {1}", Name, "Pick wafer");
  842. return true;
  843. }
  844. reason = "";
  845. return false;
  846. });
  847. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotPick"), (out string reason, int time, object[] param) =>
  848. {
  849. string station = (string)param[0];
  850. int slot = int.Parse((string)param[1]);
  851. string strarm = Regex.Replace(param[2].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
  852. RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
  853. bool ret = Pick(arm, station, slot);
  854. if (ret)
  855. {
  856. reason = string.Format("{0} {1}", Name, "Pick wafer");
  857. return true;
  858. }
  859. reason = "";
  860. return false;
  861. });
  862. DEVICE.Register(String.Format("{0}.{1}", Name, "Place"), (out string reason, int time, object[] param) =>
  863. {
  864. string station = (string)param[0];
  865. int slot = int.Parse((string)param[1]);
  866. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  867. RobotArmEnum arm = (RobotArmEnum)((int)hand);
  868. bool ret = Place(arm, station, slot);
  869. if (ret)
  870. {
  871. reason = string.Format("{0} {1}", Name, "Place wafer");
  872. return true;
  873. }
  874. reason = $"{Name} busy";
  875. return false;
  876. });
  877. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotPlace"), (out string reason, int time, object[] param) =>
  878. {
  879. string station = (string)param[0];
  880. int slot = int.Parse((string)param[1]);
  881. string strarm = Regex.Replace(param[2].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
  882. RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
  883. bool ret = Place(arm, station, slot);
  884. if (ret)
  885. {
  886. reason = string.Format("{0} {1}", Name, "Place wafer");
  887. return true;
  888. }
  889. reason = $"{Name} busy";
  890. return false;
  891. });
  892. DEVICE.Register(String.Format("{0}.{1}", Name, "Exchange"), (out string reason, int time, object[] param) =>
  893. {
  894. string station = (string)param[0];
  895. int slot = int.Parse((string)param[1]);
  896. Hand hand = (Hand)Enum.Parse(typeof(Hand), (string)param[2], true);
  897. RobotArmEnum arm = (RobotArmEnum)((int)hand);
  898. bool ret = Swap(arm, station, slot);//, slot, hand, out reason);
  899. if (ret)
  900. {
  901. reason = string.Format("{0} {1}", Name, "Swap wafer");
  902. return true;
  903. }
  904. reason = "";
  905. return false;
  906. });
  907. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotExchange"), (out string reason, int time, object[] param) =>
  908. {
  909. string station = (string)param[0];
  910. int slot = int.Parse((string)param[1]);
  911. string strarm = Regex.Replace(param[2].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
  912. RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), strarm);
  913. bool ret = Swap(arm, station, slot);//, slot, hand, out reason);
  914. if (ret)
  915. {
  916. reason = string.Format("{0} {1}", Name, "Swap wafer");
  917. return true;
  918. }
  919. reason = "";
  920. return false;
  921. });
  922. DEVICE.Register(String.Format("{0}.{1}", Name, "Goto"), (out string reason, int time, object[] param) =>
  923. {
  924. bool ret = GoTo(param);
  925. if (ret)
  926. {
  927. reason = string.Format("{0}{1}", Name, "Goto");
  928. return true;
  929. }
  930. reason = "";
  931. return false;
  932. });
  933. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotGoto"), (out string reason, int time, object[] param) =>
  934. {
  935. bool ret = GoTo(param);
  936. if (ret)
  937. {
  938. reason = string.Format("{0}{1}", Name, "Goto");
  939. return true;
  940. }
  941. reason = "";
  942. return false;
  943. });
  944. DEVICE.Register(String.Format("{0}.{1}", Name, "HirataRobotGoto"), (out string reason, int time, object[] param) =>
  945. {
  946. RobotArmEnum arm = (RobotArmEnum)Enum.Parse(typeof(RobotArmEnum), param[0].ToString());
  947. string station = param[1].ToString();
  948. int slot = Convert.ToInt32(param[2]);
  949. RobotPostionEnum pos = (RobotPostionEnum)Enum.Parse(typeof(RobotPostionEnum), param[3].ToString());
  950. bool ret = GoTo(arm, station, slot, pos);
  951. if (ret)
  952. {
  953. reason = string.Format("{0}{1}", Name, "HirataRobotGoto");
  954. return true;
  955. }
  956. reason = "";
  957. return false;
  958. });
  959. DEVICE.Register(String.Format("{0}.{1}", Name, "SetSpeed"), (out string reason, int time, object[] param) =>
  960. {
  961. bool ret = SetSpeed(param);
  962. if (ret)
  963. {
  964. reason = string.Format("{0}{1}", Name, "SetSpeed");
  965. return true;
  966. }
  967. reason = "";
  968. return false;
  969. });
  970. DEVICE.Register(String.Format("{0}.{1}", Name, "SetParameter"), (out string reason, int time, object[] param) =>
  971. {
  972. bool ret = SetParameter(param);
  973. if (ret)
  974. {
  975. reason = string.Format("{0}{1}", Name, "SetParameter");
  976. return true;
  977. }
  978. reason = "";
  979. return false;
  980. });
  981. DEVICE.Register(String.Format("{0}.{1}", Name, "ReadParameter"), (out string reason, int time, object[] param) =>
  982. {
  983. bool ret = ReadParameter(param);
  984. if (ret)
  985. {
  986. reason = string.Format("{0}{1}", Name, "ReadData");
  987. return true;
  988. }
  989. reason = "";
  990. return false;
  991. });
  992. DEVICE.Register(String.Format("{0}.{1}", Name, "RobotMove"), (out string reason, int time, object[] param) =>
  993. {
  994. bool ret = Move(param);
  995. if (ret)
  996. {
  997. reason = string.Format("{0}{1}", Name, "MovePostion");
  998. return true;
  999. }
  1000. reason = "";
  1001. return false;
  1002. });
  1003. }
  1004. public virtual bool Move(object[] param)
  1005. {
  1006. return CheckToPostMessage((int)RobotMsg.Move, param); ;
  1007. }
  1008. public virtual bool ReadParameter(object[] param)
  1009. {
  1010. return CheckToPostMessage((int)RobotMsg.ReadData, param);
  1011. }
  1012. public virtual bool SetParameter(object[] arg2)
  1013. {
  1014. return CheckToPostMessage((int)RobotMsg.SetParameters, arg2);
  1015. }
  1016. public virtual bool SetWaferSize(RobotArmEnum arm, WaferSize size)
  1017. {
  1018. return CheckToPostMessage((int)RobotMsg.SetParameters, new object[] { "WaferSize", arm, size });
  1019. }
  1020. public bool InvokeSetSpeed(string arg1, object[] arg2)
  1021. {
  1022. var speed = 3;
  1023. //string reason;
  1024. if (int.TryParse((string)arg2[0], out speed))
  1025. {
  1026. if (!(speed <= 3 || speed >= 1))
  1027. EV.PostWarningLog(ModuleName.Robot.ToString(), "Error Parameter,speed should be range in 1, 3");
  1028. return SetSpeed(new object[] { speed });
  1029. }
  1030. EV.PostWarningLog(ModuleName.Robot.ToString(), $"invalid parameters. {arg2[0]}");
  1031. return false;
  1032. }
  1033. public virtual bool SetSpeed(object[] arg2)
  1034. {
  1035. if (IsBusy) return false;
  1036. List<object> paras = new List<object>() { "TransferSpeedLevel" };
  1037. foreach (var value in arg2) paras.Add(value);
  1038. return CheckToPostMessage((int)RobotMsg.SetParameters, paras.ToArray());
  1039. }
  1040. public virtual bool SetRobotParameters(object[] arg2)
  1041. {
  1042. if (IsBusy) return false;
  1043. return CheckToPostMessage((int)RobotMsg.SetParameters, arg2.ToArray());
  1044. }
  1045. public virtual bool SetSpeed(string speedtype, int value)
  1046. {
  1047. return CheckToPostMessage((int)RobotMsg.SetParameters, new object[] { speedtype, value });
  1048. }
  1049. public virtual bool InvokeRobotGoTo(string arg1, object[] arg2)
  1050. {
  1051. return CheckToPostMessage((int)RobotMsg.GoToPosition, arg2);
  1052. }
  1053. private void SubscribeDataVariable()
  1054. {
  1055. DATA.Subscribe($"{Name}.State", () => RobotState.ToString());
  1056. DATA.Subscribe($"{Name}.RobotState", () => RobotState.ToString());
  1057. DATA.Subscribe($"{Name}.Axis1Postion", () => PositionAxis1.ToString());
  1058. DATA.Subscribe($"{Name}.Axis2Postion", () => PositionAxis2.ToString());
  1059. DATA.Subscribe($"{Name}.Axis3Postion", () => PositionAxis3.ToString());
  1060. DATA.Subscribe($"{Name}.Axis4Postion", () => PositionAxis4.ToString());
  1061. DATA.Subscribe($"{Name}.Axis5Postion", () => PositionAxis5.ToString());
  1062. DATA.Subscribe($"{Name}.RobotErrorCode", () => ErrorCode ?? ErrorCode.ToString());
  1063. DATA.Subscribe($"{Name}.IsPause", () => IsPause);
  1064. DATA.Subscribe($"{Name}.RobotMoveInfo", () => MoveInfo);
  1065. DATA.Subscribe($"{Name}.RobotBladeTraget", () => BladeTarget);
  1066. DATA.Subscribe($"{Name}.RobotBlade1Traget", () => Blade1Target);
  1067. DATA.Subscribe($"{Name}.RobotBlade2Traget", () => Blade2Target);
  1068. DATA.Subscribe($"{Name}.WaferSize", () => GetCurrentWaferSize().ToString());
  1069. DATA.Subscribe($"{Name}.Blade1WaferSize", () => GetBladeWaferSize(0).ToString());
  1070. DATA.Subscribe($"{Name}.Blade2WaferSize", () => GetBladeWaferSize(1).ToString());
  1071. DATA.Subscribe($"{Name}.CommandMessages", () => _commandMsgs);
  1072. }
  1073. private WaferSize GetBladeWaferSize(int slotIndex)
  1074. {
  1075. if (WaferManager.Instance.CheckHasWafer(RobotModuleName, slotIndex))
  1076. return WaferManager.Instance.GetWaferSize(RobotModuleName, slotIndex);
  1077. return Size;
  1078. }
  1079. private int _SmInterval
  1080. {
  1081. get
  1082. {
  1083. if (SC.ContainsItem($"Robot.{RobotModuleName}.SMInterval"))
  1084. return SC.GetValue<int>($"Robot.{RobotModuleName}.SMInterval");
  1085. return 50;
  1086. }
  1087. }
  1088. private void BuildTransitionTable()
  1089. {
  1090. fsm = new StateMachine<RobotBaseDevice>(Name + ".StateMachine", (int)RobotStateEnum.Idle, _SmInterval);
  1091. //Init sequence
  1092. AnyStateTransition(RobotMsg.ERROR, fError, RobotStateEnum.Error);
  1093. AnyStateTransition(RobotMsg.Reset, fReset, RobotStateEnum.Resetting);
  1094. AnyStateTransition(RobotMsg.Stop, fStop, RobotStateEnum.Stopped);
  1095. AnyStateTransition(RobotMsg.Abort, fAbort, RobotStateEnum.Init);
  1096. AnyStateTransition(RobotMsg.StartMaintenance, fStartMaitenance, RobotStateEnum.Maintenance);
  1097. Transition(RobotStateEnum.Maintenance, RobotMsg.CompleteMaintenance, fCompleteMaintenance, RobotStateEnum.Init);
  1098. Transition(RobotStateEnum.Maintenance, FSM_MSG.TIMER, fMonitorMaintenance, RobotStateEnum.Init);
  1099. Transition(RobotStateEnum.Resetting, RobotMsg.ActionDone, fResetComplete, RobotStateEnum.Idle);
  1100. Transition(RobotStateEnum.Resetting, FSM_MSG.TIMER, fMonitorReset, RobotStateEnum.Idle);
  1101. Transition(RobotStateEnum.Stopped, FSM_MSG.TIMER, fMonitorStop, RobotStateEnum.Idle);
  1102. Transition(RobotStateEnum.Init, RobotMsg.StartInit, fStartInit, RobotStateEnum.Initializing);
  1103. Transition(RobotStateEnum.Idle, RobotMsg.StartInit, fStartInit, RobotStateEnum.Initializing);
  1104. Transition(RobotStateEnum.Error, RobotMsg.StartInit, fStartInit, RobotStateEnum.Initializing);
  1105. Transition(RobotStateEnum.Error, RobotMsg.InitComplete, fInitComplete, RobotStateEnum.Idle);
  1106. Transition(RobotStateEnum.Init, RobotMsg.InitComplete, fInitComplete, RobotStateEnum.Idle);
  1107. Transition(RobotStateEnum.Initializing, RobotMsg.InitComplete, fInitComplete, RobotStateEnum.Idle);
  1108. Transition(RobotStateEnum.Initializing, RobotMsg.ActionDone, fInitComplete, RobotStateEnum.Idle);
  1109. Transition(RobotStateEnum.Initializing, FSM_MSG.TIMER, fMonitorInit, RobotStateEnum.Idle);
  1110. Transition(RobotStateEnum.Init, RobotMsg.StartHome, fStartHome, RobotStateEnum.Homing);
  1111. Transition(RobotStateEnum.Idle, RobotMsg.StartHome, fStartHome, RobotStateEnum.Homing);
  1112. Transition(RobotStateEnum.Error, RobotMsg.StartHome, fStartHome, RobotStateEnum.Homing);
  1113. Transition(RobotStateEnum.Init, RobotMsg.HomeComplete, fHomeComplete, RobotStateEnum.Idle);
  1114. Transition(RobotStateEnum.Error, RobotMsg.HomeComplete, fHomeComplete, RobotStateEnum.Idle);
  1115. Transition(RobotStateEnum.Homing, RobotMsg.HomeComplete, fHomeComplete, RobotStateEnum.Idle);
  1116. Transition(RobotStateEnum.Homing, RobotMsg.ActionDone, fHomeComplete, RobotStateEnum.Idle);
  1117. Transition(RobotStateEnum.Homing, FSM_MSG.TIMER, fMonitorHome, RobotStateEnum.Idle);
  1118. Transition(RobotStateEnum.Error, RobotMsg.Clear, fClear, RobotStateEnum.Init);
  1119. Transition(RobotStateEnum.Error, RobotMsg.ResetToReady, fResetToReady, RobotStateEnum.Idle);
  1120. Transition(RobotStateEnum.Idle, RobotMsg.SetParameters, fStartSetParameters, RobotStateEnum.SettingServos);
  1121. Transition(RobotStateEnum.SettingServos, RobotMsg.SetParameters, fStartSetParameters, RobotStateEnum.SettingServos);
  1122. Transition(RobotStateEnum.SettingServos, RobotMsg.SetParametersComplete, fSetComplete, RobotStateEnum.Idle);
  1123. Transition(RobotStateEnum.SettingServos, RobotMsg.ActionDone, fSetComplete, RobotStateEnum.Idle);
  1124. Transition(RobotStateEnum.SettingServos, FSM_MSG.TIMER, fMonitorSetParamter, RobotStateEnum.Idle);
  1125. Transition(RobotStateEnum.Idle, RobotMsg.ReadData, fStartReadData, RobotStateEnum.ReadingData);
  1126. Transition(RobotStateEnum.ReadingData, RobotMsg.ActionDone, null, RobotStateEnum.Idle);
  1127. Transition(RobotStateEnum.ReadingData, RobotMsg.ReadDataComplete, null, RobotStateEnum.Idle);
  1128. Transition(RobotStateEnum.ReadingData, FSM_MSG.TIMER, fMonitorReadData, RobotStateEnum.Idle);
  1129. Transition(RobotStateEnum.Idle, RobotMsg.PickWafer, fStartPickWafer, RobotStateEnum.Picking);
  1130. Transition(RobotStateEnum.Picking, RobotMsg.PickComplete, fPickComplete, RobotStateEnum.Idle);
  1131. Transition(RobotStateEnum.Picking, RobotMsg.ActionDone, fPickComplete, RobotStateEnum.Idle);
  1132. Transition(RobotStateEnum.Picking, FSM_MSG.TIMER, fMonitorPick, RobotStateEnum.Idle);
  1133. Transition(RobotStateEnum.Idle, RobotMsg.PlaceWafer, fStartPlaceWafer, RobotStateEnum.Placing);
  1134. Transition(RobotStateEnum.Placing, RobotMsg.PlaceComplete, fPlaceComplete, RobotStateEnum.Idle);
  1135. Transition(RobotStateEnum.Placing, RobotMsg.ActionDone, fPlaceComplete, RobotStateEnum.Idle);
  1136. Transition(RobotStateEnum.Placing, FSM_MSG.TIMER, fMonitorPlace, RobotStateEnum.Idle);
  1137. Transition(RobotStateEnum.Idle, RobotMsg.SwapWafer, fStartSwapWafer, RobotStateEnum.Swapping);
  1138. Transition(RobotStateEnum.Swapping, RobotMsg.SwapComplete, fSwapComplete, RobotStateEnum.Idle);
  1139. Transition(RobotStateEnum.Swapping, RobotMsg.ActionDone, fSwapComplete, RobotStateEnum.Idle);
  1140. Transition(RobotStateEnum.Swapping, FSM_MSG.TIMER, fMonitorSwap, RobotStateEnum.Idle);
  1141. Transition(RobotStateEnum.Idle, RobotMsg.MapWafer, fStartMapWafer, RobotStateEnum.Mapping);
  1142. Transition(RobotStateEnum.Mapping, RobotMsg.MapComplete, fMapComplete, RobotStateEnum.Idle);
  1143. Transition(RobotStateEnum.Mapping, RobotMsg.ActionDone, fMapComplete, RobotStateEnum.Idle);
  1144. Transition(RobotStateEnum.Mapping, FSM_MSG.TIMER, fMonitorMap, RobotStateEnum.Idle);
  1145. Transition(RobotStateEnum.Mapping, RobotMsg.ReadData, fStartReadData, RobotStateEnum.ReadingData);
  1146. Transition(RobotStateEnum.Idle, RobotMsg.GoToPosition, fStartGoTo, RobotStateEnum.GoingToPosition);
  1147. Transition(RobotStateEnum.Idle, RobotMsg.Move, fStartMove, RobotStateEnum.Moving);
  1148. Transition(RobotStateEnum.Moving, RobotMsg.MoveComplete, fMoveComplete, RobotStateEnum.Idle);
  1149. Transition(RobotStateEnum.Moving, RobotMsg.ActionDone, fMoveComplete, RobotStateEnum.Idle);
  1150. Transition(RobotStateEnum.Moving, FSM_MSG.TIMER, fMonitorMoving, RobotStateEnum.Idle);
  1151. Transition(RobotStateEnum.GoingToPosition, RobotMsg.ArrivedPosition, fGoToComplete, RobotStateEnum.Idle);
  1152. Transition(RobotStateEnum.GoingToPosition, RobotMsg.MoveComplete, fMoveComplete, RobotStateEnum.Idle);
  1153. Transition(RobotStateEnum.GoingToPosition, RobotMsg.ActionDone, fGoToComplete, RobotStateEnum.Idle);
  1154. Transition(RobotStateEnum.GoingToPosition, FSM_MSG.TIMER, fMonitorGoTo, RobotStateEnum.Idle);
  1155. Transition(RobotStateEnum.Idle, RobotMsg.Grip, fStartGrip, RobotStateEnum.Gripping);
  1156. Transition(RobotStateEnum.Gripping, RobotMsg.GripComplete, fGripComplete, RobotStateEnum.Idle);
  1157. Transition(RobotStateEnum.Gripping, RobotMsg.ActionDone, fGripComplete, RobotStateEnum.Idle);
  1158. Transition(RobotStateEnum.Gripping, FSM_MSG.TIMER, fMonitorGrip, RobotStateEnum.Idle);
  1159. Transition(RobotStateEnum.Idle, RobotMsg.UnGrip, fStartUnGrip, RobotStateEnum.UnGripping);
  1160. Transition(RobotStateEnum.UnGripping, RobotMsg.UnGripComplete, fUnGripComplete, RobotStateEnum.Idle);
  1161. Transition(RobotStateEnum.UnGripping, RobotMsg.ActionDone, fUnGripComplete, RobotStateEnum.Idle);
  1162. Transition(RobotStateEnum.UnGripping, FSM_MSG.TIMER, fMonitorUnGrip, RobotStateEnum.Idle);
  1163. Transition(RobotStateEnum.Idle, RobotMsg.ExtendForPick, fStartExtendForPick, RobotStateEnum.ExtendingForPick);
  1164. Transition(RobotStateEnum.ExtendingForPick, RobotMsg.ExtendComplete, fExtendForPickComplete, RobotStateEnum.Idle);
  1165. Transition(RobotStateEnum.ExtendingForPick, RobotMsg.ActionDone, fExtendForPickComplete, RobotStateEnum.Idle);
  1166. Transition(RobotStateEnum.ExtendingForPick, FSM_MSG.TIMER, fMonitorExtendForPickComplete, RobotStateEnum.Idle);
  1167. Transition(RobotStateEnum.Idle, RobotMsg.ExtendForPlace, fStartExtendForPlace, RobotStateEnum.ExtendingForPlace);
  1168. Transition(RobotStateEnum.ExtendingForPlace, RobotMsg.ExtendComplete, fExtendForPlaceComplete, RobotStateEnum.Idle);
  1169. Transition(RobotStateEnum.ExtendingForPlace, RobotMsg.ActionDone, fExtendForPlaceComplete, RobotStateEnum.Idle);
  1170. Transition(RobotStateEnum.ExtendingForPlace, FSM_MSG.TIMER, fMonitorExtendForPlaceComplete, RobotStateEnum.Idle);
  1171. Transition(RobotStateEnum.Idle, RobotMsg.RetractFromPick, fStartRetractFromPick, RobotStateEnum.RetractingFromPick);
  1172. Transition(RobotStateEnum.RetractingFromPick, RobotMsg.RetractComplete, fRetractFromPickComplete, RobotStateEnum.Idle);
  1173. Transition(RobotStateEnum.RetractingFromPick, RobotMsg.ActionDone, fRetractFromPickComplete, RobotStateEnum.Idle);
  1174. Transition(RobotStateEnum.RetractingFromPick, FSM_MSG.TIMER, fMonitorRetractFromPickComplete, RobotStateEnum.Idle);
  1175. Transition(RobotStateEnum.Idle, RobotMsg.RetractFromPlace, fStartRetractFromPlace, RobotStateEnum.RetractingFromPlace);
  1176. Transition(RobotStateEnum.RetractingFromPlace, RobotMsg.RetractComplete, fRetractFromPlaceComplete, RobotStateEnum.Idle);
  1177. Transition(RobotStateEnum.RetractingFromPlace, RobotMsg.ActionDone, fRetractFromPlaceComplete, RobotStateEnum.Idle);
  1178. Transition(RobotStateEnum.RetractingFromPlace, FSM_MSG.TIMER, fMonitorRetractFromPlaceComplete, RobotStateEnum.Idle);
  1179. Transition(RobotStateEnum.Idle, RobotMsg.TransferWafer, fStartTransferWafer, RobotStateEnum.Transferring);
  1180. Transition(RobotStateEnum.Transferring, RobotMsg.TransferComplete, fTransferPlaceComplete, RobotStateEnum.Idle);
  1181. Transition(RobotStateEnum.Transferring, RobotMsg.ActionDone, fTransferPlaceComplete, RobotStateEnum.Idle);
  1182. Transition(RobotStateEnum.Idle, RobotMsg.PickCassette, fStartPickCassette, RobotStateEnum.PickingCassette);
  1183. Transition(RobotStateEnum.PickingCassette, RobotMsg.PickCassetteComplete, fPickCassetteComplete, RobotStateEnum.Idle);
  1184. Transition(RobotStateEnum.PickingCassette, RobotMsg.ActionDone, fPickCassetteComplete, RobotStateEnum.Idle);
  1185. Transition(RobotStateEnum.PickingCassette, FSM_MSG.TIMER, fMonitorPickingCassette, RobotStateEnum.Idle);
  1186. Transition(RobotStateEnum.Idle, RobotMsg.PlaceCassette, fStartPlaceCassette, RobotStateEnum.PlacingCassette);
  1187. Transition(RobotStateEnum.PlacingCassette, RobotMsg.PlaceCassetteComplete, fPlaceCassetteComplete, RobotStateEnum.Idle);
  1188. Transition(RobotStateEnum.PlacingCassette, RobotMsg.ActionDone, fPlaceCassetteComplete, RobotStateEnum.Idle);
  1189. Transition(RobotStateEnum.PlacingCassette, FSM_MSG.TIMER, fMonitorPlacingCassette, RobotStateEnum.Idle);
  1190. Transition(RobotStateEnum.Idle, RobotMsg.ExecuteCommand, fStartExecuteCommand, RobotStateEnum.Executing);
  1191. Transition(RobotStateEnum.Executing, FSM_MSG.TIMER, fMonitorExecuting, RobotStateEnum.Idle);
  1192. Transition(RobotStateEnum.Executing, RobotMsg.ActionDone, null, RobotStateEnum.Idle);
  1193. }
  1194. protected virtual bool fMonitorExecuting(object[] param)
  1195. {
  1196. IsBusy = false;
  1197. return false;
  1198. }
  1199. protected virtual bool fStartExecuteCommand(object[] param)
  1200. {
  1201. return true;
  1202. }
  1203. protected virtual bool fMonitorHome(object[] param)
  1204. {
  1205. return false;
  1206. }
  1207. protected virtual bool fHomeComplete(object[] param)
  1208. {
  1209. return true;
  1210. }
  1211. protected virtual bool fStartHome(object[] param)
  1212. {
  1213. return true;
  1214. }
  1215. protected virtual bool fMonitorPlacingCassette(object[] param)
  1216. {
  1217. return false;
  1218. }
  1219. protected virtual bool fMonitorPickingCassette(object[] param)
  1220. {
  1221. return false;
  1222. }
  1223. protected virtual bool fMonitorExtendForPickComplete(object[] param)
  1224. {
  1225. return false;
  1226. }
  1227. protected virtual bool fMonitorExtendForPlaceComplete(object[] param)
  1228. {
  1229. return false;
  1230. }
  1231. protected virtual bool fMonitorRetractFromPickComplete(object[] param)
  1232. {
  1233. return false;
  1234. }
  1235. protected virtual bool fMonitorRetractFromPlaceComplete(object[] param)
  1236. {
  1237. return false;
  1238. }
  1239. protected virtual bool fPlaceCassetteComplete(object[] param)
  1240. {
  1241. return true;
  1242. }
  1243. protected virtual bool fStartPlaceCassette(object[] param)
  1244. {
  1245. return true;
  1246. }
  1247. protected virtual bool fPickCassetteComplete(object[] param)
  1248. {
  1249. return true;
  1250. }
  1251. protected virtual bool fStartPickCassette(object[] param)
  1252. {
  1253. return true;
  1254. }
  1255. protected virtual bool fMonitorMoving(object[] param)
  1256. {
  1257. return false;
  1258. }
  1259. protected virtual bool fMonitorMaintenance(object[] param)
  1260. {
  1261. return false;
  1262. }
  1263. protected virtual bool fCompleteMaintenance(object[] param)
  1264. {
  1265. return true;
  1266. }
  1267. protected virtual bool fStartMaitenance(object[] param)
  1268. {
  1269. return true;
  1270. }
  1271. protected virtual bool fMonitorUnGrip(object[] param)
  1272. {
  1273. return true;
  1274. }
  1275. protected virtual bool fMonitorGrip(object[] param)
  1276. {
  1277. return true;
  1278. }
  1279. protected virtual bool fMoveComplete(object[] param)
  1280. {
  1281. IsBusy = false;
  1282. return true;
  1283. }
  1284. protected virtual bool fStartMove(object[] param)
  1285. {
  1286. return true;
  1287. }
  1288. protected virtual bool fMonitorSetParamter(object[] param)
  1289. {
  1290. return false;
  1291. }
  1292. protected virtual bool fMonitorReadData(object[] param)
  1293. {
  1294. return false;
  1295. }
  1296. protected virtual bool fMonitorReset(object[] param)
  1297. {
  1298. return false;
  1299. }
  1300. protected virtual bool fMonitorStop(object[] param)
  1301. {
  1302. return false;
  1303. }
  1304. protected virtual bool fMonitorGoTo(object[] param)
  1305. {
  1306. return false;
  1307. }
  1308. protected virtual bool fMonitorMap(object[] param)
  1309. {
  1310. return false;
  1311. }
  1312. protected virtual bool fMonitorPlace(object[] param)
  1313. {
  1314. return false;
  1315. }
  1316. protected virtual bool fMonitorSwap(object[] param)
  1317. {
  1318. return false;
  1319. }
  1320. protected virtual bool fMonitorPick(object[] param)
  1321. {
  1322. return false;
  1323. }
  1324. protected virtual bool fMonitorInit(object[] param)
  1325. {
  1326. return false;
  1327. }
  1328. protected virtual bool fStop(object[] param)
  1329. {
  1330. return true;
  1331. }
  1332. protected virtual bool fAbort(object[] param)
  1333. {
  1334. return true;
  1335. }
  1336. protected bool fResetComplete(object[] param)
  1337. {
  1338. IsBusy = false;
  1339. return true;
  1340. }
  1341. protected abstract bool fClear(object[] param);
  1342. protected virtual bool fSetComplete(object[] param)
  1343. {
  1344. IsBusy = false;
  1345. return true;
  1346. }
  1347. protected abstract bool fStartReadData(object[] param);
  1348. protected abstract bool fStartSetParameters(object[] param);
  1349. protected abstract bool fStartTransferWafer(object[] param);
  1350. protected abstract bool fStartUnGrip(object[] param);
  1351. protected abstract bool fStartGrip(object[] param);
  1352. protected abstract bool fStartGoTo(object[] param);
  1353. protected abstract bool fStartMapWafer(object[] param);
  1354. protected abstract bool fStartSwapWafer(object[] param);
  1355. protected abstract bool fStartPlaceWafer(object[] param);
  1356. protected abstract bool fStartPickWafer(object[] param);
  1357. protected abstract bool fResetToReady(object[] param);
  1358. protected abstract bool fReset(object[] param);
  1359. protected abstract bool fStartInit(object[] param);
  1360. protected abstract bool fError(object[] param);
  1361. protected abstract bool fStartExtendForPick(object[] param);
  1362. protected abstract bool fStartExtendForPlace(object[] param);
  1363. protected abstract bool fStartRetractFromPick(object[] param);
  1364. protected abstract bool fStartRetractFromPlace(object[] param);
  1365. protected virtual bool fTransferPlaceComplete(object[] param)
  1366. {
  1367. IsBusy = false;
  1368. return true;
  1369. }
  1370. protected virtual bool fGoToComplete(object[] param)
  1371. {
  1372. IsBusy = false;
  1373. return true;
  1374. }
  1375. protected virtual bool fExtendForPickComplete(object[] param)
  1376. {
  1377. return true;
  1378. }
  1379. protected virtual bool fExtendForPlaceComplete(object[] param)
  1380. {
  1381. return true;
  1382. }
  1383. protected virtual bool fRetractFromPickComplete(object[] param)
  1384. {
  1385. return true;
  1386. }
  1387. protected virtual bool fRetractFromPlaceComplete(object[] param)
  1388. {
  1389. IsBusy = false;
  1390. return true;
  1391. }
  1392. protected virtual bool fUnGripComplete(object[] param)
  1393. {
  1394. IsBusy = false;
  1395. return true;
  1396. }
  1397. protected virtual bool fGripComplete(object[] param)
  1398. {
  1399. IsBusy = false;
  1400. return true;
  1401. }
  1402. protected virtual bool fMapComplete(object[] param)
  1403. {
  1404. IsBusy = false;
  1405. return true;
  1406. }
  1407. protected virtual bool fSwapComplete(object[] param)
  1408. {
  1409. IsBusy = false;
  1410. return true;
  1411. }
  1412. protected virtual bool fPlaceComplete(object[] param)
  1413. {
  1414. IsBusy = false;
  1415. return true;
  1416. }
  1417. protected virtual bool fPickComplete(object[] param)
  1418. {
  1419. IsBusy = false;
  1420. return true;
  1421. }
  1422. protected virtual bool fInitFail(object[] param)
  1423. {
  1424. IsBusy = false;
  1425. return true;
  1426. }
  1427. protected virtual bool fInitComplete(object[] param)
  1428. {
  1429. IsBusy = false;
  1430. return true;
  1431. }
  1432. public RobotStateEnum RobotState { get => (RobotStateEnum)fsm.State; }
  1433. public string Module { get; set; }
  1434. public string Name { get; set; }
  1435. public string ScRoot { get; set; }
  1436. public ModuleName RobotModuleName { get; private set; }
  1437. public ModuleName CurrentInteractModule { get; private set; }
  1438. public virtual bool ApproachForPick(RobotArmEnum arm, string station, int slot)
  1439. {
  1440. return true;
  1441. }
  1442. public virtual bool ApproachForPlace(RobotArmEnum arm, string station, int slot)
  1443. {
  1444. return true;
  1445. }
  1446. public virtual bool DualPick(string station, int lowerSlot)
  1447. {
  1448. return true;
  1449. }
  1450. public virtual bool DualPlace(string station, int lowerSlot)
  1451. {
  1452. return true;
  1453. }
  1454. public virtual bool DualSwap(string station, int lowerSlotPlaceTo, int lowerSlotPickFrom)
  1455. {
  1456. return true;
  1457. }
  1458. public virtual bool DualTransfer(string sourceStation, int sourceLowerSlot, string destStation, int destLowerSlot)
  1459. {
  1460. return true;
  1461. }
  1462. public virtual string[] GetStationsInUse()
  1463. {
  1464. return null;
  1465. }
  1466. public abstract RobotArmWaferStateEnum GetWaferState(RobotArmEnum arm);
  1467. #region Action
  1468. public virtual bool Home(object[] param)
  1469. {
  1470. return CheckToPostMessage((int)RobotMsg.StartInit, param);
  1471. }
  1472. public virtual bool Init(object[] param)
  1473. {
  1474. return CheckToPostMessage((int)RobotMsg.StartInit, param);
  1475. }
  1476. public virtual bool HomeModule(object[] param)
  1477. {
  1478. return CheckToPostMessage((int)RobotMsg.StartHome, param);
  1479. }
  1480. public virtual bool Abort()
  1481. {
  1482. return CheckToPostMessage((int)RobotMsg.Abort);
  1483. }
  1484. public virtual bool Grip(RobotArmEnum arm)
  1485. {
  1486. return CheckToPostMessage((int)RobotMsg.Grip, new object[] { (int)arm });
  1487. }
  1488. public virtual bool Release(RobotArmEnum arm)
  1489. {
  1490. return CheckToPostMessage((int)RobotMsg.UnGrip, new object[] { (int)arm });
  1491. }
  1492. public virtual bool Stop()
  1493. {
  1494. return CheckToPostMessage((int)RobotMsg.Stop, null);
  1495. }
  1496. public virtual bool GoTo(object[] param)
  1497. {
  1498. if (!IsReady())
  1499. return false;
  1500. if (PostMessageWithoutCheck((int)RobotMsg.GoToPosition, param))
  1501. {
  1502. string log = "";
  1503. foreach (var obj in param)
  1504. {
  1505. log += obj.ToString() + ",";
  1506. }
  1507. LOG.Write($"{RobotModuleName} start go to {log}");
  1508. return true;
  1509. }
  1510. return false;
  1511. }
  1512. public virtual bool GoTo(RobotArmEnum arm, string station, int slot, RobotPostionEnum pos, float xoffset = 0, float yoffset = 0,
  1513. float zoffset = 0, float woffset = 0, bool isFromOriginal = true, bool isJumpToNextMotion = false)
  1514. {
  1515. return GoTo(new object[] { arm, station, slot, pos, xoffset, yoffset, zoffset, woffset, isFromOriginal, isJumpToNextMotion });
  1516. }
  1517. public virtual bool RobotFlippe(bool to0degree)
  1518. {
  1519. return false;
  1520. }
  1521. #endregion
  1522. public virtual void Monitor()
  1523. {
  1524. return;
  1525. }
  1526. public virtual bool PickEx(RobotArmEnum arm, string station, int slot, double rSpeed, double tSpeed,double zSpeed,double sSpeed, double zAxisOffsetSpeed, bool isBypassInterlock)
  1527. {
  1528. if (!IsReady())
  1529. {
  1530. return false;
  1531. }
  1532. IsBusy = true;
  1533. LOG.Write($"{RobotModuleName} {arm} start post message to pick wafer from station:{station},slot:{slot + 1}.");
  1534. if (PostMessageWithoutCheck((int)RobotMsg.PickWafer, new object[] { arm, station, slot, rSpeed, tSpeed, zSpeed, sSpeed, zAxisOffsetSpeed, isBypassInterlock }))
  1535. {
  1536. LOG.Write($"{RobotModuleName} {arm} start pick wafer from station:{station},slot:{slot + 1}.");
  1537. return true;
  1538. }
  1539. return false;
  1540. }
  1541. public virtual bool Pick(RobotArmEnum arm, string station, int slot)
  1542. {
  1543. if (!IsReady())
  1544. {
  1545. return false;
  1546. }
  1547. IsBusy = true;
  1548. LOG.Write($"{RobotModuleName} {arm} start post message to pick wafer from station:{station},slot:{slot + 1}.");
  1549. if (PostMessageWithoutCheck((int)RobotMsg.PickWafer, new object[] { arm, station, slot }))
  1550. {
  1551. LOG.Write($"{RobotModuleName} {arm} start pick wafer from station:{station},slot:{slot + 1}.");
  1552. return true;
  1553. }
  1554. return false;
  1555. }
  1556. public virtual bool PickEx(RobotArmEnum arm, string station, int slot,int speed)
  1557. {
  1558. if (!IsReady())
  1559. return false;
  1560. IsBusy = true;
  1561. if (PostMessageWithoutCheck((int)RobotMsg.PickWafer, new object[] { arm, station, slot, speed}))
  1562. {
  1563. IsBusy = true;
  1564. return true;
  1565. }
  1566. return false;
  1567. }
  1568. public virtual bool PickCassette(RobotArmEnum arm, string station, int slot)
  1569. {
  1570. if (!IsReady())
  1571. return false;
  1572. IsBusy = true;
  1573. LOG.Write($"{RobotModuleName} {arm} start post message to pick cassette from {station}:{slot}");
  1574. if (PostMessageWithoutCheck((int)RobotMsg.PickCassette, new object[] { station, arm, slot }))
  1575. {
  1576. LOG.Write($"{RobotModuleName} {arm} start pick cassette from {station}:{slot}");
  1577. return true;
  1578. }
  1579. return false;
  1580. }
  1581. public virtual bool PickEx(RobotArmEnum arm, string station, int slot, float xoffset = 0, float yoffset = 0, float zoffset = 0, float woffset = 0)
  1582. {
  1583. if (!IsReady())
  1584. return false;
  1585. IsBusy = true;
  1586. if (PostMessageWithoutCheck((int)RobotMsg.PickWafer, new object[] { arm, station, slot, xoffset, yoffset, zoffset, woffset }))
  1587. {
  1588. IsBusy = true;
  1589. return true;
  1590. }
  1591. return false;
  1592. }
  1593. public virtual bool PickEx(RobotArmEnum arm, string station, int slot, float radialOffset = 0, float thetaOffset = 0)
  1594. {
  1595. if (!IsReady())
  1596. return false;
  1597. IsBusy = true;
  1598. if (PostMessageWithoutCheck((int)RobotMsg.PickWafer, new object[] { arm, station, slot, radialOffset, thetaOffset }))
  1599. {
  1600. IsBusy = true;
  1601. return true;
  1602. }
  1603. return false;
  1604. }
  1605. public virtual bool Place(RobotArmEnum arm, string station, int slot)
  1606. {
  1607. if (!IsReady())
  1608. return false;
  1609. IsBusy = true;
  1610. LOG.Write($"{RobotModuleName} {arm} start post message to place wafer to station:{station},slot:{slot + 1}.");
  1611. if (PostMessageWithoutCheck((int)RobotMsg.PlaceWafer, new object[] { arm, station, slot }))
  1612. {
  1613. LOG.Write($"{RobotModuleName} {arm} start place wafer to station:{station},slot:{slot + 1}.");
  1614. IsBusy = true;
  1615. return true;
  1616. }
  1617. return false;
  1618. }
  1619. public virtual bool PlaceEx(RobotArmEnum arm, string station, int slot, double rSpeed, double tSpeed, double zSpeed, double sSpeed, double zAxisOffsetSpeed)
  1620. {
  1621. if (!IsReady())
  1622. return false;
  1623. IsBusy = true;
  1624. LOG.Write($"{RobotModuleName} {arm} start post message to place wafer to station:{station},slot:{slot + 1}.");
  1625. if (PostMessageWithoutCheck((int)RobotMsg.PlaceWafer, new object[] { arm, station, slot, rSpeed, tSpeed, zSpeed, sSpeed, zAxisOffsetSpeed }))
  1626. {
  1627. LOG.Write($"{RobotModuleName} {arm} start place wafer to station:{station},slot:{slot + 1}.");
  1628. IsBusy = true;
  1629. return true;
  1630. }
  1631. return false;
  1632. }
  1633. public virtual bool PlaceCassette(RobotArmEnum arm, string station, int slot)
  1634. {
  1635. if (!IsReady())
  1636. return false;
  1637. IsBusy = true;
  1638. if (PostMessageWithoutCheck((int)RobotMsg.PlaceCassette, new object[] { station, arm, slot }))
  1639. {
  1640. LOG.Write($"{RobotModuleName} {arm} start place cassette to {station}:{slot}");
  1641. IsBusy = true;
  1642. return true;
  1643. }
  1644. return false;
  1645. }
  1646. public virtual bool PlaceEx(RobotArmEnum arm, string station, int slot, float xoffset = 0, float yoffset = 0, float zoffset = 0, float thetaoffset = 0)
  1647. {
  1648. if (!IsReady())
  1649. return false;
  1650. IsBusy = true;
  1651. if (PostMessageWithoutCheck((int)RobotMsg.PlaceWafer, new object[] { arm, station, slot, xoffset, yoffset, zoffset, thetaoffset }))
  1652. {
  1653. IsBusy = true;
  1654. return true;
  1655. }
  1656. return false;
  1657. }
  1658. public virtual bool PlaceEx(RobotArmEnum arm, string station, int slot, float radialOffset = 0, float thetaOffset = 0)
  1659. {
  1660. if (!IsReady())
  1661. return false;
  1662. IsBusy = true;
  1663. if (PostMessageWithoutCheck((int)RobotMsg.PlaceWafer, new object[] { arm, station, slot, radialOffset, thetaOffset }))
  1664. {
  1665. IsBusy = true;
  1666. return true;
  1667. }
  1668. return false;
  1669. }
  1670. public virtual bool Swap(RobotArmEnum pickArm, string station, int slot)
  1671. {
  1672. if (!IsReady())
  1673. return false;
  1674. IsBusy = true;
  1675. if (PostMessageWithoutCheck((int)RobotMsg.SwapWafer, new object[] { pickArm, station, slot }))
  1676. {
  1677. LOG.Write($"{RobotModuleName} {pickArm} start swap wafer from station:{station},slot:{slot + 1}.");
  1678. IsBusy = true;
  1679. return true;
  1680. }
  1681. return false;
  1682. }
  1683. public virtual bool SwapEx(RobotArmEnum pickArm, string station, int slot, float xoffset = 0, float yoffset = 0, float zoffset = 0, float thetaoffset = 0)
  1684. {
  1685. if (!IsReady())
  1686. return false;
  1687. IsBusy = true;
  1688. if (PostMessageWithoutCheck((int)RobotMsg.SwapWafer, new object[] { pickArm, station, slot, xoffset, yoffset, zoffset, thetaoffset }))
  1689. {
  1690. IsBusy = true;
  1691. return true;
  1692. }
  1693. return false;
  1694. }
  1695. public virtual bool Transfer(RobotArmEnum arm, string sourceStation, int sourceSlot, string destStation, int destSlot)
  1696. {
  1697. if (CheckToPostMessage((int)RobotMsg.TransferWafer, new object[] { arm, sourceStation, sourceSlot, destStation, destSlot }))
  1698. {
  1699. IsBusy = true;
  1700. return true;
  1701. }
  1702. return false;
  1703. }
  1704. public virtual void RobotReset()
  1705. {
  1706. if (CheckToPostMessage((int)RobotMsg.Reset, new object[] { "Reset" }))
  1707. {
  1708. IsBusy = true;
  1709. }
  1710. }
  1711. public virtual void Reset()
  1712. {
  1713. if (CheckToPostMessage((int)RobotMsg.Reset, new object[] { "Reset" }))
  1714. {
  1715. IsBusy = true;
  1716. }
  1717. }
  1718. public virtual void OnError(string errortext)
  1719. {
  1720. EV.PostAlarmLog(Name, $"{Name} occurred error: {errortext}");
  1721. IsBusy = false;
  1722. CheckToPostMessage((int)RobotMsg.ERROR, new object[] { errortext });
  1723. }
  1724. public virtual bool SetParameters(object[] param)
  1725. {
  1726. return CheckToPostMessage((int)RobotMsg.SetParameters, param);
  1727. }
  1728. public virtual void SetServo(bool isOn) { }
  1729. public void NotifySlotMapResult(ModuleName ModuleName, string slotMap)
  1730. {
  1731. if (OnSlotMapRead != null)
  1732. {
  1733. OnSlotMapRead(ModuleName, slotMap);
  1734. }
  1735. }
  1736. public virtual bool HomeAllAxes(out string reason)
  1737. {
  1738. reason = string.Empty;
  1739. return true;
  1740. }
  1741. public virtual bool WaferMapping(ModuleName module, out string reason)
  1742. {
  1743. reason = "";
  1744. if (CheckToPostMessage((int)RobotMsg.MapWafer, new object[] { module }))
  1745. {
  1746. CurrentInteractModule = module;
  1747. IsBusy = true;
  1748. return true;
  1749. }
  1750. return false;
  1751. }
  1752. public virtual bool WaferMapping(ModuleName module, int thicknessIndex = 0, WaferSize size = WaferSize.WS12)
  1753. {
  1754. if (CheckToPostMessage((int)RobotMsg.MapWafer, new object[] { module, thicknessIndex, size }))
  1755. {
  1756. CurrentInteractModule = module;
  1757. IsBusy = true;
  1758. return true;
  1759. }
  1760. return false;
  1761. }
  1762. public virtual bool QueryWaferMap(ModuleName module, out string reason)
  1763. {
  1764. reason = "";
  1765. return true;
  1766. }
  1767. public virtual bool SetMaintenanceMode(bool value)
  1768. {
  1769. if (value)
  1770. return CheckToPostMessage((int)RobotMsg.StartMaintenance, null);
  1771. return CheckToPostMessage((int)RobotMsg.CompleteMaintenance, null);
  1772. }
  1773. public virtual bool OnActionDone(object[] param)
  1774. {
  1775. IsBusy = false;
  1776. if (CheckToPostMessage((int)RobotMsg.ActionDone, new object[] { "ActionDone" }))
  1777. {
  1778. LOG.Write($"{RobotModuleName} action done");
  1779. }
  1780. return true;
  1781. }
  1782. public virtual bool ExecuteCommand(object[] paras)
  1783. {
  1784. IsBusy = true;
  1785. if (CheckToPostMessage((int)RobotMsg.ExecuteCommand, paras))
  1786. {
  1787. LOG.Write($"{RobotModuleName} excute command:{paras[0].ToString()}");
  1788. }
  1789. return true;
  1790. }
  1791. public bool CheckToPostMessage(int msg, params object[] args)
  1792. {
  1793. if (!fsm.FindTransition(fsm.State, msg))
  1794. {
  1795. if (msg != 7)
  1796. EV.PostWarningLog(Name, $"{Name} is in { (RobotStateEnum)fsm.State} state,can not do {(RobotMsg)msg}");
  1797. return false;
  1798. }
  1799. if ((RobotMsg)msg == RobotMsg.GoToPosition || (RobotMsg)msg == RobotMsg.ExtendForPick
  1800. || (RobotMsg)msg == RobotMsg.ExtendForPlace || (RobotMsg)msg == RobotMsg.Grip
  1801. || (RobotMsg)msg == RobotMsg.MapWafer || (RobotMsg)msg == RobotMsg.Move
  1802. || (RobotMsg)msg == RobotMsg.PickWafer || (RobotMsg)msg == RobotMsg.PlaceWafer
  1803. || (RobotMsg)msg == RobotMsg.RetractFromPick || (RobotMsg)msg == RobotMsg.StartInit
  1804. || (RobotMsg)msg == RobotMsg.SwapWafer || (RobotMsg)msg == RobotMsg.TransferWafer
  1805. || (RobotMsg)msg == RobotMsg.UnGrip || (RobotMsg)msg == RobotMsg.SetParameters
  1806. || (RobotMsg)msg == RobotMsg.StartHome)
  1807. IsBusy = true;
  1808. if ((RobotMsg)msg != RobotMsg.ActionDone && !((RobotMsg)msg).ToString().Contains("Complete"))
  1809. CurrentParamter = args;
  1810. fsm.PostMsg(msg, args);
  1811. return true;
  1812. }
  1813. public bool PostMessageWithoutCheck(int msg, params object[] args)
  1814. {
  1815. if ((RobotMsg)msg == RobotMsg.GoToPosition || (RobotMsg)msg == RobotMsg.ExtendForPick
  1816. || (RobotMsg)msg == RobotMsg.ExtendForPlace || (RobotMsg)msg == RobotMsg.Grip
  1817. || (RobotMsg)msg == RobotMsg.MapWafer || (RobotMsg)msg == RobotMsg.Move
  1818. || (RobotMsg)msg == RobotMsg.PickWafer || (RobotMsg)msg == RobotMsg.PlaceWafer
  1819. || (RobotMsg)msg == RobotMsg.RetractFromPick || (RobotMsg)msg == RobotMsg.StartInit
  1820. || (RobotMsg)msg == RobotMsg.SwapWafer || (RobotMsg)msg == RobotMsg.TransferWafer
  1821. || (RobotMsg)msg == RobotMsg.UnGrip || (RobotMsg)msg == RobotMsg.SetParameters
  1822. || (RobotMsg)msg == RobotMsg.StartHome)
  1823. IsBusy = true;
  1824. if ((RobotMsg)msg != RobotMsg.ActionDone && !((RobotMsg)msg).ToString().Contains("Complete"))
  1825. CurrentParamter = args;
  1826. fsm.PostMsgWithoutLock(msg, args);
  1827. return true;
  1828. }
  1829. public bool CheckToPostMessage(RobotMsg msg, params object[] args)
  1830. {
  1831. if (!fsm.FindTransition(fsm.State, (int)msg))
  1832. {
  1833. if ((int)msg != 7)
  1834. EV.PostWarningLog(Name, $"{Name} is in { (RobotStateEnum)fsm.State} state,can not do {(RobotMsg)msg}");
  1835. return false;
  1836. }
  1837. if (msg == RobotMsg.GoToPosition || msg == RobotMsg.ExtendForPick
  1838. || msg == RobotMsg.ExtendForPlace || msg == RobotMsg.Grip
  1839. || msg == RobotMsg.MapWafer || msg == RobotMsg.Move
  1840. || msg == RobotMsg.PickWafer || msg == RobotMsg.PlaceWafer
  1841. || msg == RobotMsg.RetractFromPick || msg == RobotMsg.RetractFromPlace
  1842. || msg == RobotMsg.StartInit
  1843. || msg == RobotMsg.SwapWafer || msg == RobotMsg.TransferWafer
  1844. || msg == RobotMsg.UnGrip || (RobotMsg)msg == RobotMsg.SetParameters
  1845. || msg == RobotMsg.ExecuteCommand)
  1846. IsBusy = true;
  1847. if (msg != RobotMsg.ActionDone && !(msg).ToString().Contains("Complete"))
  1848. CurrentParamter = args;
  1849. fsm.PostMsgWithoutLock((int)msg, args);
  1850. return true;
  1851. }
  1852. public bool Check(int msg, out string reason, params object[] args)
  1853. {
  1854. if (!fsm.FindTransition(fsm.State, msg))
  1855. {
  1856. reason = String.Format("{0} is in {1} state,can not do {2}", Name, (RobotStateEnum)fsm.State, (RobotMsg)msg);
  1857. return false;
  1858. }
  1859. //CurrentParamter = args;
  1860. reason = "";
  1861. return true;
  1862. }
  1863. public virtual void SetPauseResume(bool isPause) { }
  1864. public virtual void NoteError(string errortext)
  1865. {
  1866. }
  1867. }
  1868. public enum RobotMoveDirectionEnum
  1869. {
  1870. Fwd,
  1871. Rev
  1872. }
  1873. }