class CommonSetpoint(Actuator):
	bdm = BDWrapper()
	zone = None
	template = None

#TODO: Is it okay to set minVal and maxVal arbitrarily outside this class?
	def __init__ (self, name, uuid, minVal, maxVal, zone):
		self.name = name
		self.uuid = uuid
		super(CommonSetpoint, self).__init__(timedelta(minutes=10))
		self.inputType = master_actuator.TempType(minVal, maxVal)
		self.zone = zone
		self.template = actuNames.commonSetpoint
		self.sensorType = 'PresentValue'

	def set_value(self, val, tp):
		if val=='ZT':
			ztuuid = self.bdm.get_sensor_uuids({'room':self.zone, 'template':sensorNames.zoneTemperature})[0]
			now = datetime.now()
			currZT = self.bdm.get_sensor_ts(ztuuid, 'PresentValue', now-timedelta(hours=1), now).tail().tolist()[0]
			val = currZT
		else:
			pass
		super(CommonSetpoint, self).set_value(val, tp+timedelta(minutes=1))
	
	def get_value(self, beginTime, endTime):
		return super(CommonSetpoint, self).get_value(beginTime, endTime)

	def reset_value(self, val, tp):
		super(CommonSetpoint, self).reset_value(val, tp)
	
	#TODO: Do I need this?
	def set_reset_value(self, resetVal=-1):
		self.resetVal = resetVal
 def __init__(self, minLatency):
     # minLatency(datetime) ->
     self.minLatency = minLatency
     self.bdm = BDWrapper()
     #		depMap = pickle.load(open(self.depMapFile, 'rb'))
     with open(self.depMapFile, 'rb') as fp:
         depMap = json.load(fp)
     if self.uuid in depMap.keys():
         for depUuid in depMap[self.uuid]:
             self.affectingDependencyDict[depUuid] = timedelta(minutes=10)
             self.affectedDependencyDict[depUuid] = timedelta(minutes=10)

def resample_data(rawData, beginTime, endTime, sampleMethod):
    rawData = rawData[beginTime:endTime]
    if not beginTime in rawData.index:
        rawData[beginTime] = rawData.head(1)[0]
        rawData = rawData.sort_index()
    if not endTime in rawData.index:
        rawData[endTime] = rawData.tail(1)[0]
        rawData = rawData.sort_index()
    if sampleMethod == 'nextval':
        procData = rawData.resample('2Min', how='pad')
    return procData


bdm = BDWrapper()
sensors_dict = shelve.open('metadata/bacnet_devices.shelve', 'r')

#buildingName = 'ebu3b'
buildingName = sys.argv[1]

rawdataDir = 'rawdata/' + buildingName + '/'

naeDict = dict()
naeDict['ebu3b'] = ['505', '506']
deviceList = naeDict[buildingName]

beginTime = datetime(2016, 1, 18)
endTime = datetime(2016, 1, 25)

# Init raw set