当前位置: 首页>>代码示例>>Python>>正文


Python Packet.getOriginId方法代码示例

本文整理汇总了Python中Packet.Packet.getOriginId方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.getOriginId方法的具体用法?Python Packet.getOriginId怎么用?Python Packet.getOriginId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Packet.Packet的用法示例。


在下文中一共展示了Packet.getOriginId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import getOriginId [as 别名]
    def run(self):
        wait_counter = 0
        while self.stop_event.is_set() == False:

            # If we already have lots of updates pending, send those.
            if len(self.updates) > 4:# and len(self.updates) != 0:
                self.send_to_server()
                self.updates = []
            try:
                data = self.in_socket.receiveData()
                print "Incoming packet: " + str(data.encode('hex_codec'))
                # If we get something, reset the counter
                wait_counter = 0

                packet = Packet(data)
                sender = packet.getOriginId()
                payload = packet.getPayload()

                location = Point(payload.getDecimalLatitude(), payload.getDecimalLongitude(), payload.getElevation())
                game_coords = loc_translate(location)

                # Only send the message if the position is new
                #if self.loc_dict[sender] != game_coords:
                #self.updates.append([str(sender), game_coords])
                self.updates.append([str(randrange(1,5)), [randrange(0,49), randrange(0,49), randrange(0, 20)]])
                #else:
                    #print "MeshForwarder: Speck is already known at %s. Not sending." % game_coords

            except:
                # If no more data, send what we have
                if len(self.updates) > 0:
                    self.send_to_server()

                wait = 0.1
                print "MeshForwarder: No new data received from mesh. Waiting %s sec." % wait
                time.sleep(wait)

                # Stop the thread if we waited for more than ten seconds
                wait_counter += wait
                if wait_counter > 10:
                    print "No data in 10 seconds. Stopping."
                    self.stop()

        print "Mesh Forwarding thread stopped."
开发者ID:SLIPD,项目名称:Basestation,代码行数:46,代码来源:steve.py

示例2: run

# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import getOriginId [as 别名]
    def run(self):
        wait_counter = 0
        while self.stop_event.is_set() == False:
            
            # If we already have lots of updates pending, send those.
            if len(self.updates) > 4:
                self.send_to_server()
                self.updates = []
            try:
                data = self.in_socket.receiveData()
                #print "Incoming packet: " + str(data.encode('hex_codec'))
                # If we get something, reset the counter
                wait_counter = 0
                
                packet = Packet(data)
                sender = packet.getOriginId()
                payload = packet.getPayload()
                
                location = Point(payload.getDecimalLatitude(), payload.getDecimalLongitude(), payload.getElevation()) 
                game_coords = loc_translate(location)
                self.updates.append([str(sender), game_coords])
                
            except:
                # If no more data, send what we have
                self.send_to_server()
                
                wait = 0.1
                print "MeshForwarder: No Data received from mesh. Waiting %s sec." % wait
                time.sleep(wait)

                # Stop the thread if we waited for more than ten seconds
                wait_counter += wait
                if wait_counter > 10:
                    print "No data in 10 seconds. Stopping."
                    self.stop()
        
        print "Mesh Forwarding thread stopped."
开发者ID:SLIPD,项目名称:Basestation,代码行数:39,代码来源:steveping.py


注:本文中的Packet.Packet.getOriginId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。