diff MonitorDev.py @ 12:9d5b291cfd01

Add/correct docstrings & comments.
author darius
date Sat, 29 Sep 2007 14:51:20 +0000
parents 483375ca5d10
children f1832dec26e3
line wrap: on
line diff
--- a/MonitorDev.py	Sat Sep 29 14:40:54 2007 +0000
+++ b/MonitorDev.py	Sat Sep 29 14:51:20 2007 +0000
@@ -3,7 +3,7 @@
 ############################################################################
 # Monitoring/control interface to hardware for beermon
 #
-# $Id: MonitorDev.py,v 1.1 2007/09/29 14:39:59 darius Exp $
+# $Id: MonitorDev.py,v 1.2 2007/09/29 14:51:20 darius Exp $
 #
 # Depends on: Python 2.3 (I think)
 #
@@ -66,6 +66,7 @@
     lastCoolOff = 0
 
     def __init__(self, _log, conf):
+        """_log is a logging object, conf is a ConfigParser object"""
         global log
         log = _log
         threading.Thread.__init__(self)
@@ -106,6 +107,7 @@
         self.start()
         
     def setspeed(self):
+        """Set the speed microcom talks to the serial port to 38400"""
         self.commsLock.acquire()
         self.p.send('~')
         assert(self.p.expect('t - set terminal') == 0)
@@ -118,6 +120,7 @@
         self.commsLock.release()
         
     def find1wire(self):
+        """Scan the bus for 1-wire devices"""
         self.commsLock.acquire()
         self.p.sendline('')
         assert(self.p.expect('> ') == 0)
@@ -152,6 +155,7 @@
         return(devlist)
 
     def istemp(self, id):
+        """Returns true if the 1-wire device is a temperature sensor"""
         [family, a, b, c, d, e, f, g] = id.split(':')
         if (family == '10'):
             return True
@@ -159,6 +163,7 @@
             return False
 
     def updateTemps(self):
+        """Update our cached copy of temperatures"""
         for i in self.tempdevs:
             try:
                 self.temps[i] = float(self.readTemp(i))
@@ -170,6 +175,7 @@
         return(self.temps)
 
     def readTemp(self, id):
+        """Read the temperature of a sensor"""
         self.commsLock.acquire()
         cmd = 'te ' + id
         self.p.sendline(cmd)
@@ -187,6 +193,7 @@
         return(line)
 
     def setState(self, state):
+        """Set the heat/cool state, track the on/off time"""
         if (state == 'cool'):
             relay = 1 << self.coolRelay
         elif (state == 'heat'):
@@ -224,15 +231,8 @@
         assert(self.p.expect(cmd) == 0)
         self.commsLock.release()
         
-    def polltemps(self, temps):
-        while True:
-            for d in temps:
-                #print d
-                t = gettemp(p, d)
-                print "%s -> %s" % (d, t)
-            print
-
     def run(self):
+        """Sit in a loop polling temperatures"""
         while True:
             self.updateTemps()