using Aitex.Core.RT.Event; using Aitex.Core.RT.Log; using athosRT.tool; using MECF.Framework.Common.Communications; using EV = Aitex.Core.RT.Event.EV; namespace athosRT.Modules.Robot { public class RorzeRobot751MotionHandler : RorzeRobot751Handler { 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"; public RorzeRobot751MotionHandler(RorzeRobot751 robot, string command, string parameter = null) : base(robot, command, parameter) { string text = (string.IsNullOrEmpty(parameter) ? parameter : ""); 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); } public override bool HandleMessage(MessageBase msg, out bool transactionComplete) { RorzeRobot751Message rorzeRobot751Message = msg as RorzeRobot751Message; base.ResponseMessage = msg; LogObject.Info("Robot", $"Robot Handle Message: {rorzeRobot751Message.RawMessage}" + $"{(rorzeRobot751Message.IsError ? $",Error:{rorzeRobot751Message.ErrorCode}" : "")}"); if (msg.IsError) { base.Device.NoteError(rorzeRobot751Message.RawMessage); transactionComplete = true; return true; } if (msg.IsAck) { SetState(EnumHandlerState.Acked); } if (msg.IsComplete) { } if (rorzeRobot751Message.IsEvent) { if (_command == "ORGN" && rorzeRobot751Message.RawMessage.Contains("STAT") && base.Device.IsOrgshCompleted && base.Device.CurrentOpStatus == RROpStatusEnum.Stop) { base.Device.OnActionDone(null); transactionComplete = true; return true; } if (_command == "INIT" && rorzeRobot751Message.RawMessage.Contains("STAT") && base.Device.CurrentOpMode != 0) { base.Device.OnActionDone(null); transactionComplete = true; return true; } if (_motionCmd.Contains(_command)) { if (rorzeRobot751Message.RawMessage.Contains("STAT") && !base.Device.IsOrgshCompleted) { base.Device.OnError("GetErrorMsg:" + rorzeRobot751Message.RawMessage + " on command:" + _command); transactionComplete = true; return true; } if (rorzeRobot751Message.RawMessage.Contains("STAT") && base.Device.CurrentOpStatus == RROpStatusEnum.Stop) { if (base.Device.CurrentIdCodeForErrorController != "00") { EV.PostAlarmLog("Robot", "occurred error:GetErrorMsg:" + rorzeRobot751Message.RawMessage + " on command:" + _command); } base.Device.OnActionDone(null); transactionComplete = true; return true; } } } transactionComplete = false; return false; } } }