def performMeasurements(coordonatorId, nodeObjUsed, stopHour, stopMinute, filePath): a = 0 while True: if datetime.datetime.now().hour > stopHour and datetime.datetime.now().minute > stopMinute: break else: a += 1 #directGains = getDirectGainsNPl(coordonatorId,nodeObjUsed) #crossGains = getCrossGains2Pl(coordonatorId,nodeObjUsed) resultList = [datetime.datetime.now().hour, datetime.datetime.now().minute] #h_11 resultList.append(measureGainBetwTxRx(coordonatorId, nodeObjUsed[0], nodeObjUsed[1], 2422e6, txPower=0, transDuration=6)) #h_22 resultList.append(measureGainBetwTxRx(coordonatorId, nodeObjUsed[2], nodeObjUsed[3], 2422e6, txPower=0, transDuration=6)) time.sleep(5) #h_21 resultList.append(measureGainBetwTxRx(coordonatorId, nodeObjUsed[2], nodeObjUsed[1], 2422e6, txPower=0, transDuration=6)) #h_12 resultList.append(measureGainBetwTxRx(coordonatorId, nodeObjUsed[0], nodeObjUsed[3], 2422e6, txPower=0, transDuration=6)) # for elem in directGains: # resultList.append(elem) # for elem in crossGains: # resultList.append(elem) writeSomeListToFile(coordonatorId,filePath,resultList) print "Measurement %d at %d:%d"%(a,datetime.datetime.now().hour,datetime.datetime.now().minute) print "sleep for 5 minutes" time.sleep(5*60) print "Finish measurements!! :)(:"
def measureGains(self): """Measure h_ii and h_ji between players, store these values in a list and a dictionary""" # txNodes = list() # rxNodes = list() txPlayers = list() rxPlayers = list() # measure direct gains for p in self.players: # get tx and rx nodes, used for cross gain txPlayers.append(self.players[p]) rxPlayers.append(self.players[p]) self.directGains[self.players[p].getPlayerNumber()] = measureGainBetwTxRx(self.coordId, self.players[ p].physicalLayer.txNode, self.players[p].physicalLayer.rxNode, self.gameFreq, txPower=0, transDuration=6) self.players[p].physicalLayer.setDirectGain(self.directGains[self.players[p].getPlayerNumber()]) # wait for things to cool down time.sleep(2) # measure cross gains for p in self.players: result = dict() aux1 = txPlayers[:] aux1.remove(self.players[p]) for n in aux1: result[n.getPlayerNumber()] = measureGainBetwTxRx(self.coordId, n.physicalLayer.txNode, self.players[p].physicalLayer.rxNode, self.gameFreq, txPower=0, transDuration=6) # wait for things to cool down time.sleep(2) # add cross gains to dictionary self.crossGains[p] = result print self.directGains for key in self.crossGains.keys(): print self.crossGains[key]