Changeset 628 in ETALON
- Timestamp:
- Dec 7, 2016, 11:05:28 AM (8 years ago)
- Location:
- CLIO/control
- Files:
-
- 3 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
CLIO/control/clio_constants.py
r627 r628 2 2 3 3 global data_dir 4 data_dir='/Users/delerue/travail/smith-purcell/SPARC/data/201507/' 4 #data_dir="C:\\CLIO\\data\\20161201\\" 5 data_dir="/Users/delerue/Downloads/CLIO/" 5 6 6 #SCOPE_IP='192.168.197.145'7 SCOPE _IP='10.0.1.112'7 SCOPE1_IP='129.175.202.193' 8 SCOPE2_IP='129.175.202.14' 8 9 9 10 global motor_controller_IP 10 11 global motor_controller_port 11 motor_controller_IP='1 0.0.1.160'12 motor_controller_IP='129.175.202.187' 12 13 motor_controller_port=30000 13 14 … … 22 23 23 24 24 CAMERA_1_PORT='1 0.0.1.130:80'25 CAMERA_2_PORT='1 0.0.1.132:80'25 CAMERA_1_PORT='129.175.202.189:80' 26 CAMERA_2_PORT='129.175.202.190:80' 26 27 CAMERAS_PORT=[CAMERA_1_PORT, CAMERA_2_PORT] 27 28 -
CLIO/control/initialise_motors.py
r627 r628 28 28 "Writes a formatted message to a motor" 29 29 if (len(message) <= 12): 30 print 'Message length ', len(message), ' >', message, '<'30 print('Message length ', len(message), ' >', message, '<') 31 31 while len(message) < 12: 32 32 message += '0' … … 35 35 else: 36 36 if verbose == 1: 37 print 'Command too long'37 print('Command too long') 38 38 return 'Command too long' 39 39 … … 112 112 if (param == 'velocity'): 113 113 velocity = motor_send(motor + 'QV') 114 print(velocity) 114 115 velo=float(velocity[3:12]) 115 print velo116 print(velo) 116 117 return velo 117 118 elif (param == 'acceleration'): … … 212 213 213 214 def controller_hello(): 214 "Sends ça_va query to the motor and display reply"215 "Sends ca_va query to the motor and display reply" 215 216 # write_to_motor("ça_va?",1) 216 217 ret=write_to_motor(chr(231) + "a_va?", 1) -
CLIO/control/motor_function.py
r627 r628 32 32 motor_get(2,"actual_position") 33 33 lim=motor_get(2,"limit") 34 print lim34 print(lim) 35 35 return lim 36 36 … … 38 38 def table_to_mm_from_back(pos): 39 39 motor_enable(2) 40 print "BACK_LIMIT ", BACK_LIMIT40 print("BACK_LIMIT ", BACK_LIMIT) 41 41 target_pos=(pos*STEPS_TO_MM)+BACK_LIMIT 42 print target_pos42 print(target_pos) 43 43 move_motor_absolute(2,2000,target_pos) 44 44 motor_wait_for_ready(2) … … 72 72 get_out_of_limit() 73 73 BACK_LIMIT=motor_get(2,"actual_position") 74 print "BACK_LIMIT ", BACK_LIMIT74 print("BACK_LIMIT ", BACK_LIMIT) 75 75 table_to_mm_from_back(1) 76 76 … … 80 80 for icam in range(3): 81 81 if (CAMERAS_ON[icam]==1): 82 print icam,CAMERAS_ON[icam],CAMERAS_PORT[icam]82 print(icam,CAMERAS_ON[icam],CAMERAS_PORT[icam]) 83 83 image_name_and_path=data_dir+"camera_image_"+start_time_str+"_"+str(icam)+".png" 84 84 camera_image_url="http://"+CAMERAS_PORT[icam]+"/jpg/image.jpg" 85 print "camera_image_url ",camera_image_url," ",image_name_and_path85 print("camera_image_url ",camera_image_url," ",image_name_and_path) 86 86 urllib.urlretrieve(camera_image_url,image_name_and_path) 87 87 if (show==1): -
CLIO/control/scope_function.py
r627 r628 5 5 import time 6 6 import urllib 7 import sys 7 8 from datetime import datetime 8 9 from clio_constants import * 9 10 from writeclient import writeclient 10 11 11 scope_image_url="http://"+SCOPE_IP+"/crt_print.png" 12 scope1_image_url="http://"+SCOPE1_IP+"/crt_print.png" 13 scope1_ch1_url="http://"+SCOPE1_IP+"/scpi_response.txt?lang=en&request=CHAN1:STAT ON" 14 scope1_ch2_url="http://"+SCOPE1_IP+"/scpi_response.txt?lang=en&request=CHAN2:STAT ON" 15 scope1_ch3_url="http://"+SCOPE1_IP+"/scpi_response.txt?lang=en&request=CHAN3:STAT ON" 16 scope1_ch4_url="http://"+SCOPE1_IP+"/scpi_response.txt?lang=en&request=CHAN4:STAT ON" 17 scope1_data_url="http://"+SCOPE1_IP+"/chaninfo.txt?lang=en&trace=0&source=0&format=1&points=0&button=save" 18 19 scope2_image_url="http://"+SCOPE2_IP+"/Image.png" 20 scope2_data_ch1_url="http://"+SCOPE2_IP+"/data/comm.html?command=select%3Acontrol+ch1&command=save%3Awaveform%3Afileformat%20spreadsheet&wfmsend=GET" 21 scope2_data_ch2_url="http://"+SCOPE2_IP+"/data/comm.html?command=select%3Acontrol+ch2&command=save%3Awaveform%3Afileformat%20spreadsheet&wfmsend=GET" 22 scope2_data_ch3_url="http://"+SCOPE2_IP+"/data/comm.html?command=select%3Acontrol+ch3&command=save%3Awaveform%3Afileformat%20spreadsheet&wfmsend=GET" 23 scope2_data_ch4_url="http://"+SCOPE2_IP+"/data/comm.html?command=select%3Acontrol+ch4&command=save%3Awaveform%3Afileformat%20spreadsheet&wfmsend=GET" 24 12 25 13 26 14 27 def read_images_from_scope(nimages): 28 print(" Acquiring images...") 29 for iimage in range(nimages): 30 read_images_from_scope1(1) 31 read_images_from_scope2(1) 32 33 34 def read_images_from_scope1(nimages): 15 35 iimage=1 16 36 subproc=0 17 37 start_time_str=datetime.now().strftime("%Y%m%d_%H%M%S") 18 38 for iimage in range(nimages): 19 image_name_and_path=data_dir+"scope_image_"+start_time_str+"_"+str(iimage)+".png" 20 urllib.urlretrieve(scope_image_url,image_name_and_path) 21 if (subproc !=0): 22 subproc.kill() 23 subproc = subprocess.Popen(["display",image_name_and_path]) 24 time.sleep(2) 25 time.sleep(10) 26 if (subproc !=0): 27 subproc.kill() 39 image_name_and_path=data_dir+"scope1_image_"+start_time_str+"_"+str(iimage)+".png" 40 print(' image:' , image_name_and_path) 41 urllib.urlretrieve(scope1_image_url,image_name_and_path) 42 43 data_name_ch1_and_path=data_dir+"scope1_data_ch1_"+start_time_str+"_"+str(iimage)+".csv" 44 print(scope1_ch1_url) 45 txt=urllib.urlopen(scope1_ch1_url) 46 print(scope1_data_url) 47 urllib.urlretrieve(scope1_data_url,data_name_ch1_and_path) 48 49 data_name_ch2_and_path=data_dir+"scope1_data_ch2_"+start_time_str+"_"+str(iimage)+".csv" 50 print(scope1_ch2_url) 51 txt=urllib.urlopen(scope1_ch2_url) 52 print(scope1_data_url) 53 urllib.urlretrieve(scope1_data_url,data_name_ch2_and_path) 54 55 data_name_ch3_and_path=data_dir+"scope1_data_ch3_"+start_time_str+"_"+str(iimage)+".csv" 56 print(scope1_ch3_url) 57 txt=urllib.urlopen(scope1_ch3_url) 58 print(scope1_data_url) 59 urllib.urlretrieve(scope1_data_url,data_name_ch3_and_path) 60 61 data_name_ch4_and_path=data_dir+"scope1_data_ch4_"+start_time_str+"_"+str(iimage)+".csv" 62 print(scope1_ch4_url) 63 txt=urllib.urlopen(scope1_ch4_url) 64 print(scope1_data_url) 65 urllib.urlretrieve(scope1_data_url,data_name_ch4_and_path) 66 # if (subproc !=0): 67 # subproc.kill() 68 #subproc = subprocess.Popen(["display",image_name_and_path]) 69 time.sleep(5) 70 time.sleep(1) 71 # if (subproc !=0): 72 # subproc.kill() 28 73 29 74 30 def scpi_command(command): 31 reply=writeclient(SCOPE_IP,5025,command+chr(10),1) 32 print "SCPI: ",command," => ", reply 75 def read_images_from_scope2(nimages): 76 iimage=1 77 subproc=0 78 start_time_str=datetime.now().strftime("%Y%m%d_%H%M%S") 79 for iimage in range(nimages): 80 image_name_and_path=data_dir+"scope2_image_"+start_time_str+"_"+str(iimage)+".png" 81 print(' image:' , image_name_and_path) 82 try: 83 urllib.urlretrieve(scope2_image_url,image_name_and_path) 84 except: 85 print(" Error: ",sys.exc_info()[0]) 86 # if (subproc !=0): 87 # subproc.kill() 88 #subproc = subprocess.Popen(["display",image_name_and_path]) 89 time.sleep(2) 90 try: 91 data_name_ch1_and_path=data_dir+"scope2_data_ch1_"+start_time_str+"_"+str(iimage)+".csv" 92 print(scope2_data_ch1_url) 93 urllib.urlretrieve(scope2_data_ch1_url,data_name_ch1_and_path) 94 except: 95 print(" Error: ",sys.exc_info()[0]) 96 time.sleep(2) 97 98 try: 99 data_name_ch2_and_path=data_dir+"scope2_data_ch2_"+start_time_str+"_"+str(iimage)+".csv" 100 print(scope2_data_ch2_url) 101 urllib.urlretrieve(scope2_data_ch1_url,data_name_ch2_and_path) 102 except: 103 print(" Error: ",sys.exc_info()[0]) 104 time.sleep(2) 105 106 try: 107 data_name_ch3_and_path=data_dir+"scope2_data_ch3_"+start_time_str+"_"+str(iimage)+".csv" 108 print(scope2_data_ch3_url) 109 urllib.urlretrieve(scope2_data_ch3_url,data_name_ch3_and_path) 110 except: 111 print(" Error: ",sys.exc_info()[0]) 112 time.sleep(2) 113 114 try: 115 data_name_ch4_and_path=data_dir+"scope2_data_ch4_"+start_time_str+"_"+str(iimage)+".csv" 116 print(scope2_data_ch4_url) 117 urllib.urlretrieve(scope2_data_ch4_url,data_name_ch4_and_path) 118 except: 119 print(" Error: ",sys.exc_info()[0]) 120 time.sleep(2) 121 122 time.sleep(1) 123 # if (subproc !=0): 124 # subproc.kill() 125 126 127 def scpi_command1(command): 128 reply=writeclient(SCOPE1_IP,5025,command+chr(10),1) 129 print("SCPI: ",command," => ", reply) 130 131 def scpi_command2(command): 132 reply=writeclient(SCOPE2_IP,5025,command+chr(10),1) 133 print("SCPI: ",command," => ", reply) -
CLIO/control/test.py
r627 r628 1 1 __author__ = 'delerue' 2 2 3 3 import sys 4 4 from clio_constants import * 5 5 from motor_function import * 6 6 from scope_function import * 7 7 8 9 controller_hello() 10 11 motor_reset(1) 12 motor_enable(1) 13 motor_move_absolute(1,20,000) 14 motor_wait_for_ready(1) 15 read_images_from_scope(5) 16 17 motor_move_absolute(1,20,-50) 18 motor_wait_for_ready(1) 19 read_images_from_scope(5) 20 21 motor_move_absolute(1,20,000) 22 motor_wait_for_ready(1) 23 read_images_from_scope(5) 24 25 motor_disable(1) 26 27 read_images_from_scope(5) 8 read_images_from_scope(2) 28 9 29 10 30 scpi_command("*IDN?") 31 scpi_command("TIMEbase:SCALE?") 11 #motor_set(1,' velocity', 5000) 12 #motor_wait_for_ready(1) 13 #read_images_from_scope(5) 14 15 #motor_move_absolute(1,20,-50) 16 #read_images_from_scope(5) 17 18 #motor_move_absolute(1,20,000) 19 #motor_wait_for_ready(1) 20 #read_images_from_scope(5) 32 21 33 22 34 #motor_disable(1) 35 #tranlation_in_mm(-1) 36 37 #motor_reset(1) 38 #motor_enable(1) 39 #motor_move_relative(1,2000,50000) 40 #motor_wait_for_ready(1) 41 #motor_move_absolute(1,20,000) 42 #motor_wait_for_ready(1) 43 #motor_move_absolute(1,20,500) 44 #motor_wait_for_ready(1) 45 #motor_disable(1) 46 47 #get_out_of_limit() 48 49 get_camera_images(show=1) 50 51 #table_to_mm_from_back(1) 52 #grating_big_p05() 53 #time.sleep(20) 54 #grating_big_blank() 55 #time.sleep(20) 56 #grating_small_p1() 57 #time.sleep(20) 58 #grating_small_blank() 59 #time.sleep(20) 60 #grating_small_p1() 61 62 63 #read_image("/Users/delerue/Downloads/test.png") 64 #read_images_from_scope(3) 65 66 67 #read_encoder() 68 #init_encoder_ref_pos() 69 #check_encoder_constistency() 70 #monitor_encoder_consistency() 23 #read_images_from_scope(1) 71 24 72 25 73 26 #scpi_command("*IDN?") 27 #scpi_command("TIMEbase:SCALE 1e-6") 74 28 #scpi_command("TIMEbase:SCALE?") 75 29 76 #writeclient('192.168.0.21',80,'GET /'+chr(10),1)77 #writeclient('192.168.0.22',5025,'*IDN?'+chr(10),1)78 #writeclient(SCOPE_IP,5025,'*IDN?'+chr(10),1) -
CLIO/control/writeclient.py
r627 r628 12 12 s.connect((HOST, PORT)) 13 13 if (verbose==1): 14 print 'Sending message ', msg, ' to host ', HOST, ' on port ', PORT14 print('Sending message ', msg, ' to host ', HOST, ' on port ', PORT) 15 15 if (datedlog!=''): 16 16 date_str=datetime.now().strftime("_%Y%m%d") … … 29 29 f.close() 30 30 if (verbose==1): 31 print 'Received', repr(data)31 print('Received', repr(data)) 32 32 return data 33 33
Note: See TracChangeset
for help on using the changeset viewer.