DeviceManager.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using Aitex.Core.Common;
  5. using Aitex.Core.RT.Device;
  6. using Aitex.Core.RT.OperationCenter;
  7. using Aitex.Core.RT.SCCore;
  8. using Aitex.RT.Device.Custom;
  9. using MECF.Framework.Common.Equipment;
  10. using Venus_RT.Modules;
  11. using Venus_RT.Devices;
  12. using Venus_RT.Devices.EPD;
  13. using Venus_Core;
  14. using Aitex.Common.Util;
  15. using System.Reflection;
  16. namespace Venus_RT.Instances
  17. {
  18. public class DeviceEntity : DeviceEntityT<DeviceManager>
  19. {
  20. public DeviceEntity()
  21. {
  22. }
  23. }
  24. public class DeviceManager : DeviceManagerBase
  25. {
  26. private string device_model_file;
  27. private readonly string device_model_file_MF;
  28. private readonly string device_model_file_SEMF;
  29. public DeviceManager()
  30. {
  31. //switch (RtInstance.CurrentChamber)
  32. //{
  33. // case JetChamber.Venus:
  34. // device_model_file= PathManager.GetCfgDir() + RtInstance.CurrentChamber.ToString() + "\\" + "DeviceModelVenus.xml.xml";
  35. // break;
  36. // case JetChamber.Kepler2300:
  37. // case JetChamber.Kepler2200A:
  38. // case JetChamber.Kepler2200B:
  39. // device_model_file = PathManager.GetCfgDir() + RtInstance.CurrentChamber.ToString() + "\\" + "DeviceModelKepler.xml.xml";
  40. // break;
  41. //}
  42. device_model_file_MF = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config\\","TM", RtInstance.DeviceModelFileName_MF);
  43. device_model_file_SEMF = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config\\", "TM", RtInstance.DeviceModelFileName_SE);
  44. }
  45. public override bool Initialize()
  46. {
  47. if (ModuleHelper.IsInstalled(ModuleName.PMA))
  48. {
  49. JetChamber jetChamber = (JetChamber)SC.GetValue<int>("PMA.ChamberType");
  50. InitPM(ModuleName.PMA, jetChamber);
  51. }
  52. if (ModuleHelper.IsInstalled(ModuleName.PMB))
  53. {
  54. JetChamber jetChamber = (JetChamber)SC.GetValue<int>("PMB.ChamberType");
  55. InitPM(ModuleName.PMB, jetChamber);
  56. }
  57. if (ModuleHelper.IsInstalled(ModuleName.PMC))
  58. {
  59. JetChamber jetChamber = (JetChamber)SC.GetValue<int>("PMC.ChamberType");
  60. InitPM(ModuleName.PMC, jetChamber);
  61. }
  62. if (ModuleHelper.IsInstalled(ModuleName.PMD))
  63. {
  64. JetChamber jetChamber = (JetChamber)SC.GetValue<int>("PMD.ChamberType");
  65. InitPM(ModuleName.PMD, jetChamber);
  66. }
  67. if (ModuleHelper.IsInstalled(ModuleName.TM))
  68. InitTM(ModuleName.TM);
  69. if(ModuleHelper.IsInstalled(ModuleName.SETM))
  70. {
  71. InitSETM(ModuleName.SETM);
  72. }
  73. AddCustomModuleDevice(new VenusSignalTower("System", "SignalTower"));
  74. OP.Subscribe("DeviceOperation", this.Invoke);
  75. return true;
  76. }
  77. private void InitPM(ModuleName mod,JetChamber jetChamber)
  78. {
  79. device_model_file = PathManager.GetCfgDir() + "PM" + "\\" + jetChamber.ToString() + "\\" + $"{jetChamber.ToString()}DeviceModel.xml";
  80. Initialize(device_model_file, jetChamber.ToString(), mod, mod.ToString());
  81. if (SC.GetValue<int>($"{mod}.Rf.CommunicationType") == (int)CommunicationType.RS232 &&
  82. SC.GetValue<int>($"{mod}.Rf.MFG") == (int)GeneratorMFG.AdTec)
  83. {
  84. AddCustomModuleDevice(new AdTecGenerator(mod, Venus_Core.VenusDevice.Rf));
  85. }
  86. if (jetChamber == JetChamber.Kepler2300)
  87. {
  88. if (SC.GetValue<bool>($"{mod}.InnerChiller.EnableChiller") &&
  89. SC.GetValue<int>($"{mod}.InnerChiller.CommunicationType") == (int)CommunicationType.RS232)
  90. {
  91. if (SC.GetValue<int>($"{mod}.InnerChiller.MFG") == (int)ChillerMFG.SMC)
  92. {
  93. AddCustomModuleDevice(new SMCChiller(mod, "InnerChiller"));
  94. }
  95. else if (SC.GetValue<int>($"{mod}.InnerChiller.MFG") == (int)ChillerMFG.AIRSYS)
  96. {
  97. AddCustomModuleDevice(new AIRSYSChiller(mod, "InnerChiller"));
  98. }
  99. }
  100. if (SC.GetValue<bool>($"{mod}.OuterChiller.EnableChiller") &&
  101. SC.GetValue<int>($"{mod}.OuterChiller.CommunicationType") == (int)CommunicationType.RS232)
  102. {
  103. if (SC.GetValue<int>($"{mod}.OuterChiller.MFG") == (int)ChillerMFG.SMC)
  104. {
  105. AddCustomModuleDevice(new SMCChiller(mod, "OuterChiller"));
  106. }
  107. else if (SC.GetValue<int>($"{mod}.OuterChiller.MFG") == (int)ChillerMFG.AIRSYS)
  108. {
  109. AddCustomModuleDevice(new AIRSYSChiller(mod, "OuterChiller"));
  110. }
  111. }
  112. if (SC.GetValue<bool>($"{mod}.TopChiller.EnableChiller") &&
  113. SC.GetValue<int>($"{mod}.TopChiller.CommunicationType") == (int)CommunicationType.RS232)
  114. {
  115. if (SC.GetValue<int>($"{mod}.TopChiller.MFG") == (int)ChillerMFG.SMC)
  116. {
  117. AddCustomModuleDevice(new SMCChiller(mod, "TopChiller"));
  118. }
  119. else if (SC.GetValue<int>($"{mod}.TopChiller.MFG") == (int)ChillerMFG.AIRSYS)
  120. {
  121. AddCustomModuleDevice(new AIRSYSChiller(mod, "TopChiller"));
  122. }
  123. }
  124. }
  125. if (SC.GetValue<bool>($"{mod}.Match.EnableMatch") &&
  126. SC.GetValue<int>($"{mod}.Match.CommunicationType") == (int)CommunicationType.RS232 &&
  127. SC.GetValue<int>($"{mod}.Match.MFG") == (int)MatchMFG.AdTec)
  128. {
  129. AddCustomModuleDevice(new AdTecMatch(mod, Venus_Core.VenusDevice.Match));
  130. }
  131. else if (SC.GetValue<bool>($"{mod}.Match.EnableMatch") &&
  132. SC.GetValue<int>($"{mod}.Match.CommunicationType") == (int)CommunicationType.RS232 &&
  133. SC.GetValue<int>($"{mod}.Match.MFG") == (int)MatchMFG.Revtech)
  134. {
  135. AddCustomModuleDevice(new RevtechMatch(mod, Venus_Core.VenusDevice.Match, MatchCommunicationType.RS232));
  136. }
  137. else if (SC.GetValue<bool>($"{mod}.Match.EnableMatch") &&
  138. SC.GetValue<int>($"{mod}.Match.CommunicationType") == (int)CommunicationType.Ethernet&&
  139. SC.GetValue<int>($"{mod}.Match.MFG") == (int)MatchMFG.Revtech)
  140. {
  141. AddCustomModuleDevice(new RevtechMatch(mod, Venus_Core.VenusDevice.Match, MatchCommunicationType.Ethernet));
  142. }
  143. if (jetChamber != JetChamber.Kepler2200A && jetChamber != JetChamber.Kepler2200B)
  144. {
  145. if (SC.GetValue<bool>($"{mod}.BiasMatch.EnableBiasMatch") &&
  146. SC.GetValue<int>($"{mod}.BiasMatch.CommunicationType") == (int)CommunicationType.RS232 &&
  147. SC.GetValue<int>($"{mod}.BiasMatch.MFG") == (int)MatchMFG.AdTec)
  148. {
  149. AddCustomModuleDevice(new AdTecMatch(mod, Venus_Core.VenusDevice.BiasMatch));
  150. }
  151. else if (SC.GetValue<bool>($"{mod}.BiasMatch.EnableBiasMatch") &&
  152. SC.GetValue<int>($"{mod}.BiasMatch.CommunicationType") == (int)CommunicationType.RS232 &&
  153. SC.GetValue<int>($"{mod}.BiasMatch.MFG") == (int)MatchMFG.Revtech)
  154. {
  155. AddCustomModuleDevice(new RevtechMatch(mod, Venus_Core.VenusDevice.BiasMatch, MatchCommunicationType.RS232));
  156. }
  157. else if (SC.GetValue<bool>($"{mod}.BiasMatch.EnableBiasMatch") &&
  158. SC.GetValue<int>($"{mod}.BiasMatch.CommunicationType") == (int)CommunicationType.Ethernet &&
  159. SC.GetValue<int>($"{mod}.BiasMatch.MFG") == (int)MatchMFG.Revtech)
  160. {
  161. AddCustomModuleDevice(new RevtechMatch(mod, Venus_Core.VenusDevice.BiasMatch, MatchCommunicationType.Ethernet));
  162. }
  163. if (SC.GetValue<bool>($"{mod}.BiasRf.EnableBiasRF"))
  164. {
  165. if (SC.GetValue<int>($"{mod}.BiasRf.CommunicationType") == (int)CommunicationType.Ethernet &&
  166. SC.GetValue<int>($"{mod}.BiasRf.MFG") == (int)GeneratorMFG.Comet)
  167. {
  168. AddCustomModuleDevice(new CometRF(mod, SC.GetStringValue($"{mod}.BiasRf.IPAddress")));
  169. }
  170. else if (SC.GetValue<int>($"{mod}.BiasRf.MFG") == (int)GeneratorMFG.AdTec)
  171. {
  172. AddCustomModuleDevice(new AdTecGenerator(mod, Venus_Core.VenusDevice.BiasRf));
  173. }
  174. }
  175. AddCustomModuleDevice(new ESC5HighVoltage(mod));
  176. if (SC.GetValue<bool>($"{mod}.Chiller.EnableChiller") &&
  177. SC.GetValue<int>($"{mod}.Chiller.CommunicationType") == (int)CommunicationType.RS232)
  178. {
  179. if (SC.GetValue<int>($"{mod}.Chiller.MFG") == (int)ChillerMFG.SMC)
  180. {
  181. AddCustomModuleDevice(new SMCChiller(mod, "Chiller"));
  182. }
  183. else if (SC.GetValue<int>($"{mod}.Chiller.MFG") == (int)ChillerMFG.AIRSYS)
  184. {
  185. AddCustomModuleDevice(new AIRSYSChiller(mod, "Chiller"));
  186. }
  187. }
  188. if (SC.GetValue<bool>($"{mod}.EPD.IsEnabled") == true)
  189. {
  190. if (SC.GetValue<int>($"{mod}.EPD.EPDType") == 0)
  191. {
  192. AddCustomModuleDevice(new EPDClient(mod));
  193. }
  194. else
  195. {
  196. AddCustomModuleDevice(new EPDDevice(mod));
  197. }
  198. }
  199. }
  200. if (SC.GetValue<int>($"{mod}.DryPump.CommunicationType") == (int)CommunicationType.RS232)
  201. {
  202. if (SC.GetValue<int>($"{mod}.DryPump.MFG") == (int)DryPumpMFG.SKY)
  203. {
  204. AddCustomModuleDevice(new SkyPump(mod));
  205. }
  206. else if (SC.GetValue<int>($"{mod}.DryPump.MFG") == (int)DryPumpMFG.Edwards)
  207. {
  208. AddCustomModuleDevice(new EdwardsPump(mod));
  209. }
  210. }
  211. AddCustomModuleDevice(new AdixenTurboPump(mod));
  212. AddCustomModuleDevice(new PendulumValve(mod));
  213. switch (jetChamber)
  214. {
  215. case JetChamber.Venus:
  216. AddCustomDevice(new JetVenusPM(mod));
  217. break;
  218. case JetChamber.Kepler2300:
  219. AddCustomDevice(new JetKepler2300PM(mod));
  220. break;
  221. case JetChamber.Kepler2200A:
  222. AddCustomDevice(new JetKepler2200APM(mod));
  223. break;
  224. case JetChamber.Kepler2200B:
  225. AddCustomDevice(new JetKepler2200BPM(mod));
  226. break;
  227. case JetChamber.VenusSE:
  228. AddCustomDevice(new JetVenusSEPM(mod));
  229. break;
  230. case JetChamber.VenusDE:
  231. AddCustomDevice(new JetVenusDEPM(mod));
  232. break;
  233. }
  234. }
  235. private void InitTM(ModuleName mod)
  236. {
  237. Initialize(device_model_file_MF, mod.ToString(), mod, mod.ToString());
  238. if (SC.GetValue<int>($"LLA.DryPump.CommunicationType") == (int)CommunicationType.RS232)
  239. {
  240. if (SC.GetValue<int>($"LLA.DryPump.MFG") == (int)DryPumpMFG.SKY)
  241. {
  242. AddCustomModuleDevice(new SkyPump(ModuleName.LLA));
  243. }
  244. else if (SC.GetValue<int>($"LLA.DryPump.MFG") == (int)DryPumpMFG.Edwards)
  245. {
  246. AddCustomModuleDevice(new EdwardsPump(ModuleName.LLA));
  247. }
  248. }
  249. if (SC.GetValue<int>($"{mod}.DryPump.CommunicationType") == (int)CommunicationType.RS232)
  250. {
  251. if (SC.GetValue<int>($"{mod}.DryPump.MFG") == (int)DryPumpMFG.SKY)
  252. {
  253. AddCustomModuleDevice(new SkyPump(mod));
  254. }
  255. else if (SC.GetValue<int>($"{mod}.DryPump.MFG") == (int)DryPumpMFG.Edwards)
  256. {
  257. AddCustomModuleDevice(new EdwardsPump(mod));
  258. }
  259. }
  260. //AddCustomModuleDevice(new SkyPump(mod));
  261. //AddCustomModuleDevice(new SkyPump(ModuleName.LLA));
  262. AddCustomDevice(new JetTM());
  263. }
  264. private void InitSETM(ModuleName mod)
  265. {
  266. Initialize(device_model_file_SEMF, mod.ToString(), mod, mod.ToString());
  267. if (SC.GetValue<int>($"{mod}.DryPump.CommunicationType") == (int)CommunicationType.RS232)
  268. {
  269. if (SC.GetValue<int>($"{mod}.DryPump.MFG") == (int)DryPumpMFG.SKY)
  270. {
  271. AddCustomModuleDevice(new SkyPump(mod));
  272. }
  273. else if (SC.GetValue<int>($"{mod}.DryPump.MFG") == (int)DryPumpMFG.Edwards)
  274. {
  275. AddCustomModuleDevice(new EdwardsPump(mod));
  276. }
  277. }
  278. AddCustomDevice(new HongHuTM());
  279. }
  280. private WaferSize MapWaferSize(int value)
  281. {
  282. switch (value)
  283. {
  284. case 3: return WaferSize.WS3;
  285. case 4: return WaferSize.WS4;
  286. case 6: return WaferSize.WS6;
  287. case 8: return WaferSize.WS8;
  288. }
  289. return WaferSize.WS0;
  290. }
  291. private bool Invoke(string arg1, object[] args)
  292. {
  293. string name = (string)args[0];
  294. string func = (string)args[1];
  295. object[] param = new object[args.Length - 2];
  296. for (int i = 2; i < args.Length; i++)
  297. param[i - 2] = args[i].ToString();
  298. DEVICE.Do(string.Format("{0}.{1}", name, func), 0, true, param);
  299. return true;
  300. }
  301. public void RTExitPMEvent()
  302. {
  303. if (ModuleHelper.IsInstalled(ModuleName.PMA))
  304. {
  305. DEVICE.GetDevice<JetPMBase>("PMA")?.RTCloseEvent();
  306. }
  307. if (ModuleHelper.IsInstalled(ModuleName.PMB))
  308. {
  309. DEVICE.GetDevice<JetPMBase>("PMB")?.RTCloseEvent();
  310. }
  311. if (ModuleHelper.IsInstalled(ModuleName.PMC))
  312. {
  313. DEVICE.GetDevice<JetPMBase>("PMC")?.RTCloseEvent();
  314. }
  315. if (ModuleHelper.IsInstalled(ModuleName.PMD))
  316. {
  317. DEVICE.GetDevice<JetPMBase>("PMD")?.RTCloseEvent();
  318. }
  319. }
  320. }
  321. }