]> gitweb.maison.local Git - pyowl.git/commitdiff
Simplify SQL table : remove Cost column
authorLionel <lionel@ra.enneade.fdn.org>
Fri, 24 Oct 2014 13:23:55 +0000 (15:23 +0200)
committerLionel <lionel@ra.enneade.fdn.org>
Fri, 24 Oct 2014 13:23:55 +0000 (15:23 +0200)
cm160Server.py

index c255dbe5413ebfc2d7f5424cb2f5bb6f85d58ad9..05a3d762ff2bf995f6aa1af18ca0576c1d1c4ecc 100755 (executable)
@@ -142,7 +142,7 @@ class CM160Data:
     except ValueError:
       return None    
   
-  def __init__(self, min, hour, day, month, year, cost, amps):
+  def __init__(self, min, hour, day, month, year, amps):
     self.__sec        = 0       #The CM160 does not return seconds in it's data 
                                 #stream.
     self.__min        = min
@@ -153,7 +153,7 @@ class CM160Data:
                                   # to 0x49. Not sure why but I'll mask them out
                                   # so that we don't get invalid month errors.
     self.__year       = year
-    self.__costPerKWH = cost
+#    self.__costPerKWH = cost
     self.__amps       = amps
     
     self.__realTime   = False  #Changes to True when realtime data is being read
@@ -178,8 +178,8 @@ class CM160Data:
   def getSecond(self):
     return self.__sec
 
-  def getCostPerKWH(self):
-    return self.__costPerKWH
+#  def getCostPerKWH(self):
+#    return self.__costPerKWH
     
   def getAmps(self):
     return self.__amps
@@ -222,7 +222,7 @@ class CM160Data:
       
   def __str__(self):
     """Return the object as a string"""
-    s="%s %f %f" % (self.getDateStr(), self.__amps, self.__costPerKWH)
+    s="%s %f " % (self.getDateStr(), self.__amps)
     if self.__month >= 1 and self.__month <= 12:
       return s
     #The CM160 sometime returns a month greater than 12. As I don't know how to 
@@ -246,7 +246,7 @@ class CM160Data:
     if len(elems) == 4:
       try:
         self.__amps       = float(elems[2])
-        self.__costPerKWH = float(elems[3])
+#        self.__costPerKWH = float(elems[3])
         t                 = elems[0]
         d                 = elems[1]
         dateElems         = d.split("/")
@@ -510,9 +510,9 @@ class CM160:
     day = frame[3]
     hour = frame[4]
     _min = frame[5]
-    costPerKWH = (frame[6]+(frame[7]<<8))/100.0 #Cost in pence per kWh
+#    costPerKWH = (frame[6]+(frame[7]<<8))/100.0 #Cost in pence per kWh
     amps = (frame[8]+(frame[9]<<8))* 0.07       #Conversion factor to Amps
-    cm160Data = CM160Data(_min, hour, day, month, year, costPerKWH, amps)
+    cm160Data = CM160Data(_min, hour, day, month, year, amps)
     #Set flag to indicate if this CM160Data was read in realtime or during a data download
     cm160Data.setRealTime(realTimeData)
     heappush(self.__queue, cm160Data) # read data from the queue by, cm160Data = heappop(self.__queue)
@@ -768,7 +768,7 @@ class MySQLDataStore(object):
     """
     conn, cursor = self.__connect()
     try:
-        cursor.execute("CREATE TABLE cm160data(ts timestamp, current float, tariff float, UNIQUE (ts))")
+        cursor.execute("CREATE TABLE cm160data(ts timestamp, current float, UNIQUE (ts))")
         # Attempt to create table in case this is first time to run
         # the server; but thereafter we expect an exception because the
         # create will fail...
@@ -792,7 +792,7 @@ class MySQLDataStore(object):
 
     stored=False
     try:
-        self.__StoreCursor.execute("""INSERT INTO cm160data VALUES (%s,%s,%s)""", (cm160Data.getDatetime(),cm160Data.getAmps(),cm160Data.getCostPerKWH(),))
+        self.__StoreCursor.execute("""INSERT INTO cm160data VALUES (%s,%s)""", (cm160Data.getDatetime(),cm160Data.getAmps(),))
         stored=True
 
     except MySQLdb.Error as e: