Exemplo n.º 1
0
class GenericMeasure(Measure):
    def __init__(self, pattern, period, simulationTime, units):
        Measure.__init__(self, period, simulationTime, units)
                
        self.__periodicValues = PeriodicValues(0, period, simulationTime)
        
        self.__prog = re.compile(pattern)
        
        self.__units = units
    
    def getTotalValue(self):
        return self.__periodicValues.getTotal()
    
    def incValue(self, time, simulationTime):
        self.__periodicValues.incValue(time, self.getPeriod(), simulationTime)
        
    def parseInc(self, line):
        m = self.__prog.match(line)
        if m is not None:
            time  = float(m.group(1).replace(',','.'))
            self.incValue(time, self.getSimulationTime())
            
    def getProg(self):
        return self.__prog 
    
    def getValues(self): 
        return self.__periodicValues
Exemplo n.º 2
0
	def getValues(self):
		values = PeriodicValues(0, self.__period, self.__simulationTime)
		
		broadcastedMessagesArray = self.__broadcastedMessages.getValues()
		deliveredMessagesArray = self.__deliveredMessages.getValues()
		
		for index in xrange(len(broadcastedMessagesArray)):
			broadcasted = broadcastedMessagesArray.getValue(index)
			delivered = deliveredMessagesArray.getValue(index)
			if broadcasted == 0:
				values.setValue(index, 0);
			else:
				values.setValue(index, delivered / float(broadcasted))
			 
		return values
Exemplo n.º 3
0
 def __init__(self, pattern, period, simulationTime, units):
     Measure.__init__(self, period, simulationTime, units)
             
     self.__periodicValues = PeriodicValues(0, period, simulationTime)
     
     self.__prog = re.compile(pattern)
     
     self.__units = units
	def getValues(self):
		values = PeriodicValues(0, self.getPeriod(), self.getSimulationTime())
		
		searches = GenericMeasure('', self.getPeriod(), self.getSimulationTime(), Units.SEARCHES)
		founds = GenericMeasure('', self.getPeriod(), self.getSimulationTime(), Units.COMPOSITIONS)
		
		for found, startTime in self.__searches.values():
			searches.incValue(startTime, self.getSimulationTime())
			if found:
				founds.incValue(startTime, self.getSimulationTime())
				
		searchesArray = searches.getValues()
		foundsArray = founds.getValues()
		
		for index in xrange(len(searchesArray)):
			search = searchesArray.getValue(index)
			found = foundsArray.getValue(index)
			if search == 0:
				values.setValue(index, 0);
			else:
				values.setValue(index, found / float(search))
			 
		return values