def addEventToTempLastValueStore(structname, msgdata):
global latest_values_
- sensorindex = msgdata["Sensorindex"] if "Sensorindex" in msgdata else 0
+ sensorindex = int(msgdata["Sensorindex"]) if "Sensorindex" in msgdata else 0
if not structname in latest_values_:
latest_values_[structname]=[]
if not structname in sensor_cols_num_ or sensor_cols_num_[structname] < sensorindex +1:
def cleanTempLastValueOfMovementValues():
global latest_values_
for k in reset_these_structnames_.keys():
- latest_values_[k] = [0] * sensor_cols_num_[structname]
+ latest_values_[k] = [0] * sensor_cols_num_[k]
def expandSensorStoreLists(structname, newlength):
#remove old headings so we can add them again below
try:
if sensor_store_[structname][0][0] == time_column_name_:
- sensor_store_[structname][0].pop(0)
+ sensor_store_[structname].pop(0)
except:
pass
#expand all previous value lists
- sensor_store_[structname] = map(lambda l: l + ([0] * (newlength +1 - len(l))) , sensor_store_[structname])
+ newlength_including_time = newlength +1
+ sensor_store_[structname] = map(lambda l: l[:newlength_including_time] + ([0] * (newlength_including_time - len(l))) , sensor_store_[structname])
def addEventsToStore():
#if missing, add Header List [Time, 0, 1, 2]
if len(sensor_store_[structname]) == 0 or len(sensor_store_[structname][0]) < 2 or sensor_store_[structname][0][0] != time_column_name_:
- sensor_store_[structname].insert(0,[time_column_name_] + list(map(str,range(0,sensor_cols_num_[structname]))))
+ sensor_store_[structname].insert(0,[time_column_name_] + list(map(lambda n: "Sensor %d"%n,range(0,sensor_cols_num_[structname]))))
# add values
sensor_store_[structname].append([ts] + latest_values_[structname])
addEventsToStore()
cleanTempLastValueOfMovementValues()
+ logging.debug("post-cleanMovement lastdata:"+str(latest_values_))
backup_counter += 1
# save sensor_store_ to json for apache