| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 | 
							- using Aitex.Core.RT.Routine;
 
- using Aitex.Core.RT.SCCore;
 
- using MECF.Framework.Common.Equipment;
 
- using FurnaceRT.Equipments.PMs;
 
- using System;
 
- using FurnaceRT.Equipments.PMs.Routines;
 
- namespace FurnaceRT.Modules.PMs
 
- {
 
-     public class PMHomeRoutine : PMBaseRoutine
 
-     {
 
-         enum RoutineStep
 
-         {
 
-             CheckInterlock,
 
-             SetMainPowerOn,
 
-             WaitHomeFinished,
 
-         }
 
-         private int _timeout;
 
-         public PMHomeRoutine(ModuleName module, PMModule pm) : base(module, pm)
 
-         {
 
-             Module = module.ToString();
 
-             Name = "Home";
 
-         }
 
-         public Result Init()
 
-         {
 
-             return Result.DONE;
 
-         }
 
-         public override Result Start(params object[] objs)
 
-         {
 
-             Reset();
 
-             _timeout = SC.GetValue<int>($"{Module}.HomeTimeout");
 
-             Notify("Start");
 
-             return Result.RUN;
 
-         }
 
-         public override Result Monitor()
 
-         {
 
-             try
 
-             {
 
-                 //if (PMDevice != null && PMDevice.IsInstalled)
 
-                 {
 
-                     //CheckInterlock((int)RoutineStep.CheckInterlock, PMModule as PMModule, _timeout);
 
-                     //SetMainPowerOn((int)RoutineStep.SetMainPowerOn, PMModule as PMModule, _timeout);
 
-                     //SetMainPowerOn((int)RoutineStep.SetMainPowerOn, PMDevice as FurnacePM, _timeout);
 
-                     //WaitHomeFinished((int)RoutineStep.WaitHomeFinished, PMModule as PMModule, _timeout);
 
-                 }
 
-             }
 
-             catch (RoutineBreakException)
 
-             {
 
-                 return Result.RUN;
 
-             }
 
-             catch (RoutineFaildException)
 
-             {
 
-                 return Result.FAIL;
 
-             }
 
-             Notify("Finished");
 
-             return Result.DONE;
 
-         }
 
-         public override void Abort()
 
-         {
 
-         }
 
-         public void CheckInterlock(int id, PMModule pm, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = Execute(id, () =>
 
-             {
 
-                 Notify($"Run {pm.Name} home");
 
-                // pm.Home(out _);
 
-                 return true;
 
-             } );
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     Stop($"{pm.Name} error");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         public void SetMainPowerOn(int id, PMModule pm, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = Execute(id, () =>
 
-                 {
 
-                     Notify($"Set {pm.Name} main power on");
 
-                     //if (!pm.MainChiller.SetMainPowerOnOff(true, out string reason))
 
-                     //{
 
-                     //    Stop(reason);
 
-                     //    return false;
 
-                     //}
 
-                     //if (!pm.MainPump.SetMainPowerOnOff(true, out reason))
 
-                     //{
 
-                     //    Stop(reason);
 
-                     //    return false;
 
-                     //}
 
-                     return true;
 
-                 } );
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     Stop($"{pm.Name} error");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-         public void WaitHomeFinished(int id, PMModule pm, int timeout)
 
-         {
 
-             Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
 
-             {
 
-                 Notify($"Wait chiller is running");
 
-  
 
-                 return true;
 
-             }, () =>
 
-             {
 
-                 return true/*pm.MainChiller.IsRunning*/;
 
-             }, timeout * 1000);
 
-             if (ret.Item1)
 
-             {
 
-                 if (ret.Item2 == Result.FAIL)
 
-                 {
 
-                     Stop($"{pm.Name} error");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else if (ret.Item2 == Result.TIMEOUT) //timeout
 
-                 {
 
-                     Stop($"timeout, over {timeout} seconds");
 
-                     throw (new RoutineFaildException());
 
-                 }
 
-                 else
 
-                     throw (new RoutineBreakException());
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |