using Aitex.Common.Util; using Aitex.Core.RT.Device; using Aitex.Core.Util; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.IOCore; using MECF.Framework.RT.Core.IoProviders; using System.Collections.Generic; using Aitex.Core.RT.SCCore; using JetVirgoPM.Devices; using JetVirgoPM.Devices.EPDs; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Pumps.EdwardsPump; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Pumps.SkyPump; namespace JetVirgoPM { public class JetVirgoPMDeviceManager : Singleton { private Dictionary _controller = new Dictionary(); private Dictionary _device = new Dictionary(); public JetVirgoPMDeviceManager() { } public void Initialize(ModuleName module) { var controller = new DeviceController(); var device = new DeviceManagerBase(true); string ioProviderPathFile = PathManager.GetCfgDir() + "JetVirgoPM//IoProviderConfig.xml"; IoProviderManager.Instance.Initialize(ioProviderPathFile, module.ToString(), "io", true); IoManager.Instance.Initialize(PathManager.GetCfgDir() + "JetVirgoPM//interlockPM.xml"); device.Initialize(PathManager.GetCfgDir() + "JetVirgoPM//DeviceModelPM.xml", "JetVirgoPM", module, module.ToString()); if (SC.GetValue($"{module}.Rf1.CommunicationType") == (int)CommunicationType.RS232) { if (SC.GetValue($"{module}.Rf1.MFG") == (int)GeneratorMFG.AdTec) { device.AddCustomModuleDevice(new AdTecGenerator(module, "Rf1")); } else if (SC.GetValue($"{module}.Rf1.MFG") == (int)GeneratorMFG.Wattsine) { device.AddCustomModuleDevice(new MicrowareRF(module, "Rf1")); } } if (SC.GetValue($"{module}.Rf2.CommunicationType") == (int)CommunicationType.RS232) { if (SC.GetValue($"{module}.Rf2.MFG") == (int)GeneratorMFG.AdTec) { device.AddCustomModuleDevice(new AdTecGenerator(module, "Rf2")); } else if (SC.GetValue($"{module}.Rf2.MFG") == (int)GeneratorMFG.Wattsine) { device.AddCustomModuleDevice(new MicrowareRF(module, "Rf2")); } } if (SC.GetValue($"{module}.BiasRf1.EnableBiasRF") && SC.GetValue($"{module}.BiasRf1.CommunicationType") == (int)CommunicationType.Ethernet && SC.GetValue($"{module}.BiasRf1.MFG") == (int)GeneratorMFG.Comet) { device.AddCustomModuleDevice(new CometRF(module, "BiasRf1", SC.GetStringValue($"{module}.BiasRf1.IPAddress"))); } if (SC.GetValue($"{module}.BiasRf2.EnableBiasRF") && SC.GetValue($"{module}.BiasRf2.CommunicationType") == (int)CommunicationType.Ethernet && SC.GetValue($"{module}.BiasRf2.MFG") == (int)GeneratorMFG.Comet) { device.AddCustomModuleDevice(new CometRF(module, "BiasRf2", SC.GetStringValue($"{module}.BiasRf2.IPAddress"))); } if (SC.GetValue($"{module}.BiasRf1.EnableBiasRF") && SC.GetValue($"{module}.BiasRf1.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{module}.BiasRf1.MFG") == (int)GeneratorMFG.AdTec) { device.AddCustomModuleDevice(new AdTecGenerator(module, "BiasRf1")); } if (SC.GetValue($"{module}.BiasRf2.EnableBiasRF") && SC.GetValue($"{module}.BiasRf2.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{module}.BiasRf2.MFG") == (int)GeneratorMFG.AdTec) { device.AddCustomModuleDevice(new AdTecGenerator(module, "BiasRf2")); } if (SC.GetValue($"{module}.Chiller1.EnableChiller") && SC.GetValue($"{module}.Chiller1.CommunicationType") == (int)CommunicationType.RS232) { if (SC.GetValue($"{module}.Chiller1.MFG") == (int)ChillerMFG.SMC) { device.AddCustomModuleDevice(new SMCChiller(module, "Chiller1")); } else if (SC.GetValue($"{module}.Chiller1.MFG") == (int)ChillerMFG.AIRSYS) { device.AddCustomModuleDevice(new AIRSYSChiller(module, "Chiller1")); } } if (SC.GetValue($"{module}.Chiller2.EnableChiller") && SC.GetValue($"{module}.Chiller2.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"System.SetUp.ChillerSetupOp.IsInstalled") == (int)ChillerSetupOp.NoShareSingleChiller) { if( SC.GetValue($"{module}.Chiller2.MFG") == (int)ChillerMFG.SMC) { device.AddCustomModuleDevice(new SMCChiller(module, "Chiller2")); } else if (SC.GetValue($"{module}.Chiller2.MFG") == (int)ChillerMFG.AIRSYS) { device.AddCustomModuleDevice(new AIRSYSChiller(module, "Chiller2")); } } if (SC.GetValue($"{module}.match1.EnableMatch") && SC.GetValue($"{module}.match1.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{module}.match1.MFG") == (int)MatchMFG.AdTec) { device.AddCustomModuleDevice(new AdTecMatch(module, "match1")); } if (SC.GetValue($"{module}.match2.EnableMatch") && SC.GetValue($"{module}.match2.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{module}.match2.MFG") == (int)MatchMFG.AdTec) { device.AddCustomModuleDevice(new AdTecMatch(module, "match2")); } if (SC.GetValue($"{module}.BiasRf1Match.EnableMatch") && SC.GetValue($"{module}.BiasRf1Match.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{module}.BiasRf1Match.MFG") == (int)MatchMFG.AdTec) { device.AddCustomModuleDevice(new AdTecMatch(module, "BiasRf1Match")); } if (SC.GetValue($"{module}.BiasRf2Match.EnableMatch") && SC.GetValue($"{module}.BiasRf2Match.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{module}.BiasRf2Match.MFG") == (int)MatchMFG.AdTec) { device.AddCustomModuleDevice(new AdTecMatch(module, "BiasRf2Match")); } if (SC.GetValue($"{module}.DryPump.CommunicationType") == (int)CommunicationType.RS232) { if (SC.GetValue($"{module}.DryPump.MFG") == (int)DryPumpMFG.SKY) { device.AddCustomModuleDevice(new SkyPump(module, VirgoDevice.MainPump.ToString())); } else if (SC.GetValue($"{module}.DryPump.MFG") == (int)DryPumpMFG.Edwards) { device.AddCustomModuleDevice(new EdwardsPump(module, VirgoDevice.MainPump.ToString())); } } if (SC.GetValue($"{module}.EPD.IsEnabled") && SC.GetValue("System.SetUp.EPD.IsInstalled")) { device.AddCustomModuleDevice(new EPDDevice(module.ToString(), "EPD")); } device.AddCustomModuleDevice(new JetDualPM(module)); controller.Start(device); _controller[module] = controller; _device[module] = device; } public void Reset(ModuleName module) { _controller[module].Reset(); } public void Terminate(ModuleName module) { _controller[module].Terminate(); DEVICE.GetDevice($"{module}.{module}").Terminate(); } } }