TotalReservoirDevice.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.Util;
  3. using MECF.Framework.Common.CommonData;
  4. using MECF.Framework.Common.ToolLayout;
  5. using MECF.Framework.Common.TwinCat;
  6. using PunkHPX8_RT.Modules;
  7. using PunkHPX8_RT.Modules.Reservoir;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Reflection;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. namespace PunkHPX8_RT.Devices.Reservoir
  15. {
  16. public class TotalReservoirDevice : BaseDevice, IDevice
  17. {
  18. #region 常量
  19. #endregion
  20. #region 内部变量
  21. /// <summary>
  22. /// 定时器
  23. /// </summary>
  24. private PeriodicJob _period;
  25. #endregion
  26. #region 属性
  27. #endregion
  28. /// <summary>
  29. /// 构造函数
  30. /// </summary>
  31. /// <param name="moduleName"></param>
  32. /// <param name="name"></param>
  33. public TotalReservoirDevice() : base("Reservoir", "Reservoir", "Reservoir", "Reservoir")
  34. {
  35. _period = new PeriodicJob(500, OnTimer, "Reservoir.OnTimer", true, true);
  36. }
  37. /// <summary>
  38. /// 初始化
  39. /// </summary>
  40. /// <returns></returns>
  41. public bool Initialize()
  42. {
  43. return true;
  44. }
  45. /// <summary>
  46. /// 定时器
  47. /// </summary>
  48. /// <returns></returns>
  49. private bool OnTimer()
  50. {
  51. List<string> reservoirs = ReservoirItemManager.Instance.InstalledModules;
  52. foreach (string module in reservoirs)
  53. {
  54. ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(module);
  55. ReservoirEntity reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(module);
  56. if (reservoirEntity != null)
  57. {
  58. if (reservoirItem.SubType == "DM")
  59. {
  60. DMReservoirDevice reservoirDevice = DEVICE.GetDevice<DMReservoirDevice>(module);
  61. if (!reservoirEntity.IsInitialized || reservoirDevice.IsDIReplenMaxTimeOut
  62. || reservoirDevice.IsDireplenOn || reservoirDevice.IsDIReplenPerfillTimeOut)
  63. {
  64. continue;
  65. }
  66. if (reservoirDevice.CANeedDiReplen && !reservoirDevice.IsDireplenOn)
  67. {
  68. reservoirDevice.AutoCADiReplen();
  69. }
  70. }
  71. }
  72. }
  73. return true;
  74. }
  75. public void Monitor()
  76. {
  77. }
  78. public void Reset()
  79. {
  80. }
  81. public void Terminate()
  82. {
  83. _period.Stop(false);
  84. }
  85. }
  86. }