123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- using System;
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.Routine;
- using Aitex.RT.Properties;
- using Aitex.Triton160.RT.Device;
- namespace Aitex.Triton160.RT.Routine.PM
- {
- public class StopGasFlowRoutine : CommonRoutine
- {
- private enum RoutineStep
- {
- StopGasFlow,
- End,
- };
- public StopGasFlowRoutine(string module, string name)
- {
- Module = module;
- Name = name;
- Display = Resources.StopGasFlowRoutine_StopGasFlowRoutine_StopGasFlow;
- bUINotify = true;
- }
- public bool Initialize()
- {
- InitCommon();
- return true;
- }
- public void Terminate()
- {
- }
- public Result Start(params object[] objs)
- {
- Reset();
- UpdateSCValue();
- return Result.RUN;
- }
- public Result Monitor()
- {
- try
- {
- StopGasFlow((int)RoutineStep.StopGasFlow, Resources.StopGasFlowRoutine_Monitor_CloseValveAndStopMfc, Notify, Stop);
- End((int)RoutineStep.End, Resources.StopGasFlowRoutine_Monitor_StopGasFlowCompleted, Notify, Stop);
- }
- catch (RoutineBreakException)
- {
- return Result.RUN;
- }
- catch (RoutineFaildException)
- {
- return Result.FAIL;
- }
- return Result.DONE;
- }
- public void StopGasFlow(int id, string name, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(name);
- IoValve[] valves = { DeviceModel.ValveMfc1, DeviceModel.ValveMfc2, DeviceModel.ValveMfc3 , DeviceModel.ValveMfc4 , DeviceModel.ValveMfc5 };
- IoMfc[] mfcs = { DeviceModel.MfcGas1, DeviceModel.MfcGas2, DeviceModel.MfcGas3, DeviceModel.MfcGas4, DeviceModel.MfcGas5 };
- string reason = string.Empty;
- for (int i = 0; i < mfcs.Length; i++)
- {
- if (valves[i] != null)
- valves[i].TurnValve(false, out reason);
- if (mfcs[i] != null)
- mfcs[i].Ramp(0, 0);
- }
- if (DeviceModel.ValveProcessGasFinal != null)
- DeviceModel.ValveProcessGasFinal.TurnValve(false, out reason);
-
- return true;
- }, () =>
- {
- return true;
- }, 10 * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- }
- }
|