JelC5000RobotFlippe.cs 82 KB

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