]> Pileus Git - ~andy/csm213a-hw/blobdiff - vis/visual.py
Add Xively upload
[~andy/csm213a-hw] / vis / visual.py
index 6d06ba4444bf6a478cdafd0dbef54a1157f94fc9..bd52be967b6da0ec7b9fce077be4be8d857adf9b 100644 (file)
@@ -117,21 +117,22 @@ class Visual:
                print('\tlgt - ' + str(state.light))
                print('\ttch - ' + str(state.touch))
                print('\ta2d - ' + str(state.a2d))
-       
-       def timer(self):
-               serial = self.builder.get_object("serial_btn")
-               status = self.builder.get_object("conn")
 
-               if self.device.running():
-                       serial.set_active(True)
-                       status.set_from_stock(Gtk.STOCK_YES, Gtk.IconSize.BUTTON)
-               else:
-                       serial.set_active(False)
-                       status.set_from_stock(Gtk.STOCK_NO,  Gtk.IconSize.BUTTON)
-               if self.device.running():
-                       for item in self.device.process():
-                               self.update(item)
-                               #self.debug(item)
+       def timer(self):
+               def check(state, name):
+                       btn = self.builder.get_object(name + '_btn')
+                       con = self.builder.get_object(name + '_con')
+                       img = Gtk.STOCK_YES if state else Gtk.STOCK_NO
+                       btn.set_active(state)
+                       con.set_from_stock(img, Gtk.IconSize.BUTTON)
+
+               check(self.device.running(), "serial")
+               check(self.logger.running(), "xively")
+
+               for item in self.device.process():
+                       self.update(item)
+                       self.logger.append(item)
+                       #self.debug(item)
 
                return True