예제 #1
0
def treadmill():
    """
        callable function to be able to start running on a treadmill
    """
    global scanPass, backData
    scanPassScreen("top")
    thread = threading.Thread(target=reader, args=(True, ))
    thread.start()
    scanPass.mainloop()

    cardData = backData
    cardDataDb = ("rfidNumber = '" + str(cardData) + "'")
    backData = ""
    customerID = gD.getDataWhere("customerID", "loginInfo", cardDataDb)

    Treadmill.main(customerID[0][0])
예제 #2
0
def treadmill():
    """
        callable function to be able to start running on a treadmill
    """
    global scanPass, backData
    scanPassScreen("top")
    thread = threading.Thread(target=reader, args=(True,))
    thread.start()
    scanPass.mainloop()

    for i in range(3):
        GPIO.output(ledGreen, True)
        sleep(0.3)
        GPIO.output(ledGreen, False)
        sleep(0.3)
    
    cardData = backData
    cardDataDb = ("rfidNumber = '" + str(cardData) + "'")
    backData = ""
    customerID = gD.getDataWhere("customerID", "loginInfo", cardDataDb)
    
    Treadmill.main(customerID[0][0])
예제 #3
0
    def __init__(self, session_info):
        try:
            # set up the external hard drive path for the flipper output
            self.session_info = session_info
            storage_path = self.session_info[
                'external_storage'] + '/' + self.session_info['basename']
            self.session_info[
                'flipper_filename'] = storage_path + '/' + self.session_info[
                    'basename'] + '_flipper_output'

            # make data directory and initialize logfile
            os.makedirs(session_info['dir_name'])
            os.chdir(session_info['dir_name'])
            session_info['file_basename'] = session_info[
                'dir_name'] + '/' + session_info[
                    'mouse_name'] + "_" + session_info['datetime']
            logging.basicConfig(
                level=logging.INFO,
                format="%(asctime)s.%(msecs)03d,[%(levelname)s],%(message)s",
                datefmt=('%H:%M:%S'),
                handlers=[
                    logging.FileHandler(session_info['file_basename'] +
                                        '.log'),
                    logging.StreamHandler(
                    )  # sends copy of log output to screen
                ])
            logging.info(str(time.time()) + ", behavior_box_initialized")
        except Exception as error_message:
            print("Logging error")
            print(str(error_message))

        from subprocess import check_output
        IP_address = check_output(['hostname', '-I']).decode('ascii')[:-2]
        self.IP_address = IP_address
        IP_address_video_list = list(IP_address)
        IP_address_video_list[-3] = "2"
        self.IP_address_video = "".join(IP_address_video_list)
        ###############################################################################################
        # below are all the pin numbers for Yi's breakout board
        # cue LEDs - setting PWM frequency of 200 Hz
        ###############################################################################################
        self.cueLED1 = BoxLED(22, frequency=200)
        self.cueLED2 = BoxLED(18, frequency=200)
        self.cueLED3 = BoxLED(17, frequency=200)
        self.cueLED4 = BoxLED(14, frequency=200)

        ###############################################################################################
        # digital I/O's - used for cue LED
        # cue for animals
        # DIO 1 and 2 are reserved for the audio board
        ###############################################################################################
        # self.DIO3 = LED(9)  # reserved for vacuum function
        self.DIO4 = LED(10)
        self.DIO5 = LED(11)
        # there is a DIO6, but that is the same pin as the camera strobe

        ###############################################################################################
        # IR detection - for nosepoke
        ###############################################################################################
        self.IR_rx1 = Button(
            5, None,
            True)  # None, True inverts the signal so poke=True, no-poke=False
        self.IR_rx2 = Button(6, None, True)
        self.IR_rx3 = Button(12, None, True)
        self.IR_rx4 = Button(13, None,
                             True)  # (optional, reserved for future use
        self.IR_rx5 = Button(16, None,
                             True)  # (optional, reserved for future use

        # link nosepoke event detections to callbacks
        self.IR_rx1.when_pressed = self.left_IR_entry
        self.IR_rx2.when_pressed = self.center_IR_entry
        self.IR_rx3.when_pressed = self.right_IR_entry
        self.IR_rx1.when_released = self.left_IR_exit
        self.IR_rx2.when_released = self.center_IR_exit
        self.IR_rx3.when_released = self.right_IR_exit

        ###############################################################################################
        # sound: audio board DIO - pins sending TTL to the Tsunami soundboard via SMA connectors
        ###############################################################################################
        # pins originally reserved for the lick detection is now used for audio board TTL input signal
        self.sound1 = LED(26)  # originally lick1
        self.sound2 = LED(27)  # originally lick2
        self.sound3 = LED(15)  # originally lick3

        self.sound4 = LED(23)  # originally DIO1
        self.sound5 = LED(24)  # originally DIO2

        ###############################################################################################
        # flipper strobe signal (previously called camera strobe signal)
        ###############################################################################################
        # previously: self.camera_strobe = Button(4)
        # previously: rising and falling edges are detected and logged in a separate video file
        # initiating flipper object
        try:
            self.flipper = FlipperOutput(self.session_info, pin=4)
        except Exception as error_message:
            print("flipper issue\n")
            print(str(error_message))

        ###############################################################################################
        # visual stimuli
        ###############################################################################################
        try:
            self.visualstim = VisualStim(self.session_info)
        except Exception as error_message:
            print("visualstim issue\n")
            print(str(error_message))

        ###############################################################################################
        # TODO: ADC(Adafruit_ADS1x15)
        ###############################################################################################
        try:
            self.ADC = ADS1x15.ADS1015
        except Exception as error_message:
            print("ADC issue\n")
            print(str(error_message))

        # ###############################################################################################
        # # TODO: treadmill
        # ###############################################################################################
        try:
            self.treadmill = Treadmill.Treadmill(self.session_info)
        except Exception as error_message:
            print("treadmill issue\n")
            print("Ignore following erro if no treadmill is connected: ")
            print(str(error_message))

        ###############################################################################################
        # Keystroke handler
        ###############################################################################################
        try:
            DISPLAYSURF = pygame.display.set_mode((200, 200))
            pygame.display.set_caption(session_info["box_name"])
            print(
                "\nKeystroke handler initiated. In order for keystrokes to register, the pygame window"
            )
            print("must be in the foreground. Keys are as follows:\n")
            print(
                Fore.YELLOW +
                "         1: left poke            2: center poke            3: right poke"
            )
            print(
                "         Q: left lick            W: center lick            E: right lick"
            )
            print(Fore.CYAN +
                  "                       Esc: close key capture window\n" +
                  Style.RESET_ALL)
            print(
                Fore.GREEN + Style.BRIGHT +
                "         TO EXIT, CLICK THE MAIN TEXT WINDOW AND PRESS CTRL-C "
                + Fore.RED + "ONCE\n" + Style.RESET_ALL)

            self.keyboard_active = True
        except Exception as error_message:
            print("pygame issue\n")
            print(str(error_message))
예제 #4
0
def treadmill():
    """
        callable function to be able to start running on a treadmill
    """
    #basicWindow("treadmill")
    Treadmill.main()
예제 #5
0
def treadmill():
    """
        callable function to be able to start running on a treadmill
    """
    #basicWindow("treadmill")
    Treadmill.main()