DeviceManager.cs 28 KB

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