def recv(self): """ recv: receieve message from GameReg, the value is the result of imageReg and the processed image :return: True or False """ msg_buff_ret = None LOG.debug( "begin receive the message from gamereg, __game_reg_addr is {0} ". format(self.__game_reg_addr)) msg_buff = tbus.RecvFrom(self.__game_reg_addr) while msg_buff is not None: msg_buff_ret = msg_buff msg_buff = tbus.RecvFrom(self.__game_reg_addr) if msg_buff_ret: LOG.debug("receive the message from gamereg") # msg = msgpack.unpackb(msgBuffRet, object_hook=mn.decode, encoding='utf-8') msg = self._unserial_result_msg(msg_buff_ret) if msg: frame_seq = msg['value'].get('frameSeq') LOG.debug('recv frame data, frameIndex={0}'.format(frame_seq)) return msg else: LOG.error("unserial result message failed") return None return None
def Recv(self): """ Recv: receieve message from GameReg, the value is the result of imageReg and the processed image :return: True or False """ msgBuffRet = None msgBuff = tbus.RecvFrom(self.__gameRegAddr) while msgBuff is not None: msgBuffRet = msgBuff msgBuff = tbus.RecvFrom(self.__gameRegAddr) if msgBuffRet is not None: # msg = msgpack.unpackb(msgBuffRet, object_hook=mn.decode, encoding='utf-8') msg = self._UnSerialResultMsg(msgBuffRet) frameSeq = msg['value'].get('frameSeq') img_data = msg['value'].get('image') if img_data is not None: h, w = img_data.shape[:2] result = msg['value'].get('result') if result: LOG.debug( 'recv frame data, frameIndex=%s, h:%s, w:%s, result:%s', frameSeq, h, w, str(result)) return msg return None
def recv_agent(self): result_buff = None if self.__agent_addr is None: return result_buff buff = tbus.RecvFrom(self.__agent_addr) while buff is not None: result_buff = buff buff = tbus.RecvFrom(self.__agent_addr) if result_buff is not None: return self._unserial_agent_msg(result_buff)
def RecvUI(self): msgBuffRet = None msgBuff = tbus.RecvFrom(self.__UIRecognizeAddr) while msgBuff is not None: msgBuffRet = msgBuff msgBuff = tbus.RecvFrom(self.__UIRecognizeAddr) if msgBuffRet is not None: # msg = msgpack.unpackb(msgBuffRet, object_hook=mn.decode, encoding='utf-8') return self._UnSerialUIResultMsg(msgBuffRet) else: return None
def RecvMsg(self): """ Recv Msgs from MC """ msgBuffList = [] msgBuff = tbus.RecvFrom(self.__MCAddr) while msgBuff is not None: msgBuffList.append(msgBuff) # LOG.debug('Recv {0} bytes from MC'.format(len(msgBuff))) msgBuff = tbus.RecvFrom(self.__MCAddr) return msgBuffList
def recv_ui(self): msg_buff_ret = None msg_buff = tbus.RecvFrom(self.__uirecognize_addr) while msg_buff is not None: msg_buff_ret = msg_buff msg_buff = tbus.RecvFrom(self.__uirecognize_addr) if msg_buff_ret: LOG.debug("receive the message from UI") # msg = msgpack.unpackb(msgBuffRet, object_hook=mn.decode, encoding='utf-8') msg = self._unserial_ui_result_msg(msg_buff_ret) if msg: return msg else: LOG.error("unserial result message failed") return None return None
def RecvMsg(self): msgBuff = tbus.RecvFrom(self.__mcAddr) if msgBuff is not None: msg = common_pb2.tagMessage() msg.ParseFromString(msgBuff) #msg = msgpack.unpackb(msgBuff, encoding='utf-8') return msg return None
def RecvMsg(self): """ Recv Msgs from all connected addrs """ msgBuffList = [] for addr in self.__recvAddrsSet: msgBuff = tbus.RecvFrom(addr) if msgBuff is not None: msgBuffList.append((addr, msgBuff)) for addr in self.__recvAgentAddrsSet: msgBuff = tbus.RecvFrom(addr) while msgBuff is not None: msgBuffList.append((addr, msgBuff)) msgBuff = tbus.RecvFrom(addr) return msgBuffList
def RecvMsg(self): """ Recive and unserialize msg from MC channel """ msgBuff = tbus.RecvFrom(self.__mcAddr) if msgBuff is not None: msg = common_pb2.tagMessage() msg.ParseFromString(msgBuff) #msg = msgpack.unpackb(msgBuff, encoding='utf-8') return msg return None
def Recv(self): """ Recv: receieve message from GameReg, the value is the result of imageReg and the processed image :return: True or False """ msgBuffRet = None msgBuff = tbus.RecvFrom(self.__gameRegAddr) while msgBuff is not None: msgBuffRet = msgBuff msgBuff = tbus.RecvFrom(self.__gameRegAddr) if msgBuffRet is not None: # msg = msgpack.unpackb(msgBuffRet, object_hook=mn.decode, encoding='utf-8') msg = self._UnSerialResultMsg(msgBuffRet) frameSeq = msg['value'].get('frameSeq') LOG.debug('recv frame data, frameIndex={0}'.format(frameSeq)) return msg else: return None
def RecvMsg(self, peerNode): """ Recive and unserialize msg from MC channel """ peerNodeAddr = self._GetPeerNodeAddr(peerNode) if peerNodeAddr is None: self.__logger.error( 'Recv error: peer node {} address is None!'.format(peerNode)) return None self.__logger.debug( "receive the message from the address:{}".format(peerNodeAddr)) msgBuff = tbus.RecvFrom(peerNodeAddr) if msgBuff is not None: msg = common_pb2.tagMessage() msg.ParseFromString(msgBuff) #msg = msgpack.unpackb(msgBuff, encoding='utf-8') return msg return None