moving config dialog to app_config

This commit is contained in:
2022-08-22 14:27:09 +02:00
parent 28c94dd297
commit d8b34a3f99
3 changed files with 213 additions and 218 deletions

View File

@@ -9,7 +9,9 @@ import logging
_log = logging.getLogger(__name__)
from PyQt5.QtCore import QSettings
from PyQt5.QtWidgets import QApplication, QLineEdit
import os, json, yaml
import GenericDialog
class AppCfg(QSettings):
@@ -175,3 +177,186 @@ class AppCfg(QSettings):
# return str(p)
def dlg_geometry(self,obj):
SPN=GenericDialog.Spinner
app=QApplication.instance()
cfg=app._cfg
w, h = map(float,cfg.value(AppCfg.GEO_BEAM_SZ))
d = GenericDialog.GenericDialog(
title="geometry",
message="Enter the size of the beam in microns",
inputs={
"bw": ("beam width um" ,w,SPN(w, min=1, max=200, suffix=" \u00B5m"),),
"bh": ("beam height um",h,SPN(h, min=1, max=200, suffix=" \u00B5m"),),
},
)
if d.exec():
results = d.results
_log.info("Updating beamsize to {}".format(results))
bm_sz= (results["bw"], results["bh"])
_log.debug("types {}".format(type(w)))
cfg.setValue(AppCfg.GEO_BEAM_SZ, bm_sz)
cfg.sync()
bm=obj._goBeamMarker
bm.setSize(bm_sz)
#self._beammark.set_beam_size((w, h))
def dlg_posttube_references(self):
SPN=GenericDialog.Spinner
app=QApplication.instance()
cfg=app._cfg
x_up = cfg.value(AppCfg.PST_X_UP , 0.0,type=float)
y_up = cfg.value(AppCfg.PST_Y_UP , 0.0,type=float)
x_down = cfg.value(AppCfg.PST_X_DOWN, 0.0,type=float)
y_down = cfg.value(AppCfg.PST_Y_DOWN, 0.0,type=float)
dx = cfg.value(AppCfg.PST_DX , 0.0,type=float)
dy = cfg.value(AppCfg.PST_DY , 0.0,type=float)
tz_in = cfg.value(AppCfg.PST_TZ_IN , 0.0,type=float)
tz_out = cfg.value(AppCfg.PST_TZ_OUT, 0.0,type=float)
d = GenericDialog.GenericDialog(
title="Post Sample Tube Configuration",
message="Enter the relative displacements for X and Y to move the post sample tube either in or out.",
inputs={
AppCfg.PST_X_UP : ("Up X" , x_up , SPN(x_up , decimals=3, min=-45.0, max=15.0, suffix=" mm"), ),
AppCfg.PST_Y_UP : ("Up Y" , y_up , SPN(y_up , decimals=3, min=-45.0, max=15.0, suffix=" mm"), ),
AppCfg.PST_X_DOWN: ("Down X" , x_down, SPN(x_down, decimals=3, min=-45.0, max=15.0, suffix=" mm"), ),
AppCfg.PST_Y_DOWN: ("Down Y" , y_down, SPN(y_down, decimals=3, min=-45.0, max=15.0, suffix=" mm"), ),
AppCfg.PST_DX : ("out delta X" , dx , SPN(dx , decimals=3, min=-32.0, max=32.0, suffix=" mm"), ),
AppCfg.PST_DY : ("out delta Y" , dy , SPN(dy , decimals=3, min=-32.0, max=32.0, suffix=" mm"), ),
AppCfg.PST_TZ_IN : ("tube Z in position" , tz_in , SPN(tz_in , decimals=3, min=-8.0 , max=1.0 , suffix=" mm"), ),
AppCfg.PST_TZ_OUT: ("tube Z OUT position", tz_out, SPN(tz_out, decimals=3, min=-8.0 , max=1.0 , suffix=" mm"), ),
},
)
if d.exec():
results = d.results
_log.info("setting post-sample-tube displacements {}".format(results))
for k, v in results.items():
cfg.setValue(k, v)
cfg.sync()
def dlg_collimator_reference_positions(self):
SPN=GenericDialog.Spinner
app=QApplication.instance()
cfg=app._cfg
x_out = cfg.value(AppCfg.COL_DX , 0.0,type=float)
y_out = cfg.value(AppCfg.COL_DY , 0.0,type=float)
x_in = cfg.value(AppCfg.COL_X_IN, 0.0,type=float)
y_in = cfg.value(AppCfg.COL_Y_IN, 0.0,type=float)
d = GenericDialog.GenericDialog(
title="Collimator configuration",
message="Enter reference positions for the collimator",
inputs={
AppCfg.COL_DX: ("Collimator out deltaX", x_out, SPN(x_out, decimals=3, min=-15.9, max=15.9, suffix=" mm"),),
AppCfg.COL_DY: ("Collimator out deltaY", y_out, SPN(y_out, decimals=3, min=-15.9, max=15.9, suffix=" mm"),),
AppCfg.COL_X_IN: ("Collimator in X", x_in, SPN(x_in, decimals=3, min=-15.9, max=15.9, suffix=" mm"),),
AppCfg.COL_Y_IN: ("Collimator in Y", y_in, SPN(y_in, decimals=3, min=-15.9, max=15.9, suffix=" mm"),),
},
)
if d.exec():
results = d.results
_log.info("setting collimator reference positions {}".format(results))
for k, v in results.items():
cfg.setValue(k, v)
cfg.sync()
def dlg_backlight_positions(self):
SPN=GenericDialog.Spinner
app=QApplication.instance()
cfg=app._cfg
p_in = cfg.value(AppCfg.BKLGT_IN,0,type=int)
p_out = cfg.value(AppCfg.BKLGT_OUT,0,type=int)
d = GenericDialog.GenericDialog(
title="Back Light configuration",
message="Enter reference positions for the backlight",
inputs={
AppCfg.BKLGT_IN: ("In position" , p_in , SPN(p_in, min=-30000, max=10), ),
AppCfg.BKLGT_OUT: ("Out position", p_out, SPN(p_out, min=-1000, max=10), ),
},
)
if d.exec():
results = d.results
_log.info("setting back light reference positions {}".format(results))
for k, v in results.items():
cfg.setValue(k, v)
cfg.sync()
def dlg_cryojet_positions(self):
p_in = settings.value(CRYOJET_NOZZLE_IN, type=float)
p_out = settings.value(CRYOJET_NOZZLE_OUT, type=float)
motion_enabled = option(CRYOJET_MOTION_ENABLED)
d = GenericDialog(
title="Cryojet Nozzle Configuration",
message="Enter reference positions for the cryojet nozzle position",
inputs={
CRYOJET_NOZZLE_IN: ("In position", p_in, Spinner(p_in, min=3, max=15)),
CRYOJET_NOZZLE_OUT: ("Out position",p_out,Spinner(p_out, min=-1000, max=10),),
CRYOJET_MOTION_ENABLED: ("Move Cryojet in Transitions",motion_enabled,Checkbox(motion_enabled, "move cryojet"),),
},
)
if d.exec():
results = d.results
_log.info("setting cryojet reference positions {}".format(results))
for k, v in results.items():
settings.setValue(k, v)
settings.sync()
def dlg_deltatau_parameters(self):
SPN=GenericDialog.Spinner
CB=GenericDialog.Checkbox
app=QApplication.instance()
cfg=app._cfg
#dt1 = cfg.value(AppCfg.DT_HOST,'SAR-CPPM-EXPMX1')
dt1 = cfg.value(AppCfg.DT_HOST,'localhost:10001:10002')
dt2 = cfg.value(AppCfg.DT_VEL_SCL, 1, type=float)
dt3 = cfg.option(AppCfg.DT_SHOW_PLOTS)
d = GenericDialog.GenericDialog(
title="Delta Tau Parameters",
message="These parameters affect the data collection.",
inputs={
AppCfg.DT_HOST:("host name (host[:port:port_gather])", dt1, QLineEdit(),),
AppCfg.DT_VEL_SCL: ("Velocity Scale (1=optimal, 0=zero vel at target)", dt2,SPN(dt2, min=0, max=1, suffix=""),),
AppCfg.DT_SHOW_PLOTS: ("show plots after collection", dt3,CB(dt3, "active"),),
#DELTATAU_SORT_POINTS: ("Sort pointshoot/prelocated coords", b,CB(b, "sort points"),),
},
)
if d.exec():
results = d.results
_log.info("setting delta tau parameters {}".format(results))
for k, v in results.items():
cfg.setValue(k, v)
cfg.sync()
def dlg_tell_mount_positions(self):
AUTODRY_ENABLED = "tell/autodry_enabled"
AUTODRY_MAXMOUNTS = "tell/autodry_max_number_of_mounts"
AUTODRY_MAXTIME = "tell/autodry_max_time"
SECS_HOURS = 60 * 60
enabled = option(AUTODRY_ENABLED)
maxtime = settings.value(AUTODRY_MAXTIME, type=float) / SECS_HOURS
maxmounts = settings.value(AUTODRY_MAXMOUNTS, type=int)
d = GenericDialog.GenericDialog(
title="TELL Settings",
message="These control some features of the TELL sample changer",
inputs={
AUTODRY_ENABLED: ("Auto dry", enabled,
Checkbox(enabled, "enabled")),
AUTODRY_MAXMOUNTS: ("Max. num. mounts between dry",maxmounts,
Spinner(maxmounts, decimals=0, min=1, max=100, suffix=" mounts"),),
AUTODRY_MAXTIME: ("Max. time between dry",maxtime,
Spinner(maxtime, decimals=1, min=0.5, max=5, suffix=" hours"),),
},
)
if d.exec():
results = d.results
_log.info("setting tell parameters {}".format(results))
for k, v in results.items():
if k == AUTODRY_MAXTIME:
v = v * SECS_HOURS
settings.setValue(k, v)
settings.sync()