def gettempProc(conn): #ptvsd.enable_attach(None) #ptvsd.wait_for_attach() p = current_process() print(('Starting:', p.name, p.pid)) if not tempSensorId == "None": myTempSensor = Temp1Wire.Temp1Wire(tempSensorId) while True: t = time.time() time.sleep(1.91) num = myTempSensor.readTempC() elapsed = "%.2f" % (time.time() - t) conn.send([num, elapsed]) if not tempSensorPin == "None": myADC = mcp3208.mcp3208(tempSensorPin) while True: t = time.time() time.sleep(1.91) num = myADC.temp_get() elapsed = "%.2f" % (time.time() - t) conn.send([num, elapsed])
# Write data data_file = open(fileName, 'a') # open file in append mode data_file.write( str(currentTime) + "," + str(LED_state) + "," + str(leverL) + "," + str(nose) + "," + str(threshold) + "," + str(lever_obj.get_h_pos()) + "," + str(lever_obj.get_v_pos()) + "," + str(success) + "," + str(ITI_time) + "\n") #print "Lever: %i\tNose: %i" % last_arena_pos data_file.close() #################### # Main program loop #################### # Initialize lever and nose sensors adc1 = mcp3208.mcp3208(0) adc2 = mcp3208.mcp3208(1) # Set initial position of lever/nose sensors last_arena_pos = (adc1.readChannel(lever_ch1), adc1.readChannel(nose_ch)) print " \tLed State Initially: %i" % (LED_state) "Some easy trials to start with -Nose spoke trials" while successes < nb_nose_poke: currentTime = time.time() success = 0 leverL = adc1.readChannel(lever_ch1) nose = adc1.readChannel(nose_ch)