JetVirgoPMDeviceManager.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. using Aitex.Common.Util;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.Util;
  4. using MECF.Framework.Common.Equipment;
  5. using MECF.Framework.Common.IOCore;
  6. using MECF.Framework.RT.Core.IoProviders;
  7. using System.Collections.Generic;
  8. using Aitex.Core.RT.SCCore;
  9. using JetVirgoPM.Devices;
  10. using JetVirgoPM.Devices.EPDs;
  11. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Pumps.EdwardsPump;
  12. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Pumps.SkyPump;
  13. namespace JetVirgoPM
  14. {
  15. public class JetVirgoPMDeviceManager : Singleton<JetVirgoPMDeviceManager>
  16. {
  17. private Dictionary<ModuleName, DeviceController> _controller = new Dictionary<ModuleName, DeviceController>();
  18. private Dictionary<ModuleName, DeviceManagerBase> _device = new Dictionary<ModuleName, DeviceManagerBase>();
  19. public JetVirgoPMDeviceManager()
  20. {
  21. }
  22. public void Initialize(ModuleName module)
  23. {
  24. var controller = new DeviceController();
  25. var device = new DeviceManagerBase(true);
  26. string ioProviderPathFile = PathManager.GetCfgDir() + "JetVirgoPM//IoProviderConfig.xml";
  27. IoProviderManager.Instance.Initialize(ioProviderPathFile, module.ToString(), "io", true);
  28. IoManager.Instance.Initialize(PathManager.GetCfgDir() + "JetVirgoPM//interlockPM.xml");
  29. device.Initialize(PathManager.GetCfgDir() + "JetVirgoPM//DeviceModelPM.xml", "JetVirgoPM", module,
  30. module.ToString());
  31. if (SC.GetValue<int>($"{module}.Rf1.CommunicationType") == (int)CommunicationType.RS232)
  32. {
  33. if (SC.GetValue<int>($"{module}.Rf1.MFG") == (int)GeneratorMFG.AdTec)
  34. {
  35. device.AddCustomModuleDevice(new AdTecGenerator(module, "Rf1"));
  36. }
  37. else if (SC.GetValue<int>($"{module}.Rf1.MFG") == (int)GeneratorMFG.Wattsine)
  38. {
  39. device.AddCustomModuleDevice(new MicrowareRF(module, "Rf1"));
  40. }
  41. }
  42. if (SC.GetValue<int>($"{module}.Rf2.CommunicationType") == (int)CommunicationType.RS232)
  43. {
  44. if (SC.GetValue<int>($"{module}.Rf2.MFG") == (int)GeneratorMFG.AdTec)
  45. {
  46. device.AddCustomModuleDevice(new AdTecGenerator(module, "Rf2"));
  47. }
  48. else if (SC.GetValue<int>($"{module}.Rf2.MFG") == (int)GeneratorMFG.Wattsine)
  49. {
  50. device.AddCustomModuleDevice(new MicrowareRF(module, "Rf2"));
  51. }
  52. }
  53. if (SC.GetValue<bool>($"{module}.BiasRf1.EnableBiasRF") &&
  54. SC.GetValue<int>($"{module}.BiasRf1.CommunicationType") == (int)CommunicationType.Ethernet &&
  55. SC.GetValue<int>($"{module}.BiasRf1.MFG") == (int)GeneratorMFG.Comet)
  56. {
  57. device.AddCustomModuleDevice(new CometRF(module, "BiasRf1", SC.GetStringValue($"{module}.BiasRf1.IPAddress")));
  58. }
  59. if (SC.GetValue<bool>($"{module}.BiasRf2.EnableBiasRF") &&
  60. SC.GetValue<int>($"{module}.BiasRf2.CommunicationType") == (int)CommunicationType.Ethernet &&
  61. SC.GetValue<int>($"{module}.BiasRf2.MFG") == (int)GeneratorMFG.Comet)
  62. {
  63. device.AddCustomModuleDevice(new CometRF(module, "BiasRf2", SC.GetStringValue($"{module}.BiasRf2.IPAddress")));
  64. }
  65. if (SC.GetValue<bool>($"{module}.BiasRf1.EnableBiasRF") &&
  66. SC.GetValue<int>($"{module}.BiasRf1.CommunicationType") == (int)CommunicationType.RS232 &&
  67. SC.GetValue<int>($"{module}.BiasRf1.MFG") == (int)GeneratorMFG.AdTec)
  68. {
  69. device.AddCustomModuleDevice(new AdTecGenerator(module, "BiasRf1"));
  70. }
  71. if (SC.GetValue<bool>($"{module}.BiasRf2.EnableBiasRF") &&
  72. SC.GetValue<int>($"{module}.BiasRf2.CommunicationType") == (int)CommunicationType.RS232 &&
  73. SC.GetValue<int>($"{module}.BiasRf2.MFG") == (int)GeneratorMFG.AdTec)
  74. {
  75. device.AddCustomModuleDevice(new AdTecGenerator(module, "BiasRf2"));
  76. }
  77. if (SC.GetValue<bool>($"{module}.Chiller1.EnableChiller") &&
  78. SC.GetValue<int>($"{module}.Chiller1.CommunicationType") == (int)CommunicationType.RS232)
  79. {
  80. if (SC.GetValue<int>($"{module}.Chiller1.MFG") == (int)ChillerMFG.SMC)
  81. {
  82. device.AddCustomModuleDevice(new SMCChiller(module, "Chiller1"));
  83. }
  84. else if (SC.GetValue<int>($"{module}.Chiller1.MFG") == (int)ChillerMFG.AIRSYS)
  85. {
  86. device.AddCustomModuleDevice(new AIRSYSChiller(module, "Chiller1"));
  87. }
  88. }
  89. if (SC.GetValue<bool>($"{module}.Chiller2.EnableChiller") &&
  90. SC.GetValue<int>($"{module}.Chiller2.CommunicationType") == (int)CommunicationType.RS232 &&
  91. SC.GetValue<int>($"System.SetUp.ChillerSetupOp.IsInstalled") == (int)ChillerSetupOp.NoShareSingleChiller)
  92. {
  93. if( SC.GetValue<int>($"{module}.Chiller2.MFG") == (int)ChillerMFG.SMC)
  94. {
  95. device.AddCustomModuleDevice(new SMCChiller(module, "Chiller2"));
  96. }
  97. else if (SC.GetValue<int>($"{module}.Chiller2.MFG") == (int)ChillerMFG.AIRSYS)
  98. {
  99. device.AddCustomModuleDevice(new AIRSYSChiller(module, "Chiller2"));
  100. }
  101. }
  102. if (SC.GetValue<bool>($"{module}.match1.EnableMatch") &&
  103. SC.GetValue<int>($"{module}.match1.CommunicationType") == (int)CommunicationType.RS232 &&
  104. SC.GetValue<int>($"{module}.match1.MFG") == (int)MatchMFG.AdTec)
  105. {
  106. device.AddCustomModuleDevice(new AdTecMatch(module, "match1"));
  107. }
  108. if (SC.GetValue<bool>($"{module}.match2.EnableMatch") &&
  109. SC.GetValue<int>($"{module}.match2.CommunicationType") == (int)CommunicationType.RS232 &&
  110. SC.GetValue<int>($"{module}.match2.MFG") == (int)MatchMFG.AdTec)
  111. {
  112. device.AddCustomModuleDevice(new AdTecMatch(module, "match2"));
  113. }
  114. if (SC.GetValue<bool>($"{module}.BiasRf1Match.EnableMatch") &&
  115. SC.GetValue<int>($"{module}.BiasRf1Match.CommunicationType") == (int)CommunicationType.RS232 &&
  116. SC.GetValue<int>($"{module}.BiasRf1Match.MFG") == (int)MatchMFG.AdTec)
  117. {
  118. device.AddCustomModuleDevice(new AdTecMatch(module, "BiasRf1Match"));
  119. }
  120. if (SC.GetValue<bool>($"{module}.BiasRf2Match.EnableMatch") &&
  121. SC.GetValue<int>($"{module}.BiasRf2Match.CommunicationType") == (int)CommunicationType.RS232 &&
  122. SC.GetValue<int>($"{module}.BiasRf2Match.MFG") == (int)MatchMFG.AdTec)
  123. {
  124. device.AddCustomModuleDevice(new AdTecMatch(module, "BiasRf2Match"));
  125. }
  126. if (SC.GetValue<int>($"{module}.DryPump.CommunicationType") == (int)CommunicationType.RS232)
  127. {
  128. if (SC.GetValue<int>($"{module}.DryPump.MFG") == (int)DryPumpMFG.SKY)
  129. {
  130. device.AddCustomModuleDevice(new SkyPump(module, VirgoDevice.MainPump.ToString()));
  131. }
  132. else if (SC.GetValue<int>($"{module}.DryPump.MFG") == (int)DryPumpMFG.Edwards)
  133. {
  134. device.AddCustomModuleDevice(new EdwardsPump(module, VirgoDevice.MainPump.ToString()));
  135. }
  136. }
  137. if (SC.GetValue<bool>($"{module}.EPD.IsEnabled") && SC.GetValue<bool>("System.SetUp.EPD.IsInstalled"))
  138. {
  139. device.AddCustomModuleDevice(new EPDDevice(module.ToString(), "EPD"));
  140. }
  141. device.AddCustomModuleDevice(new JetDualPM(module));
  142. controller.Start(device);
  143. _controller[module] = controller;
  144. _device[module] = device;
  145. }
  146. public void Reset(ModuleName module)
  147. {
  148. _controller[module].Reset();
  149. }
  150. public void Terminate(ModuleName module)
  151. {
  152. _controller[module].Terminate();
  153. DEVICE.GetDevice<JetDualPM>($"{module}.{module}").Terminate();
  154. }
  155. }
  156. }