Update scripts/runmanager_remote.py
Complete commenting of the code, removed the manual time.sleep, now it relies on waiting for lyse to respond to each shot termination
This commit is contained in:
parent
59741c971b
commit
49bc1ec08a
@ -1,62 +1,62 @@
|
|||||||
from labscript.labscript import labscript_init
|
#this file runs the experiment through runmanager
|
||||||
from runmanager import remote
|
from datetime import datetime
|
||||||
from datetime import datetime
|
import time
|
||||||
import time
|
|
||||||
#from lyse import Run as lyse_run
|
from os import listdir
|
||||||
#from lyse import data as lyse_data
|
|
||||||
from os import listdir
|
#import for labscript
|
||||||
|
from labscript.labscript import labscript_init
|
||||||
|
from runmanager import remote
|
||||||
#from labscript_utils import import_or_reload
|
|
||||||
|
|
||||||
def run_experiment(routine_name, global_var):
|
|
||||||
#import_or_reload('labscriptlib.NNDy_TestSetup.connection_table')
|
def run_experiment(routine_name, global_var):
|
||||||
|
|
||||||
|
hdf_path = f"C:\\Users\\DyLab\\PrepLab\\Experiments\\NNDy_TestSetup\\{routine_name}"
|
||||||
hdf_path = f"C:\\Users\\DyLab\\PrepLab\\Experiments\\NNDy_TestSetup\\{routine_name}"
|
|
||||||
|
#this way it should be loading the routine based on past executions, with the possibility of only changing the global variables
|
||||||
#this way it should be loading the routine based on past executions, with the possibility of only changing the global variables
|
#it's possible that there could be some issue if the script is changed before running MLOOP
|
||||||
#it's possible that there could be some issue if the script is changed before running MLOOP
|
#without further insights on this, it's recommended to always run the sequence once from runmanager GUI before running NNDy
|
||||||
#without further insights on this, it's recommended to always run the sequence from runmanager GUI before initiating MLOOP
|
labscript_init(hdf_path,
|
||||||
labscript_init(hdf_path,
|
new = True)
|
||||||
new = True)
|
|
||||||
|
runmanager_client = remote.Client()
|
||||||
runmanager_client = remote.Client()
|
|
||||||
|
runmanager_client.set_view_shots(False)
|
||||||
runmanager_client.set_view_shots(False)
|
|
||||||
|
runmanager_client.set_globals(global_var)
|
||||||
runmanager_client.set_globals(global_var)
|
#print of all the shot globals
|
||||||
print(f'globals: \n {runmanager_client.get_globals()}')
|
print(f'globals: \n {runmanager_client.get_globals()}')
|
||||||
#print(f'number of shots: \n {runmanager_client.n_shots()}')
|
|
||||||
hdf_path = runmanager_client.get_shot_output_folder()
|
#set the path to the shot that will be created
|
||||||
|
hdf_path = runmanager_client.get_shot_output_folder()
|
||||||
|
|
||||||
runmanager_client.engage()
|
|
||||||
#print('engaged')
|
print(f'engaged, now waiting')
|
||||||
|
runmanager_client.engage()
|
||||||
#change measurement_time accordingly
|
#print('engaged')
|
||||||
# necessary becasuse engage() doesn't block execution
|
|
||||||
measurement_time = global_var['T_wlm'] + global_var['wait_AWG'] + global_var['buffer_time']
|
#NNDy_ will make sure that the script is put on hold until the shot isn't sent to lyse
|
||||||
print(f'now waiting for {measurement_time} s')
|
#ask Jianshun for further info
|
||||||
|
|
||||||
time.sleep(measurement_time)
|
|
||||||
print('waiting time is over')
|
print('waiting time is over')
|
||||||
|
|
||||||
try:
|
#returns and retrieve the hdf5 file of the shot
|
||||||
hdf_files = listdir(hdf_path)
|
|
||||||
if len(hdf_files) == 0:
|
try:
|
||||||
raise ModuleNotFoundError
|
hdf_files = listdir(hdf_path)
|
||||||
else:
|
if len(hdf_files) == 0:
|
||||||
if len(hdf_files) > 1:
|
raise ModuleNotFoundError
|
||||||
raise ImportError
|
else:
|
||||||
hdf_file = hdf_path + "/" + hdf_files[0]
|
if len(hdf_files) > 1:
|
||||||
|
raise ImportError
|
||||||
except (ModuleNotFoundError, ImportError) as e:
|
hdf_file = hdf_path + "/" + hdf_files[0]
|
||||||
raise Error(f'An error has occured while importing from hdf output folder: {e}')
|
|
||||||
|
except (ModuleNotFoundError, ImportError) as e:
|
||||||
#run = lyse_run(hdf_file, no_write=True)
|
raise Error(f'An error has occured while importing from hdf output folder: {e}')
|
||||||
#print(hdf_file)
|
|
||||||
|
|
||||||
return hdf_file
|
return hdf_file
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user