本文整理汇总了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."
示例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."