using System; using System.Collections.Generic; using System.IO; using Aitex.Core.Common; using Aitex.Core.RT.Device; using Aitex.Core.RT.OperationCenter; using Aitex.Core.RT.SCCore; using Aitex.RT.Device.Custom; using MECF.Framework.Common.Equipment; using Venus_RT.Modules; using Venus_RT.Devices; using Venus_RT.Devices.EPD; using Venus_Core; using Aitex.Common.Util; using System.Reflection; using Venus_RT.Devices.AdLinkEthercat; using System.Windows; using Aitex.Core.RT.Log; using Venus_RT.Devices.TM; namespace Venus_RT.Instances { public class DeviceEntity : DeviceEntityT { public DeviceEntity() { } } public class DeviceManager : DeviceManagerBase { private string device_model_file; private readonly string device_model_file_MF; private readonly string device_model_file_SEMF; private readonly string device_model_file_DEMF; Int32 v_board_id = -1; Int32 v_StartAxisID = 0; Int32 BUS_No = 0; private bool startEthercatOK; public DeviceManager() { device_model_file_MF = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config\\", "TM", RtInstance.DeviceModelFileName_MF); device_model_file_SEMF = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config\\", "TM", RtInstance.DeviceModelFileName_SE); device_model_file_DEMF = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config\\", "TM", RtInstance.DeviceModelFileName_DE); } public bool InitEthercat() { Int32 boardID_InBits = 0; Int32 mode = 0; Int32 ret = 0; Int32 card_name = 0; Int32 tamp = 0; Int32 StartAxisID = 0; Int32 TotalAxisNum = 0; // Card(Board) initial ret = APS168.APS_initial(ref boardID_InBits, mode); if (ret == 0) { for (int i = 0; i < 16; i++) { tamp = (boardID_InBits >> i) & 1; if (tamp == 1) { ret = APS168.APS_get_card_name(i, ref card_name); if ((card_name >= (Int32)APS_Define.DEVICE_NAME_EM_2P00) && (card_name <= (Int32)APS_Define.DEVICE_NAME_EM_FA00)) { ret = APS168.APS_get_first_axisId(i, ref StartAxisID, ref TotalAxisNum); //v_card_name = card_name; v_board_id = i; v_StartAxisID = StartAxisID; LOG.Write(eEvent.EV_DEVICE_INFO, ModuleName.System, "Ethercat Initial Success!"); break; } } } if (v_board_id == -1) { LOG.Write(eEvent.ERR_DEVICE_INFO, ModuleName.System, $"Ethercat Board Id search Fail!"); } else { LOG.Write(eEvent.EV_DEVICE_INFO, ModuleName.System, "Ethercat Board Id search Success!"); return true; } } else { LOG.Write(eEvent.ERR_DEVICE_INFO, ModuleName.System, $"Ethercat Initial Fail!"); } return false; } public bool StarteEthercat() { Int32 ret = 0; Int32 Board_ID = v_board_id; ret = APS168.APS_start_field_bus(Board_ID, BUS_No, v_StartAxisID); if (ret != 0) { LOG.Write(eEvent.ERR_DEVICE_INFO, ModuleName.System, $"Ethercat Start field bus Fail"); return false; } else { LOG.Write(eEvent.EV_DEVICE_INFO, ModuleName.System, $"Ethercat Start field bus Success"); return true; } } public override bool Initialize() { if (SC.GetValue("System.IsEnableEthercat")) { if (InitEthercat()) { if (StarteEthercat()) { startEthercatOK = true; } } } if (ModuleHelper.IsInstalled(ModuleName.PMA)) { JetChamber jetChamber = (JetChamber)SC.GetValue("PMA.ChamberType"); InitPM(ModuleName.PMA, jetChamber); } if (ModuleHelper.IsInstalled(ModuleName.PMB)) { JetChamber jetChamber = (JetChamber)SC.GetValue("PMB.ChamberType"); InitPM(ModuleName.PMB, jetChamber); } if (ModuleHelper.IsInstalled(ModuleName.PMC)) { JetChamber jetChamber = (JetChamber)SC.GetValue("PMC.ChamberType"); InitPM(ModuleName.PMC, jetChamber); } if (ModuleHelper.IsInstalled(ModuleName.PMD)) { JetChamber jetChamber = (JetChamber)SC.GetValue("PMD.ChamberType"); InitPM(ModuleName.PMD, jetChamber); } if (ModuleHelper.IsInstalled(ModuleName.TM)) { if (RtInstance.ConfigType == ConfigType.Kepler2200 || RtInstance.ConfigType == ConfigType.Kepler2300) InitTM(ModuleName.TM); //if (RtInstance.ConfigType == ConfigType.VenusSE) //{ // InitSETM(ModuleName.TM); //} //if (RtInstance.ConfigType == ConfigType.VenusDE) //{ // InitDETM(ModuleName.TM); //} } if (RtInstance.ConfigType != ConfigType.VenusDE && RtInstance.ConfigType != ConfigType.VenusSE) AddCustomModuleDevice(new KeplerSignalTower("System", "SignalTower")); OP.Subscribe("DeviceOperation", this.Invoke); return true; } private void InitPM(ModuleName mod, JetChamber jetChamber) { device_model_file = PathManager.GetCfgDir() + "PM" + "\\" + jetChamber.ToString() + "\\" + $"{jetChamber.ToString()}DeviceModel.xml"; Initialize(device_model_file, jetChamber.ToString(), mod, mod.ToString()); switch (jetChamber) { case JetChamber.Kepler2300: AddAdixenTurboPump(mod); AddEPD(mod); AddPendulumValve(mod); AddChiller(ChillerType.InnerChiller, mod); AddChiller(ChillerType.OuterChiller, mod); AddChiller(ChillerType.TopChiller, mod); AddMatch(mod); AddBiasMatch(mod); AddRF(mod); AddBiasRF(mod); AddDryPump(mod); AddCustomDevice(new JetKepler2300PM(mod)); break; case JetChamber.Kepler2200A: AddAdixenTurboPump(mod); AddPendulumValve(mod, PressureType.Pa); AddMatch(mod); AddRF(mod); AddDryPump(mod); AddCustomDevice(new JetKepler2200APM(mod)); break; case JetChamber.Kepler2200B: AddAdixenTurboPump(mod); AddPendulumValve(mod, PressureType.Pa); AddMatch(mod); AddRF(mod); AddDryPump(mod); AddRFBox(mod); AddCustomDevice(new JetKepler2200BPM(mod)); break; } } private void AddEPD(ModuleName mod) { if (SC.GetValue($"{mod}.EPD.IsEnabled") == true) { if (SC.GetValue($"{mod}.EPD.EPDType") == 0) { AddCustomModuleDevice(new EPDClient(mod)); } else { AddCustomModuleDevice(new EPDDevice(mod)); } } } private void AddAdixenTurboPump(ModuleName mod) { AddCustomModuleDevice(new AdixenTurboPump(mod)); } private void AddPendulumValve(ModuleName mod, PressureType pressureType = PressureType.mTorr) { AddCustomModuleDevice(new PendulumValve(mod, pressureType)); } private void AddChiller(ChillerType chillerType, ModuleName mod) { if (SC.GetValue($"{mod}.{chillerType}.EnableChiller") && SC.GetValue($"{mod}.{chillerType}.CommunicationType") == (int)CommunicationType.RS232) { if (SC.GetValue($"{mod}.{chillerType}.MFG") == (int)ChillerMFG.SMC) { AddCustomModuleDevice(new SMCChiller(mod, chillerType.ToString())); } else if (SC.GetValue($"{mod}.{chillerType}.MFG") == (int)ChillerMFG.AIRSYS) { AddCustomModuleDevice(new AIRSYSChiller(mod, chillerType.ToString())); } } else if (SC.GetValue($"{mod}.{chillerType}.EnableChiller") && SC.GetValue($"{mod}.{chillerType}.CommunicationType") == (int)CommunicationType.RS485 && SC.GetValue($"{mod}.{chillerType}.ShareCOM")) { if (SC.GetValue($"{mod}.{chillerType}.MFG") == (int)ChillerMFG.SMC) { AddCustomModuleDevice(new SMCShareChiller(mod, chillerType.ToString())); } //else if (SC.GetValue($"{mod}.{chillerType}.MFG") == (int)ChillerMFG.AIRSYS) //{ // AddCustomModuleDevice(new AIRSYSChiller(mod, chillerType.ToString())); //} } } private void AddMatch(ModuleName mod) { if (SC.GetValue($"{mod}.Match.EnableMatch") && SC.GetValue($"{mod}.Match.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{mod}.Match.MFG") == (int)MatchMFG.AdTec) { AddCustomModuleDevice(new AdTecMatch(mod, Venus_Core.VenusDevice.Match)); } else if (SC.GetValue($"{mod}.Match.EnableMatch") && SC.GetValue($"{mod}.Match.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{mod}.Match.MFG") == (int)MatchMFG.Revtech) { AddCustomModuleDevice(new RevtechMatch(mod, Venus_Core.VenusDevice.Match, MatchCommunicationType.RS232)); } else if (SC.GetValue($"{mod}.Match.EnableMatch") && SC.GetValue($"{mod}.Match.CommunicationType") == (int)CommunicationType.Ethernet && SC.GetValue($"{mod}.Match.MFG") == (int)MatchMFG.Revtech) { AddCustomModuleDevice(new RevtechMatch(mod, Venus_Core.VenusDevice.Match, MatchCommunicationType.Ethernet)); } } private void AddRFBox(ModuleName mod) { if (SC.GetValue($"{mod}.RFBox.EnableMatch") && SC.GetValue($"{mod}.RFBox.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{mod}.RFBox.MFG") == (int)MatchMFG.AdTec) { AddCustomModuleDevice(new AdTecMatch(mod, Venus_Core.VenusDevice.RFBox)); } else if (SC.GetValue($"{mod}.RFBox.EnableMatch") && SC.GetValue($"{mod}.RFBox.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{mod}.RFBox.MFG") == (int)MatchMFG.Revtech) { AddCustomModuleDevice(new RevtechMatch(mod, Venus_Core.VenusDevice.RFBox, MatchCommunicationType.RS232)); } else if (SC.GetValue($"{mod}.RFBox.EnableMatch") && SC.GetValue($"{mod}.RFBox.CommunicationType") == (int)CommunicationType.Ethernet && SC.GetValue($"{mod}.RFBox.MFG") == (int)MatchMFG.Revtech) { AddCustomModuleDevice(new RevtechMatch(mod, Venus_Core.VenusDevice.RFBox, MatchCommunicationType.Ethernet)); } else if (SC.GetValue($"{mod}.RFBox.EnableMatch") && SC.GetValue($"{mod}.RFBox.MFG") == (int)MatchMFG.Lz_Ethercat && startEthercatOK) { AddCustomModuleDevice(new LzMatch_Ethercat(mod, Venus_Core.VenusDevice.RFBox, v_board_id)); } } private void AddBiasMatch(ModuleName mod) { if (SC.GetValue($"{mod}.BiasMatch.EnableBiasMatch") && SC.GetValue($"{mod}.BiasMatch.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{mod}.BiasMatch.MFG") == (int)MatchMFG.AdTec) { AddCustomModuleDevice(new AdTecMatch(mod, Venus_Core.VenusDevice.BiasMatch)); } else if (SC.GetValue($"{mod}.BiasMatch.EnableBiasMatch") && SC.GetValue($"{mod}.BiasMatch.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{mod}.BiasMatch.MFG") == (int)MatchMFG.Revtech) { AddCustomModuleDevice(new RevtechMatch(mod, Venus_Core.VenusDevice.BiasMatch, MatchCommunicationType.RS232)); } else if (SC.GetValue($"{mod}.BiasMatch.EnableBiasMatch") && SC.GetValue($"{mod}.BiasMatch.CommunicationType") == (int)CommunicationType.Ethernet && SC.GetValue($"{mod}.BiasMatch.MFG") == (int)MatchMFG.Revtech) { AddCustomModuleDevice(new RevtechMatch(mod, Venus_Core.VenusDevice.BiasMatch, MatchCommunicationType.Ethernet)); } else if (SC.GetValue($"{mod}.BiasMatch.EnableBiasMatch") && SC.GetValue($"{mod}.BiasMatch.MFG") == (int)MatchMFG.Lz_Ethercat && startEthercatOK) { AddCustomModuleDevice(new LzMatch_Ethercat(mod, Venus_Core.VenusDevice.BiasMatch, v_board_id)); } else if (SC.GetValue($"{mod}.BiasMatch.EnableBiasMatch") && SC.GetValue($"{mod}.BiasMatch.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{mod}.BiasMatch.MFG") == (int)MatchMFG.Tru) { AddCustomModuleDevice(new TruPlasmaMatch(mod, Venus_Core.VenusDevice.BiasMatch)); } } private void AddRF(ModuleName mod) { if (SC.GetValue($"{mod}.Rf.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{mod}.Rf.MFG") == (int)GeneratorMFG.AdTec) { AddCustomModuleDevice(new AdTecGenerator(mod, Venus_Core.VenusDevice.Rf)); } } private void AddBiasRF(ModuleName mod) { if (SC.GetValue($"{mod}.BiasRf.EnableBiasRF")) { if (SC.GetValue($"{mod}.BiasRf.CommunicationType") == (int)CommunicationType.Ethernet && SC.GetValue($"{mod}.BiasRf.MFG") == (int)GeneratorMFG.Comet) { AddCustomModuleDevice(new CometRF(mod, SC.GetStringValue($"{mod}.BiasRf.IPAddress"))); } else if (SC.GetValue($"{mod}.BiasRf.MFG") == (int)GeneratorMFG.AdTec) { AddCustomModuleDevice(new AdTecGenerator(mod, Venus_Core.VenusDevice.BiasRf)); } else if (SC.GetValue($"{mod}.BiasRf.MFG") == (int)GeneratorMFG.Truplasma) { AddCustomModuleDevice(new TruPlasmaRF(mod, Venus_Core.VenusDevice.BiasRf)); } else if (SC.GetValue($"{mod}.BiasRf.MFG") == (int)GeneratorMFG.Truplasma_Ethercat && startEthercatOK) { AddCustomModuleDevice(new TruPlasmaRF_Ethercat(mod, Venus_Core.VenusDevice.BiasRf, v_board_id)); } } } private void AddDryPump(ModuleName mod) { if (SC.GetValue($"{mod}.DryPump.CommunicationType") == (int)CommunicationType.RS232) { if (SC.GetValue($"{mod}.DryPump.MFG") == (int)DryPumpMFG.SKY) { AddCustomModuleDevice(new SkyPump(mod)); } else if (SC.GetValue($"{mod}.DryPump.MFG") == (int)DryPumpMFG.Edwards) { AddCustomModuleDevice(new EdwardsPump(mod)); } } } private void AddEscHighVoltage(ModuleName mod) { AddCustomModuleDevice(new ESC5HighVoltage(mod)); } private void InitTM(ModuleName mod) { Initialize(device_model_file_MF, mod.ToString(), mod, mod.ToString()); if (SC.GetValue($"LLA.DryPump.CommunicationType") == (int)CommunicationType.RS232) { if (SC.GetValue($"LLA.DryPump.MFG") == (int)DryPumpMFG.SKY) { AddCustomModuleDevice(new SkyPump(ModuleName.LLA)); } else if (SC.GetValue($"LLA.DryPump.MFG") == (int)DryPumpMFG.Edwards) { AddCustomModuleDevice(new EdwardsPump(ModuleName.LLA)); } } if (SC.GetValue($"LLB.DryPump.CommunicationType") == (int)CommunicationType.RS232) { if (SC.GetValue($"LLB.DryPump.MFG") == (int)DryPumpMFG.SKY) { AddCustomModuleDevice(new SkyPump(ModuleName.LLB)); } else if (SC.GetValue($"LLB.DryPump.MFG") == (int)DryPumpMFG.Edwards) { AddCustomModuleDevice(new EdwardsPump(ModuleName.LLB)); } } if (SC.GetValue($"{mod}.DryPump.CommunicationType") == (int)CommunicationType.RS232) { if (SC.GetValue($"{mod}.DryPump.MFG") == (int)DryPumpMFG.SKY) { AddCustomModuleDevice(new SkyPump(mod)); } else if (SC.GetValue($"{mod}.DryPump.MFG") == (int)DryPumpMFG.Edwards) { AddCustomModuleDevice(new EdwardsPump(mod)); } } //AddCustomModuleDevice(new SkyPump(mod)); //AddCustomModuleDevice(new SkyPump(ModuleName.LLA)); AddCustomDevice(new JetTM()); } //private void InitSETM(ModuleName mod) //{ // Initialize(device_model_file_SEMF, mod.ToString(), mod, mod.ToString()); // if (SC.GetValue($"{mod}.DryPump.CommunicationType") == (int)CommunicationType.RS232) // { // if (SC.GetValue($"{mod}.DryPump.MFG") == (int)DryPumpMFG.SKY) // { // AddCustomModuleDevice(new SkyPump(mod)); // } // else if (SC.GetValue($"{mod}.DryPump.MFG") == (int)DryPumpMFG.Edwards) // { // AddCustomModuleDevice(new EdwardsPump(mod)); // } // } // AddCustomDevice(new HongHuTM()); //} //private void InitDETM(ModuleName mod) //{ // Initialize(device_model_file_DEMF, mod.ToString(), mod, mod.ToString()); // if (SC.GetValue($"{mod}.DryPump.CommunicationType") == (int)CommunicationType.RS232) // { // if (SC.GetValue($"{mod}.DryPump.MFG") == (int)DryPumpMFG.SKY) // { // AddCustomModuleDevice(new SkyPump(mod)); // } // else if (SC.GetValue($"{mod}.DryPump.MFG") == (int)DryPumpMFG.Edwards) // { // AddCustomModuleDevice(new EdwardsPump(mod)); // } // } // if (SC.GetValue($"VCEA.DryPump.CommunicationType") == (int)CommunicationType.RS232) // { // if (SC.GetValue($"VCEA.DryPump.MFG") == (int)DryPumpMFG.SKY) // { // AddCustomModuleDevice(new SkyPump(ModuleName.VCEA)); // } // else if (SC.GetValue($"VCEA.DryPump.MFG") == (int)DryPumpMFG.Edwards) // { // AddCustomModuleDevice(new EdwardsPump(ModuleName.VCEA)); // } // } // AddCustomDevice(new HongHuDETM()); //} private WaferSize MapWaferSize(int value) { switch (value) { case 3: return WaferSize.WS3; case 4: return WaferSize.WS4; case 6: return WaferSize.WS6; case 8: return WaferSize.WS8; } return WaferSize.WS0; } private bool Invoke(string arg1, object[] args) { string name = (string)args[0]; string func = (string)args[1]; object[] param = new object[args.Length - 2]; for (int i = 2; i < args.Length; i++) param[i - 2] = args[i].ToString(); DEVICE.Do(string.Format("{0}.{1}", name, func), 0, true, param); return true; } public void RTExitPMEvent() { if (ModuleHelper.IsInstalled(ModuleName.PMA)) { DEVICE.GetDevice("PMA")?.RTCloseEvent(); } if (ModuleHelper.IsInstalled(ModuleName.PMB)) { DEVICE.GetDevice("PMB")?.RTCloseEvent(); } if (ModuleHelper.IsInstalled(ModuleName.PMC)) { DEVICE.GetDevice("PMC")?.RTCloseEvent(); } if (ModuleHelper.IsInstalled(ModuleName.PMD)) { DEVICE.GetDevice("PMD")?.RTCloseEvent(); } } public bool CheckPMDisconnetCondition(out string reason) { if (ModuleHelper.IsInstalled(ModuleName.PMA) && DEVICE.GetDevice("PMA")?.IsPenVOpen == true) { reason = "PMA VAT is open"; return false; } if (ModuleHelper.IsInstalled(ModuleName.PMB) && DEVICE.GetDevice("PMB")?.IsPenVOpen == true) { reason = "PMB VAT is open"; return false; } if (ModuleHelper.IsInstalled(ModuleName.PMC) && DEVICE.GetDevice("PMC")?.IsPenVOpen == true) { reason = "PMC VAT is open"; return false; } if (ModuleHelper.IsInstalled(ModuleName.PMD) && DEVICE.GetDevice("PMD")?.IsPenVOpen == true) { reason = "PMD VAT is open"; return false; } reason = "ALL is close"; return true; } } }