RorzeRobot751.cs 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Core.RT.Device.Unit;
  5. using Aitex.Core.RT.Event;
  6. using Aitex.Core.RT.Log;
  7. using Aitex.Core.RT.OperationCenter;
  8. using Aitex.Core.RT.SCCore;
  9. using Aitex.Core.Util;
  10. using MECF.Framework.Common.CommonData;
  11. using MECF.Framework.Common.Communications;
  12. using MECF.Framework.Common.Equipment;
  13. using MECF.Framework.Common.SubstrateTrackings;
  14. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  15. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  16. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  17. using System;
  18. using System.Collections.Generic;
  19. using System.Text;
  20. using System.Threading;
  21. using EventType = Aitex.Core.RT.Event.EventType;
  22. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Rorze
  23. {
  24. public class RorzeRobot751 : RobotBaseDevice, IConnection
  25. {
  26. private bool isSimulatorMode;
  27. private string _scRoot;
  28. public RROpModeEnum CurrentOpMode { get; set; }
  29. public bool IsOrgshCompleted { get; set; }
  30. public bool IsCmdProcessing { get; set; }
  31. public RROpStatusEnum CurrentOpStatus { get; set; }
  32. public int CurrentOperationSpeed { get; set; } //0:Normal, 1-K Set Speed
  33. public string CurrentIdCodeForErrorController { get; set; }
  34. public bool _diEms { get; set; }
  35. public bool _diTempStop { get; set; }
  36. public bool _diVacuumPressure { get; set; }
  37. public bool _diAirSourcePressure { get; set; }
  38. public bool _diZaxisFan { get; set; }
  39. public bool _diUpperArmFan { get; set;}
  40. public bool _diLowerArmFan { get; set; }
  41. public bool _diUpperFinger1ArmWaferExistence1 { get; set; }
  42. public bool _diUpperFinger1ArmWaferExistence2 { get; set; }
  43. public bool _diLowerArmWaferExistence1 { get; set; }
  44. public bool _diLowerArmWaferExistence2 { get; set; }
  45. public bool _diTPEms { get; set; }
  46. public bool _diDeadmanSwitch { get; set; }
  47. public bool _diModeKey { get; set; }
  48. public bool IsEnableSeqNo { get; private set; }
  49. public bool IsEnableCheckSum { get; private set; }
  50. public int CurrentSeqNo { get; set; }
  51. public string PortName;
  52. internal void OnEventReceived(string rawMessage)
  53. {
  54. try
  55. {
  56. string eventname = rawMessage.Split('.')[1].Split(':')[0];
  57. string[] data = rawMessage.Split('.')[1].Split(':')[1].Split('/');
  58. switch (eventname)
  59. {
  60. case "STAT":
  61. ParseSTATStatus(data);
  62. break;
  63. case "GPIO":
  64. ParseDioStatus(data);
  65. break;
  66. }
  67. }
  68. catch(Exception ex)
  69. {
  70. LOG.Write(ex);
  71. }
  72. }
  73. private string _address;
  74. private bool _enableLog;
  75. private RorzeRobot751Connection _connection;
  76. private R_TRIG _trigError = new R_TRIG();
  77. private R_TRIG _trigCommunicationError = new R_TRIG();
  78. private R_TRIG _trigRetryConnect = new R_TRIG();
  79. public string Address => _address;
  80. private PeriodicJob _thread;
  81. private object _locker = new object();
  82. private LinkedList<HandlerBase> _lstHandlers = new LinkedList<HandlerBase>();
  83. private IoSensor _diRobotReady = null; //Normal ON
  84. private IoSensor _diRobotBlade1WaferOn = null; //Off when wafer present
  85. private IoSensor _diRobotBlade2WaferOn = null;
  86. private IoSensor _diRobotError = null; //Normal ON
  87. private IoSensor _diTPinUse = null;
  88. private IoTrigger _doRobotHold = null; // Normal ON
  89. public ModuleName CurrentInteractiveModule { get; private set; }
  90. public bool IsConnected => throw new NotImplementedException();
  91. public bool IsGrippedBlade1 { get; private set; }
  92. public bool IsGrippedBlade2 { get; private set; }
  93. public bool IsPermittedInterlock1 { get; private set; }
  94. public bool IsPermittedInterlock2 { get; private set; }
  95. public bool IsPermittedInterlock3 { get; private set; }
  96. public bool IsPermittedInterlock4 { get; private set; }
  97. public bool IsPermittedInterlock5 { get; private set; }
  98. public bool IsPermittedInterlock6 { get; private set; }
  99. public bool IsPermittedInterlock7 { get; private set; }
  100. public bool IsPermittedInterlock8 { get; private set; }
  101. public float CurrentThetaPosition { get; private set; }
  102. public float CurrentExtensionPosition { get; private set; }
  103. public float CurrentArm1Position { get; private set; }
  104. public float CurrentArm2Position { get; private set; }
  105. public float CurrentZPosition { get; private set; }
  106. public float CommandThetaPosition { get; private set; }
  107. public float CommandExtensionPosition { get; private set; }
  108. public float CommandArm1Position { get; private set; }
  109. public float CommandArm2Position { get; private set; }
  110. public float CommandZPosition { get; private set; }
  111. public int SpeedLevel { get; private set; }
  112. public int SpeedLevelSetting { get; private set; }
  113. public string ReadMemorySpec { get; private set; }
  114. public string ReadTransferStation { get; private set; }
  115. public int ReadSlotNumber { get; private set; }
  116. public string ReadArmPosture { get; private set; }
  117. public RobotArmEnum ReadBladeNo { get; private set; }
  118. public float ReadThetaPosition { get; private set; }
  119. public float ReadExtensionPosition { get; private set; }
  120. public float ReadArm1Position { get; private set; }
  121. public float ReadArm2Position { get; private set; }
  122. public float ReadZPosition { get; private set; }
  123. public Dictionary<string, string> ReadStationItemValues { get; private set; } = new Dictionary<string, string>();
  124. public Dictionary<string, string> ReadStationItemContents { get; private set; } = new Dictionary<string, string>();
  125. public string ReadParameterType { get; private set; }
  126. public string ReadParameterNo { get; private set; }
  127. public string ReadParameterValue { get; private set; }
  128. public bool IsManipulatorBatteryLow { get; private set; }
  129. public bool IsCommandExecutionReady { get; private set; }
  130. public bool IsServoON { get; private set; }
  131. public bool IsErrorOccurred { get; private set; }
  132. public bool IsControllerBatteryLow { get; private set; }
  133. public bool IsCheckInterlockWaferPresenceOnBlade1 { get; private set; }
  134. public bool IsCheckInterlockWaferPresenceOnBlade2 { get; private set; }
  135. public bool IsCheckInterlockPAOp { get; private set; }
  136. public bool IsCheckInterlockPAWaferStatus { get; private set; }
  137. public bool IsCheckInterlockPAWaferStatusByCCD { get; private set; }
  138. public string RobotSystemVersion { get; private set; }
  139. public string RobotSoftwareVersion { get; private set; }
  140. public string ReadMappingTransferStation { get; private set; }
  141. public int ReadMappingSlotNumbers { get; private set; }
  142. public string ReadSlotMap { get; private set; }
  143. public int RobotBodyNumber { get; private set; }
  144. private DateTime _dtActionStart;
  145. public RobotArmEnum chcekingArm { get; set; }
  146. public bool ParseComplete;
  147. public Dictionary<string, float> ReadMappingCalibrationResult { get; private set; }
  148. public RorzeRobot751(string module, string name, string scRoot, IoSensor[] dis, IoTrigger[] dos) : base(module, name)
  149. {
  150. Module = module;
  151. Name = name;
  152. isSimulatorMode = SC.ContainsItem("System.IsSimulatorMode") ? SC.GetValue<bool>("System.IsSimulatorMode") : false;
  153. _scRoot = scRoot;
  154. _address = SC.GetStringValue($"{_scRoot}.{Name}.Address");
  155. _enableLog = SC.GetValue<bool>($"{_scRoot}.{Name}.EnableLogMessage");
  156. RobotBodyNumber = SC.GetValue<int>($"{_scRoot}.{Name}.BodyNumber");
  157. SpeedLevelSetting = SC.GetValue<int>($"{_scRoot}.{Name}.SpeedLevel");
  158. _connection = new RorzeRobot751Connection(this, _address);
  159. _connection.EnableLog(_enableLog);
  160. if (dis != null && dis.Length >= 5)
  161. {
  162. _diRobotReady = dis[0];
  163. _diRobotBlade1WaferOn = dis[1];
  164. _diRobotBlade2WaferOn = dis[2];
  165. _diRobotError = dis[3];
  166. _diTPinUse = dis[4];
  167. _diRobotError.OnSignalChanged += _diRobotError_OnSignalChanged;
  168. _diTPinUse.OnSignalChanged += _diTPinUse_OnSignalChanged;
  169. }
  170. if (dos != null && dos.Length >= 1)
  171. {
  172. _doRobotHold = dos[0];
  173. }
  174. ConnectionManager.Instance.Subscribe($"{Name}", _connection);
  175. _thread = new PeriodicJob(1, OnTimer, $"{_scRoot}.{Name} MonitorHandler", true);
  176. ResetPropertiesAndResponses();
  177. RegisterSpecialData();
  178. RegisterAlarm();
  179. }
  180. public void HandlerMotion(string command, string[] pdata)
  181. {
  182. switch (command)
  183. {
  184. case "MMAP":
  185. try
  186. {
  187. StringBuilder sb = new StringBuilder();
  188. for (int i = 6; i < pdata.Length; i++)
  189. {
  190. string value = pdata[i].Substring(3);
  191. switch (value)
  192. {
  193. case "--":
  194. sb.Append("0");
  195. break;
  196. case "OK":
  197. sb.Append("1");
  198. break;
  199. case "CW":
  200. sb.Append("2");
  201. break;
  202. case "DW":
  203. sb.Append("W");
  204. break;
  205. }
  206. }
  207. ReadSlotMap = sb.ToString();
  208. NotifySlotMapResult(CurrentInteractiveModule, ReadSlotMap);
  209. return;
  210. }
  211. catch (Exception ex)
  212. {
  213. LOG.Write(ex);
  214. }
  215. break;
  216. default:
  217. break;
  218. }
  219. }
  220. private void RegisterAlarm()
  221. {
  222. }
  223. public void NotifyAlarmByErrorCode(string errorcode)
  224. {
  225. EV.Notify($"{Name}Error{errorcode}");
  226. }
  227. private void _diTPinUse_OnSignalChanged(IoSensor arg1, bool arg2)
  228. {
  229. SetMaintenanceMode(!arg1.Value);
  230. }
  231. private void _diRobotError_OnSignalChanged(IoSensor arg1, bool arg2)
  232. {
  233. if (arg1.Value == false)
  234. {
  235. lock (_locker)
  236. {
  237. _lstHandlers.AddLast(new RorzeRobot751ReadHandler(this, "STAT"));
  238. }
  239. OnError("RobotError");
  240. }
  241. }
  242. private void ResetPropertiesAndResponses()
  243. {
  244. }
  245. private void RegisterSpecialData()
  246. {
  247. DATA.Subscribe($"{Module}.{Name}.CurrentArm1Position", () => CurrentArm1Position);
  248. DATA.Subscribe($"{Module}.{Name}.CurrentArm2Position", () => CurrentArm2Position);
  249. DATA.Subscribe($"{Module}.{Name}.CurrentExtensionPosition", () => CurrentExtensionPosition);
  250. DATA.Subscribe($"{Module}.{Name}.CurrentThetaPosition", () => CurrentThetaPosition);
  251. DATA.Subscribe($"{Module}.{Name}.CurrentZPosition", () => CurrentZPosition);
  252. DATA.Subscribe($"{Module}.{Name}.IsManipulatorBatteryLow", () => IsManipulatorBatteryLow);
  253. DATA.Subscribe($"{Module}.{Name}.IsCommandExecutionReady", () => IsCommandExecutionReady);
  254. DATA.Subscribe($"{Module}.{Name}.IsServoON", () => IsServoON);
  255. DATA.Subscribe($"{Module}.{Name}.IsErrorOccurred", () => IsErrorOccurred);
  256. DATA.Subscribe($"{Module}.{Name}.IsControllerBatteryLow", () => IsControllerBatteryLow);
  257. DATA.Subscribe($"{Module}.{Name}.IsWaferPresenceOnBlade1", () => IsWaferPresenceOnBlade1);
  258. DATA.Subscribe($"{Module}.{Name}.IsWaferPresenceOnBlade2", () => IsWaferPresenceOnBlade2);
  259. DATA.Subscribe($"{Module}.{Name}.ErrorCode", () => ErrorCode);
  260. DATA.Subscribe($"{Module}.{Name}.IsGrippedBlade1", () => IsGrippedBlade1);
  261. DATA.Subscribe($"{Module}.{Name}.IsGrippedBlade2", () => IsGrippedBlade2);
  262. DATA.Subscribe($"{Module}.{Name}.IsPermittedInterlock1", () => IsPermittedInterlock1);
  263. DATA.Subscribe($"{Module}.{Name}.IsPermittedInterlock2", () => IsPermittedInterlock2);
  264. DATA.Subscribe($"{Module}.{Name}.IsPermittedInterlock3", () => IsPermittedInterlock3);
  265. DATA.Subscribe($"{Module}.{Name}.IsPermittedInterlock4", () => IsPermittedInterlock4);
  266. DATA.Subscribe($"{Module}.{Name}.IsPermittedInterlock5", () => IsPermittedInterlock5);
  267. DATA.Subscribe($"{Module}.{Name}.IsPermittedInterlock6", () => IsPermittedInterlock6);
  268. DATA.Subscribe($"{Module}.{Name}.IsPermittedInterlock7", () => IsPermittedInterlock7);
  269. DATA.Subscribe($"{Module}.{Name}.IsPermittedInterlock8", () => IsPermittedInterlock8);
  270. DATA.Subscribe($"{Module}.{Name}.RobotSpeed", () => SpeedLevelSetting.ToString());
  271. DATA.Subscribe($"{Name}.RobotSpeed", () =>
  272. {
  273. return SpeedLevelSetting.ToString();
  274. });
  275. OP.Subscribe("SetSpeed", InvokeSetSpeed);
  276. }
  277. private bool OnTimer()
  278. {
  279. try
  280. {
  281. if (!_connection.IsConnected || _connection.IsCommunicationError)
  282. {
  283. lock (_locker)
  284. {
  285. _lstHandlers.Clear();
  286. }
  287. _trigRetryConnect.CLK = !_connection.IsConnected;
  288. if (_trigRetryConnect.Q)
  289. {
  290. if (!_connection.Connect())
  291. {
  292. EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}.{Name}");
  293. }
  294. else
  295. {
  296. //_lstHandler.AddLast(new RobotHirataR4QueryPinHandler(this, _deviceAddress));
  297. //_lstHandler.AddLast(new RobotHirataR4SetCommModeHandler(this, _deviceAddress, EnumRfPowerCommunicationMode.Host));
  298. }
  299. }
  300. return true;
  301. }
  302. HandlerBase handler = null;
  303. lock (_locker)
  304. {
  305. if (!_connection.IsBusy)
  306. {
  307. if (_lstHandlers.Count > 0)
  308. {
  309. handler = _lstHandlers.First.Value;
  310. ExecuteHandler(handler);
  311. _lstHandlers.RemoveFirst();
  312. }
  313. }
  314. else
  315. {
  316. _connection.MonitorTimeout();
  317. _trigCommunicationError.CLK = _connection.IsCommunicationError;
  318. if (_trigCommunicationError.Q)
  319. {
  320. _lstHandlers.Clear();
  321. //EV.PostAlarmLog(Module, $"{Module}.{Name} communication error, {_connection.LastCommunicationError}");
  322. OnError($"{Module}.{Name} communication error, {_connection.LastCommunicationError}");
  323. //_trigActionDone.CLK = true;
  324. }
  325. }
  326. }
  327. }
  328. catch (Exception ex)
  329. {
  330. LOG.Write(ex);
  331. }
  332. return true;
  333. }
  334. public bool Connect()
  335. {
  336. return _connection.Connect();
  337. }
  338. public bool Disconnect()
  339. {
  340. return _connection.Disconnect();
  341. }
  342. public override bool IsReady()
  343. {
  344. //if (_diRobotReady!=null && !_diRobotReady.Value)
  345. // return false;
  346. if (_diRobotError != null && !_diRobotError.Value)
  347. return false;
  348. if (_diTPinUse != null && !_diTPinUse.Value)
  349. return false;
  350. return RobotState == RobotStateEnum.Idle && !IsBusy && fsm.CheckExecuted();
  351. }
  352. public bool ParseReadData(string _command, string[] rdata)
  353. {
  354. try
  355. {
  356. switch(_command)
  357. {
  358. case "STAT":
  359. rdata[0] = rdata[0].Split(':')[1];
  360. ParseSTATStatus(rdata);
  361. break;
  362. case "GPIO":
  363. rdata[0] = rdata[0].Split(':')[1];
  364. ParseDioStatus(rdata);
  365. break;
  366. case "GMAP":
  367. ParseSlotMap(rdata);
  368. break;
  369. case "GCHK":
  370. ParseWaferPresence(rdata);
  371. break;
  372. case "EXST":
  373. ParseWaferIsPresence(rdata);
  374. break;
  375. }
  376. //if (_command == "RSLV") //Read the speed level
  377. //{
  378. // return (rdata.Length == 1 && ParseSpeedLevel(rdata[0]));
  379. //}
  380. //if (_command == "RPOS") //Reference current postion
  381. //{
  382. // return (rdata.Length > 1 && ParsePositionData(rdata));
  383. //}
  384. //if (_command == "RSTP") //Reference registered position, read the save postion for station
  385. //{
  386. // return (rdata.Length > 6 && ParseRegisteredPositionData(rdata));
  387. //}
  388. //if (_command == "RSTR") //Reference station item value
  389. //{
  390. // return (rdata.Length == 4 && ParseStationData(rdata));
  391. //}
  392. //if (_command == "RPRM") //Reference the parameter values of the specified unit
  393. //{
  394. // return (rdata.Length == 3 && ParseParameterData(rdata));
  395. //}
  396. //if (_command == "RMSK") //Reference the interlock information
  397. //{
  398. // return (rdata.Length == 1 && ParseInterlockInfo(rdata));
  399. //}
  400. //if (_command == "RVER") //Reference the software version
  401. //{
  402. // return (rdata.Length == 2 && ParseSoftwareVersion(rdata));
  403. //}
  404. //if (_command == "RMAP") //Reference the slot map
  405. //{
  406. // return (rdata.Length > 2 && ParseSlotMap(rdata));
  407. //}
  408. //if (_command == "RMPD") //reference the mapping data
  409. //{
  410. // return (rdata.Length > 1 && ParseMappingData(rdata));
  411. //}
  412. //if (_command == "RMCA") // Reference the mapping calibration result
  413. //{
  414. // return (rdata.Length > 1 && ParseMappingCalibrationResult(rdata));
  415. //}
  416. //if (_command == "RALN") // Reference the alignment result
  417. //{
  418. // return true;
  419. //}
  420. //if (_command == "RACA") // Reference calibration result for alignment
  421. //{
  422. // return true;
  423. //}
  424. return true;
  425. }
  426. catch (Exception ex)
  427. {
  428. LOG.Write(ex);
  429. return true;
  430. }
  431. }
  432. private void ParseDioStatus(string[] rdata)
  433. {
  434. var byte1=Convert.ToByte(rdata[0].Substring(12, 2),16);
  435. var byte2 = Convert.ToByte(rdata[0].Substring(10, 2),16);
  436. IsWaferPresenceOnBlade1 = ((byte2 >> 2) & 0x01) == 1 && ((byte2 >> 3) & 0x01) == 1;
  437. IsWaferPresenceOnBlade2 = ((byte1 >> 0) & 0x01) == 1 && ((byte1 >> 1) & 0x01) == 1;
  438. }
  439. public bool ParseSTATStatus(string[] status)
  440. {
  441. try
  442. {
  443. CurrentOpMode = (RROpModeEnum)int.Parse(status[0].Substring(0,1));
  444. IsOrgshCompleted = status[0][1] == '1';
  445. IsCmdProcessing = status[0][2] == '1';
  446. CurrentOpStatus = (RROpStatusEnum)int.Parse(status[0].Substring(3, 1));
  447. CurrentOperationSpeed = int.Parse(status[0].Substring(4, 1));
  448. CurrentIdCodeForErrorController = status[1].Substring(0, 2);
  449. CurrentIdCodeForErrorController = status[1].Substring(2, 2);
  450. return true;
  451. }
  452. catch (Exception ex)
  453. {
  454. LOG.Write(ex);
  455. return true;
  456. }
  457. }
  458. public bool ParseWaferPresence(string[] data)
  459. {
  460. try
  461. {
  462. var str = data[0].Split(':')[1];
  463. IsWaferPresenceOnBlade2 = int.Parse(str.Substring(0, 1)) == 0 ? false:true ;
  464. IsWaferPresenceOnBlade1 = int.Parse(str.Substring(1, 1)) == 0 ? false : true;
  465. return true;
  466. }
  467. catch (Exception ex)
  468. {
  469. LOG.Write(ex);
  470. return true;
  471. }
  472. }
  473. public bool ParseWaferIsPresence(string[] data)
  474. {
  475. try
  476. {
  477. var str = data[0].Split(':')[1];
  478. if (chcekingArm == RobotArmEnum.Lower)
  479. {
  480. IsWaferPresenceOnBlade1 = int.Parse(str.Substring(0, 1)) == 1 ? true : false;
  481. }
  482. else if (chcekingArm == RobotArmEnum.Upper)
  483. {
  484. IsWaferPresenceOnBlade2 = int.Parse(str.Substring(0, 1)) == 1 ? true : false;
  485. }
  486. ParseComplete = true;
  487. return true;
  488. }
  489. catch (Exception ex)
  490. {
  491. LOG.Write(ex);
  492. return true;
  493. }
  494. }
  495. public bool ParseSpeedLevel(string speedlevel)
  496. {
  497. try
  498. {
  499. int level = Convert.ToInt32(speedlevel);
  500. if (level < 1 || level > 3) return false;
  501. SpeedLevel = level;
  502. return true;
  503. }
  504. catch (Exception ex)
  505. {
  506. LOG.Write(ex);
  507. return false;
  508. }
  509. }
  510. public bool ParsePositionData(string[] pdata)
  511. {
  512. try
  513. {
  514. if (pdata[0] == "R")
  515. {
  516. CommandThetaPosition = Convert.ToSingle(pdata[1]) / 1000;
  517. CommandExtensionPosition = Convert.ToSingle(pdata[2]) / 1000;
  518. CommandArm1Position = Convert.ToSingle(pdata[3]) / 1000;
  519. CommandArm2Position = Convert.ToSingle(pdata[4]) / 1000;
  520. CommandZPosition = Convert.ToSingle(pdata[5]) / 1000;
  521. return true;
  522. }
  523. if (pdata[0] == "F")
  524. {
  525. CurrentThetaPosition = Convert.ToSingle(pdata[1]) / 1000;
  526. PositionAxis1 = CurrentThetaPosition;
  527. CurrentExtensionPosition = Convert.ToSingle(pdata[2]) / 1000;
  528. PositionAxis2 = CurrentExtensionPosition;
  529. CurrentArm1Position = Convert.ToSingle(pdata[3]) / 1000;
  530. PositionAxis3 = CurrentArm1Position;
  531. CurrentArm2Position = Convert.ToSingle(pdata[4]) / 1000;
  532. PositionAxis4 = CurrentArm2Position;
  533. CurrentZPosition = Convert.ToSingle(pdata[5]) / 1000;
  534. PositionAxis5 = CurrentZPosition;
  535. return true;
  536. }
  537. return false;
  538. }
  539. catch (Exception ex)
  540. {
  541. LOG.Write(ex);
  542. return false;
  543. }
  544. }
  545. public bool ParseRegisteredPositionData(string[] pdata)
  546. {
  547. return true;
  548. }
  549. public bool ParseStationData(string[] pdata)
  550. {
  551. try
  552. {
  553. ReadMemorySpec = pdata[0];
  554. ReadTransferStation = pdata[1];
  555. if (ReadStationItemValues.ContainsKey(pdata[2]))
  556. ReadStationItemValues.Remove(pdata[2]);
  557. ReadStationItemValues.Add(pdata[2], pdata[3]);
  558. return true;
  559. }
  560. catch (Exception ex)
  561. {
  562. LOG.Write(ex);
  563. return false;
  564. }
  565. }
  566. public bool ParseParameterData(string[] pdata)
  567. {
  568. try
  569. {
  570. ReadParameterType = pdata[0];
  571. ReadParameterNo = pdata[1];
  572. ReadParameterValue = pdata[2];
  573. return true;
  574. }
  575. catch (Exception ex)
  576. {
  577. LOG.Write(ex);
  578. return false;
  579. }
  580. }
  581. public bool ParseInterlockInfo(string[] pdata)
  582. {
  583. try
  584. {
  585. int intdata = Convert.ToInt16(pdata[0]);
  586. IsCheckInterlockWaferPresenceOnBlade1 = (intdata & 0x1) == 0;
  587. IsCheckInterlockWaferPresenceOnBlade2 = (intdata & 0x2) == 0;
  588. IsCheckInterlockPAOp = (intdata & 0x10) == 0;
  589. IsCheckInterlockPAWaferStatus = (intdata & 0x20) == 0;
  590. IsCheckInterlockPAWaferStatusByCCD = (intdata & 0x40) == 0;
  591. return true;
  592. }
  593. catch (Exception ex)
  594. {
  595. LOG.Write(ex);
  596. return false;
  597. }
  598. }
  599. public bool ParseSoftwareVersion(string[] pdata)
  600. {
  601. try
  602. {
  603. RobotSystemVersion = pdata[0];
  604. RobotSoftwareVersion = pdata[1];
  605. return true;
  606. }
  607. catch (Exception ex)
  608. {
  609. LOG.Write(ex);
  610. return false;
  611. }
  612. }
  613. public bool ParseSlotMap(string[] pdata)
  614. {
  615. // n = 0 : Wafer does not exist.
  616. //1 : Wafer exists.
  617. //2 : Thickness abnormal(thick)
  618. //3 : Cross
  619. //4 : Bow / Lift
  620. //7 : Multiple wafers
  621. //8 : Thickness abnormal(thin)
  622. //9 : Mapping failure
  623. try
  624. {
  625. ReadSlotMap = pdata[0].Replace("2","W").Replace("3","2").Replace("4","?").Replace("7","W").Replace("8","?").Replace("9","?");
  626. NotifySlotMapResult(CurrentInteractiveModule, ReadSlotMap);
  627. return true;
  628. }
  629. catch (Exception ex)
  630. {
  631. LOG.Write(ex);
  632. return false;
  633. }
  634. }
  635. public bool ParseMappingData(string[] pdata)
  636. {
  637. try
  638. {
  639. ReadMappingTransferStation = pdata[0];
  640. List<string> lstupdata = new List<string>();
  641. List<string> lstdowndata = new List<string>();
  642. for (int i = 0; i < (pdata.Length - 1) / 2; i++)
  643. {
  644. lstupdata.Add(pdata[2 * i + 1].Remove(0, 3));
  645. lstdowndata.Add(pdata[2 * i + 2]);
  646. }
  647. ReadMappingDownData = lstdowndata.ToArray();
  648. ReadMappingUpData = lstupdata.ToArray();
  649. return true;
  650. }
  651. catch (Exception ex)
  652. {
  653. LOG.Write(ex);
  654. return false;
  655. }
  656. }
  657. public bool ParseMappingCalibrationResult(string[] pdata)
  658. {
  659. try
  660. {
  661. ReadMappingTransferStation = pdata[0];
  662. ReadMappingCalibrationResult.Clear();
  663. ReadMappingCalibrationResult.Add("LowestLaySlotPosition", Convert.ToInt32(pdata[1]) / 1000);
  664. ReadMappingCalibrationResult.Add("HighestLaySlotPosition", Convert.ToInt32(pdata[2]) / 1000);
  665. ReadMappingCalibrationResult.Add("WaferWidth", Convert.ToInt32(pdata[3]) / 1000);
  666. ReadMappingCalibrationResult.Add("ThreshhholdValueofDoubleInsertion", Convert.ToInt32(pdata[4]) / 1000);
  667. ReadMappingCalibrationResult.Add("ThreshhholdValueofSlantingInsertion1", Convert.ToInt32(pdata[5]) / 1000);
  668. ReadMappingCalibrationResult.Add("ThreshhholdValueofSlantingInsertion2", Convert.ToInt32(pdata[6]) / 1000);
  669. return true;
  670. }
  671. catch (Exception ex)
  672. {
  673. LOG.Write(ex);
  674. return false;
  675. }
  676. }
  677. protected override bool fClear(object[] param)
  678. {
  679. lock (_locker)
  680. {
  681. _lstHandlers.Clear();
  682. _connection.ForceClear();
  683. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "CCLR", "E"));
  684. _lstHandlers.AddLast(new RorzeRobot751ReadHandler(this, "STAT"));
  685. }
  686. return true;
  687. }
  688. protected override bool fStartReadData(object[] param)
  689. {
  690. if (param.Length < 1) return false;
  691. string readcommand = param[0].ToString();
  692. switch (readcommand)
  693. {
  694. case "CurrentStatus":
  695. lock (_locker)
  696. {
  697. _lstHandlers.AddLast(new RorzeRobot751ReadHandler(this, "STAT"));
  698. }
  699. break;
  700. case "SignalStatus":
  701. lock (_locker)
  702. {
  703. _lstHandlers.AddLast(new RorzeRobot751ReadHandler(this, "GPIO"));
  704. }
  705. break;
  706. case "CheckWaferIsPresence":
  707. {
  708. _dtActionStart = DateTime.Now;
  709. ParseComplete = false;
  710. IsBusy = true;
  711. RobotArmEnum arm = chcekingArm = (RobotArmEnum)param[1];
  712. int interval =Convert.ToInt16(param[2]);
  713. switch (arm)
  714. {
  715. case RobotArmEnum.Lower:
  716. _lstHandlers.AddLast(new RorzeRobot751ReadHandler(this, "EXST", $"(2,{interval})"));
  717. break;
  718. case RobotArmEnum.Upper:
  719. _lstHandlers.AddLast(new RorzeRobot751ReadHandler(this, "EXST", $"(1,{interval})"));
  720. break;
  721. }
  722. }
  723. break;
  724. case "CheckWaferPresence":
  725. {
  726. RobotArmEnum arm = chcekingArm = (RobotArmEnum)param[1];
  727. switch (arm)
  728. {
  729. case RobotArmEnum.Lower:
  730. _lstHandlers.AddLast(new RorzeRobot751ReadHandler(this, "GCHK", "(2)"));
  731. break;
  732. case RobotArmEnum.Upper:
  733. _lstHandlers.AddLast(new RorzeRobot751ReadHandler(this, "GCHK", "(1)"));
  734. break;
  735. case RobotArmEnum.Both:
  736. _lstHandlers.AddLast(new RorzeRobot751ReadHandler(this, "GCHK", "(3)"));
  737. break;
  738. }
  739. }
  740. break;
  741. default:
  742. break;
  743. }
  744. return true;
  745. }
  746. protected override bool fMonitorReadData(object[] param)
  747. {
  748. var readParameter = CurrentParamter[0].ToString();
  749. switch (readParameter)
  750. {
  751. case "CurrentStatus":
  752. {
  753. IsBusy = false;
  754. }
  755. break;
  756. case "SignalStatus":
  757. {
  758. IsBusy = false;
  759. }
  760. break;
  761. case "CheckWaferPresence":
  762. {
  763. IsBusy = false;
  764. }
  765. break;
  766. case "WaferSize":
  767. IsBusy = false;
  768. if (_setSizeArm == RobotArmEnum.Lower || _setSizeArm == RobotArmEnum.Blade1)
  769. WaferManager.Instance.UpdateWaferSize(RobotModuleName, 0, _setSize);
  770. if (_setSizeArm == RobotArmEnum.Upper || _setSizeArm == RobotArmEnum.Upper)
  771. WaferManager.Instance.UpdateWaferSize(RobotModuleName, 1, _setSize);
  772. if (_setSizeArm == RobotArmEnum.Both)
  773. {
  774. WaferManager.Instance.UpdateWaferSize(RobotModuleName, 0, _setSize);
  775. WaferManager.Instance.UpdateWaferSize(RobotModuleName, 1, _setSize);
  776. }
  777. Size = _setSize;
  778. break;
  779. case "CheckWaferIsPresence":
  780. {
  781. if (!ParseComplete)
  782. {
  783. if (DateTime.Now - _dtActionStart < TimeSpan.FromSeconds(30))
  784. {
  785. //OnError("CheckWaferIsPresence timeout");
  786. return false;
  787. }
  788. else
  789. {
  790. ParseComplete = false;
  791. OnError("CheckWaferIsPresence timeout");
  792. return true;
  793. }
  794. }
  795. else
  796. {
  797. ParseComplete = false;
  798. IsBusy = false;
  799. }
  800. }
  801. break;
  802. }
  803. return true;
  804. }
  805. private void ExecuteHandler(HandlerBase handler)
  806. {
  807. _connection.Execute(handler);
  808. }
  809. private string Checksum(byte[] bytes)
  810. {
  811. int sum = 0;
  812. foreach (byte code in bytes)
  813. {
  814. sum += code;
  815. }
  816. string hex = String.Format("{0:X2}", sum % 256);
  817. return hex;
  818. }
  819. protected override bool fStartSetParameters(object[] param)
  820. {
  821. try
  822. {
  823. string strParameter;
  824. string setcommand = param[0].ToString();
  825. _setParameter = setcommand;
  826. switch (setcommand)
  827. {
  828. case "RobotSpeed": // SSPD Set the motion speed
  829. int speedlevel = Convert.ToInt32(param[2]);
  830. lock (_locker)
  831. {
  832. _lstHandlers.AddLast(new RorzeRobot751SetHandler(this, "SSPD", $"(0,{speedlevel})"));
  833. }
  834. if (SC.ContainsItem($"{_scRoot}.{Name}.SpeedLevel"))
  835. {
  836. SC.SetItemValue($"{_scRoot}.{Name}.SpeedLevel", Convert.ToInt32(speedlevel));
  837. SpeedLevelSetting = SC.GetValue<int>($"{_scRoot}.{Name}.SpeedLevel");
  838. }
  839. break;
  840. case "TransferSpeedLevel": //SSLV Select the transfer speed level
  841. string sslvlevel = param[1].ToString();
  842. int nSpeed = 100;
  843. if (sslvlevel == "1") nSpeed = 100;
  844. if (sslvlevel == "2") nSpeed = 50;
  845. if (sslvlevel == "3") nSpeed = 10;
  846. if (!"123".Contains(sslvlevel))
  847. {
  848. EV.PostAlarmLog(Name, $"Set {setcommand} with invalid parameter:" + sslvlevel);
  849. return false;
  850. }
  851. lock (_locker)
  852. {
  853. _lstHandlers.AddLast(new RorzeRobot751SetHandler(this, "SSPD", $"(0,{nSpeed})"));
  854. }
  855. if (SC.ContainsItem($"{_scRoot}.{Name}.SpeedLevel"))
  856. {
  857. SC.SetItemValue($"{_scRoot}.{Name}.SpeedLevel", Convert.ToInt32(sslvlevel));
  858. SpeedLevelSetting = SC.GetValue<int>($"{_scRoot}.{Name}.SpeedLevel");
  859. }
  860. break;
  861. case "WaferSize":
  862. _setSizeArm = (RobotArmEnum)param[1];
  863. _setSize = (WaferSize)param[2];
  864. break;
  865. }
  866. }
  867. catch (Exception)
  868. {
  869. string reason = "";
  870. if (param != null)
  871. {
  872. foreach (var para in param)
  873. {
  874. reason += para.ToString() + ",";
  875. }
  876. }
  877. EV.PostAlarmLog(Name, "Set command parameter invalid:" + reason);
  878. return false;
  879. }
  880. return true;
  881. }
  882. private string _setParameter;
  883. private RobotArmEnum _setSizeArm;
  884. private WaferSize _setSize;
  885. protected override bool fMonitorSetParamter(object[] param)
  886. {
  887. IsBusy = false;
  888. switch (_setParameter)
  889. {
  890. case "WaferSize":
  891. if (_setSizeArm == RobotArmEnum.Lower || _setSizeArm == RobotArmEnum.Blade1)
  892. WaferManager.Instance.UpdateWaferSize(RobotModuleName, 0, _setSize);
  893. if (_setSizeArm == RobotArmEnum.Upper || _setSizeArm == RobotArmEnum.Upper)
  894. WaferManager.Instance.UpdateWaferSize(RobotModuleName, 1, _setSize);
  895. if (_setSizeArm == RobotArmEnum.Both)
  896. {
  897. WaferManager.Instance.UpdateWaferSize(RobotModuleName, 0, _setSize);
  898. WaferManager.Instance.UpdateWaferSize(RobotModuleName, 1, _setSize);
  899. }
  900. Size = _setSize;
  901. break;
  902. }
  903. return true;
  904. }
  905. protected override bool fStartTransferWafer(object[] param)
  906. {
  907. return false;
  908. }
  909. protected override bool fStartUnGrip(object[] param)
  910. {
  911. lock (_locker)
  912. {
  913. RobotArmEnum arm = (RobotArmEnum)param[0];
  914. switch(arm)
  915. {
  916. case RobotArmEnum.Lower:
  917. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "UCLM", "(2)"));
  918. break;
  919. case RobotArmEnum.Upper:
  920. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "UCLM", "(1)"));
  921. break;
  922. case RobotArmEnum.Both:
  923. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "UCLM", "(3)"));
  924. break;
  925. }
  926. }
  927. return true;
  928. }
  929. protected override bool fStartGrip(object[] param)
  930. {
  931. lock (_locker)
  932. {
  933. RobotArmEnum arm = (RobotArmEnum)param[0];
  934. switch (arm)
  935. {
  936. case RobotArmEnum.Lower:
  937. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "CLMP", "(2)"));
  938. break;
  939. case RobotArmEnum.Upper:
  940. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "CLMP", "(1)"));
  941. break;
  942. case RobotArmEnum.Both:
  943. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "CLMP", "(3)"));
  944. break;
  945. }
  946. }
  947. return true;
  948. }
  949. protected override bool fStartInit(object[] param)
  950. {
  951. SpeedLevelSetting = SC.GetValue<int>($"{_scRoot}.{Name}.SpeedLevel");
  952. lock (_locker)
  953. {
  954. if (_doRobotHold != null)
  955. {
  956. _doRobotHold.SetTrigger(true, out _);
  957. Thread.Sleep(100);
  958. }
  959. _lstHandlers.AddLast(new RorzeRobot751SetHandler(this, "EVNT", "(0,1)"));
  960. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "INIT"));
  961. _lstHandlers.AddLast(new RorzeRobot751SetHandler(this, "MODE","(1,0)"));
  962. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "ORGN","(0,0)"));
  963. _lstHandlers.AddLast(new RorzeRobot751SetHandler(this, "SSPD", $"(0,{SpeedLevelSetting})"));
  964. }
  965. return true;
  966. }
  967. protected override bool fStartHome(object[] param)
  968. {
  969. SpeedLevelSetting = SC.GetValue<int>($"{_scRoot}.{Name}.SpeedLevel");
  970. lock (_locker)
  971. {
  972. if (_doRobotHold != null)
  973. {
  974. _doRobotHold.SetTrigger(true, out _);
  975. Thread.Sleep(100);
  976. }
  977. //_lstHandlers.AddLast(new SR100RobotMotionHandler(this, "CSOL", "F,1,0"));
  978. _lstHandlers.AddLast(new RorzeRobot751SetHandler(this, "EVNT", "(0,1)"));
  979. _lstHandlers.AddLast(new RorzeRobot751SetHandler(this, "INIT"));
  980. _lstHandlers.AddLast(new RorzeRobot751SetHandler(this, "MODE", "(1,0)"));
  981. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "ORGN", "(0,0)"));
  982. _lstHandlers.AddLast(new RorzeRobot751SetHandler(this, "SSPD", $"(0,{SpeedLevelSetting})"));
  983. }
  984. return true;
  985. }
  986. protected override bool fStartGoTo(object[] param)
  987. {
  988. try
  989. {
  990. RobotArmEnum arm = (RobotArmEnum)param[0];
  991. ModuleName module = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  992. if (ModuleHelper.IsLoadPort(module))
  993. {
  994. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(module.ToString());
  995. if (lp != null)
  996. lp.NoteTransferStart();
  997. }
  998. BladeTarget = module;
  999. Blade1Target = module;
  1000. Blade2Target = module;
  1001. int slot = (int)param[2] + 1;
  1002. int TrsSt = GetStationsName(module);
  1003. int nArm = 0;
  1004. if (arm == RobotArmEnum.Lower)
  1005. nArm = 2;
  1006. if (arm == RobotArmEnum.Upper)
  1007. nArm = 1;
  1008. if (arm == RobotArmEnum.Both)
  1009. nArm = 3;
  1010. if (nArm == 0)
  1011. return false;
  1012. RobotPostionEnum postype = (RobotPostionEnum)param[3];
  1013. string strCmd = string.Empty;
  1014. int Id = 1;
  1015. if (postype == RobotPostionEnum.PickExtend)
  1016. {
  1017. Id = 1;
  1018. strCmd = "EXTD";
  1019. MoveInfo = new RobotMoveInfo()
  1020. {
  1021. ArmTarget = arm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1022. BladeTarget = (arm == RobotArmEnum.Lower ? RobotArm.ArmA.ToString() : RobotArm.ArmB.ToString()) + "." + module.ToString(),
  1023. };
  1024. }
  1025. if (postype == RobotPostionEnum.PickRetracted)
  1026. {
  1027. Id = 1;
  1028. strCmd = "HOME";
  1029. }
  1030. if (postype == RobotPostionEnum.PlaceExtend)
  1031. {
  1032. Id = 3;
  1033. strCmd = "EXTD";
  1034. MoveInfo = new RobotMoveInfo()
  1035. {
  1036. ArmTarget = arm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1037. BladeTarget = (arm == RobotArmEnum.Lower ? RobotArm.ArmA.ToString() : RobotArm.ArmB.ToString()) + "." + module.ToString(),
  1038. };
  1039. }
  1040. if (postype == RobotPostionEnum.PlaceRetract)
  1041. {
  1042. Id = 1;
  1043. strCmd = "HOME";
  1044. }
  1045. if (postype == RobotPostionEnum.PickReady)
  1046. {
  1047. Id = 1;
  1048. strCmd = "HOME";
  1049. }
  1050. if (postype == RobotPostionEnum.PlaceReady)
  1051. {
  1052. Id = 2;
  1053. strCmd = "HOME";
  1054. }
  1055. string strpara = $"{Id},{nArm},{TrsSt},{slot}";
  1056. //if (postype == RobotPostionEnum.PickReady)
  1057. //{
  1058. // strCmd = "MGT1";
  1059. // var Speed1 = (int)param[4];
  1060. // var ZDistince = (int)param[5];
  1061. // strpara = $"{nArm},{TrsSt},{slot},{Speed1},{ZDistince}";
  1062. //}
  1063. //if (postype == RobotPostionEnum.PlaceReady)
  1064. //{
  1065. // strCmd = "MPT1";
  1066. // var falg1 = (int)param[4];
  1067. // var falg2 = (int)param[5];
  1068. // var Speed1 = (int)param[6];
  1069. // var Speed2 = (int)param[7];
  1070. // var ZDistince = (int)param[8];
  1071. // strpara = $"{nArm},{TrsSt},{slot},{falg1},{falg2},{Speed1},{Speed2},{ZDistince}";
  1072. //}
  1073. lock (_locker)
  1074. {
  1075. lock (_locker)
  1076. {
  1077. if (_lstHandlers.Count == 0 && !_connection.IsBusy)
  1078. {
  1079. ExecuteHandler(new RorzeRobot751MotionHandler(this, strCmd, $"({strpara})"));
  1080. }
  1081. else
  1082. {
  1083. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, strCmd, $"({strpara})"));
  1084. }
  1085. }
  1086. }
  1087. return true;
  1088. }
  1089. catch (Exception ex)
  1090. {
  1091. LOG.Write(ex);
  1092. return false;
  1093. }
  1094. }
  1095. protected override bool fGoToComplete(object[] param)
  1096. {
  1097. try
  1098. {
  1099. RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
  1100. ModuleName sourcemodule = (ModuleName)Enum.Parse(typeof(ModuleName), CurrentParamter[1].ToString());
  1101. int SourceslotIndex = (int)CurrentParamter[2];
  1102. RobotPostionEnum postype = (RobotPostionEnum)CurrentParamter[3];
  1103. switch (postype)
  1104. {
  1105. //case RobotPostionEnum.PickExtend:
  1106. case RobotPostionEnum.PickRetracted:
  1107. BladeTarget = ModuleName.System;
  1108. Blade1Target = ModuleName.System;
  1109. Blade2Target = ModuleName.System;
  1110. MoveInfo = new RobotMoveInfo()
  1111. {
  1112. ArmTarget = arm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1113. BladeTarget = (arm == RobotArmEnum.Lower ? RobotArm.ArmA.ToString() : RobotArm.ArmB.ToString()) + "." + ModuleName.System,
  1114. };
  1115. if (arm == RobotArmEnum.Lower)
  1116. {
  1117. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 0);
  1118. UpdateThicknessType(sourcemodule, SourceslotIndex, RobotModuleName, 0);
  1119. //if (isSimulatorMode || GetWaferState(arm) == RobotArmWaferStateEnum.Present)
  1120. // WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 0);
  1121. //else
  1122. // OnError("Wafer detect error");
  1123. }
  1124. if (arm == RobotArmEnum.Upper)
  1125. {
  1126. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 1);
  1127. UpdateThicknessType(sourcemodule, SourceslotIndex, RobotModuleName, 1);
  1128. //if (isSimulatorMode || GetWaferState(arm) == RobotArmWaferStateEnum.Present)
  1129. // WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 1);
  1130. //else
  1131. // OnError("Wafer detect error");
  1132. }
  1133. if (arm == RobotArmEnum.Both)
  1134. {
  1135. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 0);
  1136. UpdateThicknessType(sourcemodule, SourceslotIndex, RobotModuleName, 0);
  1137. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 1);
  1138. UpdateThicknessType(sourcemodule, SourceslotIndex, RobotModuleName, 1);
  1139. //if (isSimulatorMode || GetWaferState(arm) == RobotArmWaferStateEnum.Present)
  1140. //{
  1141. // WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 0);
  1142. // WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 1);
  1143. //}
  1144. //else
  1145. // OnError("Wafer detect error");
  1146. }
  1147. break;
  1148. //case RobotPostionEnum.PlaceExtend:
  1149. case RobotPostionEnum.PlaceRetract:
  1150. BladeTarget = ModuleName.System;
  1151. Blade1Target = ModuleName.System;
  1152. Blade2Target = ModuleName.System;
  1153. MoveInfo = new RobotMoveInfo()
  1154. {
  1155. ArmTarget = arm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1156. BladeTarget = (arm == RobotArmEnum.Lower ? RobotArm.ArmA.ToString() : RobotArm.ArmB.ToString()) + "." + ModuleName.System,
  1157. };
  1158. if (arm == RobotArmEnum.Lower)
  1159. {
  1160. WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, SourceslotIndex);
  1161. UpdateThicknessType(RobotModuleName, 0, sourcemodule, SourceslotIndex);
  1162. //if (isSimulatorMode || GetWaferState(arm) == RobotArmWaferStateEnum.Absent)
  1163. // WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, SourceslotIndex);
  1164. //else
  1165. // OnError("Wafer detect error");
  1166. }
  1167. if (arm == RobotArmEnum.Upper)
  1168. {
  1169. WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, SourceslotIndex);
  1170. UpdateThicknessType(RobotModuleName, 1, sourcemodule, SourceslotIndex);
  1171. //if (isSimulatorMode || GetWaferState(arm) == RobotArmWaferStateEnum.Absent)
  1172. // WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, SourceslotIndex);
  1173. //else
  1174. // OnError("Wafer detect error");
  1175. }
  1176. if (arm == RobotArmEnum.Both)
  1177. {
  1178. WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, SourceslotIndex);
  1179. UpdateThicknessType(RobotModuleName, 0, sourcemodule, SourceslotIndex);
  1180. WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, SourceslotIndex);
  1181. UpdateThicknessType(RobotModuleName, 1, sourcemodule, SourceslotIndex);
  1182. //if (isSimulatorMode || GetWaferState(arm) == RobotArmWaferStateEnum.Absent)
  1183. //{
  1184. // WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, SourceslotIndex);
  1185. // WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, SourceslotIndex);
  1186. //}
  1187. //else
  1188. // OnError("Wafer detect error");
  1189. }
  1190. break;
  1191. case RobotPostionEnum.PickReady:
  1192. case RobotPostionEnum.PlaceReady:
  1193. {
  1194. BladeTarget = ModuleName.System;
  1195. Blade1Target = ModuleName.System;
  1196. Blade2Target = ModuleName.System;
  1197. if (arm == RobotArmEnum.Lower)
  1198. {
  1199. MoveInfo = new RobotMoveInfo()
  1200. {
  1201. ArmTarget = RobotArm.ArmA,
  1202. BladeTarget = RobotArm.ArmA+"."+ ModuleName.System.ToString(),
  1203. };
  1204. }
  1205. if (arm == RobotArmEnum.Upper)
  1206. {
  1207. MoveInfo = new RobotMoveInfo()
  1208. {
  1209. ArmTarget = RobotArm.ArmB,
  1210. BladeTarget = RobotArm.ArmB + "." + ModuleName.System.ToString(),
  1211. };
  1212. }
  1213. }
  1214. break;
  1215. }
  1216. }
  1217. catch (Exception ex)
  1218. {
  1219. LOG.Write(ex);
  1220. }
  1221. return base.fGoToComplete(param);
  1222. }
  1223. protected override bool fStop(object[] param)
  1224. {
  1225. lock (_locker)
  1226. {
  1227. if (_doRobotHold != null)
  1228. _doRobotHold.SetTrigger(false, out _);
  1229. _lstHandlers.Clear();
  1230. _connection.ForceClear();
  1231. //ExecuteHandler(new SR100RobotMotionHandler(this, "CSTP", "E"));
  1232. }
  1233. return true; ;
  1234. }
  1235. protected override bool fStartMove(object[] param)
  1236. {
  1237. try
  1238. {
  1239. string strCmd = param[0].ToString();
  1240. string strpara = string.Empty;
  1241. for (int i = 1; i < param.Length; i++)
  1242. {
  1243. if (i == 1)
  1244. strpara += param[i].ToString();
  1245. else
  1246. strpara += "," + param[i].ToString();
  1247. }
  1248. lock (_locker)
  1249. {
  1250. //_lstHandlers.AddLast(new SR100RobotMotionHandler(this, strCmd, strpara));
  1251. //_lstHandlers.AddLast(new SR100RobotReadHandler(this, "RPOS", "F"));
  1252. }
  1253. return true;
  1254. }
  1255. catch (Exception ex)
  1256. {
  1257. LOG.Write(ex);
  1258. return false;
  1259. }
  1260. }
  1261. private int GetStationsName(ModuleName module)
  1262. {
  1263. try
  1264. {
  1265. if (ModuleHelper.IsLoadPort(module))
  1266. {
  1267. var infopadindex = SC.GetStringValue($"CarrierInfo.{module}ThicknessType") =="THICK"? "0" :"1";
  1268. //int infopadindex = DEVICE.GetDevice<LoadPortBaseDevice>(module.ToString()).InfoPadCarrierIndex;
  1269. return SC.GetValue<int>($"CarrierInfo.{module}Station{infopadindex}");
  1270. }
  1271. int nvalue = SC.GetValue<int>($"CarrierInfo.{module}Station");
  1272. return nvalue;
  1273. }
  1274. catch (Exception ex)
  1275. {
  1276. LOG.Write(ex);
  1277. return 0;
  1278. }
  1279. }
  1280. private bool UpdateThicknessType(ModuleName moduleform , int moduleformslot,ModuleName moduleto,int moduletoslot)
  1281. {
  1282. try
  1283. {lock(this)
  1284. {
  1285. if (!ModuleHelper.IsLoadPort(moduleto))
  1286. {
  1287. string type = null;
  1288. if (ModuleHelper.IsRobot(moduleform))
  1289. {
  1290. if (moduleformslot == 0)
  1291. type = SC.GetStringValue($"CarrierInfo.LowerThicknessType");
  1292. else type = SC.GetStringValue($"CarrierInfo.UpperThicknessType");
  1293. SC.SetItemValueFromString($"CarrierInfo.{moduleto}ThicknessType",type);
  1294. }
  1295. else
  1296. {
  1297. type = SC.GetStringValue($"CarrierInfo.{moduleform}ThicknessType");
  1298. if (ModuleHelper.IsRobot(moduleto))
  1299. {
  1300. if (moduletoslot == 0)
  1301. SC.SetItemValueFromString($"CarrierInfo.LowerThicknessType", type);
  1302. else SC.SetItemValueFromString($"CarrierInfo.UpperThicknessType", type);
  1303. }
  1304. else SC.SetItemValueFromString($"CarrierInfo.{moduleto}ThicknessType", type);
  1305. }
  1306. }
  1307. if (!ModuleHelper.IsLoadPort(moduleform))
  1308. {
  1309. if (ModuleHelper.IsRobot(moduleform))
  1310. {
  1311. if (moduleformslot == 0)
  1312. SC.SetItemValueFromString($"CarrierInfo.LowerThicknessType", "NONE");
  1313. else SC.SetItemValueFromString($"CarrierInfo.UpperThicknessType", "NONE");
  1314. }
  1315. else SC.SetItemValueFromString($"CarrierInfo.{moduleform}ThicknessType", "NONE");
  1316. }
  1317. }
  1318. return true;
  1319. }
  1320. catch (Exception ex)
  1321. {
  1322. LOG.Write(ex);
  1323. return false;
  1324. }
  1325. }
  1326. private int GetSlotsNumber(ModuleName module)
  1327. {
  1328. try
  1329. {
  1330. if (ModuleHelper.IsLoadPort(module))
  1331. {
  1332. return DEVICE.GetDevice<LoadPortBaseDevice>(module.ToString()).ValidSlotsNumber;
  1333. }
  1334. return SC.GetValue<int>($"CarrierInfo.{module}SlotsNumber");
  1335. }
  1336. catch (Exception ex)
  1337. {
  1338. LOG.Write(ex);
  1339. return -1;
  1340. }
  1341. }
  1342. private bool _isNeedMappignData
  1343. {
  1344. get
  1345. {
  1346. if (SC.ContainsItem($"Robot.{RobotModuleName}.NeedReadMapData"))
  1347. return SC.GetValue<bool>($"Robot.{RobotModuleName}.NeedReadMapData");
  1348. return true;
  1349. }
  1350. }
  1351. protected override bool fStartMapWafer(object[] param)
  1352. {
  1353. try
  1354. {
  1355. //RobotArmEnum pickarm = (RobotArmEnum)param[0];
  1356. ModuleName module = (ModuleName)Enum.Parse(typeof(ModuleName), param[0].ToString());
  1357. BladeTarget = module;
  1358. Blade1Target = module;
  1359. Blade2Target = module;
  1360. int slotsNumber = GetSlotsNumber(module);
  1361. if (slotsNumber == -1)
  1362. {
  1363. EV.PostAlarmLog("Robot", "Invalid mapping paramter slots number");
  1364. return false;
  1365. }
  1366. //int slot = 25;// (int)param[2];
  1367. string strpara = $"({GetStationsName(module)},0,0)";
  1368. lock (_locker)
  1369. {
  1370. CurrentInteractiveModule = module;
  1371. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "WMAP", strpara));
  1372. _lstHandlers.AddLast(new RorzeRobot751ReadHandler(this, "GMAP"));
  1373. }
  1374. return true;
  1375. }
  1376. catch (Exception ex)
  1377. {
  1378. LOG.Write(ex);
  1379. return false;
  1380. }
  1381. }
  1382. protected override bool fStartSwapWafer(object[] param)
  1383. {
  1384. try
  1385. {
  1386. RobotArmEnum arm = (RobotArmEnum)param[0];
  1387. ModuleName module = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  1388. BladeTarget = module;
  1389. Blade1Target = module;
  1390. Blade2Target = module;
  1391. MoveInfo = new RobotMoveInfo()
  1392. {
  1393. ArmTarget = arm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1394. BladeTarget = (arm == RobotArmEnum.Lower ? RobotArm.ArmA.ToString() : RobotArm.ArmB.ToString()) + "." + module,
  1395. };
  1396. if (ModuleHelper.IsLoadPort(module))
  1397. {
  1398. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(module.ToString());
  1399. if (lp != null)
  1400. lp.NoteTransferStart();
  1401. }
  1402. int slot = (int)param[2] + 1;
  1403. int TrsSt = GetStationsName(module);
  1404. int nArm = 0;
  1405. if (arm == RobotArmEnum.Lower)
  1406. nArm = 2;
  1407. if (arm == RobotArmEnum.Upper)
  1408. nArm = 1;
  1409. if (nArm == 0)
  1410. return false;
  1411. string strpara = $"({nArm},{TrsSt},{slot})";
  1412. lock (_locker)
  1413. {
  1414. if (_lstHandlers.Count == 0 && !_connection.IsBusy)
  1415. {
  1416. ExecuteHandler(new RorzeRobot751MotionHandler(this, "EXCH", strpara));
  1417. }
  1418. else
  1419. {
  1420. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "EXCH", strpara));
  1421. }
  1422. }
  1423. return true;
  1424. }
  1425. catch (Exception ex)
  1426. {
  1427. LOG.Write(ex);
  1428. return false;
  1429. }
  1430. }
  1431. protected override bool fSwapComplete(object[] param)
  1432. {
  1433. RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
  1434. ModuleName sourcemodule;
  1435. if (!Enum.TryParse(CurrentParamter[1].ToString(), out sourcemodule)) return false;
  1436. int Sourceslotindex;
  1437. if (!int.TryParse(CurrentParamter[2].ToString(), out Sourceslotindex)) return false;
  1438. //int delayCount = 0;
  1439. BladeTarget = ModuleName.System;
  1440. Blade1Target = ModuleName.System;
  1441. Blade2Target = ModuleName.System;
  1442. MoveInfo = new RobotMoveInfo()
  1443. {
  1444. ArmTarget = arm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1445. BladeTarget = (arm == RobotArmEnum.Lower ? RobotArm.ArmA.ToString() : RobotArm.ArmB.ToString()) + "." + ModuleName.System,
  1446. };
  1447. if (arm == RobotArmEnum.Lower)
  1448. {
  1449. //WaferManager.Instance.WaferMoved(sourcemodule, Sourceslotindex, RobotModuleName, 0);
  1450. //WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, Sourceslotindex);
  1451. //while (!isSimulatorMode && !(GetWaferState(RobotArmEnum.Lower) == RobotArmWaferStateEnum.Present
  1452. // && GetWaferState(RobotArmEnum.Upper) == RobotArmWaferStateEnum.Absent))
  1453. //{
  1454. // delayCount++;
  1455. // Thread.Sleep(50);
  1456. // LOG.Write($"{RobotModuleName} delay {delayCount} time to detect wafer");
  1457. // if (delayCount > 100)
  1458. // {
  1459. // OnError("Wafer detect error");
  1460. // return true;
  1461. // }
  1462. //}
  1463. WaferManager.Instance.WaferMoved(sourcemodule, Sourceslotindex, RobotModuleName, 0);
  1464. UpdateThicknessType(sourcemodule, Sourceslotindex, RobotModuleName, 0);
  1465. WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, Sourceslotindex);
  1466. UpdateThicknessType(RobotModuleName, 1, sourcemodule, Sourceslotindex);
  1467. }
  1468. if (arm == RobotArmEnum.Upper)
  1469. {
  1470. //WaferManager.Instance.WaferMoved(sourcemodule, Sourceslotindex, RobotModuleName, 1);
  1471. //WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, Sourceslotindex);
  1472. //delayCount = 0;
  1473. //while (!isSimulatorMode && !(GetWaferState(RobotArmEnum.Upper) == RobotArmWaferStateEnum.Present &&
  1474. // GetWaferState(RobotArmEnum.Lower) == RobotArmWaferStateEnum.Absent))
  1475. //{
  1476. // delayCount++;
  1477. // Thread.Sleep(50);
  1478. // LOG.Write($"{RobotModuleName} delay {delayCount} time to detect wafer");
  1479. // if (delayCount > 100)
  1480. // {
  1481. // OnError("Wafer detect error");
  1482. // return true;
  1483. // }
  1484. //}
  1485. WaferManager.Instance.WaferMoved(sourcemodule, Sourceslotindex, RobotModuleName, 1);
  1486. UpdateThicknessType(sourcemodule, Sourceslotindex, RobotModuleName, 1);
  1487. WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, Sourceslotindex);
  1488. UpdateThicknessType(RobotModuleName, 0, sourcemodule, Sourceslotindex);
  1489. }
  1490. return base.fSwapComplete(param);
  1491. }
  1492. protected override bool fStartPlaceWafer(object[] param)
  1493. {
  1494. try
  1495. {
  1496. RobotArmEnum arm = (RobotArmEnum)param[0];
  1497. ModuleName module = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  1498. if (ModuleHelper.IsLoadPort(module))
  1499. {
  1500. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(module.ToString());
  1501. if (lp != null)
  1502. lp.NoteTransferStart();
  1503. }
  1504. BladeTarget = module;
  1505. Blade1Target = module;
  1506. Blade2Target = module;
  1507. MoveInfo = new RobotMoveInfo()
  1508. {
  1509. ArmTarget = arm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1510. BladeTarget = (arm == RobotArmEnum.Lower ? RobotArm.ArmA.ToString() : RobotArm.ArmB.ToString()) + "." + module,
  1511. };
  1512. int slot = (int)param[2] + 1;
  1513. int TrsSt = GetStationsName(module);
  1514. int nArm = 0;
  1515. if (arm == RobotArmEnum.Lower)
  1516. nArm = 2;
  1517. if (arm == RobotArmEnum.Upper)
  1518. nArm = 1;
  1519. if (arm == RobotArmEnum.Both)
  1520. nArm = 3;
  1521. if (nArm == 0)
  1522. return false;
  1523. string strpara = $"{nArm},{TrsSt},{slot}";
  1524. lock (_locker)
  1525. {
  1526. if (_lstHandlers.Count == 0 && !_connection.IsBusy)
  1527. {
  1528. ExecuteHandler(new RorzeRobot751MotionHandler(this, "UNLD", $"({strpara})"));
  1529. }
  1530. else
  1531. {
  1532. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "UNLD", $"({strpara})"));
  1533. }
  1534. }
  1535. return true;
  1536. }
  1537. catch (Exception ex)
  1538. {
  1539. LOG.Write(ex);
  1540. return false;
  1541. }
  1542. }
  1543. protected override bool fPlaceComplete(object[] param)
  1544. {
  1545. RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
  1546. ModuleName sourcemodule;
  1547. if (!Enum.TryParse(CurrentParamter[1].ToString(), out sourcemodule)) return false;
  1548. int Sourceslotindex;
  1549. if (!int.TryParse(CurrentParamter[2].ToString(), out Sourceslotindex)) return false;
  1550. BladeTarget = ModuleName.System;
  1551. Blade1Target = ModuleName.System;
  1552. Blade2Target = ModuleName.System;
  1553. MoveInfo = new RobotMoveInfo()
  1554. {
  1555. ArmTarget = arm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1556. BladeTarget = (arm == RobotArmEnum.Lower ? RobotArm.ArmA.ToString() : RobotArm.ArmB.ToString()) + "." + ModuleName.System,
  1557. };
  1558. if (arm == RobotArmEnum.Lower)
  1559. {
  1560. WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, Sourceslotindex);
  1561. UpdateThicknessType(RobotModuleName, 0, sourcemodule, Sourceslotindex);
  1562. }
  1563. if (arm == RobotArmEnum.Upper)
  1564. {
  1565. WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, Sourceslotindex);
  1566. UpdateThicknessType(RobotModuleName, 1, sourcemodule, Sourceslotindex);
  1567. }
  1568. if (arm == RobotArmEnum.Both)
  1569. {
  1570. WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, Sourceslotindex);
  1571. UpdateThicknessType(RobotModuleName, 0, sourcemodule, Sourceslotindex);
  1572. WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, Sourceslotindex + 1);
  1573. UpdateThicknessType(RobotModuleName, 1, sourcemodule, Sourceslotindex+1);
  1574. }
  1575. return true;
  1576. }
  1577. protected override bool fStartPickWafer(object[] param)
  1578. {
  1579. try
  1580. {
  1581. RobotArmEnum arm = (RobotArmEnum)param[0];
  1582. ModuleName module = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
  1583. if (ModuleHelper.IsLoadPort(module))
  1584. {
  1585. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(module.ToString());
  1586. if (lp != null)
  1587. lp.NoteTransferStart();
  1588. }
  1589. BladeTarget = module;
  1590. Blade1Target = module;
  1591. Blade2Target = module;
  1592. MoveInfo = new RobotMoveInfo()
  1593. {
  1594. ArmTarget = arm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1595. BladeTarget = (arm == RobotArmEnum.Lower ? RobotArm.ArmA.ToString() : RobotArm.ArmB.ToString())+ "." + module,
  1596. };
  1597. int slot = (int)param[2] + 1;
  1598. string TrsSt = GetStationsName(module).ToString();
  1599. if (string.IsNullOrEmpty(TrsSt))
  1600. {
  1601. EV.PostAlarmLog("Robot", "Invalid Parameter.");
  1602. return false;
  1603. }
  1604. int nArm = 0;
  1605. if (arm == RobotArmEnum.Lower)
  1606. nArm = 2;
  1607. if (arm == RobotArmEnum.Upper)
  1608. nArm = 1;
  1609. if (arm == RobotArmEnum.Both)
  1610. nArm = 3;
  1611. if (nArm == 0)
  1612. return false;
  1613. string strpara = $"{nArm},{TrsSt},{slot}";
  1614. lock (_locker)
  1615. {
  1616. if (_lstHandlers.Count == 0 && !_connection.IsBusy)
  1617. {
  1618. ExecuteHandler(new RorzeRobot751MotionHandler(this, "LOAD",$"({strpara})"));
  1619. }
  1620. else
  1621. {
  1622. _lstHandlers.AddLast(new RorzeRobot751MotionHandler(this, "LOAD", $"({strpara})"));
  1623. }
  1624. }
  1625. return true;
  1626. }
  1627. catch (Exception ex)
  1628. {
  1629. LOG.Write(ex);
  1630. return false;
  1631. }
  1632. }
  1633. protected override bool fPickComplete(object[] param)
  1634. {
  1635. RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
  1636. ModuleName module = (ModuleName)Enum.Parse(typeof(ModuleName), CurrentParamter[1].ToString());
  1637. ModuleName sourcemodule;
  1638. if (!Enum.TryParse(CurrentParamter[1].ToString(), out sourcemodule)) return false;
  1639. int SourceslotIndex;
  1640. if (!int.TryParse(CurrentParamter[2].ToString(), out SourceslotIndex)) return false;
  1641. BladeTarget = ModuleName.System;
  1642. Blade1Target = ModuleName.System;
  1643. Blade2Target = ModuleName.System;
  1644. MoveInfo = new RobotMoveInfo()
  1645. {
  1646. ArmTarget = arm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
  1647. BladeTarget =(arm == RobotArmEnum.Lower ? RobotArm.ArmA.ToString() : RobotArm.ArmB.ToString()) + "." + ModuleName.System,
  1648. };
  1649. if (arm == RobotArmEnum.Lower)
  1650. {
  1651. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 0);
  1652. UpdateThicknessType(sourcemodule, SourceslotIndex, RobotModuleName, 0);
  1653. }
  1654. if (arm == RobotArmEnum.Upper)
  1655. {
  1656. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 1);
  1657. UpdateThicknessType(sourcemodule, SourceslotIndex, RobotModuleName, 1);
  1658. }
  1659. if (arm == RobotArmEnum.Both)
  1660. {
  1661. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 0);
  1662. UpdateThicknessType(sourcemodule, SourceslotIndex, RobotModuleName, 0);
  1663. WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex + 1, RobotModuleName, 1);
  1664. UpdateThicknessType(sourcemodule, SourceslotIndex+1, RobotModuleName, 1);
  1665. }
  1666. return true;
  1667. }
  1668. protected override bool fResetToReady(object[] param)
  1669. {
  1670. if (_doRobotHold != null)
  1671. _doRobotHold.SetTrigger(true, out _);
  1672. return true;
  1673. }
  1674. protected override bool fReset(object[] param)
  1675. {
  1676. IsBusy = true;
  1677. if (!_connection.IsConnected)
  1678. {
  1679. _address = SC.GetStringValue($"{_scRoot}.{Name}.Address");
  1680. _enableLog = SC.GetValue<bool>($"{_scRoot}.{Name}.EnableLogMessage");
  1681. _connection = new RorzeRobot751Connection(this, _address);
  1682. _connection.EnableLog(_enableLog);
  1683. _connection.Connect();
  1684. }
  1685. lock (_locker)
  1686. {
  1687. if (_doRobotHold != null)
  1688. _doRobotHold.SetTrigger(true, out _);
  1689. _lstHandlers.Clear();
  1690. _connection.ForceClear();
  1691. _lstHandlers.AddLast(new RorzeRobot751SetHandler(this, "RSTA","(1)"));
  1692. _lstHandlers.AddLast(new RorzeRobot751SetHandler(this, "EVNT","(0,1)"));
  1693. _lstHandlers.AddLast(new RorzeRobot751ReadHandler(this, "STAT"));
  1694. }
  1695. return true;
  1696. }
  1697. protected override bool fMonitorReset(object[] param)
  1698. {
  1699. if (_lstHandlers.Count > 0 )
  1700. return false;
  1701. if(IsCmdProcessing) return false;
  1702. IsBusy = false;
  1703. return true;
  1704. }
  1705. protected override bool fError(object[] param)
  1706. {
  1707. return true;
  1708. }
  1709. protected override bool fStartExtendForPick(object[] param)
  1710. {
  1711. return false;
  1712. }
  1713. protected override bool fStartExtendForPlace(object[] param)
  1714. {
  1715. return false;
  1716. }
  1717. protected override bool fStartRetractFromPick(object[] param)
  1718. {
  1719. return false;
  1720. }
  1721. protected override bool fStartRetractFromPlace(object[] param)
  1722. {
  1723. return false;
  1724. }
  1725. public override RobotArmWaferStateEnum GetWaferState(RobotArmEnum arm)
  1726. {
  1727. if (arm == RobotArmEnum.Lower)
  1728. {
  1729. if (_diRobotBlade1WaferOn != null)
  1730. {
  1731. if (_diRobotBlade1WaferOn.Value) return RobotArmWaferStateEnum.Absent;
  1732. else return RobotArmWaferStateEnum.Present;
  1733. }
  1734. return IsWaferPresenceOnBlade1 ? RobotArmWaferStateEnum.Present : RobotArmWaferStateEnum.Absent;
  1735. }
  1736. if (arm == RobotArmEnum.Upper)
  1737. {
  1738. if (_diRobotBlade2WaferOn != null)
  1739. {
  1740. if (_diRobotBlade2WaferOn.Value) return RobotArmWaferStateEnum.Absent;
  1741. else return RobotArmWaferStateEnum.Present;
  1742. }
  1743. return IsWaferPresenceOnBlade2 ? RobotArmWaferStateEnum.Present : RobotArmWaferStateEnum.Absent;
  1744. }
  1745. if (arm == RobotArmEnum.Both)
  1746. {
  1747. if (_diRobotBlade1WaferOn != null && _diRobotBlade2WaferOn != null)
  1748. {
  1749. if (_diRobotBlade2WaferOn.Value && _diRobotBlade1WaferOn.Value)
  1750. return RobotArmWaferStateEnum.Absent;
  1751. else if (!_diRobotBlade2WaferOn.Value && !_diRobotBlade1WaferOn.Value)
  1752. return RobotArmWaferStateEnum.Present;
  1753. else return RobotArmWaferStateEnum.Unknown;
  1754. }
  1755. if (IsWaferPresenceOnBlade1 && IsWaferPresenceOnBlade2)
  1756. {
  1757. return RobotArmWaferStateEnum.Present;
  1758. }
  1759. if ((!IsWaferPresenceOnBlade1) && !IsWaferPresenceOnBlade2)
  1760. {
  1761. return RobotArmWaferStateEnum.Absent;
  1762. }
  1763. }
  1764. return RobotArmWaferStateEnum.Unknown;
  1765. }
  1766. public void NoteError(string errortext)
  1767. {
  1768. OnError(errortext);
  1769. }
  1770. public override bool OnActionDone(object[] param)
  1771. {
  1772. //BladeTarget = ModuleName.System;
  1773. //Blade1Target = ModuleName.System;
  1774. //Blade2Target = ModuleName.System;
  1775. IsBusy = false;
  1776. ModuleName sourcemodule;
  1777. if (CurrentParamter != null && CurrentParamter.Length > 2 && Enum.TryParse(CurrentParamter[1].ToString(), out sourcemodule))
  1778. {
  1779. if (ModuleHelper.IsLoadPort(sourcemodule))
  1780. {
  1781. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(sourcemodule.ToString());
  1782. if (lp != null)
  1783. lp.NoteTransferStop();
  1784. }
  1785. }
  1786. if (_lstHandlers.Count == 0)
  1787. {
  1788. IsBusy = false;
  1789. return base.OnActionDone(param);
  1790. }
  1791. return true;
  1792. }
  1793. public override void Terminate()
  1794. {
  1795. _thread.Stop();
  1796. if (!SC.ContainsItem($"{_scRoot}.{Name}.CloseConnectionOnShutDown") || SC.GetValue<bool>($"{_scRoot}.{Name}.CloseConnectionOnShutDown"))
  1797. {
  1798. LOG.Write("Close connection for" + RobotModuleName.ToString());
  1799. _connection.Disconnect();
  1800. }
  1801. base.Terminate();
  1802. }
  1803. }
  1804. public enum RROpModeEnum
  1805. {
  1806. Initializing,
  1807. Remote,
  1808. Maitanance,
  1809. Recovery,
  1810. }
  1811. public enum RROpStatusEnum
  1812. {
  1813. Stop,
  1814. Moving,
  1815. TempStop,
  1816. }
  1817. }