JelC5000RobotFlippe.cs 98 KB

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