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

Import from ini file seems to work!

parent 90ac0227
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id:6ef13cac-e600-42f8-a097-1c26e36fa733 tags:
``` python
import sys
sys.path.insert(0, './lib')
sys.path.insert(0, '..') #append parent directory
import os
import configparser
import warnings
import traceback
from interface import *
from help import *
import hp4155a
first_page = page_1()
second_page = page_2()
third_page = page_3()
fourth_page = page_4()
fifth_page = page_5()
titles = ["SMUs","User Functions","Parameters","Plotting","Save to file"]
children = [first_page,second_page,third_page,fourth_page,fifth_page]
tab = widgets.Tab()
tab.children = children
tab.titles = titles
display(tab)
start = widgets.Button(description='Start Measurement')
ini = widgets.Button(description = 'Import from ini. (Coming Soon)',style = {'description_width': 'initial'},layout=Layout(height='auto', width='auto'))
output = widgets.Output()
display(widgets.HBox([start,ini]),output)
```
%% Output
%% Cell type:code id:f5d81765-2cee-44ea-9e78-786f51d5366b tags:
``` python
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)
print(measurement_mode)
# 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)
# Get the SMU channels
for i in range(1,5):
first_page[i,1].value = config.get(f"SMU{i}",'vname')
first_page[i,2].value = config.get(f"SMU{i}",'iname')
first_page[i,3].value = config.get(f"SMU{i}",'mode')
first_page[i,4].value = config.get(f"SMU{i}",'func')
first_page[i,5].value = eval(config.get(f"SMU{i}",'disabled'))
# Get the maximum 6 user functions
for i in range(1,7):
if f"USER FUNCTION {i}" in sections:
second_page[i,0].value = config.get(f"USER FUNCTION {i}",'name')
second_page[i,1].value = config.get(f"USER FUNCTION {i}",'unit')
second_page[i,2].value = config.get(f"USER FUNCTION {i}",'expression')
# Get the Sweep units VAR1,VAR2,VARD, PULSE
# VAR1
third_page[4,0].value = config.get('VAR1','start')
third_page[5,0].value = config.get('VAR1','stop')
third_page[6,0].value = config.get('VAR1','step')
third_page[7,0].value = config.get('VAR1','comp')
third_page[8,0].value = config.get('VAR1','pcomp')
hyst = config.get('VAR1','mode')
if hyst == 'SING':
third_page[9,0].value = False
elif hyst == 'DOUB':
third_page[9,0].value = True
else:
raise Exception("Invalid Hysterisis Mode")
# VAR2
third_page[4,1].value = config.get('VAR2','start')
third_page[5,1].value = config.get('VAR2','step')
third_page[6,1].value = config.get('VAR2','points')
third_page[7,1].value = config.get('VAR2','comp')
third_page[8,1].value = config.get('VAR2','pcomp')
# VARD
third_page[4,2].value = config.get('VARD','offset')
third_page[5,2].value = config.get('VARD','ratio')
third_page[7,2].value = config.get('VARD','comp')
third_page[8,2].value = config.get('VARD','pcomp')
# PULSE
third_page[4,3].value = config.get('PULSE','period')
third_page[5,3].value = config.get('PULSE','width')
third_page[6,3].value = config.get('PULSE','base')
# Get the axes
for j in range(1,4):
fourth_page[1,j].value = config.get(f"AXIS {j}",'name')
fourth_page[2,j].value = config.get(f"AXIS {j}",'scale')
fourth_page[3,j].value = config.get(f"AXIS {j}",'min')
fourth_page[4,j].value = config.get(f"AXIS {j}",'max')
# Get the variables
for i in range(8):
if f"VARIABLE {i+1}" in sections:
fifth_page[6+i,0].value = config.get(f"VARIABLE {i+1}",'name')
fifth_page[6+i,1].value = config.get(f"VARIABLE {i+1}",'unit')
elif measurement_mode == 'SAMPLING':
third_page[0,0].value = measurement_mode
third_page[0,1].value = get_integration(sections)
# Get the SMU channels
for i in range(1,5):
first_page[i,1].value = config.get(f"SMU{i}",'vname')
first_page[i,2].value = config.get(f"SMU{i}",'iname')
first_page[i,3].value = config.get(f"SMU{i}",'mode')
first_page[i,4].value = config.get(f"SMU{i}",'func')
first_page[i,5].value = eval(config.get(f"SMU{i}",'disabled'))
# Get the maximum 6 user functions
for i in range(1,7):
if f"USER FUNCTION {i}" in sections:
second_page[i,0].value = config.get(f"USER FUNCTION {i}",'name')
second_page[i,1].value = config.get(f"USER FUNCTION {i}",'unit')
second_page[i,2].value = config.get(f"USER FUNCTION {i}",'expression')
# Get the sampling Parameters
third_page[12,0].value = config.get('SAMPLING PARAMETERS','mode')
third_page[13,0].value = config.get('SAMPLING PARAMETERS','interval')
third_page[16,0].value = config.get('SAMPLING PARAMETERS','hold')
third_page[14,0].value = config.get('SAMPLING PARAMETERS','points')
third_page[17,0].value = bool(config.get('SAMPLING PARAMETERS','filter'))
third_page[15,0].value = config.get('SAMPLING PARAMETERS','duration')
# Get the axes
for j in range(1,4):
fourth_page[1,j].value = config.get(f"AXIS {j}",'name')
fourth_page[2,j].value = config.get(f"AXIS {j}",'scale')
fourth_page[3,j].value = config.get(f"AXIS {j}",'min')
fourth_page[4,j].value = config.get(f"AXIS {j}",'max')
# Get the variables
for i in range(8):
if f"VARIABLE {i+1}" in sections:
fifth_page[6+i,0].value = config.get(f"VARIABLE {i+1}",'name')
fifth_page[6+i,1].value = config.get(f"VARIABLE {i+1}",'unit')
elif measurement_mode == 'STRESS':
third_page[0,0].value = measurement_mode
# There is no integration time
# Get the SMU channels
for i in range(1,5):
first_page[i,1].value = config.get(f"SMU{i}",'name')
# There is not iname
first_page[i,3].value = config.get(f"SMU{i}",'mode')
# Function is set automatically
first_page[i,5].value = eval(config.get(f"SMU{i}",'disabled'))
# Skip The user Functions
# Set the Stress parameters
third_page[15,0].value = config.get('PARAMETERS','stress time')
third_page[16,0].value = config.get('PARAMETERS','hold time')
third_page[17,0].value = bool(config.get('PARAMETERS','filter'))
# Skip the axes and variables
else:
raise Exception("MEASUREMENT MODE NOT FOUND!")
except Exception as e:
error_box(traceback.format_exc())
change_state(first_page,second_page,third_page,fourth_page,fifth_page)
start.disabled = False
ini.disabled = False
```
%% Cell type:code id:5eb42711-7725-435f-acb7-f8f08dbeeb3c tags:
``` python
ini.on_click(on_ini_clicked)
```
%% Cell type:code id:ee24c499-d47f-498d-9f32-6bd85ccb4b87 tags:
``` python
```
...@@ -4,6 +4,7 @@ sys.path.insert(0, '..') #append parent directory ...@@ -4,6 +4,7 @@ sys.path.insert(0, '..') #append parent directory
import os import os
import configparser import configparser
import warnings import warnings
import traceback
from interface import * from interface import *
from help import * from help import *
...@@ -24,7 +25,7 @@ tab.titles = titles ...@@ -24,7 +25,7 @@ tab.titles = titles
display(tab) display(tab)
start = widgets.Button(description='Start Measurement') start = widgets.Button(description='Start Measurement')
ini = widgets.Button(description = 'Import from ini. (Coming Soon)',style = {'description_width': 'initial'},layout=Layout(height='auto', width='auto')) ini = widgets.Button(description = 'Import from ini.')
output = widgets.Output() output = widgets.Output()
display(widgets.HBox([start,ini]),output) display(widgets.HBox([start,ini]),output)
...@@ -467,6 +468,9 @@ def on_start_clicked(b): ...@@ -467,6 +468,9 @@ def on_start_clicked(b):
for key,value in parameters.items(): for key,value in parameters.items():
config.set('SAMPLING PARAMETERS',key,str(value)) config.set('SAMPLING PARAMETERS',key,str(value))
# Sampling time
config.set('SAMPLING PARAMETERS','duration',str(duration))
# Now the constant smus # Now the constant smus
config.add_section('CONSTANT SMUS') config.add_section('CONSTANT SMUS')
for i, cons_smu in enumerate(cons_smus): for i, cons_smu in enumerate(cons_smus):
...@@ -608,9 +612,6 @@ def on_start_clicked(b): ...@@ -608,9 +612,6 @@ def on_start_clicked(b):
ini.disabled = False ini.disabled = False
return # just to be sure return # just to be sure
# This should be tested at the end.
# After the ini files have been created
"""
def on_ini_clicked(b): def on_ini_clicked(b):
with output: with output:
clear_output() clear_output()
...@@ -637,6 +638,8 @@ def on_ini_clicked(b): ...@@ -637,6 +638,8 @@ def on_ini_clicked(b):
sections = config.sections() sections = config.sections()
# Get the measurement Mode # Get the measurement Mode
measurement_mode = get_mode(sections) measurement_mode = get_mode(sections)
print(measurement_mode)
# Get the constant smus # Get the constant smus
for j in range(1,5): for j in range(1,5):
...@@ -648,6 +651,140 @@ def on_ini_clicked(b): ...@@ -648,6 +651,140 @@ def on_ini_clicked(b):
third_page[0,0].value = measurement_mode third_page[0,0].value = measurement_mode
third_page[0,1].value = get_integration(sections) third_page[0,1].value = get_integration(sections)
""" # Get the SMU channels
for i in range(1,5):
first_page[i,1].value = config.get(f"SMU{i}",'vname')
first_page[i,2].value = config.get(f"SMU{i}",'iname')
first_page[i,3].value = config.get(f"SMU{i}",'mode')
first_page[i,4].value = config.get(f"SMU{i}",'func')
first_page[i,5].value = eval(config.get(f"SMU{i}",'disabled'))
# Get the maximum 6 user functions
for i in range(1,7):
if f"USER FUNCTION {i}" in sections:
second_page[i,0].value = config.get(f"USER FUNCTION {i}",'name')
second_page[i,1].value = config.get(f"USER FUNCTION {i}",'unit')
second_page[i,2].value = config.get(f"USER FUNCTION {i}",'expression')
# Get the Sweep units VAR1,VAR2,VARD, PULSE
# VAR1
third_page[4,0].value = config.get('VAR1','start')
third_page[5,0].value = config.get('VAR1','stop')
third_page[6,0].value = config.get('VAR1','step')
third_page[7,0].value = config.get('VAR1','comp')
third_page[8,0].value = config.get('VAR1','pcomp')
hyst = config.get('VAR1','mode')
if hyst == 'SING':
third_page[9,0].value = False
elif hyst == 'DOUB':
third_page[9,0].value = True
else:
raise Exception("Invalid Hysterisis Mode")
# VAR2
third_page[4,1].value = config.get('VAR2','start')
third_page[5,1].value = config.get('VAR2','step')
third_page[6,1].value = config.get('VAR2','points')
third_page[7,1].value = config.get('VAR2','comp')
third_page[8,1].value = config.get('VAR2','pcomp')
# VARD
third_page[4,2].value = config.get('VARD','offset')
third_page[5,2].value = config.get('VARD','ratio')
third_page[7,2].value = config.get('VARD','comp')
third_page[8,2].value = config.get('VARD','pcomp')
# PULSE
third_page[4,3].value = config.get('PULSE','period')
third_page[5,3].value = config.get('PULSE','width')
third_page[6,3].value = config.get('PULSE','base')
# Get the axes
for j in range(1,4):
fourth_page[1,j].value = config.get(f"AXIS {j}",'name')
fourth_page[2,j].value = config.get(f"AXIS {j}",'scale')
fourth_page[3,j].value = config.get(f"AXIS {j}",'min')
fourth_page[4,j].value = config.get(f"AXIS {j}",'max')
# Get the variables
for i in range(8):
if f"VARIABLE {i+1}" in sections:
fifth_page[6+i,0].value = config.get(f"VARIABLE {i+1}",'name')
fifth_page[6+i,1].value = config.get(f"VARIABLE {i+1}",'unit')
elif measurement_mode == 'SAMPLING':
third_page[0,0].value = measurement_mode
third_page[0,1].value = get_integration(sections)
# Get the SMU channels
for i in range(1,5):
first_page[i,1].value = config.get(f"SMU{i}",'vname')
first_page[i,2].value = config.get(f"SMU{i}",'iname')
first_page[i,3].value = config.get(f"SMU{i}",'mode')
first_page[i,4].value = config.get(f"SMU{i}",'func')
first_page[i,5].value = eval(config.get(f"SMU{i}",'disabled'))
# Get the maximum 6 user functions
for i in range(1,7):
if f"USER FUNCTION {i}" in sections:
second_page[i,0].value = config.get(f"USER FUNCTION {i}",'name')
second_page[i,1].value = config.get(f"USER FUNCTION {i}",'unit')
second_page[i,2].value = config.get(f"USER FUNCTION {i}",'expression')
# Get the sampling Parameters
third_page[12,0].value = config.get('SAMPLING PARAMETERS','mode')
third_page[13,0].value = config.get('SAMPLING PARAMETERS','interval')
third_page[16,0].value = config.get('SAMPLING PARAMETERS','hold')
third_page[14,0].value = config.get('SAMPLING PARAMETERS','points')
third_page[17,0].value = bool(config.get('SAMPLING PARAMETERS','filter'))
third_page[15,0].value = config.get('SAMPLING PARAMETERS','duration')
# Get the axes
for j in range(1,4):
fourth_page[1,j].value = config.get(f"AXIS {j}",'name')
fourth_page[2,j].value = config.get(f"AXIS {j}",'scale')
fourth_page[3,j].value = config.get(f"AXIS {j}",'min')
fourth_page[4,j].value = config.get(f"AXIS {j}",'max')
# Get the variables
for i in range(8):
if f"VARIABLE {i+1}" in sections:
fifth_page[6+i,0].value = config.get(f"VARIABLE {i+1}",'name')
fifth_page[6+i,1].value = config.get(f"VARIABLE {i+1}",'unit')
elif measurement_mode == 'STRESS':
third_page[0,0].value = measurement_mode
# There is no integration time
# Get the SMU channels
for i in range(1,5):
first_page[i,1].value = config.get(f"SMU{i}",'name')
# There is not iname
first_page[i,3].value = config.get(f"SMU{i}",'mode')
# Function is set automatically
first_page[i,5].value = eval(config.get(f"SMU{i}",'disabled'))
# Skip The user Functions
# Set the Stress parameters
third_page[15,0].value = config.get('PARAMETERS','stress time')
third_page[16,0].value = config.get('PARAMETERS','hold time')
third_page[17,0].value = bool(config.get('PARAMETERS','filter'))
# Skip the axes and variables
else:
raise Exception("MEASUREMENT MODE NOT FOUND!")
except Exception as e:
error_box(traceback.format_exc())
change_state(first_page,second_page,third_page,fourth_page,fifth_page)
start.disabled = False
ini.disabled = False
start.on_click(on_start_clicked) start.on_click(on_start_clicked)
ini.on_click(on_ini_clicked)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment