# Fix negative jump in time # Special case for interrupts from TIMERA1, which is the iCount # overflow interrupt. We must add 65536 to the value of iCount # on enter_interrupt for TIMERA1. We read the counter BEFORE the # interrupt routine, which is the routine that will correct the base. #if (entry.get_type() == QuantoLogConstants.SINGLE_CHG_ENTER_INT and # (activity(entry.get_arg())).get_activity_type() == Msp430Constants.ACT_PXY_TIMERA1): # ic += 65536 last_ic = ic ic = entry.get_ic() if (last_ic - ic > 32768): ic += 65536 s += ' icount: ' + str(ic) if (type == QuantoLogConstants.MSG_TYPE_SINGLE_CHG or type == QuantoLogConstants.MSG_TYPE_MULTI_CHG ): s += ' ctx: %s ' % activity(entry.get_arg()) elif (type == QuantoLogConstants.MSG_TYPE_POWER_CHG): s += ' arg: 0x%0X ' % entry.get_arg() else: s += ' arg: ' + str(entry.get_arg()) s += ' ps: ' + pState.getKey() print >> fout, s #Keep track of state time and energy for regression if (lastStateKey != None and lastStateKey != pState.getKey()): delta = time - lastStateTime cumTime[lastStateKey] = cumTime.get(lastStateKey, 0) + delta delta = ic - lastStateIc cumIc[lastStateKey] = cumIc.get(lastStateKey, 0) + delta cumChanges[lastStateKey] = cumChanges.get(lastStateKey, 0) + 1
def updateFromEntry(self, entry): '''Update the values based on a log entry. This is the reason for this class, and has logic to change the global power state based on different resources individual power states. Some resources don't require explicit power state statements in the log, as their state can be inferred from lack of activity. Returns True if the state changed, False otherwise. ''' type = (entry.get_type() >> 4) & 0x0F subtype = entry.get_type() & 0x0F old_values = list(self._values) # CPU State: idle or busy, inferred from activity if (type == QuantoLogConstants.MSG_TYPE_FLUSH_REPORT): self.clear() elif (type == QuantoLogConstants.MSG_TYPE_SINGLE_CHG): if (entry.get_res_id() == ResourceConstants.CPU_RESOURCE_ID): if (activity(entry.get_arg()).get_activity_type() == QuantoCoreConstants.ACT_TYPE_IDLE): self.setBitByName('cpu', 0) else: self.setBitByName('cpu', 1) elif (type == QuantoLogConstants.MSG_TYPE_POWER_CHG): #LED States: directly from the powerstate. #Can also be inferred by the activities alone. if (entry.get_res_id() == ResourceConstants.LED0_RESOURCE_ID): self.setBitByName('led0', entry.get_arg()) elif (entry.get_res_id() == ResourceConstants.LED1_RESOURCE_ID): self.setBitByName('led1', entry.get_arg()) elif (entry.get_res_id() == ResourceConstants.LED2_RESOURCE_ID): self.setBitByName('led2', entry.get_arg()) #CC2420: has complicated power states, setting several bits. # Each transmit power level is a different bit, # but they are exclusive. See the constants for # more info. elif (entry.get_res_id() == ResourceConstants.CC2420_RESOURCE_ID): ps = entry.get_arg() #other states map( lambda x: self.setBitByName( x, _getCC2420PowerBitValues(ps, x)), ('2420starting', '2420listen', '2420rx', '2420stopping', '2420rxfifo', '2420txfifo')) #if rx !listen if (_getCC2420PowerBitValues(ps, '2420rx')): self.setBitByName('2420listen', 0) #tx : must get power. #First zero all power bits in the global power state to 0 map(lambda x: self.setBitByName(x, 0), ('2420tx3', '2420tx7', '2420tx11', '2420tx15', '2420tx19', '2420tx23', '2420tx27', '2420tx31')) #Now find the correct one if (_getCC2420PowerBitValues(ps, '2420tx')): self.setBitByName('2420listen', 0) #tx xor listen! power = ps & QuantoCC2420Constants.CC2420_POWERLEVEL_MASK if (power == 3): self.setBitByName('2420tx3', 1) elif (power == 7): self.setBitByName('2420tx7', 1) elif (power == 11): self.setBitByName('2420tx11', 1) elif (power == 15): self.setBitByName('2420tx15', 1) elif (power == 19): self.setBitByName('2420tx19', 1) elif (power == 23): self.setBitByName('2420tx23', 1) elif (power == 27): self.setBitByName('2420tx27', 1) elif (power == 31): self.setBitByName('2420tx31', 1) return old_values != self._values
first = False initialTime = time; s = QuantoLogConstantsNamed.typeName[type] s += ' ' + QuantoLogConstantsNamed.subtypeName[type][subtype] s += ' ' + ResourceConstantsNamed.names[entry.get_res_id()] if (type != QuantoLogConstants.MSG_TYPE_FLUSH_REPORT): time = time - initialTime s += ' time: ' + str(time) # Special case for interrupts from TIMERA1, which is the iCount # overflow interrupt. We must add 65536 to the value of iCount # on enter_interrupt for TIMERA1. We read the counter BEFORE the # interrupt routine, which is the routine that will correct the base. ic = entry.get_ic(); if (entry.get_type() == QuantoLogConstants.SINGLE_CHG_ENTER_INT and (activity(entry.get_arg())).get_activity_type() == Msp430Constants.ACT_PXY_TIMERA1): ic += 65536 s += ' icount: ' + str(ic) if (type == QuantoLogConstants.MSG_TYPE_SINGLE_CHG or type == QuantoLogConstants.MSG_TYPE_MULTI_CHG ): s += ' ctx: %s ' % activity(entry.get_arg()) elif (type == QuantoLogConstants.MSG_TYPE_POWER_CHG): s += ' arg: 0x%0X ' % entry.get_arg() else: s += ' arg: ' + str(entry.get_arg()) s += ' ps: ' + pState.getKey() print >> fout, s #Keep track of state time and energy for regression if (lastStateKey != None and lastStateKey != pState.getKey()): delta = time - lastStateTime
first = False initialTime = time s = QuantoLogConstantsNamed.typeName[type] s += ' ' + QuantoLogConstantsNamed.subtypeName[type][subtype] s += ' ' + ResourceConstantsNamed.names[entry.get_res_id()] if (type != QuantoLogConstants.MSG_TYPE_FLUSH_REPORT): time = time - initialTime s += ' time: ' + str(time) # Special case for interrupts from TIMERA1, which is the iCount # overflow interrupt. We must add 65536 to the value of iCount # on enter_interrupt for TIMERA1. We read the counter BEFORE the # interrupt routine, which is the routine that will correct the base. ic = entry.get_ic() if (entry.get_type() == QuantoLogConstants.SINGLE_CHG_ENTER_INT and (activity(entry.get_arg())).get_activity_type() == Msp430Constants.ACT_PXY_TIMERA1): ic += 65536 s += ' icount: ' + str(ic) if (type == QuantoLogConstants.MSG_TYPE_SINGLE_CHG or type == QuantoLogConstants.MSG_TYPE_MULTI_CHG): s += ' ctx: %s ' % activity(entry.get_arg()) elif (type == QuantoLogConstants.MSG_TYPE_POWER_CHG): s += ' arg: 0x%0X ' % entry.get_arg() else: s += ' arg: ' + str(entry.get_arg()) s += ' ps: ' + pState.getKey() print >> fout, s #Keep track of state time and energy for regression if (lastStateKey != None and lastStateKey != pState.getKey()):
def updateFromEntry(self, entry): '''Update the values based on a log entry. This is the reason for this class, and has logic to change the global power state based on different resources individual power states. Some resources don't require explicit power state statements in the log, as their state can be inferred from lack of activity. Returns True if the state changed, False otherwise. ''' type = (entry.get_type() >> 4 ) & 0x0F subtype = entry.get_type() & 0x0F old_values = list(self._values) # CPU State: idle or busy, inferred from activity if (type == QuantoLogConstants.MSG_TYPE_FLUSH_REPORT): self.clear() elif (type == QuantoLogConstants.MSG_TYPE_SINGLE_CHG): if (entry.get_res_id() == QuantoAppConstants.QUANTO_CPU_RESOURCE_ID): if (activity(entry.get_arg()).get_activity_type() == QuantoAppConstants.QUANTO_IDLE_ACTIVITY_ID): self.setBitByName('cpu',0) else: self.setBitByName('cpu',1) elif (type == QuantoLogConstants.MSG_TYPE_POWER_CHG): #LED States: directly from the powerstate. #Can also be inferred by the activities alone. if (entry.get_res_id() == QuantoAppConstants.QUANTO_LED0_RESOURCE_ID): self.setBitByName('led0',entry.get_arg()) elif (entry.get_res_id() == QuantoAppConstants.QUANTO_LED1_RESOURCE_ID): self.setBitByName('led1',entry.get_arg()) elif (entry.get_res_id() == QuantoAppConstants.QUANTO_LED2_RESOURCE_ID): self.setBitByName('led2',entry.get_arg()) #CC2420: has complicated power states, setting several bits. # Each transmit power level is a different bit, # but they are exclusive. See the constants for # more info. elif (entry.get_res_id() == QuantoAppConstants.QUANTO_CC2420_RESOURCE_ID): ps = entry.get_arg() #other states map( lambda x: self.setBitByName( x, _getCC2420PowerBitValues(ps, x) ), ('2420starting','2420listen','2420rx','2420stopping','2420rxfifo','2420txfifo')) #if rx !listen if (_getCC2420PowerBitValues(ps, '2420rx')): self.setBitByName('2420listen',0) #tx : must get power. #First zero all power bits in the global power state to 0 map( lambda x: self.setBitByName( x, 0), ('2420tx3', '2420tx7', '2420tx11', '2420tx15', '2420tx19', '2420tx23', '2420tx27', '2420tx31') ) #Now find the correct one if (_getCC2420PowerBitValues(ps, '2420tx')): self.setBitByName('2420listen',0) #tx xor listen! power = ps & QuantoCC2420Constants.CC2420_POWERLEVEL_MASK if (power == 3): self.setBitByName( '2420tx3', 1) elif (power == 7): self.setBitByName( '2420tx7', 1) elif (power == 11): self.setBitByName( '2420tx11', 1) elif (power == 15): self.setBitByName( '2420tx15', 1) elif (power == 19): self.setBitByName( '2420tx19', 1) elif (power == 23): self.setBitByName( '2420tx23', 1) elif (power == 27): self.setBitByName( '2420tx27', 1) elif (power == 31): self.setBitByName( '2420tx31', 1) return old_values != self._values