SetSpeedRoutine.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. 
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using athosRT.FSM;
  6. using athosRT.tool;
  7. using MECF.Framework.Common.Equipment;
  8. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  9. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
  10. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Diagnostics;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Threading;
  17. using System.Threading.Tasks;
  18. using static MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase.RobotBaseDevice;
  19. namespace athosRT.Modules.Robot
  20. {
  21. public class SetSpeedRoutine : ModuleRoutineBase, FSM.IRoutine
  22. {
  23. public int Speed = 5;
  24. private SCConfigItem _scItemSpeed;
  25. private SCConfigItem _scItemTimeout;
  26. private int _timeout = 5;
  27. private RobotBaseDevice robot;
  28. public SetSpeedRoutine(ModuleName chamber):base(chamber)
  29. {
  30. robot = DEVICE.GetDevice<RobotBaseDevice>("Robot");
  31. _scItemTimeout = SC.GetConfigItem("Robot.TimeLimitRobotHome");
  32. _scItemSpeed = SC.GetConfigItem("Robot.Robot.SpeedLevel");
  33. }
  34. public void Terminate()
  35. {
  36. }
  37. public RState Start(params object[] objs)
  38. {
  39. Reset();
  40. _timeout = _scItemTimeout.IntValue;
  41. //_timeout = _scItemTimeout;
  42. //EV.PostMessage<EventEnum>(ModuleName.Robot.ToString(), EventEnum.GeneralInfo, (object)string.Format("Set robot speed start.{0}", Speed));
  43. Speed = SC.GetValue<int>("Robot.Robot.SpeedLevel");
  44. return Runner.Start(ModuleName.Robot,"SetSpeed");
  45. }
  46. public RState Monitor()
  47. {
  48. LogObject.Info("robot", "home speed set");
  49. Runner
  50. //.Run((int)SetSpeedStep.NoWaferSpeed,NoWaferSpeed, CheckRobotState, _timeout)
  51. //.Wait((int)SetSpeedStep.WaitSetOver, CheckRobotState, _delay_1s)
  52. //.Run((int)SetSpeedStep.WithWaferSpeed,WithWaferSpeed, CheckRobotState, _timeout)
  53. //.Wait((int)SetSpeedStep.WaitSetOver, CheckRobotState, _delay_1s)
  54. // .Run((int)SetSpeedStep.LowSpeed,LowSpeed, CheckRobotState, _timeout)
  55. //.Wait((int)SetSpeedStep.WaitSetOver, CheckRobotState, _delay_1s)
  56. .Run(SetSpeedStep.HomeSpeed,HomeSpeed, CheckRobotState, _timeout)
  57. //.Wait((int)SetSpeedStep.WaitSetOver, CheckRobotState, _delay_1s)
  58. .Run(SetSpeedStep.LowSpeedAreaSpeed, LowSpeedAreaSpeed, CheckRobotState, _timeout)
  59. .End(SetSpeedStep.WaitSetOver, NullFun, CheckRobotState, _delay_1s)
  60. ;
  61. return Runner.Status;
  62. }
  63. private bool CheckRobotState()
  64. {
  65. Trace.WriteLine("Comfirm robot status:"+robot.RobotState);
  66. return robot.IsReady();
  67. }
  68. private bool LowSpeedAreaSpeed() => SetSpeed(SpeedType.B, Speed);
  69. //private bool HomeSpeed() => SetSpeed(SpeedType.O, Speed);
  70. private bool HomeSpeed() => SetRobotSpeed( Speed);
  71. private bool LowSpeed() => SetSpeed(SpeedType.L, Speed);
  72. private bool WithWaferSpeed() => SetSpeed(SpeedType.M, Speed);
  73. private bool NoWaferSpeed() => SetSpeed(SpeedType.H, Speed);
  74. public bool SetSpeed(SpeedType speedtype, int spd)
  75. {
  76. Trace.WriteLine("Comfirm robot status is busy:" + robot.IsBusy);
  77. Trace.WriteLine("Comfirm robot status:" + robot.RobotState);
  78. //robot.PostMsg((int)RobotMsg.SetParameters);
  79. //设置速度
  80. bool flag=robot.SetSpeed(new object[1]
  81. {
  82. spd
  83. });
  84. if (flag)
  85. {
  86. LogObject.Info("robot", "setspeedRoutine成功");
  87. Trace.WriteLine("Comfirm robot status:" + robot.IsBusy);
  88. robot.PostMsg((int)RobotMsg.SetParametersComplete);
  89. return true;
  90. }
  91. else
  92. {
  93. LogObject.Error("robot", "setspeedRoutine失败");
  94. robot.PostMsg((int)RobotMsg.ERROR);
  95. return false;
  96. }
  97. }
  98. public bool SetRobotSpeed(int spd)
  99. {
  100. // robot.IsBusy = false;
  101. //设置速度
  102. bool flag = robot.SetSpeed(new object[1]
  103. {
  104. spd
  105. });
  106. if (flag)
  107. {
  108. LogObject.Info("robot", "setspeedRoutine成功");
  109. Trace.WriteLine("Comfirm robot status:" + robot.IsBusy);
  110. robot.PostMsg((int)RobotMsg.SetParametersComplete);
  111. return true;
  112. }
  113. else
  114. {
  115. LogObject.Error("robot", "setspeedRoutine失败");
  116. robot.PostMsg((int)RobotMsg.ERROR);
  117. return false;
  118. }
  119. }
  120. public void Abort()
  121. {
  122. }
  123. public enum SetSpeedStep
  124. {
  125. NoWaferSpeed,
  126. WithWaferSpeed,
  127. LowSpeed,
  128. HomeSpeed,
  129. LowSpeedAreaSpeed,
  130. WaitSetOver
  131. }
  132. }
  133. }