Skip to content
Snippets Groups Projects
Commit 11e9e3ea authored by Alexandros Asonitis's avatar Alexandros Asonitis
Browse files

ini files part 1

parent 36de4fcf
No related branches found
No related tags found
No related merge requests found
......@@ -173,6 +173,44 @@ def check_cons_smu_samp(smus:list):
return cons_smu_numbers
def load_ini():
root = tk.Tk()
root.withdraw()
root.lift() #show window above all other applications
root.attributes("-topmost", True)#window stays above all other applications
file = filedialog.askopenfilename(filetypes=[("Ini files","*.ini")],title ='Select ini file')
while file.endswith(".ini") == False:
#open again filedialog with error message box
answer=tk.messagebox.askyesno(message='Do you want to cancel the ini file load?')
if answer == True:
raise Exception("Ini File Operation aborted!")
else:
file = filedialog.askopenfilename(filetypes=[("Ini files","*.ini")],title = "Select ini file")
root.destroy()
return file
# Get measurement mode from ini file
def get_mode(sections):
for section in sections:
if "MEASUREMENT MODE:" in section:
mode = section.split(":")[1]
return mode
raise Exception("Meaurement mode not found ini file!")
def get_integration(sections):
for section in sections:
if "INTEGRATION TIME:" in section:
integration = section.split(":")[1]
return integration
raise Exception("Integration Time not found ini file!")
\ No newline at end of file
......@@ -24,9 +24,10 @@ tab.titles = titles
display(tab)
start = widgets.Button(description='Start Measurement')
ini = widgets.Button(description = 'Import from ini.')
output = widgets.Output()
display(start,output)
display(widgets.HBox([start,ini]),output)
device = hp4155a.HP4155a('GPIB0::17::INSTR')
......@@ -34,6 +35,8 @@ def on_start_clicked(b):
with output:
clear_output()
change_state(first_page,second_page,third_page,fourth_page,fifth_page)
start.disabled = True
ini.disabled = True
# Reset the device
device.reset()
......@@ -194,6 +197,8 @@ def on_start_clicked(b):
except Exception as e:
error_box(e)
change_state(first_page,second_page,third_page,fourth_page,fifth_page)
start.disabled = False
ini.disabled = False
return
......@@ -209,6 +214,8 @@ def on_start_clicked(b):
if counter>1:
error_box(message)
change_state(first_page,second_page,third_page,fourth_page,fifth_page)
start.disabled = False
ini.disabled = False
return
......@@ -384,6 +391,8 @@ def on_start_clicked(b):
except Exception as e:
error_box(e)
change_state(first_page,second_page,third_page,fourth_page,fifth_page)
start.disabled = False
ini.disabled = False
return
......@@ -399,6 +408,8 @@ def on_start_clicked(b):
if counter>1:
error_box(message)
change_state(first_page,second_page,third_page,fourth_page,fifth_page)
start.disabled = False
ini.disabled = False
return
......@@ -414,7 +425,7 @@ def on_start_clicked(b):
# Save results
df = pd.Dataframe(values)
filename = f"{sample_series}_{field}_{dut}_{measurement_name}_sweep.txt"
filename = f"{sample_series}_{field}_{dut}_{measurement_name}_sampling.txt"
txt_file = create_file(filename)
ini_file = os.path.splitext(txt_file)[0]+'.ini'
......@@ -544,6 +555,8 @@ def on_start_clicked(b):
if counter>1:
error_box(message)
change_state(first_page,second_page,third_page,fourth_page,fifth_page)
start.disabled = False
ini.disabled = False
return
filename = f"{sample_series}_{field}_{dut}_{measurement_name}_sweep.txt"
......@@ -594,9 +607,52 @@ def on_start_clicked(b):
# End of fuction
information_box("Measurement finished!")
change_state(first_page,second_page,third_page,fourth_page,fifth_page)
start.disabled = False
ini.disabled = False
return # just to be sure
def on_ini_clicked(b):
with output:
clear_output()
change_state(first_page,second_page,third_page,fourth_page,fifth_page)
start.disabled = True
ini.disabled = True
#load values to the interface
config = configparser.ConfigParser()
try:
file = load_ini()
except Exception as e:
error_box(e)
change_state(first_page,second_page,third_page,fourth_page,fifth_page)
start.disabled = False
ini.disabled = False
return
try:
# Now we do exactly the opposite thing dictionaries to widgets
#read the values from each section
config.read(file)
# Get the sections
sections = config.sections()
# Get the measurement Mode
measurement_mode = get_mode(sections)
# Get the constant smus
for j in range(1,5):
third_page[21,j].value = config.get(f"CONSTANT SMU{j}",'value')
third_page[22,j].value = config.get(f"CONSTANT SMU{j}",'comp')
if measurement_mode == 'SWEEP':
third_page[0,0].value = measurement_mode
third_page[0,1].value = get_integration(sections)
start.on_click(on_start_clicked)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment