DeviceManager.cs 28 KB

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