def run(self): logging.critical('elec communication: start') try: fagpio.export(elec_gpio) gpio=fagpio.gpio(elec_gpio) gpio.edge='rising' gpio.direction='in' gpio.active=1 t=time.time() i=0 while self.running: logging.debug('elec communication: before poll') events=gpio.epoll_obj.poll(1) for fileno,event in events: if fileno==gpio.fvalue.fileno(): now=time.time() diff=round(now-t,2) t=now if i>1: ec.inc() ec.period(diff) logging.info('elec communication: '+str(ec.value)+' '+str(diff)+' '+ str(ec.act_pow)) else: i+=1 logging.info('elec communication: init..') except Exception,e: logging.error('elec communication: '+str(e))
def run(self): print('elec communication thread start') try: fagpio.export(num) gpio=fagpio.gpio(num) gpio.edge='rising' gpio.direction='in' gpio.active=1 t=time.time() i=0 while self.running: events=gpio.epoll_obj.poll(1) for fileno,event in events: if fileno==gpio.fvalue.fileno(): now=time.time() diff=round(now-t,2) t=now if i>1: ec.inc() ec.period(diff) print(str(ec.value)+' '+str(diff)+' '+ str(ec.act_pow)) else: i+=1 print('.') except Exception,e: print('elec communication error: '+str(e))
def __init__(self,id,gpio,dir,act,edge): threading.Thread.__init__(self) self.running=True self.id=id self.gpio=gpio self.dir=dir self.act=act self.edge=edge fagpio.export(gpio) logging.critical('gpio communication: export '+str(gpio)+' gpio')
def GDO0Open(self): p=self.GDO0Pin fagpio.export(p) p_obj=fagpio.gpio(p) p_obj.active=0 p_obj.direction='in' p_obj.edge='rising' self.GDO0File=p_obj.fvalue self.epoll_obj=p_obj.epoll_obj self.GDO0State=True
def __init__(self, id_, gpio, dir_, act, edge, counter): threading.Thread.__init__(self) self.running = True self.id = id_ self.gpio = gpio self.dir = dir_ self.act = act self.edge = edge self.counter = counter fagpio.export(gpio) logging.critical('gpio communication: export ' + str(gpio) + ' gpio')