RobotSiasunPhoenixB.cs 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO.Ports;
  4. using System.Linq;
  5. using System.Threading;
  6. using Aitex.Core.Common;
  7. using Aitex.Core.Common.DeviceData;
  8. using Aitex.Core.RT.DataCenter;
  9. using Aitex.Core.RT.Device;
  10. using Aitex.Core.RT.Device.Unit;
  11. using Aitex.Core.RT.Event;
  12. using Aitex.Core.RT.Log;
  13. using Aitex.Core.RT.OperationCenter;
  14. using Aitex.Core.RT.SCCore;
  15. using Aitex.Core.Util;
  16. using MECF.Framework.Common.CommonData;
  17. using MECF.Framework.Common.Communications;
  18. using MECF.Framework.Common.Device.Bases;
  19. using MECF.Framework.Common.Equipment;
  20. using MECF.Framework.Common.SubstrateTrackings;
  21. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Common;
  22. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  23. using Newtonsoft.Json;
  24. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.SiasunPhoenixB
  25. {
  26. public class RobotSiasunPhoenixB : RobotBaseDevice, IConnection
  27. {
  28. public string Address => Connection.Address;
  29. public bool IsConnected => Connection.IsConnected && !_connection.IsCommunicationError;
  30. public bool Connect()
  31. {
  32. return _connection.Connect();
  33. }
  34. public bool Disconnect()
  35. {
  36. return _connection.Disconnect();
  37. }
  38. public string PortStatus { get; set; } = "Closed";
  39. public Dictionary<string, int> ModuleAssociateStationDic
  40. {
  41. get => _moduleAssociateStationDic;
  42. set
  43. {
  44. _moduleAssociateStationDic = value;
  45. }
  46. }
  47. private RobotSiasunPhoenixBTCPConnection _connection;
  48. public RobotSiasunPhoenixBTCPConnection Connection
  49. {
  50. get { return _connection; }
  51. }
  52. private R_TRIG _trigError = new R_TRIG();
  53. private bool _isAlarm;
  54. private R_TRIG _trigCommunicationError = new R_TRIG();
  55. private R_TRIG _trigRetryConnect = new R_TRIG();
  56. private PeriodicJob _thread;
  57. private LinkedList<HandlerBase> _lstHandler = new LinkedList<HandlerBase>();
  58. private LinkedList<HandlerBase> _lstMonitorHandler = new LinkedList<HandlerBase>();
  59. public List<IOResponse> IOResponseList { get; set; } = new List<IOResponse>();
  60. private Dictionary<string, string> _errorCodeReferenceDic;
  61. private Dictionary<string, int> _moduleAssociateStationDic;
  62. private object _locker = new object();
  63. private SCConfigItem _scHomeTimeout;
  64. private SCConfigItem _scMotionTimeout;
  65. private SCConfigItem _scBladeSlots;
  66. private List<ModuleName> _disabledIntlkModules = new List<ModuleName>();
  67. public int BladeSlots => _scBladeSlots == null ? 1 : _scBladeSlots.IntValue;
  68. private bool _enableLog;
  69. private string _scRoot;
  70. public RobotSiasunPhoenixB(string module, string name, string scRoot, string endof = "\r\n") : base(module, name)
  71. {
  72. _scRoot = scRoot;
  73. ResetPropertiesAndResponses();
  74. string deviceIP = "";
  75. if (string.IsNullOrEmpty(_scRoot))
  76. {
  77. deviceIP = SC.GetStringValue($"{Module}.Address");
  78. _enableLog = SC.GetValue<bool>($"{Module}.EnableLogMessage");
  79. _scHomeTimeout = SC.GetConfigItem($"{Module}.HomeTimeout");
  80. _scMotionTimeout = SC.GetConfigItem($"{Module}.MotionTimeout");
  81. _scBladeSlots = SC.GetConfigItem($"{Module}.BladeSlots");
  82. }
  83. else
  84. {
  85. if(SC.ContainsItem($"{_scRoot}.{Module}.{Name}.Address"))
  86. {
  87. deviceIP = SC.GetStringValue($"{_scRoot}.{Module}.{Name}.Address");
  88. _enableLog = SC.GetValue<bool>($"{_scRoot}.{Module}.{Name}.EnableLogMessage");
  89. _scHomeTimeout = SC.GetConfigItem($"{_scRoot}.{Module}.{Module}.HomeTimeout");
  90. _scMotionTimeout = SC.GetConfigItem($"{_scRoot}.{Module}.{Module}.MotionTimeout");
  91. _scBladeSlots = SC.GetConfigItem($"{_scRoot}.{Module}.{Module}.BladeSlots");
  92. }
  93. else
  94. {
  95. deviceIP = SC.GetStringValue($"{_scRoot}.Address");
  96. _enableLog = SC.GetValue<bool>($"{_scRoot}.EnableLogMessage");
  97. _scHomeTimeout = SC.GetConfigItem($"{_scRoot}.HomeTimeout");
  98. _scMotionTimeout = SC.GetConfigItem($"{_scRoot}.MotionTimeout");
  99. _scBladeSlots = SC.GetConfigItem($"{_scRoot}.BladeSlots");
  100. }
  101. }
  102. WaferManager.Instance.SubscribeLocation(Name, BladeSlots * 2);
  103. _connection = new RobotSiasunPhoenixBTCPConnection(deviceIP, endof);
  104. _connection.EnableLog(_enableLog);
  105. if (_connection.Connect())
  106. {
  107. PortStatus = "Open";
  108. EV.PostInfoLog(Module, $"{Module}.{Name} connected");
  109. }
  110. else
  111. {
  112. PortStatus = "Close";
  113. EV.PostInfoLog(Module, $"{Module}.{Name} connect failed");
  114. }
  115. _thread = new PeriodicJob(100, OnTimer, $"{Module}.{Name} MonitorHandler", true);
  116. DATA.Subscribe($"{Module}.IsConnected", () => IsConnected);
  117. DATA.Subscribe($"{Module}.Address", () => Address);
  118. OP.Subscribe($"{Module}.Reconnect", (string cmd, object[] args) =>
  119. {
  120. Disconnect();
  121. Connect();
  122. return true;
  123. });
  124. _moduleAssociateStationDic = new Dictionary<string, int>()
  125. {
  126. {$"{ModuleName.PM1 }", 1 },
  127. {$"{ModuleName.PM2}", 2 },
  128. {$"{ModuleName.PMC}", 3 },
  129. {$"{ModuleName.PMD}", 4 },
  130. {$"{ModuleName.VCEA}", 5 },
  131. {$"{ModuleName.VCEB}", 6 },
  132. {$"{ModuleName.AlignerA}", 7 },
  133. {$"{ModuleName.AlignerB}", 8 },
  134. {$"{ModuleName.LL1}", 3 },//A1=5,A2=6,A both=7
  135. {$"{ModuleName.LLA}", 7 },//A1=5,A2=6,A both=7
  136. {$"{ModuleName.LLA}.01", 5 },//A1=5,A2=6,A both=7
  137. {$"{ModuleName.LLA}.02", 6 },//A1=5,A2=6,A both=7
  138. {$"{ModuleName.LLA}.Both", 7 },//A1=5,A2=6,A both=7
  139. {$"{ModuleName.LLB}", 10 },//B1=8,B2=9,B both=10
  140. {$"{ModuleName.LLB}.01", 8 },//B1=8,B2=9,B both=10
  141. {$"{ModuleName.LLB}.02", 9 },//B1=8,B2=9,B both=10
  142. {$"{ModuleName.LLB}.Both", 10 },//B1=8,B2=9,B both=10
  143. };
  144. _errorCodeReferenceDic = new Dictionary<string, string>()
  145. {
  146. {"901", "Main power EMO" },
  147. {"902", "Teach pendant EMO" },
  148. {"962", "Driver RDY sensor disconnect" },
  149. {"3001", "Robot collision" },
  150. {"7300", "Rotation sensor forbidden" },
  151. {"7301", "Extend sensor forbidden" },
  152. {"2200", "Output port Number not exist" },
  153. {"3120", "Joint N speed out of range" },
  154. {"3100", "Joint N position out of range" },
  155. {"100", "Robot power on fail" },
  156. {"7307", "GOTO station out of range" },
  157. {"7308", "Sensor type not support" },
  158. {"7312", "PICK station out of range" },
  159. {"7313", "PLACE station out of range" },
  160. {"7314", "XFER station out of range" },
  161. {"7315", "REMOVE not support IO type" },
  162. {"7316", "RQ INTLCK parameter invalid" },
  163. {"7319", "RQ STN station out of range" },
  164. {"7320", "wafre(WAF_SEN) parameter not set" },
  165. {"7321", "wafex(RETRACT_PIN) parameter not set" },
  166. {"7322", "svlv(SBIT_SVLV_SEN) parameter not set" },
  167. {"7323", "ens(EX_ENABLE) parameter not set" },
  168. {"7324", "RQ parameter invalid" },
  169. {"7325", "SET INTLOCK WAF_SEN parameter invalid" },
  170. {"7326", "SET INTLOCK RZ parameter invalid" },
  171. {"7327", "SET INTLOCK parameter invalid" },
  172. {"7328", "SET IO ECHO parameter invalid" },
  173. {"7329", "SET IO STATE not support" },
  174. {"7330", "SET IO parameter invalid" },
  175. {"7331", "SET STN station out of range" },
  176. {"7332", "Robot read parameter fail" },
  177. {"7333", "WAF_SEN parameter invalid" },
  178. {"7334", "SET sensor type not support" },
  179. {"7335", "SET parameter invalid" },
  180. {"7336", "STORE IO parameter invalid" },
  181. {"7337", "STORE LOAD parameter invalid" },
  182. {"7338", "STORE STN station out of range" },
  183. {"7339", "STORE STN parameter invalid" },
  184. {"7340", "STORE sensor type not support" },
  185. {"7341", "STORE parameter invalid" },
  186. {"7342", "Command invalid" },
  187. {"7343", "HOME parameter not set" },
  188. {"7344", "GOTO R axis parameter not set" },
  189. {"7345", "GOTO Z axis parameter not set" },
  190. {"7346", "ARM parameter invalid" },
  191. {"7347", "GOTO parameter not set" },
  192. {"7349", "MOVE parameter not set" },
  193. {"7350", "MOVE parameter invalid" },
  194. {"7351", "PICK parameter not set" },
  195. {"7352", "PLACE parameter not set" },
  196. {"7353", "REMOVE parameter not set" },
  197. {"7354", "Command excute not finished" },
  198. {"7355", "GOTO station parameter not set" },
  199. {"7356", "PICK station parameter not set" },
  200. {"7357", "PLACE station parameter not set" },
  201. {"7358", "ABS parameter not set" },
  202. {"7359", "REL parameter not set" },
  203. {"7360", "Robot not set main thread" },
  204. {"7361", "Robot not open main thread" },
  205. {"7362", "Current thread not main thread" },
  206. {"7363", "ex_ena(EX_ENABLE_SEN) parameter not set" },
  207. {"7364", "stable(STABLE_ SIGNAL) parameter not set" },
  208. {"7365", "MOVE parameter invalid" },
  209. {"7366", "System not on" },
  210. {"7367", "extend(EX_SIGNAL) parameter not set" },
  211. {"7368", "retract(RE_ SIGNAL) parameter not set" },
  212. {"7371", "Wafer not present before place" },
  213. {"7372", "Wafer present before pick" },
  214. {"7373", "Wafer present after place" },
  215. {"7374", "Wafer not present after pick" },
  216. {"7375", "Servo not on" },
  217. {"7376", "Exist not number parameter" },
  218. {"7385", "Driver stop abnormal" },
  219. {"7387", "Driver ID1 alarm" },
  220. {"7388", "Driver ID2 alarm" },
  221. {"7389", "Driver ID3 alarm" },
  222. {"7391", "AWC station out of range" },
  223. {"7392", "AWC out of range alarm" },
  224. {"7393", "AWC sensor set fail" },
  225. {"7398", "AWC calculate fail" },
  226. {"7399", "AWC trig number error" },
  227. {"7401", "Wafer maybe present on blade" },
  228. {"7402", "Wafer maybe not present on blade" },
  229. {"7403", "Load status in ON, not correct" },
  230. {"7404", "Load status in OFF, not correct" },
  231. {"7405", "Slot not exist" },
  232. {"7495", "ID1 encoder error" },
  233. {"7496", "ID2 encoder error" },
  234. {"7497", "ID3 encoder error" },
  235. };
  236. }
  237. private void ResetPropertiesAndResponses()
  238. {
  239. foreach (var ioResponse in IOResponseList)
  240. {
  241. ioResponse.ResonseContent = null;
  242. ioResponse.ResonseRecievedTime = DateTime.Now;
  243. }
  244. }
  245. public override bool IsReady()
  246. {
  247. return ((!_connection.IsBusy) && (_lstHandler.Count == 0) && (!_connection.IsCommunicationError) && (!IsBusy) && (RobotState == RobotStateEnum.Idle)) && !_isAlarm;
  248. }
  249. protected override bool Init()
  250. {
  251. return true;
  252. }
  253. private bool OnTimer()
  254. {
  255. try
  256. {
  257. //return true;
  258. _connection.MonitorTimeout();
  259. if (!_connection.IsConnected || _connection.IsCommunicationError)
  260. {
  261. lock (_locker)
  262. {
  263. _lstHandler.Clear();
  264. }
  265. _trigRetryConnect.CLK = !_connection.IsConnected;
  266. if (_trigRetryConnect.Q)
  267. {
  268. if (!_connection.Connect())
  269. {
  270. EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}.{Name}");
  271. }
  272. else
  273. {
  274. //_lstHandler.AddLast(new RobotSiasunPhoenixBQueryPinHandler(this, _deviceAddress));
  275. //_lstHandler.AddLast(new RobotSiasunPhoenixBSetCommModeHandler(this, _deviceAddress, EnumRfPowerCommunicationMode.Host));
  276. }
  277. }
  278. return true;
  279. }
  280. HandlerBase handler = null;
  281. if (!_connection.IsBusy)
  282. {
  283. lock (_locker)
  284. {
  285. if (_lstHandler.Count == 0)
  286. {
  287. foreach (var monitorHandler in _lstMonitorHandler)
  288. {
  289. _lstHandler.AddLast(monitorHandler);
  290. }
  291. }
  292. if (_lstHandler.Count > 0)
  293. {
  294. handler = _lstHandler.First.Value;
  295. _lstHandler.RemoveFirst();
  296. }
  297. }
  298. if (handler != null)
  299. {
  300. _connection.Execute(handler);
  301. }
  302. }
  303. }
  304. catch (Exception ex)
  305. {
  306. LOG.Write(ex);
  307. }
  308. return true;
  309. }
  310. public override void Monitor()
  311. {
  312. try
  313. {
  314. //_connection.EnableLog(_enableLog);
  315. _trigCommunicationError.CLK = _connection.IsCommunicationError;
  316. if (_trigCommunicationError.Q)
  317. {
  318. EV.PostAlarmLog(Module, $"{Module}.{Name} communication error, {_connection.LastCommunicationError}");
  319. }
  320. }
  321. catch (Exception ex)
  322. {
  323. LOG.Write(ex);
  324. }
  325. }
  326. protected override void SubscribeWaferLocation()
  327. {
  328. //do nothing
  329. }
  330. public override void Reset()
  331. {
  332. _trigError.RST = true;
  333. IsBusy = false;
  334. _connection.SetCommunicationError(false, "");
  335. _trigCommunicationError.RST = true;
  336. _trigWarningMessage.RST = true;
  337. //_enableLog = SC.GetValue<bool>($"{ScBasePath}.{Name}.EnableLogMessage");
  338. _trigRetryConnect.RST = true;
  339. base.Reset();
  340. }
  341. public void SetDisabledIntlkModules(IEnumerable<ModuleName> units)
  342. {
  343. _disabledIntlkModules.AddRange(units);
  344. }
  345. #region Command Functions
  346. public void PerformRawCommand(string command, string comandArgument)
  347. {
  348. lock (_locker)
  349. {
  350. _lstHandler.AddLast(new RobotSiasunPhoenixBRawCommandHandler(this, command, comandArgument));
  351. }
  352. }
  353. public void PerformRawCommand(string command)
  354. {
  355. lock (_locker)
  356. {
  357. _lstHandler.AddLast(new RobotSiasunPhoenixBRawCommandHandler(this, command));
  358. }
  359. }
  360. public void ResetRobot()
  361. {
  362. _connection.SendMessage("RESET\r");
  363. }
  364. public void Goto(GotoArgument gotoArg)
  365. {
  366. lock (_locker)
  367. {
  368. //_lstHandler.AddLast(new RobotSiasunPhoenixBGotoHandler(this, JsonConvert.SerializeObject(gotoArg)));
  369. }
  370. }
  371. public void Goto(object gotoArg)
  372. {
  373. lock (_locker)
  374. {
  375. //_lstHandler.AddLast(new RobotSiasunPhoenixBGotoHandler(this, gotoArg.ToString()));
  376. }
  377. }
  378. public void SevoOn()
  379. {
  380. lock (_locker)
  381. {
  382. _lstHandler.AddLast(new RobotSiasunPhoenixBSevoOnOffHandler(this, true));
  383. }
  384. }
  385. public void SevoOff()
  386. {
  387. lock (_locker)
  388. {
  389. _lstHandler.AddLast(new RobotSiasunPhoenixBSevoOnOffHandler(this, false));
  390. }
  391. }
  392. public void Halt()
  393. {
  394. lock (_locker)
  395. {
  396. _lstHandler.AddLast(new RobotSiasunPhoenixBHaltHandler(this));
  397. }
  398. }
  399. public void HomeAxis(string axis)
  400. {
  401. lock (_locker)
  402. {
  403. //_lstHandler.AddLast(new RobotSiasunPhoenixBHomeAxisHandler(this, axis));
  404. }
  405. }
  406. public void Pick(PickPlaceArgument pickArg)
  407. {
  408. lock (_locker)
  409. {
  410. //_lstHandler.AddLast(new RobotSiasunPhoenixBPickHandler(this, JsonConvert.SerializeObject(pickArg)));
  411. }
  412. }
  413. public void Pick(object gotoArg)
  414. {
  415. lock (_locker)
  416. {
  417. // _lstHandler.AddLast(new RobotSiasunPhoenixBPickHandler(this, gotoArg.ToString()));
  418. }
  419. }
  420. public void Place(PickPlaceArgument placeArg)
  421. {
  422. lock (_locker)
  423. {
  424. //_lstHandler.AddLast(new RobotSiasunPhoenixBPlaceHandler(this, JsonConvert.SerializeObject(placeArg)));
  425. }
  426. }
  427. public void Place(object placeArg)
  428. {
  429. lock (_locker)
  430. {
  431. //_lstHandler.AddLast(new RobotSiasunPhoenixBPlaceHandler(this, placeArg.ToString()));
  432. }
  433. }
  434. public void Transfer(string arm, string fromStation, string toStation)
  435. {
  436. lock (_locker)
  437. {
  438. //_lstHandler.AddLast(new RobotSiasunPhoenixBTransferHandler(this, fromStation, toStation, arm));
  439. }
  440. }
  441. public void Transfer(string fromStation, string toStation)
  442. {
  443. lock (_locker)
  444. {
  445. //_lstHandler.AddLast(new RobotSiasunPhoenixBTransferHandler(this, fromStation, toStation));
  446. }
  447. }
  448. internal void NoteSetCommEchoCompleted(bool value)
  449. {
  450. SetCommEchoCompleted = value;
  451. }
  452. public void Retract()
  453. {
  454. lock (_locker)
  455. {
  456. _lstHandler.AddLast(new RobotSiasunPhoenixBRetractHandler(this, _scMotionTimeout.IntValue));
  457. }
  458. }
  459. public void SetCommunicationEcho(string echoStatus)
  460. {
  461. lock (_locker)
  462. {
  463. //_lstHandler.AddLast(new RobotSiasunPhoenixBSetCommunicationEchoHandler(this, echoStatus));
  464. }
  465. }
  466. public void SetLoad(string arm, string status)
  467. {
  468. lock (_locker)
  469. {
  470. //_lstHandler.AddLast(new RobotSiasunPhoenixBSetLoadHandler(this, arm, status));
  471. }
  472. }
  473. public void MonitorRawCommand(bool isSelected, string command, string comandArgument)
  474. {
  475. lock (_locker)
  476. {
  477. string msg = comandArgument == null ? $"{command}\r" : $"{command} {comandArgument}\r";
  478. var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(RobotSiasunPhoenixBRawCommandHandler) && handler.SendText == msg);
  479. if (isSelected)
  480. {
  481. if (!existHandlers.Any())
  482. _lstMonitorHandler.AddFirst(new RobotSiasunPhoenixBRawCommandHandler(this, command, comandArgument));
  483. }
  484. else
  485. {
  486. if (existHandlers.Any())
  487. {
  488. _lstMonitorHandler.Remove(existHandlers.First());
  489. }
  490. }
  491. }
  492. }
  493. public void MonitorRawCommand(bool isSelected, string command)
  494. {
  495. lock (_locker)
  496. {
  497. string msg = $"{command}\r";
  498. var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(RobotSiasunPhoenixBRawCommandHandler) && handler.SendText == msg);
  499. if (isSelected)
  500. {
  501. if (!existHandlers.Any())
  502. _lstMonitorHandler.AddFirst(new RobotSiasunPhoenixBRawCommandHandler(this, command));
  503. }
  504. else
  505. {
  506. if (existHandlers.Any())
  507. {
  508. _lstMonitorHandler.Remove(existHandlers.First());
  509. }
  510. }
  511. }
  512. }
  513. public void RequestWaferOnOff(bool isSelected, string load)
  514. {
  515. lock (_locker)
  516. {
  517. //var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(RobotSiasunPhoenixBQueryWaferOnOffHandler) && handler.SendText.Contains(" " + load.ToString()));
  518. //if (isSelected)
  519. //{
  520. // if (!existHandlers.Any())
  521. // _lstMonitorHandler.AddFirst(new RobotSiasunPhoenixBQueryWaferOnOffHandler(this, load));
  522. //}
  523. //else
  524. //{
  525. // if (existHandlers.Any())
  526. // {
  527. // _lstMonitorHandler.Remove(existHandlers.First());
  528. // }
  529. //}
  530. }
  531. }
  532. internal void NoteCommEchoStatus(bool echoStatus)
  533. {
  534. CommEchoOn = echoStatus;
  535. }
  536. public void RequestWaferOnOff(bool isSelected)
  537. {
  538. lock (_locker)
  539. {
  540. //var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(RobotSiasunPhoenixBQueryWaferOnOffHandler) && handler.SendText == "RQ LOAD\r");
  541. //if (isSelected)
  542. //{
  543. // if (!existHandlers.Any())
  544. // _lstMonitorHandler.AddFirst(new RobotSiasunPhoenixBQueryWaferOnOffHandler(this, null));
  545. //}
  546. //else
  547. //{
  548. // if (existHandlers.Any())
  549. // {
  550. // _lstMonitorHandler.Remove(existHandlers.First());
  551. // }
  552. //}
  553. }
  554. }
  555. internal void NoteWafeCenData(string requestResponse)
  556. {
  557. WafeCenData = requestResponse;
  558. var dataArray = requestResponse.Split(' ');
  559. if (dataArray.Length == 15)
  560. {
  561. Offset_R = dataArray[10];
  562. Offset_T = dataArray[11];
  563. }
  564. else
  565. {
  566. NoteError("RequestWafeCenData Response Error");
  567. }
  568. }
  569. public void RequestCommunicationEcho(bool isSelected)
  570. {
  571. lock (_locker)
  572. {
  573. //var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(RobotSiasunPhoenixBRequestCommunicationEchoHandler));
  574. //if (isSelected)
  575. //{
  576. // if (!existHandlers.Any())
  577. // _lstMonitorHandler.AddFirst(new RobotSiasunPhoenixBRequestCommunicationEchoHandler(this));
  578. //}
  579. //else
  580. //{
  581. // if (existHandlers.Any())
  582. // {
  583. // _lstMonitorHandler.Remove(existHandlers.First());
  584. // }
  585. //}
  586. }
  587. }
  588. public void RequestWaferCentData(bool isSelected)
  589. {
  590. lock (_locker)
  591. {
  592. var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(RobotSiasunPhoenixBRequestWaferCentDataHandler));
  593. if (isSelected)
  594. {
  595. if (!existHandlers.Any())
  596. _lstMonitorHandler.AddFirst(new RobotSiasunPhoenixBRequestWaferCentDataHandler(this));
  597. }
  598. else
  599. {
  600. if (existHandlers.Any())
  601. {
  602. _lstMonitorHandler.Remove(existHandlers.First());
  603. }
  604. }
  605. }
  606. }
  607. #endregion
  608. #region Properties
  609. public bool SevoOnOff { get; private set; }
  610. public bool CommEchoOn { get; private set; }
  611. public bool SetCommEchoCompleted { get; private set; }
  612. public string WafeCenData { get; private set; }
  613. public string Offset_R { get; private set; }
  614. public string Offset_T { get; private set; }
  615. #endregion
  616. #region Note Functions
  617. private R_TRIG _trigWarningMessage = new R_TRIG();
  618. public void NoteError(string reason)
  619. {
  620. if (reason != null)
  621. {
  622. _trigWarningMessage.CLK = true;
  623. var content = reason;
  624. if (_errorCodeReferenceDic.ContainsKey(reason))
  625. content = _errorCodeReferenceDic[reason];
  626. if (_trigWarningMessage.Q)
  627. {
  628. EV.PostWarningLog(Module, $"{Module}.{Name} error, {reason} {content}");
  629. }
  630. _isAlarm = true;
  631. ErrorCode = reason;
  632. }
  633. else
  634. {
  635. _isAlarm = false;
  636. }
  637. }
  638. internal void NoteSevoOnOff(bool isOn)
  639. {
  640. SevoOnOff = isOn;
  641. }
  642. internal void NoteActionCompleted()
  643. {
  644. Blade1Target = ModuleName.System;
  645. Blade2Target = ModuleName.System;
  646. IsBusy = false;
  647. CheckToPostMessage((int)RobotMsg.ActionDone);
  648. }
  649. internal void NoteAxisHomed()
  650. {
  651. Blade1Target = ModuleName.System;
  652. Blade2Target = ModuleName.System;
  653. IsBusy = false;
  654. CheckToPostMessage((int)RobotMsg.InitComplete);
  655. }
  656. internal void NoteReadDataComplete()
  657. {
  658. IsBusy = false;
  659. CheckToPostMessage((int)RobotMsg.ReadDataComplete);
  660. }
  661. internal void NoteSetParametersComplete()
  662. {
  663. IsBusy = false;
  664. CheckToPostMessage((int)RobotMsg.SetParametersComplete);
  665. }
  666. internal void NoteWafeOnOff(string arm, bool isOn, bool isUnknown)
  667. {
  668. IsBusy = false;
  669. if (isUnknown)
  670. {
  671. if (arm == "A")
  672. {
  673. IsWaferPresenceOnBlade1 = false;
  674. WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Module), 0);
  675. EV.PostWarningLog(Module, $"{Module}.{Name} arm {arm} status is unkonwn");
  676. }
  677. if (arm == "B")
  678. {
  679. IsWaferPresenceOnBlade2 = false;
  680. WaferManager.Instance.DeleteWafer(ModuleHelper.Converter(Module), 1);
  681. EV.PostWarningLog(Module, $"{Module}.{Name} arm {arm} status is unkonwn");
  682. }
  683. }
  684. else
  685. {
  686. if (arm == "A")
  687. {
  688. IsWaferPresenceOnBlade1 = isOn;
  689. }
  690. else
  691. {
  692. IsWaferPresenceOnBlade2 = isOn;
  693. }
  694. }
  695. }
  696. internal void NoteRawCommandInfo(string command, string data)
  697. {
  698. //var curIOResponse = IOResponseList.Find(res => res.SourceCommandName == command);
  699. //if (curIOResponse != null)
  700. //{
  701. // IOResponseList.Remove(curIOResponse);
  702. //}
  703. //IOResponseList.Add(new IOResponse() { SourceCommandName = command, ResonseContent = data, ResonseRecievedTime = DateTime.Now });
  704. }
  705. protected override bool fStartHome(object[] param)
  706. {
  707. lock (_locker)
  708. {
  709. //_lstHandler.AddLast(new RobotSiasunPhoenixBSetCommunicationEchoHandler(this, false));
  710. //_lstHandler.AddLast(new RobotSiasunPhoenixBSevoOnOffHandler(this, true));
  711. _lstHandler.AddLast(new RobotSiasunPhoenixBHomeAxisHandler(this, _scHomeTimeout.IntValue));
  712. }
  713. return true;
  714. }
  715. protected override bool fClear(object[] param)
  716. {
  717. //lock (_locker)
  718. //{
  719. // _lstHandler.AddLast(new RobotSiasunPhoenixBResetHandler(this));
  720. //}
  721. return true;
  722. }
  723. public override bool ReadParameter(object[] param)
  724. {
  725. IsBusy = true;
  726. return CheckToPostMessage((int)RobotMsg.ReadData, param);
  727. }
  728. public override bool GoTo(object[] param)
  729. {
  730. if (param.Length < 1) return false;
  731. string command = param[0].ToString();
  732. var length = param.Length;
  733. var args = param.Skip(1).Take(length - 1).ToArray();
  734. if (!IsReady())
  735. return false;
  736. switch (command)
  737. {
  738. case "GoTo":
  739. if (PostMessageWithoutCheck((int)RobotMsg.GoToPosition, args))
  740. {
  741. IsBusy = true;
  742. string log = "";
  743. foreach (var obj in args)
  744. {
  745. log += obj.ToString() + ",";
  746. }
  747. LOG.Write($"{RobotModuleName} start go to {log}");
  748. return true;
  749. }
  750. break;
  751. case "ExtendForPick":
  752. if (PostMessageWithoutCheck((int)RobotMsg.ExtendForPick, args))
  753. {
  754. IsBusy = true;
  755. string log = "";
  756. foreach (var obj in args)
  757. {
  758. log += obj.ToString() + ",";
  759. }
  760. LOG.Write($"{RobotModuleName} start extend for pick {log}");
  761. return true;
  762. }
  763. break;
  764. case "ExtendForPlace":
  765. if (PostMessageWithoutCheck((int)RobotMsg.ExtendForPlace, args))
  766. {
  767. IsBusy = true;
  768. string log = "";
  769. foreach (var obj in args)
  770. {
  771. log += obj.ToString() + ",";
  772. }
  773. LOG.Write($"{RobotModuleName} start extend for place {log}");
  774. return true;
  775. }
  776. break;
  777. case "RetractFromPick":
  778. if (PostMessageWithoutCheck((int)RobotMsg.RetractFromPick, args))
  779. {
  780. IsBusy = true;
  781. string log = "";
  782. foreach (var obj in args)
  783. {
  784. log += obj.ToString() + ",";
  785. }
  786. LOG.Write($"{RobotModuleName} start retract from pick {log}");
  787. return true;
  788. }
  789. break;
  790. case "RetractFromPlace":
  791. if (PostMessageWithoutCheck((int)RobotMsg.RetractFromPlace, args))
  792. {
  793. IsBusy = true;
  794. string log = "";
  795. foreach (var obj in args)
  796. {
  797. log += obj.ToString() + ",";
  798. }
  799. LOG.Write($"{RobotModuleName} start retract from place {log}");
  800. return true;
  801. }
  802. break;
  803. default:
  804. break;
  805. }
  806. return false;
  807. }
  808. protected override bool fStartReadData(object[] param)
  809. {
  810. if (param.Length < 1) return false;
  811. string readcommand = param[0].ToString();
  812. switch (readcommand)
  813. {
  814. case "QueryWaferPresent":
  815. lock (_locker)
  816. {
  817. RobotArmEnum arm = (RobotArmEnum)param[1];
  818. _lstHandler.AddLast(new RobotSiasunPhoenixBQueryWaferPresentHandler(this, arm));
  819. }
  820. break;
  821. case "QueryWaferCentData":
  822. lock (_locker)
  823. {
  824. _lstHandler.AddLast(new RobotSiasunPhoenixBRequestWaferCentDataHandler(this));
  825. }
  826. break;
  827. case "CheckLoad":
  828. lock (_locker)
  829. {
  830. RobotArmEnum arm = (RobotArmEnum)param[1];
  831. int checkLoadStation = 20;
  832. _lstHandler.AddLast(new RobotSiasunPhoenixBCheckLoadHandler(this, checkLoadStation, arm, _scHomeTimeout.IntValue * 2));
  833. }
  834. break;
  835. case "CheckLoad1":
  836. lock (_locker)
  837. {
  838. RobotArmEnum arm = (RobotArmEnum)param[1];
  839. int checkLoadStation = 18;
  840. _lstHandler.AddLast(new RobotSiasunPhoenixBCheckLoadHandler(this, checkLoadStation, arm, _scHomeTimeout.IntValue * 2));
  841. }
  842. break;
  843. case "CheckLoad2":
  844. lock (_locker)
  845. {
  846. RobotArmEnum arm = (RobotArmEnum)param[1];
  847. int checkLoadStation = 19;
  848. _lstHandler.AddLast(new RobotSiasunPhoenixBCheckLoadHandler(this, checkLoadStation, arm, _scHomeTimeout.IntValue * 2));
  849. }
  850. break;
  851. default:
  852. break;
  853. }
  854. return true;
  855. }
  856. protected override bool fStartSetParameters(object[] param)
  857. {
  858. if (param.Length < 1) return false;
  859. string readcommand = param[0].ToString();
  860. switch (readcommand)
  861. {
  862. case "SetLoad":
  863. lock (_locker)
  864. {
  865. RobotArmEnum arm = (RobotArmEnum)param[1];
  866. bool.TryParse(param[2].ToString(), out bool isOn);
  867. _lstHandler.AddLast(new RobotSiasunPhoenixBSetLoadHandler(this, arm, isOn));
  868. }
  869. break;
  870. default:
  871. break;
  872. }
  873. return true;
  874. }
  875. protected override bool fStartTransferWafer(object[] param)
  876. {
  877. return true;
  878. }
  879. protected override bool fStartUnGrip(object[] param)
  880. {
  881. return true;
  882. }
  883. protected override bool fStartGrip(object[] param)
  884. {
  885. return true;
  886. }
  887. //(arm, module, slot, isRetract, isZaxisDown)
  888. protected override bool fStartGoTo(object[] param)
  889. {
  890. try
  891. {
  892. RobotArmEnum arm = (RobotArmEnum)param[0];
  893. ModuleName module = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  894. if (arm == RobotArmEnum.Blade1)
  895. Blade1Target = module;
  896. if (arm == RobotArmEnum.Blade2)
  897. Blade2Target = module;
  898. int slot = 1;
  899. if (param.Length >= 3)
  900. slot = (int)param[2] + 1;
  901. if (BladeSlots == 1)
  902. {
  903. module = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  904. if (arm == RobotArmEnum.Blade1)
  905. Blade1Target = module;
  906. if (arm == RobotArmEnum.Blade2)
  907. Blade2Target = module;
  908. if (param.Length >= 3)
  909. slot = (int)param[2] + 1;
  910. }
  911. else if (BladeSlots == 2)
  912. {
  913. module = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  914. if (arm == RobotArmEnum.Blade1)
  915. Blade1Target = module;
  916. if (arm == RobotArmEnum.Blade2)
  917. Blade2Target = module;
  918. slot = (int)param[2] / 2 + 1;
  919. }
  920. bool isRetract = true;
  921. bool isZaxisDown = true;
  922. if (param.Length >= 5)
  923. {
  924. bool.TryParse(param[3].ToString(), out isRetract);
  925. bool.TryParse(param[4].ToString(), out isZaxisDown);
  926. }
  927. MoveInfo = new RobotMoveInfo()
  928. {
  929. Action = RobotAction.Moving,
  930. ArmTarget = arm == RobotArmEnum.Blade1 ? RobotArm.ArmA : RobotArm.ArmB,
  931. BladeTarget = (CmdRobotArm == RobotArmEnum.Upper ? "ArmB" : "ArmA") + "." + $"{(isRetract ? ModuleName.System : module)}",
  932. };
  933. int station = 0;
  934. if (!_moduleAssociateStationDic.ContainsKey(module.ToString()))
  935. {
  936. EV.PostAlarmLog("Robot", "Invalid Paramter.");
  937. return false;
  938. }
  939. station = _moduleAssociateStationDic[module.ToString()];
  940. lock (_locker)
  941. {
  942. _lstHandler.AddLast(new RobotSiasunPhoenixBGotoHandler(this, module, slot, arm, isRetract, isZaxisDown, _scMotionTimeout.IntValue));
  943. }
  944. }
  945. catch (Exception ex)
  946. {
  947. LOG.Write(ex);
  948. return false;
  949. }
  950. return true;
  951. }
  952. protected override bool fStartMapWafer(object[] param)
  953. {
  954. return false;
  955. }
  956. protected override bool fStartSwapWafer(object[] param)
  957. {
  958. return false;
  959. }
  960. //(arm, module, slot, ro, to)
  961. protected override bool fStartPlaceWafer(object[] param)
  962. {
  963. try
  964. {
  965. RobotArmEnum arm = (RobotArmEnum)param[0];
  966. ModuleName module = ModuleName.System;
  967. int slot = 1;
  968. if (param.Length >= 3)
  969. slot = (int)param[2] + 1;
  970. if (BladeSlots == 1)
  971. {
  972. module = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  973. if (arm == RobotArmEnum.Blade1)
  974. Blade1Target = module;
  975. if (arm == RobotArmEnum.Blade2)
  976. Blade2Target = module;
  977. if (param.Length >= 3)
  978. slot = (int)param[2] + 1;
  979. }
  980. else if (BladeSlots == 2)
  981. {
  982. var paramArray = param[1].ToString().Split('.');
  983. module = (ModuleName)Enum.Parse(typeof(ModuleName), paramArray[0].ToString());
  984. if (arm == RobotArmEnum.Blade1)
  985. Blade1Target = module;
  986. if (arm == RobotArmEnum.Blade2)
  987. Blade2Target = module;
  988. if (paramArray.Length > 1)
  989. {
  990. slot = (int)param[2] / 2 + 1;
  991. }
  992. }
  993. int ro = 0;
  994. int to = 0;
  995. if (param.Length >= 5)
  996. {
  997. int.TryParse(param[3].ToString(), out ro);
  998. int.TryParse(param[4].ToString(), out to);
  999. }
  1000. bool isDisableInterlock = _disabledIntlkModules.Contains(module);
  1001. MoveInfo = new RobotMoveInfo()
  1002. {
  1003. Action = RobotAction.Moving,
  1004. ArmTarget = arm == RobotArmEnum.Blade1 ? RobotArm.ArmA : RobotArm.ArmB,
  1005. BladeTarget = (CmdRobotArm == RobotArmEnum.Upper ? "ArmB" : "ArmA") + "." + $"{module}",
  1006. };
  1007. lock (_locker)
  1008. {
  1009. _lstHandler.AddLast(new RobotSiasunPhoenixBPlaceHandler(this,
  1010. ModuleHelper.IsLoadLock(module) ? param[1].ToString() : module.ToString(),
  1011. slot, arm, ro, to, _scMotionTimeout.IntValue, isDisableInterlock));
  1012. }
  1013. }
  1014. catch (Exception ex)
  1015. {
  1016. LOG.Write(ex);
  1017. return false;
  1018. }
  1019. return true;
  1020. }
  1021. //(arm, module, slot, ro, to)
  1022. protected override bool fStartPickWafer(object[] param)
  1023. {
  1024. try
  1025. {
  1026. RobotArmEnum arm = (RobotArmEnum)param[0];
  1027. ModuleName module = ModuleName.System;
  1028. int slot = 1;
  1029. if (param.Length >= 3)
  1030. slot = (int)param[2] + 1;
  1031. if (BladeSlots == 1)
  1032. {
  1033. module = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  1034. if (arm == RobotArmEnum.Blade1)
  1035. Blade1Target = module;
  1036. if (arm == RobotArmEnum.Blade2)
  1037. Blade2Target = module;
  1038. if (param.Length >= 3)
  1039. slot = (int)param[2] + 1;
  1040. }
  1041. else if (BladeSlots == 2)
  1042. {
  1043. var paramArray = param[1].ToString().Split('.');
  1044. module = (ModuleName)Enum.Parse(typeof(ModuleName), paramArray[0].ToString());
  1045. if (arm == RobotArmEnum.Blade1)
  1046. Blade1Target = module;
  1047. if (arm == RobotArmEnum.Blade2)
  1048. Blade2Target = module;
  1049. if (paramArray.Length > 1)
  1050. {
  1051. slot = (int)param[2] / 2 + 1;
  1052. }
  1053. }
  1054. float ro = 0;
  1055. float to = 0;
  1056. if (param.Length >= 5)
  1057. {
  1058. float.TryParse(param[3].ToString(), out ro);
  1059. float.TryParse(param[4].ToString(), out to);
  1060. }
  1061. bool isDisableInterlock = _disabledIntlkModules.Contains(module);
  1062. MoveInfo = new RobotMoveInfo()
  1063. {
  1064. Action = RobotAction.Picking,
  1065. ArmTarget = arm == RobotArmEnum.Blade1 ? RobotArm.ArmA : RobotArm.ArmB,
  1066. BladeTarget = (CmdRobotArm == RobotArmEnum.Upper ? "ArmB" : "ArmA") + "." + $"{module}",
  1067. };
  1068. lock (_locker)
  1069. {
  1070. _lstHandler.AddLast(new RobotSiasunPhoenixBPickHandler(this,
  1071. ModuleHelper.IsLoadLock(module) ? param[1].ToString() : module.ToString(),
  1072. slot, arm, (int)ro, (int)to, _scMotionTimeout.IntValue, isDisableInterlock));
  1073. }
  1074. }
  1075. catch (Exception ex)
  1076. {
  1077. LOG.Write(ex);
  1078. return false;
  1079. }
  1080. return true;
  1081. }
  1082. protected override bool fPlaceComplete(object[] param)
  1083. {
  1084. Blade1Target = ModuleName.System;
  1085. Blade2Target = ModuleName.System;
  1086. RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
  1087. ModuleName sourcemodule;
  1088. int Sourceslotindex;
  1089. if (!int.TryParse(CurrentParamter[2].ToString(), out Sourceslotindex)) return false;
  1090. if (BladeSlots == 1)
  1091. {
  1092. if (!Enum.TryParse(CurrentParamter[1].ToString(), out sourcemodule)) return false;
  1093. if (arm == RobotArmEnum.Blade1)
  1094. WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, Sourceslotindex);
  1095. if (arm == RobotArmEnum.Blade2)
  1096. WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, Sourceslotindex);
  1097. }
  1098. else if (BladeSlots == 2)
  1099. {
  1100. var array = CurrentParamter[1].ToString().Split('.');
  1101. if (!Enum.TryParse(array[0].ToString(), out sourcemodule)) return false;
  1102. if (ModuleHelper.IsPm(sourcemodule))
  1103. {
  1104. if (arm == RobotArmEnum.Blade1)
  1105. {
  1106. WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, 0);
  1107. WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, 1);
  1108. }
  1109. if (arm == RobotArmEnum.Blade2)
  1110. {
  1111. WaferManager.Instance.WaferMoved(RobotModuleName, 2, sourcemodule, 0);
  1112. WaferManager.Instance.WaferMoved(RobotModuleName, 3, sourcemodule, 1);
  1113. }
  1114. }
  1115. if (ModuleHelper.IsLoadLock(sourcemodule))
  1116. {
  1117. if (arm == RobotArmEnum.Blade1)
  1118. {
  1119. WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, Sourceslotindex / 2 * 2);
  1120. WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, Sourceslotindex / 2 * 2 + 1);
  1121. }
  1122. if (arm == RobotArmEnum.Blade2)
  1123. {
  1124. WaferManager.Instance.WaferMoved(RobotModuleName, 2, sourcemodule, Sourceslotindex / 2 * 2);
  1125. WaferManager.Instance.WaferMoved(RobotModuleName, 3, sourcemodule, Sourceslotindex / 2 * 2 + 1);
  1126. }
  1127. }
  1128. }
  1129. return base.fPlaceComplete(param);
  1130. }
  1131. protected override bool fPickComplete(object[] param)
  1132. {
  1133. Blade1Target = ModuleName.System;
  1134. Blade2Target = ModuleName.System;
  1135. RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
  1136. ModuleName sourcemodule;
  1137. int SourceslotIndex;
  1138. if (!int.TryParse(CurrentParamter[2].ToString(), out SourceslotIndex)) return false;
  1139. if (BladeSlots == 1)
  1140. {
  1141. if (!Enum.TryParse(CurrentParamter[1].ToString(), out sourcemodule)) return false;
  1142. if (arm == RobotArmEnum.Blade1)
  1143. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 0);
  1144. if (arm == RobotArmEnum.Blade2)
  1145. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 1);
  1146. }
  1147. else if (BladeSlots == 2)
  1148. {
  1149. var array = CurrentParamter[1].ToString().Split('.');
  1150. if (!Enum.TryParse(array[0].ToString(), out sourcemodule)) return false;
  1151. if (ModuleHelper.IsPm(sourcemodule))
  1152. {
  1153. if (arm == RobotArmEnum.Blade1)
  1154. {
  1155. WaferManager.Instance.WaferMoved(sourcemodule, 0, RobotModuleName, 0);
  1156. WaferManager.Instance.WaferMoved(sourcemodule, 1, RobotModuleName, 1);
  1157. }
  1158. if (arm == RobotArmEnum.Blade2)
  1159. {
  1160. WaferManager.Instance.WaferMoved(sourcemodule, 0, RobotModuleName, 2);
  1161. WaferManager.Instance.WaferMoved(sourcemodule, 1, RobotModuleName, 3);
  1162. }
  1163. }
  1164. if (ModuleHelper.IsLoadLock(sourcemodule))
  1165. {
  1166. if (arm == RobotArmEnum.Blade1)
  1167. {
  1168. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex / 2 * 2, RobotModuleName, 0);
  1169. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex / 2 * 2 + 1, RobotModuleName, 1);
  1170. }
  1171. if (arm == RobotArmEnum.Blade2)
  1172. {
  1173. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex / 2 * 2, RobotModuleName, 2);
  1174. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex / 2 * 2 + 1, RobotModuleName, 3);
  1175. }
  1176. }
  1177. }
  1178. return base.fPickComplete(param);
  1179. }
  1180. protected override bool fResetToReady(object[] param)
  1181. {
  1182. return true;
  1183. }
  1184. protected override bool fReset(object[] param)
  1185. {
  1186. _trigError.RST = true;
  1187. _connection.SetCommunicationError(false, "");
  1188. _trigCommunicationError.RST = true;
  1189. //_enableLog = SC.GetValue<bool>($"{ScBasePath}.{Name}.EnableLogMessage");
  1190. _trigRetryConnect.RST = true;
  1191. if (_isAlarm)
  1192. {
  1193. //lock (_locker)
  1194. //{
  1195. // _lstHandler.AddLast(new RobotSiasunPhoenixBResetHandler(this));
  1196. //}
  1197. //Thread.Sleep(100);
  1198. CheckToPostMessage((int)RobotMsg.ActionDone);
  1199. }
  1200. IsBusy = false;
  1201. return true;
  1202. }
  1203. protected override bool fMonitorReset(object[] param)
  1204. {
  1205. IsBusy = false;
  1206. return true;
  1207. }
  1208. protected override bool fStartInit(object[] param)
  1209. {
  1210. lock (_locker)
  1211. {
  1212. _lstHandler.AddLast(new RobotSiasunPhoenixBSetCommunicationEchoHandler(this, false));
  1213. if (!SevoOnOff)
  1214. {
  1215. _lstHandler.AddLast(new RobotSiasunPhoenixBSevoOnOffHandler(this, true));
  1216. }
  1217. _lstHandler.AddLast(new RobotSiasunPhoenixBHomeAxisHandler(this, _scHomeTimeout.IntValue));
  1218. }
  1219. return true;
  1220. }
  1221. protected override bool fError(object[] param)
  1222. {
  1223. return true;
  1224. }
  1225. protected override bool fStartExtendForPick(object[] param)
  1226. {
  1227. try
  1228. {
  1229. RobotArmEnum arm = (RobotArmEnum)param[0];
  1230. ModuleName module = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  1231. if (arm == RobotArmEnum.Blade1)
  1232. Blade1Target = module;
  1233. if (arm == RobotArmEnum.Blade2)
  1234. Blade2Target = module;
  1235. int slot = 1;
  1236. if (param.Length >= 3)
  1237. slot = (int)param[2] + 1;
  1238. int station = 0;
  1239. if (!_moduleAssociateStationDic.ContainsKey(module.ToString()))
  1240. {
  1241. EV.PostAlarmLog("Robot", "Invalid Paramter.");
  1242. return false;
  1243. }
  1244. station = _moduleAssociateStationDic[module.ToString()];
  1245. MoveInfo = new RobotMoveInfo()
  1246. {
  1247. Action = RobotAction.Moving,
  1248. ArmTarget = arm == RobotArmEnum.Blade1 ? RobotArm.ArmA : RobotArm.ArmB,
  1249. BladeTarget = (CmdRobotArm == RobotArmEnum.Upper ? "ArmB" : "ArmA") + "." + $"{module}",
  1250. };
  1251. lock (_locker)
  1252. {
  1253. _lstHandler.AddLast(new RobotSiasunPhoenixBPickExtendHandler(this, module, slot, arm, 0, 0, _scMotionTimeout.IntValue));
  1254. }
  1255. }
  1256. catch (Exception ex)
  1257. {
  1258. LOG.Write(ex);
  1259. return false;
  1260. }
  1261. return true;
  1262. }
  1263. protected override bool fStartExtendForPlace(object[] param)
  1264. {
  1265. try
  1266. {
  1267. RobotArmEnum arm = (RobotArmEnum)param[0];
  1268. ModuleName module = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  1269. if (arm == RobotArmEnum.Blade1)
  1270. Blade1Target = module;
  1271. if (arm == RobotArmEnum.Blade2)
  1272. Blade2Target = module;
  1273. int slot = 1;
  1274. if (param.Length >= 3)
  1275. slot = (int)param[2] + 1;
  1276. int station = 0;
  1277. if (!_moduleAssociateStationDic.ContainsKey(module.ToString()))
  1278. {
  1279. EV.PostAlarmLog("Robot", "Invalid Paramter.");
  1280. return false;
  1281. }
  1282. station = _moduleAssociateStationDic[module.ToString()];
  1283. MoveInfo = new RobotMoveInfo()
  1284. {
  1285. Action = RobotAction.Moving,
  1286. ArmTarget = arm == RobotArmEnum.Blade1 ? RobotArm.ArmA : RobotArm.ArmB,
  1287. BladeTarget = (CmdRobotArm == RobotArmEnum.Upper ? "ArmB" : "ArmA") + "." + $"{module}",
  1288. };
  1289. lock (_locker)
  1290. {
  1291. _lstHandler.AddLast(new RobotSiasunPhoenixBPlaceExtendHandler(this, module, slot, arm, 0, 0, _scMotionTimeout.IntValue));
  1292. }
  1293. }
  1294. catch (Exception ex)
  1295. {
  1296. LOG.Write(ex);
  1297. return false;
  1298. }
  1299. return true;
  1300. }
  1301. protected override bool fStartRetractFromPick(object[] param)
  1302. {
  1303. try
  1304. {
  1305. RobotArmEnum arm = (RobotArmEnum)param[0];
  1306. ModuleName module = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  1307. if (arm == RobotArmEnum.Blade1)
  1308. Blade1Target = module;
  1309. if (arm == RobotArmEnum.Blade2)
  1310. Blade2Target = module;
  1311. int slot = 1;
  1312. if (param.Length >= 3)
  1313. slot = (int)param[2] + 1;
  1314. int station = 0;
  1315. if (!_moduleAssociateStationDic.ContainsKey(module.ToString()))
  1316. {
  1317. EV.PostAlarmLog("Robot", "Invalid Paramter.");
  1318. return false;
  1319. }
  1320. station = _moduleAssociateStationDic[module.ToString()];
  1321. MoveInfo = new RobotMoveInfo()
  1322. {
  1323. Action = RobotAction.Moving,
  1324. ArmTarget = arm == RobotArmEnum.Blade1 ? RobotArm.ArmA : RobotArm.ArmB,
  1325. BladeTarget = (CmdRobotArm == RobotArmEnum.Upper ? "ArmB" : "ArmA") + "." + $"{ModuleName.System}",
  1326. };
  1327. lock (_locker)
  1328. {
  1329. _lstHandler.AddLast(new RobotSiasunPhoenixBPickRetractHandler(this, module, slot, arm, 0, 0, _scMotionTimeout.IntValue));
  1330. }
  1331. }
  1332. catch (Exception ex)
  1333. {
  1334. LOG.Write(ex);
  1335. return false;
  1336. }
  1337. return true;
  1338. }
  1339. protected override bool fStartRetractFromPlace(object[] param)
  1340. {
  1341. try
  1342. {
  1343. RobotArmEnum arm = (RobotArmEnum)param[0];
  1344. ModuleName module = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  1345. if (arm == RobotArmEnum.Blade1)
  1346. Blade1Target = module;
  1347. if (arm == RobotArmEnum.Blade2)
  1348. Blade2Target = module;
  1349. int slot = 1;
  1350. if (param.Length >= 3)
  1351. slot = (int)param[2] + 1;
  1352. int station = 0;
  1353. if (!_moduleAssociateStationDic.ContainsKey(module.ToString()))
  1354. {
  1355. EV.PostAlarmLog("Robot", "Invalid Paramter.");
  1356. return false;
  1357. }
  1358. station = _moduleAssociateStationDic[module.ToString()];
  1359. MoveInfo = new RobotMoveInfo()
  1360. {
  1361. Action = RobotAction.Moving,
  1362. ArmTarget = arm == RobotArmEnum.Blade1 ? RobotArm.ArmA : RobotArm.ArmB,
  1363. BladeTarget = (CmdRobotArm == RobotArmEnum.Upper ? "ArmB" : "ArmA") + "." + $"{ModuleName.System}",
  1364. };
  1365. lock (_locker)
  1366. {
  1367. _lstHandler.AddLast(new RobotSiasunPhoenixBPlaceRetractHandler(this, module, slot, arm, 0, 0, _scMotionTimeout.IntValue));
  1368. }
  1369. }
  1370. catch (Exception ex)
  1371. {
  1372. LOG.Write(ex);
  1373. return false;
  1374. }
  1375. return true;
  1376. }
  1377. public override RobotArmWaferStateEnum GetWaferState(RobotArmEnum arm)
  1378. {
  1379. if (arm == RobotArmEnum.Blade1)
  1380. {
  1381. return IsWaferPresenceOnBlade1 ? RobotArmWaferStateEnum.Present : RobotArmWaferStateEnum.Absent;
  1382. }
  1383. if (arm == RobotArmEnum.Blade2)
  1384. {
  1385. return IsWaferPresenceOnBlade2 ? RobotArmWaferStateEnum.Present : RobotArmWaferStateEnum.Absent;
  1386. }
  1387. return RobotArmWaferStateEnum.Unknown;
  1388. }
  1389. protected override bool fStop(object[] param)
  1390. {
  1391. lock (_locker)
  1392. {
  1393. IsBusy = false;
  1394. _connection.ForceClear();
  1395. _lstHandler.Clear();
  1396. }
  1397. return true;
  1398. }
  1399. protected override bool fAbort(object[] param)
  1400. {
  1401. lock (_locker)
  1402. {
  1403. IsBusy = false;
  1404. _connection.ForceClear();
  1405. _lstHandler.Clear();
  1406. _lstHandler.AddLast(new RobotSiasunPhoenixBHaltHandler(this));
  1407. }
  1408. return true;
  1409. }
  1410. #endregion
  1411. }
  1412. public class GotoArgument
  1413. {
  1414. /// <summary>
  1415. ///
  1416. /// </summary>
  1417. public int Station { get; set; }
  1418. /// <summary>
  1419. ///
  1420. /// </summary>
  1421. public string R { get; set; }
  1422. /// <summary>
  1423. ///
  1424. /// </summary>
  1425. public string Z { get; set; }
  1426. /// <summary>
  1427. ///
  1428. /// </summary>
  1429. public int Slot { get; set; }
  1430. /// <summary>
  1431. ///
  1432. /// </summary>
  1433. public string Arm { get; set; }
  1434. }
  1435. public class PickPlaceArgument
  1436. {
  1437. /// <summary>
  1438. ///
  1439. /// </summary>
  1440. public int Station { get; set; }
  1441. /// <summary>
  1442. ///
  1443. /// </summary>
  1444. public int Slot { get; set; }
  1445. /// <summary>
  1446. ///
  1447. /// </summary>
  1448. public string Arm { get; set; }
  1449. /// <summary>
  1450. ///
  1451. /// </summary>
  1452. public int Step { get; set; }
  1453. /// <summary>
  1454. ///
  1455. /// </summary>
  1456. public string Offset { get; set; }
  1457. }
  1458. }