rework config/parameter setting

This commit is contained in:
2022-09-05 10:30:48 +02:00
parent c11e0acfcd
commit 8fc532d3ae
2 changed files with 197 additions and 31 deletions

View File

@@ -598,6 +598,13 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
action.triggered.connect(cfg.dlg_deltatau_parameters)
self.menuAdvanced.addAction(action)
action = QAction("parameters", self)
action.setToolTip("modify application parameters")
action.setStatusTip("modify application parameters")
action.triggered.connect(lambda x: cfg.dlg_parameters(self))
self.menuAdvanced.addAction(action)
#action = QAction("Cryojet Reference Positions", self)
#action.setToolTip("Update the reference positions for the cryojet nozzle position")
#action.setStatusTip("Update the reference positions for the cryojet nozzle position")
@@ -887,32 +894,36 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
self._message_critical_fault.setText(msg)
def build_group_faststage(self, toolbox):
pfx=QApplication.instance()._cfg.value(AppCfg.GBL_DEV_PREFIX)[0]
qutilities.add_item_to_toolbox(toolbox,"Fast Stage",
widget_list=[
# self.get_tweaker('SAR-EXPMX:MOT_BLGT', alias='backlight', label='backlight'),
self.get_tweaker("SAR-EXPMX:MOT_FY", alias="fast_y", label="fast Y"),
self.get_tweaker("SAR-EXPMX:MOT_FX", alias="fast_x", label="fast X"),
self.get_tweaker("SAR-EXPMX:MOT_ROT_Y",alias="omega",label="omega",tweak_min=0.001,tweak_max=180.0,),
self.get_tweaker("SAR-EXPMX:MOT_CX", alias="base_x", label="base X"),
self.get_tweaker("SAR-EXPMX:MOT_CZ", alias="base_z", label="base Z"),
#self.get_tweaker('f"{pfx}:MOT_BLGT', alias='backlight', label='backlight'),
self.get_tweaker(f"{pfx}:MOT_FY", alias="fast_y", label="fast Y"),
self.get_tweaker(f"{pfx}:MOT_FX", alias="fast_x", label="fast X"),
self.get_tweaker(f"{pfx}:MOT_ROT_Y",alias="omega",label="omega",tweak_min=0.001,tweak_max=180.0,),
self.get_tweaker(f"{pfx}:MOT_CX", alias="base_x", label="base X"),
self.get_tweaker(f"{pfx}:MOT_CZ", alias="base_z", label="base Z"),
self.get_tweaker(f"{pfx}:MOT_DET_Z", alias="det_z", label="detector Z"),
],
)
def build_group_collimator(self, toolbox):
pfx=QApplication.instance()._cfg.value(AppCfg.GBL_DEV_PREFIX)[1]
qutilities.add_item_to_toolbox(toolbox,"Collimator",
widget_list=[
self.get_tweaker("SARES30-ESBMX1", alias="colli_x", label="colli X", mtype="smaract_motor",),
self.get_tweaker("SARES30-ESBMX2", alias="colli_y", label="colli Y", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}1", alias="colli_x", label="colli X", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}2", alias="colli_y", label="colli Y", mtype="smaract_motor",),
],
)
def build_group_posttube(self, toolbox):
pfx=QApplication.instance()._cfg.value(AppCfg.GBL_DEV_PREFIX)[1]
widgets = [
self.get_tweaker("SARES30-ESBMX4", alias="tube_usx", label="upstream X", mtype="smaract_motor",),
self.get_tweaker("SARES30-ESBMX6", alias="tube_usy", label="upstream Y", mtype="smaract_motor",),
self.get_tweaker("SARES30-ESBMX5", alias="tube_dsx", label="downstream X", mtype="smaract_motor",),
self.get_tweaker("SARES30-ESBMX7", alias="tube_dsy", label="downstream Y", mtype="smaract_motor",),
self.get_tweaker("SARES30-ESBMX8", alias="tube_z", label="tube Z", mtype="smaract_motor"),
self.get_tweaker(f"{pfx}4", alias="tube_usx", label="upstream X", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}6", alias="tube_usy", label="upstream Y", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}5", alias="tube_dsx", label="downstream X", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}7", alias="tube_dsy", label="downstream Y", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}8", alias="tube_z", label="tube Z", mtype="smaract_motor"),
]
c = QWidget()
c.setLayout(QGridLayout())
@@ -937,12 +948,13 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
toolbox.addItem(block, label)
def build_group_xeye(self, toolbox):
pfx=QApplication.instance()._cfg.value(AppCfg.GBL_DEV_PREFIX)[1]
qutilities.add_item_to_toolbox(
toolbox,
"X-Ray Eye",
widget_list=[
self.get_tweaker("SARES30-ESBMX14", alias="xeye_x", label="X", mtype="smaract_motor"),
self.get_tweaker("SARES30-ESBMX15", alias="xeye_y", label="Y", mtype="smaract_motor"),
self.get_tweaker(f"{pfx}14", alias="xeye_x", label="X", mtype="smaract_motor"),
self.get_tweaker(f"{pfx}15", alias="xeye_y", label="Y", mtype="smaract_motor"),
],
)
@@ -1516,8 +1528,9 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
self.close()
def cb_deltatau_home_faststages(self):
pfx=QApplication.instance()._cfg.value(AppCfg.GBL_DEV_PREFIX)[0]
_log.warning("homing fast stages")
epics.PV("SAR-EXPMX1:ASYN.AOUT").put(b"enable plc 1")
epics.PV(f"{pfx}1:ASYN.AOUT").put(b"enable plc 1")
def cb_testcode(self):
try:
@@ -2087,6 +2100,32 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
usy.move_rel(-tandem_twv)
dsy.move_rel(-tandem_twv)
def move_detector(self, pos):
#SAR-EXPMX: MOT_DET_Z.VAL
app=QApplication.instance()
cfg=app._cfg
det_z = self.tweakers["det_z"]
if AppCfg.DFT_POS_DET not in cfg.allKeys():
msg="detector default positions are not configured."
_log.warning(msg)
QMessageBox.warning(self, "configuration incomplete", msg)
return
pos = cfg.value(AppCfg.DFT_POS_DET)
_log.info("moving collimator {} to X,Y = {:.3f}, {:.3f}".format(pos, x_pos, y_pos))
if pos == "out":
cy.move_abs(y_pos+dy, assert_position=True)
cx.move_abs(x_pos+dx, assert_position=True)
elif pos == "in":
cx.move_abs(x_pos, assert_position=True)
cy.move_abs(y_pos, assert_position=True)
elif pos == "ready":
cx.move_abs(x_pos, assert_position=True)
cy.move_abs(y_pos+dy, assert_position=True)
else:
raise ValueError("Collimator position *{}* is not known!!")
def move_collimator(self, pos):
app=QApplication.instance()
cfg=app._cfg
@@ -2118,6 +2157,7 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
else:
raise ValueError("Collimator position *{}* is not known!!")
# **************** OBSOLETE AND/OR OLD STUFF ****************
@@ -2737,37 +2777,40 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
cx.move_abs(to_pos, assert_position=True)
def _OLD_build_cryo_group(self, toolbox):
pfx=QApplication.instance()._cfg.value(AppCfg.GBL_DEV_PREFIX)[0]
qutilities.add_item_to_toolbox(
toolbox,
"Cryojet",
widget_list=[
self.get_tweaker("SAR-EXPMX:MOT_CRYO", alias="cryo", label="cryo X")
self.get_tweaker(f"{pfx}:MOT_CRYO", alias="cryo", label="cryo X")
],
)
def _OLD_build_wegde_group(self, toolbox):
pfx=QApplication.instance()._cfg.value(AppCfg.GBL_DEV_PREFIX)[0]
qutilities.add_item_to_toolbox(toolbox,"Wedge Mover",
widget_list=[
self.get_tweaker("SAR-EXPMX:MOT_WEDGE1", alias="wedge_1", label="wedge_1"),
self.get_tweaker("SAR-EXPMX:MOT_WEDGE2", alias="wedge_2", label="wedge_2"),
self.get_tweaker("SAR-EXPMX:MOT_WEDGE3", alias="wedge_3", label="wedge_3"),
self.get_tweaker("SAR-EXPMX:MOT_WEDGE4", alias="wedge_4", label="wedge_4"),
self.get_tweaker("SAR-EXPMX:MOT_WEDGEX", alias="wedge_x", label="wedge_x"),
self.get_tweaker("SAR-EXPMX:MOT_WEDGEY", alias="wedge_y", label="wedge_y"),
self.get_tweaker("SAR-EXPMX:MOT_WEDGEA", alias="wedge_a", label="wedge_a"),
self.get_tweaker("SAR-EXPMX:MOT_WEDGEB", alias="wedge_b", label="wedge_b"),
self.get_tweaker(f"{pfx}:MOT_WEDGE1", alias="wedge_1", label="wedge_1"),
self.get_tweaker(f"{pfx}:MOT_WEDGE2", alias="wedge_2", label="wedge_2"),
self.get_tweaker(f"{pfx}:MOT_WEDGE3", alias="wedge_3", label="wedge_3"),
self.get_tweaker(f"{pfx}:MOT_WEDGE4", alias="wedge_4", label="wedge_4"),
self.get_tweaker(f"{pfx}:MOT_WEDGEX", alias="wedge_x", label="wedge_x"),
self.get_tweaker(f"{pfx}:MOT_WEDGEY", alias="wedge_y", label="wedge_y"),
self.get_tweaker(f"{pfx}:MOT_WEDGEA", alias="wedge_a", label="wedge_a"),
self.get_tweaker(f"{pfx}:MOT_WEDGEB", alias="wedge_b", label="wedge_b"),
],
)
def _OLD_build_slits_group(self, toolbox):
pfx=QApplication.instance()._cfg.value(AppCfg.GBL_DEV_PREFIX)[0]
qutilities.add_item_to_toolbox(
toolbox,
"Slits",
widget_list=[
self.get_tweaker("SARES30-ESBMX10", alias="slit_right", label="left", mtype="smaract_motor", ),
self.get_tweaker("SARES30-ESBMX11", alias="slit_left", label="right", mtype="smaract_motor",),
self.get_tweaker("SARES30-ESBMX12", alias="slit_bottom", label="bottom", mtype="smaract_motor",),
self.get_tweaker("SARES30-ESBMX13",alias="slit_top",label="top",mtype="smaract_motor",),
self.get_tweaker(f"{pfx}10", alias="slit_right", label="left", mtype="smaract_motor", ),
self.get_tweaker(f"{pfx}11", alias="slit_left", label="right", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}12", alias="slit_bottom", label="bottom", mtype="smaract_motor",),
self.get_tweaker(f"{pfx}13",alias="slit_top",label="top",mtype="smaract_motor",),
],
)