RorzeRobot751MotionHandler.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using Aitex.Core.RT.Event;
  2. using Aitex.Core.RT.Log;
  3. using MECF.Framework.Common.Communications;
  4. namespace athosRT.Modules.Robot
  5. {
  6. public class RorzeRobot751MotionHandler : RorzeRobot751Handler
  7. {
  8. 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";
  9. public RorzeRobot751MotionHandler(RorzeRobot751 robot, string command, string parameter = null)
  10. : base(robot, command, parameter)
  11. {
  12. string text = (string.IsNullOrEmpty(parameter) ? parameter : "");
  13. 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);
  14. }
  15. public override bool HandleMessage(MessageBase msg, out bool transactionComplete)
  16. {
  17. RorzeRobot751Message rorzeRobot751Message = msg as RorzeRobot751Message;
  18. base.ResponseMessage = msg;
  19. LOG.Write(base.Device.Name + " handler message:" + rorzeRobot751Message.RawMessage + " in ASCII.", 2, "D:\\sorter\\trunk\\Efem\\Jet\\Jet_001_2P_Jet\\EfemRT\\Devices\\Rorze751\\RorzeRobot751Handler.cs", "HandleMessage", 162);
  20. if (msg.IsError)
  21. {
  22. base.Device.NoteError(rorzeRobot751Message.RawMessage);
  23. transactionComplete = true;
  24. return true;
  25. }
  26. if (msg.IsAck)
  27. {
  28. SetState(EnumHandlerState.Acked);
  29. }
  30. if (msg.IsComplete)
  31. {
  32. }
  33. if (rorzeRobot751Message.IsEvent)
  34. {
  35. if (_command == "ORGN" && rorzeRobot751Message.RawMessage.Contains("STAT") && base.Device.IsOrgshCompleted && base.Device.CurrentOpStatus == RROpStatusEnum.Stop)
  36. {
  37. base.Device.OnActionDone(null);
  38. transactionComplete = true;
  39. return true;
  40. }
  41. if (_command == "INIT" && rorzeRobot751Message.RawMessage.Contains("STAT") && base.Device.CurrentOpMode != 0)
  42. {
  43. base.Device.OnActionDone(null);
  44. transactionComplete = true;
  45. return true;
  46. }
  47. if (_motionCmd.Contains(_command))
  48. {
  49. if (rorzeRobot751Message.RawMessage.Contains("STAT") && !base.Device.IsOrgshCompleted)
  50. {
  51. base.Device.OnError("GetErrorMsg:" + rorzeRobot751Message.RawMessage + " on command:" + _command);
  52. transactionComplete = true;
  53. return true;
  54. }
  55. if (rorzeRobot751Message.RawMessage.Contains("STAT") && base.Device.CurrentOpStatus == RROpStatusEnum.Stop)
  56. {
  57. if (base.Device.CurrentIdCodeForErrorController != "00")
  58. {
  59. EV.PostAlarmLog("Robot", "occurred error:GetErrorMsg:" + rorzeRobot751Message.RawMessage + " on command:" + _command);
  60. }
  61. base.Device.OnActionDone(null);
  62. transactionComplete = true;
  63. return true;
  64. }
  65. }
  66. }
  67. transactionComplete = false;
  68. return false;
  69. }
  70. }
  71. }