diff --git a/hp4155/Custom_SMU/lib/help.py b/hp4155/Custom_SMU/lib/help.py index db79fc9b17de8f601c7791b57313c42a437b7f29..dcdeef37d5389d80075932bd263f8d7ad66767ee 100644 --- a/hp4155/Custom_SMU/lib/help.py +++ b/hp4155/Custom_SMU/lib/help.py @@ -1,3 +1,5 @@ +import tkinter as tk +import tkinter.messagebox # Check the functionalities of smus VAR1,VAR2 and VARD def check_sweep_func(smus:list,func:str): @@ -29,4 +31,90 @@ def setup_axes(axes_info:list,device): if ax_plot == 'Y2' and ax_info['name'] == "": # Y2 axis can be empty pass else: - device.display_variable() \ No newline at end of file + device.display_variable(ax_plot,ax_info['name']) + device.axis_scale(ax_plot,ax_info['scale']) + device.display_variable_min_max(ax_plot,'MIN',ax_info['min']) + device.display_variable_min_max(ax_plot,'MAX',ax_info['max']) + + +# Find unit of a variable +def find_unit(variable,smus,user_functions): + + #firstly search over the names of the smus + + for smu in smus: + if variable == smu['vname']: + return 'V' + elif variable== smu['iname']: + return 'A' + else: + pass + + # Secondly search over the user functions + for user_function in user_functions: + if variable == user_function['name']: + return user_function['unit'] + + return "" + +# Setup the variables to be saved +def save_variables(smus,user_functions,axes,variables,device): + + # condition number one: the plotted variables need to be saved in the file + + # Retrieve the names of the variables + variable_names =[] + for variable in variables: + variable_names.append(variable['name']) + + # Retrieve the axes names (variable) + axes_names=[] + for ax in axes: + axes_names.append(ax['name']) + + # Now Check if axes names are in the variable names + for ax_name in axes_names: + index = 7 + if ax_name not in variable_names: + variables[index]['name'] = ax_name + variables[index]['unit'] = find_unit(ax_name,smus,user_functions) + index = index-1 + + # Now save the variables + variable_names =[] + for variable in variables: + if variable['name'] != "": # Empty + variable_names.append(variable['name']) + + # Send the command to tool + device.variables_to_save(variable_names) + + # Return the new variables dictionary + return variables + +def error_box(information): + #open dialog and hide the main window + root = tk.Tk() + root.withdraw() + root.lift() #show window above all other applications + + root.attributes("-topmost", True)#window stays above all other applications + + #display meaagebox + tkinter.messagebox.showerror(message=information) + root.destroy() + +def information_box(information): + #open dialog and hide the main window + root = tk.Tk() + root.withdraw() + root.lift() #show window above all other applications + + root.attributes("-topmost", True)#window stays above all other applications + + #display meaagebox + tkinter.messagebox.showinfo(message=information) + root.destroy() + + + \ No newline at end of file diff --git a/hp4155/Custom_SMU/main.py b/hp4155/Custom_SMU/main.py index a1c8010238c4ef48e597c7de1fc58e8af105ff65..310667cc5bdf05da801624bb72163c9961f74c63 100644 --- a/hp4155/Custom_SMU/main.py +++ b/hp4155/Custom_SMU/main.py @@ -3,6 +3,7 @@ sys.path.insert(0, './lib') sys.path.insert(0, '..') #append parent directory from interface import * +from help import * import hp4155a first_page = page_1() @@ -177,9 +178,33 @@ def on_start_clicked(b): device.setup_cons_smu(i+1,cons_smu) # Now set the axes - # Set X-axis - device.display_variable('X',axes[0]['name']) - device.axis_scale('') + setup_axes(axes,device) + + # Set the variables to be saved + variables = save_variables(smus,user_functions,axes,variables,device) + + # Modify the fifth page for user + for i in range(8): + fifth_page[6+i,0].value = variables[i]['name'] + fifth_page[6+i,1].value = variables[i]['unit'] + + + # Start the measurement + device.single_measurement() + while device.operation_completed()==False: + pass + + device.autoscaling() + + # List all errors occured + counter,message = device.list_all_errors() + if counter>1: + error_box(message) + change_state(first_page,second_page,third_page,fourth_page,fifth_page) + return + + + # Sampling Measurement Mode