From: Bernhard Tittelbach Date: Thu, 10 Oct 2013 02:29:08 +0000 (+0000) Subject: bugfixes. finally works X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=d3dd7636b3d3386aa3a328b251478c8396477e30;p=svn42.git bugfixes. finally works --- diff --git a/sensorvalues-to-json-zmq.py b/sensorvalues-to-json-zmq.py index bf71013..fa6e7f5 100755 --- a/sensorvalues-to-json-zmq.py +++ b/sensorvalues-to-json-zmq.py @@ -169,7 +169,7 @@ reset_these_structnames_ = {} 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: @@ -198,7 +198,7 @@ def addEventToTempLastValueStore(structname, msgdata): 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): @@ -208,11 +208,12 @@ 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(): @@ -224,7 +225,7 @@ 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]) @@ -303,6 +304,7 @@ if __name__ == "__main__": addEventsToStore() cleanTempLastValueOfMovementValues() + logging.debug("post-cleanMovement lastdata:"+str(latest_values_)) backup_counter += 1 # save sensor_store_ to json for apache