RfPowerRoutine.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using System;
  2. using Aitex.Core.RT.Device.Unit;
  3. using Aitex.Core.RT.Event;
  4. using Aitex.Core.RT.Log;
  5. using Aitex.Core.RT.Routine;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.RT.Properties;
  8. using Aitex.Triton160.Common;
  9. using Aitex.Triton160.RT.Device;
  10. namespace Aitex.Triton160.RT.Routine.PM
  11. {
  12. public class RfPowerRoutine : CommonRoutine
  13. {
  14. private enum RoutineStep
  15. {
  16. RFPowerOn,
  17. End,
  18. };
  19. private double _rfAlarmRange;
  20. private double _rfAlarmTime;
  21. private double _rfPowerOnTime;
  22. public RfPowerRoutine(string module, string name)
  23. {
  24. Module = module;
  25. Name = name;
  26. Display = name;
  27. bUINotify = true;
  28. }
  29. public bool Initialize()
  30. {
  31. InitCommon();
  32. return true;
  33. }
  34. public void Terminate()
  35. {
  36. }
  37. public Result Start(params object[] objs)
  38. {
  39. if (!DeviceModel.ValveChamberPumping.Status )
  40. {
  41. EV.PostMessage(ModuleNameString.System, EventEnum.GeneralInfo, string.Format(Resources.GasFlowRoutine_Start_PumpingValveNotOpenOpenPumpValveFirst));
  42. return Result.FAIL;
  43. }
  44. bool isGasFlowing = !(
  45. (DeviceModel.ValveProcessGasFinal!= null && !DeviceModel.ValveProcessGasFinal.Status));
  46. if (isGasFlowing)
  47. {
  48. IoValve[] valves ={ DeviceModel.ValveMfc1, DeviceModel.ValveMfc2, DeviceModel.ValveMfc3 , DeviceModel.ValveMfc4 , DeviceModel.ValveMfc5 };
  49. if (!Array.Exists(valves, v =>v!=null && v.Status))
  50. isGasFlowing = false;
  51. IoMfc[] mfcs =
  52. {
  53. DeviceModel.MfcGas1, DeviceModel.MfcGas2, DeviceModel.MfcGas3, DeviceModel.MfcGas4,
  54. DeviceModel.MfcGas5
  55. };
  56. if (!Array.Exists(mfcs, m =>m!=null && m.FeedBack > 0.1))
  57. isGasFlowing = false;
  58. }
  59. if (!isGasFlowing)
  60. {
  61. EV.PostMessage(ModuleNameString.System, EventEnum.GeneralInfo, string.Format("No gas flowing for RF power on"));
  62. return Result.FAIL;
  63. }
  64. Reset();
  65. UpdateSCValue();
  66. _rfPowerOnTime = Convert.ToDouble(objs[0]);
  67. _rfAlarmRange = SC.GetValue<double>(SCName.System_RfPowerAlarmRange);
  68. _rfAlarmTime = SC.GetValue<double>(SCName.System_RfPowerAlarmTime);
  69. return Result.RUN;
  70. }
  71. public Result Monitor()
  72. {
  73. try
  74. {
  75. RFPowerOn((int)RoutineStep.RFPowerOn, Resources.RfPowerRoutine_Monitor_RFPowerOn, (int)_rfPowerOnTime, (float)_rfAlarmRange, (float)_rfAlarmTime, Notify, Stop);
  76. End((int)RoutineStep.End, Resources.RfPowerRoutine_Monitor_RfPowerCompleted, Notify, Stop);
  77. }
  78. catch (RoutineBreakException)
  79. {
  80. return Result.RUN;
  81. }
  82. catch (RoutineFaildException)
  83. {
  84. return Result.FAIL;
  85. }
  86. return Result.DONE;
  87. }
  88. public void AbortRf()
  89. {
  90. try
  91. {
  92. string reason = string.Empty;
  93. if (DeviceModel.Rf!= null && !DeviceModel.Rf.SetPowerOnOff(false, out reason))
  94. {
  95. LOG.Error(reason + Resources.RfPowerRoutine_AbortRf_StopRFError);
  96. }
  97. }
  98. catch (Exception ex)
  99. {
  100. LOG.Write(ex);
  101. }
  102. }
  103. }
  104. }