RorzeRobot751MotionHandler.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Aitex.Core.RT.Event;
  2. using Aitex.Core.RT.Log;
  3. using athosRT.tool;
  4. using MECF.Framework.Common.Communications;
  5. using EV = Aitex.Core.RT.Event.EV;
  6. namespace athosRT.Modules.Robot
  7. {
  8. public class RorzeRobot751MotionHandler : RorzeRobot751Handler
  9. {
  10. private string _motionCmd = "HOME,EXTD,LOAD, UNLD,TRNS, EXCH,CLMP, UCLM,WMAP, UTRN,MGET, MPUT,MGT1, MGT2,MPT1, MPT2,WCHK, ALEX,ALLD, ALUL,ALGT, ALEA,ALMV,STEP,GCHK";
  11. public RorzeRobot751MotionHandler(RorzeRobot751 robot, string command, string parameter = null)
  12. : base(robot, command, parameter)
  13. {
  14. string text = (string.IsNullOrEmpty(parameter) ? parameter : "");
  15. LOG.Write(robot.Name + " execute motion command " + command + " " + text + " in ASCII.", 2, "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Devices\\Rorze751\\RorzeRobot751Handler.cs", ".ctor", 152);
  16. }
  17. public override bool HandleMessage(MessageBase msg, out bool transactionComplete)
  18. {
  19. RorzeRobot751Message rorzeRobot751Message = msg as RorzeRobot751Message;
  20. base.ResponseMessage = msg;
  21. LogObject.Info("Robot", $"Robot Handle Message: {rorzeRobot751Message.RawMessage}" + $"{(rorzeRobot751Message.IsError ? $",Error:{rorzeRobot751Message.ErrorCode}" : "")}");
  22. if (msg.IsError)
  23. {
  24. base.Device.NoteError(rorzeRobot751Message.RawMessage);
  25. transactionComplete = true;
  26. return true;
  27. }
  28. if (msg.IsAck)
  29. {
  30. SetState(EnumHandlerState.Acked);
  31. }
  32. if (msg.IsComplete)
  33. {
  34. }
  35. if (rorzeRobot751Message.IsEvent)
  36. {
  37. if (_command == "ORGN" && rorzeRobot751Message.RawMessage.Contains("STAT") && base.Device.IsOrgshCompleted && base.Device.CurrentOpStatus == RROpStatusEnum.Stop)
  38. {
  39. base.Device.OnActionDone(null);
  40. transactionComplete = true;
  41. return true;
  42. }
  43. if (_command == "INIT" && rorzeRobot751Message.RawMessage.Contains("STAT") && base.Device.CurrentOpMode != 0)
  44. {
  45. base.Device.OnActionDone(null);
  46. transactionComplete = true;
  47. return true;
  48. }
  49. if (_motionCmd.Contains(_command))
  50. {
  51. if (rorzeRobot751Message.RawMessage.Contains("STAT") && !base.Device.IsOrgshCompleted)
  52. {
  53. base.Device.OnError("GetErrorMsg:" + rorzeRobot751Message.RawMessage + " on command:" + _command);
  54. transactionComplete = true;
  55. return true;
  56. }
  57. if (rorzeRobot751Message.RawMessage.Contains("STAT") && base.Device.CurrentOpStatus == RROpStatusEnum.Stop)
  58. {
  59. if (base.Device.CurrentIdCodeForErrorController != "00")
  60. {
  61. EV.PostAlarmLog("Robot", "occurred error:GetErrorMsg:" + rorzeRobot751Message.RawMessage + " on command:" + _command);
  62. }
  63. base.Device.OnActionDone(null);
  64. transactionComplete = true;
  65. return true;
  66. }
  67. }
  68. }
  69. transactionComplete = false;
  70. return false;
  71. }
  72. }
  73. }