def main(): db = database_class() #os.system('clear') # Works only in linux print('\t\tPOWER CONSUMPTION') while True: xb = Xbee() packet = xb.xbee_read() if packet: data = extractData(packet) print('-------------------------------------------------') try: tm = data[0] power = data [1] print '|',tm,'\tConsumption => \t',power,'Unit','|','\n' db.insertDb(tm,power) except Exception as e: print e
except Exception as e: # print 'plc init():'+str(e) print 'class PLC __init__(): %s' %(str(e),) def read_int(self): data = self.instrument.read_register(5146) return data def read_float(self): data = self.instrument.read_float(5147)/100000 return data db = database_class() xb = XBEE() plc = PLC() led = LED(12) # Here 12 is the max threshold value print('\t\tPOWER CONSUMPTION') while True: try: time = strftime("%Y-%m-%d %H:%M:%S") #consumption = dummyPacket() consumption = plc.read_float() if(consumption > led.threshold) {