Ejemplo n.º 1
0
    def handle(self):
        #client = self.request
        sock = SimpleMessageSocket(self.request)
        address = self.client_address[0]
        print('connected with {}'.format(address))
        ctl = RobotController()
        motion_thread = MotionThread(ctl)
        motion_thread.start()

        msg_handlers = {
            SimpleMessageType.JOINT_TRAJ_PT: self.on_joint_traj_pt,
            SimpleMessageType.EXECUTE_PROGRAM: self.on_execute_program
        }

        try:
            while True:
                recv_msg = sock.recv()

                msg_handler = msg_handlers.get(recv_msg.msg_type,
                                               self.on_unkown_message)

                reply_msg = msg_handler(ctl, recv_msg, motion_thread)
                sock.send(reply_msg)
        finally:
            ctl.close()
Ejemplo n.º 2
0
    def handle(self):
        #client = self.request
        sock = SimpleMessageSocket(self.request)
        address = self.client_address[0]
        print('connected from {}'.format(address))
        ctl = RobotController()

        msg_handlers = {
            SimpleMessageType.SET_IO: self.on_set_io,
            SimpleMessageType.SET_POSTURE: self.on_set_posture,
            SimpleMessageType.GET_POSTURE: self.on_get_posture,
            SimpleMessageType.SYS_STAT: self.on_sys_stat,
            SimpleMessageType.SET_TOOL_OFFSET: self.on_set_tool_offset
        }

        try:
            while True:
                recv_msg = sock.recv()

                msg_handler = msg_handlers.get(recv_msg.msg_type,
                                               self.on_unkown_message)

                reply_msg = msg_handler(ctl, recv_msg)
                sock.send(reply_msg)
        finally:
            ctl.close()