def dataPointView(deviceID,stream_id): #dataPointList = datamanager.getAllDatapointsByID(deviceID,stream_id) dataPointList = datamanager.getAllDatapointsByIDRaw(str(deviceID),stream_id) count=0 list =[] for st in dataPointList: #st.timestamp = str(time.strftime('%B %d, %Y %H:%M:%S', time.localtime(float(st[0])/1000))) #list.append([str(time.strftime('%B %d, %Y %H:%M:%S', time.localtime(float(st[0])/1000))),st[1]]) list.append([st[0],st[1]]) count+=1 max =750 decimateInterval = int(math.ceil(count//max)) #dataPointList = dataPointList[1::decimateInterval] list = list[1::decimateInterval] streamList = datamanager.getStreamListByDeviceID(deviceID) return render_template('dataPointList.html', #dataPoint user= g.user.get_username(), dataPointList=list, streamList=streamList, dev_id = deviceID, stID = stream_id, eventData=datamanager.getAllEventOccurances(), datatable=1)
def get_data(dev_id,streamName): print "Get_Data",dev_id,streamName stList = datamanager.getStreamListByDeviceID(dev_id) datapoints = datamanager.getAllDatapointsByIDRaw(str(dev_id),streamName) list=[] count=0 try: for i in datapoints: list.append([i[0],float(i[1])]) count+=1 except: count=0 if count: max =750 decimateInterval = int(math.ceil(count//max)) print "Count",count,"Dec,",decimateInterval,max list = list[1::decimateInterval] else: list =[] return jsonify(label =streamName, data=list)