DeviceManager.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System;
  2. using System.IO;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Core.RT.OperationCenter;
  5. using Aitex.Core.RT.SCCore;
  6. using MECF.Framework.Common.Equipment;
  7. using SorterRT.Modules;
  8. using Virgo_DRT.Devices;
  9. namespace Virgo_DRT.Instances
  10. {
  11. public class DeviceEntity : DeviceEntityT<DeviceManager>
  12. {
  13. public DeviceEntity()
  14. {
  15. }
  16. }
  17. public class DeviceManager : DeviceManagerBase
  18. {
  19. private readonly string device_model_file;
  20. public DeviceManager()
  21. {
  22. device_model_file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config\\", RtInstance.DeviceModelFileName);
  23. }
  24. public override bool Initialize()
  25. {
  26. if (SC.GetValue<bool>("System.PMAIsInstalled"))
  27. InitPM(ModuleName.PMA);
  28. if (SC.GetValue<bool>("System.PMBIsInstalled"))
  29. InitPM(ModuleName.PMB);
  30. OP.Subscribe("DeviceOperation", this.Invoke);
  31. return true;
  32. }
  33. private void InitPM(ModuleName mod)
  34. {
  35. Initialize(device_model_file, RtInstance.SystemName, mod, mod.ToString());
  36. if (SC.GetValue<int>($"{mod}.Rf.CommunicationType") == (int)CommunicationType.RS232 &&
  37. SC.GetValue<int>($"{mod}.Rf.MFG") == (int)GeneratorMFG.AdTec)
  38. {
  39. AddCustomModuleDevice(new AdTecGenerator(mod));
  40. }
  41. if (SC.GetValue<bool>($"{mod}.match.EnableMatch") &&
  42. SC.GetValue<int>($"{mod}.match.CommunicationType") == (int)CommunicationType.RS232 &&
  43. SC.GetValue<int>($"{mod}.match.MFG") == (int)MatchMFG.AdTec)
  44. {
  45. AddCustomModuleDevice(new AdTecMatch(mod));
  46. }
  47. if (SC.GetValue<int>($"{mod}.DryPump.CommunicationType") == (int)CommunicationType.RS232)
  48. {
  49. if (SC.GetValue<int>($"{mod}.DryPump.MFG") == (int)DryPumpMFG.SKY)
  50. {
  51. AddCustomModuleDevice(new SkyPump(mod));
  52. }
  53. else if (SC.GetValue<int>($"{mod}.DryPump.MFG") == (int)DryPumpMFG.Edwards)
  54. {
  55. AddCustomModuleDevice(new EdwardsPump(mod));
  56. }
  57. }
  58. AddCustomDevice(new JetPM(mod));
  59. }
  60. private bool Invoke(string arg1, object[] args)
  61. {
  62. string name = (string)args[0];
  63. string func = (string)args[1];
  64. object[] param = new object[args.Length - 2];
  65. for (int i = 2; i < args.Length; i++)
  66. param[i - 2] = args[i].ToString();
  67. DEVICE.Do(string.Format("{0}.{1}", name, func), 0, true, param);
  68. return true;
  69. }
  70. }
  71. }