Ejemplo n.º 1
0
def temporal(systemlist, paralist, unparalist, pinlist):
    if unparalist[0] == 0 or time.time() - systemlist[2] >= unparalist[1]:
        exit(systemlist[0], systemlist[1])
    # deliver food
    arduino.c_food("deliver", systemlist[0], pinlist[2], systemlist[1])
    # delay for the duration of US
    arduino.c_delay(paralist[1], systemlist[1])
    # remove food
    arduino.c_food("remove", systemlist[0], pinlist[2], systemlist[1])
    # delay for the paralist[3]-trial interval
    arduino.c_delay(paralist[3], systemlist[1])
    unparalist[0] -= 1
    # if the amount has not matched the requirement, call the function for this mode again
    temporal(systemlist, paralist, unparalist, pinlist)
Ejemplo n.º 2
0
def temporal(systemlist,paralist,unparalist,pinlist):
	if unparalist[0] == 0 or time.time() - systemlist[2] >= unparalist[1]:
		exit(systemlist[0], systemlist[1])
	# deliver food
	arduino.c_food("deliver",systemlist[0],pinlist[2],systemlist[1])
	# delay for the duration of US
	arduino.c_delay(paralist[1],systemlist[1])
	# remove food
	arduino.c_food("remove",systemlist[0],pinlist[2],systemlist[1])
	# delay for the paralist[3]-trial interval
	arduino.c_delay(paralist[3],systemlist[1])
	unparalist[0] -= 1	
	# if the amount has not matched the requirement, call the function for this mode again
	temporal(systemlist,paralist,unparalist,pinlist)
Ejemplo n.º 3
0
def temporal(t,dur_u,inter):
    global i2
    
    # deliver food
    arduino.food("deliver",board,servoPin,top)
    # delay for the duration of US
    arduino.c_delay(dur_u,top)
    # remove food
    arduino.food("remove",board,servoPin,top)  
    # delay for the inter-trial interval
    arduino.c_delay(inter,top)
        
    i2 += 1 # increase the number of trials    
    # if the amount has not matched the requirement, call the function for this mode again
    if i2 <= t:
        temporal(t,dur_u,inter)
Ejemplo n.º 4
0
def forward (t,dur_c,dur_u,btw,inter,r,g):
    global i1 
    
    # if there is no overlap between CS and US
    if btw>=0:  
        # turn on CS
        arduino.cs(g,r)
        # delay for the duration of CS
        arduino.c_delay(dur_c,top)
        # turn off CS
        arduino.cs(0,0)        
        # delay for the interval between CS and US
        arduino.c_delay(btw,top)
        # deliver food
        arduino.food("delive",board,servoPin,top)
        # delay for the duration of US
        arduino.c_delay(dur_u,top)
        # remove food
        arduino.food("remove",board,servoPin,top)
        # delay for the inter-trial interval
        arduino.c_delay(inter,top)
        
        i1 += 1 # increase the number of trails
        # if the amount has not matched the requirement, call the function for this mode again
        if i1 <= t:
            forward (t,dur_c,dur_u,btw,inter,r,g)
            
    # if there is overlap between CS and US
    else:
        # If CS is gone before US
        if -1*btw<=dur_u: # -1 due to the negative value for overlap
            # turn on CS
            arduino.cs(g,r)
            # delay for the time until US is supposed to present
            arduino.c_delay(dur_c+btw,top)
            # deliver food
            arduino.food("deliver",board,servoPin,top)
            # delay for the time until the overlap of CS has passed,
            # i.e., the interval between CS and US
            arduino.c_delay(-1*btw,top)
            # turn off CS
            arduino.cs(0,0)
            # delay for the time until the duration of it has been fulfilled
            arduino.c_delay(btw+dur_u,top)
            # remove food
            arduino.food("remove",board,servoPin,top)
            # delay for the inter-trial interval
            arduino.c_delay(inter,top)
        
            i1 += 1 # increase the number of trails
            # if the amount has not matched the requirement, call the function for this mode again
            if i1 <= t:
                forward (t,dur_c,dur_u,btw,inter,r,g)
        
        # cs is gone after us
        else: 
            # turn on CS
            arduino.cs(g,r)
            # delay until US is supposed to present
            arduino.c_delay(dur_c+btw,top)
            # deliver food
            arduino.food("deliver",board,servoPin,top)
            # delay for the duration of US
            arduino.c_delay(dur_u,top)
            # remove food
            arduino.food("remove",board,servoPin,top)
            # delay until fulfill the duration of CS
            arduino.c_delay(dur_c+btw-dur_u,top)
            # turn off CS
            arduino.cs(0,0)
            # delay for the inter-trial interval
            arduino.c_delay(inter,top)
        
            i1 += 1 # increase the number of trails
            # if the amount has not matched the requirement, call the function for this mode again
            if i1 <= t:
                forward (t,dur_c,dur_u,btw,inter,r,g)
Ejemplo n.º 5
0
def blocking(systemlist, paralist, unparalist, pinlist):
    if unparalist[0] == 0 or time.time() - systemlist[2] >= unparalist[1]:
        exit(systemlist[0], systemlist[1])
    # if there is no overlap between CS and US
    if paralist[2] >= 0:
        # turn on CS
        arduino.cs(pinlist[0], 1)
        arduino.cs(pinlist[1], 1)
        # delay for the duration of CS
        arduino.c_delay(paralist[0], systemlist[1])
        # turn off CS
        arduino.cs(pinlist[0], 0)
        arduino.cs(pinlist[1], 0)
        # delay for the interval between CS and US
        arduino.c_delay(paralist[2], systemlist[1])
        # deliver food
        arduino.c_food("deliver", systemlist[0], pinlist[2], systemlist[1])
        # delay for the duration of US
        arduino.c_delay(paralist[1], systemlist[1])
        # remove food
        arduino.c_food("remove", systemlist[0], pinlist[2], systemlist[1])
        # delay for the paralist[3]-trial interval
        arduino.c_delay(paralist[3], systemlist[1])
        unparalist[0] -= 1
        # if the amount has not matched the requirement, call the function for this mode again
        blocking(systemlist, paralist, unparalist, pinlist)

    # if there is overlap between CS and US
    else:
        # If CS is gone before US
        if -1 * paralist[2] <= paralist[
                1]:  # -1 due to the negative value for overlap
            # turn on CS
            arduino.cs(pinlist[0], 1)
            arduino.cs(pinlist[1], 1)
            # delay for the time until US is supposed to present
            arduino.c_delay(paralist[0] + paralist[2], systemlist[1])
            # deliver food
            arduino.c_food("deliver", systemlist[0], pinlist[2], systemlist[1])
            # delay for the time until the overlap of CS has passed,
            # i.e., the interval between CS and US
            arduino.c_delay(-1 * paralist[2], systemlist[1])
            # turn off CS
            arduino.cs(pinlist[0], 0)
            arduino.cs(pinlist[1], 0)
            # delay for the time until the duration of it has been fulfilled
            arduino.c_delay(paralist[2] + paralist[1], systemlist[1])
            # remove food
            arduino.c_food("remove", systemlist[0], pinlist[2], systemlist[1])
            # delay for the paralist[3]-trial interval
            arduino.c_delay(paralist[3], systemlist[1])
            unparalist[0] -= 1
            # if the amount has not matched the requirement, call the function for this mode again
            blocking(systemlist, paralist, unparalist, pinlist)

        # cs is gone after us
        else:
            # turn on CS
            arduino.cs(pinlist[0], 1)
            arduino.cs(paralist[1], 1)
            # delay until US is supposed to present
            arduino.c_delay(paralist[0] + paralist[2], systemlist[1])
            # deliver food
            arduino.c_food("deliver", systemlist[0], pinlist[2], systemlist[1])
            # delay for the duration of US
            arduino.c_delay(paralist[1], systemlist[1])
            # remove food
            arduino.c_food("remove", systemlist[0], pinlist[2], systemlist[1])
            # delay until fulfill the duration of CS
            arduino.c_delay(paralist[0] + paralist[2] - paralist[1],
                            systemlist[1])
            # turn off CS
            arduino.cs(pinlist[0], 0)
            arduino.cs(pinlist[1], 0)
            # delay for the paralist[3]-trial interval
            arduino.c_delay(paralist[3], systemlist[1])
            unparalist[0] -= 1
            # if the amount has not matched the requirement, call the function for this mode again
            forward(systemlist, paralist, unparalist, pinlist)
Ejemplo n.º 6
0
def blocking(systemlist,paralist,unparalist,pinlist):
	if unparalist[0] == 0 or time.time() - systemlist[2] >= unparalist[1]:
		exit(systemlist[0], systemlist[1])
	# if there is no overlap between CS and US
	if paralist[2]>=0:
		# turn on CS
		arduino.cs(pinlist[0],1)
		arduino.cs(pinlist[1],1)
		# delay for the duration of CS
		arduino.c_delay(paralist[0],systemlist[1])
		# turn off CS
		arduino.cs(pinlist[0],0)
		arduino.cs(pinlist[1],0)	
		# delay for the interval between CS and US
		arduino.c_delay(paralist[2],systemlist[1])
		# deliver food
		arduino.c_food("deliver",systemlist[0],pinlist[2],systemlist[1])
		# delay for the duration of US
		arduino.c_delay(paralist[1],systemlist[1])
		# remove food
		arduino.c_food("remove",systemlist[0],pinlist[2],systemlist[1])
		# delay for the paralist[3]-trial interval
		arduino.c_delay(paralist[3],systemlist[1])
		unparalist[0] -= 1
		# if the amount has not matched the requirement, call the function for this mode again
		blocking (systemlist,paralist,unparalist,pinlist)
			
	# if there is overlap between CS and US
	else:
		# If CS is gone before US
		if -1*paralist[2]<=paralist[1]: # -1 due to the negative value for overlap
			# turn on CS
			arduino.cs(pinlist[0],1)
			arduino.cs(pinlist[1],1)
			# delay for the time until US is supposed to present
			arduino.c_delay(paralist[0]+paralist[2],systemlist[1])
			# deliver food
			arduino.c_food("deliver",systemlist[0],pinlist[2],systemlist[1])
			# delay for the time until the overlap of CS has passed,
			# i.e., the interval between CS and US
			arduino.c_delay(-1*paralist[2],systemlist[1])
			# turn off CS
			arduino.cs(pinlist[0],0)
			arduino.cs(pinlist[1],0)
			# delay for the time until the duration of it has been fulfilled
			arduino.c_delay(paralist[2]+paralist[1],systemlist[1])
			# remove food
			arduino.c_food("remove",systemlist[0],pinlist[2],systemlist[1])
			# delay for the paralist[3]-trial interval
			arduino.c_delay(paralist[3],systemlist[1])
			unparalist[0] -= 1
			# if the amount has not matched the requirement, call the function for this mode again
			blocking (systemlist,paralist,unparalist,pinlist)
		
		# cs is gone after us
		else: 
			# turn on CS
			arduino.cs(pinlist[0],1)
			arduino.cs(paralist[1],1)
			# delay until US is supposed to present
			arduino.c_delay(paralist[0]+paralist[2],systemlist[1])
			# deliver food
			arduino.c_food("deliver",systemlist[0],pinlist[2],systemlist[1])
			# delay for the duration of US
			arduino.c_delay(paralist[1],systemlist[1])
			# remove food
			arduino.c_food("remove",systemlist[0],pinlist[2],systemlist[1])
			# delay until fulfill the duration of CS
			arduino.c_delay(paralist[0]+paralist[2]-paralist[1],systemlist[1])
			# turn off CS
			arduino.cs(pinlist[0],0)
			arduino.cs(pinlist[1],0)
			# delay for the paralist[3]-trial interval
			arduino.c_delay(paralist[3],systemlist[1])
			unparalist[0] -= 1
			# if the amount has not matched the requirement, call the function for this mode again
			forward (systemlist,paralist,unparalist,pinlist)