Beispiel #1
0
 def __init__(self):
     super(proto_login, self).__init__
     self.phead = mthead.proto_head(_type=PKTTYPE_LOGIN_ROBOT)
     self.cct = proto_uint32(0x100 << 6)
     self.access = proto_uint32(0)
     self.ori = proto_binary()
     self.enc = proto_binary()
Beispiel #2
0
 def on_recvdata(self, data, cb):
     head = mthead.proto_head()
     head.build(data, 0)
     self.__timestamp = int(round(time.time() * 1000))
     if head.type.value is agvinfoproto.kAgvInfoProto_heart_beat:
         self.__on_keepalive(head)
     if head.type.value is agvinfoproto.kAgvInfoProto_get_agvinfo:
         self.__on_getagvinfo(head)
     if head.type.value is agvinfoproto.kAgvInfoProto_set_agvinfo:
         self.__on_setagvinfo(data)
Beispiel #3
0
    def notify_all(self):
        tcp_list = []
        # Reduce lock occupancy time
        self.__map_mutex.acquire()
        for link in self.__map_tcp_session:
            if None != self.__map_tcp_session[link]:
                tcp_list.append(self.__map_tcp_session[link])
        self.__map_mutex.release()

        ack = mthead.proto_head(_id=0,
                                _type=agvinfoproto.kAgvInfoProto_update_notify,
                                _size=24)
        for tcp_object in tcp_list:
            ack.id(getPktId())
            tcp_object.send(ack.serialize(), ack.length())
Beispiel #4
0
 def __init__(self):
     super(proto_discover_mt, self).__init__()
     self.phead = mthead.proto_head(_type=PKTTYPE_KEEPALIVE_UDP)
     self.address = str('\x00' * 16)
     self.port = proto_uint16(0)
Beispiel #5
0
 def __init__(self):
     super(proto_pre_login, self).__init__()
     self.phead = mthead.proto_head()
     self.key = proto_binary()
Beispiel #6
0
 def __init__(self):
     super(proto_common_vct, self).__init__()
     self.phead = mthead.proto_head(_type=PKTTYPE_COMMON_READ_BYID_ACK)
     self.items = proto_vector(TYPE=proto_common)
Beispiel #7
0
 def __keepalive(self) -> int:
     heartbeat = mthead.proto_head(
         _id=getPktId(),
         _type=agvinfoproto.kAgvInfoProto_heart_beat,
         _size=24)
     return self.send(heartbeat.serialize(), heartbeat.length())
Beispiel #8
0
 def __on_keepalive(self, _head):
     ack = mthead.proto_head(
         _id=_head.id,
         _type=agvinfoproto.kAgvInfoProto_heart_beat_ack,
         _size=24)
     self.send(ack.serialize(), ack.length())
Beispiel #9
0
 def __init__(self):
     super(proto_common_write, self).__init__()
     self.phead = mthead.proto_head(_type=PKTTYPE_COMMON_WRITE_BYID)
     self.items = proto_vector(TYPE=proto_common_write_item)
Beispiel #10
0
 def __init__(self):
     super(proto_req_agvinfo,self).__init__()
     self.head = mthead.proto_head()
     self.method = serialize.proto_uint8(0)
     self.info = serialize.proto_vector(proto_agvinfo)