from os import system # ./rm_config.py # Contains our config file utils import rm_config # ./rm_utils.py # Contains various utility functions import rm_utils config = rm_config.rm_read_config() # Interrupt setup # NOTE: Not safe to run interupts with callbacks due to MySQL conflicts GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(22, GPIO.RISING, bouncetime=50) DAQC.enableDINint(0, 0, 'r') DAQC.intEnable(0) # Globals # These are set up in repeatermond.cfg USER = config['MYSQLD']['USER'] PASSWD = config['MYSQLD']['PASSWD'] DBHOST = config['MYSQLD']['DBHOST'] DBNAME = config['MYSQLD']['DBNAME'] ANTS = [int(str_val) for str_val in config['MONITOR']['ANTS'].split(',')] ANALOGIO = [ int(str_val) for str_val in config['MONITOR']['ANALOGIO'].split(',') ] DIGIN = [int(str_val) for str_val in config['MONITOR']['DIGIN'].split(',')] ELEMENTS = [
detector = DAQX.getINTflags(0) if detector & 0b1: counter1 += 1 if detector & 0b10: counter2 += 1 def storecpm(value1, value2): f = open("log.dat", 'a') f.write(str(time.time()) + ",") f.write(str(value1) + ",") f.write( str(value2) + "\n") f.close() GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(22, GPIO.FALLING, callback=counterDET) DAQC.enableDINint(0,0,'r') #enable the push button interrupt DAQC.enableDINint(0,1,'f') DAQC.intEnable(0) #enable global interrupts checkpoint = time.time() try: if (checkpoint < time.time()): print "Counter is ", counter storecpm(counter1, counter2) counter1 = 0 counter2 = 0 checkpoint = time.time() + 60