Example #1
0
 def __init__(self, loginVo, sensorName):
     logger.info('ProcessLedGreen init')
     self.loginVo = loginVo
     self.sensorName = sensorName
     DAQC.clrLED(0, 0)
     DAQC.clrLED(0, 1)
     DAQC.enableSWint(0)
     DAQC.intEnable(0)
     self.ledColor = 'green'
     self.btnPressed = '0'
Example #2
0
def clr_all():
    DAQC.clrLED(0, 0)
    DAQC.clrLED(0, 1)
    DAQC.clrDOUTbit(0, 0)
    DAQC.clrDOUTbit(0, 1)
    DAQC.clrDOUTbit(0, 2)
    DAQC.clrDOUTbit(0, 3)
    DAQC.clrDOUTbit(0, 4)
    DAQC.clrDOUTbit(0, 5)
    DAQC.clrDOUTbit(0, 6)
    print("\r\n")
Example #3
0
    def run(self, *args):
        logger.info("BlinkLedThread run start")

        while True:
            if self.isShutdown:
                break
            for i in range(0, 100):
                DAQC.clrLED(self.daqcBoard, 0)
                DAQC.clrLED(self.daqcBoard, 1)
            time.sleep(.25)
            for i in range(0, 100):
                DAQC.setLED(self.daqcBoard, self.led)
            time.sleep(.25)
        for i in range(0, 100):
            DAQC.clrLED(self.daqcBoard, 0)
            DAQC.clrLED(self.daqcBoard, 1)
Example #4
0
 def handleIote2eResult(self, iote2eResult):
     logger.info('ProcessLedGreen handleIote2eResult: ' + str(iote2eResult))
     actuatorValue = iote2eResult.pairs['actuatorValue']
     logger.info('actuatorValue {}'.format(actuatorValue))
     if self.ledColor == 'green':
         logger.info('set led green')
         for i in range(0, 100):
             DAQC.clrLED(0, 0)
             DAQC.clrLED(0, 1)
         #time.sleep(.25)
         for i in range(0, 100):
             DAQC.setLED(0, 1)
         self.ledColor = 'red'
     elif self.ledColor == 'red':
         logger.info('set led red')
         for i in range(0, 100):
             DAQC.clrLED(0, 0)
             DAQC.clrLED(0, 1)
         #time.sleep(.25)
         for i in range(0, 100):
             DAQC.setLED(0, 0)
         self.ledColor = 'green'
Example #5
0
def leds():
    DAQC.enableSWint(0)
    DAQC.intEnable(0)
    while True:
        DAQC.setLED(0, 0)
        if DAQC.getINTflags(0) == 256:
            break
        time.sleep(.25)
        if DAQC.getINTflags(0) == 256:
            break
        DAQC.clrLED(0, 0)
        if DAQC.getINTflags(0) == 256:
            break
        time.sleep(.25)
        if DAQC.getINTflags(0) == 256:
            break
    for i in range(0, 100):
        DAQC.clrLED(0, 0)
        DAQC.clrLED(0, 1)
Example #6
0
            elif (cmd == "setPWM"):
                channel = args['channel']
                value = args['value']
                PP.setPWM(addr, channel, value)
                resp['channel'] = channel
                resp['value'] = value
            elif (cmd == "calDAC"):
                PP.calDAC(addr)
            elif (cmd == "getFREQ" and plate_type == "DAQC2"):
                value = DP2.getFREQ(addr)
                resp['value'] = value
            elif (cmd == "setLED" and plate_type == "DAQC"):
                color = args['color']

                if color == 'off':
                    DP.clrLED(addr, 0)
                    DP.clrLED(addr, 1)
                elif color == 'red':
                    DP.setLED(addr, 0)
                    DP.clrLED(addr, 1)
                elif color == 'green':
                    DP.clrLED(addr, 0)
                    DP.setLED(addr, 1)
                elif color == 'yellow':
                    DP.setLED(addr, 0)
                    DP.setLED(addr, 1)
                else:
                    sys.stderr.write("unsupported LED color: " + color)

                resp['color'] = color
            elif (cmd == "setLED" and plate_type == "DAQC2"):
Example #7
0
def blink_green():
    DAQC.setLED(0, 1)
    sleep(0.05)
    DAQC.clrLED(0, 1)
    sleep(0.05)
Example #8
0
def blink_red():
    DAQC.setLED(0, 0)
    sleep(0.05)
    DAQC.clrLED(0, 0)
    sleep(0.05)
# GPIO event detection must be set up AFTER clearing DAQC interrupt flag
GPIO.setmode(GPIO.BCM)
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.add_event_detect(22, GPIO.FALLING, callback=sample)
DAQC.getINTflags(0)

# set up BME280
sensor = BME280(mode=BME280_OSAMPLE_8)

try:
    while (1):
        # wait for button
        DAQC.setLED(0, 0)
        time.sleep(0.5)
        DAQC.clrLED(0, 0)
        time.sleep(0.5)

except KeyboardInterrupt:
    DAQC.clrLED(0, 0)
    GPIO.cleanup()

    # set filename
    archive_time = time.ctime()
    archive_time = archive_time.replace(' ', '_')
    computer_name = socket.gethostname()
    filename = ('../../data/output/atmo_data_' + computer_name + '.pkl')
    if os.path.isfile(filename):
        backup = ('../../data/output/atmo_data_' + computer_name + '_' +
                  archive_time + '.pkl')
        os.rename(filename, backup)