######################################### photogate_check.py ###################################

import sys
mypath=sys.path[0]
if mypath.find('my_python') == -1:       #If true, then "my_python" could not be found
  print "Sorry.  You need to be in my_python for Halverson's program to work."
  print "(That''s because I am assuming that the tgraphlix.py and ezu3.py libraries are there.)"
  exit()
sys.path[0]=mypath[0:mypath.find('my_python')]+'my_python'

print "Use ^C to kill this program"
import u3
from ezu3 import *
from time import sleep
d = u3.U3() # Opens the first LabJackU3 found on the USB
u3setup(d,['ain','ain','ain','ain','dout','dout','dout','dout'])

while True:
  V1=ain0(d)       #Read analog inputs
  V2=ain2(d)       #Analog inputs range from 0 to 2.4 Volts
  s=format(V1,"4.2f")               #Print the value of gate 1 voltage
  print "V1=%s|" % s ,
  for i in range(0,int(5*V1)):      #Print a bunch of spaces then a "1"
    print " ",
  print "1",
  for i in range(0,13-int(5*V1)):   #Pad with blanks
    print " ",
  s=format(V2,"4.2f")               #Print the value of analog input 1
  print "| V2=%s|" % s ,
  for i in range(0,int(5*V2)):      #Print a bunch of spaces then a "2"
    print " ",
  print "2",
  for i in range(0,13-int(5*V2)):   #Pad with blanks
    print " ",
  print "|"
  sleep(0.25)




