GasFlowRoutine.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using Aitex.Core.Common.DeviceData;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.Routine;
  5. using Aitex.Core.RT.SCCore;
  6. using JetVirgoPM.Devices;
  7. namespace JetVirgoPM.PMs.Routines
  8. {
  9. class GasFlowRoutine : PMRoutineBase, IStepRoutine
  10. {
  11. private enum RoutineStep
  12. {
  13. CheckPressure,
  14. StartFlow,
  15. StopFlow,
  16. CheckStable,
  17. End,
  18. };
  19. public bool _gasStatus = false;
  20. private double _pressureAlarmRange;
  21. private double _pressureAlarmTime;
  22. //private double _gasFlowAlarmRange;
  23. //private double _gasFlowAlarmTime;
  24. private double[] _mfcSetPoint = new double[6];
  25. public GasFlowRoutine(JetDualPM chamber) : base(chamber)
  26. {
  27. Name = "Flow gas";
  28. bUINotify = true;
  29. }
  30. public RState Start(params object[] objs)
  31. {
  32. if (!_chamber.IsFastPumpOpened)
  33. {
  34. StopFlow2();
  35. Stop("Pump 阀没有打开");
  36. return RState.Failed;
  37. }
  38. Reset();
  39. _pressureAlarmRange = SC.GetValue<double>($"{Module}.GasFlowPressureAlarmRange");
  40. _pressureAlarmTime = SC.GetValue<double>($"{Module}.GasFlowPressureAlarmTime");
  41. // open process final valve and flow
  42. Notify("Open valve and flow mfc");
  43. _chamber.OpenValve(ValveType.PURGE, true);
  44. _chamber.OpenValve(ValveType.PROCESS, true);
  45. int i = 0;
  46. foreach (object o in objs)
  47. {
  48. _mfcSetPoint[i++] = (double)o;
  49. }
  50. FlowMfc2((int)RoutineStep.StartFlow, _mfcSetPoint);
  51. _gasStatus = true;
  52. return Runner.Start(_chamber.Module.ToString(), Name);
  53. }
  54. public RState Monitor()
  55. {
  56. if (_chamber.HasGasOutOfRange)
  57. {
  58. Stop("流气率越界");
  59. _gasStatus = false;
  60. return RState.Failed;
  61. }
  62. Runner.End(RoutineStep.End, EndFunc, _delay_50ms);
  63. return Runner.Status;
  64. }
  65. public void FlowMfc2(int id, double[] mfcValues)
  66. {
  67. string reason = string.Empty;
  68. for (int index = 0; index < mfcValues.Length; index++)
  69. {
  70. _chamber.FlowGas(index, mfcValues[index]);
  71. }
  72. }
  73. public void StopFlow2()
  74. {
  75. Notify("Close valve and stop to flow MFC");
  76. _chamber.OpenValve(ValveType.PURGE, false);
  77. _chamber.OpenValve(ValveType.PROCESS, false);
  78. _chamber.StopAllGases();
  79. }
  80. public override void Abort()
  81. {
  82. this.StopFlow2();
  83. _gasStatus = false;
  84. }
  85. }
  86. }