RobotBase.cs 83 KB

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