using Aitex.Core.RT.Device; using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using athosRT.FSM; using athosRT.tool; using MECF.Framework.Common.Equipment; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using static MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase.RobotBaseDevice; namespace athosRT.Modules.Robot { public class SetSpeedRoutine : ModuleRoutineBase, FSM.IRoutine { public int Speed = 5; private SCConfigItem _scItemSpeed; private SCConfigItem _scItemTimeout; private int _timeout = 5; private RobotBaseDevice robot; public SetSpeedRoutine(ModuleName chamber):base(chamber) { robot = DEVICE.GetDevice("Robot"); _scItemTimeout = SC.GetConfigItem("Robot.TimeLimitRobotHome"); _scItemSpeed = SC.GetConfigItem("Robot.Robot.SpeedLevel"); } public void Terminate() { } public RState Start(params object[] objs) { Reset(); _timeout = _scItemTimeout.IntValue; //_timeout = _scItemTimeout; //EV.PostMessage(ModuleName.Robot.ToString(), EventEnum.GeneralInfo, (object)string.Format("Set robot speed start.{0}", Speed)); Speed = SC.GetValue("Robot.Robot.SpeedLevel"); return Runner.Start(ModuleName.Robot,"SetSpeed"); } public RState Monitor() { LogObject.Info("robot", "home speed set"); Runner //.Run((int)SetSpeedStep.NoWaferSpeed,NoWaferSpeed, CheckRobotState, _timeout) //.Wait((int)SetSpeedStep.WaitSetOver, CheckRobotState, _delay_1s) //.Run((int)SetSpeedStep.WithWaferSpeed,WithWaferSpeed, CheckRobotState, _timeout) //.Wait((int)SetSpeedStep.WaitSetOver, CheckRobotState, _delay_1s) // .Run((int)SetSpeedStep.LowSpeed,LowSpeed, CheckRobotState, _timeout) //.Wait((int)SetSpeedStep.WaitSetOver, CheckRobotState, _delay_1s) .Run(SetSpeedStep.HomeSpeed,HomeSpeed, CheckRobotState, _timeout) //.Wait((int)SetSpeedStep.WaitSetOver, CheckRobotState, _delay_1s) .Run(SetSpeedStep.LowSpeedAreaSpeed, LowSpeedAreaSpeed, CheckRobotState, _timeout) .End(SetSpeedStep.WaitSetOver, NullFun, CheckRobotState, _delay_1s) ; return Runner.Status; } private bool CheckRobotState() { Trace.WriteLine("Comfirm robot status:"+robot.RobotState); return robot.IsReady(); } private bool LowSpeedAreaSpeed() => SetSpeed(SpeedType.B, Speed); //private bool HomeSpeed() => SetSpeed(SpeedType.O, Speed); private bool HomeSpeed() => SetRobotSpeed( Speed); private bool LowSpeed() => SetSpeed(SpeedType.L, Speed); private bool WithWaferSpeed() => SetSpeed(SpeedType.M, Speed); private bool NoWaferSpeed() => SetSpeed(SpeedType.H, Speed); public bool SetSpeed(SpeedType speedtype, int spd) { Trace.WriteLine("Comfirm robot status is busy:" + robot.IsBusy); Trace.WriteLine("Comfirm robot status:" + robot.RobotState); //robot.PostMsg((int)RobotMsg.SetParameters); //设置速度 bool flag=robot.SetSpeed(new object[1] { spd }); if (flag) { LogObject.Info("robot", "setspeedRoutine成功"); Trace.WriteLine("Comfirm robot status:" + robot.IsBusy); robot.PostMsg((int)RobotMsg.SetParametersComplete); return true; } else { LogObject.Error("robot", "setspeedRoutine失败"); robot.PostMsg((int)RobotMsg.ERROR); return false; } } public bool SetRobotSpeed(int spd) { // robot.IsBusy = false; //设置速度 bool flag = robot.SetSpeed(new object[1] { spd }); if (flag) { LogObject.Info("robot", "setspeedRoutine成功"); Trace.WriteLine("Comfirm robot status:" + robot.IsBusy); robot.PostMsg((int)RobotMsg.SetParametersComplete); return true; } else { LogObject.Error("robot", "setspeedRoutine失败"); robot.PostMsg((int)RobotMsg.ERROR); return false; } } public void Abort() { } public enum SetSpeedStep { NoWaferSpeed, WithWaferSpeed, LowSpeed, HomeSpeed, LowSpeedAreaSpeed, WaitSetOver } } }