sparse value store
authorBernhard Tittelbach <xro@realraum.at>
Tue, 15 Oct 2013 19:51:47 +0000 (19:51 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Tue, 15 Oct 2013 19:51:47 +0000 (19:51 +0000)
sensorvalues-to-json-zmq.py

index fa6e7f5..d6bc31e 100755 (executable)
@@ -40,7 +40,7 @@ class UWSConfig:
     self.config_parser.add_section('json')
     self.config_parser.set('json','write_path',"/dev/shm/wget/r3sensors.json")
     self.config_parser.set('json','moveto_path',"/dev/shm/www/r3sensors.json")
-    self.config_parser.set('json','backup_path',"/home/guests/realraum.wirdorange.org/public_html/r3sensors.json.bak")
+    self.config_parser.set('json','backup_path',"/home/guests/realraum.wirdorange.org/r3sensors.json.bak")
     self.config_parser.set('json','backup_every',"50")
     self.config_parser.set('json','limit_list_len',"10000")
     self.config_parser.set('json','updateinterval',"30")
@@ -228,6 +228,12 @@ def addEventsToStore():
             sensor_store_[structname].insert(0,[time_column_name_] + list(map(lambda n: "Sensor %d"%n,range(0,sensor_cols_num_[structname]))))
 
         # add values
+        try:
+            # if latest values are identical, just update timestamp
+            if sensor_store_[structname][-1][1:] == latest_values_[structname] and sensor_store_[structname][-1][1:] == sensor_store_[structname][-2][1:]:
+                sensor_store_[structname].pop()
+        except:
+            pass
         sensor_store_[structname].append([ts] + latest_values_[structname])
 
         #cap list lenght