123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- using System;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
- namespace EFEM.RT.Routines
- {
- public class SetSpeedRoutine : CommonRoutine, IRoutine
- {
- enum Set
- {
- H, //No-wafer transfer speed,
- M, //With-wafer transfer speed
- L, //Low speed
- O, //Home speed
- B, //Speed in low-speed-area
- }
- public int Speed = 5;
- private SCConfigItem _scItemSpeed;
- private SCConfigItem _scItemTimeout;
- private int _timeout = 5;
- public SetSpeedRoutine(string module, string name)
- {
- }
- public bool Initalize()
- {
- _scItemTimeout = SC.GetConfigItem(SorterCommon.ScPathName.Robot_TimeLimitRobotHome);
- _scItemSpeed = SC.GetConfigItem(SorterCommon.ScPathName.Robot_RobotSpeed);
- return true;
- }
- public void Terminate()
- {
-
- }
- public Result Start(params object[] objs)
- {
- Reset();
- _timeout = _scItemTimeout.IntValue;
- EV.PostMessage(ModuleName.Robot.ToString(), EventEnum.GeneralInfo, string.Format("Set robot speed start.{0}",Speed));
- Speed = SC.GetValue<int>(SorterCommon.ScPathName.Robot_RobotSpeed);
- return Result.RUN;
- }
-
- public Result Monitor()
- {
- try
- {
- SetSpeed((int)Set.H, "Set No-wafer transfer speed", SpeedType.H, Speed, _timeout, Notify, Stop);
- SetSpeed((int)Set.M, "Set With-wafer transfer speed", SpeedType.M, Speed, _timeout, Notify, Stop);
- SetSpeed((int)Set.L, "Set Low speed", SpeedType.L, Speed, _timeout, Notify, Stop);
- SetSpeed((int)Set.O, "Set Home speed", SpeedType.O, Speed, _timeout, Notify, Stop);
- SetSpeed((int)Set.B, "Set Speed in low-speed-area", SpeedType.B, Speed, _timeout, Notify, Stop);
- }
- catch (RoutineBreakException)
- {
- return Result.RUN;
- }
- catch (RoutineFaildException)
- {
- return Result.FAIL;
- }
- EV.PostMessage(ModuleName.Robot.ToString(), EventEnum.GeneralInfo, "Set speed end");
-
- return Result.DONE;
- }
- public new void Abort()
- {
- }
- protected void SetSpeed(int id, string name, SpeedType type, int speed, int time, Action<string> notify, Action<string> error)
- {
- Tuple<bool, Result> ret = ExecuteAndWait(id, () =>
- {
- notify(name);
- string reason = string.Empty;
- robot.SetSpeed(new object[] {type.ToString(),speed });
- return true;
- }, () =>
- {
- if (robot.RobotState == RobotStateEnum.Idle)
- {
- return true;
- }
- return false;
- }, time * 1000);
- if (ret.Item1)
- {
- if (ret.Item2 == Result.FAIL)
- {
- throw (new RoutineFaildException());
- }
- else if (ret.Item2 == Result.TIMEOUT) //timeout
- {
- error(String.Format("set speed timeout, than {0} seconds", time));
- throw (new RoutineFaildException());
- }
- else
- throw (new RoutineBreakException());
- }
- }
- protected override void Notify(string message)
- {
- EV.PostMessage(Module, EventEnum.GeneralInfo, String.Format("Set Speed :{0}", message));
- }
- /// <summary>
- /// prepare process failed
- /// </summary>
- /// <param name="failReason"></param>
- /// <param name="reactor"></param>
- protected override void Stop(string failReason)
- {
- string reason = String.Empty;
- EV.PostMessage(Module, EventEnum.DefaultWarning, string.Format("Set speed failed:{0}", failReason));
- }
- }
- }
|