DeviceManager.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. using Aitex.Common.Util;
  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 Aitex.Sorter.Common;
  11. using EFEM.RT.Devices.Aligner;
  12. using EFEM.RT.Devices.Flipper;
  13. using EFEM.RT.Devices.LoadPorts.Fortrend;
  14. using EFEM.RT.Devices.LoadPorts.JetOpenCst;
  15. using EFEM.RT.Devices.LoadPorts.SmartTagReader;
  16. using EFEM.RT.Devices.Rorze751;
  17. using EfemRT.Devices.LoadPorts.Hirata;
  18. using MECF.Framework.Common.Equipment;
  19. using MECF.Framework.Common.SubstrateTrackings;
  20. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.BufferStations;
  21. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.CarrierIdReaders.CarrierIDReaderBase;
  22. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.CarrierIdReaders.OmronBarcode;
  23. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.CarrierIdReaders.OmronRFID;
  24. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.FFUs.AAF;
  25. //using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.Fortrend;
  26. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
  27. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Linq;
  31. using System.Text.RegularExpressions;
  32. using System.Xml;
  33. //using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Rorze;
  34. namespace EFEM.RT.Devices
  35. {
  36. internal class DeviceEntity : DeviceEntityT<DeviceManager>
  37. {
  38. }
  39. public class DeviceManager : DeviceManagerBase
  40. {
  41. private const int LoadPortMaxQuantity = 3;
  42. private const int PMSlot = 1;
  43. private static readonly int Buffer1SlotCount = SC.ContainsItem("System.Buffer1SlotCount") ? SC.GetValue<int>("System.Buffer1SlotCount") : 0;
  44. private static readonly int Buffer2SlotCount = SC.ContainsItem("System.Buffer2SlotCount") ? SC.GetValue<int>("System.Buffer2SlotCount") : 0;
  45. private static readonly int LoadPortQuantity = DeviceDefineManager.Instance.GetValue<int>("LoadPortQuantity") ?? 0;
  46. private static readonly int LoadLockQuantity = DeviceDefineManager.Instance.GetValue<int>("LoadLockQuantity") ?? 0;
  47. private static readonly int BufferQuantity = DeviceDefineManager.Instance.GetValue<int>("BufferQuantity") ?? 0;
  48. private static readonly int LoadLockSlot = DeviceDefineManager.Instance.GetValue<int>("LoadLockSlot") ?? 0;
  49. //private static readonly int BufferSlot = DeviceDefineManager.Instance.GetValue<int>("BufferSlot") ?? 0;
  50. private static readonly bool LoadLockDoorControlByStation = DeviceDefineManager.Instance.GetValue<bool>("LLDoorControlByStation") ?? false;
  51. //private static readonly bool DmcCardUsed = DeviceDefineManager.Instance.GetValue<bool>("DmcCardInstalled") ?? false;
  52. private static readonly bool DisableSignalTower = DeviceDefineManager.Instance.GetValue<bool>("DisableSignalTower") ?? false;
  53. private static readonly bool BufferIsDisable = SC.ContainsItem("System.BufferDisable") ? SC.GetValue<bool>("System.BufferDisable") : true;
  54. private static readonly bool Buffer1IsDisable = SC.ContainsItem("System.Buffer1Disable") ? SC.GetValue<bool>("System.Buffer1Disable") : true;
  55. private static readonly bool Buffer2IsDisable = SC.ContainsItem("System.Buffer2Disable") ? SC.GetValue<bool>("System.Buffer2Disable") : true;
  56. private static readonly bool Aligner1IsDisable = SC.ContainsItem("System.Aligner1Disable") ? SC.GetValue<bool>("System.Aligner1Disable") : true;
  57. private static readonly bool Aligner2IsDisable = SC.ContainsItem("System.Aligner2Disable") ? SC.GetValue<bool>("System.Aligner2Disable") : true;
  58. private static readonly bool PMAIsDisable = SC.ContainsItem("System.PMADisable") ? SC.GetValue<bool>("System.PMADisable") : true;
  59. private static readonly bool PMBIsDisable = SC.ContainsItem("System.PMBDisable") ? SC.GetValue<bool>("System.PMBDisable") : true;
  60. private static readonly bool CoolingBuffer1IsDisable = SC.ContainsItem("System.CoolingBuffer1Disable") ? SC.GetValue<bool>("System.CoolingBuffer1Disable") : true;
  61. private static readonly bool CoolingBuffer2IsDisable = SC.ContainsItem("System.CoolingBuffer2Disable") ? SC.GetValue<bool>("System.CoolingBuffer2Disable") : true;
  62. private static readonly bool FlipperIsDisable = SC.ContainsItem("System.FlipperDisable") ? SC.GetValue<bool>("System.FlipperDisable") : true;
  63. private static readonly bool LoadPort1IsDisable = SC.ContainsItem("LoadPort.LP1.Disable") ? SC.GetValue<bool>("LoadPort.LP1.Disable") : true;
  64. private static readonly bool LoadPort2IsDisable = SC.ContainsItem("LoadPort.LP2.Disable") ? SC.GetValue<bool>("LoadPort.LP2.Disable") : true;
  65. private static readonly string RobotType = SC.ContainsItem("Robot.RobotType") ? SC.GetStringValue("Robot.RobotType") : "None";
  66. public string[] CarrierIdReader => _carrierIdReader.Take(LoadPortQuantity).ToArray();
  67. private readonly string[] _carrierIdReader =
  68. {
  69. "CarrierIdReader",
  70. "CarrierIdReader",
  71. "CarrierIdReader",
  72. "CarrierIdReader",
  73. "CarrierIdReader",
  74. "CarrierIdReader",
  75. "CarrierIdReader",
  76. "CarrierIdReader",
  77. "CarrierIdReader",
  78. "CarrierIdReader"
  79. };
  80. public string[] CarrierRfidReader => _carrierRfidReader.Take(LoadPortQuantity).ToArray();
  81. private readonly string[] _carrierRfidReader =
  82. {
  83. "RFID",
  84. "RFID",
  85. "RFID",
  86. "RFID",
  87. "RFID",
  88. "RFID",
  89. "RFID",
  90. "RFID",
  91. "RFID",
  92. "RFID"
  93. };
  94. public string[] BarcodeIdReaderName => _barcodeIdReaderName.Take(LoadPortQuantity).ToArray();
  95. private readonly string[] _barcodeIdReaderName = new[]
  96. {
  97. "BarcodeReaderA",
  98. "BarcodeReaderB",
  99. "BarcodeReaderC",
  100. "BarcodeReaderD",
  101. "BarcodeReaderE",
  102. "BarcodeReaderF",
  103. "BarcodeReaderG",
  104. "BarcodeReaderH",
  105. "BarcodeReaderI",
  106. "BarcodeReaderJ",
  107. "BarcodeReaderK",
  108. };
  109. public string[] BufferNames => _bufferNames.Take(BufferQuantity).ToArray();
  110. private readonly string[] _bufferNames =
  111. {
  112. DeviceName.Buffer1,
  113. DeviceName.Buffer2,
  114. DeviceName.Buffer3,
  115. DeviceName.Buffer4,
  116. DeviceName.Buffer5
  117. };
  118. public IEnumerable<ModuleName> LpNames => _lpNames.Take(LoadPortQuantity);
  119. private readonly ModuleName[] _lpNames =
  120. {
  121. ModuleName.LP1, ModuleName.LP2, ModuleName.LP3, ModuleName.LP4, ModuleName.LP5, ModuleName.LP6,
  122. ModuleName.LP7, ModuleName.LP8, ModuleName.LP9, ModuleName.LP10
  123. };
  124. private string[] CarrierIdReaderPortScName => _carrierIdReaderPortScName.Take(LoadPortQuantity).ToArray();
  125. private readonly string[] _carrierIdReaderPortScName =
  126. {
  127. SorterCommon.ScPathName.LoadPort_LoadPort1CarrierIdReaderPortName,
  128. SorterCommon.ScPathName.LoadPort_LoadPort2CarrierIdReaderPortName,
  129. SorterCommon.ScPathName.LoadPort_LoadPort3CarrierIdReaderPortName,
  130. SorterCommon.ScPathName.LoadPort_LoadPort4CarrierIdReaderPortName,
  131. SorterCommon.ScPathName.LoadPort_LoadPort5CarrierIdReaderPortName,
  132. SorterCommon.ScPathName.LoadPort_LoadPort6CarrierIdReaderPortName,
  133. SorterCommon.ScPathName.LoadPort_LoadPort7CarrierIdReaderPortName,
  134. SorterCommon.ScPathName.LoadPort_LoadPort8CarrierIdReaderPortName,
  135. SorterCommon.ScPathName.LoadPort_LoadPort9CarrierIdReaderPortName,
  136. SorterCommon.ScPathName.LoadPort_LoadPort10CarrierIdReaderPortName
  137. };
  138. private readonly string[] _rfidReaderAddress =
  139. {
  140. EFEMSC.ScPathName.LoadPort_LoadPort1CarrierIdReaderAddress,
  141. EFEMSC.ScPathName.LoadPort_LoadPort2CarrierIdReaderAddress,
  142. EFEMSC.ScPathName.LoadPort_LoadPort3CarrierIdReaderAddress,
  143. EFEMSC.ScPathName.LoadPort_LoadPort4CarrierIdReaderAddress,
  144. EFEMSC.ScPathName.LoadPort_LoadPort5CarrierIdReaderAddress,
  145. EFEMSC.ScPathName.LoadPort_LoadPort6CarrierIdReaderAddress,
  146. EFEMSC.ScPathName.LoadPort_LoadPort7CarrierIdReaderAddress,
  147. EFEMSC.ScPathName.LoadPort_LoadPort8CarrierIdReaderAddress,
  148. EFEMSC.ScPathName.LoadPort_LoadPort9CarrierIdReaderAddress,
  149. EFEMSC.ScPathName.LoadPort_LoadPort10CarrierIdReaderAddress
  150. };
  151. private readonly string[] _rfidReaderPages =
  152. {
  153. EFEMSC.ScPathName.LoadPort_LoadPort1CarrierIdReaderPage,
  154. EFEMSC.ScPathName.LoadPort_LoadPort2CarrierIdReaderPage,
  155. EFEMSC.ScPathName.LoadPort_LoadPort3CarrierIdReaderPage,
  156. EFEMSC.ScPathName.LoadPort_LoadPort4CarrierIdReaderPage,
  157. EFEMSC.ScPathName.LoadPort_LoadPort5CarrierIdReaderPage,
  158. EFEMSC.ScPathName.LoadPort_LoadPort6CarrierIdReaderPage,
  159. EFEMSC.ScPathName.LoadPort_LoadPort7CarrierIdReaderPage,
  160. EFEMSC.ScPathName.LoadPort_LoadPort8CarrierIdReaderPage,
  161. EFEMSC.ScPathName.LoadPort_LoadPort9CarrierIdReaderPage,
  162. EFEMSC.ScPathName.LoadPort_LoadPort10CarrierIdReaderPage
  163. };
  164. private readonly string[] _rfidNames =
  165. {
  166. DeviceName.RFIDReaderA,
  167. DeviceName.RFIDReaderB,
  168. DeviceName.RFIDReaderC,
  169. DeviceName.RFIDReaderD,
  170. DeviceName.RFIDReaderE,
  171. DeviceName.RFIDReaderF,
  172. DeviceName.RFIDReaderG,
  173. DeviceName.RFIDReaderH,
  174. DeviceName.RFIDReaderI,
  175. DeviceName.RFIDReaderJ
  176. };
  177. public string[] LpPortNameSc => _lpPortNameSc.Take(LoadPortQuantity).ToArray();
  178. private readonly string[] _lpPortNameSc =
  179. {
  180. EFEMSC.ScPathName.LoadPort_LoadPort1PortName,
  181. EFEMSC.ScPathName.LoadPort_LoadPort2PortName,
  182. EFEMSC.ScPathName.LoadPort_LoadPort3PortName,
  183. EFEMSC.ScPathName.LoadPort_LoadPort4PortName,
  184. EFEMSC.ScPathName.LoadPort_LoadPort5PortName,
  185. EFEMSC.ScPathName.LoadPort_LoadPort6PortName,
  186. EFEMSC.ScPathName.LoadPort_LoadPort7PortName,
  187. EFEMSC.ScPathName.LoadPort_LoadPort8PortName,
  188. EFEMSC.ScPathName.LoadPort_LoadPort9PortName,
  189. EFEMSC.ScPathName.LoadPort_LoadPort10PortName
  190. };
  191. public string[] LLNames => _llNames.Take(LoadLockQuantity).ToArray();
  192. private readonly string[] _llNames =
  193. {
  194. DeviceName.LL1,
  195. DeviceName.LL2,
  196. DeviceName.LL3,
  197. DeviceName.LL4,
  198. DeviceName.LL5,
  199. DeviceName.LL6,
  200. DeviceName.LL7,
  201. DeviceName.LL8
  202. };
  203. private char[] rfidInstallment;
  204. private char[] carrierIdInstallment;
  205. private char[] e84Support;
  206. public bool IsAnyLPIdle()
  207. {
  208. return LpNames.Any(moduleName => DEVICE.GetDevice<LoadPortBaseDevice>(moduleName.ToString()).IsIdle);
  209. }
  210. public ModuleName[] GetAllLoadPortName()
  211. {
  212. return LpNames as ModuleName[];
  213. }
  214. public LoadPortBaseDevice[] GetAllLoadPorts()
  215. {
  216. var lp = LpNames.Select(lpName => DEVICE.GetDevice<LoadPortBaseDevice>(lpName.ToString())).ToList();
  217. return lp.ToArray();
  218. }
  219. public CIDReaderBaseDevice GetGeneralBarcodeReader(string lp)
  220. {
  221. string pattern = "[1-9]\\d*";
  222. Regex rgx = new Regex(pattern);
  223. var match = int.Parse(rgx.Match(lp).ToString());
  224. if (match <= LoadPortQuantity)
  225. return DEVICE.GetDevice<CIDReaderBaseDevice>($"CarrierIDReader.{_barcodeIdReaderName[match - 1]}");
  226. return null;
  227. //var index = Array.IndexOf(LpNames.ToArray(), lp);
  228. //return DEVICE.GetDevice<GeneralBarcodeReader>(lp + "." + _barcodeIdReaderName[index]);
  229. }
  230. private OmronBarcodeReader GetBarcodeReader(string lp)
  231. {
  232. var index = Array.IndexOf(LpNames.ToArray(), lp);
  233. return DEVICE.GetDevice<OmronBarcodeReader>(lp + "." + _carrierIdReader[index]);
  234. }
  235. public OmronRfidReader GetRfidReader(string lp)
  236. {
  237. string pattern = "[1-9]\\d*";
  238. Regex rgx = new Regex(pattern);
  239. var match = int.Parse(rgx.Match(lp).ToString());
  240. if (match <= LoadPortQuantity)
  241. return DEVICE.GetDevice<OmronRfidReader>(_rfidNames[match - 1]);
  242. return null;
  243. }
  244. //Initialize should be call by main before fsm run
  245. public override bool Initialize()
  246. {
  247. var fi = typeof(DeviceModel).GetFields();
  248. foreach (var p in fi) p.SetValue(null, GetDevice(p.Name));
  249. IoSensor[] llDoorOpen =
  250. {
  251. DeviceModel.SensorPMASystemInterlock,
  252. DeviceModel.SensorPMBSystemInterlock,
  253. };
  254. IoSensor[] llArmExtendEnable =
  255. {
  256. DeviceModel.SensorRBNotExtendPMA,
  257. DeviceModel.SensorRBNotExtendPMB,
  258. };
  259. IoTrigger[] llSsfeytoPM =
  260. {
  261. DeviceModel.TrigSafetytoPMA,
  262. DeviceModel.TrigSafetytoPMB,
  263. };
  264. IoTrigger[] llArmNotExtendExtendPM =
  265. {
  266. DeviceModel.TrigRBNotExtendPMA,
  267. DeviceModel.TrigRBNotExtendPMB,
  268. };
  269. IoSensor[] lpPoadOpen =
  270. {
  271. DeviceModel.SensorSMIF1PODOPEN,
  272. DeviceModel.SensorSMIF2PODOPEN,
  273. };
  274. IoSensor[] robotExtendtoLP =
  275. {
  276. DeviceModel.SensorRBNotExtendSIMF1,
  277. DeviceModel.SensorRBNotExtendSIMF2,
  278. };
  279. IoSensor[] GirdSensor =
  280. {
  281. DeviceModel.SensorRBNotExtendSIMF1,
  282. DeviceModel.SensorRBNotExtendSIMF2,
  283. };
  284. IoTrigger[] SafeytoLP =
  285. {
  286. DeviceModel.TrigSafetytoPMA,
  287. DeviceModel.TrigSafetytoPMB,
  288. };
  289. IoSensor[][] LPSensorArry =
  290. {
  291. new IoSensor[]
  292. {
  293. DeviceModel.Sensor4InchCstPresence,
  294. DeviceModel.Sensor4InchCstProtrusion1,
  295. //DeviceModel.Sensor4InchCstProtrusion2,
  296. DeviceModel.Sensor6InchCstPresence,
  297. DeviceModel.Sensor6InchCstProtrusion1,
  298. // DeviceModel.Sensor4InchCstProtrusion2,
  299. DeviceModel.Sensor8InchCstPresence,
  300. DeviceModel.Sensor8InchCstProtrusion1,
  301. // DeviceModel.Sensor4InchCstProtrusion2,
  302. DeviceModel.SensorCstDoorClosed,
  303. DeviceModel.SensorRBNotExtendSIMF1,
  304. DeviceModel.SensorRobotRemotetoEFEM,
  305. },
  306. };
  307. var barcodeIdReaderName = new[]
  308. {
  309. "BarcodeReaderA",
  310. "BarcodeReaderB",
  311. "BarcodeReaderC",
  312. "BarcodeReaderD",
  313. "BarcodeReaderE",
  314. "BarcodeReaderF",
  315. "BarcodeReaderG",
  316. "BarcodeReaderH",
  317. "BarcodeReaderI",
  318. "BarcodeReaderJ",
  319. "BarcodeReaderK",
  320. };
  321. IoTrigger[][] LPTriggerArry =
  322. {
  323. new IoTrigger[]
  324. {
  325. DeviceModel.TrigSafetytoSMIF1,
  326. },
  327. };
  328. IoTrigger[] ioTriggerLP = new IoTrigger[2]
  329. {
  330. DeviceModel.TrigSafetytoSMIF1,
  331. DeviceModel.TrigSafetytoSMIF2
  332. };
  333. //Robot Device Initialize
  334. RobotBaseDevice robot;
  335. switch (RobotType)
  336. {
  337. case "NXC100":
  338. robot = new RorzeRobot751(ModuleName.System.ToString(), DeviceName.Robot, "Robot", null, null);
  339. AddCustomDevice(robot, "Robot", robot.GetType());
  340. break;
  341. default:
  342. robot = new RorzeRobot751(ModuleName.System.ToString(), DeviceName.Robot, "Robot", null, null);
  343. AddCustomDevice(robot, "Robot", robot.GetType());
  344. break;
  345. }
  346. //LoadPort Device Initialize
  347. for (int i = 0; i < LoadPortMaxQuantity; i++)
  348. {
  349. if (!SC.ContainsItem($"LoadPort.LP{i + 1}.Disable")) continue;
  350. if (!SC.GetValue<bool>($"LoadPort.LP{i + 1}.Disable"))
  351. {
  352. if (SC.GetValue<int>($"LoadPort.LP{i + 1}.CstType") == 0)
  353. {
  354. LoadPortBaseDevice lp = new FortrendSmifPort("", _lpNames[i].ToString(), "LoadPort", robot, robotExtendtoLP[i], lpPoadOpen[i]);
  355. AddCustomDevice(lp, "LoadPort", typeof(LoadPortBaseDevice));
  356. if (SC.GetValue<bool>($"LoadPort.LP{i + 1}.ExternalSmartTagReader"))
  357. {
  358. CIDReaderBaseDevice barcodeReader = new SmartTagReader("CarrierIDReader", barcodeIdReaderName[i], "CarrierID", lp);
  359. AddCustomDevice(barcodeReader, "BarcodeReader", typeof(CIDReaderBaseDevice));
  360. lp.CIDReaders = new CIDReaderBaseDevice[] { barcodeReader };
  361. }
  362. }
  363. else if (SC.GetValue<int>($"LoadPort.LP{i + 1}.CstType") == 1)
  364. {
  365. LoadPortBaseDevice lp = new OpenStageJet("", _lpNames[i].ToString(), LPSensorArry[i], LPTriggerArry[i], robot);
  366. AddCustomDevice(lp, "LoadPort", typeof(LoadPortBaseDevice));
  367. string readcommand = "LON\r";
  368. string stopcommand = "LOFF\r";
  369. CIDReaderBaseDevice barcodeReader = new GeneralBarcodeReader("CarrierIDReader", barcodeIdReaderName[i], "CarrierID", readcommand, true, lp, stopcommand);
  370. AddCustomDevice(barcodeReader, "BarcodeReader", typeof(CIDReaderBaseDevice));
  371. lp.CIDReaders = new CIDReaderBaseDevice[] { barcodeReader };
  372. }
  373. else if (SC.GetValue<int>($"LoadPort.LP{i + 1}.CstType") == 2)
  374. {
  375. LoadPortBaseDevice lp = new HirataLoadPort(ModuleName.System.ToString(), this._lpNames[i].ToString(), "LoadPort", (RobotBaseDevice)null, ioTriggerLP);
  376. AddCustomDevice(lp, "LoadPort", typeof(LoadPortBaseDevice));
  377. if (SC.GetValue<bool>($"LoadPort.LP{i + 1}.ExternalSmartTagReader"))
  378. {
  379. CIDReaderBaseDevice barcodeReader = new SmartTagReader("CarrierIDReader", barcodeIdReaderName[i], "CarrierID", lp);
  380. AddCustomDevice(barcodeReader, "BarcodeReader", typeof(CIDReaderBaseDevice));
  381. lp.CIDReaders = new CIDReaderBaseDevice[] { barcodeReader };
  382. }
  383. }
  384. }
  385. }
  386. //Aligner Device Initialize
  387. if (!Aligner1IsDisable)
  388. {
  389. switch (SC.GetValue<int>("Aligner.AlignerType"))
  390. {
  391. case 1://Aligner with Pin
  392. break;
  393. default://Aligner without Pin
  394. AddCustomDevice(new MechanicalAligner(ModuleName.System, ModuleName.Aligner1, 1), "Aligner1", typeof(MechanicalAligner));
  395. break;
  396. }
  397. }
  398. if (!Aligner2IsDisable)
  399. {
  400. switch (SC.GetValue<int>("Aligner.AlignerType"))
  401. {
  402. case 1://Aligner with Pin
  403. //AddCustomDevice(new RorzePreAligner(ModuleName.System.ToString(), "Aligner2", "Aligner2", "", ""), "Aligner2", typeof(PreAligner));
  404. break;
  405. default://Aligner without Pin
  406. AddCustomDevice(new MechanicalAligner(ModuleName.System, ModuleName.Aligner2, 1), "Aligner2", typeof(MechanicalAligner));
  407. break;
  408. }
  409. Singleton<WaferManager>.Instance.SubscribeLocation(ModuleName.Aligner2, 1);
  410. }
  411. //PM Device Initialize
  412. if (!PMAIsDisable)
  413. {
  414. LoadLockDevice ll = new LoadLockDevice("System", _llNames[0], PMSlot, llDoorOpen[0],
  415. llArmExtendEnable[0], llSsfeytoPM[0], llArmNotExtendExtendPM[0]);
  416. AddCustomDevice(ll, "LoadLockDevice", ll.GetType());
  417. }
  418. if (!PMBIsDisable)
  419. {
  420. LoadLockDevice ll = new LoadLockDevice("System", _llNames[1], PMSlot, llDoorOpen[1],
  421. llArmExtendEnable[1], llSsfeytoPM[1], llArmNotExtendExtendPM[1]);
  422. AddCustomDevice(ll, "LoadLockDevice", ll.GetType());
  423. }
  424. //Buffer Device Initialize
  425. if (!BufferIsDisable)
  426. {
  427. BufferStation buffer = new Buffer("System", "Buffer", Buffer1SlotCount, llDoorOpen[0]);//Normal Buffer
  428. AddCustomDevice(buffer, "BufferStation", buffer.GetType());
  429. }
  430. if (!Buffer1IsDisable)
  431. {
  432. BufferStation buffer = new Buffer("System", _bufferNames[0], Buffer1SlotCount, llDoorOpen[0]);//Normal Buffer
  433. AddCustomDevice(buffer, "BufferStation", buffer.GetType());
  434. }
  435. if (!Buffer2IsDisable)
  436. {
  437. BufferStation buffer = new Buffer("System", _bufferNames[1], Buffer2SlotCount, llDoorOpen[1]);//Normal Buffer
  438. AddCustomDevice(buffer, "BufferStation", buffer.GetType());
  439. }
  440. //Flipper Device Initialize
  441. if (FlipperIsDisable)
  442. {
  443. //JetFlipper jetFlipper = new JetFlipper(ModuleName.System.ToString(), "Flipper", "Flipper", null, null);
  444. //AddCustomDevice(jetFlipper, "Flipper", typeof(JetFlipper));
  445. }
  446. //SignalTower Initialize
  447. if (!DisableSignalTower)
  448. {
  449. }
  450. //SignalTower Initialize
  451. if (DisableSignalTower)
  452. {
  453. DeviceModel.SignalTower.CustomSignalTower(PathManager.GetCfgDir() + "\\SignalTower.xml");
  454. }
  455. //EquipmentMonitor Initialize
  456. AddCustomDevice(new EquipmentMonitor(), "EquipmentMonitor", typeof(EquipmentMonitor));
  457. foreach (var nodeModelChild in DeviceModelNodes.ChildNodes)
  458. {
  459. XmlElement nodeDevices = nodeModelChild as XmlElement;
  460. }
  461. //FFU Initialize(in use)
  462. var SorterFFU = new FfuAAF("FFU", "FFU", "System", 1);
  463. SorterFFU.Initialize();
  464. //FFU12 Device Initialize
  465. if (DeviceDefineManager.Instance.GetValue<bool>("FfuMemoBusControl") ?? false)
  466. {
  467. var comPort = SC.GetStringValue("System.FFUComPortName");
  468. var ffu1 = new Ffu("", "FFU1", "01", comPort);
  469. AddCustomDevice(ffu1, "FFU", typeof(Ffu));
  470. var ffu2 = new Ffu("", "FFU2", "02", comPort);
  471. AddCustomDevice(ffu2, "FFU", typeof(Ffu));
  472. }
  473. OP.Subscribe(OperationName.ResetDevice, InvokeResetDevice);
  474. OP.Subscribe(OperationName.DeviceOperation, InvokeDeviceOperation);
  475. OP.Subscribe(OperationName.SetManualScanCode, InvokeSetManualScanCode);
  476. OP.Subscribe(OperationName.Scan, InvokeScan);
  477. OP.Subscribe(OperationName.Write, InvokeWrite);
  478. OP.Subscribe("ReadCarrierId", InvokeScan);
  479. OP.Subscribe(OperationName.ReadFoupRFID, InvokeReadRfid);
  480. OP.Subscribe(OperationName.WriteFoupRFID, InvokeWriteRfid);
  481. robot.OnSlotMapRead += Robot_OnSlotMapRead;
  482. return true;
  483. }
  484. private bool InvokeWrite(string arg1, object[] args)
  485. {
  486. if (!(GetRfidReader(args[0].ToString()).Write(args[1].ToString(), out string reason)))
  487. {
  488. EV.PostWarningLog(args[0].ToString(), $"fail to write RFID, {reason}");
  489. return false;
  490. }
  491. return true;
  492. }
  493. private bool InvokeWriteRfid(string arg1, object[] arg2)
  494. {
  495. if (!GetRfidReader(arg2[0].ToString()).Write(arg2[1].ToString(), out var reason))
  496. {
  497. EV.PostWarningLog(arg1, $"fail to write RFID, {reason}");
  498. return false;
  499. }
  500. return true;
  501. }
  502. private bool InvokeReadRfid(string arg1, object[] arg2)
  503. {
  504. if (!GetRfidReader(arg2[0].ToString()).Read(out var reason))
  505. {
  506. EV.PostWarningLog(arg1, $"fail to read RFID, {reason}");
  507. return false;
  508. }
  509. return true;
  510. }
  511. private bool InvokeScan(string arg1, object[] args)
  512. {
  513. if (SC.GetValue<bool>($"LoadPort.{args[0].ToString()}.ExternalSmartTagReader") && SC.GetValue<int>($"LoadPort.{args[0].ToString()}.CstType") == 0)
  514. {
  515. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(args[0].ToString());
  516. return lp.ReadCarrierID();//lp.ReadCarrierID(
  517. }
  518. else
  519. {
  520. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(args[0].ToString());
  521. return lp.ReadCarrierIDByIndex(new object[] { 0 });//lp.ReadCarrierID();
  522. }
  523. }
  524. private bool InvokeSetManualScanCode(string arg1, object[] args)
  525. {
  526. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(args[0].ToString());
  527. lp.OnCarrierIdRead(args[1].ToString());
  528. return true;
  529. }
  530. private bool InvokeOffline(string arg1, object[] arg2)
  531. {
  532. return true;
  533. }
  534. private void Robot_OnSlotMapRead(ModuleName module, string slotMap)
  535. {
  536. if (ModuleHelper.IsLoadPort(module))
  537. {
  538. var lp = DEVICE.GetDevice<LoadPortBaseDevice>(module.ToString());
  539. if (lp != null) lp.OnSlotMapRead(slotMap);
  540. }
  541. if (ModuleHelper.IsBuffer(module))
  542. {
  543. var buffer = DEVICE.GetDevice<BufferStation>(module.ToString());
  544. if (buffer != null)
  545. buffer.OnSlotMapRead(slotMap);
  546. }
  547. }
  548. private bool InvokeDeviceOperation(string arg1, object[] args)
  549. {
  550. var name = "";
  551. var func = "";
  552. try
  553. {
  554. name = (string)args[0];
  555. func = (string)args[1];
  556. if ((bool)DATA.Poll(ModuleName.System.ToString(), ParamName.IsMaintenanceMode))
  557. {
  558. EV.PostMessage("System", EventEnum.DefaultWarning,
  559. string.Format("System in maintenance, can not execute {0}{1}", name, func));
  560. return false;
  561. }
  562. var param = new object[args.Length - 2];
  563. for (var i = 2; i < args.Length; i++)
  564. param[i - 2] = args[i].ToString();
  565. if (name == "SignalTower")
  566. {
  567. OP.DoOperation($"System.SignalTower.{func}");
  568. return true;
  569. }
  570. if (ModuleHelper.IsLoadPort(ModuleHelper.Converter(name)))
  571. {
  572. OP.DoOperation($"{name}.{func}", param);
  573. }
  574. else
  575. {
  576. DeviceCmd(name, func, param);
  577. }
  578. }
  579. catch (Exception ex)
  580. {
  581. LOG.Write(ex);
  582. EV.PostMessage("System", EventEnum.DefaultWarning,
  583. string.Format("Invalid parameters, can not execute {0}{1}", name, func));
  584. return false;
  585. }
  586. return true;
  587. }
  588. private bool InvokeResetDevice(string arg1, object[] arg2)
  589. {
  590. Singleton<DeviceEntity>.Instance.PostMsg(DeviceEntityT<DeviceManager>.MSG.RESET);
  591. return true;
  592. }
  593. private void DeviceCmd(string name, string cmd, params object[] args)
  594. {
  595. DEVICE.Do(string.Format("{0}.{1}", name, cmd), 0, true, args);
  596. }
  597. }
  598. }