JetVirgoPMDeviceManager.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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 IoProviderConfigPath = "IoProviderConfig";
  27. string InterlockPath = "interlockPM";
  28. string DeviceModelPath = "DeviceModelPM";
  29. if (SC.GetValue<bool>($"{module}.IsPlus"))
  30. {
  31. IoProviderConfigPath = "IoProviderConfigPlus";
  32. InterlockPath = "interlockPMPlus";
  33. DeviceModelPath = "DeviceModelPMPlus";
  34. }
  35. string ioProviderPathFile = PathManager.GetCfgDir() + $"JetVirgoPM//{IoProviderConfigPath}.xml";
  36. IoProviderManager.Instance.Initialize(ioProviderPathFile, module.ToString(), "io", true);
  37. IoManager.Instance.Initialize(PathManager.GetCfgDir() + $"JetVirgoPM//{InterlockPath}.xml");
  38. device.Initialize(PathManager.GetCfgDir() + $"JetVirgoPM//{DeviceModelPath}.xml", "JetVirgoPM", module,
  39. module.ToString());
  40. if (SC.GetValue<int>($"{module}.Rf1.CommunicationType") == (int)CommunicationType.RS232 &&
  41. SC.GetValue<int>($"{module}.Rf1.MFG") == (int)GeneratorMFG.AdTec)
  42. {
  43. device.AddCustomModuleDevice(new AdTecGenerator(module, "Rf1"));
  44. }
  45. if (SC.GetValue<int>($"{module}.Rf2.CommunicationType") == (int)CommunicationType.RS232 &&
  46. SC.GetValue<int>($"{module}.Rf2.MFG") == (int)GeneratorMFG.AdTec)
  47. {
  48. device.AddCustomModuleDevice(new AdTecGenerator(module, "Rf2"));
  49. }
  50. if (SC.GetValue<bool>($"{module}.BiasRf1.EnableBiasRF") &&
  51. SC.GetValue<int>($"{module}.BiasRf1.CommunicationType") == (int)CommunicationType.Ethernet &&
  52. SC.GetValue<int>($"{module}.BiasRf1.MFG") == (int)GeneratorMFG.Comet)
  53. {
  54. device.AddCustomModuleDevice(new CometRF(module, "BiasRf1", SC.GetStringValue($"{module}.BiasRf1.IPAddress")));
  55. }
  56. if (SC.GetValue<bool>($"{module}.BiasRf2.EnableBiasRF") &&
  57. SC.GetValue<int>($"{module}.BiasRf2.CommunicationType") == (int)CommunicationType.Ethernet &&
  58. SC.GetValue<int>($"{module}.BiasRf2.MFG") == (int)GeneratorMFG.Comet)
  59. {
  60. device.AddCustomModuleDevice(new CometRF(module, "BiasRf2", SC.GetStringValue($"{module}.BiasRf2.IPAddress")));
  61. }
  62. if (SC.GetValue<bool>($"{module}.BiasRf1.EnableBiasRF") &&
  63. SC.GetValue<int>($"{module}.BiasRf1.CommunicationType") == (int)CommunicationType.RS232 &&
  64. SC.GetValue<int>($"{module}.BiasRf1.MFG") == (int)GeneratorMFG.AdTec)
  65. {
  66. device.AddCustomModuleDevice(new AdTecGenerator(module, "BiasRf1"));
  67. }
  68. if (SC.GetValue<bool>($"{module}.BiasRf2.EnableBiasRF") &&
  69. SC.GetValue<int>($"{module}.BiasRf2.CommunicationType") == (int)CommunicationType.RS232 &&
  70. SC.GetValue<int>($"{module}.BiasRf2.MFG") == (int)GeneratorMFG.AdTec)
  71. {
  72. device.AddCustomModuleDevice(new AdTecGenerator(module, "BiasRf2"));
  73. }
  74. if (SC.GetValue<bool>($"{module}.Chiller1.EnableChiller") &&
  75. SC.GetValue<int>($"{module}.Chiller1.CommunicationType") == (int)CommunicationType.RS232)
  76. {
  77. if (SC.GetValue<int>($"{module}.Chiller1.MFG") == (int)ChillerMFG.SMC)
  78. {
  79. device.AddCustomModuleDevice(new SMCChiller(module, "Chiller1"));
  80. }
  81. else if (SC.GetValue<int>($"{module}.Chiller1.MFG") == (int)ChillerMFG.AIRSYS)
  82. {
  83. device.AddCustomModuleDevice(new AIRSYSChiller(module, "Chiller1"));
  84. }
  85. }
  86. if (SC.GetValue<bool>($"{module}.Chiller2.EnableChiller") &&
  87. SC.GetValue<int>($"{module}.Chiller2.CommunicationType") == (int)CommunicationType.RS232 &&
  88. SC.GetValue<int>($"System.SetUp.ChillerSetupOp.IsInstalled") == (int)ChillerSetupOp.NoShareSingleChiller)
  89. {
  90. if( SC.GetValue<int>($"{module}.Chiller2.MFG") == (int)ChillerMFG.SMC)
  91. {
  92. device.AddCustomModuleDevice(new SMCChiller(module, "Chiller2"));
  93. }
  94. else if (SC.GetValue<int>($"{module}.Chiller2.MFG") == (int)ChillerMFG.AIRSYS)
  95. {
  96. device.AddCustomModuleDevice(new AIRSYSChiller(module, "Chiller2"));
  97. }
  98. }
  99. //srf1 match adtec
  100. if (SC.GetValue<bool>($"{module}.match1.EnableMatch") &&
  101. SC.GetValue<int>($"{module}.match1.CommunicationType") == (int)CommunicationType.RS232 &&
  102. SC.GetValue<int>($"{module}.match1.MFG") == (int)MatchMFG.AdTec)
  103. {
  104. device.AddCustomModuleDevice(new AdTecMatch(module, "match1"));
  105. }
  106. //srf2 match adtec
  107. if (SC.GetValue<bool>($"{module}.match2.EnableMatch") &&
  108. SC.GetValue<int>($"{module}.match2.CommunicationType") == (int)CommunicationType.RS232 &&
  109. SC.GetValue<int>($"{module}.match2.MFG") == (int)MatchMFG.AdTec)
  110. {
  111. device.AddCustomModuleDevice(new AdTecMatch(module, "match2"));
  112. }
  113. //brf1 match adtec
  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. //brf2 match adtec
  121. if (SC.GetValue<bool>($"{module}.BiasRf2Match.EnableMatch") &&
  122. SC.GetValue<int>($"{module}.BiasRf2Match.CommunicationType") == (int)CommunicationType.RS232 &&
  123. SC.GetValue<int>($"{module}.BiasRf2Match.MFG") == (int)MatchMFG.AdTec)
  124. {
  125. device.AddCustomModuleDevice(new AdTecMatch(module, "BiasRf2Match"));
  126. }
  127. //srf1 match revtec
  128. if (SC.GetValue<bool>($"{module}.match1.EnableMatch") &&
  129. SC.GetValue<int>($"{module}.match1.CommunicationType") == (int)CommunicationType.Ethernet &&
  130. SC.GetValue<int>($"{module}.match1.MFG") == (int)MatchMFG.RevTec)
  131. {
  132. device.AddCustomModuleDevice(new RevtechMatch(module, "match1"));
  133. }
  134. //srf2 match revtec
  135. if (SC.GetValue<bool>($"{module}.match2.EnableMatch") &&
  136. SC.GetValue<int>($"{module}.match2.CommunicationType") == (int)CommunicationType.Ethernet &&
  137. SC.GetValue<int>($"{module}.match2.MFG") == (int)MatchMFG.RevTec)
  138. {
  139. device.AddCustomModuleDevice(new RevtechMatch(module, "match2"));
  140. }
  141. //brf1 match revtec
  142. if (SC.GetValue<bool>($"{module}.BiasRf1Match.EnableMatch") &&
  143. SC.GetValue<int>($"{module}.BiasRf1Match.CommunicationType") == (int)CommunicationType.Ethernet &&
  144. SC.GetValue<int>($"{module}.BiasRf1Match.MFG") == (int)MatchMFG.RevTec)
  145. {
  146. device.AddCustomModuleDevice(new RevtechMatch(module, "BiasRf1Match"));
  147. }
  148. //brf2 match revtec
  149. if (SC.GetValue<bool>($"{module}.BiasRf2Match.EnableMatch") &&
  150. SC.GetValue<int>($"{module}.BiasRf2Match.CommunicationType") == (int)CommunicationType.Ethernet &&
  151. SC.GetValue<int>($"{module}.BiasRf2Match.MFG") == (int)MatchMFG.RevTec)
  152. {
  153. device.AddCustomModuleDevice(new RevtechMatch(module, "BiasRf2Match"));
  154. }
  155. if (SC.GetValue<int>($"{module}.DryPump.CommunicationType") == (int)CommunicationType.RS232)
  156. {
  157. if (SC.GetValue<int>($"{module}.DryPump.MFG") == (int)DryPumpMFG.SKY)
  158. {
  159. device.AddCustomModuleDevice(new SkyPump(module, VirgoDevice.MainPump.ToString()));
  160. }
  161. else if (SC.GetValue<int>($"{module}.DryPump.MFG") == (int)DryPumpMFG.Edwards)
  162. {
  163. device.AddCustomModuleDevice(new EdwardsPump(module, VirgoDevice.MainPump.ToString()));
  164. }
  165. }
  166. if (SC.GetValue<bool>($"{module}.EPD.IsEnabled") && SC.GetValue<bool>("System.SetUp.EPD.IsInstalled"))
  167. {
  168. device.AddCustomModuleDevice(new EPDDevice(module.ToString(), "EPD"));
  169. }
  170. device.AddCustomModuleDevice(new JetDualPM(module));
  171. controller.Start(device);
  172. _controller[module] = controller;
  173. _device[module] = device;
  174. }
  175. public void Reset(ModuleName module)
  176. {
  177. _controller[module].Reset();
  178. }
  179. public void Terminate(ModuleName module)
  180. {
  181. _controller[module].Terminate();
  182. }
  183. }
  184. }