本文整理汇总了Python中Message.printData方法的典型用法代码示例。如果您正苦于以下问题:Python Message.printData方法的具体用法?Python Message.printData怎么用?Python Message.printData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message.printData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testHandleMessage
# 需要导入模块: import Message [as 别名]
# 或者: from Message import printData [as 别名]
def testHandleMessage(self, msg):
# determine message type and process accordingly
if msg.msgType==1:
# TBD
pass
elif msg.msgType==2:
# Start the add target process with the target data of the message
self.testAddTarget(msg.data)
elif msg.msgType==3:
# Update drone status list
self.drones[msg.data[0]]=[msg.data[1],msg.data[2]]
# Check which target assignment heruristic is in use
if self.heuristic==1:
# If the drone is idle and there are target assignments in the queue, assign that drone a target
if (self.drones[msg.data[0]][0]=="Idle") and (len(self.priorityQueue)!=0):
newTgtData=self.priorityQueue.pop()
newTgtMsg=Message(2,newTgtData,self.id,msg.data[0],self.localTime)
#self.sendMessage(newTgtMsg)
if(debug==1):
print 'CAOC sending message: '
newTgtMsg.printData(1)
self.drones[msg.data[0]][0]="Busy"
# Check which target assignment heruristic is in use
elif self.heuristic==2 or self.heuristic==3:
# If the drone is idle and there are target assignments in the queue, assign that drone the nearest target
if (self.drones[msg.data[0]][0]=="Idle") and (len(self.priorityQueue)!=0):
droneLocation=self.drones[msg.data[0]][1] #x,y coords
droneX=self.drones[msg.data[0]][1].xpos
droneY=self.drones[msg.data[0]][1].ypos
indexCloseTgt=0
minDist=999999
for i in range(len(self.priorityQueue)):
tgtX=self.priorityQueue[i][6].xpos #x coord
tgtY=self.priorityQueue[i][6].ypos #y coord
dist=sqrt((tgtX-droneX)**2+(tgtY-droneY)**2)
if dist<minDist:
minDist=dist
indexCloseTgt=i
newTgtData=self.priorityQueue.pop(indexCloseTgt)
newTgtMsg=Message(2,newTgtData,self.id,msg.data[0],self.localTime)
#self.sendMessage(newTgtMsg)
if(debug==1):
print 'CAOC sending message: '
newTgtMsg.printData(1)
self.drones[msg.data[0]][0]="Busy"
示例2: updateTargets
# 需要导入模块: import Message [as 别名]
# 或者: from Message import printData [as 别名]
def updateTargets(self, timestamp):
# send request to HMINT for targets available as of self.localTime
print 'CAOC: Sending target request for time %d to HMINT' % timestamp
sys.stdout.flush()
requestData = TargetRequest(timestamp)
msg = Message(4, requestData, LogicalProcess.CAOC_ID, LogicalProcess.HMINT_ID, timestamp)
self.sendMessage(msg)
# wait for response
responseData = None
while True:
print 'CAOC: Waiting for target response from HMINT'
sys.stdout.flush()
time.sleep(1)
if(self.Loopcont.getCon()==0):
break
msgs = self.inputQueue.getAllMessages()
for msg in msgs:
msg.printData(1)
if msg.msgType == 5:
print 'CAOC: Received target response for time %d from HMINT' % self.localTime
sys.stdout.flush()
responseData = msg.data
self.inputQueue.removeByID(msg.id)
if msg.color == LPGVTData.WHITE:
self.gvtData.counts[self.LPID] -= 1
if(debug==1):
print 'LP %d recvd WHITE msg, rcvd count is now %d' % (self.LPID, self.gvtData.counts[self.LPID])
break
if not(responseData is None):
break
# add targets
if(self.Loopcont.getCon()==0):
return
for target in responseData.targetData:
print 'CAOC: Adding target to priority queue:', target
self.addTarget(target)
sys.stdout.flush()
示例3: testAddTarget
# 需要导入模块: import Message [as 别名]
# 或者: from Message import printData [as 别名]
def testAddTarget(self, targetData):
# Check if the queue is empty
if len(self.priorityQueue)==0:
# Check which target assignment heruristic is in use
if self.heuristic==1:
# If the queue is empty and there is an idle drone, send it the incoming target assignment
for i in range(len(self.drones)):
if self.drones[i][0]=='Idle':
newTgtMsg=Message(2,targetData,self.id,i,self.localTime)
#self.sendMessage(newTgtMsg)
if(debug==1):
print 'CAOC sending message: '
newTgtMsg.printData(1)
self.drones[i][0]='Busy'
break
# If the queue is empty and all drones are busy, put the target assignment in the queue
else:
self.priorityQueue.insert(0,targetData)
# Check which target assignment heruristic is in use
elif self.heuristic==2:
# Determine distance of target from idle drones
tgtX=targetData[6].xpos #x coord
tgtY=targetData[6].ypos #y coord
indexCloseDrone=0
minDist=999999 #arbitrarily large cut-off
if(debug==1):
print self.drones
for i in range(len(self.drones)):
droneX=self.drones[i][1].xpos
droneY=self.drones[i][1].ypos
dist=sqrt((tgtX-droneX)**2+(tgtY-droneY)**2)
if dist<minDist and self.drones[i][0]=="Idle":
minDist=dist
indexCloseDrone=i
# If the queue is empty and all drones are busy, put the target assignment in the queue
if minDist==999999:
self.priorityQueue.insert(0,targetData)
# If the queue is empty and there are idle drones, send the nearest drone the incoming target assignment
else:
newTgtMsg=Message(2,targetData,self.id,indexCloseDrone,self.localTime)
#self.sendMessage(newTgtMsg)
print 'CAOC sending message: '
newTgtMsg.printData(1)
self.drones[indexCloseDrone][0]='Busy'
elif self.heuristic==3:
# Adjust tgt priority be intel value/goal track time if the tgt has no track attempts
if targetData[9]==0:
targetData[2]=targetData[1]/targetData[7]
# Determine distance of target from idle drones
tgtX=targetData[6].xpos #x coord
tgtY=targetData[6].ypos #y coord
indexCloseDrone=0
minDist=999999
for i in range(len(self.drones)):
droneX=self.drones[i][1].xpos
droneY=self.drones[i][1].ypos
dist=sqrt((tgtX-droneX)**2+(tgtY-droneY)**2)
if dist<minDist and self.drones[i][0]=="Idle":
minDist=dist
indexCloseDrone=i
# If the queue is empty and all drones are busy, put the target assignment in the queue
if minDist==999999:
self.priorityQueue.insert(0,targetData)
# If the queue is empty and there are idle drones, send the nearest drone the incoming target assignment
else:
newTgtMsg=Message(2,targetData,self.id,indexCloseDrone,self.localTime)
#self.sendMessage(newTgtMsg)
print 'CAOC sending message: '
newTgtMsg.printData(1)
self.drones[indexCloseDrone][0]='Busy'
# If the queue is not empty (implying all drones are busy), put the target assignment in the queue in order
else:
if self.heuristic==3:
# Adjust tgt priority be intel value/goal track time if the tgt has no track attempts
if targetData[9]==0:
targetData[2]=targetData[1]/targetData[7]
# Put target data into priority queue in priority order
if targetData[2]>=self.priorityQueue[len(self.priorityQueue)-1][2]:
self.priorityQueue.append(targetData)
else:
for i in range(len(self.priorityQueue)):
if targetData[2]<self.priorityQueue[i][2]:
self.priorityQueue.insert(i,targetData)
break
print('CAOC Added target to priority queue')