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 IoProviderConfigPath = "IoProviderConfig"; string InterlockPath = "interlockPM"; string DeviceModelPath = "DeviceModelPM"; if (SC.GetValue($"{module}.IsPlus")) { IoProviderConfigPath = "IoProviderConfigPlus"; InterlockPath = "interlockPMPlus"; DeviceModelPath = "DeviceModelPMPlus"; } string ioProviderPathFile = PathManager.GetCfgDir() + $"JetVirgoPM//{IoProviderConfigPath}.xml"; IoProviderManager.Instance.Initialize(ioProviderPathFile, module.ToString(), "io", true); IoManager.Instance.Initialize(PathManager.GetCfgDir() + $"JetVirgoPM//{InterlockPath}.xml"); device.Initialize(PathManager.GetCfgDir() + $"JetVirgoPM//{DeviceModelPath}.xml", "JetVirgoPM", module, module.ToString()); if (SC.GetValue($"{module}.Rf1.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{module}.Rf1.MFG") == (int)GeneratorMFG.AdTec) { device.AddCustomModuleDevice(new AdTecGenerator(module, "Rf1")); } if (SC.GetValue($"{module}.Rf2.CommunicationType") == (int)CommunicationType.RS232 && SC.GetValue($"{module}.Rf2.MFG") == (int)GeneratorMFG.AdTec) { device.AddCustomModuleDevice(new AdTecGenerator(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")); } } //srf1 match adtec 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")); } //srf2 match adtec 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")); } //brf1 match adtec 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")); } //brf2 match adtec 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")); } //srf1 match revtec if (SC.GetValue($"{module}.match1.EnableMatch") && SC.GetValue($"{module}.match1.CommunicationType") == (int)CommunicationType.Ethernet && SC.GetValue($"{module}.match1.MFG") == (int)MatchMFG.RevTec) { device.AddCustomModuleDevice(new RevtechMatch(module, "match1")); } //srf2 match revtec if (SC.GetValue($"{module}.match2.EnableMatch") && SC.GetValue($"{module}.match2.CommunicationType") == (int)CommunicationType.Ethernet && SC.GetValue($"{module}.match2.MFG") == (int)MatchMFG.RevTec) { device.AddCustomModuleDevice(new RevtechMatch(module, "match2")); } //brf1 match revtec if (SC.GetValue($"{module}.BiasRf1Match.EnableMatch") && SC.GetValue($"{module}.BiasRf1Match.CommunicationType") == (int)CommunicationType.Ethernet && SC.GetValue($"{module}.BiasRf1Match.MFG") == (int)MatchMFG.RevTec) { device.AddCustomModuleDevice(new RevtechMatch(module, "BiasRf1Match")); } //brf2 match revtec if (SC.GetValue($"{module}.BiasRf2Match.EnableMatch") && SC.GetValue($"{module}.BiasRf2Match.CommunicationType") == (int)CommunicationType.Ethernet && SC.GetValue($"{module}.BiasRf2Match.MFG") == (int)MatchMFG.RevTec) { device.AddCustomModuleDevice(new RevtechMatch(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(); } } }