JelC5000Robot.cs 94 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO.Ports;
  4. using System.Linq;
  5. using System.Text;
  6. using Aitex.Core.Common.DeviceData;
  7. using Aitex.Core.RT.Device;
  8. using Aitex.Core.RT.Device.Unit;
  9. using Aitex.Core.RT.Event;
  10. using Aitex.Core.RT.Log;
  11. using Aitex.Core.RT.OperationCenter;
  12. using Aitex.Core.RT.SCCore;
  13. using Aitex.Core.Util;
  14. using MECF.Framework.Common.Communications;
  15. using MECF.Framework.Common.Device.Bases;
  16. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Common;
  17. using Newtonsoft.Json;
  18. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  19. using MECF.Framework.Common.Equipment;
  20. using MECF.Framework.Common.SubstrateTrackings;
  21. using System.Threading;
  22. using Aitex.Core.Common;
  23. using Aitex.Core.RT.DataCenter;
  24. using System.Text.RegularExpressions;
  25. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  26. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  27. using MECF.Framework.Common.CommonData;
  28. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Flipper.FlipperBase;
  29. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.JEL
  30. {
  31. public class JelC5000Robot : RobotBaseDevice, IConnection
  32. {
  33. private int _bodyNumber;
  34. private string _robotModel; //T-00902H
  35. public int BodyNumber => SC.GetValue<int>($"{_scRoot}.{Name}.BodyNumber");
  36. private string _address = "";
  37. public string Address { get => _address; }
  38. private bool isSimulatorMode;
  39. private string _scRoot;
  40. private PeriodicJob _thread;
  41. protected JelC5000RobotConnection _connection;
  42. private R_TRIG _trigError = new R_TRIG();
  43. private R_TRIG _trigCommunicationError = new R_TRIG();
  44. private R_TRIG _trigRetryConnect = new R_TRIG();
  45. private R_TRIG _trigActionDone = new R_TRIG();
  46. protected LinkedList<HandlerBase> _lstMonitorHandler = new LinkedList<HandlerBase>();
  47. protected object _locker = new object();
  48. private bool _enableLog;
  49. public string PortName;
  50. public bool IsConnected { get; }
  51. public bool Connect()
  52. {
  53. return true;
  54. }
  55. private int _lowerArmWaferSensorIndex
  56. {
  57. get
  58. {
  59. if (SC.ContainsItem($"Robot.{RobotModuleName}.LowerArmWaferSensorIndex"))
  60. return SC.GetValue<int>($"Robot.{RobotModuleName}.LowerArmWaferSensorIndex");
  61. return 1;
  62. }
  63. }
  64. protected bool ResetBeforeCmd
  65. {
  66. get
  67. {
  68. if (SC.ContainsItem($"Robot.{RobotModuleName}.ResetBeforeCmd") && SC.GetValue<bool>($"Robot.{RobotModuleName}.ResetBeforeCmd"))
  69. return true;
  70. return false;
  71. }
  72. }
  73. public bool Disconnect()
  74. {
  75. return true;
  76. }
  77. public JelC5000Robot(string module, string name, string scRoot, string robotModel = "",int bladeCount = 2) : base(module, name,scRoot,bladeCount)
  78. {
  79. _robotModel = robotModel;
  80. isSimulatorMode = SC.ContainsItem("System.IsSimulatorMode") ? SC.GetValue<bool>("System.IsSimulatorMode") : false;
  81. _scRoot = scRoot;
  82. //base.Initialize();
  83. ResetPropertiesAndResponses();
  84. RegisterSpecialData();
  85. _enableLog = SC.GetValue<bool>($"{_scRoot}.{Name}.EnableLogMessage");
  86. //_bodyNumber = SC.GetValue<int>($"{_scRoot}.{Name}.BodyNumber");
  87. PortName = SC.GetStringValue($"{_scRoot}.{Name}.PortName");
  88. _connection = new JelC5000RobotConnection(this,PortName);
  89. _connection.IsEnableHandlerRetry = false;
  90. _connection.EnableLog(_enableLog);
  91. if (_connection.Connect())
  92. {
  93. EV.PostInfoLog(Module, $"{Module}.{Name} connected");
  94. }
  95. _thread = new PeriodicJob(5, OnTimer, $"{Module}.{Name} MonitorHandler", true);
  96. }
  97. protected override void SubscribeWaferLocation()
  98. {
  99. WaferManager.Instance.SubscribeLocation(Name, BladeCount);
  100. }
  101. #region Properties
  102. public JelAxisStatus JelC5000RobotStatus { get; private set; }
  103. public JelAxisStatus AxisStatus { get; private set; }
  104. public float XAxisPostion { get; private set; }
  105. public float ThetaAxisPostion { get; private set; }
  106. public float YAxisPostion { get; private set; }
  107. public float ZAxisPostion { get; private set; }
  108. public Int32[] AData { get; private set; } = new Int32[1000];
  109. public JelParameterData[] RobotParameters { get; private set; } = new JelParameterData[2000];
  110. public string ReadBankNumber { get; set; } = "";
  111. public int ReadCassetNumber { get; set; }
  112. public int ReadSlotNumber { get; set; }
  113. public bool IsVacuumSensorON { get; private set; } = true;
  114. public bool IsEchoBack { get; private set; }
  115. public JelCommandStatus CurrentCompoundCommandStatus { get; set; }
  116. public string StopPostionOfCompoundCommand { get; private set; }
  117. public string[] MainRoutines { get; private set; } = new string[320];
  118. public string[] SubRoutines { get; private set; } = new string[16];
  119. public string CurrentReadRoutine { get; private set; }
  120. public int HighSpeed { get; private set; }
  121. public int LowSpeed { get; private set; }
  122. public int DomainOfAccDec { get; private set; }
  123. public int AccDecSpeed { get; private set; }
  124. public int MagnificationOfFrequency { get; private set; }
  125. public int PulsePostionOfManualSlowDown { get; private set; }
  126. public int CurrentReadSpeedData { get; private set; }
  127. public Int32 CurrentReadAData { get; private set; }
  128. public Int32 ReadPosXAxisPostion { get; private set; }
  129. public Int32 ReadPosYAxisPostion { get; private set; }
  130. public Int32 ReadPosThetaAxisPostion { get; private set; }
  131. public Int32 ReadPosZAxisPostion { get; private set; }
  132. public float ReadParameterMin { get; private set; }
  133. public float ReadParameterMax { get; private set; }
  134. public float ReadParameterValue { get; private set; }
  135. //Mapping Data
  136. public float MappingFirstSlotPosition { get; private set; }
  137. public float MappingTopSlotPostion { get; private set; }
  138. public int MappingSlotsNumber { get; private set; }
  139. public float MappingMinDetectWidth { get; private set; }
  140. public float MappingMaxDetectWidth { get; private set; }
  141. public float MappingGateWidth { get; private set; }
  142. public float MappingStopPostion { get; private set; }
  143. public float MappingSpeed { get; private set; }
  144. public bool IsMappingSensorON { get; private set; }
  145. public string MappingWaferResult { get; private set; } = string.Empty;
  146. public string MappingWidthResult { get; private set; } = string.Empty;
  147. public override bool Blade1Enable => true;
  148. public override bool Blade2Enable => false;
  149. #endregion
  150. #region ParseHandler
  151. public void ParseData(string command,string parameter,string data)
  152. {
  153. try
  154. {
  155. string datavalue = data.Replace($"${BodyNumber}", "").Replace("\r", "");
  156. if(command == "SPA")
  157. {
  158. CurrentReadSpeedData = Convert.ToInt32(datavalue);
  159. }
  160. if (command == "") ParseRobotStatus(datavalue); // Read Robot Status
  161. if (command == "6" || command == "6M") ParseRobotPostion(parameter, datavalue); //Read Postion Data
  162. if (command == "A") // Read A data
  163. {
  164. int _index;
  165. if (!int.TryParse(parameter.Replace("D", ""), out _index)) return;
  166. AData[_index] = Convert.ToInt32(datavalue);
  167. CurrentReadAData = Convert.ToInt32(datavalue);
  168. }
  169. if (command == "BC")
  170. {
  171. ReadBankNumber = datavalue;
  172. }
  173. if (command == "WCP")
  174. {
  175. string[] strvalues = datavalue.Split(',');
  176. ReadCassetNumber = Convert.ToInt32(strvalues[0]);
  177. ReadSlotNumber = Convert.ToInt32(strvalues[1]);
  178. }
  179. if (command == $"CS{_lowerArmWaferSensorIndex}")
  180. {
  181. IsVacuumSensorON = datavalue == "1";
  182. }
  183. if (command == "DTD")
  184. {
  185. int _index;
  186. if (!int.TryParse(parameter, out _index)) return;
  187. string[] paradata = datavalue.Split(',');
  188. //if (paradata.Length < 3) return;
  189. RobotParameters[_index].Value = paradata[0];
  190. RobotParameters[_index].MinValue = paradata[1];
  191. RobotParameters[_index].MaxValue = paradata[2];
  192. }
  193. if (command == "EE")
  194. {
  195. IsEchoBack = datavalue == "E";
  196. }
  197. if (command == "G")
  198. {
  199. if (datavalue == "0") CurrentCompoundCommandStatus = JelCommandStatus.NormalEnd;
  200. if (datavalue == "1") CurrentCompoundCommandStatus = JelCommandStatus.InExecution;
  201. if (datavalue == "P") CurrentCompoundCommandStatus = JelCommandStatus.InPause;
  202. if (datavalue == "E") CurrentCompoundCommandStatus = JelCommandStatus.InError;
  203. }
  204. if (command == "GER")
  205. {
  206. LOG.Write("Compaund command stop postion:" + datavalue);
  207. }
  208. if (command == "IR")
  209. {
  210. int _index;
  211. if (!int.TryParse(parameter, out _index)) return;
  212. if (_index < 0 || _index > 319) return;
  213. MainRoutines[_index] = datavalue;
  214. CurrentReadRoutine = datavalue;
  215. }
  216. if (command == "IRS")
  217. {
  218. int _index = Convert.ToInt32(parameter, 16);
  219. if (_index < 0 || _index > 15) return;
  220. SubRoutines[_index] = datavalue;
  221. CurrentReadRoutine = datavalue;
  222. }
  223. if (command == "O")
  224. {
  225. CurrentReadSpeedData = Convert.ToInt32(datavalue);
  226. if (parameter == "H")
  227. HighSpeed = Convert.ToInt32(datavalue);
  228. if (parameter == "L")
  229. LowSpeed = Convert.ToInt32(datavalue);
  230. if (parameter == "S")
  231. DomainOfAccDec = Convert.ToInt32(datavalue);
  232. if (parameter == "G")
  233. AccDecSpeed = Convert.ToInt32(datavalue);
  234. if (parameter == "X")
  235. MagnificationOfFrequency = Convert.ToInt32(datavalue);
  236. if (parameter == "D")
  237. PulsePostionOfManualSlowDown = Convert.ToInt32(datavalue);
  238. }
  239. if (command == "PSD")
  240. {
  241. string[] stradata = datavalue.Split(',');
  242. ReadPosXAxisPostion = Convert.ToInt32(stradata[0].ToString());
  243. ReadPosYAxisPostion = Convert.ToInt32(stradata[1].ToString());
  244. ReadPosThetaAxisPostion = Convert.ToInt32(stradata[2].ToString());
  245. ReadPosZAxisPostion = Convert.ToInt32(stradata[3].ToString());
  246. }
  247. if (command == "DTD")
  248. {
  249. string[] stradata = datavalue.Split(',');
  250. ReadParameterValue = Convert.ToSingle(stradata[0].ToString());
  251. ReadParameterMin = Convert.ToSingle(stradata[1].ToString());
  252. ReadParameterMax = Convert.ToSingle(stradata[2].ToString());
  253. }
  254. if (command == "WLO") // Obtaining the postion data of mapping 1st slot detected
  255. MappingFirstSlotPosition = Convert.ToSingle(datavalue);
  256. if(command == "WHI")
  257. MappingTopSlotPostion = Convert.ToSingle(datavalue);
  258. if(command == "WFC")
  259. MappingSlotsNumber = Convert.ToInt32(datavalue);
  260. if(command == "WWN")
  261. MappingMinDetectWidth = Convert.ToSingle(datavalue);
  262. if(command == "WWM")
  263. MappingMaxDetectWidth = Convert.ToSingle(datavalue);
  264. if(command == "WWG")
  265. MappingGateWidth = Convert.ToSingle(datavalue);
  266. if(command == "WEND")
  267. MappingStopPostion = Convert.ToSingle(datavalue);
  268. if(command == "WSP")
  269. MappingSpeed = Convert.ToSingle(datavalue);
  270. if(command == "WFK")
  271. {
  272. MappingWaferResult = datavalue;
  273. NotifySlotMapResult(CurrentInteractModule, datavalue.Replace(",", "").Replace("E", "?"));
  274. }
  275. if (command == "WFW")
  276. MappingWidthResult = datavalue;
  277. }
  278. catch(Exception ex)
  279. {
  280. LOG.Write($"Parse {command}.{parameter??parameter} data {data} error:" + ex.ToString());
  281. OnError($"Parse data error:{command}.{parameter ?? parameter} data {data}");
  282. }
  283. }
  284. private void ParseRobotStatus(string data)
  285. {
  286. if (data.Length < 2) return;
  287. int intRobostatus = Convert.ToInt16(data.ToArray()[0].ToString(), 16);
  288. if (intRobostatus == 0)
  289. JelC5000RobotStatus = (JelAxisStatus)Convert.ToInt16(data.ToArray()[0].ToString(), 16);
  290. if((intRobostatus & 0x1) == 0x1)
  291. {
  292. JelC5000RobotStatus = JelAxisStatus.InOperation;
  293. }
  294. if ((intRobostatus & 0x2) == 0x2)
  295. {
  296. JelC5000RobotStatus = JelAxisStatus.SensorError;
  297. OnError(JelC5000RobotStatus.ToString());
  298. }
  299. if ((intRobostatus & 0x4) == 0x4)
  300. {
  301. JelC5000RobotStatus = JelAxisStatus.SensorErrorOrStoppedByAlarm;
  302. OnError(JelC5000RobotStatus.ToString());
  303. }
  304. if ((intRobostatus & 0x8) == 0x8)
  305. {
  306. JelC5000RobotStatus = JelAxisStatus.CommandError;
  307. OnError(JelC5000RobotStatus.ToString());
  308. }
  309. if (data.ToArray()[1] == '0')
  310. AxisStatus = JelAxisStatus.NormalEnd;
  311. else
  312. AxisStatus = JelAxisStatus.InOperation;
  313. }
  314. private void ParseRobotPostion(string axis,string data)
  315. {
  316. float _floatvalue;
  317. if (!float.TryParse(data, out _floatvalue)) return;
  318. if (axis == "1")
  319. {
  320. PositionAxis1 = _floatvalue;
  321. }
  322. if (axis == "2")
  323. {
  324. PositionAxis2 = _floatvalue;
  325. }
  326. if (axis == "3")
  327. {
  328. PositionAxis3 = _floatvalue;
  329. }
  330. if (axis == "4")
  331. {
  332. PositionAxis4 = _floatvalue;
  333. }
  334. if (axis == "X")
  335. {
  336. XAxisPostion = _floatvalue;
  337. }
  338. if (axis == "Y")
  339. {
  340. YAxisPostion = _floatvalue;
  341. }
  342. if (axis == "U")
  343. {
  344. ThetaAxisPostion = _floatvalue;
  345. }
  346. if (axis == "Z")
  347. {
  348. ZAxisPostion = _floatvalue;
  349. }
  350. }
  351. #endregion
  352. private bool OnTimer()
  353. {
  354. try
  355. {
  356. if (!_connection.IsConnected || _connection.IsCommunicationError)
  357. {
  358. lock (_locker)
  359. {
  360. _lstMonitorHandler.Clear();
  361. }
  362. _trigRetryConnect.CLK = !_connection.IsConnected;
  363. if (_trigRetryConnect.Q)
  364. {
  365. _connection.SetPortAddress(SC.GetStringValue($"{_scRoot}.{Name}.PortName"));
  366. if (!_connection.Connect())
  367. {
  368. EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}.{Name}");
  369. }
  370. else
  371. {
  372. }
  373. }
  374. return true;
  375. }
  376. HandlerBase handler = null;
  377. DateTime dtstart = DateTime.Now;
  378. lock (_locker)
  379. {
  380. if(_lstMonitorHandler.Count > 0)
  381. {
  382. if (!_connection.IsBusy)
  383. {
  384. handler = _lstMonitorHandler.First.Value;
  385. _connection.Execute(handler);
  386. _lstMonitorHandler.RemoveFirst();
  387. }
  388. else
  389. {
  390. _connection.MonitorTimeout();
  391. _trigCommunicationError.CLK = _connection.IsCommunicationError;
  392. if (_trigCommunicationError.Q)
  393. {
  394. _lstMonitorHandler.Clear();
  395. OnError($"{Module}.{Name} communication error, {_connection.LastCommunicationError}");
  396. }
  397. }
  398. }
  399. }
  400. }
  401. catch (Exception ex)
  402. {
  403. LOG.Write(ex);
  404. }
  405. return true;
  406. }
  407. private void RegisterSpecialData()
  408. {
  409. DATA.Subscribe($"{Module}.{Name}.CurrentReadRoutine", () => CurrentReadRoutine);
  410. DATA.Subscribe($"{Module}.{Name}.CurrentReadSpeedData", () => CurrentReadSpeedData);
  411. DATA.Subscribe($"{Module}.{Name}.CurrentReadAData", () => CurrentReadAData);
  412. DATA.Subscribe($"{Module}.{Name}.IsVacuumSensorON", () => IsVacuumSensorON);
  413. DATA.Subscribe($"{Module}.{Name}.JelC5000RobotStatus", () => JelC5000RobotStatus.ToString());
  414. DATA.Subscribe($"{Module}.{Name}.AxisStatus", () => AxisStatus.ToString());
  415. DATA.Subscribe($"{Module}.{Name}.CurrentCompoundCommandStatus", () => CurrentCompoundCommandStatus.ToString());
  416. DATA.Subscribe($"{Module}.{Name}.ReadCassetNumber", () => ReadCassetNumber.ToString());
  417. DATA.Subscribe($"{Module}.{Name}.ReadSlotNumber", () => ReadSlotNumber.ToString());
  418. DATA.Subscribe($"{Module}.{Name}.ReadBankNumber", () => ReadBankNumber.ToString());
  419. DATA.Subscribe($"{Module}.{Name}.ReadPosXAxisPostion", () => ReadPosXAxisPostion);
  420. DATA.Subscribe($"{Module}.{Name}.ReadPosYAxisPostion", () => ReadPosYAxisPostion);
  421. DATA.Subscribe($"{Module}.{Name}.ReadPosZAxisPostion", () => ReadPosZAxisPostion);
  422. DATA.Subscribe($"{Module}.{Name}.ReadPosThetaAxisPostion", () => ReadPosThetaAxisPostion);
  423. DATA.Subscribe($"{Module}.{Name}.ReadParameterMax", () => ReadParameterMax.ToString());
  424. DATA.Subscribe($"{Module}.{Name}.ReadParameterMin", () => ReadParameterMin.ToString());
  425. DATA.Subscribe($"{Module}.{Name}.ReadParameterValue", () => ReadParameterValue.ToString());
  426. DATA.Subscribe($"{Module}.{Name}.MappingFirstSlotPosition", () => MappingFirstSlotPosition.ToString());
  427. DATA.Subscribe($"{Module}.{Name}.MappingGateWidth", () => MappingGateWidth.ToString());
  428. DATA.Subscribe($"{Module}.{Name}.MappingMaxDetectWidth", () => MappingMaxDetectWidth.ToString());
  429. DATA.Subscribe($"{Module}.{Name}.MappingMinDetectWidth", () => MappingMinDetectWidth.ToString());
  430. DATA.Subscribe($"{Module}.{Name}.MappingSlotsNumber", () => MappingSlotsNumber.ToString());
  431. DATA.Subscribe($"{Module}.{Name}.MappingSpeed", () => MappingSpeed.ToString());
  432. DATA.Subscribe($"{Module}.{Name}.MappingStopPostion", () => MappingStopPostion.ToString());
  433. DATA.Subscribe($"{Module}.{Name}.MappingTopSlotPostion", () => MappingTopSlotPostion.ToString());
  434. DATA.Subscribe($"{Module}.{Name}.IsMappingSensorON", () => IsMappingSensorON.ToString());
  435. DATA.Subscribe($"{Module}.{Name}.MappingWaferResult", () => MappingWaferResult.ToString());
  436. DATA.Subscribe($"{Module}.{Name}.MappingWidthResult", () => MappingWidthResult.ToString());
  437. DATA.Subscribe($"{Name}.RobotSpeed", () => CurrentReadSpeedData);
  438. DATA.Subscribe($"{Name}.CurrentReadRoutine", () => CurrentReadRoutine);
  439. DATA.Subscribe($"{Name}.CurrentReadSpeedData", () => CurrentReadSpeedData);
  440. DATA.Subscribe($"{Name}.CurrentReadAData", () => CurrentReadAData);
  441. DATA.Subscribe($"{Name}.IsVacuumSensorON", () => IsVacuumSensorON);
  442. DATA.Subscribe($"{Name}.JelC5000RobotStatus", () => JelC5000RobotStatus.ToString());
  443. DATA.Subscribe($"{Name}.AxisStatus", () => AxisStatus.ToString());
  444. DATA.Subscribe($"{Name}.CurrentCompoundCommandStatus", () => CurrentCompoundCommandStatus.ToString());
  445. DATA.Subscribe($"{Name}.ReadCassetNumber", () => ReadCassetNumber.ToString());
  446. DATA.Subscribe($"{Name}.ReadSlotNumber", () => ReadSlotNumber.ToString());
  447. DATA.Subscribe($"{Name}.ReadBankNumber", () => ReadBankNumber.ToString());
  448. DATA.Subscribe($"{Name}.ReadPosXAxisPostion", () => ReadPosXAxisPostion.ToString());
  449. DATA.Subscribe($"{Name}.ReadPosYAxisPostion", () => ReadPosYAxisPostion.ToString());
  450. DATA.Subscribe($"{Name}.ReadPosZAxisPostion", () => ReadPosZAxisPostion.ToString());
  451. DATA.Subscribe($"{Name}.ReadPosThetaAxisPostion", () => ReadPosThetaAxisPostion.ToString());
  452. DATA.Subscribe($"{Name}.XAxisPostion", () => XAxisPostion.ToString());
  453. DATA.Subscribe($"{Name}.YAxisPostion", () => YAxisPostion.ToString());
  454. DATA.Subscribe($"{Name}.ZAxisPostion", () => ZAxisPostion.ToString());
  455. DATA.Subscribe($"{Name}.ThetaAxisPostion", () => ThetaAxisPostion.ToString());
  456. DATA.Subscribe($"{Name}.ReadParameterMax", () => ReadParameterMax.ToString());
  457. DATA.Subscribe($"{Name}.ReadParameterMin", () => ReadParameterMin.ToString());
  458. DATA.Subscribe($"{Name}.ReadParameterValue", () => ReadParameterValue.ToString());
  459. DATA.Subscribe($"{Name}.MappingFirstSlotPosition", () => MappingFirstSlotPosition.ToString());
  460. DATA.Subscribe($"{Name}.MappingGateWidth", () => MappingGateWidth.ToString());
  461. DATA.Subscribe($"{Name}.MappingMaxDetectWidth", () => MappingMaxDetectWidth.ToString());
  462. DATA.Subscribe($"{Name}.MappingMinDetectWidth", () => MappingMinDetectWidth.ToString());
  463. DATA.Subscribe($"{Name}.MappingSlotsNumber", () => MappingSlotsNumber.ToString());
  464. DATA.Subscribe($"{Name}.MappingSpeed", () => MappingSpeed.ToString());
  465. DATA.Subscribe($"{Name}.MappingStopPostion", () => MappingStopPostion.ToString());
  466. DATA.Subscribe($"{Name}.MappingTopSlotPostion", () => MappingTopSlotPostion.ToString());
  467. DATA.Subscribe($"{Name}.IsMappingSensorON", () => IsMappingSensorON.ToString());
  468. DATA.Subscribe($"{Name}.MappingWaferResult", () => MappingWaferResult.ToString());
  469. DATA.Subscribe($"{Name}.MappingWidthResult", () => MappingWidthResult.ToString());
  470. }
  471. private void ResetPropertiesAndResponses()
  472. {
  473. }
  474. protected override bool fReset(object[] param)
  475. {
  476. _trigError.RST = true;
  477. _connection.SetCommunicationError(false, "");
  478. _trigCommunicationError.RST = true;
  479. _enableLog = SC.GetValue<bool>($"{_scRoot}.{Name}.EnableLogMessage");
  480. _connection.EnableLog(_enableLog);
  481. _trigRetryConnect.RST = true;
  482. _lstMonitorHandler.Clear();
  483. //_lstMonitorHandler.Clear();
  484. _connection.ForceClear();
  485. lock (_locker)
  486. {
  487. _lstMonitorHandler.AddLast(new JelC5000RobotRawCommandHandler(this, $"RD"));
  488. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, ""));
  489. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "BC")); // Read bank number
  490. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WCP")); // Read Cassette Number
  491. }
  492. return true;
  493. }
  494. protected override bool fMonitorReset(object[] param)
  495. {
  496. IsBusy = false;
  497. if (JelC5000RobotStatus == JelAxisStatus.NormalEnd
  498. && (AxisStatus == JelAxisStatus.NormalEnd)
  499. && _lstMonitorHandler.Count == 0
  500. && !_connection.IsBusy)
  501. {
  502. IsBusy = false;
  503. return true;
  504. }
  505. if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
  506. _connection.Execute(new JelC5000RobotReadHandler(this, ""));
  507. return false;
  508. }
  509. protected override bool fStartMove(object[] param)
  510. {
  511. if (param.Length < 4) return false;
  512. int axis,intdirect;
  513. if (!int.TryParse(param[0].ToString(), out axis)) return false;
  514. if (axis > 4 || axis < 0) return false;
  515. if (!int.TryParse(param[1].ToString(), out intdirect)) return false;
  516. if (intdirect > 1 || intdirect < 0) return false;
  517. RobotMoveDirectionEnum direction = (RobotMoveDirectionEnum)Convert.ToInt16(param[1].ToString());
  518. uint instance;
  519. if (!uint.TryParse(param[2].ToString(), out instance)) return false;
  520. if (instance > 8388607) instance = 8388607;
  521. string movebasetype = Regex.Replace(param[3].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
  522. if (movebasetype != "0" && movebasetype != "1") return false;
  523. string commandstr = "";
  524. if (movebasetype == "0") commandstr = "3";
  525. if(movebasetype == "1")
  526. {
  527. if (direction == RobotMoveDirectionEnum.Fwd) commandstr = "4";
  528. else commandstr = "5";
  529. }
  530. if (string.IsNullOrEmpty(commandstr)) return false;
  531. string speedtype = string.Empty;
  532. if (param.Length > 4)
  533. speedtype = Regex.Replace(param[4].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
  534. if (speedtype != "" && speedtype != "M" && speedtype != "L") return false;
  535. lock (_locker)
  536. {
  537. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "2", instance.ToString()));
  538. _lstMonitorHandler.AddLast(new JelC5000RobotMoveHandler(this, commandstr + "M", axis.ToString() + speedtype));
  539. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, ""));
  540. }
  541. return true;
  542. }
  543. protected override bool fMonitorMoving(object[] param)
  544. {
  545. if (JelC5000RobotStatus == JelAxisStatus.NormalEnd
  546. && (AxisStatus == JelAxisStatus.NormalEnd)
  547. && _lstMonitorHandler.Count == 0
  548. && !_connection.IsBusy)
  549. {
  550. IsBusy = false;
  551. return true;
  552. }
  553. if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
  554. _connection.Execute(new JelC5000RobotReadHandler(this, ""));
  555. return false;
  556. }
  557. protected override bool fStartInit(object[] param)
  558. {
  559. //string speedtype = string.Empty;
  560. //if (param != null && param.Length >0)
  561. // speedtype = Regex.Replace(param[0].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
  562. //if (speedtype != "" && speedtype != "M" && speedtype != "L") return false;
  563. _dtActionStart = DateTime.Now;
  564. int compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.InitCmdNO");
  565. int Robotspeed = SC.GetValue<int>($"Robot.{Name}.RobotSpeed");
  566. if (Robotspeed < 0)
  567. Robotspeed = 0;
  568. if (Robotspeed > 99)
  569. Robotspeed = 99;
  570. lock (_locker)
  571. {
  572. _lstMonitorHandler.AddLast(new JelC5000RobotRawCommandHandler(this, $"RD"));
  573. _lstMonitorHandler.AddLast(new JelC5000RobotCompaundCommandHandler(this, compaundcmdNO.ToString()));
  574. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, ""));
  575. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "G"));
  576. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
  577. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "BC")); // Read bank number
  578. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WCP")); // Read Cassette Number
  579. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "1"));
  580. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "2"));
  581. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "3"));
  582. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "4"));
  583. //_lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "X"));
  584. //_lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "Y"));
  585. //_lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "U"));
  586. //_lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "Z"));
  587. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "SPA", Robotspeed.ToString()));
  588. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "SPA"));
  589. }
  590. return true;
  591. }
  592. protected override bool fMonitorInit(object[] param)
  593. {
  594. IsBusy = false;
  595. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(RobotCommandTimeout))
  596. {
  597. HandlerError("InitTimeout");
  598. return true;
  599. }
  600. if (_lstMonitorHandler.Count ==0 && !_connection.IsBusy)
  601. {
  602. if (CurrentCompoundCommandStatus == JelCommandStatus.NormalEnd &&
  603. JelC5000RobotStatus == JelAxisStatus.NormalEnd
  604. && AxisStatus == JelAxisStatus.NormalEnd)
  605. {
  606. Blade1Target = ModuleName.System;
  607. Blade2Target = ModuleName.System;
  608. CmdTarget = ModuleName.System;
  609. MoveInfo = new RobotMoveInfo()
  610. {
  611. Action = RobotAction.Picking,
  612. ArmTarget = CmdRobotArm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  613. BladeTarget = BuildBladeTarget(),
  614. };
  615. if(IsVacuumSensorON && WaferManager.Instance.CheckNoWafer(RobotModuleName,0))
  616. {
  617. EV.PostAlarmLog("Robot", $"There's unknown wafer on {RobotModuleName}.");
  618. WaferManager.Instance.CreateWafer(RobotModuleName, 0, WaferStatus.Normal);
  619. }
  620. if (!IsVacuumSensorON && WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))
  621. {
  622. EV.PostAlarmLog("Robot", $"There's a wafer on {RobotModuleName} but robot didn't detect.");
  623. }
  624. return true;
  625. }
  626. if (CurrentCompoundCommandStatus != JelCommandStatus.NormalEnd)
  627. {
  628. if (CurrentCompoundCommandStatus == JelCommandStatus.InError)
  629. {
  630. OnError("Init Compaund command execution error");
  631. return false;
  632. }
  633. }
  634. }
  635. return false;
  636. }
  637. protected override bool fStartReadData(object[] param)
  638. {
  639. if(param.Length <1) return false;
  640. string readcommand = param[0].ToString();
  641. switch(readcommand)
  642. {
  643. case "CurrentStatus":
  644. lock (_locker)
  645. {
  646. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, ""));
  647. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
  648. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "G")); // Read out the compaund command status
  649. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "BC")); // Read bank number
  650. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WCP")); // Read Cassette Number
  651. }
  652. break;
  653. case "CurrentPositionData":
  654. lock(_locker)
  655. {
  656. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "1"));
  657. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "2"));
  658. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "3"));
  659. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "4"));
  660. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "X"));
  661. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "Y"));
  662. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "U"));
  663. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "6", "Z"));
  664. }
  665. break;
  666. case "CompaundCommand":
  667. if (param.Length < 3) return false;
  668. string routineselction = param[1].ToString();
  669. if(routineselction == "MainRoutine")
  670. {
  671. int routineno;
  672. if (!int.TryParse(param[2].ToString(), out routineno)) return false;
  673. if (routineno > 319 || routineno < 1) return false;
  674. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "IR",routineno.ToString().PadLeft(3,'0')));
  675. }
  676. if (routineselction == "SubRoutine")
  677. {
  678. char routineno;
  679. if (!char.TryParse(param[2].ToString(), out routineno)) return false;
  680. if (routineno > 'F' || routineno < 1) return false;
  681. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "IRS", routineno.ToString()));
  682. }
  683. break;
  684. case "RobotSpeed":
  685. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "SPA"));
  686. break;
  687. case "AData":
  688. if (param.Length < 2) return false;
  689. int datano;
  690. if (!int.TryParse(param[1].ToString(), out datano)) return false;
  691. if (datano < 0 || datano > 999) return false;
  692. lock(_locker)
  693. {
  694. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "A", datano.ToString("D3")+"D"));
  695. }
  696. break;
  697. case "EPData":
  698. if (param.Length < 2) return false;
  699. if (param[1].ToString() == "AData")
  700. {
  701. lock (_locker)
  702. {
  703. _lstMonitorHandler.AddLast(new JelC5000RobotRawCommandHandler (this, $"AL"));
  704. }
  705. }
  706. break;
  707. case "PositionData":
  708. if (param.Length < 2) return false;
  709. int posNO;
  710. if (!int.TryParse(param[1].ToString(), out posNO)) return false;
  711. if (posNO > 999 || posNO < 0) return false;
  712. lock (_locker)
  713. {
  714. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "PSD", posNO.ToString("D3")));
  715. }
  716. break;
  717. case "RobotParameter":
  718. if (param.Length < 2) return false;
  719. uint parano;
  720. if(!uint.TryParse(param[1].ToString(), out parano)) return false;
  721. lock(_locker)
  722. {
  723. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "DTD", parano.ToString()));
  724. }
  725. break;
  726. case "MappingData":
  727. lock(_locker)
  728. {
  729. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WLO"));
  730. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WHI"));
  731. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WFC"));
  732. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WWN"));
  733. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WWM"));
  734. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WWG"));
  735. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WEND"));
  736. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WSP"));
  737. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WFK"));
  738. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WFW"));
  739. }
  740. break;
  741. }
  742. return true;
  743. }
  744. protected override bool fMonitorReadData(object[] param)
  745. {
  746. if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
  747. {
  748. IsBusy = false;
  749. return true;
  750. }
  751. return false;
  752. }
  753. protected override bool fStartSetParameters(object[] param)
  754. {
  755. try
  756. {
  757. string setcommand = param[0].ToString();
  758. switch (setcommand)
  759. {
  760. case "CompaundCommand":
  761. if (param.Length < 4) return false;
  762. string routineselction = param[1].ToString();
  763. if (routineselction == "MainRoutine")
  764. {
  765. int routineno;
  766. if (!int.TryParse(param[2].ToString(), out routineno)) return false;
  767. if (routineno > 319 || routineno < 1) return false;
  768. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "I", routineno.ToString().PadLeft(3, '0')));
  769. _lstMonitorHandler.AddLast(new JelC5000RobotRawCommandHandler(this, param[3].ToString()));
  770. }
  771. if (routineselction == "SubRoutine")
  772. {
  773. char routineno;
  774. if (!char.TryParse(param[2].ToString(), out routineno)) return false;
  775. if (routineno > 'F' || routineno < 1) return false;
  776. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "IS", routineno.ToString()));
  777. _lstMonitorHandler.AddLast(new JelC5000RobotRawCommandHandler(this, param[3].ToString()));
  778. }
  779. break;
  780. case "RobotSpeed":
  781. //if (param.Length < 3) return false;
  782. //string speedtype = param[1].ToString().Split('(')[0];
  783. //Int32 speedvalue;
  784. //if (!Int32.TryParse(param[2].ToString(), out speedvalue)) return false;
  785. //_lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "O" + speedtype, speedvalue.ToString().PadLeft(5, '0')));
  786. Int32 speedvalue;
  787. if (!Int32.TryParse(param[2].ToString(), out speedvalue)) return false;
  788. if(SC.ContainsItem($"Robot.{RobotModuleName}.RobotSpeed"))
  789. {
  790. SC.SetItemValue($"Robot.{RobotModuleName}.RobotSpeed", speedvalue);
  791. }
  792. if (speedvalue < 0)
  793. speedvalue = 0;
  794. if (speedvalue > 99)
  795. speedvalue = 99;
  796. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "SPA" , speedvalue.ToString()));
  797. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "SPA"));
  798. break;
  799. case "AData":
  800. if (param.Length < 3) return false;
  801. Int32 datano, datavalue;
  802. if (!Int32.TryParse(param[1].ToString(), out datano)) return false;
  803. if (!Int32.TryParse(param[2].ToString(), out datavalue)) return false;
  804. if (datano > 999 || datano < 0) return false;
  805. if (datavalue > 8388607 || datavalue < -8388608) return false;
  806. lock (_locker)
  807. {
  808. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "A", datano.ToString("D3") + datavalue.ToString()));
  809. }
  810. break;
  811. case "EPData":
  812. if (param.Length < 2) return false;
  813. if (param[1].ToString() == "AData")
  814. {
  815. lock (_locker)
  816. {
  817. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "AW"));
  818. }
  819. }
  820. break;
  821. case "PositionData":
  822. if (param.Length < 6) return false;
  823. Int32 posno, rightarmpos, thetapos, leftarmpos, zpos;
  824. if (!Int32.TryParse(param[1].ToString(), out posno)) return false;
  825. if (!Int32.TryParse(param[2].ToString(), out rightarmpos)) return false;
  826. if (!Int32.TryParse(param[3].ToString(), out thetapos)) return false;
  827. if (!Int32.TryParse(param[4].ToString(), out leftarmpos)) return false;
  828. if (!Int32.TryParse(param[5].ToString(), out zpos)) return false;
  829. if (posno > 999 || posno < 0) return false;
  830. lock (_locker)
  831. {
  832. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "PS",
  833. $"{posno.ToString("D3")}{rightarmpos},{thetapos},{leftarmpos},{zpos}"));
  834. }
  835. return true;
  836. case "CurrentPositionData":
  837. Int32 currentpos = Int32.Parse(param[1].ToString());
  838. if (currentpos > 999 || currentpos < 0) return false;
  839. lock (_locker)
  840. {
  841. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "PS",
  842. $"{currentpos.ToString("D3")}"));
  843. }
  844. break;
  845. case "RobotParameter":
  846. if (param.Length < 3) return false;
  847. Int32 parano, paravalue;
  848. if (!Int32.TryParse(param[1].ToString(), out parano)) return false;
  849. if (!Int32.TryParse(param[2].ToString(), out paravalue)) return false;
  850. lock (_locker)
  851. {
  852. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "DTSVAL", $"{parano},{paravalue}"));
  853. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "DW"));
  854. }
  855. break;
  856. case "MappingData":
  857. lock(_locker)
  858. {
  859. if (!string.IsNullOrEmpty(param[1].ToString()))
  860. {
  861. float tempvalue = float.Parse(param[1].ToString());
  862. string strtempvalue;
  863. if (tempvalue <0)
  864. {
  865. strtempvalue = "-" +(-tempvalue).ToString().PadLeft(7, '0');
  866. }
  867. else
  868. strtempvalue = tempvalue.ToString().PadLeft(8, '0');
  869. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WLO",strtempvalue));
  870. }
  871. if (!string.IsNullOrEmpty(param[2].ToString()))
  872. {
  873. float tempvalue = float.Parse(param[2].ToString());
  874. string strtempvalue;
  875. if (tempvalue < 0)
  876. {
  877. strtempvalue = "-" + (-tempvalue).ToString().PadLeft(7, '0');
  878. }
  879. else
  880. strtempvalue = tempvalue.ToString().PadLeft(8, '0');
  881. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WHI",strtempvalue));
  882. }
  883. if (!string.IsNullOrEmpty(param[3].ToString()))
  884. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WFC",
  885. (Convert.ToInt16(param[3].ToString()).ToString("D2"))));
  886. if (!string.IsNullOrEmpty(param[4].ToString()))
  887. {
  888. float tempvalue = float.Parse(param[4].ToString());
  889. string strtempvalue;
  890. if (tempvalue < 0)
  891. {
  892. strtempvalue = "-" + (-tempvalue).ToString().PadLeft(7, '0');
  893. }
  894. else
  895. strtempvalue = tempvalue.ToString().PadLeft(8, '0');
  896. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WWN", strtempvalue));
  897. }
  898. if (!string.IsNullOrEmpty(param[5].ToString()))
  899. {
  900. float tempvalue = float.Parse(param[5].ToString());
  901. string strtempvalue;
  902. if (tempvalue < 0)
  903. {
  904. strtempvalue = "-" + (-tempvalue).ToString().PadLeft(7, '0');
  905. }
  906. else
  907. strtempvalue = tempvalue.ToString().PadLeft(8, '0');
  908. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WWM", strtempvalue));
  909. }
  910. if (!string.IsNullOrEmpty(param[6].ToString()))
  911. {
  912. float tempvalue = float.Parse(param[6].ToString());
  913. string strtempvalue;
  914. if (tempvalue < 0)
  915. {
  916. strtempvalue = "-" + (-tempvalue).ToString().PadLeft(7, '0');
  917. }
  918. else
  919. strtempvalue = tempvalue.ToString().PadLeft(8, '0');
  920. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WWG", strtempvalue));
  921. }
  922. if (!string.IsNullOrEmpty(param[7].ToString()))
  923. {
  924. float tempvalue = float.Parse(param[7].ToString());
  925. string strtempvalue;
  926. if (tempvalue < 0)
  927. {
  928. strtempvalue = "-" + (-tempvalue).ToString().PadLeft(7, '0');
  929. }
  930. else
  931. strtempvalue = tempvalue.ToString().PadLeft(8, '0');
  932. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WEND", strtempvalue));
  933. }
  934. if (!string.IsNullOrEmpty(param[8].ToString()))
  935. {
  936. float tempvalue = float.Parse(param[8].ToString());
  937. string strtempvalue;
  938. if (tempvalue < 0)
  939. {
  940. strtempvalue = "-" + (-tempvalue).ToString().PadLeft(7, '0');
  941. }
  942. else
  943. strtempvalue = tempvalue.ToString().PadLeft(8, '0');
  944. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WSP", strtempvalue));
  945. }
  946. }
  947. break;
  948. case "MappingCommand":
  949. lock(_locker)
  950. {
  951. //_lstMonitorHandler.AddLast(new JelC5000RobotMoveHandler(this, "WFS"));
  952. //_lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WFK"));
  953. //_lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WFW"));
  954. }
  955. break;
  956. case "BankNumber":
  957. lock (_locker)
  958. {
  959. if (param.Length > 1 && !string.IsNullOrEmpty(param[1].ToString()))
  960. {
  961. int bankno = Convert.ToInt16(param[1].ToString());
  962. if (bankno <= 15 && bankno >= 0)
  963. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "BC", bankno.ToString("X")));
  964. }
  965. if (param.Length > 2 && !string.IsNullOrEmpty(param[2].ToString()))
  966. {
  967. int cassetteno = Convert.ToInt16(param[2].ToString());
  968. if (cassetteno <=5 && cassetteno <= 1)
  969. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WCP", cassetteno.ToString()));
  970. }
  971. if (param.Length > 3 && !string.IsNullOrEmpty(param[3].ToString()))
  972. {
  973. int slotno = Convert.ToInt16(param[3].ToString());
  974. if (slotno <= 25 && slotno >= 1)
  975. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WCD", slotno.ToString()));
  976. }
  977. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "BC"));
  978. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WCP"));
  979. }
  980. break;
  981. }
  982. }
  983. catch (Exception )
  984. {
  985. string reason = "";
  986. if(param!=null)
  987. {
  988. foreach(var para in param)
  989. {
  990. reason += para.ToString() + ",";
  991. }
  992. }
  993. EV.PostAlarmLog(Name, "Set command parameter valid:" + reason);
  994. return false;
  995. }
  996. return true;
  997. }
  998. protected override bool fMonitorSetParamter(object[] param)
  999. {
  1000. if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
  1001. {
  1002. IsBusy = false;
  1003. return true;
  1004. }
  1005. return base.fMonitorSetParamter(param);
  1006. }
  1007. public override bool IsReady()
  1008. {
  1009. return RobotState == RobotStateEnum.Idle && !IsBusy;
  1010. }
  1011. protected override bool fClear(object[] param)
  1012. {
  1013. return true;
  1014. }
  1015. protected override bool fStartTransferWafer(object[] param)
  1016. {
  1017. return false;
  1018. }
  1019. protected override bool fStartUnGrip(object[] param)
  1020. {
  1021. if (param == null || param.Length < 1) return false;
  1022. RobotArmEnum arm = (RobotArmEnum)((int)param[0]);
  1023. lock (_locker)
  1024. {
  1025. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "DS", "10"));
  1026. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, ""));
  1027. }
  1028. return true;
  1029. }
  1030. protected override bool fMonitorUnGrip(object[] param)
  1031. {
  1032. IsBusy = false;
  1033. if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
  1034. {
  1035. if (JelC5000RobotStatus != JelAxisStatus.NormalEnd
  1036. || AxisStatus != JelAxisStatus.NormalEnd)
  1037. {
  1038. lock (_locker)
  1039. {
  1040. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, ""));
  1041. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
  1042. }
  1043. return false;
  1044. }
  1045. RobotArmEnum arm = (RobotArmEnum)((int)CurrentParamter[0]);
  1046. //if(IsVacuumSensorON)
  1047. // HandlerError("UnGrip wafer failed!");
  1048. IsBusy = false;
  1049. return true;
  1050. }
  1051. return false;
  1052. }
  1053. protected override bool fStartGrip(object[] param)
  1054. {
  1055. if(param == null || param.Length <1) return false;
  1056. RobotArmEnum arm = (RobotArmEnum)((int)param[0]);
  1057. lock (_locker)
  1058. {
  1059. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "DS", "11"));
  1060. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, ""));
  1061. }
  1062. return true;
  1063. }
  1064. protected override bool fMonitorGrip(object[] param)
  1065. {
  1066. IsBusy = false;
  1067. if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
  1068. {
  1069. if (JelC5000RobotStatus != JelAxisStatus.NormalEnd
  1070. || AxisStatus != JelAxisStatus.NormalEnd)
  1071. {
  1072. lock (_locker)
  1073. {
  1074. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, ""));
  1075. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
  1076. }
  1077. return false;
  1078. }
  1079. //if (!IsVacuumSensorON)
  1080. // HandlerError("UnGrip wafer failed!");
  1081. IsBusy = false;
  1082. return true;
  1083. }
  1084. return false;
  1085. }
  1086. protected override bool fStop(object[] param)
  1087. {
  1088. IsBusy = false;
  1089. _lstMonitorHandler.Clear();
  1090. _connection.ForceClear();
  1091. _connection.Execute(new JelC5000RobotSetHandler(this, "S"));
  1092. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "GE"));
  1093. return ReadStatus();
  1094. }
  1095. protected override bool fStartGoTo(object[] param)
  1096. {
  1097. try
  1098. {
  1099. _dtActionStart = DateTime.Now;
  1100. RobotArmEnum arm = (RobotArmEnum)param[0];
  1101. ModuleName tempmodule = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  1102. BladeTarget = tempmodule;
  1103. Blade1Target = tempmodule;
  1104. Blade2Target = tempmodule;
  1105. int slot = (int)param[2] + 1;
  1106. RobotPostionEnum postype = (RobotPostionEnum)param[3];
  1107. var wz = WaferManager.Instance.GetWaferSize(RobotModuleName, (int)arm);
  1108. if (!GetBankAndCassetteNumber(tempmodule, wz, out int bankno, out int cassetteNO))
  1109. {
  1110. EV.PostAlarmLog("Robot", $"{RobotModuleName} can't find the bankno or cassette no for {tempmodule}");
  1111. OnError("ParseStationError");
  1112. return false;
  1113. }
  1114. //int wzindex = 0;
  1115. //if (wz == WaferSize.WS12) wzindex = 12;
  1116. //if (wz == WaferSize.WS8) wzindex = 8;
  1117. //if (wz == WaferSize.WS6) wzindex = 6;
  1118. //if (wz == WaferSize.WS5) wzindex = 5;
  1119. //if (wz == WaferSize.WS4) wzindex = 4;
  1120. //if (wz == WaferSize.WS3) wzindex = 3;
  1121. //if (wz == WaferSize.WS2) wzindex = 2;
  1122. //if (ModuleHelper.IsLoadPort(tempmodule))
  1123. //{
  1124. // var lp = DEVICE.GetDevice<LoadPortBaseDevice>(tempmodule.ToString());
  1125. // if (lp != null) lp.NoteTransferStart();
  1126. // wzindex = lp.InfoPadCarrierIndex;
  1127. //}
  1128. //int bankno = SC.GetValue<int>($"CarrierInfo.{tempmodule}BankNumber{wzindex}");
  1129. //int cassetteNO = SC.GetValue<int>($"CarrierInfo.{tempmodule}CassetteNumber{wzindex}");
  1130. int compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.{arm}Goto{postype}CmdNO");
  1131. int compaundcmdNOforSafe = SC.GetValue<int>($"Robot.{Name}.SafeCmdNO");
  1132. lock (_locker)
  1133. {
  1134. if (ResetBeforeCmd)
  1135. _lstMonitorHandler.AddLast(new JelC5000RobotRawCommandHandler(this, $"RD"));
  1136. if (compaundcmdNOforSafe!=0 &&
  1137. (ReadBankNumber != bankno.ToString("X") || cassetteNO != ReadCassetNumber))
  1138. {
  1139. _lstMonitorHandler.AddLast(new JelC5000RobotCompaundCommandHandler(this, compaundcmdNOforSafe.ToString()));
  1140. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "G"));
  1141. }
  1142. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "BC", bankno.ToString("X")));
  1143. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WCP", cassetteNO.ToString()));
  1144. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WCD", slot.ToString()));
  1145. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "BC"));
  1146. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WCP"));
  1147. _lstMonitorHandler.AddLast(new JelC5000RobotCompaundCommandHandler(this, compaundcmdNO.ToString()));
  1148. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "G"));
  1149. }
  1150. Blade1Target = tempmodule;
  1151. Blade2Target = tempmodule;
  1152. CmdTarget = tempmodule;
  1153. MoveInfo = new RobotMoveInfo()
  1154. {
  1155. Action = RobotAction.Picking,
  1156. ArmTarget = CmdRobotArm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1157. BladeTarget = BuildBladeTarget(),
  1158. };
  1159. return true;
  1160. }
  1161. catch (Exception ex)
  1162. {
  1163. LOG.Write(ex);
  1164. return false;
  1165. }
  1166. }
  1167. protected override bool fMonitorGoTo(object[] param)
  1168. {
  1169. IsBusy = false;
  1170. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(RobotCommandTimeout))
  1171. {
  1172. OnError("Robot Goto timeout");
  1173. return true;
  1174. }
  1175. if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
  1176. {
  1177. if (CurrentCompoundCommandStatus == JelCommandStatus.NormalEnd)
  1178. {
  1179. RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
  1180. ModuleName tempmodule = (ModuleName)Enum.Parse(typeof(ModuleName), CurrentParamter[1].ToString());
  1181. Blade1Target = tempmodule;
  1182. Blade2Target = tempmodule;
  1183. IsBusy = false;
  1184. CmdTarget = tempmodule;
  1185. MoveInfo = new RobotMoveInfo()
  1186. {
  1187. Action = RobotAction.Moving,
  1188. ArmTarget = CmdRobotArm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1189. BladeTarget = BuildBladeTarget(),
  1190. };
  1191. return true;
  1192. }
  1193. if (CurrentCompoundCommandStatus == JelCommandStatus.InError)
  1194. {
  1195. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "GER"));
  1196. HandlerError("GoToFailed");
  1197. }
  1198. }
  1199. return false;
  1200. }
  1201. protected override bool fStartMapWafer(object[] param)
  1202. {
  1203. try
  1204. {
  1205. _dtActionStart = DateTime.Now;
  1206. ModuleName tempmodule = (ModuleName)Enum.Parse(typeof(ModuleName), param[0].ToString());
  1207. //int carrierindex = 0;
  1208. if (ModuleHelper.IsLoadPort(tempmodule))
  1209. {
  1210. LoadPortBaseDevice lp = DEVICE.GetDevice<LoadPortBaseDevice>(tempmodule.ToString());
  1211. if (lp != null)
  1212. lp.NoteTransferStart();
  1213. //carrierindex = lp.InfoPadCarrierIndex;
  1214. }
  1215. WaferSize wz = WaferManager.Instance.GetWaferSize(tempmodule, 0);
  1216. if (!GetBankAndCassetteNumber(tempmodule, wz, out int bankno, out int cassetteNO))
  1217. {
  1218. EV.PostAlarmLog("Robot", $"{RobotModuleName} can't find the bankno or cassette no for {tempmodule}");
  1219. OnError("ParseStationError");
  1220. return false;
  1221. }
  1222. //else
  1223. //{
  1224. // WaferSize wz = WaferManager.Instance.GetWaferSize(tempmodule, 0);
  1225. // if (param.Length >= 3)
  1226. // {
  1227. // wz = (WaferSize)Enum.Parse(typeof(WaferSize), param[2].ToString());
  1228. // }
  1229. // if (wz == WaferSize.WS12) carrierindex = 12;
  1230. // if (wz == WaferSize.WS8) carrierindex = 8;
  1231. // if (wz == WaferSize.WS6) carrierindex = 6;
  1232. // if (wz == WaferSize.WS4) carrierindex = 4;
  1233. // if (wz == WaferSize.WS3) carrierindex = 3;
  1234. //}
  1235. //int bankno = SC.GetValue<int>($"CarrierInfo.{tempmodule}BankNumber{carrierindex}");
  1236. //int cassetteNO = SC.GetValue<int>($"CarrierInfo.{tempmodule}CassetteNumber{carrierindex}");
  1237. int compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.MapCmdNO");
  1238. lock (_locker)
  1239. {
  1240. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "BC", bankno.ToString("X")));
  1241. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WCP", cassetteNO.ToString()));
  1242. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WCD", "1"));
  1243. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "BC"));
  1244. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WCP"));
  1245. _lstMonitorHandler.AddLast(new JelC5000RobotRawCommandHandler(this, $"RD"));
  1246. }
  1247. DateTime readstarttime = DateTime.Now;
  1248. while (_lstMonitorHandler.Count != 0 || _connection.IsBusy)
  1249. {
  1250. if (DateTime.Now - readstarttime > TimeSpan.FromSeconds(20))
  1251. {
  1252. OnError("Set Timeout.");
  1253. return false;
  1254. }
  1255. }
  1256. if (ReadBankNumber != bankno.ToString("X") || cassetteNO != ReadCassetNumber)
  1257. {
  1258. OnError("Set data failed.");
  1259. return false;
  1260. }
  1261. lock (_locker)
  1262. {
  1263. _lstMonitorHandler.AddLast(new JelC5000RobotCompaundCommandHandler(this, compaundcmdNO.ToString()));
  1264. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "G"));
  1265. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WFK"));
  1266. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WFW"));
  1267. }
  1268. }
  1269. catch (Exception ex)
  1270. {
  1271. string reason = "";
  1272. if (param != null)
  1273. foreach (var strpara in param)
  1274. reason += strpara.ToString();
  1275. OnError($"{Name} Map command valid:" + reason);
  1276. LOG.Write(ex);
  1277. return false;
  1278. }
  1279. return true;
  1280. }
  1281. protected override bool fMonitorMap(object[] param)
  1282. {
  1283. IsBusy = false;
  1284. //return true;
  1285. if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
  1286. {
  1287. //RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
  1288. ModuleName sourcemodule;
  1289. if (!Enum.TryParse(CurrentParamter[0].ToString(), out sourcemodule)) return false;
  1290. if (ModuleHelper.IsLoadPort(sourcemodule))
  1291. {
  1292. //LoadPortBaseDevice lp = DEVICE.GetDevice<LoadPortBaseDevice>(sourcemodule.ToString());
  1293. //if (lp != null && !lp.NoteTransferStop())
  1294. // return false;
  1295. }
  1296. IsBusy = false;
  1297. return true;
  1298. }
  1299. return false;
  1300. }
  1301. protected override bool fStartSwapWafer(object[] param)
  1302. {
  1303. return false;
  1304. }
  1305. protected DateTime _dtActionStart;
  1306. protected override bool fMonitorSwap(object[] param)
  1307. {
  1308. if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
  1309. {
  1310. if (CurrentCompoundCommandStatus == JelCommandStatus.NormalEnd)
  1311. {
  1312. RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
  1313. ModuleName sourcemodule;
  1314. if (!Enum.TryParse(CurrentParamter[1].ToString(), out sourcemodule)) return false;
  1315. int Sourceslotindex;
  1316. if (!int.TryParse(CurrentParamter[2].ToString(), out Sourceslotindex)) return false;
  1317. if (arm == RobotArmEnum.Lower)
  1318. {
  1319. WaferManager.Instance.WaferMoved(sourcemodule, Sourceslotindex, RobotModuleName, 0);
  1320. WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, Sourceslotindex);
  1321. }
  1322. if (arm == RobotArmEnum.Upper)
  1323. {
  1324. WaferManager.Instance.WaferMoved(sourcemodule, Sourceslotindex, RobotModuleName, 1);
  1325. WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, Sourceslotindex);
  1326. }
  1327. if (arm == RobotArmEnum.Both)
  1328. {
  1329. }
  1330. IsBusy = false;
  1331. return true;
  1332. }
  1333. if (CurrentCompoundCommandStatus == JelCommandStatus.InExecution ||
  1334. CurrentCompoundCommandStatus == JelCommandStatus.None)
  1335. {
  1336. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "G"));
  1337. }
  1338. if (CurrentCompoundCommandStatus == JelCommandStatus.InError)
  1339. {
  1340. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "GER"));
  1341. OnError("Compaund Comand execution failed");
  1342. }
  1343. }
  1344. return false;
  1345. }
  1346. protected override bool fStartPlaceWafer(object[] param)
  1347. {
  1348. _dtActionStart = DateTime.Now;
  1349. try
  1350. {
  1351. RobotArmEnum arm = (RobotArmEnum)param[0];
  1352. ModuleName tempmodule = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  1353. int slotindex = int.Parse(param[2].ToString());
  1354. var wz = WaferManager.Instance.GetWaferSize(RobotModuleName, arm == RobotArmEnum.Both ? 0 : (int)arm);
  1355. if (!GetBankAndCassetteNumber(tempmodule, wz, out int bankno, out int cassetteNO))
  1356. {
  1357. EV.PostAlarmLog("Robot", $"{RobotModuleName} can't find the bankno or cassette no for {tempmodule}");
  1358. OnError("ParseStationError");
  1359. return false;
  1360. }
  1361. //int wzindex = 0;
  1362. //if (wz == WaferSize.WS12) wzindex = 12;
  1363. //if (wz == WaferSize.WS8) wzindex = 8;
  1364. //if (wz == WaferSize.WS6) wzindex = 6;
  1365. //if (wz == WaferSize.WS5) wzindex = 5;
  1366. //if (wz == WaferSize.WS4) wzindex = 4;
  1367. //if (wz == WaferSize.WS3) wzindex = 3;
  1368. //if (wz == WaferSize.WS2) wzindex = 2;
  1369. //if (ModuleHelper.IsLoadPort(tempmodule))
  1370. //{
  1371. // var lp = DEVICE.GetDevice<LoadPortBaseDevice>(tempmodule.ToString());
  1372. // if (lp != null)
  1373. // lp.NoteTransferStart();
  1374. // wzindex = DEVICE.GetDevice<LoadPortBaseDevice>(tempmodule.ToString()).InfoPadCarrierIndex;
  1375. //}
  1376. //int bankno = SC.GetValue<int>($"CarrierInfo.{tempmodule}BankNumber{wzindex}");
  1377. //int cassetteNO = SC.GetValue<int>($"CarrierInfo.{tempmodule}CassetteNumber{wzindex}");
  1378. int compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.PlaceCmdNO");
  1379. int compaundcmdNOforSafe = SC.GetValue<int>($"Robot.{Name}.SafeCmdNO");
  1380. if (ModuleHelper.IsAligner(tempmodule))
  1381. {
  1382. if (SC.ContainsItem($"Robot.{Name}.PlaceAtAlignerCmdNO"))
  1383. {
  1384. compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.PlaceAtAlignerCmdNO");
  1385. }
  1386. }
  1387. lock (_locker)
  1388. {
  1389. if(ResetBeforeCmd)
  1390. _lstMonitorHandler.AddLast(new JelC5000RobotRawCommandHandler(this, $"RD"));
  1391. if (compaundcmdNOforSafe!=0 &&
  1392. (ReadBankNumber != bankno.ToString("X") || cassetteNO != ReadCassetNumber))
  1393. {
  1394. _lstMonitorHandler.AddLast(new JelC5000RobotCompaundCommandHandler(this, compaundcmdNOforSafe.ToString()));
  1395. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "G"));
  1396. }
  1397. if(ReadBankNumber != bankno.ToString("X"))
  1398. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "BC", bankno.ToString("X")));
  1399. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WCP", cassetteNO.ToString()));
  1400. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WCD", (slotindex+1).ToString()));
  1401. //_lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "BC"));
  1402. //_lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WCP"));
  1403. _lstMonitorHandler.AddLast(new JelC5000RobotCompaundCommandHandler(this, compaundcmdNO.ToString()));
  1404. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "G"));
  1405. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
  1406. }
  1407. Blade1Target = tempmodule;
  1408. Blade2Target = tempmodule;
  1409. CmdTarget = tempmodule;
  1410. MoveInfo = new RobotMoveInfo()
  1411. {
  1412. Action = RobotAction.Placing,
  1413. ArmTarget = RobotArm.Both, // CmdRobotArm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1414. BladeTarget = BuildBladeTarget(),
  1415. };
  1416. }
  1417. catch (Exception ex)
  1418. {
  1419. string reason = "";
  1420. if (param != null)
  1421. foreach (var strpara in param)
  1422. reason += strpara.ToString();
  1423. OnError($"{Name} Pick command valid:" + reason);
  1424. LOG.Write(ex);
  1425. return false;
  1426. }
  1427. return true;
  1428. }
  1429. protected override bool fStartPickWafer(object[] param)
  1430. {
  1431. _dtActionStart = DateTime.Now;
  1432. try
  1433. {
  1434. ModuleName tempmodule = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  1435. int slotindex = int.Parse(param[2].ToString());
  1436. var wz = WaferManager.Instance.GetWaferSize(tempmodule, slotindex);
  1437. if(!GetBankAndCassetteNumber(tempmodule,wz,out int bankno,out int cassetteNO))
  1438. {
  1439. EV.PostAlarmLog("Robot", $"{RobotModuleName} can't find the bankno or cassette no for {tempmodule}");
  1440. OnError("ParseStationError");
  1441. return false;
  1442. }
  1443. //int wzindex = 0;
  1444. //if (wz == WaferSize.WS12) wzindex = 12;
  1445. //if (wz == WaferSize.WS8) wzindex = 8;
  1446. //if (wz == WaferSize.WS6) wzindex = 6;
  1447. //if (wz == WaferSize.WS5) wzindex = 5;
  1448. //if (wz == WaferSize.WS4) wzindex = 4;
  1449. //if (wz == WaferSize.WS3) wzindex = 3;
  1450. //if (wz == WaferSize.WS2) wzindex = 2;
  1451. //if (ModuleHelper.IsLoadPort(tempmodule))
  1452. //{
  1453. // var lp = DEVICE.GetDevice<LoadPortBaseDevice>(tempmodule.ToString());
  1454. // if (lp != null) lp.NoteTransferStart();
  1455. // wzindex = lp.InfoPadCarrierIndex;
  1456. //}
  1457. //int bankno = SC.GetValue<int>($"CarrierInfo.{tempmodule}BankNumber{wzindex}");
  1458. //int cassetteNO = SC.GetValue<int>($"CarrierInfo.{tempmodule}CassetteNumber{wzindex}");
  1459. int compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.PickCmdNO");
  1460. if(ModuleHelper.IsAligner(tempmodule))
  1461. {
  1462. if(SC.ContainsItem($"Robot.{Name}.PickAtAlignerCmdNO"))
  1463. {
  1464. compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.PickAtAlignerCmdNO");
  1465. }
  1466. }
  1467. int compaundcmdNOforSafe = SC.GetValue<int>($"Robot.{Name}.SafeCmdNO");
  1468. //lock (_locker)
  1469. //{
  1470. // _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "BC"));
  1471. // _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WCP"));
  1472. //}
  1473. //DateTime readstarttime = DateTime.Now;
  1474. //while (_lstMonitorHandler.Count != 0 || _connection.IsBusy)
  1475. //{
  1476. // if (DateTime.Now - readstarttime > TimeSpan.FromSeconds(20))
  1477. // {
  1478. // OnError("Read bankno and cassette no for pick Timeout.");
  1479. // return false;
  1480. // }
  1481. //}
  1482. lock (_locker)
  1483. {
  1484. if (ResetBeforeCmd)
  1485. _lstMonitorHandler.AddLast(new JelC5000RobotRawCommandHandler(this, $"RD"));
  1486. if (compaundcmdNOforSafe!=0
  1487. &&(ReadBankNumber != bankno.ToString("X") || cassetteNO != ReadCassetNumber))
  1488. {
  1489. _lstMonitorHandler.AddLast(new JelC5000RobotCompaundCommandHandler(this, compaundcmdNOforSafe.ToString()));
  1490. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "G"));
  1491. }
  1492. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "BC", bankno.ToString("X")));
  1493. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WCP", cassetteNO.ToString()));
  1494. _lstMonitorHandler.AddLast(new JelC5000RobotSetHandler(this, "WCD", (slotindex+1).ToString()));
  1495. //_lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "BC"));
  1496. //_lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "WCP"));
  1497. _lstMonitorHandler.AddLast(new JelC5000RobotCompaundCommandHandler(this,compaundcmdNO.ToString()));
  1498. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "G"));
  1499. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
  1500. }
  1501. Blade1Target = tempmodule;
  1502. Blade2Target = tempmodule;
  1503. CmdTarget = tempmodule;
  1504. MoveInfo = new RobotMoveInfo()
  1505. {
  1506. Action = RobotAction.Picking,
  1507. ArmTarget = CmdRobotArm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1508. BladeTarget = BuildBladeTarget(),
  1509. };
  1510. }
  1511. catch (Exception ex)
  1512. {
  1513. string reason = "";
  1514. if (param != null)
  1515. {
  1516. foreach (var strpara in param)
  1517. reason += strpara.ToString();
  1518. }
  1519. LOG.Write(ex);
  1520. OnError($"{Name} Pick command valid:" + reason);
  1521. return false;
  1522. }
  1523. return true;
  1524. }
  1525. protected override bool fMonitorPlace(object[] param)
  1526. {
  1527. IsBusy = false;
  1528. if(DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(RobotCommandTimeout))
  1529. {
  1530. OnError("Place wafer timeout");
  1531. return true;
  1532. }
  1533. if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
  1534. {
  1535. if (CurrentCompoundCommandStatus == JelCommandStatus.NormalEnd)
  1536. {
  1537. RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
  1538. ModuleName sourcemodule;
  1539. if (!Enum.TryParse(CurrentParamter[1].ToString(), out sourcemodule)) return false;
  1540. int Sourceslotindex;
  1541. if (!int.TryParse(CurrentParamter[2].ToString(), out Sourceslotindex)) return false;
  1542. if (IsVacuumSensorON)
  1543. {
  1544. OnError("Vacuum sensor on blade is ON");
  1545. return false;
  1546. }
  1547. if (arm == RobotArmEnum.Lower)
  1548. WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, Sourceslotindex);
  1549. if (arm == RobotArmEnum.Upper)
  1550. WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, Sourceslotindex);
  1551. if (arm == RobotArmEnum.Both)
  1552. {
  1553. WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, Sourceslotindex);
  1554. WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, Sourceslotindex);
  1555. }
  1556. Blade1Target = ModuleName.System;
  1557. Blade2Target = ModuleName.System;
  1558. if (ModuleHelper.IsLoadPort(sourcemodule))
  1559. {
  1560. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(sourcemodule.ToString());
  1561. if (lp != null)
  1562. lp.NoteTransferStop();
  1563. }
  1564. IsBusy = false;
  1565. CmdTarget = ModuleName.System;
  1566. MoveInfo = new RobotMoveInfo()
  1567. {
  1568. Action = RobotAction.Picking,
  1569. ArmTarget = CmdRobotArm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1570. BladeTarget = BuildBladeTarget(),
  1571. };
  1572. return true;
  1573. }
  1574. if (CurrentCompoundCommandStatus == JelCommandStatus.InError)
  1575. {
  1576. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "GER"));
  1577. HandlerError("PlaceFailed");
  1578. }
  1579. }
  1580. return false;
  1581. }
  1582. protected override bool fMonitorPick(object[] param)
  1583. {
  1584. IsBusy = false;
  1585. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(RobotCommandTimeout))
  1586. {
  1587. OnError("Pick wafer timeout");
  1588. return true;
  1589. }
  1590. if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
  1591. {
  1592. if (CurrentCompoundCommandStatus == JelCommandStatus.NormalEnd)
  1593. {
  1594. RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
  1595. ModuleName sourcemodule;
  1596. if (!Enum.TryParse(CurrentParamter[1].ToString(), out sourcemodule)) return false;
  1597. int SourceslotIndex;
  1598. if (!int.TryParse(CurrentParamter[2].ToString(), out SourceslotIndex)) return false;
  1599. if(!IsVacuumSensorON)
  1600. {
  1601. OnError("Vacuum sensor is not ON");
  1602. return false;
  1603. }
  1604. if (arm == RobotArmEnum.Lower)
  1605. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 0);
  1606. if (arm == RobotArmEnum.Upper)
  1607. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 1);
  1608. if(arm == RobotArmEnum.Both)
  1609. {
  1610. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 0);
  1611. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 1);
  1612. }
  1613. Blade1Target = ModuleName.System;
  1614. Blade2Target = ModuleName.System;
  1615. if (ModuleHelper.IsLoadPort(sourcemodule))
  1616. {
  1617. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(sourcemodule.ToString());
  1618. if (lp != null)
  1619. lp.NoteTransferStop();
  1620. }
  1621. IsBusy = false;
  1622. CmdTarget = ModuleName.System;
  1623. MoveInfo = new RobotMoveInfo()
  1624. {
  1625. Action = RobotAction.Picking,
  1626. ArmTarget = CmdRobotArm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1627. BladeTarget = BuildBladeTarget(),
  1628. };
  1629. return true;
  1630. }
  1631. if(CurrentCompoundCommandStatus == JelCommandStatus.InError)
  1632. {
  1633. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "GER"));
  1634. OnError("Compaund Comand execution failed");
  1635. }
  1636. else
  1637. {
  1638. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "G"));
  1639. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
  1640. }
  1641. }
  1642. return false;
  1643. }
  1644. protected override bool fStartExecuteCommand(object[] param)
  1645. {
  1646. string command = param[0].ToString();
  1647. if (string.IsNullOrEmpty(command))
  1648. return false;
  1649. lock(_locker)
  1650. {
  1651. _lstMonitorHandler.AddLast(new JelC5000RobotRawCommandHandler(this, command));
  1652. }
  1653. _dtActionStart = DateTime.Now;
  1654. return true;
  1655. }
  1656. protected override bool fMonitorExecuting(object[] param)
  1657. {
  1658. IsBusy = false;
  1659. if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(RobotCommandTimeout))
  1660. {
  1661. OnError("Command execution timeout");
  1662. return true;
  1663. }
  1664. if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
  1665. return true;
  1666. return false;
  1667. }
  1668. protected override bool fResetToReady(object[] param)
  1669. {
  1670. return true;
  1671. }
  1672. protected override bool fError(object[] param)
  1673. {
  1674. return true;
  1675. }
  1676. protected override bool fStartExtendForPick(object[] param)
  1677. {
  1678. return true;
  1679. }
  1680. protected override bool fStartExtendForPlace(object[] param)
  1681. {
  1682. return true;
  1683. }
  1684. protected override bool fStartRetractFromPick(object[] param)
  1685. {
  1686. return true;
  1687. }
  1688. protected override bool fStartRetractFromPlace(object[] param)
  1689. {
  1690. return true;
  1691. }
  1692. public override RobotArmWaferStateEnum GetWaferState(RobotArmEnum arm)
  1693. {
  1694. bool ispresent = WaferManager.Instance.CheckHasWafer(RobotModuleName, 0);
  1695. if (ispresent) return RobotArmWaferStateEnum.Present;
  1696. return RobotArmWaferStateEnum.Absent;
  1697. //if (IsVacuumSensorON == ispresent)
  1698. // return ispresent ? RobotArmWaferStateEnum.Present : RobotArmWaferStateEnum.Absent;
  1699. //return RobotArmWaferStateEnum.Unknown;
  1700. }
  1701. public bool ReadStatus()
  1702. {
  1703. lock(_locker)
  1704. {
  1705. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, ""));
  1706. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
  1707. _lstMonitorHandler.AddLast(new JelC5000RobotReadHandler(this, "G"));
  1708. }
  1709. return true;
  1710. }
  1711. public override bool SetWaferSize(RobotArmEnum arm, WaferSize size)
  1712. {
  1713. if (WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))
  1714. WaferManager.Instance.UpdateWaferSize(RobotModuleName, 0, size);
  1715. return true;
  1716. }
  1717. public override WaferSize GetCurrentWaferSize()
  1718. {
  1719. if (WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))
  1720. return WaferManager.Instance.GetWaferSize(RobotModuleName, 0);
  1721. return WaferSize.WS0;
  1722. }
  1723. public void HandlerError(string errorMsg)
  1724. {
  1725. _lstMonitorHandler.Clear();
  1726. OnError(errorMsg);
  1727. }
  1728. private string BuildBladeTarget()
  1729. {
  1730. return (CmdRobotArm == RobotArmEnum.Upper ? "ArmB" : "ArmA") + "." + CmdTarget;
  1731. }
  1732. public bool GetBankAndCassetteNumber(ModuleName module, WaferSize wz, out int BankNum, out int CassetteNum)
  1733. {
  1734. BankNum = 0;
  1735. CassetteNum = 0;
  1736. int wzindex = 0;
  1737. if (ModuleHelper.IsLoadPort(module))
  1738. {
  1739. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(module.ToString());
  1740. if (lp != null)
  1741. {
  1742. wzindex = lp.InfoPadCarrierIndex;
  1743. }
  1744. else
  1745. {
  1746. var lp1 = DEVICE.GetDevice<LoadPort>(module.ToString());
  1747. wzindex = lp.InfoPadCarrierIndex;
  1748. }
  1749. if (SC.ContainsItem($"CarrierInfo.{module}BankNumber{wzindex}"))
  1750. BankNum = SC.GetValue<int>($"CarrierInfo.{module}BankNumber{wzindex}");
  1751. else if (SC.ContainsItem($"CarrierInfo.Carrier{wzindex}.{module}BankNumber"))
  1752. BankNum = SC.GetValue<int>($"CarrierInfo.Carrier{wzindex}.{module}BankNumber");
  1753. else if (SC.ContainsItem($"CarrierInfo.Carrier{wzindex}.{module}Station"))
  1754. {
  1755. string[] stationInfo = SC.GetStringValue($"CarrierInfo.Carrier{wzindex}.{module}Station").Split('.');
  1756. if (stationInfo.Length < 2) return false;
  1757. if (!int.TryParse(stationInfo[0], out BankNum))
  1758. {
  1759. EV.PostAlarmLog("Robot", $"{RobotModuleName} parse bank number failed");
  1760. return false;
  1761. }
  1762. if (!int.TryParse(stationInfo[1], out CassetteNum))
  1763. {
  1764. EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
  1765. return false;
  1766. }
  1767. return true;
  1768. }
  1769. else
  1770. {
  1771. return false;
  1772. }
  1773. if (SC.ContainsItem($"CarrierInfo.{module}CassetteNumber{wzindex}"))
  1774. CassetteNum = SC.GetValue<int>($"CarrierInfo.{module}CassetteNumber{wzindex}");
  1775. else if (SC.ContainsItem($"CarrierInfo.Carrier{wzindex}.{module}CassetteNumber"))
  1776. CassetteNum = SC.GetValue<int>($"CarrierInfo.Carrier{wzindex}.{module}CassetteNumber");
  1777. else
  1778. {
  1779. EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
  1780. return false;
  1781. }
  1782. return true;
  1783. }
  1784. if (ModuleHelper.IsTurnOverStation(module))
  1785. {
  1786. var flipper = DEVICE.GetDevice<FlipperBaseDevice>(module.ToString());
  1787. if (SC.ContainsItem($"CarrierInfo.{module}{flipper.CurrentFlipperPosition}Station"))
  1788. {
  1789. string[] stationInfo = SC.GetStringValue($"CarrierInfo.{module}{flipper.CurrentFlipperPosition}Station").Split('.');
  1790. if (stationInfo.Length < 2) return false;
  1791. if (!int.TryParse(stationInfo[0], out BankNum))
  1792. {
  1793. EV.PostAlarmLog("Robot", $"{RobotModuleName} parse bank number failed");
  1794. return false;
  1795. }
  1796. if (!int.TryParse(stationInfo[1], out CassetteNum))
  1797. {
  1798. EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
  1799. return false;
  1800. }
  1801. return true;
  1802. }
  1803. }
  1804. if (wz == WaferSize.WS12) wzindex = 12;
  1805. if (wz == WaferSize.WS8) wzindex = 8;
  1806. if (wz == WaferSize.WS6) wzindex = 6;
  1807. if (wz == WaferSize.WS4) wzindex = 4;
  1808. if (wz == WaferSize.WS3) wzindex = 3;
  1809. if (SC.ContainsItem($"CarrierInfo.{module}Station"))
  1810. {
  1811. string[] stationInfo = SC.GetStringValue($"CarrierInfo.{module}Station").Split('.');
  1812. if (stationInfo.Length < 2) return false;
  1813. if (!int.TryParse(stationInfo[0], out BankNum))
  1814. {
  1815. EV.PostAlarmLog("Robot", $"{RobotModuleName} parse bank number failed");
  1816. return false;
  1817. }
  1818. if (!int.TryParse(stationInfo[1], out CassetteNum))
  1819. {
  1820. EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
  1821. return false;
  1822. }
  1823. return true;
  1824. }
  1825. if (SC.ContainsItem($"CarrierInfo.{module}Station{wzindex}"))
  1826. {
  1827. string[] stationInfo = SC.GetStringValue($"CarrierInfo.{module}Station{wzindex}").Split('.');
  1828. if (stationInfo.Length < 2) return false;
  1829. if (!int.TryParse(stationInfo[0], out BankNum))
  1830. {
  1831. EV.PostAlarmLog("Robot", $"{RobotModuleName} parse bank number failed");
  1832. return false;
  1833. }
  1834. if (!int.TryParse(stationInfo[1], out CassetteNum))
  1835. {
  1836. EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
  1837. return false;
  1838. }
  1839. return true;
  1840. }
  1841. if (SC.ContainsItem($"CarrierInfo.{module}BankNumber{wzindex}"))
  1842. BankNum = SC.GetValue<int>($"CarrierInfo.{module}BankNumber{wzindex}");
  1843. else
  1844. return false;
  1845. if (SC.ContainsItem($"CarrierInfo.{module}CassetteNumber{wzindex}"))
  1846. CassetteNum = SC.GetValue<int>($"CarrierInfo.{module}CassetteNumber{wzindex}");
  1847. else
  1848. return false;
  1849. return true;
  1850. }
  1851. }
  1852. }