123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
-
- 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<RobotBaseDevice>("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<EventEnum>(ModuleName.Robot.ToString(), EventEnum.GeneralInfo, (object)string.Format("Set robot speed start.{0}", Speed));
- Speed = SC.GetValue<int>("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
- }
- }
- }
|